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 Pele Physics #7

Merged
merged 3 commits into from
Aug 17, 2021
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
8 changes: 3 additions & 5 deletions Exec/RegTests/FlameSheet/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ USE_HIP = FALSE

# PelePhysics
Chemistry_Model = drm19
Reactions_dir = Fuego
Eos_dir = Fuego
Transport_dir = Simple

USE_SUNDIALS_PP = TRUE
Reactor_dir = cvode
Eos_Model = Fuego
Transport_Model = Simple

include $(PELELMEX_HOME)/Utils/Make.PeleLMeX
6 changes: 3 additions & 3 deletions Exec/RegTests/HotBubble/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ USE_HIP = FALSE

# PelePhysics
Chemistry_Model = air
Reactions_dir = Null
Eos_dir = Fuego
Transport_dir = Constant
Reactor_dir = null
Eos_Model = Fuego
Transport_Model = Constant

USE_SUNDIALS_PP = TRUE

Expand Down
8 changes: 8 additions & 0 deletions Exec/RegTests/HotBubble/pelelm_prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ void PeleLM::readProbParm()
pp.query("T_bubble", prob_parm->T_bubble);
pp.query("bubble_radius", prob_parm->bubble_rad);
pp.query("bubble_y0", prob_parm->bubble_y0);

auto& trans_parm = PeleLM::trans_parms.host_trans_parm();
amrex::ParmParse pptr("transport");
pp.query("const_viscosity", trans_parm.const_viscosity);
pp.query("const_bulk_viscosity", trans_parm.const_bulk_viscosity);
pp.query("const_conductivity", trans_parm.const_conductivity);
pp.query("const_diffusivity", trans_parm.const_diffusivity);
PeleLM::trans_parms.sync_to_device();
}
8 changes: 4 additions & 4 deletions Exec/RegTests/PeriodicCases/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PELE_PHYSICS_HOME ?= ${TOP}/PelePhysics
DIM = 2
DEBUG = FALSE
PRECISION = DOUBLE
VERBOSE = FALSE
VERBOSE = TRUE
TINY_PROFILE = FALSE

# Compilation
Expand All @@ -22,8 +22,8 @@ USE_HIP = FALSE

# PelePhysics
Chemistry_Model = air
Reactions_dir = Null
Eos_dir = Fuego
Transport_dir = Constant
Reactor_dir = null
Eos_Model = Fuego
Transport_Model = Constant

include $(PELELMEX_HOME)/Utils/Make.PeleLMeX
8 changes: 8 additions & 0 deletions Exec/RegTests/PeriodicCases/pelelm_prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,12 @@ void PeleLM::readProbParm()
amrex::Print() << " Unknown prob.type ! Should be ConvectedVortex, ConvectedGaussian or DiffusedGaussian \n";
amrex::Abort();
}

auto& trans_parm = PeleLM::trans_parms.host_trans_parm();
amrex::ParmParse pptr("transport");
pp.query("const_viscosity", trans_parm.const_viscosity);
pp.query("const_bulk_viscosity", trans_parm.const_bulk_viscosity);
pp.query("const_conductivity", trans_parm.const_conductivity);
pp.query("const_diffusivity", trans_parm.const_diffusivity);
PeleLM::trans_parms.sync_to_device();
}
5 changes: 5 additions & 0 deletions Source/PeleLM.H
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <AMReX_VisMF.H>

