Skip to content

Commit

Permalink
MultiFabRegister follow-up: use has_vector when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
EZoni committed Sep 26, 2024
1 parent e3e6ab8 commit e50f414
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions Source/BoundaryConditions/PML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ PML::CheckPoint (
{
using ablastr::fields::Direction;

if (fields.has(FieldType::pml_E_fp, Direction{0}, 0))
if (fields.has_vector(FieldType::pml_E_fp, 0))
{
ablastr::fields::VectorField pml_E_fp = fields.get_alldirs(FieldType::pml_E_fp, 0);
ablastr::fields::VectorField pml_B_fp = fields.get_alldirs(FieldType::pml_B_fp, 0);
Expand All @@ -1246,7 +1246,7 @@ PML::CheckPoint (
VisMF::AsyncWrite(*pml_B_fp[2], dir+"_Bz_fp");
}

if (fields.has(FieldType::pml_E_cp, Direction{0}, 0))
if (fields.has_vector(FieldType::pml_E_cp, 0))
{
ablastr::fields::VectorField pml_E_cp = fields.get_alldirs(FieldType::pml_E_cp, 0);
ablastr::fields::VectorField pml_B_cp = fields.get_alldirs(FieldType::pml_B_cp, 0);
Expand All @@ -1267,7 +1267,7 @@ PML::Restart (
{
using ablastr::fields::Direction;

if (fields.has(FieldType::pml_E_fp, Direction{0}, 0))
if (fields.has_vector(FieldType::pml_E_fp, 0))
{
ablastr::fields::VectorField pml_E_fp = fields.get_alldirs(FieldType::pml_E_fp, 0);
ablastr::fields::VectorField pml_B_fp = fields.get_alldirs(FieldType::pml_B_fp, 0);
Expand All @@ -1279,7 +1279,7 @@ PML::Restart (
VisMF::Read(*pml_B_fp[2], dir+"_Bz_fp");
}

if (fields.has(FieldType::pml_E_cp, Direction{0}, 0))
if (fields.has_vector(FieldType::pml_E_cp, 0))
{
ablastr::fields::VectorField pml_E_cp = fields.get_alldirs(FieldType::pml_E_cp, 0);
ablastr::fields::VectorField pml_B_cp = fields.get_alldirs(FieldType::pml_B_cp, 0);
Expand Down
2 changes: 1 addition & 1 deletion Source/Evolve/WarpXEvolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ WarpX::PushParticlesandDeposit (int lev, amrex::Real cur_time, DtType a_dt_type,
m_fields.get(FieldType::current_fp, Direction{1}, lev),
m_fields.get(FieldType::current_fp, Direction{2}, lev),
lev);
if (m_fields.has(FieldType::current_buf, Direction{0}, lev)) {
if (m_fields.has_vector(FieldType::current_buf, lev)) {
ApplyInverseVolumeScalingToCurrentDensity(
m_fields.get(FieldType::current_buf, Direction{0}, lev),
m_fields.get(FieldType::current_buf, Direction{1}, lev),
Expand Down
8 changes: 4 additions & 4 deletions Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ void FiniteDifferenceSolver::EvolveB (
fields.get(FieldType::G_fp, lev) : fields.get(FieldType::G_cp, lev);
}
ablastr::fields::VectorField face_areas;
if (fields.has(FieldType::face_areas, Direction{0}, lev)) {
if (fields.has_vector(FieldType::face_areas, lev)) {
face_areas = fields.get_alldirs(FieldType::face_areas, lev);
}
ablastr::fields::VectorField area_mod;
if (fields.has(FieldType::area_mod, Direction{0}, lev)) {
if (fields.has_vector(FieldType::area_mod, lev)) {
area_mod = fields.get_alldirs(FieldType::area_mod, lev);
}
ablastr::fields::VectorField ECTRhofield;
if (fields.has(FieldType::ECTRhofield, Direction{0}, lev)) {
if (fields.has_vector(FieldType::ECTRhofield, lev)) {
ECTRhofield = fields.get_alldirs(FieldType::ECTRhofield, lev);
}
ablastr::fields::VectorField Venl;
if (fields.has(FieldType::Venl, Direction{0}, lev)) {
if (fields.has_vector(FieldType::Venl, lev)) {
Venl = fields.get_alldirs(FieldType::Venl, lev);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Particles/LaserParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ LaserParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields,
amrex::LayoutData<amrex::Real>* cost = WarpX::getCosts(lev);

const bool has_rho = fields.has(FieldType::rho_fp, lev);
const bool has_buffer = fields.has(FieldType::current_buf, lev);
const bool has_buffer = fields.has_vector(FieldType::current_buf, lev);

#ifdef AMREX_USE_OMP
#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
Expand Down
10 changes: 5 additions & 5 deletions Source/Particles/PhysicalParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1753,9 +1753,9 @@ PhysicalParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields,
const iMultiFab* gather_masks = WarpX::GatherBufferMasks(lev);

const bool has_rho = fields.has(FieldType::rho_fp, lev);
const bool has_cjx = fields.has(FieldType::current_buf, Direction{0}, lev);
const bool has_cEx = fields.has(FieldType::Efield_cax, Direction{0}, lev);
const bool has_buffer = has_cEx || has_cjx;
const bool has_J_buf = fields.has_vector(FieldType::current_buf, lev);
const bool has_E_cax = fields.has_vector(FieldType::Efield_cax, lev);
const bool has_buffer = has_E_cax || has_J_buf;

amrex::MultiFab & Ex = *fields.get(FieldType::Efield_aux, Direction{0}, lev);
amrex::MultiFab & Ey = *fields.get(FieldType::Efield_aux, Direction{1}, lev);
Expand Down Expand Up @@ -1850,7 +1850,7 @@ PhysicalParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields,
pti, lev, current_masks, gather_masks );
}

const long np_current = has_cjx ? nfine_current : np;
const long np_current = has_J_buf ? nfine_current : np;

if (has_rho && ! skip_deposition && ! do_not_deposit) {
// Deposit charge before particle push, in component 0 of MultiFab rho.
Expand All @@ -1870,7 +1870,7 @@ PhysicalParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields,

if (! do_not_push)
{
const long np_gather = has_cEx ? nfine_gather : np;
const long np_gather = has_E_cax ? nfine_gather : np;

int e_is_nodal = Ex.is_nodal() and Ey.is_nodal() and Ez.is_nodal();

Expand Down

0 comments on commit e50f414

Please sign in to comment.