Class mgrid::NonlinearMultigrid
ClassList > mgrid > NonlinearMultigrid
Nonlinear full-approximation-scheme (FAS) multigrid solver. More...
#include <multigrid_nonlinear.hpp>
Inherits the following classes: mgrid::MultigridBase
Public Attributes inherited from mgrid::MultigridBase
| Type | Name |
|---|---|
| int | coarsestLevel Level index of the coarsest grid (always 0). |
| int | finestLevel Level index of the finest grid. |
Public Functions
| Type | Name |
|---|---|
| NonlinearMultigrid (const Settings & settings) Builds the solver state from settings . |
|
| virtual void | multigrid () override Runs the FAS full-multigrid cycle. |
| ~NonlinearMultigrid () override Defaulted polymorphic destructor. |
Public Functions inherited from mgrid::MultigridBase
| Type | Name |
|---|---|
| MultigridBase (const Settings & settings) Builds the solver state from settings . |
|
| virtual double | differential_operator (Level level, int i, int j) = 0 Evaluates the discrete PDE operator at one grid point. |
| void | evaluate_operator (Level level, FDArray & result) Evaluates the discrete operator over result . |
| void | evaluate_residual (Level level, FDArray & result) Evaluates the residual source - operator(solution) overresult . |
| virtual std::string | filename (std::string root="") = 0 Builds the output file name for this problem. |
| bool | fully_periodic () const True when both axes of the grid hierarchy wrap periodically. |
| FDArray & | get_result () The current solution on the finest grid. |
| void | initial_guess (T arg) Sets the finest-level initial guess and flags it as provided. |
| virtual void | multigrid () Runs the multigrid cycle. |
| void | relax (Level level, unsigned long n) Smooths solution[level] with a fixed number of sweeps. |
| void | relax (Level level, double tolerance) Smooths solution[level] until the relative change falls belowtolerance ormaxIterations sweeps have run. |
| virtual void | relaxation_updater (Level level, int i, int j) = 0 Applies one in-place relaxation update at a single grid point. |
| virtual void | solve () Solves the problem. |
| FDArray & | source_term () Accesses the finest-level source term. |
| void | source_term (T arg) Sets the finest-level source term and flags it as provided. |
| virtual void | write (int numOfVariables, std::string root="") Writes the finest-level solution (and optional derived fields) to a netCDF-4 file. |
| virtual | ~MultigridBase () = default Defaulted polymorphic destructor. |
Protected Attributes
| Type | Name |
|---|---|
| Stack | rightHandSide Per-level right-hand side (vestigial; retained from the legacy class). |
| Stack | truncError Per-level relative truncation error L R u - R L u . |
Protected Attributes inherited from mgrid::MultigridBase
| Type | Name |
|---|---|
| const double | aspect Domain aspect ratio. |
| const int | cycleType FMG cycle type (V / W / three). |
| bool | initialIsSet = {false}Has an initial guess been provided? |
| const unsigned long | maxIterations Cap on relax-to-tolerance sweeps. |
| int | nxfine = {0} |
| int | nzfine = {0}Finest-grid extents (rows, columns). |
| const unsigned long | postRelax Post-correction relaxation sweeps. |
| const unsigned long | preRelax Pre-correction relaxation sweeps. |
| const double | residualTolerance Convergence tolerance for the solver. |
| Stack | solution |
| Stack | source |
| bool | sourceIsSet = {false}Has a source term been provided? |
| Stack | temp Solution, source and scratch grid hierarchies. |
Protected Functions inherited from mgrid::MultigridBase
| Type | Name |
|---|---|
| void | mark_source_set () Flags the source term as set without touching its array. |
| virtual void | on_cycle_end (double residual_norm) |
Detailed Description
Drives a nonlinear elliptic PDE to its discrete solution with a full multigrid cycle in which every level carries the full solution (not just a correction): the solution and source are restricted down the hierarchy, the coarsest level is solved, and each successively finer level is reached by interpolation followed by Settings::mgCycleType FAS cycles. On the downstroke each coarse level is given a corrected right-hand side R f + (L R u - R L u) (the relative-truncation-error correction) so that the coarse problem shares the fine solution as its fixed point; the upstroke applies the coarse-grid correction I (u_2h - R u_h). A concrete subclass supplies the discrete PDE by overriding differential_operator, relaxation_updater and filename; this class only implements the cycle.
Note:
Modernised from the 2011 mgrid::NonlinearMultigrid: the finestLevel / coarsestLevel locals that shadowed the MultigridBase members are dropped (the base's members are used directly), not is spelled !, and the commented-out dead blocks are removed. The cycle body is otherwise transcribed verbatim from multigrid_nonlinear.cpp.
Public Functions Documentation
function NonlinearMultigrid
Builds the solver state from settings .
inline explicit mgrid::NonlinearMultigrid::NonlinearMultigrid (
const Settings & settings
)
Parameters:
settingssolver configuration, forwarded toMultigridBase; also sizes the extratruncErrorandrightHandSidegrid hierarchies.
function multigrid
Runs the FAS full-multigrid cycle.
virtual void mgrid::NonlinearMultigrid::multigrid () override
Note:
No-op unless a source term has been provided. Restricts the solution and source to the coarsest level, solves there, then sweeps up the hierarchy running Settings::mgCycleType FAS cycles at each level.
Note:
FAS: coarse levels carry a corrected right-hand side R f + (L R u - R L u), so the coarse operator has the restricted fine solution as its fixed point.
Implements mgrid::MultigridBase::multigrid
function ~NonlinearMultigrid
Defaulted polymorphic destructor.
mgrid::NonlinearMultigrid::~NonlinearMultigrid () override
Protected Attributes Documentation
variable rightHandSide
Per-level right-hand side (vestigial; retained from the legacy class).
Stack mgrid::NonlinearMultigrid::rightHandSide;
variable truncError
Per-level relative truncation error L R u - R L u .
Stack mgrid::NonlinearMultigrid::truncError;
The documentation for this class was generated from the following file include/multigrid/multigrid_nonlinear.hpp