Skip to content

Commit

Permalink
Rename Efield/Bfield to E/B
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiLehe committed Sep 24, 2024
1 parent 0337ee1 commit 7988c63
Show file tree
Hide file tree
Showing 57 changed files with 939 additions and 939 deletions.
6 changes: 3 additions & 3 deletions Docs/source/developers/fields.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ Due the AMR strategy used in WarpX (see section :ref:`Theory: AMR <theory-amr>`

* In some conditions, i.e., when buffers are used for the field gather (for numerical reasons), a **copy of E and B on the auxiliary grid** ``_aux`` **of the level below** ``lev-1`` is stored in fields with suffix ``_cax`` (for `coarse aux`).

As an example, the structures for the electric field are ``Efield_fp``, ``Efield_cp``, ``Efield_aux`` (and optionally ``Efield_cax``).
As an example, the structures for the electric field are ``E_fp``, ``E_cp``, ``E_aux`` (and optionally ``E_cax``).

Declaration
-----------

All the fields described above are public members of class ``WarpX``, defined in ``WarpX.H``. They are defined as an ``amrex::Vector`` (over MR levels) of ``std::array`` (for the 3 spatial components :math:`E_x`, :math:`E_y`, :math:`E_z`) of ``std::unique_ptr`` of ``amrex::MultiFab``, i.e.:

amrex::Vector<std::array< std::unique_ptr<amrex::MultiFab>, 3 > > Efield_fp;
amrex::Vector<std::array< std::unique_ptr<amrex::MultiFab>, 3 > > E_fp;

Hence, ``Ex`` on MR level ``lev`` is a pointer to an ``amrex::MultiFab``. The other fields are organized in the same way.

Expand All @@ -50,7 +50,7 @@ As all cell-wise operation, the field push is done as follows (this is split in
// Loop over MR levels
for (int lev = 0; lev <= finest_level; ++lev) {
// Get pointer to MultiFab Ex on level lev
MultiFab* Ex = Efield_fp[lev][0].get();
MultiFab* Ex = E_fp[lev][0].get();
// Loop over boxes (or tiles if not on GPU)
for ( MFIter mfi(*Ex, TilingIfNotGPU()); mfi.isValid(); ++mfi ) {
// Apply field solver on the FAB
Expand Down
4 changes: 2 additions & 2 deletions Docs/source/developers/particles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ On a loop over particles it can be useful to access the fields on the box we are

.. code-block:: cpp
// E is a reference to, say, WarpX::Efield_aux
// E is a reference to, say, WarpX::E_aux
// Get the Ex field on the grid
const FArrayBox& exfab = (*E[lev][0])[pti];
// Let's be generous and also get the underlying box (i.e., index info)
Expand All @@ -91,7 +91,7 @@ Main functions
Buffers
-------

To reduce numerical artifacts at the boundary of a mesh-refinement patch, WarpX has an option to use buffers: When particles evolve on the fine level, they gather from the coarse level (e.g., ``Efield_cax``, a copy of the ``aux`` data from the level below) if they are located on the fine level but fewer than ``WarpX::n_field_gather_buffer`` cells away from the coarse-patch boundary. Similarly, when particles evolve on the fine level, they deposit on the coarse level (e.g., ``Efield_cp``) if they are located on the fine level but fewer than ``WarpX::n_current_deposition_buffer`` cells away from the coarse-patch boundary.
To reduce numerical artifacts at the boundary of a mesh-refinement patch, WarpX has an option to use buffers: When particles evolve on the fine level, they gather from the coarse level (e.g., ``E_cax``, a copy of the ``aux`` data from the level below) if they are located on the fine level but fewer than ``WarpX::n_field_gather_buffer`` cells away from the coarse-patch boundary. Similarly, when particles evolve on the fine level, they deposit on the coarse level (e.g., ``E_cp``) if they are located on the fine level but fewer than ``WarpX::n_current_deposition_buffer`` cells away from the coarse-patch boundary.

``WarpX::gather_buffer_masks`` and ``WarpX::current_buffer_masks`` contain masks indicating if a cell is in the interior of the fine-resolution patch or in the buffers. Then, particles depending on this mask in

Expand Down
2 changes: 1 addition & 1 deletion Docs/source/developers/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Fields
The ``fields`` module provides wrapper around most of the MultiFabs that are defined in the WarpX class.
For a list of all of the available wrappers, see the file ``Python/pywarpx/fields.py``.
For each MultiFab, there is a function that will return a wrapper around the data.
For instance, the function ``ExWrapper`` returns a wrapper around the ``x`` component of the MultiFab vector ``Efield_aux``.
For instance, the function ``ExWrapper`` returns a wrapper around the ``x`` component of the MultiFab vector ``E_aux``.

.. code-block:: python
Expand Down
4 changes: 2 additions & 2 deletions Docs/source/usage/workflows/python_extend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ This object is the Python equivalent to the C++ ``WarpX`` simulation class.

.. py:method:: multifab(multifab_name: str)
Return MultiFabs by name, e.g., ``"Efield_aux[x][level=0]"``, ``"Efield_cp[x][level=0]"``, ...
Return MultiFabs by name, e.g., ``"E_aux[x][level=0]"``, ``"E_cp[x][level=0]"``, ...

The physical fields in WarpX have the following naming:

Expand Down Expand Up @@ -134,7 +134,7 @@ This example accesses the :math:`E_x(x,y,z)` field at level 0 after every time s
warpx = sim.extension.warpx
# data access
E_x_mf = warpx.multifab(f"Efield_fp[x][level=0]")
E_x_mf = warpx.multifab(f"E_fp[x][level=0]")
# compute
# iterate over mesh-refinement levels
Expand Down
2 changes: 1 addition & 1 deletion Python/pywarpx/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Functions can be called at the following times:
* ``loadExternalFields``: during ``WarpX::LoadExternalFields`` to write ``B/Efield_fp_external`` values
* ``loadExternalFields``: during ``WarpX::LoadExternalFields`` to write ``B/E_fp_external`` values
* ``beforeInitEsolve``: before the initial solve for the E fields (i.e. before the PIC loop starts)
* ``afterinit``: immediately after the init is complete
* ``beforeEsolve``: before the solve for E fields
Expand Down
48 changes: 24 additions & 24 deletions Python/pywarpx/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,37 +580,37 @@ def norm0(self, *args):

def ExWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Efield_aux", idir=0, level=level, include_ghosts=include_ghosts
mf_name="E_aux", idir=0, level=level, include_ghosts=include_ghosts
)


def EyWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Efield_aux", idir=1, level=level, include_ghosts=include_ghosts
mf_name="E_aux", idir=1, level=level, include_ghosts=include_ghosts
)


def EzWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Efield_aux", idir=2, level=level, include_ghosts=include_ghosts
mf_name="E_aux", idir=2, level=level, include_ghosts=include_ghosts
)


def BxWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Bfield_aux", idir=0, level=level, include_ghosts=include_ghosts
mf_name="B_aux", idir=0, level=level, include_ghosts=include_ghosts
)


def ByWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Bfield_aux", idir=1, level=level, include_ghosts=include_ghosts
mf_name="B_aux", idir=1, level=level, include_ghosts=include_ghosts
)


def BzWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Bfield_aux", idir=2, level=level, include_ghosts=include_ghosts
mf_name="B_aux", idir=2, level=level, include_ghosts=include_ghosts
)


Expand All @@ -634,73 +634,73 @@ def JzWrapper(level=0, include_ghosts=False):

def ExFPWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Efield_fp", idir=0, level=level, include_ghosts=include_ghosts
mf_name="E_fp", idir=0, level=level, include_ghosts=include_ghosts
)


def EyFPWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Efield_fp", idir=1, level=level, include_ghosts=include_ghosts
mf_name="E_fp", idir=1, level=level, include_ghosts=include_ghosts
)


def EzFPWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Efield_fp", idir=2, level=level, include_ghosts=include_ghosts
mf_name="E_fp", idir=2, level=level, include_ghosts=include_ghosts
)


def BxFPWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Bfield_fp", idir=0, level=level, include_ghosts=include_ghosts
mf_name="B_fp", idir=0, level=level, include_ghosts=include_ghosts
)


def ByFPWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Bfield_fp", idir=1, level=level, include_ghosts=include_ghosts
mf_name="B_fp", idir=1, level=level, include_ghosts=include_ghosts
)


def BzFPWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Bfield_fp", idir=2, level=level, include_ghosts=include_ghosts
mf_name="B_fp", idir=2, level=level, include_ghosts=include_ghosts
)


def ExFPExternalWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Efield_fp_external", idir=0, level=level, include_ghosts=include_ghosts
mf_name="E_fp_external", idir=0, level=level, include_ghosts=include_ghosts
)


def EyFPExternalWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Efield_fp_external", idir=1, level=level, include_ghosts=include_ghosts
mf_name="E_fp_external", idir=1, level=level, include_ghosts=include_ghosts
)


def EzFPExternalWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Efield_fp_external", idir=2, level=level, include_ghosts=include_ghosts
mf_name="E_fp_external", idir=2, level=level, include_ghosts=include_ghosts
)


def BxFPExternalWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Bfield_fp_external", idir=0, level=level, include_ghosts=include_ghosts
mf_name="B_fp_external", idir=0, level=level, include_ghosts=include_ghosts
)


def ByFPExternalWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Bfield_fp_external", idir=1, level=level, include_ghosts=include_ghosts
mf_name="B_fp_external", idir=1, level=level, include_ghosts=include_ghosts
)


def BzFPExternalWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Bfield_fp_external", idir=2, level=level, include_ghosts=include_ghosts
mf_name="B_fp_external", idir=2, level=level, include_ghosts=include_ghosts
)


Expand Down Expand Up @@ -771,37 +771,37 @@ def AzFPWrapper(level=0, include_ghosts=False):

def ExCPWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Efield_cp", idir=0, level=level, include_ghosts=include_ghosts
mf_name="E_cp", idir=0, level=level, include_ghosts=include_ghosts
)


def EyCPWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Efield_cp", idir=1, level=level, include_ghosts=include_ghosts
mf_name="E_cp", idir=1, level=level, include_ghosts=include_ghosts
)


def EzCPWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Efield_cp", idir=2, level=level, include_ghosts=include_ghosts
mf_name="E_cp", idir=2, level=level, include_ghosts=include_ghosts
)


def BxCPWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Bfield_cp", idir=0, level=level, include_ghosts=include_ghosts
mf_name="B_cp", idir=0, level=level, include_ghosts=include_ghosts
)


def ByCPWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Bfield_cp", idir=1, level=level, include_ghosts=include_ghosts
mf_name="B_cp", idir=1, level=level, include_ghosts=include_ghosts
)


def BzCPWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(
mf_name="Bfield_cp", idir=2, level=level, include_ghosts=include_ghosts
mf_name="B_cp", idir=2, level=level, include_ghosts=include_ghosts
)


