Skip to content

Commit efb0190

Browse files
committed
Compute electrostatic fields at the beginning of EM simulations, if phi is specified
1 parent 07738d3 commit efb0190

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

Source/FieldSolver/ElectrostaticSolver.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ WarpX::ComputeSpaceChargeField (bool const reset_fields)
8888
}
8989

9090
// Add the field due to the boundary potentials
91-
if (electrostatic_solver_id == ElectrostaticSolverAlgo::Relativistic){
91+
if (m_boundary_potential_specified ||
92+
(electrostatic_solver_id == ElectrostaticSolverAlgo::Relativistic)){
9293
AddBoundaryField();
9394
}
9495
}

Source/WarpX.H

+1
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,7 @@ public:
954954
*/
955955
[[nodiscard]] amrex::IntVect get_numprocs() const {return numprocs;}
956956

957+
bool m_boundary_potential_specified = false;
957958
ElectrostaticSolver::PoissonBoundaryHandler m_poisson_boundary_handler;
958959
void ComputeSpaceChargeField (bool reset_fields);
959960
void AddBoundaryField ();

Source/WarpX.cpp

+13-9
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,7 @@ WarpX::ReadParameters ()
756756
"Currently, the embedded boundary in RZ only works for electrostatic solvers (or no solver).");
757757
#endif
758758

759-
if (electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrame ||
760-
electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrameElectroMagnetostatic)
759+
if (electrostatic_solver_id != ElectrostaticSolverAlgo::Relativistic)
761760
{
762761
// Note that with the relativistic version, these parameters would be
763762
// input for each species.
@@ -771,13 +770,18 @@ WarpX::ReadParameters ()
771770
}
772771
// Parse the input file for domain boundary potentials
773772
const ParmParse pp_boundary("boundary");
774-
pp_boundary.query("potential_lo_x", m_poisson_boundary_handler.potential_xlo_str);
775-
pp_boundary.query("potential_hi_x", m_poisson_boundary_handler.potential_xhi_str);
776-
pp_boundary.query("potential_lo_y", m_poisson_boundary_handler.potential_ylo_str);
777-
pp_boundary.query("potential_hi_y", m_poisson_boundary_handler.potential_yhi_str);
778-
pp_boundary.query("potential_lo_z", m_poisson_boundary_handler.potential_zlo_str);
779-
pp_boundary.query("potential_hi_z", m_poisson_boundary_handler.potential_zhi_str);
780-
pp_warpx.query("eb_potential(x,y,z,t)", m_poisson_boundary_handler.potential_eb_str);
773+
bool potential_specified = false;
774+
// When reading the potential at the boundary from the input file, set this flag to true if any of the potential is specified
775+
potential_specified |= pp_boundary.query("potential_lo_x", m_poisson_boundary_handler.potential_xlo_str);
776+
potential_specified |= pp_boundary.query("potential_hi_x", m_poisson_boundary_handler.potential_xhi_str);
777+
potential_specified |= pp_boundary.query("potential_lo_y", m_poisson_boundary_handler.potential_ylo_str);
778+
potential_specified |= pp_boundary.query("potential_hi_y", m_poisson_boundary_handler.potential_yhi_str);
779+
potential_specified |= pp_boundary.query("potential_lo_z", m_poisson_boundary_handler.potential_zlo_str);
780+
potential_specified |= pp_boundary.query("potential_hi_z", m_poisson_boundary_handler.potential_zhi_str);
781+
#if defined(AMREX_USE_EB)
782+
potential_specified |= pp_warpx.query("eb_potential(x,y,z,t)", m_poisson_boundary_handler.potential_eb_str);
783+
#endif
784+
m_boundary_potential_specified = potential_specified;
781785
m_poisson_boundary_handler.buildParsers();
782786
#ifdef WARPX_DIM_RZ
783787
pp_boundary.query("verboncoeur_axis_correction", verboncoeur_axis_correction);

0 commit comments

Comments
 (0)