6#include <sll/math_tools.hpp>
8#include "ddc_aliases.hpp"
18 template <
class Gr
id1D>
26 static inline constexpr double s_2_pi = 2. * M_PI;
41 template <
class IdxRange>
55 Evaluator(
double c0,
double c1) : m_c0(c0), m_c1(c1) {}
71 void operator()(ddc::ChunkSpan<
double, ddc::DiscreteDomain<Grid1D>> chunk)
const
73 auto const& idx_range = chunk.idx_range();
75 for (ddc::DiscreteElement<Grid1D>
const i : idx_range) {
76 chunk(i) = eval(ddc::coordinate(i), 0);
86 double deriv(
double const x,
int const derivative)
const noexcept
88 return eval(x, derivative);
96 void deriv(ddc::ChunkSpan<
double, ddc::DiscreteDomain<Grid1D>> chunk,
int const derivative)
99 auto const& idx_range = chunk.idx_range();
101 for (ddc::DiscreteElement<Grid1D>
const i : idx_range) {
102 chunk(i) = eval(ddc::coordinate(i), derivative);
113 return ipow(s_2_pi * m_c0, diff);
117 double eval(
double const x,
int const derivative)
const noexcept
119 return ipow(s_2_pi * m_c0, derivative)
120 * std::cos(M_PI_2 * derivative + s_2_pi * (m_c0 * x + m_c1));
An analytical evaluator to be used for exact comparisons in tests.
Definition cosine_evaluator.hpp:20
double deriv(double const x, int const derivative) const noexcept
Evaluate the derivative of the equation at x.
Definition cosine_evaluator.hpp:86
double max_norm(int diff=0) const
The maximum norm of this equation.
Definition cosine_evaluator.hpp:111
Evaluator(IdxRange idx_range)
A constructor taking the range over which the evaluator will be applied.
Definition cosine_evaluator.hpp:42
void deriv(ddc::ChunkSpan< double, ddc::DiscreteDomain< Grid1D > > chunk, int const derivative) const
Evaluate the derivative of the equation at the positions on which chunk is defined.
Definition cosine_evaluator.hpp:96
Evaluator(double c0, double c1)
A constructor parametrising the equation.
Definition cosine_evaluator.hpp:55
Grid1D Dim
The grid dimension.
Definition cosine_evaluator.hpp:23
double operator()(double const x) const noexcept
Evaluate the equation at x.
Definition cosine_evaluator.hpp:62
void operator()(ddc::ChunkSpan< double, ddc::DiscreteDomain< Grid1D > > chunk) const
Evaluate the equation at the positions on which chunk is defined.
Definition cosine_evaluator.hpp:71
A wrapper around a cosine Evaluator that can be used in tests.
Definition cosine_evaluator.hpp:14