Expand Down
24 changes: 12 additions & 12 deletions Source/BoundaryConditions/PML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,16 +703,16 @@ PML::PML (const int lev, const BoxArray& grid_ba,
auto& warpx = WarpX::GetInstance();
using ablastr::fields::Direction;

const amrex::BoxArray ba_Ex = amrex::convert(ba, warpx.m_fields.get(FieldType::Efield_fp, Direction{0}, 0)->ixType().toIntVect());
const amrex::BoxArray ba_Ey = amrex::convert(ba, warpx.m_fields.get(FieldType::Efield_fp, Direction{1}, 0)->ixType().toIntVect());
const amrex::BoxArray ba_Ez = amrex::convert(ba, warpx.m_fields.get(FieldType::Efield_fp, Direction{2}, 0)->ixType().toIntVect());
const amrex::BoxArray ba_Ex = amrex::convert(ba, warpx.m_fields.get(FieldType::E_fp, Direction{0}, 0)->ixType().toIntVect());
const amrex::BoxArray ba_Ey = amrex::convert(ba, warpx.m_fields.get(FieldType::E_fp, Direction{1}, 0)->ixType().toIntVect());
const amrex::BoxArray ba_Ez = amrex::convert(ba, warpx.m_fields.get(FieldType::E_fp, Direction{2}, 0)->ixType().toIntVect());
warpx.m_fields.alloc_init(FieldType::pml_E_fp, Direction{0}, lev, ba_Ex, dm, ncompe, nge, 0.0_rt, false, false);
warpx.m_fields.alloc_init(FieldType::pml_E_fp, Direction{1}, lev, ba_Ey, dm, ncompe, nge, 0.0_rt, false, false);
warpx.m_fields.alloc_init(FieldType::pml_E_fp, Direction{2}, lev, ba_Ez, dm, ncompe, nge, 0.0_rt, false, false);

const amrex::BoxArray ba_Bx = amrex::convert(ba, warpx.m_fields.get(FieldType::Bfield_fp, Direction{0}, 0)->ixType().toIntVect());
const amrex::BoxArray ba_By = amrex::convert(ba, warpx.m_fields.get(FieldType::Bfield_fp, Direction{1}, 0)->ixType().toIntVect());
const amrex::BoxArray ba_Bz = amrex::convert(ba, warpx.m_fields.get(FieldType::Bfield_fp, Direction{2}, 0)->ixType().toIntVect());
const amrex::BoxArray ba_Bx = amrex::convert(ba, warpx.m_fields.get(FieldType::B_fp, Direction{0}, 0)->ixType().toIntVect());
const amrex::BoxArray ba_By = amrex::convert(ba, warpx.m_fields.get(FieldType::B_fp, Direction{1}, 0)->ixType().toIntVect());
const amrex::BoxArray ba_Bz = amrex::convert(ba, warpx.m_fields.get(FieldType::B_fp, Direction{2}, 0)->ixType().toIntVect());
warpx.m_fields.alloc_init(FieldType::pml_B_fp, Direction{0}, lev, ba_Bx, dm, ncompb, ngb, 0.0_rt, false, false);
warpx.m_fields.alloc_init(FieldType::pml_B_fp, Direction{1}, lev, ba_By, dm, ncompb, ngb, 0.0_rt, false, false);
warpx.m_fields.alloc_init(FieldType::pml_B_fp, Direction{2}, lev, ba_Bz, dm, ncompb, ngb, 0.0_rt, false, false);
Expand Down Expand Up @@ -841,16 +841,16 @@ PML::PML (const int lev, const BoxArray& grid_ba,
cdm.define(cba);
}

const amrex::BoxArray cba_Ex = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::Efield_cp, Direction{0}, 1)->ixType().toIntVect());
const amrex::BoxArray cba_Ey = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::Efield_cp, Direction{1}, 1)->ixType().toIntVect());
const amrex::BoxArray cba_Ez = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::Efield_cp, Direction{2}, 1)->ixType().toIntVect());
const amrex::BoxArray cba_Ex = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::E_cp, Direction{0}, 1)->ixType().toIntVect());
const amrex::BoxArray cba_Ey = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::E_cp, Direction{1}, 1)->ixType().toIntVect());
const amrex::BoxArray cba_Ez = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::E_cp, Direction{2}, 1)->ixType().toIntVect());
warpx.m_fields.alloc_init(FieldType::pml_E_cp, Direction{0}, lev, cba_Ex, cdm, ncompe, nge, 0.0_rt, false, false);
warpx.m_fields.alloc_init(FieldType::pml_E_cp, Direction{1}, lev, cba_Ey, cdm, ncompe, nge, 0.0_rt, false, false);
warpx.m_fields.alloc_init(FieldType::pml_E_cp, Direction{2}, lev, cba_Ez, cdm, ncompe, nge, 0.0_rt, false, false);

