Skip to content

Commit

Permalink
Control EB generation level (#114)
Browse files Browse the repository at this point in the history
* Add code to handle controling at which level the EB is generated.

* Update submodules
  • Loading branch information
esclapez authored Aug 5, 2022
1 parent cc9a450 commit 29a0d22
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Source/PeleLM.H
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ class PeleLM : public amrex::AmrCore {

void makeEBGeometry();

int getRestartEBMaxLevel();

void initialRedistribution();

void initCoveredState();
Expand Down Expand Up @@ -1232,6 +1234,7 @@ class PeleLM : public amrex::AmrCore {
int m_EB_refine_LevMin = -1;
int m_EB_refine_LevAdapt = -1;
int m_signDistNeeded = 0;
int m_EB_generate_max_level = -1;
amrex::Real m_derefineEBBuffer = 3.0;
std::unique_ptr<amrex::MultiFab> m_signedDist0 = nullptr;
amrex::Vector<amrex::Real> coveredState_h;
Expand Down
64 changes: 62 additions & 2 deletions Source/PeleLMEB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,32 @@ void PeleLM::makeEBGeometry()
std::string geom_type;
ppeb2.get("geom_type", geom_type);

// At what level should the EB be generated ?
// Default : max_level
int prev_max_lvl_eb = max_level;

// If restarting: use the level at which it was generated earlier
prev_max_lvl_eb = (getRestartEBMaxLevel() > 0) ? getRestartEBMaxLevel()
: prev_max_lvl_eb;

// Manual override if needed -> might incur issues with previously covered/uncovered
// cell flipping
ppeb2.query("max_level_generation",prev_max_lvl_eb);
AMREX_ALWAYS_ASSERT(prev_max_lvl_eb <= max_level);

// Stash away the level at which we ended up
m_EB_generate_max_level = prev_max_lvl_eb;

// Generate the EB data at prev_max_lvl_eb and create consistent coarse version from there.
if (geom_type == "UserDefined") {
EBUserDefined(geom.back(), req_coarsening_level, max_coarsening_level);
EBUserDefined(geom[prev_max_lvl_eb], req_coarsening_level, max_coarsening_level);
} else {
// If geom_type is not an AMReX recognized type, it'll crash.
EB2::Build(geom.back(), req_coarsening_level, max_coarsening_level);
EB2::Build(geom[prev_max_lvl_eb], req_coarsening_level, max_coarsening_level);
}

// Add finer level, might be inconsistent with the coarser level created above.
EB2::addFineLevels(max_level - prev_max_lvl_eb);
}

void PeleLM::redistributeAofS(int a_lev,
Expand Down Expand Up @@ -432,4 +452,44 @@ PeleLM::correct_vel_small_cells (Vector<MultiFab*> const& a_vel,
}
}

int
PeleLM::getRestartEBMaxLevel()
{
if (m_restart_chkfile.empty()) {
return -1;
} else {
// Go and parse the line we need
std::string File(m_restart_chkfile + "/Header");

VisMF::IO_Buffer io_buffer(VisMF::GetIOBufferSize());

Vector<char> fileCharPtr;
ParallelDescriptor::ReadAndBcastFile(File, fileCharPtr);
std::string fileCharPtrString(fileCharPtr.dataPtr());
std::istringstream is(fileCharPtrString, std::istringstream::in);

std::string line, word;

// Title line
std::getline(is, line);

// Finest level
std::getline(is, line);

// Step count
std::getline(is, line);

// Either what we're looking for or m_cur_time
std::getline(is, line);

if (line.find('.') != std::string::npos) {
return -1;
} else {
int max_eb_rst = -1;
max_eb_rst = std::stoi(line);
return max_eb_rst;
}
}
}

#endif
25 changes: 23 additions & 2 deletions Source/PeleLMPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,13 @@ void PeleLM::WriteHeader(const std::string& name, bool is_checkpoint) const
}

HeaderFile << finest_level << "\n";

// Time stepping controls

HeaderFile << m_nstep << "\n";

#ifdef AMREX_USE_EB
HeaderFile << m_EB_generate_max_level << "\n";
#endif

HeaderFile << m_cur_time << "\n";
HeaderFile << m_dt << "\n";
HeaderFile << m_prev_dt << "\n";
Expand Down Expand Up @@ -462,9 +466,26 @@ void PeleLM::ReadCheckPointFile()
is >> m_nstep;
GotoNextLine(is);

#ifdef AMREX_USE_EB
// Finest level at which EB was generated
// actually used independently, so just skip ...
std::getline(is, line);

// ... but to be backward compatible, if we get a float,
// let's assume it's m_cur_time
if (line.find('.') != std::string::npos) {
m_cur_time = std::stod(line);
} else {
// Skip line and read current time
is >> m_cur_time;
GotoNextLine(is);
}
#else

// Current time
is >> m_cur_time;
GotoNextLine(is);
#endif

// Time step size
is >> m_dt;
Expand Down
1 change: 0 additions & 1 deletion Source/PeleLMSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ void PeleLM::Setup() {
prob_parm = new ProbParm{};
prob_parm_d = (ProbParm*)The_Arena()->alloc(sizeof(ProbParm));


// Problem parameters
readProbParm();

Expand Down
2 changes: 1 addition & 1 deletion Submodules/PelePhysics
Submodule PelePhysics updated 30 files
+35 −0 Support/Mechanism/Models/BurkeDryer/mechanism.H
+36 −0 Support/Mechanism/Models/Davis/mechanism.H
+43 −0 Support/Mechanism/Models/FFCM1_Red/mechanism.H
+29 −0 Support/Mechanism/Models/JL4/mechanism.H
+34 −0 Support/Mechanism/Models/Kolla/mechanism.H
+31 −0 Support/Mechanism/Models/LiDryer/mechanism.H
+61 −0 Support/Mechanism/Models/LuDME/mechanism.H
+54 −0 Support/Mechanism/Models/LuEthylene/mechanism.H
+140 −0 Support/Mechanism/Models/NUIGalway/mechanism.H
+69 −0 Support/Mechanism/Models/SootReaction/mechanism.H
+24 −0 Support/Mechanism/Models/air/mechanism.H
+94 −0 Support/Mechanism/Models/alzeta/mechanism.H
+28 −0 Support/Mechanism/Models/chem-CH4-2step/mechanism.H
+31 −0 Support/Mechanism/Models/chem-H/mechanism.H
+25 −0 Support/Mechanism/Models/decane_3sp/mechanism.H
+75 −0 Support/Mechanism/Models/dodecane_lu/mechanism.H
+78 −0 Support/Mechanism/Models/dodecane_wang/mechanism.H
+26 −0 Support/Mechanism/Models/dodmethair_4sp/mechanism.H
+43 −0 Support/Mechanism/Models/drm19/mechanism.H
+51 −0 Support/Mechanism/Models/ethylene_af/mechanism.H
+54 −0 Support/Mechanism/Models/grimech12/mechanism.H
+57 −0 Support/Mechanism/Models/grimech30-noArN/mechanism.H
+75 −0 Support/Mechanism/Models/grimech30/mechanism.H
+25 −0 Support/Mechanism/Models/heptane_3sp/mechanism.H
+74 −0 Support/Mechanism/Models/heptane_fc/mechanism.H
+110 −0 Support/Mechanism/Models/heptane_lu_88sk/mechanism.H
+24 −0 Support/Mechanism/Models/nitrogens/mechanism.H
+56 −0 Support/Mechanism/Models/propane_fc/mechanism.H
+38 −0 Support/Mechanism/Models/sCO2/mechanism.H
+2 −1 ThirdParty/Make.ThirdParty
2 changes: 1 addition & 1 deletion Submodules/amrex
Submodule amrex updated 36 files
+20 −3 Src/Base/AMReX_Any.H
+12 −1 Src/Base/AMReX_BLBackTrace.cpp
+1 −1 Src/Base/AMReX_BaseFab.H
+2 −2 Src/Base/AMReX_BoxList.H
+1 −1 Src/Base/AMReX_FabArray.H
+178 −0 Src/Base/AMReX_MPMD.H
+225 −0 Src/Base/AMReX_MPMD.cpp
+6 −2 Src/Base/CMakeLists.txt
+4 −0 Src/Base/Make.package
+9 −1 Src/EB/AMReX_EB2.H
+9 −0 Src/EB/AMReX_EB2.cpp
+30 −2 Src/EB/AMReX_EB2_IndexSpaceI.H
+1 −0 Src/EB/AMReX_EB2_IndexSpace_STL.H
+6 −0 Src/EB/AMReX_EB2_IndexSpace_STL.cpp
+3 −3 Src/Extern/HYPRE/AMReX_HypreIJIface.H
+1 −1 Src/Extern/HYPRE/AMReX_HypreIJIface.cpp
+2 −2 Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.cpp
+5 −0 Src/LinearSolvers/MLMG/AMReX_MLCGSolver.H
+7 −0 Src/LinearSolvers/MLMG/AMReX_MLCGSolver.cpp
+2 −2 Src/LinearSolvers/MLMG/AMReX_MLCellABecLap.H
+8 −3 Src/LinearSolvers/MLMG/AMReX_MLCellABecLap.cpp
+25 −2 Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H
+435 −16 Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.cpp
+1 −1 Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.H
+12 −9 Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.cpp
+94 −43 Src/LinearSolvers/MLMG/AMReX_MLLinOp.H
+274 −3 Src/LinearSolvers/MLMG/AMReX_MLLinOp.cpp
+486 −0 Src/LinearSolvers/MLMG/AMReX_MLLinOp_temp.H
+19 −23 Src/LinearSolvers/MLMG/AMReX_MLMG.H
+234 −745 Src/LinearSolvers/MLMG/AMReX_MLMG.cpp
+5 −3 Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.H
+20 −9 Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.cpp
+22 −16 Src/LinearSolvers/MLMG/AMReX_MLNodeLinOp.H
+144 −12 Src/LinearSolvers/MLMG/AMReX_MLNodeLinOp.cpp
+7 −1 Tests/EB/CNS/Source/main.cpp
+1 −0 Tools/GNUMake/packages/Make.hdf5

0 comments on commit 29a0d22

Please sign in to comment.