Skip to content

Commit

Permalink
make no_substepping multilevel and set to 1 if anelastic; also set de…
Browse files Browse the repository at this point in the history
…fault coupling_type to TwoWay
  • Loading branch information
asalmgren committed Sep 21, 2024
1 parent a3b9137 commit 06e3d7a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
46 changes: 27 additions & 19 deletions Source/DataStructs/ERF_DataStruct.H
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,7 @@ struct SolverChoice {
// Should we project the initial velocity field to make it divergence-free?
pp.query("project_initial_velocity", project_initial_velocity);

int nvals_inc = pp.countval("anelastic");
AMREX_ALWAYS_ASSERT(nvals_inc == 0 || nvals_inc == 1 || nvals_inc >= max_level+1);
amrex::Vector<int> anelastic_in; anelastic_in.resize(nvals_inc);
pp.queryarr("anelastic",anelastic_in);
if (nvals_inc == 0) {
for (int i = 0; i <= max_level; ++i) anelastic.push_back(0);
amrex::Warning("NOTE: ERF was built with the Poisson solver but the anelastic flag was not set");
} else if (nvals_inc == 1) {
for (int i = 0; i <= max_level; ++i) anelastic.push_back(anelastic_in[0]);
} else {
for (int i = 0; i <= max_level; ++i) anelastic.push_back(anelastic_in[0]);
}
read_int_string(max_level, "anelastic", anelastic, 0);

bool any_anelastic = false;
for (int i = 0; i <= max_level; ++i) {
Expand All @@ -219,15 +208,15 @@ struct SolverChoice {
for (int i = 0; i <= max_level; ++i) anelastic[i] = 0;
#endif

// Turn off acoustic substepping?
pp.query("no_substepping", no_substepping);
read_int_string(max_level, "no_substepping", no_substepping, 0);

pp.query("force_stage1_single_substep", force_stage1_single_substep);

#if defined(ERF_USE_POISSON_SOLVE)
for (int lev = 0; lev <= max_level; lev++) {
if (anelastic[lev] != 0 && no_substepping == 0)
{
amrex::Abort("If you specify anelastic, you must specific no_substepping");
no_subtepping = 1;
}
}
#endif
Expand Down Expand Up @@ -363,7 +352,7 @@ struct SolverChoice {
}

// Which type of refinement
static std::string coupling_type_string = "OneWay";
static std::string coupling_type_string = "TwoWay";
pp.query("coupling_type",coupling_type_string);
if (coupling_type_string == "TwoWay") {
coupling_type = CouplingType::TwoWay;
Expand Down Expand Up @@ -441,10 +430,10 @@ struct SolverChoice {
void display(int max_level)
{
amrex::Print() << "SOLVER CHOICE: " << std::endl;
amrex::Print() << "no_substepping : " << no_substepping << std::endl;
amrex::Print() << "force_stage1_single_substep : " << force_stage1_single_substep << std::endl;
for (int lev = 0; lev <= max_level; lev++) {
amrex::Print() << "anelastic at level : " << lev << " is " << anelastic[lev] << std::endl;
amrex::Print() << "anelastic at level : " << lev << " is " << anelastic[lev] << std::endl;
amrex::Print() << "no_substepping at level : " << lev << " is " << no_substepping[lev] << std::endl;
}
amrex::Print() << "use_coriolis : " << use_coriolis << std::endl;
amrex::Print() << "use_gravity : " << use_gravity << std::endl;
Expand Down Expand Up @@ -532,6 +521,24 @@ struct SolverChoice {
}
}

void read_int_string (int max_level, const char* string_to_read,
amrex::Vector<int>& vec_to_fill, int default_int)
{
amrex::ParmParse pp("erf");
int nvals = pp.countval(string_to_read);
AMREX_ALWAYS_ASSERT(nvals == 0 || nvals == 1 || nvals >= max_level+1);
amrex::Vector<int> temp; temp.resize(nvals);
pp.queryarr(string_to_read,temp);
if (nvals == 0) {
for (int i = 0; i <= max_level; ++i) vec_to_fill.push_back(default_int);
} else if (nvals == 1) {
for (int i = 0; i <= max_level; ++i) vec_to_fill.push_back(temp[0]);
} else {
for (int i = 0; i <= max_level; ++i) vec_to_fill.push_back(temp[i]);
}
}


AdvChoice advChoice;
DiffChoice diffChoice;
SpongeChoice spongeChoice;
Expand All @@ -540,10 +547,11 @@ struct SolverChoice {
// Default prefix
std::string pp_prefix {"erf"};

int no_substepping = 0;
int force_stage1_single_substep = 1;

amrex::Vector<int> no_substepping;
amrex::Vector<int> anelastic;

int constant_density = 0;
int project_every_stage = 1;
int ncorr = 1;
Expand Down
2 changes: 1 addition & 1 deletion Source/ERF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@ ERF::ParameterSanityChecks ()
for (int lev = 0; lev <= max_level; lev++)
{
// We ignore fixed_fast_dt if not substepping
if (solverChoice.no_substepping) {
if (solverChoice.no_substepping[lev]) {
fixed_fast_dt[lev] = -1.0;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/ERF_make_new_arrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ ERF::initialize_integrator (int lev, MultiFab& cons_mf, MultiFab& vel_mf)
int_state.push_back(MultiFab(convert(ba,IntVect(0,0,1)), dm, 1, vel_mf.nGrow())); // zmom

mri_integrator_mem[lev] = std::make_unique<MRISplitIntegrator<Vector<MultiFab> > >(int_state);
mri_integrator_mem[lev]->setNoSubstepping(solverChoice.no_substepping);
mri_integrator_mem[lev]->setNoSubstepping(solverChoice.no_substepping[lev]);
mri_integrator_mem[lev]->setAnelastic(solverChoice.anelastic[lev]);
mri_integrator_mem[lev]->setNcompCons(ncomp_cons);
mri_integrator_mem[lev]->setForceFirstStageSingleSubstep(solverChoice.force_stage1_single_substep);
Expand Down
2 changes: 1 addition & 1 deletion Source/TimeIntegration/ERF_ComputeTimestep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ ERF::estTimeStep (int level, long& dt_fast_ratio) const
&vars_new[level][Vars::yvel],
&vars_new[level][Vars::zvel]});

int l_no_substepping = solverChoice.no_substepping;
int l_no_substepping = solverChoice.no_substepping[level];
int l_anelastic = solverChoice.anelastic[level];

#ifdef ERF_USE_EB
Expand Down

0 comments on commit 06e3d7a

Please sign in to comment.