Skip to content

Commit

Permalink
Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgrote committed Nov 5, 2024
1 parent 6c226e8 commit b2d5cdf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
37 changes: 18 additions & 19 deletions Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include <array>
#include <memory>

using namespace amrex;
using namespace ablastr::fields;

/**
Expand Down Expand Up @@ -128,29 +127,29 @@ void FiniteDifferenceSolver::EvolveE (
#endif

amrex::LayoutData<amrex::Real>* cost = WarpX::getCosts(lev);
Real constexpr c2 = PhysConst::c * PhysConst::c;
amrex::Real constexpr c2 = PhysConst::c * PhysConst::c;

// Loop through the grids, and over the tiles within each grid
#ifdef AMREX_USE_OMP
#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
#endif
for ( MFIter mfi(*Efield[0], TilingIfNotGPU()); mfi.isValid(); ++mfi ) {
for ( amrex::MFIter mfi(*Efield[0], amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi ) {
if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers)
{
amrex::Gpu::synchronize();
}
auto wt = static_cast<amrex::Real>(amrex::second());

// Extract field data for this grid/tile
Array4<Real> const& Ex = Efield[0]->array(mfi);
Array4<Real> const& Ey = Efield[1]->array(mfi);
Array4<Real> const& Ez = Efield[2]->array(mfi);
Array4<Real> const& Bx = Bfield[0]->array(mfi);
Array4<Real> const& By = Bfield[1]->array(mfi);
Array4<Real> const& Bz = Bfield[2]->array(mfi);
Array4<Real> const& jx = Jfield[0]->array(mfi);
Array4<Real> const& jy = Jfield[1]->array(mfi);
Array4<Real> const& jz = Jfield[2]->array(mfi);
amrex::Array4<amrex::Real> const& Ex = Efield[0]->array(mfi);
amrex::Array4<amrex::Real> const& Ey = Efield[1]->array(mfi);
amrex::Array4<amrex::Real> const& Ez = Efield[2]->array(mfi);
amrex::Array4<amrex::Real> const& Bx = Bfield[0]->array(mfi);
amrex::Array4<amrex::Real> const& By = Bfield[1]->array(mfi);
amrex::Array4<amrex::Real> const& Bz = Bfield[2]->array(mfi);
amrex::Array4<amrex::Real> const& jx = Jfield[0]->array(mfi);
amrex::Array4<amrex::Real> const& jy = Jfield[1]->array(mfi);
amrex::Array4<amrex::Real> const& jz = Jfield[2]->array(mfi);

amrex::Array4<amrex::Real> lx, ly, lz;
if (EB::enabled()) {
Expand All @@ -160,14 +159,14 @@ void FiniteDifferenceSolver::EvolveE (
}

// Extract stencil coefficients
Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr();
Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr();
Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr();
amrex::Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr();
amrex::Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr();
amrex::Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr();

// Extract tileboxes for which to loop
Box const& tex = mfi.tilebox(Efield[0]->ixType().toIntVect());
Box const& tey = mfi.tilebox(Efield[1]->ixType().toIntVect());
Box const& tez = mfi.tilebox(Efield[2]->ixType().toIntVect());
amrex::Box const& tex = mfi.tilebox(Efield[0]->ixType().toIntVect());
amrex::Box const& tey = mfi.tilebox(Efield[1]->ixType().toIntVect());
amrex::Box const& tez = mfi.tilebox(Efield[2]->ixType().toIntVect());

// Loop over the cells and update the fields
amrex::ParallelFor(
Expand Down Expand Up @@ -223,7 +222,7 @@ void FiniteDifferenceSolver::EvolveE (
if (Ffield) {

// Extract field data for this grid/tile
const Array4<Real const> F = Ffield->array(mfi);
const amrex::Array4<amrex::Real const> F = Ffield->array(mfi);

// Loop over the cells and update the fields
amrex::ParallelFor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class FiniteDifferenceSolver
FiniteDifferenceSolver (
ElectromagneticSolverAlgo fdtd_algo,
std::array<amrex::Real,3> cell_size,
ablastr::utils::enums::GridType grid_type );
ablastr::utils::enums::GridType grid_type,
int ncomps);

void EvolveB ( ablastr::fields::MultiFabRegister& fields,
int lev,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@
FiniteDifferenceSolver::FiniteDifferenceSolver (
ElectromagneticSolverAlgo const fdtd_algo,
std::array<amrex::Real,3> cell_size,
ablastr::utils::enums::GridType grid_type):
ablastr::utils::enums::GridType grid_type,
int ncomps):
// Register the type of finite-difference algorithm
m_fdtd_algo{fdtd_algo},
m_grid_type{grid_type}
m_grid_type{grid_type},
m_ncomps{ncomps}
{
// return if not FDTD
if (fdtd_algo == ElectromagneticSolverAlgo::None || fdtd_algo == ElectromagneticSolverAlgo::PSATD) {
return;
}

m_ncomps = WarpX::ncomps;

// Calculate coefficients of finite-difference stencil
#ifdef WARPX_DIM_RZ
m_dr = cell_size[0];
Expand Down
4 changes: 2 additions & 2 deletions Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2452,7 +2452,7 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm
#endif
} // ElectromagneticSolverAlgo::PSATD
else {
m_fdtd_solver_fp[lev] = std::make_unique<FiniteDifferenceSolver>(electromagnetic_solver_id, dx, grid_type);
m_fdtd_solver_fp[lev] = std::make_unique<FiniteDifferenceSolver>(electromagnetic_solver_id, dx, grid_type, ncomps);
}

//
Expand Down Expand Up @@ -2664,7 +2664,7 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm
} // ElectromagneticSolverAlgo::PSATD
else {
m_fdtd_solver_cp[lev] = std::make_unique<FiniteDifferenceSolver>(electromagnetic_solver_id, cdx,
grid_type);
grid_type, ncomps);
}
}

Expand Down

0 comments on commit b2d5cdf

Please sign in to comment.