const amrex::BoxArray cba_Bx = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::Bfield_cp, Direction{0}, 1)->ixType().toIntVect());
const amrex::BoxArray cba_By = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::Bfield_cp, Direction{1}, 1)->ixType().toIntVect());
const amrex::BoxArray cba_Bz = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::Bfield_cp, Direction{2}, 1)->ixType().toIntVect());
const amrex::BoxArray cba_Bx = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::B_cp, Direction{0}, 1)->ixType().toIntVect());
const amrex::BoxArray cba_By = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::B_cp, Direction{1}, 1)->ixType().toIntVect());
const amrex::BoxArray cba_Bz = amrex::convert(cba, WarpX::GetInstance().m_fields.get(FieldType::B_cp, Direction{2}, 1)->ixType().toIntVect());
warpx.m_fields.alloc_init(FieldType::pml_B_cp, Direction{0}, lev, cba_Bx, cdm, ncompb, ngb, 0.0_rt, false, false);
warpx.m_fields.alloc_init(FieldType::pml_B_cp, Direction{1}, lev, cba_By, cdm, ncompb, ngb, 0.0_rt, false, false);
warpx.m_fields.alloc_init(FieldType::pml_B_cp, Direction{2}, lev, cba_Bz, cdm, ncompb, ngb, 0.0_rt, false, false);
Expand Down
8 changes: 4 additions & 4 deletions Source/BoundaryConditions/PML_RZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ PML_RZ::PML_RZ (int lev, amrex::BoxArray const& grid_ba, amrex::DistributionMapp
bool const remake = false;
bool const redistribute_on_remake = false;

amrex::MultiFab const& Er_fp = *warpx.m_fields.get(FieldType::Efield_fp, Direction{0}, lev);
amrex::MultiFab const& Et_fp = *warpx.m_fields.get(FieldType::Efield_fp, Direction{1}, lev);
amrex::MultiFab const& Er_fp = *warpx.m_fields.get(FieldType::E_fp, Direction{0}, lev);
amrex::MultiFab const& Et_fp = *warpx.m_fields.get(FieldType::E_fp, Direction{1}, lev);
amrex::BoxArray const ba_Er = amrex::convert(grid_ba, Er_fp.ixType().toIntVect());
amrex::BoxArray const ba_Et = amrex::convert(grid_ba, Et_fp.ixType().toIntVect());
warpx.m_fields.alloc_init(FieldType::pml_E_fp, Direction{0}, lev, ba_Er, grid_dm, Er_fp.nComp(), Er_fp.nGrowVect(), 0.0_rt,
remake, redistribute_on_remake);
warpx.m_fields.alloc_init(FieldType::pml_E_fp, Direction{1}, lev, ba_Et, grid_dm, Et_fp.nComp(), Et_fp.nGrowVect(), 0.0_rt,
remake, redistribute_on_remake);

amrex::MultiFab const& Br_fp = *warpx.m_fields.get(FieldType::Bfield_fp,Direction{0},lev);
amrex::MultiFab const& Bt_fp = *warpx.m_fields.get(FieldType::Bfield_fp,Direction{1},lev);
amrex::MultiFab const& Br_fp = *warpx.m_fields.get(FieldType::B_fp,Direction{0},lev);
amrex::MultiFab const& Bt_fp = *warpx.m_fields.get(FieldType::B_fp,Direction{1},lev);
amrex::BoxArray const ba_Br = amrex::convert(grid_ba, Br_fp.ixType().toIntVect());
amrex::BoxArray const ba_Bt = amrex::convert(grid_ba, Bt_fp.ixType().toIntVect());
warpx.m_fields.alloc_init(FieldType::pml_B_fp, Direction{0}, lev, ba_Br, grid_dm, Br_fp.nComp(), Br_fp.nGrowVect(), 0.0_rt,
Expand Down
8 changes: 4 additions & 4 deletions Source/BoundaryConditions/WarpXEvolvePML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ WarpX::DampPML (const int lev, PatchType patch_type)
if (pml_rz[lev]) {
using ablastr::fields::Direction;
using warpx::fields::FieldType;
pml_rz[lev]->ApplyDamping( m_fields.get(FieldType::Efield_fp, Direction{1}, lev),
m_fields.get(FieldType::Efield_fp, Direction{2}, lev),
m_fields.get(FieldType::Bfield_fp, Direction{1}, lev),
m_fields.get(FieldType::Bfield_fp, Direction{2}, lev),
pml_rz[lev]->ApplyDamping( m_fields.get(FieldType::E_fp, Direction{1}, lev),
m_fields.get(FieldType::E_fp, Direction{2}, lev),
m_fields.get(FieldType::B_fp, Direction{1}, lev),
m_fields.get(FieldType::B_fp, Direction{2}, lev),
dt[lev], m_fields);
}
#endif
Expand Down
Loading

0 comments on commit 7988c63

Please sign in to comment.