Skip to content

Commit

Permalink
Merge pull request AMReX-Codes#7 from jclepelch/fftw_rect_dom
Browse files Browse the repository at this point in the history
Fftw rect dom
  • Loading branch information
ajnonaka authored Jun 26, 2023
2 parents 13f71ec + ebf04c3 commit 110b9ea
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
10 changes: 8 additions & 2 deletions ExampleCodes/FFTW/Basic/inputs
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
n_cell = 64
max_grid_size = 32
max_grid_size = 32
n_cell_x = 64
n_cell_y = 128
n_cell_z = 32

prob_hi_x = 1.
prob_hi_y = 1.
prob_hi_z = 1.
35 changes: 24 additions & 11 deletions ExampleCodes/FFTW/Basic/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@ int main (int argc, char* argv[])
// **********************************

// number of cells on each side of the domain
int n_cell;
int n_cell_x;
int n_cell_y;
int n_cell_z;

// size of each box (or grid)
// dimensions of each box (or grid)
Real prob_hi_x;
Real prob_hi_y;
Real prob_hi_z;

// This is the largest size a grid can be
int max_grid_size;

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

// We need to get n_cell from the inputs file - this is the number of cells on each side of
// a square (or cubic) domain.
pp.get("n_cell",n_cell);
// We need to get n_cell_ from the inputs file - this is the number of cells on each side of
// a rectangular domain.
pp.get("n_cell_x",n_cell_x);
pp.get("n_cell_y",n_cell_y);
pp.get("n_cell_z",n_cell_z);

// We need to get prob_hi_x/y/z from the inputs file - this is the physical dimensions of the domain
pp.get("prob_hi_x",prob_hi_x);
pp.get("prob_hi_y",prob_hi_y);
pp.get("prob_hi_z",prob_hi_z);

// The domain is broken into boxes of size max_grid_size
pp.get("max_grid_size",max_grid_size);
Expand All @@ -53,7 +67,6 @@ int main (int argc, char* argv[])
// **********************************
// DEFINE SIMULATION SETUP AND GEOMETRY
// **********************************

// make BoxArray and Geometry
// ba will contain a list of boxes that cover the domain
// geom contains information such as the physical domain size,
Expand All @@ -63,7 +76,7 @@ int main (int argc, char* argv[])

// define lower and upper indices
IntVect dom_lo(AMREX_D_DECL( 0, 0, 0));
IntVect dom_hi(AMREX_D_DECL(n_cell-1, n_cell-1, n_cell-1));
IntVect dom_hi(AMREX_D_DECL(n_cell_x-1, n_cell_y-1, n_cell_z-1));

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

// This defines the physical box, [0,1] in each direction.
// This defines the physical box size in each direction
RealBox real_box({ AMREX_D_DECL(0., 0., 0.)},
{ AMREX_D_DECL(1., 1., 1.)} );
{ AMREX_D_DECL(prob_hi_x, prob_hi_y, prob_hi_z)} );

// periodic in all direction
Array<int,AMREX_SPACEDIM> is_periodic{AMREX_D_DECL(1,1,1)};
Expand Down Expand Up @@ -118,9 +131,9 @@ int main (int argc, char* argv[])
Real x = (i+0.5) * dx[0];
Real y = (j+0.5) * dx[1];
Real z = (AMREX_SPACEDIM==3) ? (k+0.5) * dx[2] : 0.;
phi_ptr(i,j,k) = std::sin(2*M_PI*x + omega)*std::sin(2*M_PI*y + omega);
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);
if (AMREX_SPACEDIM == 3) {
phi_ptr *= std::sin(2*M_PI*z + omega);
phi_ptr(i,j,k) *= std::sin(2*M_PI*z/prob_hi_z + omega);
}
});
}
Expand Down

0 comments on commit 110b9ea

Please sign in to comment.