Skip to content

Class mgrid::Stack

ClassList > mgrid > Stack

Grid-level hierarchy for a multigrid solve. More...

  • #include <stack.hpp>

Public Attributes

Type Name
BoundaryConditions boundaryConditions
Finest-level master boundary conditions.
const Level finestLevel
Level index of the finest grid ( numberOfGrids - 1 ).

Public Static Attributes

Type Name
Level coarsestLevel = 0
Level index of the coarsest grid (always 0).

Public Functions

Type Name
Stack (const Settings & s)
Builds the grid hierarchy described by s .
const Axis & axis (int d) const
The x ( d == 0 ) or z (d == 1 ) grid axis, taken from the coarsest level.
std::vector< FDArray >::iterator begin ()
Iterator to the coarsest level (enables range- for ).
std::vector< FDArray >::const_iterator begin () const
Const iterator to the coarsest level (enables range- for ).
void coarsen (Level level)
Restricts level level onto levellevel - 1 in place.
void coarsen (Level level, FDArray & result)
Restricts level level intoresult .
std::vector< FDArray >::iterator end ()
One-past-the-finest-level iterator (enables range- for ).
std::vector< FDArray >::const_iterator end () const
Const one-past-the-finest-level iterator (enables range- for ).
void inject (Level level)
Injects level level onto levellevel - 1 in place.
void inject (Level level, FDArray & result)
Injects level level intoresult .
FDArray & operator[] (Level l)
Mutable access to the grid at level l .
const FDArray & operator[] (Level l) const
Read-only access to the grid at level l .
void propagate_boundary_conditions ()
Down-samples the finest-level boundary conditions onto every coarser level at stride 2.
void refine (Level level)
Interpolates level level onto levellevel + 1 in place.
void refine (Level level, FDArray & result)
Interpolates level level intoresult .
Level size () const
Number of grid levels in the hierarchy.

Detailed Description

Composes a std::vector< FDArray > of grid levels (level 0 is the coarsest, finestLevel the finest). A bounded axis refines n -> 2*(n-1)+1 per level; a periodic axis refines n -> 2*n and requires an even minimumResolution. Unlike the legacy class this does not inherit from std::vector.

Public Attributes Documentation

variable boundaryConditions

Finest-level master boundary conditions.

BoundaryConditions mgrid::Stack::boundaryConditions;


variable finestLevel

Level index of the finest grid ( numberOfGrids - 1 ).

const Level mgrid::Stack::finestLevel;


Public Static Attributes Documentation

variable coarsestLevel

Level index of the coarsest grid (always 0).

Level mgrid::Stack::coarsestLevel;


Public Functions Documentation

function Stack

Builds the grid hierarchy described by s .

explicit mgrid::Stack::Stack (
    const Settings & s
) 

Parameters:

  • s solver settings (grid count, coarsest resolution, aspect ratio)

Postcondition:

Every level is sized and zeroed; boundaryConditions holds the default finest-level pattern.


function axis

The x ( d == 0 ) or z (d == 1 ) grid axis, taken from the coarsest level.

inline const Axis & mgrid::Stack::axis (
    int d
) const

Parameters:

  • d axis selector: 0 for the x axis, anything else for the z axis

Returns:

const reference to that level-0 Axis (point count, spacing, periodicity); every level shares the same periodicity.


function begin [1/2]

Iterator to the coarsest level (enables range- for ).

inline std::vector< FDArray >::iterator mgrid::Stack::begin () 

Returns:

begin iterator over the levels


function begin [2/2]

Const iterator to the coarsest level (enables range- for ).

inline std::vector< FDArray >::const_iterator mgrid::Stack::begin () const

Returns:

const begin iterator over the levels


function coarsen [1/2]

Restricts level level onto levellevel - 1 in place.

void mgrid::Stack::coarsen (
    Level level
) 

Parameters:

  • level finer level whose data is restricted; the result is written to level level - 1

Note:

Applies restriction_operator from level level to level level - 1.


function coarsen [2/2]

Restricts level level intoresult .

void mgrid::Stack::coarsen (
    Level level,
    FDArray & result
) 

Parameters:

  • level finer level whose data is restricted
  • result destination grid on the coarser level, overwritten with the restricted field

Note:

Applies restriction_operator from level level into result.


function end [1/2]

One-past-the-finest-level iterator (enables range- for ).

inline std::vector< FDArray >::iterator mgrid::Stack::end () 

Returns:

end iterator over the levels


function end [2/2]

Const one-past-the-finest-level iterator (enables range- for ).

inline std::vector< FDArray >::const_iterator mgrid::Stack::end () const

Returns:

const end iterator over the levels


function inject [1/2]

Injects level level onto levellevel - 1 in place.

void mgrid::Stack::inject (
    Level level
) 

Parameters:

  • level finer level whose data is injected to level level - 1

Note:

Applies injection_operator (no averaging); used by the FAS solver for the solution transfer.


function inject [2/2]

Injects level level intoresult .

void mgrid::Stack::inject (
    Level level,
    FDArray & result
) 

Parameters:

  • level finer level whose data is injected
  • result destination grid on the coarser level, overwritten

Note:

Applies injection_operator from level level into result.


function operator[]

Mutable access to the grid at level l .

inline FDArray & mgrid::Stack::operator[] (
    Level l
) 

Parameters:

  • l level index (coarsestLevel .. finestLevel)

Returns:

reference to that level's FDArray


function operator[]

Read-only access to the grid at level l .

inline const FDArray & mgrid::Stack::operator[] (
    Level l
) const

Parameters:

  • l level index (coarsestLevel .. finestLevel)

Returns:

const reference to that level's FDArray


function propagate_boundary_conditions

Down-samples the finest-level boundary conditions onto every coarser level at stride 2.

void mgrid::Stack::propagate_boundary_conditions () 

Note:

The finest level receives an explicit copy of boundaryConditions; each coarser level L rebuilds every edge as coarse[k] = finer[2*k] (stride 2 from level L + 1), sized to that level's edge extent. An edge whose finest-level condition is periodic is instead filled with a length-matched run of periodicCondition (no value sampling). The copies are computed ONCE: no live aliasing, so mutating Stack::boundaryConditions afterwards does not auto-propagate — a caller must re-invoke propagate_boundary_conditions() (spec §5.5).


function refine [1/2]

Interpolates level level onto levellevel + 1 in place.

void mgrid::Stack::refine (
    Level level
) 

Parameters:

  • level coarser level whose data is interpolated; the result is written to level level + 1

Note:

Applies interpolation_operator from level level to level level + 1.


function refine [2/2]

Interpolates level level intoresult .

void mgrid::Stack::refine (
    Level level,
    FDArray & result
) 

Parameters:

  • level coarser level whose data is interpolated
  • result destination grid on the finer level, overwritten with the interpolated field

Note:

Applies interpolation_operator from level level into result.


function size

Number of grid levels in the hierarchy.

inline Level mgrid::Stack::size () const

Returns:

the level count



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