Skip to content

Class mgrid::LinearMultigrid

ClassList > mgrid > LinearMultigrid

Linear full-multigrid (FMG) solver. More...

  • #include <multigrid_linear.hpp>

Inherits the following classes: mgrid::MultigridBase

Public Attributes inherited from mgrid::MultigridBase

See 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
LinearMultigrid (const Settings & settings)
Builds the solver state from settings .
virtual void multigrid () override
Runs the full-multigrid cycle.
~LinearMultigrid () override
Defaulted polymorphic destructor.

Public Functions inherited from mgrid::MultigridBase

See 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 inherited from mgrid::MultigridBase

See 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

See 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 constant-coefficient linear PDE to its discrete solution with a full-multigrid cycle: the right-hand side is restricted down the hierarchy, the coarsest level is solved, and each successively finer level is reached by interpolation followed by Settings::mgCycleType correction cycles (V / W / three). 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::LinearMultigrid: the finestLevel / coarsestLevel locals that shadowed the MultigridBase members are dropped (the base's members, set from solution in the constructor, are used directly) and not is spelled !. The cycle body is otherwise transcribed verbatim from multigrid_linear.cpp.

Public Functions Documentation

function LinearMultigrid

Builds the solver state from settings .

inline explicit mgrid::LinearMultigrid::LinearMultigrid (
    const Settings & settings
) 

Parameters:

  • settings solver configuration, forwarded to MultigridBase.

function multigrid

Runs the full-multigrid cycle.

virtual void mgrid::LinearMultigrid::multigrid () override

Note:

No-op unless a source term has been provided. Restricts the right-hand side to the coarsest level, solves it, then sweeps up the hierarchy running a full-multigrid V/W cycle (per Settings::mgCycleType) at each level before a final post-correction smooth on the finest grid.

Implements mgrid::MultigridBase::multigrid


function ~LinearMultigrid

Defaulted polymorphic destructor.

mgrid::LinearMultigrid::~LinearMultigrid () override



The documentation for this class was generated from the following file include/multigrid/multigrid_linear.hpp