|
IBAMR
IBAMR version 0.19.
|
Implements the FAC iterative solution procedure for a linear system of equations, Au=f, defined on some subset of levels in an AMR patch hierarchy. More...
#include <ibtk/FACPreconditioner.h>

Public Member Functions | |
| FACPreconditioner (const std::string &name, FACOperatorStrategy< DIM > &user_ops, tbox::Pointer< tbox::Database > database=NULL) | |
| virtual | ~FACPreconditioner () |
| bool | solveSystem (SAMRAIVectorReal< DIM, double > &solution, SAMRAIVectorReal< DIM, double > &rhs) |
| Solve linear system Au=f using the FAC algorithm. More... | |
| void | initializeSolverState (const SAMRAIVectorReal< DIM, double > &solution, const SAMRAIVectorReal< DIM, double > &rhs) |
| Compute hierarchy-dependent data required for solving. More... | |
| void | deallocateSolverState () |
| Remove all hierarchy-dependent data computed by initializeSolverState() More... | |
| bool | checkVectorStateCompatibility (const SAMRAIVectorReal< DIM, double > &solution, const SAMRAIVectorReal< DIM, double > &rhs) const |
| Check compatibility of vectors with existing solver state. More... | |
Functions to set solving parameters. | |
| void | setPresmoothingSweeps (int num_pre_sweeps) |
| Set the number of pre-smoothing sweeps during FAC iteration process. More... | |
| void | setPostsmoothingSweeps (int num_post_sweeps) |
| Set the number of post-smoothing sweeps during FAC iteration process. More... | |
| void | setMaxCycles (int max_cycles) |
| Set the max number of iterations (cycles) to use per solve. More... | |
| void | setResidualTolerance (double residual_tol, double relative_residual_tol=-1.0) |
| Set the residual tolerance for stopping. More... | |
| void | setAlgorithmChoice (const std::string &choice) |
| Set the choice of FAC cycling algorithm to use. More... | |
| void | enableLogging (bool enabled=true) |
| Enable or disable logging. More... | |
Functions to get data on last solve. | |
| int | getNumberOfIterations () const |
| Return FAC iteration count from last (or current if there is one) FAC iteration process. More... | |
| void | getConvergenceFactors (double &avg_factor, double &final_factor) const |
| Get convergance rates of the last (or current if there is one) FAC solve. More... | |
| double | getNetConvergenceFactor () const |
| Get the net convergance rate of the last (or current if there is one) FAC solve. More... | |
| double | getAvgConvergenceFactor () const |
| Get the average convergance rates of the last (or current if there is one) FAC solve. More... | |
| double | getFinalConvergenceFactor () const |
| Get the final convergance rate of the last (or current if there is one) FAC solve. More... | |
| double | getResidualNorm () const |
| Return residual norm from the just-completed FAC iteration. More... | |
| virtual void | printClassData (std::ostream &os) const |
| Print data members for debugging. More... | |
Functions not implemented: | |
| std::string | d_object_name |
| Name of this FAC solver object. More... | |
| FACOperatorStrategy< DIM > & | d_fac_operator |
| Object providing problem-specific routines. More... | |
| FACPreconditioner (const FACPreconditioner< DIM > &) | |
| void | operator= (const FACPreconditioner< DIM > &) |
| void | getFromInput (tbox::Pointer< tbox::Database > database) |
| Set state using database. More... | |
| double | computeFullCompositeResidual (SAMRAIVectorReal< DIM, double > &residual, SAMRAIVectorReal< DIM, double > &solution, SAMRAIVectorReal< DIM, double > &rhs) |
| Compute composite residual on all levels and returns residual norm. More... | |
| void | facCycle_Recursive (SAMRAIVectorReal< DIM, double > &error, SAMRAIVectorReal< DIM, double > &residual, SAMRAIVectorReal< DIM, double > &solution, int lmax, int lmin, int ln) |
| Perform recursive FAC cycle iteration. More... | |
| void | facCycle_McCormick (SAMRAIVectorReal< DIM, double > &error, SAMRAIVectorReal< DIM, double > &residual, SAMRAIVectorReal< DIM, double > &solution, int lmax, int lmin, int ln) |
| Perform recursive FAC cycle iteration from McCormick. More... | |
| void | facCycle (SAMRAIVectorReal< DIM, double > &error, SAMRAIVectorReal< DIM, double > &residual, SAMRAIVectorReal< DIM, double > &solution, int lmax, int lmin) |
| Perform FAC cycle iteration. More... | |
The solution is found by applying an FAC algorithm to the composite grid represented in the hierarchy. After each FAC cycle the norm of the residual will be computed over all levels involved. The FAC iteration will stop when either the maximum number of iterations is reached, or the residual norm on all levels is below the given tolerance.
The user must perform the following steps to use the FAC solver:
| SAMRAI::solv::FACPreconditioner< DIM >::FACPreconditioner | ( | const std::string & | name, |
| FACOperatorStrategy< DIM > & | user_ops, | ||
| tbox::Pointer< tbox::Database > | database = NULL |
||
| ) |
Constructor.
| name | Object name |
| user_ops | Reference to user-specified FAC operator |
| database | Input database with initialization parameters |
|
virtual |
Virtual destructor.
|
private |
| bool SAMRAI::solv::FACPreconditioner< DIM >::solveSystem | ( | SAMRAIVectorReal< DIM, double > & | solution, |
| SAMRAIVectorReal< DIM, double > & | rhs | ||
| ) |
The return value is true if the solver converged and false otherwise. The problem-specific portions of the FAC procedure, including the definitions of A are provided by the FACOperatorStrategy<DIM> object passed to the constructor. More information about the iteration can be found by calling the functions getNumberOfIterations() and getResidualNorm() and by looking at the log information.
Before calling this function, the form of the solution and right-hand-side quantities should be set properly by the user on all patch interiors on the range of levels covered by the FAC iteration. All data in these vectors (that will be used by the FACOperatorStrategy implementation) should be allocated. Thus, the user is responsible for managing the storage for the solution and right-hand-side.
Conditions on arguments:
Upon return from this function, the solution vector will contain the result of the solve.
| solution | solution vector u |
| rhs | right hand side vector f |
See initializeSolverState() and deallocateSolverState() for opportunities to save overhead when using multiple consecutive solves.
| void SAMRAI::solv::FACPreconditioner< DIM >::initializeSolverState | ( | const SAMRAIVectorReal< DIM, double > & | solution, |
| const SAMRAIVectorReal< DIM, double > & | rhs | ||
| ) |
By default, the solveSystem() method computes some required hierarchy-dependent data before solving and removes that data after the solve. For multiple solves using the same hierarchy configuration, it is more efficient to manually compute, using initializeSolverState(), and remove, using deallocateSolverState(), the hierarchy-dependent data so that it is not done inside solveSystem(). If solveSystem() detects that the solver state is already initialized, it will NOT change the state.
The vector arguments for solveSystem() need not match those for initializeSolverState(). However, there must be a certain degree of similarity, including
When assertion checking is enabled, limited checking is done by solveSystem() to help ensure that of the vectors passed to solveSystem() is compatible with the existing state.
It is important to remember to reinitialize the solver state when your hierarchy configuration changes.
It is safe to initializeSolverState() when the state is already initialized (the state is deallocated and reinitialized).
Conditions on arguments:
To unset the data set in this function, see deallocateSolverState().
After setting data for the current object, this function calls the operator's corresponding function, FACOperatorStrategy<DIM>::initializeOperatorState() so that the operator object can take steps to remain in sync.
| solution | solution vector u |
| rhs | right hand side vector f |
| void SAMRAI::solv::FACPreconditioner< DIM >::deallocateSolverState | ( | ) |
Remove all hierarchy-dependent data set by initializeSolverState(). It is safe to call deallocateSolverState() even state is already deallocated.
After deallocating data for the current object, this function calls the operator's corresponding function, FACOperatorStrategy<DIM>::deallocateOperatorState() so that the operator object can take steps to remain in sync.
| bool SAMRAI::solv::FACPreconditioner< DIM >::checkVectorStateCompatibility | ( | const SAMRAIVectorReal< DIM, double > & | solution, |
| const SAMRAIVectorReal< DIM, double > & | rhs | ||
| ) | const |
Check whether the solution and residual vectors given are compatible with the existing solver state (solver state must be initialized). Compatibility means that the vectors are sufficiently similar with the vectors with which the state are initialized. Compatibility implies that the vectors may be used in solveSystem().
The checking is not perfect! Due to the possibility of user-defined patch data, data-dependent checks cannot be performed. It is possible that a false compatibility is returned.
| void SAMRAI::solv::FACPreconditioner< DIM >::setPresmoothingSweeps | ( | int | num_pre_sweeps | ) |
Presmoothing is applied during the fine-to-coarse phase of the iteration. The default is to use one sweep.
| num_pre_sweeps | Number of presmoothing sweeps |
| void SAMRAI::solv::FACPreconditioner< DIM >::setPostsmoothingSweeps | ( | int | num_post_sweeps | ) |
Postsmoothing is applied during the coarse-to-fine phase of the iteration. The default is to use one sweep.
| num_post_sweeps | Number of postsmoothing sweeps |
| void SAMRAI::solv::FACPreconditioner< DIM >::setMaxCycles | ( | int | max_cycles | ) |
| void SAMRAI::solv::FACPreconditioner< DIM >::setResidualTolerance | ( | double | residual_tol, |
| double | relative_residual_tol = -1.0 |
||
| ) |
The solution is considered converged if ||b-Ax|| <= residual_tol or ||b-Ax|| <= relative_residual_tol*||b||.
If you want the prescribed maximum number of cycles to always be taken, set both residual tolerances to negative numbers.
| void SAMRAI::solv::FACPreconditioner< DIM >::setAlgorithmChoice | ( | const std::string & | choice | ) |
For developer experimentation use only. All others should use the default choice.
| void SAMRAI::solv::FACPreconditioner< DIM >::enableLogging | ( | bool | enabled = true | ) |
Set streams to NULL to turn off output.
| enabled | Logging state. true=on, false=off. |
| int SAMRAI::solv::FACPreconditioner< DIM >::getNumberOfIterations | ( | ) | const |
| void SAMRAI::solv::FACPreconditioner< DIM >::getConvergenceFactors | ( | double & | avg_factor, |
| double & | final_factor | ||
| ) | const |
The convergence factor is the factor to which the residual has been reduced. The final factor is that from the last FAC cycle.
| avg_factor | average convergence factor over FAC cycles from last solve. |
| final_factor | convergence factor of the last FAC cycle |
| double SAMRAI::solv::FACPreconditioner< DIM >::getNetConvergenceFactor | ( | ) | const |
The net factor is the factor to which the residual has been reduced by the FAC cycles. It is (current residual)/( initial residual + epsilon), so it may not be accurate if the initial residual is very small.
| double SAMRAI::solv::FACPreconditioner< DIM >::getAvgConvergenceFactor | ( | ) | const |
The average factor is the net factor to the power of 1/(number of FAC cycles). It may not be accurate if the initial residual is very small.
| double SAMRAI::solv::FACPreconditioner< DIM >::getFinalConvergenceFactor | ( | ) | const |
The final factor is the factor to which the residual has been reduced by the last FAC cycle.
| double SAMRAI::solv::FACPreconditioner< DIM >::getResidualNorm | ( | ) | const |
The norm return value is computed as the maximum norm over all patch levels involved in the solve. The value corresponds to the norm applied in the user-defined residual computation.
The latest computed norm is the one returned.
|
virtual |
|
private |
|
private |
See the class description for the parameters that can be set from a database.
| database | Input database. If a NULL pointer is given, nothing is done. |
|
private |
Uses the FACOperatorStrategy<DIM>::computeResidualOnLevel() function provided by the operator object to compute per level residual. Perform coarsen residual operation to get fine-grid approximation of residual on to coarse grid.
The residual is r=f-Au.
| residual | residual vector r |
| solution | solution vector u |
| rhs | right hand side vector f |
|
private |
Do one FAC iteration of Ae=r system. The FAC algorithm modifies Ae=r on coarser levels so that each coarser level solves for the change in error of the next finer level, as is expected in the FAC algorithm.
The level number range lmax to lmin must exist in the vectors e and r.
Assumes:
| error | error vector e |
| residual | residual vector r |
| solution | solution vector u |
| lmax | finest level number |
| lmin | coarsest level number |
| ln | current level number |
|
private |
Do one FAC iteration of Ae=r system. The FAC algorithm modifies Ae=r on coarser levels so that each coarser level solves for the change in error of the next finer level, as is expected in the FAC algorithm.
The level number range lmax to lmin must exist in the vectors e and r.
Assumes:
| error | error vector e |
| residual | residual vector r |
| solution | solution vector u |
| lmax | finest level number |
| lmin | coarsest level number |
| ln | current level number |
|
private |
Do one FAC iteration of Ae=r system. The FAC algorithm modifies Ae=r on coarser levels so that each coarser level solves for the change in error of the next finer level, as is expected in the FAC algorithm.
The level number range lmax to lmin must exist in the vectors e and r.
Assumes:
|
private |
|
private |
tbox::Pointer is initialized by constructor never changes.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
The convergence factor stack is reset for each solve and contains the convergence factors for each FAC cycle.
|
private |
The average convergence factor computed from the current values in d_convergence_factor.
|
private |
The net convergence factor computed from the current values in d_convergence_factor.
|
private |
|
private |
|
private |
Timers for performance measurement.
1.8.17