Skip to content

Commit fc5ebc2

Browse files
committed
Implement fft::create
1 parent 6171a1e commit fc5ebc2

21 files changed

+200
-129
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ add_library(openpfc
103103
src/openpfc/core/box3d.cpp
104104
src/openpfc/core/decomposition.cpp
105105
src/openpfc/factory/decomposition_factory.cpp
106+
src/openpfc/fft.cpp
106107
# Add more .cpp files as you go
107108
)
108109

apps/aluminumNew/aluminumTest.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ using namespace Catch::Matchers;
4444
TEST_CASE("Aluminum functionality", "[Aluminum]") {
4545
SECTION("Step model and calculate norm of the result") {
4646
MPI_Worker worker(0, nullptr);
47-
World world = world::create({32, 32, 32});
48-
Decomposition decomp = make_decomposition(world);
49-
auto plan_options = heffte::default_options<heffte::backend::fftw>();
50-
FFT fft(decomp, MPI_COMM_WORLD, plan_options, world);
47+
auto world = world::create({32, 32, 32});
48+
auto decomp = make_decomposition(world);
49+
auto fft = fft::create(decomp);
5150

5251
Aluminum aluminum(world);
5352
aluminum.set_n0(-0.0060);

examples/02_domain_decomposition.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ int main(int argc, char *argv[]) {
3131
// Domain decomposition can be done in a manual manner, just by giving the
3232
// size of the calculation domain, id number and total number of subdomains:
3333
int comm_rank = 0, comm_size = 2;
34-
World world1 = world::create({32, 4, 4});
35-
Decomposition decomp1 = make_decomposition(world1, comm_rank, comm_size);
34+
auto world1 = world::create({32, 4, 4});
35+
auto decomp1 = make_decomposition(world1, comm_rank, comm_size);
3636
// cout << decomp1 << endl;
3737

3838
// In practice, we let MPI communicator to decide the number of subdomains.
3939
MPI_Init(&argc, &argv);
4040
MPI_Comm comm = MPI_COMM_WORLD;
4141
MPI_Comm_rank(comm, &comm_rank);
42-
World world2 = world::create({32, 4, 4});
43-
Decomposition decomp2 = make_decomposition(world2, comm);
44-
// if (comm_rank == 0) cout << decomp2 << endl;
42+
auto world2 = world::create({32, 4, 4});
43+
auto decomp2 = make_decomposition(world2, comm);
44+
if (comm_rank == 0) cout << decomp2 << endl;
4545

4646
// By default, MPI_COMM_WORLD is used, so the above example can be simplified:
47-
// cout << make_decomposition(world2) << endl;
47+
cout << make_decomposition(world2) << endl;
4848

4949
MPI_Finalize();
5050
return 0;

examples/03_parallel_fft.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,9 @@ int main(int argc, char *argv[]) {
126126
MPI_Comm_size(comm, &num_procs);
127127

128128
// Construct world, decomposition and fft
129-
World world = world::create({8, 1, 1});
130-
Decomposition decomposition = make_decomposition(world, comm);
131-
auto plan_options = heffte::default_options<heffte::backend::fftw>();
132-
FFT fft(decomposition, comm, plan_options, world);
129+
auto world = world::create({8, 1, 1});
130+
auto decomposition = make_decomposition(world, comm);
131+
auto fft = fft::create(decomposition);
133132

134133
// Create two vectors; in contains input data and results are stored to out
135134
vector<double> in(fft.size_inbox());

examples/04_diffusion_model.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,9 @@ void run() {
230230
double z0 = -0.5 * Lz * dz;
231231

232232
// Construct world, decomposition, fft and model
233-
World world = world::create({Lx, Ly, Lz}, {x0, y0, z0}, {dx, dy, dz});
234-
Decomposition decomp = make_decomposition(world);
235-
auto plan_options = heffte::default_options<heffte::backend::fftw>();
236-
FFT fft(decomp, MPI_COMM_WORLD, plan_options, world);
233+
auto world = world::create({Lx, Ly, Lz}, {x0, y0, z0}, {dx, dy, dz});
234+
auto decomp = make_decomposition(world);
235+
auto fft = fft::create(decomp);
237236
Diffusion model(world);
238237

239238
// Define time

examples/05_simulator.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,10 @@ void run() {
183183
std::array<int, 3> dimensions = {L, L, L};
184184
std::array<double, 3> discretization = {h, h, h};
185185
std::array<double, 3> origin = {o, o, o};
186-
World world = world::create(dimensions, origin, discretization);
186+
auto world = world::create(dimensions, origin, discretization);
187187

188-
Decomposition decomp = make_decomposition(world);
189-
auto plan_options = heffte::default_options<heffte::backend::fftw>();
190-
FFT fft(decomp, MPI_COMM_WORLD, plan_options, world);
188+
auto decomp = make_decomposition(world);
189+
auto fft = fft::create(decomp);
191190
Diffusion model(world);
192191

193192
// Define time

examples/09_parallel_fft_high_level.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ int main(int argc, char *argv[]) {
1111

1212
// Create MPI session, World and Decomposition
1313
MPI_Worker worker(argc, argv);
14-
World world = world::create({4, 3, 2});
15-
Decomposition decomp = make_decomposition(world);
14+
auto world = world::create({4, 3, 2});
15+
auto decomp = make_decomposition(world);
1616

1717
// Create input field
1818
// DiscreteField<double, 3> input(decomp);
@@ -30,8 +30,7 @@ int main(int argc, char *argv[]) {
3030
// Fill input field with random numbers
3131
apply(input, [&](auto, auto, auto) { return dis(gen); });
3232

33-
auto plan_options = heffte::default_options<heffte::backend::fftw>();
34-
FFT fft(decomp, MPI_COMM_WORLD, plan_options, world);
33+
auto fft = fft::create(decomp);
3534

3635
// Create output array to store FFT results. If requested array is of type T =
3736
// complex<double>, then array will be constructed using complex indices so

examples/12_cahn_hilliard.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,9 @@ int main(int argc, char **argv) {
113113
double z0 = 0.0;
114114

115115
// Construct world, decomposition, fft and model
116-
World world = world::create({Lx, Ly, Lz}, {x0, y0, z0}, {dx, dy, dz});
117-
Decomposition decomp = make_decomposition(world);
118-
auto plan_options = heffte::default_options<heffte::backend::fftw>();
119-
FFT fft(decomp, MPI_COMM_WORLD, plan_options, world);
116+
auto world = world::create({Lx, Ly, Lz}, {x0, y0, z0}, {dx, dy, dz});
117+
auto decomposition = make_decomposition(world);
118+
auto fft = fft::create(decomposition);
120119
CahnHilliard model(world);
121120
model.set_fft(fft);
122121

examples/diffusion_model_with_custom_initial_condition.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ void run() {
9292
Time time(tspan, saveat);
9393

9494
MPI_Comm comm = MPI_COMM_WORLD;
95-
Decomposition decomposition = make_decomposition(world, comm);
96-
auto plan_options = heffte::default_options<heffte::backend::fftw>();
97-
FFT fft(decomposition, comm, plan_options, world);
95+
auto decomposition = make_decomposition(world, comm);
96+
auto fft = fft::create(decomposition);
9897
Diffusion model(world);
9998
Simulator simulator(model, time);
10099

include/openpfc/boundary_conditions/fixed_bc.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// SPDX-FileCopyrightText: 2025 VTT Technical Research Centre of Finland Ltd
22
// SPDX-License-Identifier: AGPL-3.0-or-later
33

4-
#ifndef PFC_BOUNDARY_CONDITIONS_FIXED_BC_HPP
5-
#define PFC_BOUNDARY_CONDITIONS_FIXED_BC_HPP
4+
#pragma once
65

7-
#include "../field_modifier.hpp"
6+
#include "openpfc/core/types.hpp"
7+
#include "openpfc/field_modifier.hpp"
88

99
namespace pfc {
1010

11+
using pfc::types::Int3;
12+
1113
class FixedBC : public FieldModifier {
1214

1315
private:
@@ -56,5 +58,3 @@ class FixedBC : public FieldModifier {
5658
};
5759

5860
} // namespace pfc
59-
60-
#endif // PFC_BOUNDARY_CONDITIONS_FIXED_BC_HPP

0 commit comments

Comments
 (0)