6#ifndef IPPL_POISSON_CG_H
7#define IPPL_POISSON_CG_H
17#define IPPL_SOLVER_OPERATOR_WRAPPER(fun, type) \
22 template <
typename FieldLHS,
typename FieldRHS = FieldLHS>
24 using Tlhs =
typename FieldLHS::value_type;
28 constexpr static unsigned Dim = FieldLHS::dim;
30 using OperatorRet = UnaryMinus<detail::meta_laplace<lhs_type>>;
31 using LowerRet = UnaryMinus<detail::meta_lower_laplace<lhs_type>>;
32 using UpperRet = UnaryMinus<detail::meta_upper_laplace<lhs_type>>;
40 static_assert(std::is_floating_point<Tlhs>::value,
"Not a floating point type");
47 static_assert(std::is_floating_point<Tlhs>::value,
"Not a floating point type");
57 if (solver_type ==
"preconditioned") {
61 std::string preconditioner_type =
65 int inner = this->
params_m.template
get<int>(
"gauss_seidel_inner_iterations");
66 int outer = this->
params_m.template
get<int>(
"gauss_seidel_outer_iterations");
68 int richardson_iterations =
77 for (
unsigned int d = 0; d <
Dim; ++d) {
80 double local_min = 4 / std::pow(h, 2);
83 for (
unsigned int i = 1; i < n; ++i) {
84 test = 4. / std::pow(h, 2) * std::pow(std::sin(i * M_PI * h / 2.), 2);
85 if (test > local_max) {
88 if (test < local_min) {
103 preconditioner_type, level, degree, richardson_iterations, inner, outer,
106 algo_m->setPreconditioner(
113 preconditioner_type, level, degree, richardson_iterations, inner, outer,
153 this->
params_m.add(
"max_iterations", 2000);
155 this->
params_m.add(
"solver",
"non-preconditioned");
#define IPPL_SOLVER_OPERATOR_WRAPPER(fun, type)
detail::meta_upper_laplace< Field > upper_laplace(Field &u)
detail::meta_upper_and_lower_laplace< Field > upper_and_lower_laplace_no_comm(Field &u)
detail::meta_lower_laplace< Field > lower_laplace(Field &u)
double negative_inverse_diagonal_laplace(Field &u)
detail::meta_upper_laplace< Field > upper_laplace_no_comm(Field &u)
double diagonal_laplace(Field &u)
detail::meta_grad< Field > grad(Field &u)
detail::meta_laplace< Field > laplace(Field &u)
detail::meta_lower_laplace< Field > lower_laplace_no_comm(Field &u)
KOKKOS_INLINE_FUNCTION auto & get(Tuple< Ts... > &t)
Accessor function to get an element mutable reference at a specific index from a Tuple.
detail::meta_upper_and_lower_laplace< Field > upper_and_lower_laplace(Field &u)
Layout_t & getLayout() const
KOKKOS_INLINE_FUNCTION Mesh_t & get_mesh() const
FieldLayout< Dim > Layout_t
virtual KOKKOS_INLINE_FUNCTION const vector_type & getMeshSpacing() const =0
KOKKOS_INLINE_FUNCTION const vector_type & getGridsize() const
UnaryMinus< detail::meta_upper_laplace< lhs_type > > UpperRet
UnaryMinus< detail::meta_upper_and_lower_laplace< lhs_type > > UpperAndLowerRet
static constexpr unsigned Dim
typename Field< T, Dim >::value_type Tlhs
double InverseDiagonalRet
UnaryMinus< detail::meta_lower_laplace< lhs_type > > LowerRet
void setDefaultParameters() override
std::unique_ptr< CG< OperatorRet, LowerRet, UpperRet, UpperAndLowerRet, InverseDiagonalRet, DiagRet, Field< T, Dim >, Field_t< Dim > > > algo_m
UnaryMinus< detail::meta_laplace< lhs_type > > OperatorRet
PoissonCG(lhs_type &lhs, rhs_type &rhs)
void setSolver(lhs_type lhs)
Poisson< Field< T, Dim >, Field_t< Dim > > Base