Skip to content

Commit d9935f4

Browse files
authored
MultiFabRegister: use has_vector when possible (#5334)
1 parent e3e6ab8 commit d9935f4

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

Source/BoundaryConditions/PML.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ PML::CheckPoint (
12341234
{
12351235
using ablastr::fields::Direction;
12361236

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

1249-
if (fields.has(FieldType::pml_E_cp, Direction{0}, 0))
1249+
if (fields.has_vector(FieldType::pml_E_cp, 0))
12501250
{
12511251
ablastr::fields::VectorField pml_E_cp = fields.get_alldirs(FieldType::pml_E_cp, 0);
12521252
ablastr::fields::VectorField pml_B_cp = fields.get_alldirs(FieldType::pml_B_cp, 0);
@@ -1267,7 +1267,7 @@ PML::Restart (
12671267
{
12681268
using ablastr::fields::Direction;
12691269

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

1282-
if (fields.has(FieldType::pml_E_cp, Direction{0}, 0))
1282+
if (fields.has_vector(FieldType::pml_E_cp, 0))
12831283
{
12841284
ablastr::fields::VectorField pml_E_cp = fields.get_alldirs(FieldType::pml_E_cp, 0);
12851285
ablastr::fields::VectorField pml_B_cp = fields.get_alldirs(FieldType::pml_B_cp, 0);

Source/Evolve/WarpXEvolve.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ WarpX::PushParticlesandDeposit (int lev, amrex::Real cur_time, DtType a_dt_type,
11471147
m_fields.get(FieldType::current_fp, Direction{1}, lev),
11481148
m_fields.get(FieldType::current_fp, Direction{2}, lev),
11491149
lev);
1150-
if (m_fields.has(FieldType::current_buf, Direction{0}, lev)) {
1150+
if (m_fields.has_vector(FieldType::current_buf, lev)) {
11511151
ApplyInverseVolumeScalingToCurrentDensity(
11521152
m_fields.get(FieldType::current_buf, Direction{0}, lev),
11531153
m_fields.get(FieldType::current_buf, Direction{1}, lev),

Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,19 @@ void FiniteDifferenceSolver::EvolveB (
7979
fields.get(FieldType::G_fp, lev) : fields.get(FieldType::G_cp, lev);
8080
}
8181
ablastr::fields::VectorField face_areas;
82-
if (fields.has(FieldType::face_areas, Direction{0}, lev)) {
82+
if (fields.has_vector(FieldType::face_areas, lev)) {
8383
face_areas = fields.get_alldirs(FieldType::face_areas, lev);
8484
}
8585
ablastr::fields::VectorField area_mod;
86-
if (fields.has(FieldType::area_mod, Direction{0}, lev)) {
86+
if (fields.has_vector(FieldType::area_mod, lev)) {
8787
area_mod = fields.get_alldirs(FieldType::area_mod, lev);
8888
}
8989
ablastr::fields::VectorField ECTRhofield;
90-
if (fields.has(FieldType::ECTRhofield, Direction{0}, lev)) {
90+
if (fields.has_vector(FieldType::ECTRhofield, lev)) {
9191
ECTRhofield = fields.get_alldirs(FieldType::ECTRhofield, lev);
9292
}
9393
ablastr::fields::VectorField Venl;
94-
if (fields.has(FieldType::Venl, Direction{0}, lev)) {
94+
if (fields.has_vector(FieldType::Venl, lev)) {
9595
Venl = fields.get_alldirs(FieldType::Venl, lev);
9696
}
9797

Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,19 @@ void FiniteDifferenceSolver::EvolveE (
7373
}
7474

7575
ablastr::fields::VectorField edge_lengths;
76-
if (fields.has(FieldType::edge_lengths, Direction{0}, lev)) {
76+
if (fields.has_vector(FieldType::edge_lengths, lev)) {
7777
edge_lengths = fields.get_alldirs(FieldType::edge_lengths, lev);
7878
}
7979
ablastr::fields::VectorField face_areas;
80-
if (fields.has(FieldType::face_areas, Direction{0}, lev)) {
80+
if (fields.has_vector(FieldType::face_areas, lev)) {
8181
face_areas = fields.get_alldirs(FieldType::face_areas, lev);
8282
}
8383
ablastr::fields::VectorField area_mod;
84-
if (fields.has(FieldType::area_mod, Direction{0}, lev)) {
84+
if (fields.has_vector(FieldType::area_mod, lev)) {
8585
area_mod = fields.get_alldirs(FieldType::area_mod, lev);
8686
}
8787
ablastr::fields::VectorField ECTRhofield;
88-
if (fields.has(FieldType::ECTRhofield, Direction{0}, lev)) {
88+
if (fields.has_vector(FieldType::ECTRhofield, lev)) {
8989
ECTRhofield = fields.get_alldirs(FieldType::ECTRhofield, lev);
9090
}
9191

Source/FieldSolver/FiniteDifferenceSolver/EvolveEPML.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void FiniteDifferenceSolver::EvolveEPML (
6969
const ablastr::fields::VectorField Jfield = (patch_type == PatchType::fine) ?
7070
fields.get_alldirs(FieldType::pml_j_fp, level) : fields.get_alldirs(FieldType::pml_j_cp, level);
7171
ablastr::fields::VectorField edge_lengths;
72-
if (fields.has(FieldType::pml_edge_lengths, Direction{0}, level)) {
72+
if (fields.has_vector(FieldType::pml_edge_lengths, level)) {
7373
edge_lengths = fields.get_alldirs(FieldType::pml_edge_lengths, level);
7474
}
7575
amrex::MultiFab * Ffield = nullptr;

Source/Parallelization/WarpXComm.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ WarpX::UpdateAuxilaryDataStagToNodal ()
196196
{
197197
if (electromagnetic_solver_id != ElectromagneticSolverAlgo::None) {
198198
Array<std::unique_ptr<MultiFab>,3> Btmp;
199-
if (m_fields.has(FieldType::Bfield_cax, Direction{0}, lev)) {
199+
if (m_fields.has_vector(FieldType::Bfield_cax, lev)) {
200200
for (int i = 0; i < 3; ++i) {
201201
Btmp[i] = std::make_unique<MultiFab>(
202202
*m_fields.get(FieldType::Bfield_cax, Direction{i}, lev), amrex::make_alias, 0, 1);
@@ -290,7 +290,7 @@ WarpX::UpdateAuxilaryDataStagToNodal ()
290290
{
291291
if (electromagnetic_solver_id != ElectromagneticSolverAlgo::None) {
292292
Array<std::unique_ptr<MultiFab>,3> Etmp;
293-
if (m_fields.has(FieldType::Efield_cax, Direction{0}, lev)) {
293+
if (m_fields.has_vector(FieldType::Efield_cax, lev)) {
294294
for (int i = 0; i < 3; ++i) {
295295
Etmp[i] = std::make_unique<MultiFab>(
296296
*m_fields.get(FieldType::Efield_cax, Direction{i}, lev), amrex::make_alias, 0, 1);
@@ -450,7 +450,7 @@ WarpX::UpdateAuxilaryDataSameType ()
450450
Bfield_aux[lev - 1][2]->nComp(), ng_src, ng, WarpX::do_single_precision_comms,
451451
crse_period);
452452

453-
if (m_fields.has(FieldType::Bfield_cax, Direction{0}, lev))
453+
if (m_fields.has_vector(FieldType::Bfield_cax, lev))
454454
{
455455
MultiFab::Copy(*m_fields.get(FieldType::Bfield_cax, Direction{0}, lev), dBx, 0, 0, m_fields.get(FieldType::Bfield_cax, Direction{0}, lev)->nComp(), ng);
456456
MultiFab::Copy(*m_fields.get(FieldType::Bfield_cax, Direction{1}, lev), dBy, 0, 0, m_fields.get(FieldType::Bfield_cax, Direction{1}, lev)->nComp(), ng);
@@ -535,7 +535,7 @@ WarpX::UpdateAuxilaryDataSameType ()
535535
WarpX::do_single_precision_comms,
536536
crse_period);
537537

538-
if (m_fields.has(FieldType::Efield_cax, Direction{0}, lev))
538+
if (m_fields.has_vector(FieldType::Efield_cax, lev))
539539
{
540540
MultiFab::Copy(*m_fields.get(FieldType::Efield_cax, Direction{0}, lev), dEx, 0, 0, m_fields.get(FieldType::Efield_cax, Direction{0}, lev)->nComp(), ng);
541541
MultiFab::Copy(*m_fields.get(FieldType::Efield_cax, Direction{1}, lev), dEy, 0, 0, m_fields.get(FieldType::Efield_cax, Direction{1}, lev)->nComp(), ng);

Source/Particles/LaserParticleContainer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ LaserParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields,
586586
amrex::LayoutData<amrex::Real>* cost = WarpX::getCosts(lev);
587587

588588
const bool has_rho = fields.has(FieldType::rho_fp, lev);
589-
const bool has_buffer = fields.has(FieldType::current_buf, lev);
589+
const bool has_buffer = fields.has_vector(FieldType::current_buf, lev);
590590

591591
#ifdef AMREX_USE_OMP
592592
#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())

Source/Particles/PhysicalParticleContainer.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1753,9 +1753,9 @@ PhysicalParticleContainer::Evolve (ablastr::fields::MultiFabRegister& fields,
17531753
const iMultiFab* gather_masks = WarpX::GatherBufferMasks(lev);
17541754

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

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

1853-
const long np_current = has_cjx ? nfine_current : np;
1853+
const long np_current = has_J_buf ? nfine_current : np;
18541854

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

18711871
if (! do_not_push)
18721872
{
1873-
const long np_gather = has_cEx ? nfine_gather : np;
1873+
const long np_gather = has_E_cax ? nfine_gather : np;
18741874

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

0 commit comments

Comments
 (0)