Skip to content

Commit

Permalink
Revert "fix comments regarding regridding functions"
Browse files Browse the repository at this point in the history
This reverts commit 3dfec1d.
  • Loading branch information
ajnonaka committed Sep 20, 2017
1 parent 3dfec1d commit 2bc3b4d
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 114 deletions.
23 changes: 11 additions & 12 deletions Tutorials/Amr/Advection_AmrCore/Source/AmrCoreAdv.H
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,31 @@ public:
// initializes multilevel data
void InitData ();

// tag all cells for refinement
// overrides the pure virtual function in AmrCore
virtual void ErrorEst (int lev, amrex::TagBoxArray& tags, amrex::Real time, int ngrow) override;

// Make a new level from scratch using provided BoxArray and DistributionMapping.
// Only used during initialization.
// overrides the pure virtual function in AmrCore
virtual void MakeNewLevelFromScratch (int lev, amrex::Real time, const amrex::BoxArray& ba,
const amrex::DistributionMapping& dm) override;

// Make a new level using provided BoxArray and DistributionMapping and
// fill with interpolated coarse level data.
// overrides the pure virtual function in AmrCore
virtual void MakeNewLevelFromCoarse (int lev, amrex::Real time, const amrex::BoxArray& ba,
const amrex::DistributionMapping& dm) override;
const amrex::DistributionMapping& dm) override;

// Remake an existing level using provided BoxArray and DistributionMapping and
// fill with existing fine and coarse data.
// overrides the pure virtual function in AmrCore
virtual void RemakeLevel (int lev, amrex::Real time, const amrex::BoxArray& ba,
const amrex::DistributionMapping& dm) override;
const amrex::DistributionMapping& dm) override;

// Delete level data
// overrides the pure virtual function in AmrCore
virtual void ClearLevel (int lev) override;

// initialize data using a fortran routine to compute initial state
// overrides the pure virtual function in AmrCore
virtual void MakeNewLevelFromScratch (int lev, amrex::Real time, const amrex::BoxArray& ba,
const amrex::DistributionMapping& dm) override;

// tag all cells for refinement
// overrides the pure virtual function in AmrCore
virtual void ErrorEst (int lev, amrex::TagBoxArray& tags, amrex::Real time, int ngrow) override;

private:

////////////////
Expand Down
202 changes: 100 additions & 102 deletions Tutorials/Amr/Advection_AmrCore/Source/AmrCoreAdv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,106 @@ AmrCoreAdv::InitData ()
}
}

// Make a new level from scratch using provided BoxArray and DistributionMapping.
// Only used during initialization.
// overrides the pure virtual function in AmrCore
void
AmrCoreAdv::MakeNewLevelFromCoarse (int lev, Real time, const BoxArray& ba,
const DistributionMapping& dm)
{
const int ncomp = phi_new[lev-1]->nComp();
const int nghost = phi_new[lev-1]->nGrow();

phi_new[lev].reset(new MultiFab(ba, dm, ncomp, nghost));
phi_old[lev].reset(new MultiFab(ba, dm, ncomp, nghost));

t_new[lev] = time;
t_old[lev] = time - 1.e200;

if (lev > 0 && do_reflux) {
flux_reg[lev].reset(new FluxRegister(ba, dm, refRatio(lev-1), lev, ncomp));
}

FillCoarsePatch(lev, time, *phi_new[lev], 0, ncomp);
}

// Remake an existing level using provided BoxArray and DistributionMapping and
// fill with existing fine and coarse data.
// overrides the pure virtual function in AmrCore
void
AmrCoreAdv::RemakeLevel (int lev, Real time, const BoxArray& ba,
const DistributionMapping& dm)
{
const int ncomp = phi_new[lev]->nComp();
const int nghost = phi_new[lev]->nGrow();

#if __cplusplus >= 201402L
auto new_state = std::make_unique<MultiFab>(ba, dm, ncomp, nghost);
auto old_state = std::make_unique<MultiFab>(ba, dm, ncomp, nghost);
#else
std::unique_ptr<MultiFab> new_state(new MultiFab(ba, dm, ncomp, nghost));
std::unique_ptr<MultiFab> old_state(new MultiFab(ba, dm, ncomp, nghost));
#endif

FillPatch(lev, time, *new_state, 0, ncomp);

std::swap(new_state, phi_new[lev]);
std::swap(old_state, phi_old[lev]);

t_new[lev] = time;
t_old[lev] = time - 1.e200;

if (lev > 0 && do_reflux) {
flux_reg[lev].reset(new FluxRegister(ba, dm, refRatio(lev-1), lev, ncomp));
}
}

// Delete level data
// overrides the pure virtual function in AmrCore
void
AmrCoreAdv::ClearLevel (int lev)
{
phi_new[lev].reset(nullptr);
phi_old[lev].reset(nullptr);
flux_reg[lev].reset(nullptr);
}

