Discontinuous Galerkin Library
#include "dg/algorithm.h"
|
\( A x = b\) More...
Classes | |
struct | dg::NestedGrids< Geometry, Matrix, Container > |
Hold nested grids and provide dg fast interpolation and projection matrices. More... | |
struct | dg::MultigridCG2d< Geometry, Matrix, Container > |
Solve. More... | |
Functions | |
template<class MatrixType0 , class ContainerType0 , class ContainerType1 , class MatrixType1 , class NestedGrids > | |
void | dg::nested_iterations (std::vector< MatrixType0 > &ops, ContainerType0 &x, const ContainerType1 &b, std::vector< MatrixType1 > &inverse_ops, NestedGrids &nested_grids) |
Full approximation nested iterations. More... | |
template<class NestedGrids , class MatrixType0 , class MatrixType1 , class MatrixType2 > | |
void | dg::multigrid_cycle (std::vector< MatrixType0 > &ops, std::vector< MatrixType1 > &inverse_ops_down, std::vector< MatrixType2 > &inverse_ops_up, NestedGrids &nested_grids, unsigned gamma, unsigned p) |
EXPERIMENTAL Full approximation multigrid cycle. More... | |
template<class MatrixType0 , class MatrixType1 , class MatrixType2 , class NestedGrids , class ContainerType0 , class ContainerType1 > | |
void | dg::full_multigrid (std::vector< MatrixType0 > &ops, ContainerType0 &x, const ContainerType1 &b, std::vector< MatrixType1 > &inverse_ops_down, std::vector< MatrixType2 > &inverse_ops_up, NestedGrids &nested_grids, unsigned gamma, unsigned mu) |
EXPERIMENTAL One Full multigrid cycle. More... | |
template<class NestedGrids , class MatrixType0 , class MatrixType1 , class MatrixType2 , class ContainerType0 , class ContainerType1 , class ContainerType2 > | |
void | dg::fmg_solve (std::vector< MatrixType0 > &ops, ContainerType0 &x, const ContainerType1 &b, std::vector< MatrixType1 > &inverse_ops_down, std::vector< MatrixType2 > &inverse_ops_up, NestedGrids &nested_grids, const ContainerType2 &weights, double eps, unsigned gamma) |
EXPERIMENTAL Full multigrid cycles. More... | |
\( A x = b\)
void dg::fmg_solve | ( | std::vector< MatrixType0 > & | ops, |
ContainerType0 & | x, | ||
const ContainerType1 & | b, | ||
std::vector< MatrixType1 > & | inverse_ops_down, | ||
std::vector< MatrixType2 > & | inverse_ops_up, | ||
NestedGrids & | nested_grids, | ||
const ContainerType2 & | weights, | ||
double | eps, | ||
unsigned | gamma | ||
) |
EXPERIMENTAL Full multigrid cycles.
ops | Index 0 is the MatrixType on the original grid, 1 on the half grid, 2 on the quarter grid, ... |
x | (read/write) contains initial guess on input and the solution on output |
b | The right hand side |
inverse_ops_down | a vector of inverse, smoothing operators (usually lambda functions combining operators and solvers) of size stages-1 |
inverse_ops_up | a vector of inverse, smoothing operators (usually lambda functions combining operators and solvers) of size stages |
nested_grids | provides projection and interapolation operations and workspace |
weights | Defines the error norm |
eps | relative and absolute error tolerance |
gamma | The shape of the multigrid cycle: typically 1 (V-cycle) or 2 (W-cycle) |
void dg::full_multigrid | ( | std::vector< MatrixType0 > & | ops, |
ContainerType0 & | x, | ||
const ContainerType1 & | b, | ||
std::vector< MatrixType1 > & | inverse_ops_down, | ||
std::vector< MatrixType2 > & | inverse_ops_up, | ||
NestedGrids & | nested_grids, | ||
unsigned | gamma, | ||
unsigned | mu | ||
) |
EXPERIMENTAL One Full multigrid cycle.
ops | Index 0 is the f on the original grid, 1 on the half grid, 2 on the quarter grid, ... |
x | (read/write) contains initial guess on input and the solution on output |
b | The right hand side |
inverse_ops_down | a vector of inverse, smoothing operators (usually lambda functions combining operators and solvers) of size stages-1 |
inverse_ops_up | a vector of inverse, smoothing operators (usually lambda functions combining operators and solvers) of size stages |
nested_grids | provides projection and interapolation operations and workspace |
gamma | The shape of the multigrid cycle: typically 1 (V-cycle) or 2 (W-cycle) |
mu | The repetition of the multigrid cycle (1 is typically ok) |
MatrixType | Any class for which a specialization of TensorTraits exists and defines a tensor_category derived from AnyMatrixTag . Furthermore, any functor/lambda type with signature void operator()( const ContainerType0&, ContainerType1&) . For example
SelfMadeMatrixTag only those blas2 functions that have a corresponding member function in the Matrix class (e.g. symv( const ContainerType0&, ContainerType1&); ) can be called. If a Container has the RecursiveVectorTag , then the matrix is applied to each of the elements unless the type has the SelfMadeMatrixTag or is a Functor type. |
ContainerType | Any class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag . Among others
ContainerTypes in the argument list, then TensorTraits must exist for all of them |
void dg::multigrid_cycle | ( | std::vector< MatrixType0 > & | ops, |
std::vector< MatrixType1 > & | inverse_ops_down, | ||
std::vector< MatrixType2 > & | inverse_ops_up, | ||
NestedGrids & | nested_grids, | ||
unsigned | gamma, | ||
unsigned | p | ||
) |
EXPERIMENTAL Full approximation multigrid cycle.
Compute \( x_0^h \leftarrow C_{\nu_1}^{\nu_2}(x_0^h, b^h)\) for given \( b^h\) and initial guess \( x_0^h\):
Note that we need to save the initial guess \( w_0^h := x_0^h\) in a multigrid cycle because we need it to compute the error for the next upper level.
This algorithm forms the core of multigrid algorithms.
ops | Index 0 is the Operator on the original grid, 1 on the half grid, 2 on the quarter grid, ... |
inverse_ops_down | a vector of inverse, smoothing operators (usually lambda functions combining operators and solvers) of size stages-1 |
inverse_ops_up | a vector of inverse, smoothing operators (usually lambda functions combining operators and solvers) of size stages |
nested_grids | provides projection and interapolation operations and workspace |
gamma | The shape of the multigrid cycle: typically 1 (V-cycle) or 2 (W-cycle) |
p | The current stage h |
MatrixType | Any class for which a specialization of TensorTraits exists and defines a tensor_category derived from AnyMatrixTag . Furthermore, any functor/lambda type with signature void operator()( const ContainerType0&, ContainerType1&) . For example
SelfMadeMatrixTag only those blas2 functions that have a corresponding member function in the Matrix class (e.g. symv( const ContainerType0&, ContainerType1&); ) can be called. If a Container has the RecursiveVectorTag , then the matrix is applied to each of the elements unless the type has the SelfMadeMatrixTag or is a Functor type. |
ContainerType | Any class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag . Among others
ContainerTypes in the argument list, then TensorTraits must exist for all of them |
void dg::nested_iterations | ( | std::vector< MatrixType0 > & | ops, |
ContainerType0 & | x, | ||
const ContainerType1 & | b, | ||
std::vector< MatrixType1 > & | inverse_ops, | ||
NestedGrids & | nested_grids | ||
) |
Full approximation nested iterations.
Solve \( f(x_0^{h}) = b^{h}\) for given \( b^h\) and initial guess \( x_0^h\):
This algorithm is equivalent to a multigrid V-cycle with zero down-grid smoothing and infinite (i.e. solving) upgrid smoothing.
ops | Operators f on the various grids, i.e. dg::apply( ops[0], x, b) computes b = f(x). Index 0 is on the original grid, 1 on the half grid, 2 on the quarter grid, ... |
x | (read/write) contains initial guess on input and the solution on output (if the initial guess is good enough the solve may return immediately) |
b | The right hand side |
inverse_ops | a vector of inverse operators f^{-1} , i.e. dg::apply( inverse_ops[0], b, x) computes \( x = f^{-1}(b)\) (usually lambda functions combining operators and solvers). On call x contains the initial guess and should contain the solution on return. |
nested_grids | provides projection and interapolation operations and workspace |
MatrixType | Any class for which a specialization of TensorTraits exists and defines a tensor_category derived from AnyMatrixTag . Furthermore, any functor/lambda type with signature void operator()( const ContainerType0&, ContainerType1&) . For example
SelfMadeMatrixTag only those blas2 functions that have a corresponding member function in the Matrix class (e.g. symv( const ContainerType0&, ContainerType1&); ) can be called. If a Container has the RecursiveVectorTag , then the matrix is applied to each of the elements unless the type has the SelfMadeMatrixTag or is a Functor type. |
ContainerType | Any class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag . Among others
ContainerTypes in the argument list, then TensorTraits must exist for all of them |