@@ -46,33 +46,34 @@ struct FFTLayout {
4646const FFTLayout create (const Decomposition &decomposition, int r2c_direction,
4747 int num_domains);
4848
49+ inline auto get_real_box (const FFTLayout &layout, int i) {
50+ return layout.m_real_boxes .at (i);
51+ }
52+
53+ inline auto get_complex_box (const FFTLayout &layout, int i) {
54+ return layout.m_complex_boxes .at (i);
55+ }
56+
4957} // namespace layout
5058
51- using heffte::box3d;
52- using pfc::types::Bool3;
5359using pfc::types::Int3;
5460using pfc::types::Real3;
55- using Box3D = heffte::box3d<int >; // /< Type alias for 3D integer box.
5661
57- inline heffte::fft3d_r2c<heffte::backend::fftw>
58- make_fft (const Box3D &inbox, const Box3D &outbox, const int &r2c_direction,
59- MPI_Comm comm, heffte::plan_options plan_options) {
60- return heffte::fft3d_r2c<heffte::backend::fftw>(inbox, outbox, r2c_direction, comm,
61- plan_options);
62- }
62+ using Decomposition = pfc::decomposition::Decomposition<pfc::csys::CartesianTag>;
63+ using ComplexVector = std::vector<std::complex <double >>;
64+ using fft_r2c = heffte::fft3d_r2c<heffte::backend::fftw>;
65+ using box3di = heffte::box3d<int >; // /< Type alias for 3D integer box.
6366
6467/* *
6568 * @brief FFT class for performing forward and backward Fast Fourier
6669 * Transformations.
6770 */
6871struct FFT {
6972
70- using ComplexVector = std::vector<std::complex <double >>;
73+ // const Decomposition m_decomposition; /**< The Decomposition object. */
74+ // const box3di m_inbox, m_outbox; /**< Local inbox and outbox boxes. */
7175
72- const Decomposition m_decomposition; /* *< The Decomposition object. */
73- const heffte::box3d<int > m_inbox, m_outbox; /* *< Local inbox and outbox boxes. */
74- const int m_r2c_direction; /* *< Real-to-complex symmetry direction. */
75- const heffte::fft3d_r2c<heffte::backend::fftw> m_fft; /* *< HeFFTe FFT object. */
76+ const fft_r2c m_fft; /* *< HeFFTe FFT object. */
7677 ComplexVector m_wrk; /* *< Workspace vector for FFT computations. */
7778 double m_fft_time = 0.0 ; /* *< Recorded FFT computation time. */
7879
@@ -86,21 +87,15 @@ struct FFT {
8687 * @param plan_options Optional plan options for configuring the FFT behavior.
8788 * @param world The World object providing the domain size information.
8889 */
89- FFT (const Decomposition &decomposition, MPI_Comm comm,
90- heffte::plan_options plan_options)
91- : m_decomposition(decomposition), m_inbox(decomposition.m_inbox),
92- m_outbox (decomposition.m_outbox), m_r2c_direction(0 ),
93- m_fft(make_fft(m_inbox, m_outbox, m_r2c_direction, comm, plan_options)),
94- m_wrk(std::vector<std::complex <double >>(m_fft.size_workspace())){};
90+ FFT (fft_r2c fft) : m_fft(std::move(fft)), m_wrk(m_fft.size_workspace()) {}
9591
9692 /* *
9793 * @brief Performs the forward FFT transformation.
9894 *
9995 * @param in Input vector of real values.
10096 * @param out Output vector of complex values.
10197 */
102- void forward (const std::vector<double > &in,
103- std::vector<std::complex <double >> &out) {
98+ void forward (const std::vector<double > &in, ComplexVector &out) {
10499 m_fft_time -= MPI_Wtime ();
105100 m_fft.forward (in.data (), out.data (), m_wrk.data ());
106101 m_fft_time += MPI_Wtime ();
@@ -112,8 +107,7 @@ struct FFT {
112107 * @param in Input vector of complex values.
113108 * @param out Output vector of real values.
114109 */
115- void backward (const std::vector<std::complex <double >> &in,
116- std::vector<double > &out) {
110+ void backward (const ComplexVector &in, std::vector<double > &out) {
117111 m_fft_time -= MPI_Wtime ();
118112 m_fft.backward (in.data (), out.data (), m_wrk.data (), heffte::scale::full);
119113 m_fft_time += MPI_Wtime ();
@@ -136,7 +130,7 @@ struct FFT {
136130 *
137131 * @return Reference to the Decomposition object.
138132 */
139- const Decomposition &get_decomposition () { return m_decomposition; }
133+ // const Decomposition &get_decomposition() { return m_decomposition; }
140134
141135 /* *
142136 * @brief Returns the size of the inbox used for FFT computations.
@@ -160,24 +154,36 @@ struct FFT {
160154 size_t size_workspace () const { return m_fft.size_workspace (); }
161155};
162156
163- inline const Box3D &get_inbox (const FFT &fft) noexcept { return fft.m_inbox ; }
164- inline const Box3D &get_outbox (const FFT &fft) noexcept { return fft.m_outbox ; }
165- inline const Int3 &get_inbox_size (const FFT &fft) noexcept {
166- return get_inbox (fft).size ;
167- }
168- inline const Int3 &get_inbox_offset (const FFT &fft) noexcept {
169- return get_inbox (fft).low ;
170- }
171- inline const Int3 &get_outbox_size (const FFT &fft) noexcept {
172- return get_outbox (fft).size ;
157+ inline const auto &get_fft_object (const FFT &fft) noexcept { return fft.m_fft ; }
158+
159+ inline const auto get_inbox (const FFT &fft) noexcept {
160+ return get_fft_object (fft).inbox ();
173161}
174- inline const Int3 &get_outbox_offset (const FFT &fft) noexcept {
175- return get_outbox (fft).low ;
162+
163+ inline const auto get_outbox (const FFT &fft) noexcept {
164+ return get_fft_object (fft).outbox ();
176165}
177166
178- FFT create (const Decomposition &decomposition);
167+ /* *
168+ * @brief Creates an FFT object based on the given decomposition and MPI
169+ * communicator.
170+ *
171+ * @param decomposition The Decomposition object defining the domain
172+ * decomposition.
173+ * @param comm The MPI communicator for parallel computations.
174+ * @param options Optional plan options for configuring the FFT behavior.
175+ * @return An FFT object containing the FFT configuration and data.
176+ */
179177FFT create (const Decomposition &decomposition, MPI_Comm comm,
180178 heffte::plan_options options);
179+ /* *
180+ * @brief Creates an FFT object based on the given decomposition.
181+ *
182+ * @param decomposition The Decomposition object defining the domain
183+ * decomposition.
184+ * @return An FFT object containing the FFT configuration and data.
185+ */
186+ FFT create (const Decomposition &decomposition);
181187
182188} // namespace fft
183189
0 commit comments