diff options
Diffstat (limited to 'Source/Initialization')
-rw-r--r-- | Source/Initialization/PlasmaInjector.cpp | 26 | ||||
-rw-r--r-- | Source/Initialization/WarpXInitData.cpp | 35 |
2 files changed, 53 insertions, 8 deletions
diff --git a/Source/Initialization/PlasmaInjector.cpp b/Source/Initialization/PlasmaInjector.cpp index af6a7a208..5710cab9a 100644 --- a/Source/Initialization/PlasmaInjector.cpp +++ b/Source/Initialization/PlasmaInjector.cpp @@ -81,10 +81,16 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name) // NOTE: When periodic boundaries are used, default injection range is set to mother grid dimensions. const amrex::Geometry& geom = WarpX::GetInstance().Geom(0); if( geom.isPeriodic(0) ) { +# ifndef WARPX_DIM_1D_Z xmin = geom.ProbLo(0); xmax = geom.ProbHi(0); +# else + zmin = geom.ProbLo(0); + zmax = geom.ProbHi(0); +# endif } +# ifndef WARPX_DIM_1D_Z if( geom.isPeriodic(1) ) { # ifndef WARPX_DIM_3D zmin = geom.ProbLo(1); @@ -94,6 +100,7 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name) ymax = geom.ProbHi(1); # endif } +# endif # ifdef WARPX_DIM_3D if( geom.isPeriodic(2) ) { @@ -246,16 +253,18 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name) flux_normal_axis = 0; } #else +# ifndef WARPX_DIM_1D_Z if (flux_normal_axis_string == "x" || flux_normal_axis_string == "X") { flux_normal_axis = 0; } +# endif #endif #ifdef WARPX_DIM_3D - else if (flux_normal_axis_string == "y" || flux_normal_axis_string == "Y") { + if (flux_normal_axis_string == "y" || flux_normal_axis_string == "Y") { flux_normal_axis = 1; } #endif - else if (flux_normal_axis_string == "z" || flux_normal_axis_string == "Z") { + if (flux_normal_axis_string == "z" || flux_normal_axis_string == "Z") { flux_normal_axis = AMREX_SPACEDIM-1; } #ifdef WARPX_DIM_3D @@ -263,8 +272,10 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name) #else # ifdef WARPX_DIM_RZ std::string flux_normal_axis_help = "'r' or 'z'."; -# else +# elif WARPX_DIM_XZ std::string flux_normal_axis_help = "'x' or 'z'."; +# else + std::string flux_normal_axis_help = "'z'."; # endif #endif AMREX_ALWAYS_ASSERT_WITH_MESSAGE(flux_normal_axis >= 0, @@ -282,7 +293,10 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name) } else if (injection_style == "nuniformpercell") { // Note that for RZ, three numbers are expected, r, theta, and z. // For 2D, only two are expected. The third is overwritten with 1. -#if WARPX_DIM_XZ + // For 1D, only one is expected. The second and third are overwritten with 1. +#if defined(WARPX_DIM_1D_Z) + constexpr int num_required_ppc_each_dim = 1; +#elif defined(WARPX_DIM_XZ) constexpr int num_required_ppc_each_dim = 2; #else constexpr int num_required_ppc_each_dim = 3; @@ -292,6 +306,10 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name) #if WARPX_DIM_XZ num_particles_per_cell_each_dim.push_back(1); #endif +#if WARPX_DIM_1D_Z + num_particles_per_cell_each_dim.push_back(1); // overwrite 2nd number with 1 + num_particles_per_cell_each_dim.push_back(1); // overwrite 3rd number with 1 +#endif #if WARPX_DIM_RZ if (WarpX::n_rz_azimuthal_modes > 1) { AMREX_ALWAYS_ASSERT_WITH_MESSAGE( diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index 41fda5567..f92fe80aa 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -86,11 +86,13 @@ WarpX::PostProcessBaseGrids (BoxArray& ba0) const klo += domlo[2]; khi += domlo[2]; #endif +#if (AMREX_SPACEDIM >= 2) for (int j = 0; j < numprocs[1]; ++j) { int jlo = (j < extra[1]) ? j*(sz[1]+1) : (j*sz[1]+extra[1]); int jhi = (j < extra[1]) ? jlo+(sz[1]+1)-1 : jlo+sz[1]-1; jlo += domlo[1]; jhi += domlo[1]; +#endif for (int i = 0; i < numprocs[0]; ++i) { int ilo = (i < extra[0]) ? i*(sz[0]+1) : (i*sz[0]+extra[0]); int ihi = (i < extra[0]) ? ilo+(sz[0]+1)-1 : ilo+sz[0]-1; @@ -358,6 +360,7 @@ WarpX::computeMaxStepBoostAccelerator(const amrex::Geometry& a_geom){ void WarpX::InitNCICorrector () { +#if !(defined WARPX_DIM_1D_Z) if (WarpX::use_fdtd_nci_corr) { for (int lev = 0; lev <= max_level; ++lev) @@ -367,8 +370,10 @@ WarpX::InitNCICorrector () amrex::Real dz, cdtodz; if (AMREX_SPACEDIM == 3){ dz = dx[2]; - }else{ + }else if(AMREX_SPACEDIM == 2){ dz = dx[1]; + }else{ + dz = dx[0]; } cdtodz = PhysConst::c * dt[lev] / dz; @@ -385,6 +390,7 @@ WarpX::InitNCICorrector () nci_godfrey_filter_bxbyez[lev]->ComputeStencils(); } } +#endif } void @@ -663,13 +669,20 @@ WarpX::InitializeExternalFieldsOnGridUsingParser ( #endif // Shift required in the x-, y-, or z- position // depending on the index type of the multifab +#if (AMREX_SPACEDIM==1) + amrex::Real x = 0._rt; + amrex::Real y = 0._rt; + amrex::Real fac_z = (1._rt - x_nodal_flag[1]) * dx_lev[1] * 0.5_rt; + amrex::Real z = j*dx_lev[1] + real_box.lo(1) + fac_z; +#elif (AMREX_SPACEDIM==2) amrex::Real fac_x = (1._rt - x_nodal_flag[0]) * dx_lev[0] * 0.5_rt; amrex::Real x = i*dx_lev[0] + real_box.lo(0) + fac_x; -#if (AMREX_SPACEDIM==2) amrex::Real y = 0._rt; amrex::Real fac_z = (1._rt - x_nodal_flag[1]) * dx_lev[1] * 0.5_rt; amrex::Real z = j*dx_lev[1] + real_box.lo(1) + fac_z; #else + amrex::Real fac_x = (1._rt - x_nodal_flag[0]) * dx_lev[0] * 0.5_rt; + amrex::Real x = i*dx_lev[0] + real_box.lo(0) + fac_x; amrex::Real fac_y = (1._rt - x_nodal_flag[1]) * dx_lev[1] * 0.5_rt; amrex::Real y = j*dx_lev[1] + real_box.lo(1) + fac_y; amrex::Real fac_z = (1._rt - x_nodal_flag[2]) * dx_lev[2] * 0.5_rt; @@ -682,13 +695,20 @@ WarpX::InitializeExternalFieldsOnGridUsingParser ( #ifdef AMREX_USE_EB if(geom_data_y(i, j, k)<=0) return; #endif +#if (AMREX_SPACEDIM==1) + amrex::Real x = 0._rt; + amrex::Real y = 0._rt; + amrex::Real fac_z = (1._rt - y_nodal_flag[1]) * dx_lev[1] * 0.5_rt; + amrex::Real z = j*dx_lev[1] + real_box.lo(1) + fac_z; +#elif (AMREX_SPACEDIM==2) amrex::Real fac_x = (1._rt - y_nodal_flag[0]) * dx_lev[0] * 0.5_rt; amrex::Real x = i*dx_lev[0] + real_box.lo(0) + fac_x; -#if (AMREX_SPACEDIM==2) amrex::Real y = 0._rt; amrex::Real fac_z = (1._rt - y_nodal_flag[1]) * dx_lev[1] * 0.5_rt; amrex::Real z = j*dx_lev[1] + real_box.lo(1) + fac_z; #elif (AMREX_SPACEDIM==3) + amrex::Real fac_x = (1._rt - y_nodal_flag[0]) * dx_lev[0] * 0.5_rt; + amrex::Real x = i*dx_lev[0] + real_box.lo(0) + fac_x; amrex::Real fac_y = (1._rt - y_nodal_flag[1]) * dx_lev[1] * 0.5_rt; amrex::Real y = j*dx_lev[1] + real_box.lo(1) + fac_y; amrex::Real fac_z = (1._rt - y_nodal_flag[2]) * dx_lev[2] * 0.5_rt; @@ -701,13 +721,20 @@ WarpX::InitializeExternalFieldsOnGridUsingParser ( #ifdef AMREX_USE_EB if(geom_data_z(i, j, k)<=0) return; #endif +#if (AMREX_SPACEDIM==1) + amrex::Real x = 0._rt; + amrex::Real y = 0._rt; + amrex::Real fac_z = (1._rt - z_nodal_flag[1]) * dx_lev[1] * 0.5_rt; + amrex::Real z = j*dx_lev[1] + real_box.lo(1) + fac_z; +#elif (AMREX_SPACEDIM==2) amrex::Real fac_x = (1._rt - z_nodal_flag[0]) * dx_lev[0] * 0.5_rt; amrex::Real x = i*dx_lev[0] + real_box.lo(0) + fac_x; -#if (AMREX_SPACEDIM==2) amrex::Real y = 0._rt; amrex::Real fac_z = (1._rt - z_nodal_flag[1]) * dx_lev[1] * 0.5_rt; amrex::Real z = j*dx_lev[1] + real_box.lo(1) + fac_z; #elif (AMREX_SPACEDIM==3) + amrex::Real fac_x = (1._rt - z_nodal_flag[0]) * dx_lev[0] * 0.5_rt; + amrex::Real x = i*dx_lev[0] + real_box.lo(0) + fac_x; amrex::Real fac_y = (1._rt - z_nodal_flag[1]) * dx_lev[1] * 0.5_rt; amrex::Real y = j*dx_lev[1] + real_box.lo(1) + fac_y; amrex::Real fac_z = (1._rt - z_nodal_flag[2]) * dx_lev[2] * 0.5_rt; |