#include <mechanism.H>
#include "PelePhysics.H"
#include <PeleLM_Index.H>
#include <PeleLMDerive.H>
#include <pelelm_prob_parm.H>
Expand Down Expand Up @@ -781,6 +782,10 @@ class PeleLM : public amrex::AmrCore {
// Problem parameters
std::unique_ptr<ProbParm> prob_parm;

// Transport pointer
pele::physics::transport::TransportParams<
pele::physics::PhysicsType::transport_type> trans_parms;

// Linear solvers
std::unique_ptr<DiffusionOp> m_diffusion_op;
std::unique_ptr<DiffusionTensorOp> m_diffusionTensor_op;
Expand Down
3 changes: 3 additions & 0 deletions Source/PeleLMEvolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ void PeleLM::Evolve() {
if ( m_check_int > 0 && !chk_justDidIt ) {
WriteCheckPointFile();
}

// TODO: set a clean up function.
trans_parms.deallocate();

}

Expand Down
2 changes: 1 addition & 1 deletion Source/PeleLMPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void PeleLM::WritePlotFile() {
//----------------------------------------------------------------
// Components names
Vector<std::string> names;
pele::physics::eos::speciesNames(names);
pele::physics::eos::speciesNames<pele::physics::PhysicsType::eos_type>(names);

Vector<std::string> plt_VarsName;
plt_VarsName.push_back("x_velocity");
Expand Down
10 changes: 5 additions & 5 deletions Source/PeleLMReactions.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <PeleLM.H>
#include <PeleLM_K.H>
#include <reactor.h>
#include <reactor.H>
#ifdef PLM_USE_EFIELD
#include <PeleLMEF_Constants.H>
#endif
Expand Down Expand Up @@ -107,8 +107,8 @@ void PeleLM::advanceChemistry(int lev,

Real dt_incr = a_dt;
Real time_chem = 0;
#ifdef AMREX_USE_GPU
int reactor_type = 2;
#ifdef AMREX_USE_GPU
int tmp_fctCn = 0;
tmp_fctCn = react(bx, rhoY_n, extF_rhoY, temp_n, rhon, extF_rhoH, fcl, mask_arr,
dt_incr, time_chem, reactor_type, amrex::Gpu::gpuStream());
Expand All @@ -118,7 +118,7 @@ void PeleLM::advanceChemistry(int lev,
/* Solve */
int tmp_fctCn = 0;
tmp_fctCn = react(bx, rhoY_n, extF_rhoY, temp_n, rhoH_n, extF_rhoH, fcl, mask_arr,
dt_incr, time_chem);
dt_incr, time_chem, reactor_type);
dt_incr = a_dt;
time_chem = 0;
#endif
Expand Down Expand Up @@ -288,8 +288,8 @@ void PeleLM::advanceChemistry(int lev,

Real dt_incr = a_dt;
Real time_chem = 0;
#ifdef AMREX_USE_GPU
int reactor_type = 2;
#ifdef AMREX_USE_GPU
int tmp_fctCn = 0;
tmp_fctCn = react(bx, rhoY_o, extF_rhoY, temp_o, rhoH_o, extF_rhoH, fcl, mask_arr,
dt_incr, time_chem, reactor_type, amrex::Gpu::gpuStream());
Expand All @@ -299,7 +299,7 @@ void PeleLM::advanceChemistry(int lev,
/* Solve */
int tmp_fctCn = 0;
tmp_fctCn = react(bx, rhoY_o, extF_rhoY, temp_o, rhoH_o, extF_rhoH, fcl, mask_arr,
dt_incr, time_chem);
dt_incr, time_chem, reactor_type);
dt_incr = a_dt;
time_chem = 0;
#endif
Expand Down
9 changes: 4 additions & 5 deletions Source/PeleLMSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <AMReX_ParmParse.H>
#include <PeleLMDeriveFunc.H>
#include "PelePhysics.H"
#include <reactor.h>
#include <reactor.H>
#ifdef PLM_USE_EFIELD
#include "EOS_Extension.H"
#endif
Expand Down Expand Up @@ -34,8 +34,7 @@ void PeleLM::Setup() {
// Initialize EOS and others
if (!m_incompressible) {
amrex::Print() << " Initialization of Transport ... \n";
pele::physics::transport::InitTransport<
pele::physics::PhysicsType::eos_type>()();
trans_parms.allocate();
if (m_do_react) {
int reactor_type = 2;
int ncells_chem = 1;
Expand Down Expand Up @@ -332,7 +331,7 @@ void PeleLM::variablesSetup() {
stateComponents.emplace_back(DENSITY,"density");
Print() << " First species: " << FIRSTSPEC << "\n";
Vector<std::string> names;
pele::physics::eos::speciesNames(names);
pele::physics::eos::speciesNames<pele::physics::PhysicsType::eos_type>(names);
for (int n = 0; n < NUM_SPECIES; n++ ) {
stateComponents.emplace_back(FIRSTSPEC+n,"rho.Y("+names[n]+")");
}
Expand Down Expand Up @@ -406,7 +405,7 @@ void PeleLM::derivedSetup()

// Get species names
Vector<std::string> spec_names;
pele::physics::eos::speciesNames(spec_names);
pele::physics::eos::speciesNames<pele::physics::PhysicsType::eos_type>(spec_names);

// Set species mass fractions
Vector<std::string> var_names_massfrac(NUM_SPECIES);
Expand Down
6 changes: 2 additions & 4 deletions Source/PeleLMTransportProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ void PeleLM::calcViscosity(const TimeStamp &a_time) {
} else {

// Transport data pointer
pele::physics::transport::TransParm const* ltransparm =
pele::physics::transport::trans_parm_g;
auto const* ltransparm = trans_parms.device_trans_parm();

#ifdef _OPENMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
Expand Down Expand Up @@ -49,8 +48,7 @@ void PeleLM::calcDiffusivity(const TimeStamp &a_time) {
auto ldata_p = getLevelDataPtr(lev,a_time);

// Transport data pointer
pele::physics::transport::TransParm const* ltransparm =
pele::physics::transport::trans_parm_g;
auto const* ltransparm = trans_parms.device_trans_parm();

#ifdef _OPENMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
Expand Down
6 changes: 4 additions & 2 deletions Source/PeleLM_K.H
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ getTransportCoeff(int i, int j, int k,
amrex::Array4< amrex::Real> const& rhoDi,
amrex::Array4< amrex::Real> const& lambda,
amrex::Array4< amrex::Real> const& mu,
pele::physics::transport::TransParm const* trans_parm) noexcept
pele::physics::transport::TransParm<pele::physics::PhysicsType::eos_type,
pele::physics::PhysicsType::transport_type> const* trans_parm) noexcept
{
using namespace amrex::literals;

Expand Down Expand Up @@ -65,7 +66,8 @@ getVelViscosity(int i, int j, int k,
amrex::Array4<const amrex::Real> const& rhoY,
amrex::Array4< amrex::Real> const& T,
amrex::Array4< amrex::Real> const& mu,
pele::physics::transport::TransParm const* trans_parm) noexcept
pele::physics::transport::TransParm<pele::physics::PhysicsType::eos_type,
pele::physics::PhysicsType::transport_type> const* trans_parm) noexcept
{
using namespace amrex::literals;

Expand Down
54 changes: 47 additions & 7 deletions Utils/Make.PeleLMeX
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,52 @@ Blocs += $(foreach dir, $(LMdirs), $(PELELMEX_HOME)/$(dir))
#---------------
# PelePhysics sources
#---------------
# EOS models switches
ifeq ($(Eos_Model),$(filter $(Eos_Model),GammaLaw))
DEFINES += -DUSE_GAMMALAW_EOS
endif
ifeq ($(Eos_Model),$(filter $(Eos_Model),Fuego))
DEFINES += -DUSE_FUEGO_EOS
endif
ifeq ($(Eos_Model),$(filter $(Eos_Model),Soave-Redlich-Kwong))
DEFINES += -DUSE_SRK_EOS
endif

# Transport model switches
ifeq ($(Transport_Model), Simple)
DEFINES += -DUSE_SIMPLE_TRANSPORT
endif
ifeq ($(Transport_Model), EGLib)
DEFINES += -DEGLIB_TRANSPORT
USE_FUEGO = TRUE
endif
ifeq ($(Transport_Model), Constant)
DEFINES += -DUSE_CONSTANT_TRANSPORT
endif
ifeq ($(Transport_Model), Sutherland)
DEFINES += -DUSE_SUTHERLAND_TRANSPORT
endif

# Reactor model switches
ifeq ($(Reactor_dir), arkode)
USE_SUNDIALS_PP = TRUE
USE_ARKODE_PP = TRUE
ReacDirs = Reactions Reactions/$(strip $(Reactor_dir))
endif
ifeq ($(Reactor_dir), cvode)
USE_SUNDIALS_PP = TRUE
USE_CVODE_PP = TRUE
USE_KLU_PP ?= FALSE
DEFINES += -DCOMPILE_JACOBIAN
ReacDirs = Reactions Reactions/$(strip $(Reactor_dir))
endif
ifeq ($(Reactor_dir), null)
ReacDirs = Reactions/$(strip $(Reactor_dir))
endif

ChemDir = Support/Fuego/Mechanism/Models/$(Chemistry_Model)
ReacDir = Reactions/$(strip $(Reactions_dir))
EosDir = Eos/$(strip $(Eos_dir))
TranDir = Transport/$(strip $(Transport_dir))

PPdirs := Utility Source $(ChemDir) $(ReacDir) $(EosDir) $(TranDir)
PPdirs := Utility Source $(ChemDir) $(ReacDirs) Eos Transport
PPHdirs := Support/Fuego/Evaluation
Bpack += $(foreach dir, $(PPdirs), $(PELE_PHYSICS_HOME)/$(dir)/Make.package)
Blocs += $(foreach dir, $(PPdirs), $(PELE_PHYSICS_HOME)/$(dir))
Expand Down Expand Up @@ -90,13 +130,13 @@ print-%::
#---------------
ifeq ($(USE_SUNDIALS_PP),TRUE)
TPL:
cd $(PELE_PHYSICS_HOME)/ThirdParty; make AMREX_HOME=$(AMREX_HOME) USE_CUDA=$(USE_CUDA) USE_KLU=$(USE_KLU_PP) DEBUG=$(DEBUG) COMP=$(COMP) NVCC=$(COMP)
cd $(PELE_PHYSICS_HOME)/ThirdParty; make AMREX_HOME=$(AMREX_HOME) USE_CUDA=$(USE_CUDA) USE_KLU_PP=$(USE_KLU_PP) DEBUG=$(DEBUG) COMP=$(COMP) NVCC=$(COMP)

TPLclean:
cd $(PELE_PHYSICS_HOME)/ThirdParty; make AMREX_HOME=$(AMREX_HOME) USE_CUDA=$(USE_CUDA) USE_KLU=$(USE_KLU_PP) DEBUG=$(DEBUG) COMP=$(HOSTCC) NVCC=$(COMP) clean
cd $(PELE_PHYSICS_HOME)/ThirdParty; make AMREX_HOME=$(AMREX_HOME) USE_CUDA=$(USE_CUDA) USE_KLU_PP=$(USE_KLU_PP) DEBUG=$(DEBUG) COMP=$(HOSTCC) NVCC=$(COMP) clean

TPLrealclean:
cd $(PELE_PHYSICS_HOME)/ThirdParty; make AMREX_HOME=$(AMREX_HOME) USE_CUDA=$(USE_CUDA) USE_KLU=$(USE_KLU_PP) DEBUG=$(DEBUG) COMP=$(HOSTCC) NVCC=$(COMP) realclean
cd $(PELE_PHYSICS_HOME)/ThirdParty; make AMREX_HOME=$(AMREX_HOME) USE_CUDA=$(USE_CUDA) USE_KLU_PP=$(USE_KLU_PP) DEBUG=$(DEBUG) COMP=$(HOSTCC) NVCC=$(COMP) realclean
else
TPL:
TPLclean:
Expand Down