Skip to content

Commit

Permalink
Pass the this ptr to LevelData constructor to allow for easier
Browse files Browse the repository at this point in the history
addition of optional components
  • Loading branch information
cgilet committed Jun 18, 2024
1 parent 0e232e8 commit 60c2852
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 49 deletions.
8 changes: 3 additions & 5 deletions src/incflo.H
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,9 @@ private:
/*! Initialize tracer particles */
void initializeTracerParticles (amrex::ParGDBBase* gdb
#ifdef AMREX_USE_EB
,amrex::EBFArrayBoxFactory const& ebfact
,amrex::EBFArrayBoxFactory const& ebfact
#endif
);
);

/*! Evolve tracers and hydro particles */
void evolveTracerParticles (AMREX_D_DECL(amrex::Vector<amrex::MultiFab const*> const& u_mac,
Expand All @@ -586,9 +586,7 @@ private:
LevelData (amrex::BoxArray const& ba,
amrex::DistributionMapping const& dm,
amrex::FabFactory<amrex::FArrayBox> const& fact,
int ntrac, int ng_state,
const std::string& advection_type, bool implicit_diffusion,
bool use_tensor_correction, bool advect_tracer);
incflo* a_incflo);
// cell-centered multifabs
amrex::MultiFab velocity;
amrex::MultiFab velocity_o;
Expand Down
6 changes: 1 addition & 5 deletions src/incflo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,7 @@ void incflo::MakeNewLevelFromScratch (int lev, Real time, const BoxArray& new_gr
#endif

m_leveldata[lev] = std::make_unique<LevelData>(grids[lev], dmap[lev], *m_factory[lev],
m_ntrac, nghost_state(),
m_advection_type,
m_diff_type==DiffusionType::Implicit,
use_tensor_correction,
m_advect_tracer);
this);

m_t_new[lev] = time;
m_t_old[lev] = time - Real(1.e200);
Expand Down
12 changes: 2 additions & 10 deletions src/incflo_regrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ void incflo::MakeNewLevelFromCoarse (int lev,
std::unique_ptr<FabFactory<FArrayBox> > new_fact(new FArrayBoxFactory());
#endif
std::unique_ptr<LevelData> new_leveldata
(new LevelData(ba, dm, *new_fact, m_ntrac, nghost_state(),
m_advection_type,
m_diff_type==DiffusionType::Implicit,
use_tensor_correction,
m_advect_tracer));
(new LevelData(ba, dm, *new_fact, this));
fillcoarsepatch_velocity(lev, time, new_leveldata->velocity, 0);
fillcoarsepatch_density(lev, time, new_leveldata->density, 0);
if (m_ntrac > 0) {
Expand Down Expand Up @@ -79,11 +75,7 @@ void incflo::RemakeLevel (int lev, Real time, const BoxArray& ba,
std::unique_ptr<FabFactory<FArrayBox> > new_fact(new FArrayBoxFactory());
#endif
std::unique_ptr<LevelData> new_leveldata
(new LevelData(ba, dm, *new_fact, m_ntrac, nghost_state(),
m_advection_type,
m_diff_type==DiffusionType::Implicit,
use_tensor_correction,
m_advect_tracer));
(new LevelData(ba, dm, *new_fact, this));
fillpatch_velocity(lev, time, new_leveldata->velocity, 0);
fillpatch_density(lev, time, new_leveldata->density, 0);
if (m_ntrac > 0) {
Expand Down
57 changes: 28 additions & 29 deletions src/setup/incflo_arrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,49 @@ using namespace amrex;
incflo::LevelData::LevelData (amrex::BoxArray const& ba,
amrex::DistributionMapping const& dm,
amrex::FabFactory<FArrayBox> const& fact,
int ntrac, int ng_state,
const std::string& advection_type, bool implicit_diffusion,
bool use_tensor_correction, bool advect_tracer)
: velocity (ba, dm, AMREX_SPACEDIM, ng_state, MFInfo(), fact),
velocity_o (ba, dm, AMREX_SPACEDIM, ng_state, MFInfo(), fact),
velocity_eb (ba, dm, AMREX_SPACEDIM, ng_state, MFInfo(), fact),
incflo* my_incflo)
: velocity (ba, dm, AMREX_SPACEDIM, my_incflo->nghost_state(), MFInfo(), fact),
velocity_o (ba, dm, AMREX_SPACEDIM, my_incflo->nghost_state(), MFInfo(), fact),
velocity_eb (ba, dm, AMREX_SPACEDIM, my_incflo->nghost_state(), MFInfo(), fact),

density (ba, dm, 1 , ng_state, MFInfo(), fact),
density_eb (ba, dm, 1 , ng_state, MFInfo(), fact),
density_o (ba, dm, 1 , ng_state, MFInfo(), fact),
density_nph (ba, dm, 1 , ng_state, MFInfo(), fact),
density (ba, dm, 1 , my_incflo->nghost_state(), MFInfo(), fact),
density_eb (ba, dm, 1 , my_incflo->nghost_state(), MFInfo(), fact),
density_o (ba, dm, 1 , my_incflo->nghost_state(), MFInfo(), fact),
density_nph (ba, dm, 1 , my_incflo->nghost_state(), MFInfo(), fact),

tracer (ba, dm, ntrac , ng_state, MFInfo(), fact),
tracer_eb (ba, dm, ntrac , ng_state, MFInfo(), fact),
tracer_o (ba, dm, ntrac , ng_state, MFInfo(), fact),
tracer (ba, dm, my_incflo->m_ntrac, my_incflo->nghost_state(), MFInfo(), fact),
tracer_eb (ba, dm, my_incflo->m_ntrac, my_incflo->nghost_state(), MFInfo(), fact),
tracer_o (ba, dm, my_incflo->m_ntrac, my_incflo->nghost_state(), MFInfo(), fact),

mac_phi (ba, dm, 1 , 1 , MFInfo(), fact),
p_nd (amrex::convert(ba,IntVect::TheNodeVector()),
mac_phi (ba, dm, 1 , 1 , MFInfo(), fact),
p_nd (amrex::convert(ba,IntVect::TheNodeVector()),
dm, 1 , 0 , MFInfo(), fact),
gp (ba, dm, AMREX_SPACEDIM, 0 , MFInfo(), fact),
gp (ba, dm, AMREX_SPACEDIM, 0 , MFInfo(), fact),

conv_velocity_o(ba, dm, AMREX_SPACEDIM, 0, MFInfo(), fact),
conv_density_o (ba, dm, 1 , 0, MFInfo(), fact),
conv_tracer_o (ba, dm, ntrac , 0, MFInfo(), fact)
conv_velocity_o (ba, dm, AMREX_SPACEDIM , 0, MFInfo(), fact),
conv_density_o (ba, dm, 1 , 0, MFInfo(), fact),
conv_tracer_o (ba, dm, my_incflo->m_ntrac, 0, MFInfo(), fact)
{
if (advection_type != "MOL") {
if (my_incflo->m_advection_type != "MOL") {
divtau_o.define(ba, dm, AMREX_SPACEDIM, 0, MFInfo(), fact);
if (advect_tracer) {
laps_o.define(ba, dm, ntrac, 0, MFInfo(), fact);
if (my_incflo->m_advect_tracer) {
laps_o.define(ba, dm, my_incflo->m_ntrac, 0, MFInfo(), fact);
}
} else {
conv_velocity.define(ba, dm, AMREX_SPACEDIM, 0, MFInfo(), fact);
conv_density.define (ba, dm, 1 , 0, MFInfo(), fact);
conv_tracer.define (ba, dm, ntrac , 0, MFInfo(), fact);
conv_velocity.define(ba, dm, AMREX_SPACEDIM , 0, MFInfo(), fact);
conv_density.define (ba, dm, 1 , 0, MFInfo(), fact);
conv_tracer.define (ba, dm, my_incflo->m_ntrac, 0, MFInfo(), fact);

if (!implicit_diffusion || use_tensor_correction)
bool implicit_diffusion = my_incflo->m_diff_type == DiffusionType::Implicit;
if (!implicit_diffusion || my_incflo->use_tensor_correction)
{
divtau.define (ba, dm, AMREX_SPACEDIM, 0, MFInfo(), fact);
divtau_o.define(ba, dm, AMREX_SPACEDIM, 0, MFInfo(), fact);
}
if (!implicit_diffusion && advect_tracer)
if (!implicit_diffusion && my_incflo->m_advect_tracer)
{
laps.define (ba, dm, ntrac, 0, MFInfo(), fact);
laps_o.define(ba, dm, ntrac, 0, MFInfo(), fact);
laps.define (ba, dm, my_incflo->m_ntrac, 0, MFInfo(), fact);
laps_o.define(ba, dm, my_incflo->m_ntrac, 0, MFInfo(), fact);
}
}
}
Expand Down

0 comments on commit 60c2852

Please sign in to comment.