Skip to content

Commit

Permalink
Updates for PeleLMeX (AMReX-Combustion#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrood-nrel authored Dec 21, 2023
1 parent a32da14 commit 8b7c52c
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 86 deletions.
24 changes: 0 additions & 24 deletions CMake/PelePhysicsConfig.cmake.in

This file was deleted.

15 changes: 10 additions & 5 deletions Source/Radiation/Constants.H
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,26 @@ struct RadComps

void checkIndices()
{
if (co2Indx > 0)
if (co2Indx > 0) {
std::cout << " include radiative gas: CO2, the index is " << co2Indx
<< std::endl;
if (h2oIndx > 0)
}
if (h2oIndx > 0) {
std::cout << " include radiative gas: H2O, the index is " << h2oIndx
<< std::endl;
if (coIndx > 0)
}
if (coIndx > 0) {
std::cout << " include radiative gas: CO, the index is " << coIndx
<< std::endl;
if (ch4Indx > 0)
}
if (ch4Indx > 0) {
std::cout << " include radiative gas: CH4, the index is " << coIndx
<< std::endl;
if (c2h4Indx > 0)
}
if (c2h4Indx > 0) {
std::cout << " include radiative gas: C2H4, the index is " << coIndx
<< std::endl;
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion Source/Radiation/MLMGParam.H
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public:
consolidation_(1),
composite_solve_(1),
fine_level_solve_only_(0),
use_hypre_(0),
use_hypre_(false),
ebbc_type_(2)
{
}
Expand Down
7 changes: 4 additions & 3 deletions Source/Radiation/POneMulti.H
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public:
auto const max_coarsening_level = mlmgpp_.max_coarsening_level_;
auto const agglomeration = mlmgpp_.agglomeration_;
auto const consolidation = mlmgpp_.consolidation_;
info_.setAgglomeration(agglomeration);
info_.setConsolidation(consolidation);
info_.setAgglomeration(agglomeration != 0);
info_.setConsolidation(consolidation != 0);
info_.setMaxCoarseningLevel(max_coarsening_level);
}

Expand Down Expand Up @@ -99,8 +99,9 @@ public:
mlmg.setVerbose(verbose);
mlmg.setBottomVerbose(bottom_verbose);
mlmg.setBottomSolver(amrex::BottomSolver::bicgstab);
if (use_hypre)
if (use_hypre) {
mlmg.setBottomSolver(amrex::MLMG::BottomSolver::hypre);
}
mlmg.setBottomTolerance(bottom_reltol);
mlmg.setBottomToleranceAbs(bottom_abstol);

Expand Down
50 changes: 29 additions & 21 deletions Source/Radiation/PeleLMRad.H
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ public:
)
: geom_(geom), grids_(grids), dmap_(dmap), rc_(rc), mlmgpp_(mlmgpp)
{
if (amrex::ParallelDescriptor::IOProcessor())
if (amrex::ParallelDescriptor::IOProcessor()) {
rc_.checkIndices();
}

auto const nlevels = geom_.size();

Expand Down Expand Up @@ -202,18 +203,20 @@ public:
if (j >= dlo.y && j <= dhi.y && k >= dlo.z && k <= dhi.z) {
int jj, kk;

if (j < bx.loVect3d()[1])
if (j < bx.loVect3d()[1]) {
jj = bx.loVect3d()[1];
else if (j > bx.hiVect3d()[1])
} else if (j > bx.hiVect3d()[1]) {
jj = bx.hiVect3d()[1];
else
} else {
jj = j;
if (k < bx.loVect3d()[2])
}
if (k < bx.loVect3d()[2]) {
kk = bx.loVect3d()[2];
else if (k > bx.hiVect3d()[2])
} else if (k > bx.hiVect3d()[2]) {
kk = bx.hiVect3d()[2];
else
} else {
kk = k;
}

if (i > dhi.x) {
robin_cell = true;
Expand All @@ -226,18 +229,20 @@ public:
} else if (i >= dlo.x && i <= dhi.x && k >= dlo.z && k <= dhi.z) {
int ii, kk;

if (i < bx.loVect3d()[0])
if (i < bx.loVect3d()[0]) {
ii = bx.loVect3d()[0];
else if (i > bx.hiVect3d()[0])
} else if (i > bx.hiVect3d()[0]) {
ii = bx.hiVect3d()[0];
else
} else {
ii = i;
if (k < bx.loVect3d()[2])
}
if (k < bx.loVect3d()[2]) {
kk = bx.loVect3d()[2];
else if (k > bx.hiVect3d()[2])
} else if (k > bx.hiVect3d()[2]) {
kk = bx.hiVect3d()[2];
else
} else {
kk = k;
}

if (j > dhi.y) {
robin_cell = true;
Expand All @@ -250,18 +255,20 @@ public:
} else if (i >= dlo.x && i <= dhi.x && j >= dlo.y && j <= dhi.y) {
int ii, jj;

if (i < bx.loVect3d()[0])
if (i < bx.loVect3d()[0]) {
ii = bx.loVect3d()[0];
else if (i > bx.hiVect3d()[0])
} else if (i > bx.hiVect3d()[0]) {
ii = bx.hiVect3d()[0];
else
} else {
ii = i;
if (j < bx.loVect3d()[1])
}
if (j < bx.loVect3d()[1]) {
jj = bx.loVect3d()[1];
else if (j > bx.hiVect3d()[1])
} else if (j > bx.hiVect3d()[1]) {
jj = bx.hiVect3d()[1];
else
} else {
jj = j;
}

if (k > dhi.z) {
robin_cell = true;
Expand Down Expand Up @@ -342,8 +349,9 @@ public:
{
// std::cout << "begin of evaluateRad() \n";

for (int ilev = 0; ilev < grids_.size(); ++ilev)
for (int ilev = 0; ilev < grids_.size(); ++ilev) {
bcoef_[ilev].FillBoundary();
}
// if (composite_solve_)
rte_->solve();
// else
Expand All @@ -365,7 +373,7 @@ public:
});
}

RadComps const readRadIndices() const { return rc_; }
RadComps readRadIndices() const { return rc_; }

amrex::Vector<amrex::MultiFab> const& G() { return solution_; }

Expand Down
31 changes: 16 additions & 15 deletions Source/Radiation/PlanckMean.H
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,25 @@ namespace PeleRad {
class PlanckMean
{
private:
amrex::GpuArray<amrex::Real, 126ul> kpco2_;
amrex::GpuArray<amrex::Real, 126ul> kph2o_;
amrex::GpuArray<amrex::Real, 126ul> kpco_;
amrex::GpuArray<amrex::Real, 126ul> kpch4_;
amrex::GpuArray<amrex::Real, 126ul> kpc2h4_;
amrex::GpuArray<amrex::Real, 126ul> kpsoot_;
amrex::GpuArray<amrex::Real, 126UL> kpco2_;
amrex::GpuArray<amrex::Real, 126UL> kph2o_;
amrex::GpuArray<amrex::Real, 126UL> kpco_;
amrex::GpuArray<amrex::Real, 126UL> kpch4_;
amrex::GpuArray<amrex::Real, 126UL> kpc2h4_;
amrex::GpuArray<amrex::Real, 126UL> kpsoot_;

AMREX_GPU_HOST
void read_kp_file(
std::string file_path, amrex::GpuArray<amrex::Real, 126ul>& file_data)
std::string file_path, amrex::GpuArray<amrex::Real, 126UL>& file_data)
{
std::ifstream datastream(file_path);
if (!datastream.is_open()) {
amrex::Abort("PeleRad: Failed to open data file: " + file_path);
}
size_t idx = 0;
for (amrex::Real T_temp, kp_temp; datastream >> T_temp >> kp_temp;) {
if (!amrex::almostEqual(T_temp, 300.0 + 20.0 * idx)) {
if (!amrex::almostEqual(
T_temp, 300.0 + 20.0 * static_cast<amrex::Real>(idx))) {
amrex::Abort(
"PeleRad: Invalid temperatures in data file: " + file_path);
}
Expand All @@ -37,7 +38,7 @@ private:
"PeleRad: Invalid number of entries in data file, must have 126: " +
file_path);
}
file_data[idx] = kp_temp;
file_data[idx] = static_cast<int>(kp_temp);
idx++;
}
if (idx < 126) {
Expand Down Expand Up @@ -73,22 +74,22 @@ public:
}

AMREX_GPU_HOST_DEVICE
const amrex::GpuArray<amrex::Real, 126ul>& kpco2() const { return kpco2_; }
const amrex::GpuArray<amrex::Real, 126UL>& kpco2() const { return kpco2_; }

AMREX_GPU_HOST_DEVICE
const amrex::GpuArray<amrex::Real, 126ul>& kph2o() const { return kph2o_; }
const amrex::GpuArray<amrex::Real, 126UL>& kph2o() const { return kph2o_; }

AMREX_GPU_HOST_DEVICE
const amrex::GpuArray<amrex::Real, 126ul>& kpco() const { return kpco_; }
const amrex::GpuArray<amrex::Real, 126UL>& kpco() const { return kpco_; }

AMREX_GPU_HOST_DEVICE
const amrex::GpuArray<amrex::Real, 126ul>& kpch4() const { return kpch4_; }
const amrex::GpuArray<amrex::Real, 126UL>& kpch4() const { return kpch4_; }

AMREX_GPU_HOST_DEVICE
const amrex::GpuArray<amrex::Real, 126ul>& kpc2h4() const { return kpc2h4_; }
const amrex::GpuArray<amrex::Real, 126UL>& kpc2h4() const { return kpc2h4_; }

AMREX_GPU_HOST_DEVICE
const amrex::GpuArray<amrex::Real, 126ul>& kpsoot() const { return kpsoot_; }
const amrex::GpuArray<amrex::Real, 126UL>& kpsoot() const { return kpsoot_; }
};

} // namespace PeleRad
Expand Down
18 changes: 7 additions & 11 deletions Source/Radiation/SpectralModels.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
#include <AMReX_FArrayBox.H>
#include <AMReX_Gpu.H>

namespace PeleRad {

namespace RadProp {
namespace PeleRad::RadProp {
AMREX_GPU_HOST_DEVICE
AMREX_FORCE_INLINE
void
Expand Down Expand Up @@ -38,7 +36,7 @@ amrex::Real
interpk(
int const& TindexL,
amrex::Real const& weight,
amrex::GpuArray<amrex::Real, 126ul> const& k)
amrex::GpuArray<amrex::Real, 126UL> const& k)
{
return (1.0 - weight) * k[TindexL] + weight * k[TindexL + 1];
}
Expand All @@ -56,9 +54,9 @@ getRadPropGas(
amrex::Array4<const amrex::Real> const& temp,
amrex::Array4<const amrex::Real> const& pressure,
amrex::Array4<amrex::Real> const& absc,
amrex::GpuArray<amrex::Real, 126ul> const& kdataco2,
amrex::GpuArray<amrex::Real, 126ul> const& kdatah2o,
amrex::GpuArray<amrex::Real, 126ul> const& kdataco)
amrex::GpuArray<amrex::Real, 126UL> const& kdataco2,
amrex::GpuArray<amrex::Real, 126UL> const& kdatah2o,
amrex::GpuArray<amrex::Real, 126UL> const& kdataco)
{
int TindexL = 0;
amrex::Real weight = 1.0;
Expand Down Expand Up @@ -88,7 +86,7 @@ getRadPropSoot(
amrex::Array4<const amrex::Real> const& fv,
amrex::Array4<const amrex::Real> const& temp,
amrex::Array4<amrex::Real> const& absc,
amrex::GpuArray<amrex::Real, 126ul> const& kdatasoot)
amrex::GpuArray<amrex::Real, 126UL> const& kdatasoot)
{
int TindexL = 0;
amrex::Real weight = 1.0;
Expand All @@ -101,7 +99,5 @@ getRadPropSoot(
absc(i, j, k) += fv(i, j, k) * kp_soot; // cgs, in cm-1
}

} // namespace RadProp

} // namespace PeleRad
} // namespace PeleRad::RadProp
#endif
2 changes: 2 additions & 0 deletions Source/Soot/SootModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,9 @@ Real
SootModel::estSootDt(const Box& vbox, Array4<const Real> const& Qstate) const
{
// Primitive components
#ifndef PELELM_USE_SOOT
const int qRhoIndx = m_sootIndx.qRhoIndx;
#endif
const int qTempIndx = m_sootIndx.qTempIndx;
const int qSpecIndx = m_sootIndx.qSpecIndx;
const int qSootIndx = m_sootIndx.qSootIndx;
Expand Down
4 changes: 4 additions & 0 deletions Source/Spray/SprayInterpolation.H
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,15 @@ InterpolateGasPhase(
#ifdef PELELM_USE_SPRAY
inv_rho = 1.;
#endif
#ifndef PELELM_USE_SPRAY
amrex::Real ke = 0.;
#endif
for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
amrex::Real vel = momarr(cur_indx, dir) * inv_rho;
gpv.vel_fluid[dir] += cw * vel;
#ifndef PELELM_USE_SPRAY
ke += vel * vel / 2.;
#endif
}
amrex::Real T_i = Tarr(cur_indx);
#ifndef PELELM_USE_SPRAY
Expand Down
12 changes: 10 additions & 2 deletions Source/Spray/WallFunctions.H
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,21 @@ impose_wall(
amrex::IntVect& bflags,
const amrex::Real* cBoilT,
const amrex::Real p_fluid,
const bool use_EB,
const bool
#ifdef AMREX_USE_EB
use_EB
#endif
/*unused*/,
#ifdef AMREX_USE_EB
amrex::Array4<amrex::EBCellFlag const> const& flags,
amrex::Array4<amrex::Real const> const& bcent,
amrex::Array4<amrex::Real const> const& bnorm,
#endif
const amrex::IntVect& ijkc_prev,
const amrex::IntVect&
#ifdef AMREX_USE_EB
ijkc_prev
#endif
/*unused*/,
splash_breakup* N_SB,
const SBPtrs& rf,
const amrex::Real film_h)
Expand Down
Loading

0 comments on commit 8b7c52c

Please sign in to comment.