aboutsummaryrefslogtreecommitdiff
path: root/Source/WarpX.H
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WarpX.H')
-rw-r--r--Source/WarpX.H74
1 files changed, 71 insertions, 3 deletions
diff --git a/Source/WarpX.H b/Source/WarpX.H
index decde3dc2..3bab73833 100644
--- a/Source/WarpX.H
+++ b/Source/WarpX.H
@@ -24,6 +24,7 @@
#include <AMReX_LayoutData.H>
#include <AMReX_Interpolater.H>
#include <AMReX_FillPatchUtil.H>
+#include <WarpXParserWrapper.H>
#ifdef _OPENMP
# include <omp.h>
@@ -73,8 +74,10 @@ public:
MultiParticleContainer& GetPartContainer () { return *mypc; }
- static void shiftMF(amrex::MultiFab& mf, const amrex::Geometry& geom, int num_shift, int dir,
- amrex::Real external_field = 0.);
+ static void shiftMF (amrex::MultiFab& mf, const amrex::Geometry& geom,
+ int num_shift, int dir, amrex::Real external_field=0.0,
+ bool useparser = false,
+ ParserWrapper *field_parser=nullptr);
static void GotoNextLine (std::istream& is);
@@ -86,6 +89,28 @@ public:
static amrex::Vector<amrex::Real> E_external_grid;
static amrex::Vector<amrex::Real> B_external_grid;
+ // Initialization Type for External E and B
+ static std::string B_ext_grid_s;
+ static std::string E_ext_grid_s;
+
+ // Parser for B_external on the grid
+ static std::string str_Bx_ext_grid_function;
+ static std::string str_By_ext_grid_function;
+ static std::string str_Bz_ext_grid_function;
+ // Parser for E_external on the grid
+ static std::string str_Ex_ext_grid_function;
+ static std::string str_Ey_ext_grid_function;
+ static std::string str_Ez_ext_grid_function;
+
+ // ParserWrapper for B_external on the grid
+ std::unique_ptr<ParserWrapper> Bxfield_parser;
+ std::unique_ptr<ParserWrapper> Byfield_parser;
+ std::unique_ptr<ParserWrapper> Bzfield_parser;
+ // ParserWrapper for E_external on the grid
+ std::unique_ptr<ParserWrapper> Exfield_parser;
+ std::unique_ptr<ParserWrapper> Eyfield_parser;
+ std::unique_ptr<ParserWrapper> Ezfield_parser;
+
// Algorithms
static long current_deposition_algo;
static long charge_deposition_algo;
@@ -323,6 +348,49 @@ public:
protected:
+ /**
+ * \brief
+ * This function initializes E, B, rho, and F, at all the levels
+ * of the multifab. rho and F are initialized with 0.
+ * The E and B fields are initialized using user-defined inputs.
+ * The initialization type is set using "B_ext_grid_init_style"
+ * and "E_ext_grid_init_style". The initialization style is set to "default"
+ * if not explicitly defined by the user, and the E and B fields are
+ * initialized with E_external_grid and B_external_grid, respectively, each with
+ * a default value of 0.
+ * If the initialization type for the E and B field is "constant",
+ * then, the E and B fields at all the levels are initialized with
+ * user-defined values for E_external_grid and B_external_grid.
+ * If the initialization type for B-field is set to
+ * "parse_B_ext_grid_function", then, the parser is used to read
+ * Bx_external_grid_function(x,y,z), By_external_grid_function(x,y,z),
+ * and Bz_external_grid_function(x,y,z).
+ * Similarly, if the E-field initialization type is set to
+ * "parse_E_ext_grid_function", then, the parser is used to read
+ * Ex_external_grid_function(x,y,z), Ey_external_grid_function(x,y,z),
+ * and Ex_external_grid_function(x,y,z). The parser for the E and B
+ * initialization assumes that the function has three independent
+ * variables, at max, namely, x, y, z. However, any number of constants
+ * can be used in the function used to define the E and B fields on the grid.
+ */
+ void InitLevelData (int lev, amrex::Real time);
+
+ /**
+ * \brief
+ * This function initializes the E and B fields on each level
+ * using the parser and the user-defined function for the external fields.
+ * The subroutine will parse the x_/y_z_external_grid_function and
+ * then, the B or E multifab is initialized based on the (x,y,z) position
+ * on the staggered yee-grid or cell-centered grid.
+ */
+ void InitializeExternalFieldsOnGridUsingParser (
+ amrex::MultiFab *mfx, amrex::MultiFab *mfy, amrex::MultiFab *mfz,
+ ParserWrapper *xfield_parser, ParserWrapper *yfield_parser,
+ ParserWrapper *zfield_parser, amrex::IntVect x_nodal_flag,
+ amrex::IntVect y_nodal_flag, amrex::IntVect z_nodal_flag,
+ const int lev);
+
+
//! Tagging cells for refinement
virtual void ErrorEst (int lev, amrex::TagBoxArray& tags, amrex::Real time, int /*ngrow*/) final;
@@ -410,7 +478,6 @@ private:
void AllocLevelData (int lev, const amrex::BoxArray& new_grids,
const amrex::DistributionMapping& new_dmap);
- void InitLevelData (int lev, amrex::Real time);
void InitFromCheckpoint ();
void PostRestart ();
@@ -665,4 +732,5 @@ private:
int insitu_pin_mesh;
};
+
#endif