10 template <
typename FieldLHS,
typename FieldRHS>
16 template <
typename FieldLHS,
typename FieldRHS>
26 std::array<bool, Dim> isParallel = layout_r.
isParallel();
27 for (
unsigned d = 0; d <
Dim; ++d) {
29 originComplex[d] = 0.0;
40 mesh_type meshComplex(domainComplex, hComplex, originComplex);
52 template <
typename FieldLHS,
typename FieldRHS>
62 using vector_type =
typename mesh_type::vector_type;
68 for (
size_t d = 0; d <
Dim; ++d) {
70 rmax[d] = origin[d] + (N[d] * hx[d]);
81 KOKKOS_LAMBDA(
const index_array_type& args) {
83 for (
unsigned d = 0; d <
Dim; ++d) {
84 iVec[d] += lDomComplex[d].first();
89 for (
size_t d = 0; d <
Dim; ++d) {
91 bool shift = (iVec[d] > (N[d] / 2));
92 kVec[d] = 2 *
pi / Len * (iVec[d] - shift * N[d]);
96 for (
unsigned d = 0; d <
Dim; ++d) {
97 Dr += kVec[d] * kVec[d];
100 bool isNotZero = (Dr != 0.0);
101 scalar_type factor = isNotZero * (1.0 / (Dr + ((!isNotZero) * 1.0)));
103 apply(view, args) *= factor;
116 auto viewRhs = this->
rhs_mp->getView();
117 auto viewLhs = this->
lhs_mp->getView();
118 const int nghostL = this->
lhs_mp->getNghost();
120 for (
size_t gd = 0; gd <
Dim; ++gd) {
122 "Gradient FFTPeriodicPoissonSolver",
getRangePolicy(view, nghost),
123 KOKKOS_LAMBDA(
const index_array_type& args) {
125 for (
unsigned d = 0; d <
Dim; ++d) {
126 iVec[d] += lDomComplex[d].first();
131 for (
size_t d = 0; d <
Dim; ++d) {
133 bool shift = (iVec[d] > (N[d] / 2));
134 bool notMid = (iVec[d] != (N[d] / 2));
137 kVec[d] = notMid * 2 *
pi / Len * (iVec[d] - shift * N[d]);
141 for (
unsigned d = 0; d <
Dim; ++d) {
142 Dr += kVec[d] * kVec[d];
147 bool isNotZero = (Dr != 0.0);
148 scalar_type factor = isNotZero * (1.0 / (Dr + ((!isNotZero) * 1.0)));
150 apply(tempview, args) *= -(imag * kVec[gd] * factor);
156 "Assign Gradient FFTPeriodicPoissonSolver",
158 KOKKOS_LAMBDA(
const index_array_type& args) {
159 apply(viewLhs, args)[gd] =
apply(viewRhs, args);
167 throw IpplException(
"FFTPeriodicPoissonSolver::solve",
"Unrecognized output_type");
void initialize(int &argc, char *argv[], MPI_Comm comm)
KOKKOS_INLINE_FUNCTION constexpr decltype(auto) apply(const View &view, const Coords &coords)
RangePolicy< View::rank, typenameView::execution_space, PolicyArgs... >::policy_type getRangePolicy(const View &view, int shift=0)
void parallel_for(const std::string &name, const ExecPolicy &policy, const FunctorType &functor)
KOKKOS_INLINE_FUNCTION auto & get(Tuple< Ts... > &t)
Accessor function to get an element mutable reference at a specific index from a Tuple.
const NDIndex< Dim > & getDomain() const
std::array< bool, Dim > isParallel() const
CxField_t tempFieldComplex_m
typename FieldLHS::Mesh_t::vector_type vector_type
std::shared_ptr< FFT_t > fft_mp
typename FFT_t::Complex_t Complex_t
Vector< Trhs, Dim > Vector_t
void setRhs(rhs_type &rhs) override
std::shared_ptr< Layout_t > layoutComplex_mp
FieldLayout< Dim > Layout_t
typename FieldRHS::Mesh_t mesh_type
typename FieldLHS::Mesh_t::value_type scalar_type
static constexpr unsigned Dim
virtual void setRhs(rhs_type &rhs)
::ippl::Vector< index_type, Dim > index_array_type