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

Fix derive for state variables with ghost cells #707

Merged
merged 4 commits into from
Oct 23, 2023
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
9 changes: 7 additions & 2 deletions Exec/RegTests/PMF/pmf-lidryer-arkode.inp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pelec.v = 1 # verbosity in PeleC cpp files
amr.v = 1 # verbosity in Amr.cpp
#amr.grid_log = grdlog # name of grid logging file

# REFINEMENT / REGRIDDING
# REFINEMENT / REGRIDDING
amr.max_level = 1 # maximum level number allowed
amr.ref_ratio = 2 2 2 2 # refinement ratio
amr.regrid_int = 2 2 2 2 # how often to regrid
Expand All @@ -49,14 +49,19 @@ pelec.plot_rhoy = 0
pelec.plot_massfrac = 1

# PROBLEM PARAMETERS
prob.pamb = 1013250.0
prob.pamb = 1013250.0
prob.phi_in = -0.5
prob.pertmag = 0.005
prob.pmf_datafile = "LiDryer_H2_p1_phi0_4000tu0300.dat"

tagging.max_ftracerr_lev = 4
tagging.ftracerr = 150.e-6

tagging.refinement_indicators = gtemp
tagging.gtemp.adjacent_difference_greater = 100
tagging.gtemp.field_name = Temp
tagging.gtemp.max_level = 1

extern.new_Jacobian_each_cell = 0

pelec.do_hydro = 1
Expand Down
7 changes: 5 additions & 2 deletions Source/BCfill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ struct PCHypFillExtDir
void operator()(
const amrex::IntVect& iv,
amrex::Array4<amrex::Real> const& dest,
const int /*dcomp*/,
const int /*numcomp*/,
const int dcomp,
const int numcomp,
amrex::GeometryData const& geom,
const amrex::Real time,
const amrex::BCRec* bcr,
const int /*bcomp*/,
const int /*orig_comp*/) const
{
// We need the whole state to apply physical BCs
AMREX_ALWAYS_ASSERT(dcomp == 0 && numcomp == NVAR);

const int* domlo = geom.Domain().loVect();
const int* domhi = geom.Domain().hiVect();
const amrex::Real* prob_lo = geom.ProbLo();
Expand Down
54 changes: 32 additions & 22 deletions Source/PeleC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1932,29 +1932,21 @@ PeleC::errorEst(
std::unique_ptr<amrex::MultiFab>
PeleC::derive(const std::string& name, amrex::Real time, int ngrow)
{
if ((do_les) && (name == "C_s2")) {
if ((do_les) && ((name == "C_s2") || (name == "C_I") || (name == "Pr_T"))) {
AMREX_ASSERT(ngrow <= LES_Coeffs.nGrow());
std::unique_ptr<amrex::MultiFab> derive_dat(
new amrex::MultiFab(grids, dmap, 1, 0));
amrex::MultiFab::Copy(*derive_dat, LES_Coeffs, comp_Cs2, 0, 1, 0);
return derive_dat;
}
if ((do_les) && (name == "C_I")) {
std::unique_ptr<amrex::MultiFab> derive_dat(
new amrex::MultiFab(grids, dmap, 1, 0));
amrex::MultiFab::Copy(*derive_dat, LES_Coeffs, comp_CI, 0, 1, 0);
return derive_dat;
}
if ((do_les) && (les_model != 1) && (name == "Pr_T")) {
std::unique_ptr<amrex::MultiFab> derive_dat(
new amrex::MultiFab(grids, dmap, 1, 0));
amrex::MultiFab::Copy(*derive_dat, LES_Coeffs, comp_PrT, 0, 1, 0);
return derive_dat;
}
if ((do_les) && (les_model == 1) && (name == "Pr_T")) {
std::unique_ptr<amrex::MultiFab> derive_dat(
new amrex::MultiFab(grids, dmap, 1, 0));
amrex::MultiFab::Copy(*derive_dat, LES_Coeffs, comp_Cs2ovPrT, 0, 1, 0);
amrex::MultiFab::Divide(*derive_dat, LES_Coeffs, comp_Cs2, 0, 1, 0);
new amrex::MultiFab(grids, dmap, 1, ngrow));
if (name == "C_s2") {
amrex::MultiFab::Copy(*derive_dat, LES_Coeffs, comp_Cs2, 0, 1, ngrow);
} else if (name == "C_I") {
amrex::MultiFab::Copy(*derive_dat, LES_Coeffs, comp_CI, 0, 1, ngrow);
} else if ((les_model != 1) && (name == "Pr_T")) {
amrex::MultiFab::Copy(*derive_dat, LES_Coeffs, comp_PrT, 0, 1, ngrow);
} else { // Pr_T, les_model==1
amrex::MultiFab::Copy(
*derive_dat, LES_Coeffs, comp_Cs2ovPrT, 0, 1, ngrow);
amrex::MultiFab::Divide(*derive_dat, LES_Coeffs, comp_Cs2, 0, 1, ngrow);
}
return derive_dat;
}

Expand All @@ -1968,6 +1960,24 @@ PeleC::derive(const std::string& name, amrex::Real time, int ngrow)
return mf;
}

// Can't use the AmrLevel derive for state variables with ghost cells:
// That will fillpatch them individually, but we require the full state
// for physBCs. Therefore, instead fillpatch the full state and then grab
// the component we need.
int index, scomp;
if (isStateVariable(name, index, scomp) && (ngrow > 0)) {
amrex::MultiFab S_data(
get_new_data(State_Type).boxArray(),
get_new_data(State_Type).DistributionMap(), NVAR, ngrow, amrex::MFInfo(),
Factory());
FillPatch(
*this, S_data, S_data.nGrow(), time, State_Type, Density, NVAR, 0);
std::unique_ptr<amrex::MultiFab> derive_dat(
new amrex::MultiFab(grids, dmap, 1, ngrow, amrex::MFInfo(), Factory()));
amrex::MultiFab::Copy(*derive_dat, S_data, scomp, 0, 1, ngrow);
return derive_dat;
}

// For those using GrowBoxByOne we need this
if ((name == "enstrophy") || (name == "magvort") || (name == "divu")) {
ngrow += 1;
Expand Down
Loading