From 69ef068443b59ff0a10537eebf1b579e1bc180f7 Mon Sep 17 00:00:00 2001 From: Alfred Mishi Date: Mon, 20 May 2024 11:41:14 -0700 Subject: [PATCH 1/3] Modified Basic Amrex-Tutorial --- ExampleCodes/heFFTe/Basic/main.cpp | 35 ++++++++++++++++++------------ 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/ExampleCodes/heFFTe/Basic/main.cpp b/ExampleCodes/heFFTe/Basic/main.cpp index acb44cde..494c3cd4 100644 --- a/ExampleCodes/heFFTe/Basic/main.cpp +++ b/ExampleCodes/heFFTe/Basic/main.cpp @@ -5,6 +5,7 @@ #include #include #include +#include using namespace amrex; @@ -29,12 +30,12 @@ int main (int argc, char* argv[]) int max_grid_size_z; // physical dimensions of the domain - Real prob_lo_x = 0.; - Real prob_lo_y = 0.; - Real prob_lo_z = 0.; - Real prob_hi_x = 1.; - Real prob_hi_y = 1.; - Real prob_hi_z = 1.; + Real prob_lo_x = -10.; + Real prob_lo_y = -10.; + Real prob_lo_z = -10.; + Real prob_hi_x = 10.; + Real prob_hi_y = 10.; + Real prob_hi_z = 10.; // ********************************** // READ PARAMETER VALUES FROM INPUTS FILE @@ -69,7 +70,7 @@ int main (int argc, char* argv[]) 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); + Box domain(dom_lo, dom_hi, amrex::IntVect::TheNodeVector()); // number of points in the domain long npts = domain.numPts(); @@ -77,13 +78,14 @@ int main (int argc, char* argv[]) // Initialize the boxarray "ba" from the single box "domain" BoxArray ba(domain); - +Print() << "ba" " " << ba << " "<< std::endl; // create IntVect of max_grid_size IntVect max_grid_size(AMREX_D_DECL(max_grid_size_x,max_grid_size_y,max_grid_size_z)); // Break up boxarray "ba" into chunks no larger than "max_grid_size" along a direction ba.maxSize(max_grid_size); - +Print() << "ba.maxSize" " " << max_grid_size << " "<< std::endl; +Print() << "ba_after_maxSize" " " << ba << " "<< std::endl; // How Boxes are distrubuted among MPI processes DistributionMapping dm(ba); @@ -123,9 +125,9 @@ int main (int argc, char* argv[]) Real x = prob_lo_x + (i+0.5) * dx[0]; Real y = (AMREX_SPACEDIM>=2) ? prob_lo_y + (j+0.5) * dx[1] : 0.; Real z = (AMREX_SPACEDIM==3) ? prob_lo_z + (k+0.5) * dx[2] : 0.; - fab(i,j,k) = std::sin(4*M_PI*x/prob_hi_x + omega); + fab(i,j,k) = std::exp(-x*x*0.5); if (AMREX_SPACEDIM >= 2) { - fab(i,j,k) *= std::sin(6*M_PI*y/prob_hi_y + omega); + fab(i,j,k) *= std::exp(-y*y*0.2); } if (AMREX_SPACEDIM == 3) { fab(i,j,k) *= std::sin(8*M_PI*z/prob_hi_z + omega); @@ -211,6 +213,10 @@ int main (int argc, char* argv[]) {c_local_box.bigEnd(0) ,c_local_box.bigEnd(1) ,c_local_box.bigEnd(2)}}, 0, ParallelDescriptor::Communicator()); +AllPrint() << "local_z" " " << local_box.smallEnd(2) << " " <::type; @@ -255,7 +261,7 @@ int main (int argc, char* argv[]) } // increase the size of boxes touching the hi-x domain by 1 in x - // this is an (Nx x Ny x Nz) -> (Nx/2+1 x Ny x Nz) real-to-complex sizing + // this is an (Nx x Ny x Nz) i-> (Nx/2+1 x Ny x Nz) real-to-complex sizing if (b.bigEnd(0) == geom.Domain().bigEnd(0)) { c_box.growHi(0,1); } @@ -396,9 +402,10 @@ int main (int argc, char* argv[]) // zero_avg=0 means set the k=0 value to zero, // otherwise it sets the k=0 value to the average value of the signal in real space - int zero_avg = 1; + //int zero_avg = 0; // zero k=0 mode + /* if (zero_avg == 1) { for (MFIter mfi(fft_data_onegrid); mfi.isValid(); ++mfi) { @@ -416,7 +423,7 @@ int main (int argc, char* argv[]) }); } } - + */ // SHIFT DATA for (MFIter mfi(fft_data_onegrid); mfi.isValid(); ++mfi) { From 4fdef25300cf0870e1a0f7008200f133c0c2e1b5 Mon Sep 17 00:00:00 2001 From: Alfred Mishi Date: Mon, 20 May 2024 13:47:35 -0700 Subject: [PATCH 2/3] Modified Basic Amrex-Tutorials --- ExampleCodes/heFFTe/Basic/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExampleCodes/heFFTe/Basic/main.cpp b/ExampleCodes/heFFTe/Basic/main.cpp index 494c3cd4..cc256e36 100644 --- a/ExampleCodes/heFFTe/Basic/main.cpp +++ b/ExampleCodes/heFFTe/Basic/main.cpp @@ -424,7 +424,7 @@ AllPrint() << "local_x" " " << local_box.smallEnd(0) << " " < Date: Thu, 23 May 2024 06:03:36 -0700 Subject: [PATCH 3/3] Modified Basic Tutorial: Node-Centered Potential (Phi) --- ExampleCodes/heFFTe/Basic/main.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/ExampleCodes/heFFTe/Basic/main.cpp b/ExampleCodes/heFFTe/Basic/main.cpp index cc256e36..d95445ea 100644 --- a/ExampleCodes/heFFTe/Basic/main.cpp +++ b/ExampleCodes/heFFTe/Basic/main.cpp @@ -30,12 +30,12 @@ int main (int argc, char* argv[]) int max_grid_size_z; // physical dimensions of the domain - Real prob_lo_x = -10.; - Real prob_lo_y = -10.; - Real prob_lo_z = -10.; - Real prob_hi_x = 10.; - Real prob_hi_y = 10.; - Real prob_hi_z = 10.; + Real prob_lo_x = 0.; + Real prob_lo_y = 0.; + Real prob_lo_z = 0.; + Real prob_hi_x = 1.; + Real prob_hi_y = 1.; + Real prob_hi_z = 1.; // ********************************** // READ PARAMETER VALUES FROM INPUTS FILE @@ -84,8 +84,6 @@ Print() << "ba" " " << ba << " "<< std::endl; // Break up boxarray "ba" into chunks no larger than "max_grid_size" along a direction ba.maxSize(max_grid_size); -Print() << "ba.maxSize" " " << max_grid_size << " "<< std::endl; -Print() << "ba_after_maxSize" " " << ba << " "<< std::endl; // How Boxes are distrubuted among MPI processes DistributionMapping dm(ba); @@ -125,9 +123,9 @@ Print() << "ba_after_maxSize" " " << ba << " "<< std::endl; Real x = prob_lo_x + (i+0.5) * dx[0]; Real y = (AMREX_SPACEDIM>=2) ? prob_lo_y + (j+0.5) * dx[1] : 0.; Real z = (AMREX_SPACEDIM==3) ? prob_lo_z + (k+0.5) * dx[2] : 0.; - fab(i,j,k) = std::exp(-x*x*0.5); + fab(i,j,k) = std::sin(4*M_PI*z/prob_hi_x + omega); if (AMREX_SPACEDIM >= 2) { - fab(i,j,k) *= std::exp(-y*y*0.2); + fab(i,j,k) *= std::sin(6*M_PI*z/prob_hi_y + omega); } if (AMREX_SPACEDIM == 3) { fab(i,j,k) *= std::sin(8*M_PI*z/prob_hi_z + omega);