diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/Diagnostics/ElectrostaticIO.cpp | 22 | ||||
-rw-r--r-- | Source/Diagnostics/Make.package | 9 | ||||
-rw-r--r-- | Source/Evolve/WarpXEvolveES.cpp | 13 | ||||
-rw-r--r-- | Source/Initialization/PlasmaInjector.cpp | 39 | ||||
-rw-r--r-- | Source/Laser/LaserParticleContainer.H | 11 | ||||
-rw-r--r-- | Source/Make.WarpX | 3 | ||||
-rw-r--r-- | Source/Particles/MultiParticleContainer.H | 22 | ||||
-rw-r--r-- | Source/Particles/PhotonParticleContainer.H | 7 | ||||
-rw-r--r-- | Source/Particles/PhysicalParticleContainer.H | 40 | ||||
-rw-r--r-- | Source/Particles/PhysicalParticleContainer.cpp | 18 | ||||
-rw-r--r-- | Source/Particles/RigidInjectedParticleContainer.H | 18 | ||||
-rw-r--r-- | Source/Particles/WarpXParticleContainer.H | 29 | ||||
-rw-r--r-- | Source/Python/WarpXWrappers.cpp | 181 | ||||
-rw-r--r-- | Source/Python/WarpXWrappers.h | 18 | ||||
-rw-r--r-- | Source/WarpX.H | 4 | ||||
-rw-r--r-- | Source/WarpX.cpp | 11 |
16 files changed, 254 insertions, 191 deletions
diff --git a/Source/Diagnostics/ElectrostaticIO.cpp b/Source/Diagnostics/ElectrostaticIO.cpp index a023da0b7..332638cff 100644 --- a/Source/Diagnostics/ElectrostaticIO.cpp +++ b/Source/Diagnostics/ElectrostaticIO.cpp @@ -1,6 +1,3 @@ -#include <AMReX_MGT_Solver.H> -#include <AMReX_stencil_types.H> - #include <WarpX.H> #include <WarpX_f.H> @@ -98,24 +95,7 @@ WritePlotFileES (const amrex::Vector<std::unique_ptr<amrex::MultiFab> >& rho, } } - Vector<std::string> particle_varnames; - particle_varnames.push_back("weight"); - - particle_varnames.push_back("momentum_x"); - particle_varnames.push_back("momentum_y"); - particle_varnames.push_back("momentum_z"); - - particle_varnames.push_back("Ex"); - particle_varnames.push_back("Ey"); - particle_varnames.push_back("Ez"); - - particle_varnames.push_back("Bx"); - particle_varnames.push_back("By"); - particle_varnames.push_back("Bz"); - - Vector<std::string> int_names; - - mypc->Checkpoint(plotfilename, particle_varnames, int_names); + mypc->Checkpoint(plotfilename); WriteJobInfo(plotfilename); diff --git a/Source/Diagnostics/Make.package b/Source/Diagnostics/Make.package index 7fd5e5f76..710e4399b 100644 --- a/Source/Diagnostics/Make.package +++ b/Source/Diagnostics/Make.package @@ -2,14 +2,17 @@ CEXE_sources += WarpXIO.cpp CEXE_sources += BackTransformedDiagnostic.cpp CEXE_sources += ParticleIO.cpp CEXE_sources += FieldIO.cpp +CEXE_sources += SliceDiagnostic.cpp +ifeq ($(DO_ELECTROSTATIC),TRUE) + CEXE_sources += ElectrostaticIO.cpp +endif + CEXE_headers += FieldIO.H CEXE_headers += BackTransformedDiagnostic.H -CEXE_headers += ElectrostaticIO.cpp CEXE_headers += SliceDiagnostic.H -CEXE_sources += SliceDiagnostic.cpp ifeq ($(USE_OPENPMD), TRUE) -CEXE_sources += WarpXOpenPMD.cpp + CEXE_sources += WarpXOpenPMD.cpp endif INCLUDE_LOCATIONS += $(WARPX_HOME)/Source/Diagnostics diff --git a/Source/Evolve/WarpXEvolveES.cpp b/Source/Evolve/WarpXEvolveES.cpp index 61a8a5f32..555ab37ad 100644 --- a/Source/Evolve/WarpXEvolveES.cpp +++ b/Source/Evolve/WarpXEvolveES.cpp @@ -1,6 +1,3 @@ -#include <AMReX_MGT_Solver.H> -#include <AMReX_stencil_types.H> - #include <WarpX.H> #include <WarpX_f.H> @@ -11,16 +8,6 @@ namespace using namespace amrex; -class NoOpPhysBC - : public amrex::PhysBCFunctBase -{ -public: - NoOpPhysBC () {} - virtual ~NoOpPhysBC () {} - virtual void FillBoundary (amrex::MultiFab& mf, int, int, amrex::Real time) override { } - using amrex::PhysBCFunctBase::FillBoundary; -}; - void WarpX::EvolveES (int numsteps) { diff --git a/Source/Initialization/PlasmaInjector.cpp b/Source/Initialization/PlasmaInjector.cpp index 5464430cf..f7c7e498f 100644 --- a/Source/Initialization/PlasmaInjector.cpp +++ b/Source/Initialization/PlasmaInjector.cpp @@ -109,6 +109,7 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name) part_pos_s.end(), part_pos_s.begin(), ::tolower); + num_particles_per_cell_each_dim.assign(3, 0); if (part_pos_s == "python") { return; } else if (part_pos_s == "singleparticle") { @@ -275,17 +276,26 @@ void PlasmaInjector::parseMomentum (ParmParse& pp) int dir = 0; std::string direction = "x"; pp.query("beta", beta); + if(beta < 0){ + amrex::Abort("Please enter a positive beta value. Drift direction is set with <s_name>.bulk_vel_dir = 'x' or '+x', '-x', 'y' or '+y', etc."); + } pp.query("theta", theta); - pp.query("direction", direction); - if(direction == "x" || direction == "X"){ + pp.query("bulk_vel_dir", direction); + if(direction[0] == '-'){ + beta = -beta; + } + if((direction == "x" || direction[1] == 'x') || + (direction == "X" || direction[1] == 'X')){ dir = 0; - } else if (direction == "y" || direction == "Y"){ + } else if ((direction == "y" || direction[1] == 'y') || + (direction == "Y" || direction[1] == 'Y')){ dir = 1; - } else if (direction == "z" || direction == "Z"){ + } else if ((direction == "z" || direction[1] == 'z') || + (direction == "Z" || direction[1] == 'Z')){ dir = 2; } else{ std::stringstream stringstream; - stringstream << "Direction " << direction << " is not recognzied. Please enter x, y, or z."; + stringstream << "Cannot interpret <s_name>.bulk_vel_dir input '" << direction << "'. Please enter +/- x, y, or z with no whitespace between the sign and other character."; direction = stringstream.str(); amrex::Abort(direction.c_str()); } @@ -297,17 +307,26 @@ void PlasmaInjector::parseMomentum (ParmParse& pp) int dir = 0; std::string direction = "x"; pp.query("beta", beta); + if(beta < 0){ + amrex::Abort("Please enter a positive beta value. Drift direction is set with <s_name>.bulk_vel_dir = 'x' or '+x', '-x', 'y' or '+y', etc."); + } pp.query("theta", theta); - pp.query("direction", direction); - if(direction == "x" || direction == "X"){ + pp.query("bulk_vel_dir", direction); + if(direction[0] == '-'){ + beta = -beta; + } + if((direction == "x" || direction[1] == 'x') || + (direction == "X" || direction[1] == 'X')){ dir = 0; - } else if (direction == "y" || direction == "Y"){ + } else if ((direction == "y" || direction[1] == 'y') || + (direction == "Y" || direction[1] == 'Y')){ dir = 1; - } else if (direction == "z" || direction == "Z"){ + } else if ((direction == "z" || direction[1] == 'z') || + (direction == "Z" || direction[1] == 'Z')){ dir = 2; } else{ std::stringstream stringstream; - stringstream << "Direction " << direction << " is not recognzied. Please enter x, y, or z."; + stringstream << "Cannot interpret <s_name>.bulk_vel_dir input '" << direction << "'. Please enter +/- x, y, or z with no whitespace between the sign and other character."; direction = stringstream.str(); amrex::Abort(direction.c_str()); } diff --git a/Source/Laser/LaserParticleContainer.H b/Source/Laser/LaserParticleContainer.H index 63ace31fb..1e83ca02f 100644 --- a/Source/Laser/LaserParticleContainer.H +++ b/Source/Laser/LaserParticleContainer.H @@ -10,6 +10,17 @@ #include <memory> #include <limits> +/** + * The main method to inject a laser pulse in WarpX is to use an artificial + * antenna: particles evenly distributed in a given plane (one particle per + * cell) move at each iteration and deposit a current J onto the grid, which + * in turns creates an electromagnetic field on the grid. The particles' + * displacements are prescribed to create the field requested by the user. + * + * These artificial particles are contained in the LaserParticleContainer. + * LaserParticleContainer derives directly from WarpXParticleContainer. It + * requires a DepositCurrent function, but no FieldGather function. + */ class LaserParticleContainer : public WarpXParticleContainer { diff --git a/Source/Make.WarpX b/Source/Make.WarpX index 462299db9..fa708a62a 100644 --- a/Source/Make.WarpX +++ b/Source/Make.WarpX @@ -172,9 +172,6 @@ ifeq ($(USE_RZ),TRUE) endif ifeq ($(DO_ELECTROSTATIC),TRUE) - include $(AMREX_HOME)/Src/LinearSolvers/C_to_F_MG/Make.package - include $(AMREX_HOME)/Src/LinearSolvers/F_MG/FParallelMG.mak - include $(AMREX_HOME)/Src/F_BaseLib/FParallelMG.mak DEFINES += -DWARPX_DO_ELECTROSTATIC endif diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index d7ddc7a72..9db129b05 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -23,14 +23,20 @@ #include <string> #include <algorithm> -// -// MultiParticleContainer holds multiple (nspecies or npsecies+1 when -// using laser) WarpXParticleContainer. WarpXParticleContainer is -// derived from amrex::ParticleContainer, and it is -// polymorphic. PhysicalParticleContainer and LaserParticleContainer are -// concrete class derived from WarpXParticlContainer. -// - +/** + * The class MultiParticleContainer holds multiple instances of the polymorphic + * class WarpXParticleContainer, stored in its member variable "allcontainers". + * The class WarpX typically has a single (pointer to an) instance of + * MultiParticleContainer. + * + * MultiParticleContainer typically has two types of functions: + * - Functions that loop over all instances of WarpXParticleContainer in + * allcontainers and calls the corresponding function (for instance, + * MultiParticleContainer::Evolve loops over all particles containers and + * calls the corresponding WarpXParticleContainer::Evolve function). + * - Functions that specifically handle multiple species (for instance + * ReadParameters or mapSpeciesProduct). + */ class MultiParticleContainer { diff --git a/Source/Particles/PhotonParticleContainer.H b/Source/Particles/PhotonParticleContainer.H index 580f13f86..9b688cc59 100644 --- a/Source/Particles/PhotonParticleContainer.H +++ b/Source/Particles/PhotonParticleContainer.H @@ -4,6 +4,13 @@ #include <PhysicalParticleContainer.H> #include <AMReX_Vector.H> +/** + * Photon particles have no mass, they deposit no charge, and see specific QED + * effects. For these reasons, they are stored in the separate particle + * container PhotonParticleContainer, that inherts from + * PhysicalParticleContainer. The particle pusher and current deposition, in + * particular, are overriden in this container. + */ class PhotonParticleContainer : public PhysicalParticleContainer { diff --git a/Source/Particles/PhysicalParticleContainer.H b/Source/Particles/PhysicalParticleContainer.H index 1cd4ba621..0192ffb37 100644 --- a/Source/Particles/PhysicalParticleContainer.H +++ b/Source/Particles/PhysicalParticleContainer.H @@ -15,6 +15,13 @@ #include <map> +/** + * PhysicalParticleContainer is the ParticleContainer class containing plasma + * particles (if a simulation has 2 plasma species, say "electrons" and + * "ions"), they will be two instances of PhysicalParticleContainer. + * + * PhysicalParticleContainer inherits from WarpXParticleContainer. + */ class PhysicalParticleContainer : public WarpXParticleContainer { @@ -68,6 +75,39 @@ public: int lev, int depos_lev); + /** + * \brief Evolve is the central function PhysicalParticleContainer that + * advances plasma particles for a time dt (typically one timestep). + * + * \param lev level on which particles are living + * \param Ex MultiFab from which field Ex is gathered + * \param Ey MultiFab from which field Ey is gathered + * \param Ez MultiFab from which field Ez is gathered + * \param Bx MultiFab from which field Bx is gathered + * \param By MultiFab from which field By is gathered + * \param Bz MultiFab from which field Bz is gathered + * \param jx MultiFab to which the particles' current jx is deposited + * \param jy MultiFab to which the particles' current jy is deposited + * \param jz MultiFab to which the particles' current jz is deposited + * \param cjx Same as jx (coarser, from lev-1), when using deposition buffers + * \param cjy Same as jy (coarser, from lev-1), when using deposition buffers + * \param cjz Same as jz (coarser, from lev-1), when using deposition buffers + * \param rho MultiFab to which the particles' charge is deposited + * \param crho Same as rho (coarser, from lev-1), when using deposition buffers + * \param cEx Same as Ex (coarser, from lev-1), when using gather buffers + * \param cEy Same as Ey (coarser, from lev-1), when using gather buffers + * \param cEz Same as Ez (coarser, from lev-1), when using gather buffers + * \param cBx Same as Bx (coarser, from lev-1), when using gather buffers + * \param cBy Same as By (coarser, from lev-1), when using gather buffers + * \param cBz Same as Bz (coarser, from lev-1), when using gather buffers + * \param t current physical time + * \param dt time step by which particles are advanced + * \param a_dt_type type of time step (used for sub-cycling) + * + * Evolve iterates over particle iterator (each box) and performs filtering, + * field gather, particle push and current deposition for all particles + * in the box. + */ virtual void Evolve (int lev, const amrex::MultiFab& Ex, const amrex::MultiFab& Ey, diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index d5c08074a..94d9bc363 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -1431,15 +1431,19 @@ PhysicalParticleContainer::SplitParticles(int lev) { pti.GetPosition(xp, yp, zp); - // offset for split particles is computed as a function of cell size - // and number of particles per cell, so that a uniform distribution - // before splitting results in a uniform distribution after splitting const amrex::Vector<int> ppc_nd = plasma_injector->num_particles_per_cell_each_dim; const std::array<Real,3>& dx = WarpX::CellSize(lev); - amrex::Vector<Real> split_offset = {dx[0]/2._rt/ppc_nd[0], - dx[1]/2._rt/ppc_nd[1], - dx[2]/2._rt/ppc_nd[2]}; - + amrex::Vector<Real> split_offset = {dx[0]/2._rt, + dx[1]/2._rt, + dx[2]/2._rt}; + if (ppc_nd[0] > 0){ + // offset for split particles is computed as a function of cell size + // and number of particles per cell, so that a uniform distribution + // before splitting results in a uniform distribution after splitting + split_offset[0] /= ppc_nd[0]; + split_offset[1] /= ppc_nd[1]; + split_offset[2] /= ppc_nd[2]; + } // particle Array Of Structs data auto& particles = pti.GetArrayOfStructs(); // particle Struct Of Arrays data diff --git a/Source/Particles/RigidInjectedParticleContainer.H b/Source/Particles/RigidInjectedParticleContainer.H index a2473c5ad..fecb9c48e 100644 --- a/Source/Particles/RigidInjectedParticleContainer.H +++ b/Source/Particles/RigidInjectedParticleContainer.H @@ -4,6 +4,24 @@ #include <PhysicalParticleContainer.H> #include <AMReX_Vector.H> +/** + * When injecting a particle beam (typically for a plasma wakefield + * acceleration simulation), say propagating in the z direction, it can + * be necessary to make particles propagate in a straight line up to a given + * location z=z0. This is of particular importance when running in a boosted + * frame, where the beam may evolve due to its space charge fields before + * entering the plasma, causing the actual injected beam, and hence the whole + * simulation result, to depend on the Lorentz factor of the boost. + * + * This feature is implemented in RigidInjectedParticleContainer: At each + * iteration, for each particle, if z<z0 the particle moves in a straight line, + * and if z>z0 the particle evolves as a regular PhysicalParticleContainer. + * + * Note: This option is also useful to build self-consistent space charge + * fields for the particle beam. + * + * RigidInjectedParticleContainer derives from PhysicalParticleContainer. + */ class RigidInjectedParticleContainer : public PhysicalParticleContainer { diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H index 567bb402d..fa5c586da 100644 --- a/Source/Particles/WarpXParticleContainer.H +++ b/Source/Particles/WarpXParticleContainer.H @@ -101,8 +101,32 @@ public: } }; +// Forward-declaration needed by WarpXParticleContainer below class MultiParticleContainer; +/** + * WarpXParticleContainer is the base polymorphic class from which all concrete + * particle container classes (that store a collection of particles) derive. Derived + * classes can be used for plasma particles, photon particles, or non-physical + * particles (e.g., for the laser antenna). + * It derives from amrex::ParticleContainer<0,0,PIdx::nattribs>, where the + * template arguments stand for the number of int and amrex::Real SoA and AoS + * data in amrex::Particle. + * - AoS amrex::Real: x, y, z (default), 0 additional (first template + * parameter) + * - AoS int: id, cpu (default), 0 additional (second template parameter) + * - SoA amrex::Real: PIdx::nattribs (third template parameter), see PIdx for + * the list. + * + * WarpXParticleContainer contains the main functions for initialization, + * interaction with the grid (field gather and current deposition) and particle + * push. + * + * Note: many functions are pure virtual (meaning they MUST be defined in + * derived classes, e.g., Evolve) or empty function (meaning they + * do not do anything, e.g., FieldGather, meant to be overriden by derived + * function) or actual functions (e.g. CurrentDeposition). + */ class WarpXParticleContainer : public amrex::ParticleContainer<0,0,PIdx::nattribs> { @@ -140,6 +164,11 @@ public: amrex::Real t, amrex::Real dt) = 0; #endif // WARPX_DO_ELECTROSTATIC + /** + * Evolve is the central WarpXParticleContainer function that advances + * particles for a time dt (typically one timestep). It is a pure virtual + * function for flexibility. + */ virtual void Evolve (int lev, const amrex::MultiFab& Ex, const amrex::MultiFab& Ey, const amrex::MultiFab& Ez, const amrex::MultiFab& Bx, const amrex::MultiFab& By, const amrex::MultiFab& Bz, diff --git a/Source/Python/WarpXWrappers.cpp b/Source/Python/WarpXWrappers.cpp index ad34d71ee..e72d467d7 100644 --- a/Source/Python/WarpXWrappers.cpp +++ b/Source/Python/WarpXWrappers.cpp @@ -208,113 +208,80 @@ extern "C" return myspc.TotalNumberOfParticles(); } - amrex::Real** warpx_getEfield(int lev, int direction, - int *return_size, int *ncomps, int *ngrow, int **shapes) { - auto & mf = WarpX::GetInstance().getEfield(lev, direction); - return getMultiFabPointers(mf, return_size, ncomps, ngrow, shapes); - } - - int* warpx_getEfieldLoVects(int lev, int direction, - int *return_size, int *ngrow) { - auto & mf = WarpX::GetInstance().getEfield(lev, direction); - return getMultiFabLoVects(mf, return_size, ngrow); - } - - amrex::Real** warpx_getEfieldCP(int lev, int direction, - int *return_size, int *ncomps, int *ngrow, int **shapes) { - auto & mf = WarpX::GetInstance().getEfield_cp(lev, direction); - return getMultiFabPointers(mf, return_size, ncomps, ngrow, shapes); - } - - int* warpx_getEfieldCPLoVects(int lev, int direction, - int *return_size, int *ngrow) { - auto & mf = WarpX::GetInstance().getEfield_cp(lev, direction); - return getMultiFabLoVects(mf, return_size, ngrow); - } - - amrex::Real** warpx_getEfieldFP(int lev, int direction, - int *return_size, int *ncomps, int *ngrow, int **shapes) { - auto & mf = WarpX::GetInstance().getEfield_fp(lev, direction); - return getMultiFabPointers(mf, return_size, ncomps, ngrow, shapes); - } - - int* warpx_getEfieldFPLoVects(int lev, int direction, - int *return_size, int *ngrow) { - auto & mf = WarpX::GetInstance().getEfield_fp(lev, direction); - return getMultiFabLoVects(mf, return_size, ngrow); - } - - amrex::Real** warpx_getBfield(int lev, int direction, - int *return_size, int *ncomps, int *ngrow, int **shapes) { - auto & mf = WarpX::GetInstance().getBfield(lev, direction); - return getMultiFabPointers(mf, return_size, ncomps, ngrow, shapes); - } - - int* warpx_getBfieldLoVects(int lev, int direction, - int *return_size, int *ngrow) { - auto & mf = WarpX::GetInstance().getBfield(lev, direction); - return getMultiFabLoVects(mf, return_size, ngrow); - } - - amrex::Real** warpx_getBfieldCP(int lev, int direction, - int *return_size, int *ncomps, int *ngrow, int **shapes) { - auto & mf = WarpX::GetInstance().getBfield_cp(lev, direction); - return getMultiFabPointers(mf, return_size, ncomps, ngrow, shapes); - } - - int* warpx_getBfieldCPLoVects(int lev, int direction, - int *return_size, int *ngrow) { - auto & mf = WarpX::GetInstance().getBfield_cp(lev, direction); - return getMultiFabLoVects(mf, return_size, ngrow); - } - - amrex::Real** warpx_getBfieldFP(int lev, int direction, - int *return_size, int *ncomps, int *ngrow, int **shapes) { - auto & mf = WarpX::GetInstance().getBfield_fp(lev, direction); - return getMultiFabPointers(mf, return_size, ncomps, ngrow, shapes); - } - - int* warpx_getBfieldFPLoVects(int lev, int direction, - int *return_size, int *ngrow) { - auto & mf = WarpX::GetInstance().getBfield_fp(lev, direction); - return getMultiFabLoVects(mf, return_size, ngrow); - } - - amrex::Real** warpx_getCurrentDensity(int lev, int direction, - int *return_size, int *ncomps, int *ngrow, int **shapes) { - auto & mf = WarpX::GetInstance().getcurrent(lev, direction); - return getMultiFabPointers(mf, return_size, ncomps, ngrow, shapes); - } - - int* warpx_getCurrentDensityLoVects(int lev, int direction, - int *return_size, int *ngrow) { - auto & mf = WarpX::GetInstance().getcurrent(lev, direction); - return getMultiFabLoVects(mf, return_size, ngrow); - } - - amrex::Real** warpx_getCurrentDensityCP(int lev, int direction, - int *return_size, int *ncomps, int *ngrow, int **shapes) { - auto & mf = WarpX::GetInstance().getcurrent_cp(lev, direction); - return getMultiFabPointers(mf, return_size, ncomps, ngrow, shapes); - } - - int* warpx_getCurrentDensityCPLoVects(int lev, int direction, - int *return_size, int *ngrow) { - auto & mf = WarpX::GetInstance().getcurrent_cp(lev, direction); - return getMultiFabLoVects(mf, return_size, ngrow); - } - - amrex::Real** warpx_getCurrentDensityFP(int lev, int direction, - int *return_size, int *ncomps, int *ngrow, int **shapes) { - auto & mf = WarpX::GetInstance().getcurrent_fp(lev, direction); - return getMultiFabPointers(mf, return_size, ncomps, ngrow, shapes); - } - - int* warpx_getCurrentDensityFPLoVects(int lev, int direction, - int *return_size, int *ngrow) { - auto & mf = WarpX::GetInstance().getcurrent_fp(lev, direction); - return getMultiFabLoVects(mf, return_size, ngrow); - } +#define WARPX_GET_FIELD(FIELD, GETTER) \ + amrex::Real** FIELD(int lev, int direction, \ + int *return_size, int *ncomps, int *ngrow, int **shapes) { \ + auto & mf = GETTER(lev, direction); \ + return getMultiFabPointers(mf, return_size, ncomps, ngrow, shapes); \ + } + +#define WARPX_GET_LOVECTS(FIELD, GETTER) \ + int* FIELD(int lev, int direction, \ + int *return_size, int *ngrow) { \ + auto & mf = GETTER(lev, direction); \ + return getMultiFabLoVects(mf, return_size, ngrow); \ + } + + WARPX_GET_FIELD(warpx_getEfield, WarpX::GetInstance().getEfield); + WARPX_GET_FIELD(warpx_getEfieldCP, WarpX::GetInstance().getEfield_cp); + WARPX_GET_FIELD(warpx_getEfieldFP, WarpX::GetInstance().getEfield_fp); + + WARPX_GET_FIELD(warpx_getBfield, WarpX::GetInstance().getBfield); + WARPX_GET_FIELD(warpx_getBfieldCP, WarpX::GetInstance().getBfield_cp); + WARPX_GET_FIELD(warpx_getBfieldFP, WarpX::GetInstance().getBfield_fp); + + WARPX_GET_FIELD(warpx_getCurrentDensity, WarpX::GetInstance().getcurrent); + WARPX_GET_FIELD(warpx_getCurrentDensityCP, WarpX::GetInstance().getcurrent_cp); + WARPX_GET_FIELD(warpx_getCurrentDensityFP, WarpX::GetInstance().getcurrent_fp); + + WARPX_GET_LOVECTS(warpx_getEfieldLoVects, WarpX::GetInstance().getEfield); + WARPX_GET_LOVECTS(warpx_getEfieldCPLoVects, WarpX::GetInstance().getEfield_cp); + WARPX_GET_LOVECTS(warpx_getEfieldFPLoVects, WarpX::GetInstance().getEfield_fp); + + WARPX_GET_LOVECTS(warpx_getBfieldLoVects, WarpX::GetInstance().getBfield); + WARPX_GET_LOVECTS(warpx_getBfieldCPLoVects, WarpX::GetInstance().getBfield_cp); + WARPX_GET_LOVECTS(warpx_getBfieldFPLoVects, WarpX::GetInstance().getBfield_fp); + + WARPX_GET_LOVECTS(warpx_getCurrentDensityLoVects, WarpX::GetInstance().getcurrent); + WARPX_GET_LOVECTS(warpx_getCurrentDensityCPLoVects, WarpX::GetInstance().getcurrent_cp); + WARPX_GET_LOVECTS(warpx_getCurrentDensityFPLoVects, WarpX::GetInstance().getcurrent_fp); + +#define WARPX_GET_FIELD_PML(FIELD, GETTER) \ + amrex::Real** FIELD(int lev, int direction, \ + int *return_size, int *ncomps, int *ngrow, int **shapes) { \ + auto * pml = WarpX::GetInstance().GetPML(lev); \ + if (pml) { \ + auto & mf = *(pml->GETTER()[direction]); \ + return getMultiFabPointers(mf, return_size, ncomps, ngrow, shapes); \ + } else { \ + return nullptr; \ + } \ + } + +#define WARPX_GET_LOVECTS_PML(FIELD, GETTER) \ + int* FIELD(int lev, int direction, \ + int *return_size, int *ngrow) { \ + auto * pml = WarpX::GetInstance().GetPML(lev); \ + if (pml) { \ + auto & mf = *(pml->GETTER()[direction]); \ + return getMultiFabLoVects(mf, return_size, ngrow); \ + } else { \ + return nullptr; \ + } \ + } + + WARPX_GET_FIELD_PML(warpx_getEfieldCP_PML, GetE_cp); + WARPX_GET_FIELD_PML(warpx_getEfieldFP_PML, GetE_fp); + WARPX_GET_FIELD_PML(warpx_getBfieldCP_PML, GetB_cp); + WARPX_GET_FIELD_PML(warpx_getBfieldFP_PML, GetB_fp); + WARPX_GET_FIELD_PML(warpx_getCurrentDensityCP_PML, Getj_cp); + WARPX_GET_FIELD_PML(warpx_getCurrentDensityFP_PML, Getj_fp); + WARPX_GET_LOVECTS_PML(warpx_getEfieldCPLoVects_PML, GetE_cp); + WARPX_GET_LOVECTS_PML(warpx_getEfieldFPLoVects_PML, GetE_fp); + WARPX_GET_LOVECTS_PML(warpx_getBfieldCPLoVects_PML, GetB_cp); + WARPX_GET_LOVECTS_PML(warpx_getBfieldFPLoVects_PML, GetB_fp); + WARPX_GET_LOVECTS_PML(warpx_getCurrentDensityCPLoVects_PML, Getj_cp); + WARPX_GET_LOVECTS_PML(warpx_getCurrentDensityFPLoVects_PML, Getj_fp); amrex::ParticleReal** warpx_getParticleStructs(int speciesnumber, int lev, int* num_tiles, int** particles_per_tile) { diff --git a/Source/Python/WarpXWrappers.h b/Source/Python/WarpXWrappers.h index a272b9250..4de885b88 100644 --- a/Source/Python/WarpXWrappers.h +++ b/Source/Python/WarpXWrappers.h @@ -67,24 +67,6 @@ extern "C" { long warpx_getNumParticles(int speciesnumber); - amrex::Real** warpx_getEfield(int lev, int direction, - int *return_size, int* ncomps, int* ngrow, int **shapes); - - int* warpx_getEfieldLoVects(int lev, int direction, - int *return_size, int* ngrow); - - amrex::Real** warpx_getBfield(int lev, int direction, - int *return_size, int* ncomps, int* ngrow, int **shapes); - - int* warpx_getBfieldLoVects(int lev, int direction, - int *return_size, int* ngrow); - - amrex::Real** warpx_getCurrentDensity(int lev, int direction, - int *return_size, int* ncomps, int* ngrow, int **shapes); - - int* warpx_getCurrentDensityLoVects(int lev, int direction, - int *return_size, int* ngrow); - amrex::ParticleReal** warpx_getParticleStructs(int speciesnumber, int lev, int* num_tiles, int** particles_per_tile); diff --git a/Source/WarpX.H b/Source/WarpX.H index eec397fd1..4b2404198 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -209,6 +209,8 @@ public: void CopyJPML (); + PML* GetPML (int lev); + void PushParticlesandDepose (int lev, amrex::Real cur_time, DtType a_dt_type=DtType::Full); void PushParticlesandDepose ( amrex::Real cur_time); @@ -536,7 +538,7 @@ private: amrex::Real load_balance_knapsack_factor = 1.24; // Override sync every ? steps - int override_sync_int = 10; + int override_sync_int = 1; // Other runtime parameters int verbose = 1; diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 3d1650617..470c8ea7e 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -1180,6 +1180,17 @@ WarpX::ComputeDivE (amrex::MultiFab& divE, int dcomp, } } +PML* +WarpX::GetPML (int lev) +{ + if (do_pml) { + // This should check if pml was initialized + return pml[lev].get(); + } else { + return nullptr; + } +} + void WarpX::BuildBufferMasks () { |