Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WarpX class: move SetDotMask to anonymous namespace in WarpX.cpp #5644

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/FieldSolver/ImplicitSolvers/WarpXSolverVec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ void WarpXSolverVec::Copy ( FieldType a_array_type,
for (int lev = 0; lev < m_num_amr_levels; ++lev) {
if (m_array_type != FieldType::None) {
for (int n = 0; n < 3; ++n) {
const amrex::iMultiFab* dotMask = m_WarpX->getFieldDotMaskPointer(m_array_type,lev,n);
const amrex::iMultiFab* dotMask = m_WarpX->getFieldDotMaskPointer(m_array_type, lev, ablastr::fields::Direction{n});
auto rtmp = amrex::MultiFab::Dot( *dotMask,
*m_array_vec[lev][n], 0,
*a_X.getArrayVec()[lev][n], 0, 1, 0, local);
result += rtmp;
}
}
if (m_scalar_type != FieldType::None) {
const amrex::iMultiFab* dotMask = m_WarpX->getFieldDotMaskPointer(m_scalar_type,lev,0);
const amrex::iMultiFab* dotMask = m_WarpX->getFieldDotMaskPointer(m_scalar_type,lev, ablastr::fields::Direction{0});
auto rtmp = amrex::MultiFab::Dot( *dotMask,
*m_scalar_vec[lev], 0,
*a_X.getScalarVec()[lev], 0, 1, 0, local);
Expand Down
9 changes: 1 addition & 8 deletions Source/WarpX.H
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,7 @@ public:
* Get pointer to the amrex::MultiFab containing the dotMask for the specified field
*/
[[nodiscard]] const amrex::iMultiFab*
getFieldDotMaskPointer (warpx::fields::FieldType field_type, int lev, int dir) const;

/**
* \brief
* Set the dotMask container
*/
void SetDotMask( std::unique_ptr<amrex::iMultiFab>& field_dotMask,
std::string const & field_name, int lev, int dir ) const;
getFieldDotMaskPointer (warpx::fields::FieldType field_type, int lev, ablastr::fields::Direction dir) const;

[[nodiscard]] bool DoPML () const {return do_pml;}
[[nodiscard]] bool DoFluidSpecies () const {return do_fluid_species;}
Expand Down
48 changes: 27 additions & 21 deletions Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,27 @@ namespace
std::any_of(field_boundary_hi.begin(), field_boundary_hi.end(), is_pml);
return is_any_pml;
}

/**
* \brief
* Set the dotMask container
*/
void SetDotMask( std::unique_ptr<amrex::iMultiFab>& field_dotMask,
ablastr::fields::ConstScalarField const& field,
amrex::Periodicity const& periodicity)

{
// Define the dot mask for this field_type needed to properly compute dotProduct()
// for field values that have shared locations on different MPI ranks
if (field_dotMask != nullptr) { return; }

const auto& this_ba = field->boxArray();
const auto tmp = amrex::MultiFab{
this_ba, field->DistributionMap(),
1, 0, amrex::MFInfo().SetAlloc(false)};

field_dotMask = tmp.OwnerMask(periodicity);
}
}

void WarpX::MakeWarpX ()
Expand Down Expand Up @@ -3316,40 +3337,25 @@ WarpX::MakeDistributionMap (int lev, amrex::BoxArray const& ba)
}

const amrex::iMultiFab*
WarpX::getFieldDotMaskPointer ( FieldType field_type, int lev, int dir ) const
WarpX::getFieldDotMaskPointer ( FieldType field_type, int lev, ablastr::fields::Direction dir ) const
{
const auto periodicity = Geom(lev).periodicity();
switch(field_type)
{
case FieldType::Efield_fp :
SetDotMask( Efield_dotMask[lev][dir], "Efield_fp", lev, dir );
::SetDotMask( Efield_dotMask[lev][dir], m_fields.get("Efield_fp", dir, lev), periodicity);
return Efield_dotMask[lev][dir].get();
case FieldType::Bfield_fp :
SetDotMask( Bfield_dotMask[lev][dir], "Bfield_fp", lev, dir );
::SetDotMask( Bfield_dotMask[lev][dir], m_fields.get("Bfield_fp", dir, lev), periodicity);
return Bfield_dotMask[lev][dir].get();
case FieldType::vector_potential_fp :
SetDotMask( Afield_dotMask[lev][dir], "vector_potential_fp", lev, dir );
::SetDotMask( Afield_dotMask[lev][dir], m_fields.get("vector_potential_fp", dir, lev), periodicity);
return Afield_dotMask[lev][dir].get();
case FieldType::phi_fp :
SetDotMask( phi_dotMask[lev], "phi_fp", lev, 0 );
::SetDotMask( phi_dotMask[lev], m_fields.get("phi_fp", dir, lev), periodicity);
return phi_dotMask[lev].get();
default:
WARPX_ABORT_WITH_MESSAGE("Invalid field type for dotMask");
return Efield_dotMask[lev][dir].get();
}
}

void WarpX::SetDotMask( std::unique_ptr<amrex::iMultiFab>& field_dotMask,
std::string const & field_name, int lev, int dir ) const
{
// Define the dot mask for this field_type needed to properly compute dotProduct()
// for field values that have shared locations on different MPI ranks
if (field_dotMask != nullptr) { return; }

ablastr::fields::ConstVectorField const& this_field = m_fields.get_alldirs(field_name,lev);
const amrex::BoxArray& this_ba = this_field[dir]->boxArray();
const amrex::MultiFab tmp( this_ba, this_field[dir]->DistributionMap(),
1, 0, amrex::MFInfo().SetAlloc(false) );
const amrex::Periodicity& period = Geom(lev).periodicity();
field_dotMask = tmp.OwnerMask(period);

}
Loading