PCG Solver class for solving \( (y-\alpha\hat I(t,y)) = \rho\).
More...
template<class ContainerType>
struct dg::DefaultSolver< ContainerType >
PCG Solver class for solving \( (y-\alpha\hat I(t,y)) = \rho\).
for given t, alpha and rho. \( \hat I\) must be linear self-adjoint positive definite as it uses a conjugate gradient solver to invert the equation.
- Note
- This struct is a simple wrapper. It exists because self-adjoint operators appear quite often in practice and is not actually the recommended default way of writing a solver for the implicit time part. It is better to start with the following code and adapt from there
ContainerType& ys) mutable
{
auto wrapper = [a = alpha, t = time, &i = im](
const auto&
x,
auto&
y){
i( t, x, y);
};
pcg.solve( wrapper, y, ys, im.precond(), im.weights(), eps);
};
Preconditioned conjugate gradient method to solve .
Definition: pcg.h:57
void copy(const ContainerTypeIn &source, ContainerTypeOut &target)
Definition: blas1.h:164
void axpby(get_value_type< ContainerType > alpha, const ContainerType1 &x, get_value_type< ContainerType > beta, ContainerType &y)
Definition: blas1.h:231
get_value_type< ContainerType > value_type
Definition: implicit.h:62
- See also
- In general it is recommended to write your own solver using a wrapper lambda like the above and one of the existing solvers like
dg::PCG
, dg::LGMRES
or dg::AndersonAcceleration
- Template Parameters
-
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
dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them |
- See also
- See The dg dispatch system for a detailed explanation of our type dispatch system
-
ImExMultistep ImplicitMultistep ARKStep DIRKStep
◆ container_type
template<class ContainerType >
◆ value_type
template<class ContainerType >
◆ DefaultSolver() [1/2]
template<class ContainerType >
◆ DefaultSolver() [2/2]
template<class ContainerType >
template<class Implicit >
it does not matter what values copyable
contains, but its size is important; the solve
method can only be called with vectors of the same size)
- Template Parameters
-
Implicit | The self-adjoint, positive definite implicit part of the right hand side. Has signature void operator()(value_type, const ContainerType&, ContainerType&) The first argument is the time, the second is the input vector, which the functor may not override, and the third is the output, i.e. y' = I(t, y) translates to I(t, y, y'). The two ContainerType arguments never alias each other in calls to the functor. Also needs the WeightType weights() and PreconditionerType precond() member functions. |
- Parameters
-
im | The implicit part of the differential equation. Stored as a std::function . |
- Attention
- make sure that im lives throughout the lifetime of this object, else we'll get a dangling reference
- Parameters
-
copyable | forwarded to constructor of dg::PCG |
max_iter | maximum iteration number in cg, forwarded to constructor of dg::PCG |
eps | relative and absolute accuracy parameter, used in the solve method of dg::PCG |
◆ construct()
template<class ContainerType >
template<class ... Params>
Perfect forward parameters to one of the constructors.
- Template Parameters
-
Params | deduced by the compiler |
- Parameters
-
ps | parameters forwarded to constructors |
◆ operator()()
template<class ContainerType >
◆ set_benchmark()
template<class ContainerType >
Set or unset performance timings during iterations.
- Parameters
-
benchmark | If true, additional output will be written to std::cout during solution |
The documentation for this struct was generated from the following file: