7template<
class Implicit,
class Solver>
10 Adaptor( Implicit& im, Solver& solver) : m_im(im), m_solver(solver){}
11 template<
class ContainerType,
class value_type>
12 void operator()( value_type t,
const ContainerType& x, ContainerType& y)
16 template<
class ContainerType,
class value_type>
17 void operator()( value_type alpha, value_type t, ContainerType& y,
const ContainerType& yp)
19 m_solver.solve( alpha, m_im, t, y, yp);
58template<
class ContainerType>
85 template<
class Implicit>
87 unsigned max_iter,
value_type eps): m_max_iter(max_iter)
89 m_im = [&im = im](
value_type t,
const ContainerType&
y, ContainerType&
97 m_solve = [ &
weights = im.weights(), &precond = im.precond(), pcg =
99 (
const std::function<void(
const ContainerType&,ContainerType&)>&
100 wrapper, ContainerType&
y,
const ContainerType& ys)
mutable
102 return pcg.solve( wrapper,
y, ys, precond,
weights, eps);
106 template<
class ...Params>
121 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
123 auto wrapper = [a = alpha, t = time, &i = m_im](
const auto&
x,
auto&
y){
128 if(m_benchmark) ti.
tic();
130 unsigned number = m_solve( wrapper,
y, ys);
134 DG_RANK0 std::cout <<
"# of pcg iterations time solver: "
135 <<number<<
"/"<<m_max_iter<<
" took "<<ti.
diff()<<
"s\n";
139 std::function<void(
value_type,
const ContainerType&, ContainerType&)>
141 std::function< unsigned (
const std::function<
void(
const
142 ContainerType&,ContainerType&)>&, ContainerType&,
143 const ContainerType&)> m_solve;
145 bool m_benchmark =
true;
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
MPI_Vector< thrust::host_vector< real_type > > weights(const aRealMPITopology2d< real_type > &g)
Nodal weight coefficients.
Definition: mpi_weights.h:22
typename TensorTraits< std::decay_t< Vector > >::value_type get_value_type
Definition: tensor_traits.h:38
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
PCG Solver class for solving .
Definition: implicit.h:60
DefaultSolver()
No memory allocation.
Definition: implicit.h:64
ContainerType container_type
Definition: implicit.h:61
DefaultSolver(Implicit &im, const ContainerType ©able, unsigned max_iter, value_type eps)
Definition: implicit.h:86
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition: implicit.h:107
void set_benchmark(bool benchmark)
Set or unset performance timings during iterations.
Definition: implicit.h:114
get_value_type< ContainerType > value_type
Definition: implicit.h:62
void operator()(value_type alpha, value_type time, ContainerType &y, const ContainerType &ys)
Definition: implicit.h:116
Simple tool for performance measuring.
Definition: dg_doc.h:445
double diff() const
Return time in seconds elapsed between tic and toc.
#define DG_RANK0
Definition: typedefs.h:147