Skip to content

Commit 110b9ea

Browse files
authored
Merge pull request AMReX-Codes#7 from jclepelch/fftw_rect_dom
Fftw rect dom
2 parents 13f71ec + ebf04c3 commit 110b9ea

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

ExampleCodes/FFTW/Basic/inputs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
n_cell = 64
2-
max_grid_size = 32
1+
max_grid_size = 32
2+
n_cell_x = 64
3+
n_cell_y = 128
4+
n_cell_z = 32
5+
6+
prob_hi_x = 1.
7+
prob_hi_y = 1.
8+
prob_hi_z = 1.

ExampleCodes/FFTW/Basic/main.cpp

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,16 @@ int main (int argc, char* argv[])
2727
// **********************************
2828

2929
// number of cells on each side of the domain
30-
int n_cell;
30+
int n_cell_x;
31+
int n_cell_y;
32+
int n_cell_z;
3133

32-
// size of each box (or grid)
34+
// dimensions of each box (or grid)
35+
Real prob_hi_x;
36+
Real prob_hi_y;
37+
Real prob_hi_z;
38+
39+
// This is the largest size a grid can be
3340
int max_grid_size;
3441

3542
// **********************************
@@ -42,9 +49,16 @@ int main (int argc, char* argv[])
4249
// pp.query means we optionally need the inputs file to have it - but we must supply a default here
4350
ParmParse pp;
4451

45-
// We need to get n_cell from the inputs file - this is the number of cells on each side of
46-
// a square (or cubic) domain.
47-
pp.get("n_cell",n_cell);
52+
// We need to get n_cell_ from the inputs file - this is the number of cells on each side of
53+
// a rectangular domain.
54+
pp.get("n_cell_x",n_cell_x);
55+
pp.get("n_cell_y",n_cell_y);
56+
pp.get("n_cell_z",n_cell_z);
57+
58+
// We need to get prob_hi_x/y/z from the inputs file - this is the physical dimensions of the domain
59+
pp.get("prob_hi_x",prob_hi_x);
60+
pp.get("prob_hi_y",prob_hi_y);
61+
pp.get("prob_hi_z",prob_hi_z);
4862

4963
// The domain is broken into boxes of size max_grid_size
5064
pp.get("max_grid_size",max_grid_size);
@@ -53,7 +67,6 @@ int main (int argc, char* argv[])
5367
// **********************************
5468
// DEFINE SIMULATION SETUP AND GEOMETRY
5569
// **********************************
56-
5770
// make BoxArray and Geometry
5871
// ba will contain a list of boxes that cover the domain
5972
// geom contains information such as the physical domain size,
@@ -63,7 +76,7 @@ int main (int argc, char* argv[])
6376

6477
// define lower and upper indices
6578
IntVect dom_lo(AMREX_D_DECL( 0, 0, 0));
66-
IntVect dom_hi(AMREX_D_DECL(n_cell-1, n_cell-1, n_cell-1));
79+
IntVect dom_hi(AMREX_D_DECL(n_cell_x-1, n_cell_y-1, n_cell_z-1));
6780

6881
// Make a single box that is the entire domain
6982
Box domain(dom_lo, dom_hi);
@@ -77,9 +90,9 @@ int main (int argc, char* argv[])
7790
// How Boxes are distrubuted among MPI processes
7891
DistributionMapping dm(ba);
7992

80-
// This defines the physical box, [0,1] in each direction.
93+
// This defines the physical box size in each direction
8194
RealBox real_box({ AMREX_D_DECL(0., 0., 0.)},
82-
{ AMREX_D_DECL(1., 1., 1.)} );
95+
{ AMREX_D_DECL(prob_hi_x, prob_hi_y, prob_hi_z)} );
8396

8497
// periodic in all direction
8598
Array<int,AMREX_SPACEDIM> is_periodic{AMREX_D_DECL(1,1,1)};
@@ -118,9 +131,9 @@ int main (int argc, char* argv[])
118131
Real x = (i+0.5) * dx[0];
119132
Real y = (j+0.5) * dx[1];
120133
Real z = (AMREX_SPACEDIM==3) ? (k+0.5) * dx[2] : 0.;
121-
phi_ptr(i,j,k) = std::sin(2*M_PI*x + omega)*std::sin(2*M_PI*y + omega);
134+
phi_ptr(i,j,k) = std::sin(4*M_PI*x/prob_hi_x + omega)*std::sin(124*M_PI*y/prob_hi_y + omega);
122135
if (AMREX_SPACEDIM == 3) {
123-
phi_ptr *= std::sin(2*M_PI*z + omega);
136+
phi_ptr(i,j,k) *= std::sin(2*M_PI*z/prob_hi_z + omega);
124137
}
125138
});
126139
}

0 commit comments

Comments
 (0)