// initialize data using a fortran routine to compute initial state
// overrides the pure virtual function in AmrCore
void AmrCoreAdv::MakeNewLevelFromScratch (int lev, Real time, const BoxArray& ba,
const DistributionMapping& dm)
{
const int ncomp = 1;
const int nghost = 0;

phi_new[lev].reset(new MultiFab(ba, dm, ncomp, nghost));
phi_old[lev].reset(new MultiFab(ba, dm, ncomp, nghost));

t_new[lev] = time;
t_old[lev] = time - 1.e200;

if (lev > 0 && do_reflux) {
flux_reg[lev].reset(new FluxRegister(ba, dm, refRatio(lev-1), lev, ncomp));
}

const Real* dx = geom[lev].CellSize();
const Real* prob_lo = geom[lev].ProbLo();
Real cur_time = t_new[lev];

MultiFab& state = *phi_new[lev];

for (MFIter mfi(state); mfi.isValid(); ++mfi)
{
const Box& box = mfi.validbox();
const int* lo = box.loVect();
const int* hi = box.hiVect();

initdata(lev, cur_time, ARLIM_3D(lo), ARLIM_3D(hi),
BL_TO_FORTRAN_3D(state[mfi]), ZFILL(dx),
ZFILL(prob_lo));
}
}

// tag all cells for refinement
// overrides the pure virtual function in AmrCore
void
Expand Down Expand Up @@ -176,108 +276,6 @@ AmrCoreAdv::ErrorEst (int lev, TagBoxArray& tags, Real time, int ngrow)
}
}


// Make a new level from scratch using provided BoxArray and DistributionMapping.
// Only used during initialization.
// overrides the pure virtual function in AmrCore
void AmrCoreAdv::MakeNewLevelFromScratch (int lev, Real time, const BoxArray& ba,
const DistributionMapping& dm)
{
const int ncomp = 1;
const int nghost = 0;

phi_new[lev].reset(new MultiFab(ba, dm, ncomp, nghost));
phi_old[lev].reset(new MultiFab(ba, dm, ncomp, nghost));

t_new[lev] = time;
t_old[lev] = time - 1.e200;

if (lev > 0 && do_reflux) {
flux_reg[lev].reset(new FluxRegister(ba, dm, refRatio(lev-1), lev, ncomp));
}

const Real* dx = geom[lev].CellSize();
const Real* prob_lo = geom[lev].ProbLo();
Real cur_time = t_new[lev];

MultiFab& state = *phi_new[lev];

for (MFIter mfi(state); mfi.isValid(); ++mfi)
{
const Box& box = mfi.validbox();
const int* lo = box.loVect();
const int* hi = box.hiVect();

initdata(lev, cur_time, ARLIM_3D(lo), ARLIM_3D(hi),
BL_TO_FORTRAN_3D(state[mfi]), ZFILL(dx),
ZFILL(prob_lo));
}
}

// Make a new level using provided BoxArray and DistributionMapping and
// fill with interpolated coarse level data.
// overrides the pure virtual function in AmrCore
void
AmrCoreAdv::MakeNewLevelFromCoarse (int lev, Real time, const BoxArray& ba,
const DistributionMapping& dm)
{
const int ncomp = phi_new[lev-1]->nComp();
const int nghost = phi_new[lev-1]->nGrow();

phi_new[lev].reset(new MultiFab(ba, dm, ncomp, nghost));
phi_old[lev].reset(new MultiFab(ba, dm, ncomp, nghost));

t_new[lev] = time;
t_old[lev] = time - 1.e200;

if (lev > 0 && do_reflux) {
flux_reg[lev].reset(new FluxRegister(ba, dm, refRatio(lev-1), lev, ncomp));
}

FillCoarsePatch(lev, time, *phi_new[lev], 0, ncomp);
}

// Remake an existing level using provided BoxArray and DistributionMapping and
// fill with existing fine and coarse data.
// overrides the pure virtual function in AmrCore
void
AmrCoreAdv::RemakeLevel (int lev, Real time, const BoxArray& ba,
const DistributionMapping& dm)
{
const int ncomp = phi_new[lev]->nComp();
const int nghost = phi_new[lev]->nGrow();

#if __cplusplus >= 201402L
auto new_state = std::make_unique<MultiFab>(ba, dm, ncomp, nghost);
auto old_state = std::make_unique<MultiFab>(ba, dm, ncomp, nghost);
#else
std::unique_ptr<MultiFab> new_state(new MultiFab(ba, dm, ncomp, nghost));
std::unique_ptr<MultiFab> old_state(new MultiFab(ba, dm, ncomp, nghost));
#endif

FillPatch(lev, time, *new_state, 0, ncomp);

std::swap(new_state, phi_new[lev]);
std::swap(old_state, phi_old[lev]);

t_new[lev] = time;
t_old[lev] = time - 1.e200;

if (lev > 0 && do_reflux) {
flux_reg[lev].reset(new FluxRegister(ba, dm, refRatio(lev-1), lev, ncomp));
}
}

// Delete level data
// overrides the pure virtual function in AmrCore
void
AmrCoreAdv::ClearLevel (int lev)
{
phi_new[lev].reset(nullptr);
phi_old[lev].reset(nullptr);
flux_reg[lev].reset(nullptr);
}

// read in some parameters from inputs file
void
AmrCoreAdv::ReadParameters ()
Expand Down

0 comments on commit 2bc3b4d

Please sign in to comment.