diff options
Diffstat (limited to 'Source/Utils')
-rw-r--r-- | Source/Utils/CoarsenIO.cpp | 18 | ||||
-rw-r--r-- | Source/Utils/CoarsenMR.cpp | 18 | ||||
-rw-r--r-- | Source/Utils/Interpolate_K.H | 7 | ||||
-rw-r--r-- | Source/Utils/WarpXMovingWindow.cpp | 29 | ||||
-rw-r--r-- | Source/Utils/WarpXUtil.cpp | 14 |
5 files changed, 73 insertions, 13 deletions
diff --git a/Source/Utils/CoarsenIO.cpp b/Source/Utils/CoarsenIO.cpp index 2cb97b0e1..e2ea419ad 100644 --- a/Source/Utils/CoarsenIO.cpp +++ b/Source/Utils/CoarsenIO.cpp @@ -41,24 +41,36 @@ CoarsenIO::Loop ( MultiFab& mf_dst, GpuArray<int,3> cr; // coarsening ratio sf[0] = stag_src[0]; +#if (AMREX_SPACEDIM == 1) + sf[1] = 0; +#else sf[1] = stag_src[1]; -#if (AMREX_SPACEDIM == 2) +#endif +#if (AMREX_SPACEDIM == 2 || AMREX_SPACEDIM == 1) sf[2] = 0; #elif (AMREX_SPACEDIM == 3) sf[2] = stag_src[2]; #endif sc[0] = stag_dst[0]; +#if (AMREX_SPACEDIM == 1) + sc[1] = 0; +#else sc[1] = stag_dst[1]; -#if (AMREX_SPACEDIM == 2) +#endif +#if (AMREX_SPACEDIM == 2 || AMREX_SPACEDIM == 1) sc[2] = 0; #elif (AMREX_SPACEDIM == 3) sc[2] = stag_dst[2]; #endif cr[0] = crse_ratio[0]; +#if (AMREX_SPACEDIM == 1) + cr[1] = 1; +#else cr[1] = crse_ratio[1]; -#if (AMREX_SPACEDIM == 2) +#endif +#if (AMREX_SPACEDIM == 2 || AMREX_SPACEDIM == 1) cr[2] = 1; #elif (AMREX_SPACEDIM == 3) cr[2] = crse_ratio[2]; diff --git a/Source/Utils/CoarsenMR.cpp b/Source/Utils/CoarsenMR.cpp index 80562d542..b701af088 100644 --- a/Source/Utils/CoarsenMR.cpp +++ b/Source/Utils/CoarsenMR.cpp @@ -30,24 +30,36 @@ CoarsenMR::Loop ( MultiFab& mf_dst, GpuArray<int,3> cr; // coarsening ratio sf[0] = stag_src[0]; +#if (AMREX_SPACEDIM == 1) + sf[1] = 0; +#else sf[1] = stag_src[1]; -#if (AMREX_SPACEDIM == 2) +#endif +#if (AMREX_SPACEDIM == 2 || AMREX_SPACEDIM == 1) sf[2] = 0; #elif (AMREX_SPACEDIM == 3) sf[2] = stag_src[2]; #endif sc[0] = stag_dst[0]; +#if (AMREX_SPACEDIM == 1) + sc[1] = 0; +#else sc[1] = stag_dst[1]; -#if (AMREX_SPACEDIM == 2) +#endif +#if (AMREX_SPACEDIM == 2 || AMREX_SPACEDIM == 1) sc[2] = 0; #elif (AMREX_SPACEDIM == 3) sc[2] = stag_dst[2]; #endif cr[0] = crse_ratio[0]; +#if (AMREX_SPACEDIM == 1) + cr[1] = 1; +#else cr[1] = crse_ratio[1]; -#if (AMREX_SPACEDIM == 2) +#endif +#if (AMREX_SPACEDIM == 2 || AMREX_SPACEDIM == 1) cr[2] = 1; #elif (AMREX_SPACEDIM == 3) cr[2] = crse_ratio[2]; diff --git a/Source/Utils/Interpolate_K.H b/Source/Utils/Interpolate_K.H index 9c8e0a2b4..f452f1acf 100644 --- a/Source/Utils/Interpolate_K.H +++ b/Source/Utils/Interpolate_K.H @@ -18,11 +18,16 @@ void interp (int j, int k, int l, Real const wx = static_cast<Real>(type[0]) * static_cast<amrex::Real>(j-jg*r_ratio) * rr; Real const owx = 1.0_rt-wx; +#if (AMREX_SPACEDIM >= 2) int const kg = amrex::coarsen(k,r_ratio); Real const wy = static_cast<Real>(type[1]) * static_cast<amrex::Real>(k-kg*r_ratio) * rr; Real const owy = 1.0_rt-wy; +#endif -#if (AMREX_SPACEDIM == 2) +#if (AMREX_SPACEDIM == 1) + fine(j,k,l) = owx * crse(jg ,0,0) + + wx * crse(jg+1,0,0); +#elif (AMREX_SPACEDIM == 2) fine(j,k,l) = owx * owy * crse(jg ,kg ,0) + owx * wy * crse(jg ,kg+1,0) + wx * owy * crse(jg+1,kg ,0) diff --git a/Source/Utils/WarpXMovingWindow.cpp b/Source/Utils/WarpXMovingWindow.cpp index 600ad180e..3bb48d1a5 100644 --- a/Source/Utils/WarpXMovingWindow.cpp +++ b/Source/Utils/WarpXMovingWindow.cpp @@ -63,6 +63,12 @@ WarpX::UpdatePlasmaInjectionPosition (amrex::Real a_dt) // This needs to be converted in order to index `boost_direction` // which has 3 components, for both 2D and 3D simulations. WarpX::boost_direction[2*dir] * PhysConst::c * a_dt; +#elif ( AMREX_SPACEDIM == 1 ) + // In 1D, dir=0 corresponds to z + // This needs to be converted in order to index `boost_direction` + // which has 3 components, for 1D, 2D, and 3D simulations. + WarpX::boost_direction[2] * PhysConst::c * a_dt; + amrex::ignore_unused(dir); #endif } } @@ -365,13 +371,20 @@ WarpX::shiftMF (amrex::MultiFab& mf, const amrex::Geometry& geom, int num_shift, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept { // Compute x,y,z co-ordinates based on index type of mf +#if (AMREX_SPACEDIM==1) + amrex::Real x = 0.0; + amrex::Real y = 0.0; + amrex::Real fac_z = (1.0 - mf_type[0]) * dx[0]*0.5; + amrex::Real z = i*dx[0] + real_box.lo(0) + fac_z; +#elif (AMREX_SPACEDIM==2) amrex::Real fac_x = (1.0 - mf_type[0]) * dx[0]*0.5; amrex::Real x = i*dx[0] + real_box.lo(0) + fac_x; -#if (AMREX_SPACEDIM==2) amrex::Real y = 0.0; amrex::Real fac_z = (1.0 - mf_type[1]) * dx[1]*0.5; amrex::Real z = j*dx[1] + real_box.lo(1) + fac_z; #else + amrex::Real fac_x = (1.0 - mf_type[0]) * dx[0]*0.5; + amrex::Real x = i*dx[0] + real_box.lo(0) + fac_x; amrex::Real fac_y = (1.0 - mf_type[1]) * dx[1]*0.5; amrex::Real y = j*dx[1] + real_box.lo(1) + fac_y; amrex::Real fac_z = (1.0 - mf_type[2]) * dx[2]*0.5; @@ -417,6 +430,11 @@ WarpX::ShiftGalileanBoundary () m_v_galilean[0]*time_shift, std::numeric_limits<amrex::Real>::quiet_NaN(), m_v_galilean[2]*time_shift }; +#elif (AMREX_SPACEDIM == 1) + m_galilean_shift = { + std::numeric_limits<Real>::quiet_NaN(), + std::numeric_limits<Real>::quiet_NaN(), + m_v_galilean[2]*time_shift }; #endif #if (AMREX_SPACEDIM == 3) @@ -430,8 +448,13 @@ WarpX::ShiftGalileanBoundary () new_hi[0] = current_hi[0] + m_galilean_shift[0]; new_lo[1] = current_lo[1] + m_galilean_shift[2]; new_hi[1] = current_hi[1] + m_galilean_shift[2]; - } - #endif + } +#elif (AMREX_SPACEDIM == 1) + { + new_lo[0] = current_lo[0] + m_galilean_shift[2]; + new_hi[0] = current_hi[0] + m_galilean_shift[2]; + } +#endif time_of_last_gal_shift = cur_time; ResetProbDomain(amrex::RealBox(new_lo, new_hi)); diff --git a/Source/Utils/WarpXUtil.cpp b/Source/Utils/WarpXUtil.cpp index 06f0a7da5..d77a35b3a 100644 --- a/Source/Utils/WarpXUtil.cpp +++ b/Source/Utils/WarpXUtil.cpp @@ -170,8 +170,10 @@ void ConvertLabParamsToBoost() #if (AMREX_SPACEDIM == 3) Vector<int> dim_map {0, 1, 2}; -#else +#elif (AMREX_SPACEDIM == 2) Vector<int> dim_map {0, 2}; +#else + Vector<int> dim_map {2}; #endif for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) @@ -219,6 +221,8 @@ void NullifyMF(amrex::MultiFab& mf, int lev, amrex::Real zmin, amrex::Real zmax) amrex::Array<amrex::Real,3> galilean_shift = { 0., 0., 0., }; #elif (AMREX_SPACEDIM == 2) amrex::Array<amrex::Real,3> galilean_shift = { 0., std::numeric_limits<Real>::quiet_NaN(), 0., } ; +#elif (AMREX_SPACEDIM == 1) + amrex::Array<amrex::Real,3> galilean_shift = {std::numeric_limits<Real>::quiet_NaN(), std::numeric_limits<Real>::quiet_NaN(), 0., } ; #endif const amrex::Real zmin_box = WarpX::LowerCorner(bx, galilean_shift, lev)[2]; const amrex::Real zmax_box = WarpX::UpperCorner(bx, lev)[2]; @@ -226,8 +230,10 @@ void NullifyMF(amrex::MultiFab& mf, int lev, amrex::Real zmin, amrex::Real zmax) // Get box lower index in the z direction #if (AMREX_SPACEDIM==3) const int lo_ind = bx.loVect()[2]; -#else +#elif (AMREX_SPACEDIM==2) const int lo_ind = bx.loVect()[1]; +#else + const int lo_ind = bx.loVect()[0]; #endif // Check if box intersect with [zmin, zmax] if ( (zmax>zmin_box && zmin<=zmax_box) ){ @@ -237,8 +243,10 @@ void NullifyMF(amrex::MultiFab& mf, int lev, amrex::Real zmin, amrex::Real zmax) [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept{ #if (AMREX_SPACEDIM==3) const Real z_gridpoint = zmin_box+(k-lo_ind)*dz; -#else +#elif (AMREX_SPACEDIM==2) const Real z_gridpoint = zmin_box+(j-lo_ind)*dz; +#else + const Real z_gridpoint = zmin_box+(i-lo_ind)*dz; #endif if ( (z_gridpoint >= zmin) && (z_gridpoint < zmax) ) { arr(i,j,k) = 0.; |