Loading [MathJax]/jax/output/HTML-CSS/config.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
FFTBackendLegacy.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2024 The ESPResSo project
3 * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
4 * Max-Planck-Institute for Polymer Research, Theory Group
5 *
6 * This file is part of ESPResSo.
7 *
8 * ESPResSo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * ESPResSo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include "config/config.hpp"
25
26#if defined(P3M) or defined(DP3M)
27
28#include "common.hpp"
29#include "data_struct.hpp"
30
31#include <array>
32#include <memory>
33#include <tuple>
34#include <type_traits>
35
36namespace fft {
37template <typename FloatType> struct fft_data_struct;
38} // namespace fft
39
40/**
41 * @brief Historic FFT backend based on FFTW3.
42 * The 3D FFT is split into three 1D FFTs.
43 */
44template <typename FloatType>
45class FFTBackendLegacy : public FFTBackend<FloatType> {
46 static_assert(std::is_same_v<FloatType, float> or
47 std::is_same_v<FloatType, double>,
48 "FFTW only implements float and double");
49 std::unique_ptr<fft::fft_data_struct<FloatType>> fft;
50 using FFTBackend<FloatType>::local_mesh;
52 int ca_mesh_size = -1;
53 int ks_pnum = -1;
54
55public:
58 void init(P3MParameters const &params) override;
59 void forward_fft(FloatType *rs_mesh) override;
60 void backward_fft(FloatType *rs_mesh) override;
61 int get_ca_mesh_size() const noexcept override { return ca_mesh_size; }
62 int get_ks_pnum() const noexcept override { return ks_pnum; }
63 std::array<int, 3u> const &get_mesh_size() const override {
64 return fft->get_mesh_size();
65 }
66 std::array<int, 3u> const &get_mesh_start() const override {
67 return fft->get_mesh_start();
68 }
69
70 /**
71 * @brief Index helpers for reciprocal space.
72 * After the FFT the data is in order YZX, which
73 * means that Y is the slowest changing index.
74 */
75 std::tuple<int, int, int> get_permutations() const override {
76 constexpr static int KX = 2;
77 constexpr static int KY = 0;
78 constexpr static int KZ = 1;
79 return {KX, KY, KZ};
80 }
81};
82
83#endif // defined(P3M) or defined(DP3M)
Historic FFT backend based on FFTW3.
void backward_fft(FloatType *rs_mesh) override
~FFTBackendLegacy() override
std::array< int, 3u > const & get_mesh_size() const override
std::array< int, 3u > const & get_mesh_start() const override
void init(P3MParameters const &params) override
std::tuple< int, int, int > get_permutations() const override
Index helpers for reciprocal space.
void forward_fft(FloatType *rs_mesh) override
int get_ca_mesh_size() const noexcept override
int get_ks_pnum() const noexcept override
API for the FFT backend of the P3M algorithm.
bool check_complex_residuals
P3MLocalMesh const & local_mesh
This file contains the defaults for ESPResSo.
Definition fft.cpp:74
Common functions for dipolar and charge P3M.
static SteepestDescentParameters params
Currently active steepest descent instance.
Properties of the local mesh.
Structure to hold P3M parameters and some dependent variables.