diff options
author | 2021-12-08 15:27:38 -0800 | |
---|---|---|
committer | 2021-12-08 23:27:38 +0000 | |
commit | 583c78e563f7a74e89fb49ff77c7a93c0baaad78 (patch) | |
tree | af71f27e07f68a26bc64bacfed976d64c8c7bf0b /Source/FieldSolver | |
parent | 6577874ae22634fee907fe9180080f7e6998afa1 (diff) | |
download | WarpX-583c78e563f7a74e89fb49ff77c7a93c0baaad78.tar.gz WarpX-583c78e563f7a74e89fb49ff77c7a93c0baaad78.tar.zst WarpX-583c78e563f7a74e89fb49ff77c7a93c0baaad78.zip |
Replace AMREX_SPACEDIM: Evolve & FieldSolver (#2642)
* AMREX_SPACEDIM : Boundary Conditions
* AMREX_SPACEDIM : Parallelization
* Fix compilation
* AMREX_SPACEDIM : Initialization
* Fix Typo
* space
* AMREX_SPACEDIM : Particles
* AMREX_SPACEDIM : Evolve and FieldSolver
Diffstat (limited to 'Source/FieldSolver')
13 files changed, 86 insertions, 86 deletions
diff --git a/Source/FieldSolver/ElectrostaticSolver.cpp b/Source/FieldSolver/ElectrostaticSolver.cpp index 582890aa8..017d8a5e1 100644 --- a/Source/FieldSolver/ElectrostaticSolver.cpp +++ b/Source/FieldSolver/ElectrostaticSolver.cpp @@ -382,10 +382,10 @@ WarpX::computePhiCartesian (const amrex::Vector<std::unique_ptr<amrex::MultiFab> amrex::Array<amrex::Real,AMREX_SPACEDIM> phi_bc_values_hi; phi_bc_values_lo[0] = field_boundary_handler.potential_xlo(gett_new(0)); phi_bc_values_hi[0] = field_boundary_handler.potential_xhi(gett_new(0)); -#if (AMREX_SPACEDIM==2) +#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) phi_bc_values_lo[1] = field_boundary_handler.potential_zlo(gett_new(0)); phi_bc_values_hi[1] = field_boundary_handler.potential_zhi(gett_new(0)); -#elif (AMREX_SPACEDIM==3) +#elif defined(WARPX_DIM_3D) phi_bc_values_lo[1] = field_boundary_handler.potential_ylo(gett_new(0)); phi_bc_values_hi[1] = field_boundary_handler.potential_yhi(gett_new(0)); phi_bc_values_lo[2] = field_boundary_handler.potential_zlo(gett_new(0)); @@ -400,9 +400,9 @@ WarpX::computePhiCartesian (const amrex::Vector<std::unique_ptr<amrex::MultiFab> // Set the value of beta amrex::Array<amrex::Real,AMREX_SPACEDIM> beta_solver = -# if (AMREX_SPACEDIM==1) +# if defined(WARPX_DIM_1D_Z) {{ beta[2] }}; // beta_x and beta_z -# elif (AMREX_SPACEDIM==2) +# elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) {{ beta[0], beta[2] }}; // beta_x and beta_z # else {{ beta[0], beta[1], beta[2] }}; @@ -465,19 +465,19 @@ WarpX::computePhiCartesian (const amrex::Vector<std::unique_ptr<amrex::MultiFab> if (do_electrostatic == ElectrostaticSolverAlgo::LabFrame) { for (int lev = 0; lev <= max_level; ++lev) { -#if (AMREX_SPACEDIM==1) +#if defined(WARPX_DIM_1D_Z) mlmg.getGradSolution( {amrex::Array<amrex::MultiFab*,1>{ get_pointer_Efield_fp(lev, 2) }} ); -#elif (AMREX_SPACEDIM==2) +#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) mlmg.getGradSolution( {amrex::Array<amrex::MultiFab*,2>{ get_pointer_Efield_fp(lev, 0),get_pointer_Efield_fp(lev, 2) }} ); -#elif (AMREX_SPACEDIM==3) +#elif defined(WARPX_DIM_3D) mlmg.getGradSolution( {amrex::Array<amrex::MultiFab*,3>{ get_pointer_Efield_fp(lev, 0),get_pointer_Efield_fp(lev, 1), @@ -586,11 +586,11 @@ WarpX::computeE (amrex::Vector<std::array<std::unique_ptr<amrex::MultiFab>, 3> > #endif for ( MFIter mfi(*phi[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi ) { -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const Real inv_dx = 1._rt/dx[0]; const Real inv_dy = 1._rt/dx[1]; const Real inv_dz = 1._rt/dx[2]; -#elif (AMREX_SPACEDIM == 2) +#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) const Real inv_dx = 1._rt/dx[0]; const Real inv_dz = 1._rt/dx[1]; #else @@ -599,7 +599,7 @@ WarpX::computeE (amrex::Vector<std::array<std::unique_ptr<amrex::MultiFab>, 3> > #if (AMREX_SPACEDIM >= 2) const Box& tbx = mfi.tilebox( E[lev][0]->ixType().toIntVect() ); #endif -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const Box& tby = mfi.tilebox( E[lev][1]->ixType().toIntVect() ); #endif const Box& tbz = mfi.tilebox( E[lev][2]->ixType().toIntVect() ); @@ -608,7 +608,7 @@ WarpX::computeE (amrex::Vector<std::array<std::unique_ptr<amrex::MultiFab>, 3> > #if (AMREX_SPACEDIM >= 2) const auto& Ex_arr = (*E[lev][0])[mfi].array(); #endif -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const auto& Ey_arr = (*E[lev][1])[mfi].array(); #endif const auto& Ez_arr = (*E[lev][2])[mfi].array(); @@ -619,7 +619,7 @@ WarpX::computeE (amrex::Vector<std::array<std::unique_ptr<amrex::MultiFab>, 3> > // Calculate the electric field // Use discretized derivative that matches the staggering of the grid. -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) amrex::ParallelFor( tbx, tby, tbz, [=] AMREX_GPU_DEVICE (int i, int j, int k) { Ex_arr(i,j,k) += @@ -646,7 +646,7 @@ WarpX::computeE (amrex::Vector<std::array<std::unique_ptr<amrex::MultiFab>, 3> > +(beta_y*beta_z-1)*inv_dz*( phi_arr(i,j,k+1)-phi_arr(i,j,k) ); } ); -#elif (AMREX_SPACEDIM == 2) +#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) amrex::ParallelFor( tbx, tbz, [=] AMREX_GPU_DEVICE (int i, int j, int k) { Ex_arr(i,j,k) += @@ -703,11 +703,11 @@ WarpX::computeB (amrex::Vector<std::array<std::unique_ptr<amrex::MultiFab>, 3> > #endif for ( MFIter mfi(*phi[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi ) { -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const Real inv_dx = 1._rt/dx[0]; const Real inv_dy = 1._rt/dx[1]; const Real inv_dz = 1._rt/dx[2]; -#elif (AMREX_SPACEDIM == 2) +#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) const Real inv_dx = 1._rt/dx[0]; const Real inv_dz = 1._rt/dx[1]; #else @@ -730,7 +730,7 @@ WarpX::computeB (amrex::Vector<std::array<std::unique_ptr<amrex::MultiFab>, 3> > // Calculate the magnetic field // Use discretized derivative that matches the staggering of the grid. -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) amrex::ParallelFor( tbx, tby, tbz, [=] AMREX_GPU_DEVICE (int i, int j, int k) { Bx_arr(i,j,k) += inv_c * ( @@ -754,7 +754,7 @@ WarpX::computeB (amrex::Vector<std::array<std::unique_ptr<amrex::MultiFab>, 3> > + phi_arr(i+1,j+1,k)-phi_arr(i,j+1,k))); } ); -#elif (AMREX_SPACEDIM == 2) +#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) amrex::ParallelFor( tbx, tby, tbz, [=] AMREX_GPU_DEVICE (int i, int j, int k) { Bx_arr(i,j,k) += inv_c * ( diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveEPML.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveEPML.cpp index b182a836b..b8c43190f 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveEPML.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveEPML.cpp @@ -192,7 +192,7 @@ void FiniteDifferenceSolver::EvolveEPMLCartesian ( const Real* sigmaj_y = sigba[mfi].sigma[1].data(); const Real* sigmaj_z = sigba[mfi].sigma[2].data(); int const x_lo = sigba[mfi].sigma[0].lo(); -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) int const y_lo = sigba[mfi].sigma[1].lo(); int const z_lo = sigba[mfi].sigma[2].lo(); #else diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp index 3cd607392..8076bdf8f 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp @@ -177,7 +177,7 @@ MacroscopicProperties::InitData () Ez_IndexType[idim] = Ez_stag[idim]; macro_cr_ratio[idim] = 1; } -#if (AMREX_SPACEDIM==2) +#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) sigma_IndexType[2] = 0; epsilon_IndexType[2] = 0; mu_IndexType[2] = 0; @@ -208,7 +208,7 @@ MacroscopicProperties::InitializeMacroMultiFabUsingParser ( // Shift x, y, z position based on index type amrex::Real fac_x = (1._rt - iv[0]) * dx_lev[0] * 0.5_rt; amrex::Real x = i * dx_lev[0] + real_box.lo(0) + fac_x; -#if (AMREX_SPACEDIM==2) +#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) amrex::Real y = 0._rt; amrex::Real fac_z = (1._rt - iv[1]) * dx_lev[1] * 0.5_rt; amrex::Real z = j * dx_lev[1] + real_box.lo(1) + fac_z; diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/ComovingPsatdAlgorithm.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/ComovingPsatdAlgorithm.H index cc9e7e4fc..b6d46095e 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/ComovingPsatdAlgorithm.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/ComovingPsatdAlgorithm.H @@ -89,7 +89,7 @@ class ComovingPsatdAlgorithm : public SpectralBaseAlgorithm // k vectors KVectorComponent kx_vec; -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) KVectorComponent ky_vec; #endif KVectorComponent kz_vec; diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/ComovingPsatdAlgorithm.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/ComovingPsatdAlgorithm.cpp index ba9613d3b..0e2953624 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/ComovingPsatdAlgorithm.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/ComovingPsatdAlgorithm.cpp @@ -35,7 +35,7 @@ ComovingPsatdAlgorithm::ComovingPsatdAlgorithm (const SpectralKSpace& spectral_k // Initialize the infinite-order k vectors (the argument n_order = -1 selects // the infinite order option, the argument nodal = false is then irrelevant) kx_vec(spectral_kspace.getModifiedKComponent(dm, 0, -1, false)), -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) ky_vec(spectral_kspace.getModifiedKComponent(dm, 1, -1, false)), kz_vec(spectral_kspace.getModifiedKComponent(dm, 2, -1, false)), #else @@ -86,7 +86,7 @@ ComovingPsatdAlgorithm::pushSpectralFields (SpectralFieldData& f) const // Extract pointers for the k vectors const amrex::Real* modified_kx_arr = modified_kx_vec[mfi].dataPtr(); -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) const amrex::Real* modified_ky_arr = modified_ky_vec[mfi].dataPtr(); #endif const amrex::Real* modified_kz_arr = modified_kz_vec[mfi].dataPtr(); @@ -111,7 +111,7 @@ ComovingPsatdAlgorithm::pushSpectralFields (SpectralFieldData& f) const // k vector values const amrex::Real kx_mod = modified_kx_arr[i]; -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) const amrex::Real ky_mod = modified_ky_arr[j]; const amrex::Real kz_mod = modified_kz_arr[k]; #else @@ -169,7 +169,7 @@ void ComovingPsatdAlgorithm::InitializeSpectralCoefficients (const SpectralKSpac // Extract pointers for the k vectors const amrex::Real* kx_mod = modified_kx_vec[mfi].dataPtr(); const amrex::Real* kx = kx_vec[mfi].dataPtr(); -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) const amrex::Real* ky_mod = modified_ky_vec[mfi].dataPtr(); const amrex::Real* ky = ky_vec[mfi].dataPtr(); #endif @@ -187,7 +187,7 @@ void ComovingPsatdAlgorithm::InitializeSpectralCoefficients (const SpectralKSpac // Store comoving velocity const amrex::Real vx = m_v_comoving[0]; -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) const amrex::Real vy = m_v_comoving[1]; #endif const amrex::Real vz = m_v_comoving[2]; @@ -198,7 +198,7 @@ void ComovingPsatdAlgorithm::InitializeSpectralCoefficients (const SpectralKSpac // Calculate norm of finite-order k vector const amrex::Real knorm_mod = std::sqrt( std::pow(kx_mod[i], 2) + -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) std::pow(ky_mod[j], 2) + std::pow(kz_mod[k], 2)); #else @@ -207,7 +207,7 @@ void ComovingPsatdAlgorithm::InitializeSpectralCoefficients (const SpectralKSpac // Calculate norm of infinite-order k vector const amrex::Real knorm = std::sqrt( std::pow(kx[i], 2) + -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) std::pow(ky[j], 2) + std::pow(kz[k], 2)); #else @@ -224,7 +224,7 @@ void ComovingPsatdAlgorithm::InitializeSpectralCoefficients (const SpectralKSpac // Calculate dot product of k vector with comoving velocity const amrex::Real kv = kx[i]*vx + -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) ky[j]*vy + kz[k]*vz; #else kz[j]*vz; @@ -441,7 +441,7 @@ ComovingPsatdAlgorithm::CurrentCorrection (const int lev, // Extract pointers for the k vectors const amrex::Real* const modified_kx_arr = modified_kx_vec[mfi].dataPtr(); const amrex::Real* const kx_arr = kx_vec[mfi].dataPtr(); -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) const amrex::Real* const modified_ky_arr = modified_ky_vec[mfi].dataPtr(); const amrex::Real* const ky_arr = ky_vec[mfi].dataPtr(); #endif @@ -469,7 +469,7 @@ ComovingPsatdAlgorithm::CurrentCorrection (const int lev, // k vector values, and coefficients const amrex::Real kx_mod = modified_kx_arr[i]; const amrex::Real kx = kx_arr[i]; -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) const amrex::Real ky_mod = modified_ky_arr[j]; const amrex::Real kz_mod = modified_kz_arr[k]; const amrex::Real ky = ky_arr[j]; diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.cpp index 14ffc2d91..bfe02a238 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PMLPsatdAlgorithm.cpp @@ -78,7 +78,7 @@ PMLPsatdAlgorithm::pushSpectralFields(SpectralFieldData& f) const { // Extract pointers for the k vectors const Real* modified_kx_arr = modified_kx_vec[mfi].dataPtr(); -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) const Real* modified_ky_arr = modified_ky_vec[mfi].dataPtr(); #endif const Real* modified_kz_arr = modified_kz_vec[mfi].dataPtr(); @@ -155,7 +155,7 @@ PMLPsatdAlgorithm::pushSpectralFields(SpectralFieldData& f) const { // k vector values, and coefficients const Real kx = modified_kx_arr[i]; -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) const Real ky = modified_ky_arr[j]; const Real kz = modified_kz_arr[k]; #else @@ -362,7 +362,7 @@ void PMLPsatdAlgorithm::InitializeSpectralCoefficients ( // Extract pointers for the k vectors const Real* modified_kx = modified_kx_vec[mfi].dataPtr(); -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) const Real* modified_ky = modified_ky_vec[mfi].dataPtr(); #endif const Real* modified_kz = modified_kz_vec[mfi].dataPtr(); @@ -376,7 +376,7 @@ void PMLPsatdAlgorithm::InitializeSpectralCoefficients ( ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const Real kx = modified_kx[i]; -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) const Real ky = modified_ky[j]; const Real kz = modified_kz[k]; #else diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.H index d0dce0fef..954c313ee 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.H @@ -156,7 +156,7 @@ class PsatdAlgorithm : public SpectralBaseAlgorithm // Centered modified finite-order k vectors KVectorComponent modified_kx_vec_centered; -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) KVectorComponent modified_ky_vec_centered; #endif KVectorComponent modified_kz_vec_centered; diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp index 1f3c67629..fe9562dba 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp @@ -49,7 +49,7 @@ PsatdAlgorithm::PsatdAlgorithm( // these are computed always with the assumption of centered grids // (argument nodal = true), for both nodal and staggered simulations modified_kx_vec_centered(spectral_kspace.getModifiedKComponent(dm, 0, norder_x, true)), -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) modified_ky_vec_centered(spectral_kspace.getModifiedKComponent(dm, 1, norder_y, true)), modified_kz_vec_centered(spectral_kspace.getModifiedKComponent(dm, 2, norder_z, true)), #else @@ -183,7 +183,7 @@ PsatdAlgorithm::pushSpectralFields (SpectralFieldData& f) const // Extract pointers for the k vectors const amrex::Real* modified_kx_arr = modified_kx_vec[mfi].dataPtr(); -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const amrex::Real* modified_ky_arr = modified_ky_vec[mfi].dataPtr(); #endif const amrex::Real* modified_kz_arr = modified_kz_vec[mfi].dataPtr(); @@ -220,7 +220,7 @@ PsatdAlgorithm::pushSpectralFields (SpectralFieldData& f) const // k vector values const amrex::Real kx = modified_kx_arr[i]; -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const amrex::Real ky = modified_ky_arr[j]; const amrex::Real kz = modified_kz_arr[k]; #else @@ -447,7 +447,7 @@ void PsatdAlgorithm::InitializeSpectralCoefficients ( // Extract pointers for the k vectors const amrex::Real* kx_s = modified_kx_vec[mfi].dataPtr(); const amrex::Real* kx_c = modified_kx_vec_centered[mfi].dataPtr(); -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const amrex::Real* ky_s = modified_ky_vec[mfi].dataPtr(); const amrex::Real* ky_c = modified_ky_vec_centered[mfi].dataPtr(); #endif @@ -471,7 +471,7 @@ void PsatdAlgorithm::InitializeSpectralCoefficients ( // Extract Galilean velocity amrex::Real vg_x = m_v_galilean[0]; -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) amrex::Real vg_y = m_v_galilean[1]; #endif amrex::Real vg_z = m_v_galilean[2]; @@ -482,7 +482,7 @@ void PsatdAlgorithm::InitializeSpectralCoefficients ( // Calculate norm of k vector const amrex::Real knorm_s = std::sqrt( std::pow(kx_s[i], 2) + -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) std::pow(ky_s[j], 2) + std::pow(kz_s[k], 2)); #else std::pow(kz_s[j], 2)); @@ -501,7 +501,7 @@ void PsatdAlgorithm::InitializeSpectralCoefficients ( // modified k vectors, to work correctly for both nodal and staggered simulations. // w_c = 0 always with standard PSATD (zero Galilean velocity). const amrex::Real w_c = kx_c[i]*vg_x + -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) ky_c[j]*vg_y + kz_c[k]*vg_z; #else kz_c[j]*vg_z; @@ -646,7 +646,7 @@ void PsatdAlgorithm::InitializeSpectralCoefficientsAveraging ( // Extract pointers for the k vectors const amrex::Real* kx_s = modified_kx_vec[mfi].dataPtr(); const amrex::Real* kx_c = modified_kx_vec_centered[mfi].dataPtr(); -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const amrex::Real* ky_s = modified_ky_vec[mfi].dataPtr(); const amrex::Real* ky_c = modified_ky_vec_centered[mfi].dataPtr(); #endif @@ -663,7 +663,7 @@ void PsatdAlgorithm::InitializeSpectralCoefficientsAveraging ( // Extract Galilean velocity amrex::Real vg_x = m_v_galilean[0]; -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) amrex::Real vg_y = m_v_galilean[1]; #endif amrex::Real vg_z = m_v_galilean[2]; @@ -674,7 +674,7 @@ void PsatdAlgorithm::InitializeSpectralCoefficientsAveraging ( // Calculate norm of k vector const amrex::Real knorm_s = std::sqrt( std::pow(kx_s[i], 2) + -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) std::pow(ky_s[j], 2) + std::pow(kz_s[k], 2)); #else std::pow(kz_s[j], 2)); @@ -692,7 +692,7 @@ void PsatdAlgorithm::InitializeSpectralCoefficientsAveraging ( // modified k vectors, to work correctly for both nodal and staggered simulations. // w_c = 0 always with standard PSATD (zero Galilean velocity). const amrex::Real w_c = kx_c[i]*vg_x + -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) ky_c[j]*vg_y + kz_c[k]*vg_z; #else kz_c[j]*vg_z; @@ -836,7 +836,7 @@ void PsatdAlgorithm::InitializeSpectralCoefficientsAvgLin ( // Extract pointers for the k vectors const Real* kx_s = modified_kx_vec[mfi].dataPtr(); -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) const Real* ky_s = modified_ky_vec[mfi].dataPtr(); #endif const Real* kz_s = modified_kz_vec[mfi].dataPtr(); @@ -853,7 +853,7 @@ void PsatdAlgorithm::InitializeSpectralCoefficientsAvgLin ( // Calculate norm of k vector const Real knorm_s = std::sqrt( std::pow(kx_s[i], 2) + -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) std::pow(ky_s[j], 2) + std::pow(kz_s[k], 2)); #else std::pow(kz_s[j], 2)); @@ -924,7 +924,7 @@ PsatdAlgorithm::CurrentCorrection ( // Extract pointers for the k vectors const amrex::Real* const modified_kx_arr = modified_kx_vec[mfi].dataPtr(); const amrex::Real* const modified_kx_arr_c = modified_kx_vec_centered[mfi].dataPtr(); -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const amrex::Real* const modified_ky_arr = modified_ky_vec[mfi].dataPtr(); const amrex::Real* const modified_ky_arr_c = modified_ky_vec_centered[mfi].dataPtr(); #endif @@ -952,7 +952,7 @@ PsatdAlgorithm::CurrentCorrection ( // k vector values, and coefficients const amrex::Real kx = modified_kx_arr[i]; const amrex::Real kx_c = modified_kx_arr_c[i]; -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const amrex::Real ky = modified_ky_arr[j]; const amrex::Real kz = modified_kz_arr[k]; const amrex::Real ky_c = modified_ky_arr_c[j]; @@ -1040,7 +1040,7 @@ PsatdAlgorithm::VayDeposition ( // Extract pointers for the modified k vectors const amrex::Real* const modified_kx_arr = modified_kx_vec[mfi].dataPtr(); -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const amrex::Real* const modified_ky_arr = modified_ky_vec[mfi].dataPtr(); #endif const amrex::Real* const modified_kz_arr = modified_kz_vec[mfi].dataPtr(); @@ -1050,7 +1050,7 @@ PsatdAlgorithm::VayDeposition ( { // Shortcuts for the values of D const Complex Dx = fields(i,j,k,Idx.Jx); -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const Complex Dy = fields(i,j,k,Idx.Jy); #endif const Complex Dz = fields(i,j,k,Idx.Jz); @@ -1060,7 +1060,7 @@ PsatdAlgorithm::VayDeposition ( // Modified k vector values const amrex::Real kx_mod = modified_kx_arr[i]; -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const amrex::Real ky_mod = modified_ky_arr[j]; const amrex::Real kz_mod = modified_kz_arr[k]; #else @@ -1071,7 +1071,7 @@ PsatdAlgorithm::VayDeposition ( if (kx_mod != 0._rt) fields(i,j,k,Idx.Jx) = I * Dx / kx_mod; else fields(i,j,k,Idx.Jx) = 0._rt; -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) // Compute Jy if (ky_mod != 0._rt) fields(i,j,k,Idx.Jy) = I * Dy / ky_mod; else fields(i,j,k,Idx.Jy) = 0._rt; diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.H index 4a35871cd..ad9f9925e 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.H @@ -102,7 +102,7 @@ class SpectralBaseAlgorithm // Modified finite-order vectors KVectorComponent modified_kx_vec; -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) KVectorComponent modified_ky_vec; #endif KVectorComponent modified_kz_vec; diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.cpp index 92e3fcf94..4ecbb9000 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.cpp @@ -37,14 +37,14 @@ SpectralBaseAlgorithm::SpectralBaseAlgorithm(const SpectralKSpace& spectral_kspa m_spectral_index(spectral_index), // Compute and assign the modified k vectors modified_kx_vec(spectral_kspace.getModifiedKComponent(dm,0,norder_x,nodal)), -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) modified_ky_vec(spectral_kspace.getModifiedKComponent(dm,1,norder_y,nodal)), modified_kz_vec(spectral_kspace.getModifiedKComponent(dm,2,norder_z,nodal)) #else modified_kz_vec(spectral_kspace.getModifiedKComponent(dm,1,norder_z,nodal)) #endif { -#if (AMREX_SPACEDIM!=3) +#if !defined(WARPX_DIM_3D) amrex::ignore_unused(norder_y); #endif } @@ -77,7 +77,7 @@ SpectralBaseAlgorithm::ComputeSpectralDivE ( Array4<Complex> fields = field_data.fields[mfi].array(); // Extract pointers for the k vectors const Real* modified_kx_arr = modified_kx_vec[mfi].dataPtr(); -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) const Real* modified_ky_arr = modified_ky_vec[mfi].dataPtr(); #endif const Real* modified_kz_arr = modified_kz_vec[mfi].dataPtr(); @@ -92,7 +92,7 @@ SpectralBaseAlgorithm::ComputeSpectralDivE ( const Complex Ez = fields(i,j,k,Idx.Ez); // k vector values const Real kx = modified_kx_arr[i]; -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) const Real ky = modified_ky_arr[j]; const Real kz = modified_kz_arr[k]; #else diff --git a/Source/FieldSolver/SpectralSolver/SpectralFieldData.H b/Source/FieldSolver/SpectralSolver/SpectralFieldData.H index aac4035a1..16f8e179c 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralFieldData.H +++ b/Source/FieldSolver/SpectralSolver/SpectralFieldData.H @@ -142,7 +142,7 @@ class SpectralFieldData // a cell-centered grid in real space, instead of a nodal grid SpectralShiftFactor xshift_FFTfromCell, xshift_FFTtoCell, zshift_FFTfromCell, zshift_FFTtoCell; -#if (AMREX_SPACEDIM==3) +#if defined(WARPX_DIM_3D) SpectralShiftFactor yshift_FFTfromCell, yshift_FFTtoCell; #endif diff --git a/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp b/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp index f16fc3aa2..9d8563b6b 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp @@ -123,7 +123,7 @@ SpectralFieldData::SpectralFieldData( const int lev, ShiftType::TransformFromCellCentered); xshift_FFTtoCell = k_space.getSpectralShiftFactor(dm, 0, ShiftType::TransformToCellCentered); -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) yshift_FFTfromCell = k_space.getSpectralShiftFactor(dm, 1, ShiftType::TransformFromCellCentered); yshift_FFTtoCell = k_space.getSpectralShiftFactor(dm, 1, @@ -200,12 +200,12 @@ SpectralFieldData::ForwardTransform (const int lev, #if (AMREX_SPACEDIM >= 2) const bool is_nodal_x = (stag[0] == amrex::IndexType::NODE) ? true : false; #endif -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const bool is_nodal_y = (stag[1] == amrex::IndexType::NODE) ? true : false; const bool is_nodal_z = (stag[2] == amrex::IndexType::NODE) ? true : false; -#elif (AMREX_SPACEDIM == 2) +#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) const bool is_nodal_z = (stag[1] == amrex::IndexType::NODE) ? true : false; -#elif (AMREX_SPACEDIM == 1) +#elif defined(WARPX_DIM_1D_Z) const bool is_nodal_z = (stag[0] == amrex::IndexType::NODE) ? true : false; #endif @@ -254,7 +254,7 @@ SpectralFieldData::ForwardTransform (const int lev, #if (AMREX_SPACEDIM >= 2) const Complex* xshift_arr = xshift_FFTfromCell[mfi].dataPtr(); #endif -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const Complex* yshift_arr = yshift_FFTfromCell[mfi].dataPtr(); #endif const Complex* zshift_arr = zshift_FFTfromCell[mfi].dataPtr(); @@ -268,12 +268,12 @@ SpectralFieldData::ForwardTransform (const int lev, #if (AMREX_SPACEDIM >= 2) if (is_nodal_x==false) spectral_field_value *= xshift_arr[i]; #endif -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) if (is_nodal_y==false) spectral_field_value *= yshift_arr[j]; if (is_nodal_z==false) spectral_field_value *= zshift_arr[k]; -#elif (AMREX_SPACEDIM == 2) +#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) if (is_nodal_z==false) spectral_field_value *= zshift_arr[j]; -#elif (AMREX_SPACEDIM == 1) +#elif defined(WARPX_DIM_1D_Z) if (is_nodal_z==false) spectral_field_value *= zshift_arr[i]; #endif // Copy field into the right index @@ -306,26 +306,26 @@ SpectralFieldData::BackwardTransform (const int lev, #if (AMREX_SPACEDIM >= 2) const bool is_nodal_x = mf.is_nodal(0); #endif -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const bool is_nodal_y = mf.is_nodal(1); const bool is_nodal_z = mf.is_nodal(2); -#elif (AMREX_SPACEDIM == 2) +#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) const bool is_nodal_z = mf.is_nodal(1); -#elif (AMREX_SPACEDIM == 1) +#elif defined(WARPX_DIM_1D_Z) const bool is_nodal_z = mf.is_nodal(0); #endif #if (AMREX_SPACEDIM >= 2) const int si = (is_nodal_x) ? 1 : 0; #endif -#if (AMREX_SPACEDIM == 1) +#if defined(WARPX_DIM_1D_Z) const int si = (is_nodal_z) ? 1 : 0; const int sj = 0; const int sk = 0; -#elif (AMREX_SPACEDIM == 2) +#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) const int sj = (is_nodal_z) ? 1 : 0; const int sk = 0; -#elif (AMREX_SPACEDIM == 3) +#elif defined(WARPX_DIM_3D) const int sj = (is_nodal_y) ? 1 : 0; const int sk = (is_nodal_z) ? 1 : 0; #endif @@ -353,7 +353,7 @@ SpectralFieldData::BackwardTransform (const int lev, #if (AMREX_SPACEDIM >= 2) const Complex* xshift_arr = xshift_FFTtoCell[mfi].dataPtr(); #endif -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const Complex* yshift_arr = yshift_FFTtoCell[mfi].dataPtr(); #endif const Complex* zshift_arr = zshift_FFTtoCell[mfi].dataPtr(); @@ -367,12 +367,12 @@ SpectralFieldData::BackwardTransform (const int lev, #if (AMREX_SPACEDIM >= 2) if (is_nodal_x==false) spectral_field_value *= xshift_arr[i]; #endif -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) if (is_nodal_y==false) spectral_field_value *= yshift_arr[j]; if (is_nodal_z==false) spectral_field_value *= zshift_arr[k]; -#elif (AMREX_SPACEDIM == 2) +#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) if (is_nodal_z==false) spectral_field_value *= zshift_arr[j]; -#elif (AMREX_SPACEDIM == 1) +#elif defined(WARPX_DIM_1D_Z) if (is_nodal_z==false) spectral_field_value *= zshift_arr[i]; #endif // Copy field into temporary array @@ -394,25 +394,25 @@ SpectralFieldData::BackwardTransform (const int lev, // Total number of cells, including ghost cells (nj represents ny in 3D and nz in 2D) const int ni = mf_box.length(0); -#if (AMREX_SPACEDIM == 1) +#if defined(WARPX_DIM_1D_Z) constexpr int nj = 1; constexpr int nk = 1; -#elif (AMREX_SPACEDIM == 2) +#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) const int nj = mf_box.length(1); constexpr int nk = 1; -#elif (AMREX_SPACEDIM == 3) +#elif defined(WARPX_DIM_3D) const int nj = mf_box.length(1); const int nk = mf_box.length(2); #endif // Lower bound of the box (lo_j represents lo_y in 3D and lo_z in 2D) const int lo_i = amrex::lbound(mf_box).x; -#if (AMREX_SPACEDIM == 1) +#if defined(WARPX_DIM_1D_Z) constexpr int lo_j = 0; constexpr int lo_k = 0; -#elif (AMREX_SPACEDIM == 2) +#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) const int lo_j = amrex::lbound(mf_box).y; constexpr int lo_k = 0; -#elif (AMREX_SPACEDIM == 3) +#elif defined(WARPX_DIM_3D) const int lo_j = amrex::lbound(mf_box).y; const int lo_k = amrex::lbound(mf_box).z; #endif diff --git a/Source/FieldSolver/WarpX_QED_K.H b/Source/FieldSolver/WarpX_QED_K.H index db8158d70..a20dde8b9 100644 --- a/Source/FieldSolver/WarpX_QED_K.H +++ b/Source/FieldSolver/WarpX_QED_K.H @@ -97,7 +97,7 @@ constexpr amrex::Real c2i = 1._rt/c2; const amrex::Real dxi = 1._rt/dx; const amrex::Real dzi = 1._rt/dz; -#if (AMREX_SPACEDIM == 3) +#if defined(WARPX_DIM_3D) const amrex::Real dyi = 1._rt/dy; // Picking out points for stencil to be used in curl function of M |