aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xPython/pywarpx/_libwarpx.py6
-rw-r--r--Python/pywarpx/picmi.py4
-rw-r--r--Source/FieldSolver/ElectrostaticSolver.cpp32
-rw-r--r--Source/Utils/WarpXUtil.cpp5
-rw-r--r--Source/WarpX.cpp7
5 files changed, 32 insertions, 22 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py
index 52bebf46a..9de822739 100755
--- a/Python/pywarpx/_libwarpx.py
+++ b/Python/pywarpx/_libwarpx.py
@@ -312,12 +312,10 @@ class LibWarpX():
'''
if self.geometry_dim == '3d':
dimensions = {'x' : 0, 'y' : 1, 'z' : 2}
- elif self.geometry_dim == '2d':
+ elif self.geometry_dim == '2d' or self.geometry_dim == 'rz':
dimensions = {'x' : 0, 'z' : 1}
elif self.geometry_dim == '1d':
dimensions = {'z' : 0}
- elif self.geometry_dim == 'rz':
- dimensions = {'r': 0, 'z': 1}
else:
raise RuntimeError(f"Unknown simulation geometry: {self.geometry_dim}")
@@ -334,7 +332,7 @@ class LibWarpX():
else:
if self.geometry_dim == '3d':
boundary_num = 6
- elif self.geometry_dim == '2d':
+ elif self.geometry_dim == '2d' or self.geometry_dim == 'rz':
boundary_num = 4
elif self.geometry_dim == '1d':
boundary_num = 2
diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py
index 49aac44dc..695c6c207 100644
--- a/Python/pywarpx/picmi.py
+++ b/Python/pywarpx/picmi.py
@@ -410,8 +410,8 @@ class CylindricalGrid(picmistandard.PICMI_CylindricalGrid):
self.blocking_factor_x = kw.pop('warpx_blocking_factor_x', None)
self.blocking_factor_y = kw.pop('warpx_blocking_factor_y', None)
- self.potential_xmin = None
- self.potential_xmax = None
+ self.potential_xmin = kw.pop('warpx_potential_lo_r', None)
+ self.potential_xmax = kw.pop('warpx_potential_hi_r', None)
self.potential_ymin = None
self.potential_ymax = None
self.potential_zmin = kw.pop('warpx_potential_lo_z', None)
diff --git a/Source/FieldSolver/ElectrostaticSolver.cpp b/Source/FieldSolver/ElectrostaticSolver.cpp
index 477797106..18f90431f 100644
--- a/Source/FieldSolver/ElectrostaticSolver.cpp
+++ b/Source/FieldSolver/ElectrostaticSolver.cpp
@@ -243,12 +243,11 @@ WarpX::computePhi (const amrex::Vector<std::unique_ptr<amrex::MultiFab> >& rho,
amrex::Array<amrex::Real,AMREX_SPACEDIM> phi_bc_values_hi;
phi_bc_values_lo[WARPX_ZINDEX] = field_boundary_handler.potential_zlo(gett_new(0));
phi_bc_values_hi[WARPX_ZINDEX] = field_boundary_handler.potential_zhi(gett_new(0));
-#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
- 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));
-#elif defined(WARPX_DIM_3D)
+#ifndef WARPX_DIM_1D_Z
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));
+#endif
+#if 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));
#endif
@@ -663,14 +662,25 @@ WarpX::computeB (amrex::Vector<std::array<std::unique_ptr<amrex::MultiFab>, 3> >
void ElectrostaticSolver::BoundaryHandler::definePhiBCs ( )
{
+ int dim_start = 0;
#ifdef WARPX_DIM_RZ
- lobc[0] = LinOpBCType::Neumann;
- hibc[0] = LinOpBCType::Dirichlet;
- dirichlet_flag[0] = false;
- dirichlet_flag[1] = false;
- int dim_start=1;
-#else
- int dim_start=0;
+ WarpX& warpx = WarpX::GetInstance();
+ auto geom = warpx.Geom(0);
+ if (geom.ProbLo(0) == 0){
+ lobc[0] = LinOpBCType::Neumann;
+ dirichlet_flag[0] = false;
+ dim_start = 1;
+
+ // handle the r_max boundary explicity
+ if (WarpX::field_boundary_hi[0] == FieldBoundaryType::PEC) {
+ hibc[0] = LinOpBCType::Dirichlet;
+ dirichlet_flag[1] = true;
+ }
+ else if (WarpX::field_boundary_hi[0] == FieldBoundaryType::None) {
+ hibc[0] = LinOpBCType::Neumann;
+ dirichlet_flag[1] = false;
+ }
+ }
#endif
for (int idim=dim_start; idim<AMREX_SPACEDIM; idim++){
if ( WarpX::field_boundary_lo[idim] == FieldBoundaryType::Periodic
diff --git a/Source/Utils/WarpXUtil.cpp b/Source/Utils/WarpXUtil.cpp
index 864fc3b10..03b3768a7 100644
--- a/Source/Utils/WarpXUtil.cpp
+++ b/Source/Utils/WarpXUtil.cpp
@@ -698,11 +698,6 @@ void ReadBCParams ()
}
}
}
-#ifdef WARPX_DIM_RZ
- // Ensure code aborts if PEC is specified at r=0 for RZ
- AMREX_ALWAYS_ASSERT_WITH_MESSAGE( WarpX::field_boundary_lo[0] == FieldBoundaryType::None,
- "Error : Field boundary at r=0 must be ``none``. \n");
-#endif
// Appending periodicity information to input so that it can be used by amrex
// to set parameters necessary to define geometry and perform communication
diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp
index 585369d70..c30eb79d1 100644
--- a/Source/WarpX.cpp
+++ b/Source/WarpX.cpp
@@ -891,6 +891,13 @@ WarpX::ReadParameters ()
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(Geom(0).isPeriodic(0) == 0,
"The problem must not be periodic in the radial direction");
+ // Ensure code aborts if PEC is specified at r=0 for RZ
+ if (Geom(0).ProbLo(0) == 0){
+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE(
+ WarpX::field_boundary_lo[0] == FieldBoundaryType::None,
+ "Error : Field boundary at r=0 must be ``none``. \n");
+ }
+
if (maxwell_solver_id == MaxwellSolverAlgo::PSATD) {
// Force do_nodal=true (that is, not staggered) and
// use same shape factors in all directions, for gathering