Skip to content

Commit d70ef2a

Browse files
committed
Move m_inbox and m_outbox to FFT class
1 parent 42fab4c commit d70ef2a

20 files changed

+122
-123
lines changed

apps/aluminumNew/Aluminum.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class Aluminum : public Model {
163163

164164
void prepare_operators(double dt) {
165165
const Decomposition &decomp = get_decomposition();
166+
const FFT &fft = get_fft();
166167
World w = decomposition::get_world(decomp);
167168
auto spacing = get_spacing(w);
168169
auto size = get_size(w);
@@ -173,8 +174,8 @@ class Aluminum : public Model {
173174
auto Ly = size[1];
174175
auto Lz = size[2];
175176

176-
std::array<int, 3> low = get_outbox(decomp).low;
177-
std::array<int, 3> high = get_outbox(decomp).high;
177+
std::array<int, 3> low = get_outbox(fft).low;
178+
std::array<int, 3> high = get_outbox(fft).high;
178179

179180
int idx = 0;
180181
const double pi = std::atan(1.0) * 4.0;
@@ -242,9 +243,8 @@ class Aluminum : public Model {
242243
double dx = get_spacing(w, 0);
243244
double x0 = get_origin(w, 0);
244245
int Lx = get_size(w, 0);
245-
const Decomposition &decomp = get_decomposition();
246-
Int3 low = get_inbox(decomp).low;
247-
Int3 high = get_inbox(decomp).high;
246+
Int3 low = get_inbox(fft).low;
247+
Int3 high = get_inbox(fft).high;
248248

249249
// Calculate mean-field density n_mf
250250
fft.forward(psi, psi_F);

apps/aluminumNew/SeedGridFCC.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ class SeedGridFCC : public FieldModifier {
6262
*/
6363
void apply(Model &m, double) override {
6464
const World &w = m.get_world();
65-
const Decomposition &decomp = m.get_decomposition();
65+
const FFT &fft = m.get_fft();
6666
Field &field = m.get_real_field("psi");
67-
Int3 low = get_inbox(decomp).low;
68-
Int3 high = get_inbox(decomp).high;
67+
Int3 low = get_inbox(fft).low;
68+
Int3 high = get_inbox(fft).high;
6969

7070
// Use the new World API to get size, spacing, and origin
7171
auto size = get_size(w);

apps/aluminumNew/SlabFCC.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ class SlabFCC : public FieldModifier {
7272
*/
7373
void apply(Model &m, double) override {
7474
const World &w = m.get_world();
75-
const Decomposition &decomp = m.get_decomposition();
75+
const FFT &fft = m.get_fft();
7676
Field &field = m.get_real_field("psi");
77-
Int3 low = get_inbox(decomp).low;
78-
Int3 high = get_inbox(decomp).high;
77+
Int3 low = get_inbox(fft).low;
78+
Int3 high = get_inbox(fft).high;
7979

8080
// auto Lx = w.Lx;
8181
auto Ly = get_size(w, 1);

apps/tungsten.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class Tungsten : public Model {
102102
}
103103

104104
void prepare_operators(double dt) {
105+
const FFT &fft = get_fft();
105106
const Decomposition &decomp = get_decomposition();
106107
World w = decomposition::get_world(decomp);
107108
auto spacing = get_spacing(w);
@@ -113,8 +114,8 @@ class Tungsten : public Model {
113114
auto Ly = size[1];
114115
auto Lz = size[2];
115116

116-
std::array<int, 3> low = get_outbox(decomp).low;
117-
std::array<int, 3> high = get_outbox(decomp).high;
117+
std::array<int, 3> low = get_outbox(fft).low;
118+
std::array<int, 3> high = get_outbox(fft).high;
118119

119120
int idx = 0;
120121
const double pi = std::atan(1.0) * 4.0;

examples/02_domain_decomposition.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ int main(int argc, char *argv[]) {
3333
int comm_rank = 0, comm_size = 2;
3434
World world1 = world::create({32, 4, 4});
3535
Decomposition decomp1 = make_decomposition(world1, comm_rank, comm_size);
36-
cout << decomp1 << endl;
36+
// 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);
4242
World world2 = world::create({32, 4, 4});
4343
Decomposition decomp2 = make_decomposition(world2, comm);
44-
if (comm_rank == 0) cout << decomp2 << endl;
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/04_diffusion_model.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ class Diffusion : public Model {
110110
Upper and lower limits for this particular MPI rank, in both inbox and
111111
outbox, are given by domain decomposition object
112112
*/
113-
Int3 i_low = get_inbox(decomp).low;
114-
Int3 i_high = get_inbox(decomp).high;
115-
Int3 o_low = get_outbox(decomp).low;
116-
Int3 o_high = get_outbox(decomp).high;
113+
Int3 i_low = get_inbox(fft).low;
114+
Int3 i_high = get_inbox(fft).high;
115+
Int3 o_low = get_outbox(fft).low;
116+
Int3 o_high = get_outbox(fft).high;
117117

118118
/*
119119
Typically initial conditions are constructed elsewhere. However, to keep

examples/05_simulator.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ class GaussianIC : public FieldModifier {
5050
void apply(Model &m, double t) override {
5151
(void)t; // suppress compiler warning about unused parameter
5252
const World &w = m.get_world();
53-
const Decomposition &decomp = m.get_decomposition();
53+
const FFT &fft = m.get_fft();
5454
std::vector<double> &field = m.get_real_field("psi");
55-
Int3 low = get_inbox(decomp).low;
56-
Int3 high = get_inbox(decomp).high;
55+
Int3 low = get_inbox(fft).low;
56+
Int3 high = get_inbox(fft).high;
5757

5858
if (m.is_rank0()) std::cout << "Create initial condition" << std::endl;
5959
size_t idx = 0;
@@ -100,8 +100,9 @@ class Diffusion : public Model {
100100
void prepare_operators(double dt) {
101101
const Decomposition &decomp = get_decomposition();
102102
const World &w = decomposition::get_world(decomp);
103-
std::array<int, 3> low = get_outbox(decomp).low;
104-
std::array<int, 3> high = get_outbox(decomp).high;
103+
FFT &fft = get_fft();
104+
std::array<int, 3> low = get_outbox(fft).low;
105+
std::array<int, 3> high = get_outbox(fft).high;
105106

106107
if (is_rank0()) std::cout << "Prepare operators" << std::endl;
107108
size_t idx = 0;

examples/08_discrete_fields.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,23 @@ int main() {
5252
Decomposition decomp4 = make_decomposition(world, 3, 4);
5353

5454
std::cout << decomp1 << std::endl;
55-
const std::array<int, 3> &inbox_size1 = get_inbox_size(decomp1);
56-
const std::array<int, 3> &inbox_offset1 = get_inbox_offset(decomp1);
55+
const std::array<int, 3> &inbox_size1 = get_inbox(decomp1).size;
56+
const std::array<int, 3> &inbox_offset1 = get_inbox(decomp1).low;
5757
DiscreteField<double, 3> field1(inbox_size1, inbox_offset1, get_origin(world),
5858
get_spacing(world));
5959

60-
const std::array<int, 3> &inbox_size2 = get_inbox_size(decomp2);
61-
const std::array<int, 3> &inbox_offset2 = get_inbox_offset(decomp2);
60+
const std::array<int, 3> &inbox_size2 = get_inbox(decomp2).size;
61+
const std::array<int, 3> &inbox_offset2 = get_inbox(decomp2).low;
6262
DiscreteField<double, 3> field2(inbox_size2, inbox_offset2, get_origin(world),
6363
get_spacing(world));
6464

65-
const std::array<int, 3> &inbox_size3 = get_inbox_size(decomp3);
66-
const std::array<int, 3> &inbox_offset3 = get_inbox_offset(decomp3);
65+
const std::array<int, 3> &inbox_size3 = get_inbox(decomp3).size;
66+
const std::array<int, 3> &inbox_offset3 = get_inbox(decomp3).low;
6767
DiscreteField<double, 3> field3(inbox_size3, inbox_offset3, get_origin(world),
6868
get_spacing(world));
6969

70-
const std::array<int, 3> &inbox_size4 = get_inbox_size(decomp4);
71-
const std::array<int, 3> &inbox_offset4 = get_inbox_offset(decomp4);
70+
const std::array<int, 3> &inbox_size4 = get_inbox(decomp4).size;
71+
const std::array<int, 3> &inbox_offset4 = get_inbox(decomp4).low;
7272
DiscreteField<double, 3> field4(inbox_size4, inbox_offset4, get_origin(world),
7373
get_spacing(world));
7474
std::cout << field1 << std::endl;

examples/09_parallel_fft_high_level.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ int main(int argc, char *argv[]) {
1717
// Create input field
1818
// DiscreteField<double, 3> input(decomp);
1919

20-
auto dimensions = get_inbox_size(decomp);
21-
auto offsets = get_inbox_offset(decomp);
20+
auto dimensions = decomp.m_inbox.size;
21+
auto offsets = decomp.m_inbox.low;
2222
auto origin = get_origin(world);
2323
auto discretization = get_spacing(world);
2424
DiscreteField<double, 3> input(dimensions, offsets, origin, discretization);
@@ -30,21 +30,21 @@ 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);
35+
3336
// Create output array to store FFT results. If requested array is of type T =
3437
// complex<double>, then array will be constructed using complex indices so
3538
// that it matches the Fourier-space, i.e. first dimension is floor(Lx/2) + 1.
36-
Array<complex<double>, 3> output(decomp);
39+
Array<complex<double>, 3> output(get_outbox_size(fft));
3740

3841
std::cout << "input: " << input << std::endl; // this is {4, 3, 2}
3942
std::cout << "output: " << output << std::endl; // this is {3, 3, 2}
4043

4144
// This would construct an array of type T = <double> with different indices
42-
// Array<double, 3> output2(decomp);
45+
// Array<double, 3> output2(fft);
4346
// std::cout << output2 << std::endl; // this is {4, 3, 2}
4447

45-
auto plan_options = heffte::default_options<heffte::backend::fftw>();
46-
FFT fft(decomp, MPI_COMM_WORLD, plan_options, world);
47-
4848
fft.forward(input, output);
4949

5050
// Display results

examples/11_write_results.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ int main(int argc, char **argv) {
1616
World world = world::create({4, 3, 2});
1717
Decomposition decomp = make_decomposition(world);
1818
// DiscreteField<double, 3> field(decomp);
19-
auto dimensions = get_inbox_size(decomp);
20-
auto offsets = get_inbox_offset(decomp);
19+
auto dimensions = decomp.m_inbox.size;
20+
auto offsets = decomp.m_inbox.low;
2121
auto origin = get_origin(world);
2222
auto discretization = get_spacing(world);
2323
DiscreteField<double, 3> field(dimensions, offsets, origin, discretization);

0 commit comments

Comments
 (0)