ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
PoissonSolverFFT.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
25
26#include "greens_function.hpp"
27
30#if defined(__CUDACC__)
33#endif
34
35#include <utils/Vector.hpp>
36
37#include <blockforest/communication/UniformBufferedScheme.h>
38#include <domain_decomposition/BlockDataID.h>
39#include <field/AddToStorage.h>
40#include <field/GhostLayerField.h>
41#include <field/communication/PackInfo.h>
42#include <field/vtk/VTKWriter.h>
43#include <stencil/D3Q27.h>
44#include <waLBerlaDefinitions.h>
45#if defined(__CUDACC__)
46#include <gpu/AddGPUFieldToStorage.h>
47#include <gpu/FieldAccessor.h>
48#include <gpu/FieldIndexing.h>
49#include <gpu/GPUField.h>
50#include <gpu/HostFieldAllocator.h>
51#include <gpu/Kernel.h>
52#include <gpu/communication/MemcpyPackInfo.h>
53#include <gpu/communication/UniformGPUScheme.h>
54#endif
55
56#if defined(__clang__)
57#pragma clang diagnostic push
58#pragma clang diagnostic ignored "-Wfloat-conversion"
59#pragma clang diagnostic ignored "-Wimplicit-float-conversion"
60#elif defined(__GNUC__) or defined(__GNUG__)
61#pragma GCC diagnostic push
62#pragma GCC diagnostic ignored "-Wfloat-conversion"
63#endif
64
65#include <heffte.h>
66#include <heffte_backends.h>
67#include <heffte_geometry.h>
68
69#if defined(__clang__)
70#pragma clang diagnostic pop
71#elif defined(__GNUC__) or defined(__GNUG__)
72#pragma GCC diagnostic pop
73#endif
74
75#include <algorithm>
76#include <array>
77#include <complex>
78#include <cstddef>
79#include <functional>
80#include <memory>
81#include <optional>
82#include <string>
83#include <type_traits>
84#include <utility>
85#include <vector>
86
87namespace walberla {
88
89template <typename T, std::size_t N>
90auto to_array(Utils::Vector<T, N> const &vec) {
91 std::array<T, N> res{};
92 std::ranges::copy(vec, res.begin());
93 return res;
94}
95
96inline int pos_to_linear_index(int x, int y, int z, auto const &dim) {
97 return (z * dim[1] + y) * dim[0] + x;
98}
99
100template <typename FloatType, lbmpy::Arch Architecture>
102private:
103 template <typename T> FloatType FloatType_c(T t) {
104 return numeric_cast<FloatType>(t);
105 }
106
107protected:
108 template <typename FT, lbmpy::Arch AT = lbmpy::Arch::CPU> struct FieldTrait {
109 using ComplexType = std::complex<FloatType>;
110 using PotentialField = field::GhostLayerField<FT, 1u>;
111 using PotentialFieldVTK = field::GhostLayerField<FT, 1u>;
112 template <class Field>
113 using PackInfo = field::communication::PackInfo<Field>;
114 template <class Stencil>
116 blockforest::communication::UniformBufferedScheme<Stencil>;
117 };
118
119#if defined(__CUDACC__)
120 template <typename FT> struct FieldTrait<FT, lbmpy::Arch::GPU> {
121 using ComplexType = std::conditional_t<std::is_same_v<FloatType, float>,
122 cufftComplex, cufftDoubleComplex>;
123 using PotentialField = gpu::GPUField<FT>;
124 using PotentialFieldVTK = field::GhostLayerField<FT, 1u>;
125 template <class Field>
126 using PackInfo = gpu::communication::MemcpyPackInfo<Field>;
127 template <class Stencil>
128 using FullCommunicator = gpu::communication::UniformGPUScheme<Stencil>;
129 };
130#endif
131
132public:
138 FieldTrait<FloatType,
139 Architecture>::template FullCommunicator<stencil::D3Q27>;
140 template <class Field>
141 using PackInfo =
143
144protected:
145 template <typename ComplexType> struct heffte_container {
146#if defined(__CUDACC__)
147 using backend = heffte::backend::cufft;
148#else // __CUDACC__
149 using backend = heffte::backend::fftw;
150#endif // __CUDACC__
151 std::unique_ptr<heffte::box3d<>> box_in;
152 std::unique_ptr<heffte::box3d<>> box_out;
153 std::unique_ptr<heffte::fft3d<backend>> fft;
154 std::unique_ptr<heffte::fft3d<backend>::buffer_container<ComplexType>>
156
157 heffte_container(heffte::plan_options const &options,
158 auto const &grid_range) {
159 auto const offset_vec = Utils::Vector3i({1, 1, 1});
160 auto const order = Utils::Vector3i({0, 1, 2});
161 box_in = std::make_unique<heffte::box3d<>>(
162 to_array(Utils::Vector3i(grid_range.first)),
163 to_array(grid_range.second - offset_vec), to_array(order));
164 box_out = std::make_unique<heffte::box3d<>>(
165 to_array(Utils::Vector3i(grid_range.first)),
166 to_array(grid_range.second - offset_vec), to_array(order));
167 fft = std::make_unique<heffte::fft3d<backend>>(*box_in, *box_out,
168 MPI_COMM_WORLD, options);
169 buffer = std::make_unique<
170 heffte::fft3d<backend>::buffer_container<ComplexType>>(
171 fft->size_workspace());
172 }
173 };
174
175private:
176 BlockDataID m_potential_field_with_ghosts_id;
177#if defined(__CUDACC__)
178 BlockDataID m_potential_field_id;
179 BlockDataID m_greens_function_field_id;
180 BlockDataID m_potential_fourier_id;
181#endif // __CUDACC__
182
183 std::unique_ptr<heffte_container<ComplexType>> heffte;
184 std::shared_ptr<FullCommunicator> m_full_communication;
185
186#if defined(__CUDACC__)
187 std::optional<BlockDataID> m_potential_cpu_field_id;
188 std::shared_ptr<gpu::HostFieldAllocator<FloatType>> m_host_field_allocator;
189
190 using GreenFunctionField = gpu::GPUField<FloatType>;
191 using PotentialFourier = gpu::GPUField<ComplexType>;
192
193 walberla::gpu::Kernel<void (*)(walberla::gpu::FieldAccessor<ComplexType>,
194 walberla::gpu::FieldAccessor<FloatType>)>
195 kernel_greens;
196 walberla::gpu::Kernel<void (*)(walberla::gpu::FieldAccessor<FloatType>,
197 walberla::gpu::FieldAccessor<FloatType>)>
198 kernel_move_fields;
199#else // __CUDACC__
200 std::vector<FloatType> m_greens;
201 std::vector<FloatType> m_potential;
202 std::vector<ComplexType> m_potential_fourier;
203#endif // __CUDACC__
204
205public:
206 ~PoissonSolverFFT() override = default;
207 PoissonSolverFFT(std::shared_ptr<LatticeWalberla> lattice,
208 double permittivity)
209 : PoissonSolver(std::move(lattice), permittivity)
210#if defined(__CUDACC__)
211 ,
212 kernel_greens(gpu::make_kernel(
213 multiply_by_greens_function<FloatType, ComplexType>)),
214 kernel_move_fields(gpu::make_kernel(move_field<FloatType>))
215#endif
216 {
217 auto blocks = get_lattice().get_blocks();
218#if defined(__CUDACC__)
219 m_potential_field_id = gpu::addGPUFieldToStorage<PotentialField>(
220 blocks, "potential field", 1u, field::fzyx, 0u, false);
221 m_potential_field_with_ghosts_id =
222 gpu::addGPUFieldToStorage<PotentialField>(
223 blocks, "potential field with ghosts", 1u, field::fzyx,
224 get_lattice().get_ghost_layers());
225 m_greens_function_field_id = gpu::addGPUFieldToStorage<GreenFunctionField>(
226 blocks, "greens function", 1u, field::fzyx, 0u, false);
227 m_potential_fourier_id = gpu::addGPUFieldToStorage<PotentialFourier>(
228 blocks, "fourier field", 1u, field::fzyx, 0u, false);
229
230 auto const grid_range = get_lattice().get_local_grid_range();
231 auto const global_dim = get_lattice().get_grid_dimensions();
232 for (auto &block : *blocks) {
233 auto green_field = block.template getData<GreenFunctionField>(
234 m_greens_function_field_id);
235 auto kernel = gpu::make_kernel(create_greens_function<FloatType>);
236 kernel.addFieldIndexingParam(
237 gpu::FieldIndexing<FloatType>::xyz(*green_field));
238 kernel.addParam(grid_range.first[0]);
239 kernel.addParam(grid_range.first[1]);
240 kernel.addParam(grid_range.first[2]);
241 kernel.addParam(grid_range.second[0]);
242 kernel.addParam(grid_range.second[1]);
243 kernel.addParam(grid_range.second[2]);
244 kernel.addParam(global_dim[0]);
245 kernel.addParam(global_dim[1]);
246 kernel.addParam(global_dim[2]);
247 kernel();
248
249 auto potential =
250 block.template getData<PotentialField>(m_potential_field_id);
251 auto potential_ghosts = block.template getData<PotentialField>(
252 m_potential_field_with_ghosts_id);
253 auto green = block.template getData<GreenFunctionField>(
254 m_greens_function_field_id);
255 auto fourier =
256 block.template getData<PotentialFourier>(m_potential_fourier_id);
257
258 kernel_greens =
259 gpu::make_kernel(multiply_by_greens_function<FloatType, ComplexType>);
260 kernel_greens.addFieldIndexingParam(
261 gpu::FieldIndexing<ComplexType>::allInner(*fourier));
262 kernel_greens.addFieldIndexingParam(
263 gpu::FieldIndexing<FloatType>::allInner(*green));
264
265 kernel_move_fields = gpu::make_kernel(move_field<FloatType>);
266 kernel_move_fields.addFieldIndexingParam(
267 gpu::FieldIndexing<FloatType>::xyz(*potential_ghosts));
268 kernel_move_fields.addFieldIndexingParam(
269 gpu::FieldIndexing<FloatType>::xyz(*potential));
270 }
271
272 m_host_field_allocator =
273 std::make_shared<gpu::HostFieldAllocator<FloatType>>();
274#else // __CUDACC__
275 m_potential_field_with_ghosts_id = field::addToStorage<PotentialField>(
276 blocks, "potential field with ghosts", 0., field::fzyx,
277 get_lattice().get_ghost_layers());
278#endif // __CUDACC__
279
280 m_full_communication = std::make_shared<FullCommunicator>(blocks);
281 m_full_communication->addPackInfo(
282 std::make_shared<PackInfo<PotentialField>>(
283 m_potential_field_with_ghosts_id));
284 }
285
286 [[nodiscard]] bool is_gpu() const noexcept override {
287 return Architecture == lbmpy::Arch::GPU;
288 }
289
290 [[nodiscard]] bool is_double_precision() const noexcept override {
291 return std::is_same_v<FloatType, double>;
292 }
293
294 std::size_t get_potential_field_id() const noexcept override {
295 return static_cast<std::size_t>(m_potential_field_with_ghosts_id);
296 }
297
298 void setup_fft([[maybe_unused]] bool use_gpu_aware) override {
299 auto const grid_range = get_lattice().get_local_grid_range();
300 heffte::plan_options options = heffte::default_options<
302#if defined(__CUDACC__)
303 if constexpr (Architecture == lbmpy::Arch::GPU) {
304 options.use_reorder = false;
305 options.algorithm = heffte::reshape_algorithm::p2p_plined;
306 options.use_pencils = true;
307 options.use_gpu_aware = use_gpu_aware;
308 }
309#endif
310 heffte =
311 std::make_unique<heffte_container<ComplexType>>(options, grid_range);
312#if not defined(__CUDACC__)
313 if constexpr (Architecture == lbmpy::Arch::CPU) {
314 m_potential = std::vector<FloatType>(heffte->fft->size_inbox());
315 m_greens = std::vector<FloatType>(heffte->fft->size_outbox());
316 m_potential_fourier =
317 std::vector<ComplexType>(heffte->fft->size_outbox());
318 auto const dim = grid_range.second - grid_range.first;
319 auto const global_dim = get_lattice().get_grid_dimensions();
320 for (int x = 0; x < dim[0]; x++) {
321 for (int y = 0; y < dim[1]; y++) {
322 for (int z = 0; z < dim[2]; z++) {
323 m_greens[pos_to_linear_index(x, y, z, dim)] =
324 greens_function<FloatType>(x + grid_range.first[0],
325 y + grid_range.first[1],
326 z + grid_range.first[2], global_dim);
327 }
328 }
329 }
330 }
331#endif
333 }
334
335 [[nodiscard]] std::optional<double>
337 bool consider_ghosts = false) override {
338 auto bc = get_block_and_cell(get_lattice(), node, consider_ghosts);
339
340 if (not bc or get_potential_field_id() == 0u)
341 return std::nullopt;
342
343 auto const potential_field = bc->block->template getData<PotentialField>(
344 m_potential_field_with_ghosts_id);
345 return {double_c(
346 walberla::ek::accessor::Scalar::get(potential_field, bc->cell))};
347 }
348
349 [[nodiscard]] std::vector<double>
351 Utils::Vector3i const &upper_corner) const override {
352 std::vector<double> out;
353 uint_t values_size{0u};
354 auto const &lattice = get_lattice();
355 if (auto const ci = get_interval(lattice, lower_corner, upper_corner)) {
356 out = std::vector<double>(ci->numCells());
357 for (auto &block : *lattice.get_blocks()) {
358 auto const block_offset = lattice.get_block_corner(block, true);
359 if (auto const bci = get_block_interval(
360 lattice, lower_corner, upper_corner, block_offset, block)) {
361 auto const potential_field = block.template getData<PotentialField>(
362 m_potential_field_with_ghosts_id);
363 auto const values = ek::accessor::Scalar::get(potential_field, *bci);
364 assert(values.size() == bci->numCells());
365 values_size += bci->numCells();
366 auto kernel = [&values, &out](unsigned const block_index,
367 unsigned const local_index,
368 Utils::Vector3i const &) {
369 out[local_index] = double_c(values[block_index]);
370 };
371
372 copy_block_buffer(*bci, *ci, block_offset, lower_corner, kernel);
373 }
374 }
375 assert(values_size == ci->numCells());
376 }
377 return out;
378 }
379
380 void solve() override {
381#if not defined(__CUDACC__)
382 if constexpr (Architecture == lbmpy::Arch::CPU) {
383 auto grid_range = get_lattice().get_local_grid_range();
384 auto dim = grid_range.second - grid_range.first;
385 heffte->fft->forward(m_potential.data(), m_potential_fourier.data(),
386 heffte->buffer->data());
387 std::ranges::transform(m_potential_fourier, m_greens,
388 m_potential_fourier.begin(), std::multiplies<>{});
389 heffte->fft->backward(m_potential_fourier.data(), m_potential.data(),
390 heffte->buffer->data());
391
392 for (auto &block : *get_lattice().get_blocks()) {
393 auto potential_with_ghosts = block.template getData<PotentialField>(
394 m_potential_field_with_ghosts_id);
395 for (int x = 0; x < dim[0]; x++) {
396 for (int y = 0; y < dim[1]; y++) {
397 for (int z = 0; z < dim[2]; z++) {
398 potential_with_ghosts->get(x, y, z) =
399 m_potential[pos_to_linear_index(x, y, z, dim)];
400 }
401 }
402 }
403 }
404 }
405#endif
406#if defined(__CUDACC__)
407 if constexpr (Architecture == lbmpy::Arch::GPU) {
408 for (auto &block : *get_lattice().get_blocks()) {
409 auto potential =
410 block.template getData<PotentialField>(m_potential_field_id);
411 auto fourier =
412 block.template getData<PotentialFourier>(m_potential_fourier_id);
413 FloatType *_data_potential = potential->dataAt(0, 0, 0, 0);
414 ComplexType *_data_fourier = fourier->dataAt(0, 0, 0, 0);
415 heffte->fft->forward(_data_potential, _data_fourier,
416 heffte->buffer->data());
417 kernel_greens();
418 heffte->fft->backward(_data_fourier, _data_potential,
419 heffte->buffer->data());
420 kernel_move_fields();
421 }
422 }
423#endif
426 }
427
428 void add_charge_to_field(std::size_t id, double valency) override {
429 auto const factor = FloatType_c(valency / get_permittivity());
430 auto const density_id = BlockDataID(id);
431#if not defined(__CUDACC__)
432 if constexpr (Architecture == lbmpy::Arch::CPU) {
433 auto grid_range = get_lattice().get_local_grid_range();
434 auto dim = grid_range.second - grid_range.first;
435 for (auto &block : *get_lattice().get_blocks()) {
436 auto density_field = block.template getData<PotentialField>(density_id);
437 for (int x = 0; x < dim[0]; x++) {
438 for (int y = 0; y < dim[1]; y++) {
439 for (int z = 0; z < dim[2]; z++) {
440 m_potential[pos_to_linear_index(x, y, z, dim)] +=
441 factor * density_field->get(x, y, z);
442 }
443 }
444 }
445 }
446 }
447#endif
448#if defined(__CUDACC__)
449 if constexpr (Architecture == lbmpy::Arch::GPU) {
450 for (auto &block : *get_lattice().get_blocks()) {
451 auto field =
452 block.template getData<PotentialField>(m_potential_field_id);
453 auto density_field =
454 block.template getData<gpu::GPUField<FloatType>>(density_id);
455 add_fields(field, density_field, FloatType_c(factor));
456 }
457 }
458#endif
459 }
460
461 void reset_charge_field() override {
462#if not defined(__CUDACC__)
463 if constexpr (Architecture == lbmpy::Arch::CPU) {
464 auto const grid_range = get_lattice().get_local_grid_range();
465 auto const dim = grid_range.second - grid_range.first;
466 for (int x = 0; x < dim[0]; x++) {
467 for (int i = 0; i < m_potential_fourier.size(); i++) {
468 m_potential_fourier[i] *= m_greens[i];
469 }
470 for (int y = 0; y < dim[1]; y++) {
471 for (int z = 0; z < dim[2]; z++) {
472 m_potential[pos_to_linear_index(x, y, z, dim)] = FloatType(0.0);
473 }
474 }
475 }
476 }
477#endif
478#if defined(__CUDACC__)
479 if constexpr (Architecture == lbmpy::Arch::GPU) {
480 // the FFT-solver re-uses the potential field for the charge
481 for (auto &block : *get_lattice().get_blocks()) {
482 auto field =
483 block.template getData<PotentialField>(m_potential_field_id);
484 ek::accessor::Scalar::initialize(field, FloatType_c(0.));
485 }
486 }
487#endif
488 }
489
490protected:
491 void ghost_communication() { (*m_full_communication)(); }
492
493 void integrate_vtk_writers() override {
494 for (auto const &it : m_vtk_auto) {
495 auto &vtk_handle = it.second;
496 if (vtk_handle->enabled) {
497 vtk::writeFiles(vtk_handle->ptr)();
498 vtk_handle->execution_count++;
499 }
500 }
501 }
502
503protected:
504 template <typename Field_T, uint_t F_SIZE_ARG, typename OutputType>
505 class VTKWriter : public vtk::BlockCellDataWriter<OutputType, F_SIZE_ARG> {
506 public:
507 VTKWriter(ConstBlockDataID const &block_id, std::string const &id,
508 FloatType unit_conversion)
509 : vtk::BlockCellDataWriter<OutputType, F_SIZE_ARG>(id),
510 m_block_id(block_id), m_field(nullptr),
511 m_conversion(unit_conversion) {}
512
513 protected:
514 void configure() override {
515 WALBERLA_ASSERT_NOT_NULLPTR(this->block_);
516 m_field = this->block_->template getData<Field_T>(m_block_id);
517 }
518
519 ConstBlockDataID const m_block_id;
520 Field_T const *m_field;
521 FloatType const m_conversion;
522 };
523
524 template <typename OutputType = float>
526 : public VTKWriter<PotentialFieldVTK, 1u, OutputType> {
527 public:
529 using Base::Base;
530 using Base::evaluate;
531
532 protected:
533 OutputType evaluate(cell_idx_t const x, cell_idx_t const y,
534 cell_idx_t const z, cell_idx_t const) override {
535 WALBERLA_ASSERT_NOT_NULLPTR(this->m_field);
536 auto const potential =
538 return numeric_cast<OutputType>(this->m_conversion * potential);
539 }
540 };
541
542public:
543 void register_vtk_field_writers(walberla::vtk::VTKOutput &vtk_obj,
544 LatticeModel::units_map const &units,
545 int flag_observables) override {
546#if defined(__CUDACC__)
547 auto const allocate_cpu_field_if_empty =
548 [&]<typename Field>(auto const &blocks, std::string name,
549 std::optional<BlockDataID> &cpu_field) {
550 if (not cpu_field) {
551 cpu_field = field::addToStorage<Field>(
552 blocks, name, FloatType{0}, field::fzyx,
553 get_lattice().get_ghost_layers(), m_host_field_allocator);
554 }
555 };
556#endif
557 if (flag_observables & static_cast<int>(EKPoissonOutputVTK::potential)) {
558 auto const unit_conversion = FloatType_c(units.at("potential"));
559#if defined(__CUDACC__)
560 if constexpr (Architecture == lbmpy::Arch::GPU) {
561 auto const &blocks = get_lattice().get_blocks();
562 allocate_cpu_field_if_empty.template operator()<PotentialFieldVTK>(
563 blocks, "potential_cpu", m_potential_cpu_field_id);
564 vtk_obj.addBeforeFunction(
565 gpu::fieldCpyFunctor<PotentialFieldVTK, PotentialField>(
566 blocks, *m_potential_cpu_field_id,
567 m_potential_field_with_ghosts_id));
568 vtk_obj.addCellDataWriter(make_shared<PotentialVTKWriter<float>>(
569 *m_potential_cpu_field_id, "potential", unit_conversion));
570 }
571#endif
572 if constexpr (Architecture == lbmpy::Arch::CPU) {
573 vtk_obj.addCellDataWriter(make_shared<PotentialVTKWriter<float>>(
574 m_potential_field_with_ghosts_id, "potential", unit_conversion));
575 }
576 }
577 }
578
579private:
580#if defined(__CUDACC__)
581 void add_fields(PotentialField *field_out,
582 gpu::GPUField<FloatType> *field_add, FloatType factor) {
583 auto kernel = gpu::make_kernel(add_fields_with_factor<FloatType>);
584 kernel.addFieldIndexingParam(
585 gpu::FieldIndexing<FloatType>::xyz(*field_out));
586 kernel.addFieldIndexingParam(
587 gpu::FieldIndexing<FloatType>::xyz(*field_add));
588 kernel.addParam(factor);
589 kernel();
590 }
591#endif
592};
593
594} // namespace walberla
Vector implementation and trait types for boost qvm interoperability.
std::map< std::string, std::shared_ptr< VTKHandle > > m_vtk_auto
VTK writers that are executed automatically.
std::unordered_map< std::string, double > units_map
std::pair< Utils::Vector3i, Utils::Vector3i > get_local_grid_range(bool with_halo=false) const
DEVICE_QUALIFIER constexpr iterator begin() noexcept
Definition Array.hpp:140
OutputType evaluate(cell_idx_t const x, cell_idx_t const y, cell_idx_t const z, cell_idx_t const) override
VTKWriter(ConstBlockDataID const &block_id, std::string const &id, FloatType unit_conversion)
FieldTrait< FloatType, Architecture >::template FullCommunicator< stencil::D3Q27 > FullCommunicator
bool is_gpu() const noexcept override
FieldTrait< FloatType, Architecture >::PotentialFieldVTK PotentialFieldVTK
bool is_double_precision() const noexcept override
std::vector< double > get_slice_potential(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const override
PoissonSolverFFT(std::shared_ptr< LatticeWalberla > lattice, double permittivity)
void setup_fft(bool use_gpu_aware) override
FieldTrait< FloatType, Architecture >::ComplexType ComplexType
std::optional< double > get_node_potential(Utils::Vector3i const &node, bool consider_ghosts=false) override
void add_charge_to_field(std::size_t id, double valency) override
FieldTrait< FloatType, Architecture >::PotentialField PotentialField
void register_vtk_field_writers(walberla::vtk::VTKOutput &vtk_obj, LatticeModel::units_map const &units, int flag_observables) override
FieldTrait< FloatType, Architecture >::template PackInfo< Field > PackInfo
~PoissonSolverFFT() override=default
std::size_t get_potential_field_id() const noexcept override
LatticeWalberla const & get_lattice() const noexcept override
virtual double get_permittivity() const noexcept
static double * block(double *p, std::size_t index, std::size_t size)
Definition elc.cpp:176
VectorXi< 3 > Vector3i
Definition Vector.hpp:194
Definition fft.cpp:78
STL namespace.
void initialize(GhostLayerField< double, 1u > *scalar_field, double const &value)
auto get(GhostLayerField< double, 1u > const *scalar_field, Cell const &cell)
\file PackInfoPdfDoublePrecision.cpp \author pystencils
int pos_to_linear_index(int x, int y, int z, auto const &dim)
auto to_array(Utils::Vector< T, N > const &vec)
std::optional< BlockAndCell > get_block_and_cell(::LatticeWalberla const &lattice, signed_integral_vector auto const &node, bool consider_ghost_layers)
std::optional< walberla::cell::CellInterval > get_block_interval(::LatticeWalberla const &lattice, Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner, Utils::Vector3i const &block_offset, IBlock const &block)
void copy_block_buffer(CellInterval const &bci, CellInterval const &ci, Utils::Vector3i const &block_offset, Utils::Vector3i const &lower_corner, Kernel &&kernel)
Synchronize data between a sliced block and a container.
std::optional< walberla::cell::CellInterval > get_interval(::LatticeWalberla const &lattice, Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner)
blockforest::communication::UniformBufferedScheme< Stencil > FullCommunicator
field::GhostLayerField< FT, 1u > PotentialFieldVTK
field::GhostLayerField< FT, 1u > PotentialField
field::communication::PackInfo< Field > PackInfo
std::unique_ptr< heffte::fft3d< backend > > fft
std::unique_ptr< heffte::box3d<> > box_in
std::unique_ptr< heffte::box3d<> > box_out
std::unique_ptr< heffte::fft3d< backend >::buffer_container< ComplexType > > buffer
heffte_container(heffte::plan_options const &options, auto const &grid_range)