Skip to content

Commit

Permalink
Merge branch 'updateQPD'
Browse files Browse the repository at this point in the history
  • Loading branch information
drummerdoc committed Jul 13, 2023
2 parents 473b063 + ad591b5 commit 23a6af5
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 408 deletions.
22 changes: 10 additions & 12 deletions Src/ModelSpecificAnalysis/plotQPD.cpp
@@ -1,14 +1,11 @@
#include <string>
#include <iostream>
#include <set>

#include <AMReX_ParmParse.H>
#include <AMReX_MultiFab.H>
#include <AMReX_DataServices.H>
#include <AMReX_BCRec.H>
#include <AMReX_Interpolater.H>
#include <AMReX_GpuLaunch.H>
#include <AMReX_WritePlotFile.H>
#include <util.H>

#include <PelePhysics.H>

Expand All @@ -30,15 +27,15 @@ print_usage (int,
struct ELIcompare
{
// Order EL iters using the underlying edge
bool operator()(const EdgeList::const_iterator& lhs, const EdgeList::const_iterator& rhs) {
bool operator()(const EdgeList::const_iterator& lhs, const EdgeList::const_iterator& rhs) const {
return *lhs < *rhs;
}
};

std::string
getFileRoot(const std::string& infile)
{
vector<std::string> tokens = Tokenize(infile,std::string("/"));
std::vector<std::string> tokens = Tokenize(infile,std::string("/"));
return tokens[tokens.size()-1];
}

Expand Down Expand Up @@ -110,6 +107,8 @@ main (int argc,
inNames[idRlocal] = RName;

Vector<Real> Qfsum(nreactions,0), Qrsum(nreactions,0);

auto rmap=GetReactionMap();

const int nGrow = 0;
for (int lev=0; lev<Nlev; ++lev)
Expand Down Expand Up @@ -150,8 +149,8 @@ main (int argc,
Real Qf[nreactions];
Real Qr[nreactions];
Real Pcgs;
CKPX(&Rl,&Tl,Xl,&Pcgs);
CKKFKR(&Pcgs,&Tl,Xl,Qf,Qr);
CKPX(Rl,Tl,Xl,Pcgs);
CKKFKR(Pcgs,Tl,Xl,Qf,Qr);

for (int n=0; n<nreactions; ++n) {
Qfarr(i,j,k,n) = Qf[n];
Expand All @@ -176,8 +175,8 @@ main (int argc,
}

for (int i=0; i<nreactions; ++i) {
Qfsum[i] += Qf.sum(i) * vol;
Qrsum[i] += Qr.sum(i) * vol;
Qfsum[rmap[i]] += Qf[mfi].sum(i) * vol;
Qrsum[rmap[i]] += Qr[mfi].sum(i) * vol;
}
}

Expand Down Expand Up @@ -211,7 +210,7 @@ main (int argc,
}

std::map<EdgeList::const_iterator,Real,ELIcompare> Qf,Qr;

Real normVal = 1;
for (EdgeList::const_iterator it = edges.begin(); it!=edges.end(); ++it)
{
Expand All @@ -235,7 +234,6 @@ main (int argc,
normVal *= scaleNorm;
}
std::cout << "NormVal: " << normVal << std::endl;


for (EdgeList::const_iterator it = edges.begin(); it!=edges.end(); ++it)
{
Expand Down
61 changes: 33 additions & 28 deletions Src/ModelSpecificAnalysis/testQPDtools.cpp
Expand Up @@ -12,7 +12,6 @@
#include <AMReX_BLFort.H>
#include <PelePhysics.H>
#include <util.H>
#include <util_F.H>

using namespace amrex;
using namespace analysis_util;
Expand All @@ -25,72 +24,79 @@ main (int argc,
{
ParmParse pp;

Vector<std::string> elem_names = GetElemNames();
int nelements = NumElements();
Print() << " ==> Element list \n";
Vector<std::string> elem_names;
CKSYME_STR(elem_names);
Print() << "{ ";
for (int i=0; i<nelements; ++i) {
for (int i=0; i<NUM_ELEMENTS; ++i) {
Print() << elem_names[i] << " ";
}
Print() << "}" << std::endl;

Vector<std::string> spec_names = GetSpecNames();
int nspecies = NumSpecies();
Print() << "\n ==> Species list \n";
Vector<std::string> spec_names;
CKSYMS_STR(spec_names);
Print() << "{ ";
for (int i=0; i<nspecies; ++i) {
for (int i=0; i<NUM_SPECIES; ++i) {
Print() << spec_names[i] << " ";
}
Print() << "}" << std::endl;

for (int i=0; i<nspecies; ++i) {
Print() << "\n ==> Species composition \n";
for (int i=0; i<NUM_SPECIES; ++i) {
Print() << spec_names[i] << " = { ";
for (int j=0; j<nelements; ++j) {
int ne = NumElemXinSpecY(elem_names[j],spec_names[i]);
for (int j=0; j<NUM_ELEMENTS; ++j) {
int ne = NumElemXinSpecY(j,i);
if (ne > 0) {
Print() << elem_names[j] << ":" << ne << " ";
}
}
Print() << "}\n";
}

int nreactions = NumReactions();
Print() << "NumReactions: " << nreactions << std::endl;
Print() << "\n ==> NumReactions: " << NUM_REACTIONS << std::endl;

Vector<int> rns(nreactions);
for (int i=0; i<nspecies; ++i) {
rns = ReactionsWithXonL(i);
Print() << "\n ==> Species in reactions \n";
for (int i=0; i<NUM_SPECIES; ++i) {
Vector<int> rnsL;
getReactWithXOnL(rnsL,i);
Print() << "Spec, rnsL, rnsR: " << spec_names[i] << ": ";
Print() << "{ ";
for (int j=0; j<rns.size(); ++j) {
Print() << rns[j] << " ";
for (int j=0; j<rnsL.size(); ++j) {
Print() << rnsL[j] << " ";
}
Print() << "}";
rns = ReactionsWithXonR(i);
Vector<int> rnsR;
getReactWithXOnR(rnsR,i);
Print() << " { ";
for (int j=0; j<rns.size(); ++j) {
Print() << rns[j] << " ";
for (int j=0; j<rnsR.size(); ++j) {
Print() << rnsR[j] << " ";
}
Print() << "}" << std::endl;
}

Print() << "\n ==> RMAP \n";
Vector<int> rmap = GetReactionMap();
Print() << "rmap = { ";
Print() << "{ ";
for (int j=0; j<rmap.size(); ++j) {
Print() << rmap[j] << " ";
}
Print() << "}\n";

// Build revese reaction map
Vector<int> rrmap(nreactions);
for (int i=0; i<nreactions; ++i) {
Vector<int> rrmap(NUM_REACTIONS);
for (int i=0; i<NUM_REACTIONS; ++i) {
rrmap[rmap[i]] = i;
}
Print() << "rrmap = { ";
Print() << "\n ==> RRMAP \n";
Print() << "{ ";
for (int j=0; j<rrmap.size(); ++j) {
Print() << rrmap[j] << " ";
}
Print() << "}\n";

for (int j=0; j<nreactions; ++j) {
Print() << "\n ==> Stoich coeffs \n";
for (int j=0; j<NUM_REACTIONS; ++j) {
auto sc = specCoeffsInReactions(rmap[j]);
Print() << "rn[" << j << "] (" << rmap[j] << ") = { ";
for (int i=0; i<sc.size(); ++i) {
Expand All @@ -99,15 +105,14 @@ main (int argc,
Print() << "}\n";
}

Print() << "\n ==> Edges \n";
std::string trElem = "C";
pp.query("trElem",trElem);
AMREX_ALWAYS_ASSERT(IndexElem(trElem)>=0 && IndexElem(trElem)<NumElements());
AMREX_ALWAYS_ASSERT(IndexElem(trElem)>=0 && IndexElem(trElem)<NUM_ELEMENTS);
auto edges = getEdges(trElem,1,1);
for (auto edge : edges) {
Print() << edge << std::endl;
}


}
Finalize();
return 0;
Expand Down
75 changes: 22 additions & 53 deletions Tools/GNUmake/Make.Analysis
Expand Up @@ -31,18 +31,10 @@ all: $(executable)
$(SILENT) $(RM) AMReX_buildInfo.cpp
@echo SUCCESS

# PelePhysics
EOS_HOME ?= $(PELE_PHYSICS_HOME)/Eos
REACTIONS_HOME ?= $(PELE_PHYSICS_HOME)/Reactions
TRAN_HOME ?= $(PELE_PHYSICS_HOME)/Transport
PP_SRC_HOME = $(PELE_PHYSICS_HOME)/Source
INCLUDE_LOCATIONS += $(PP_SRC_HOME)
VPATH_LOCATIONS += $(PP_SRC_HOME)
Bpack += $(PP_SRC_HOME)/Make.package
Blocs += $(PP_SRC_HOME)

# EOS
EOS_HOME = $(PELE_PHYSICS_HOME)/Eos/
#--------------------
# PelePhysics sources
#--------------------
# EOS models switches
ifeq ($(Eos_Model),$(filter $(Eos_Model),GammaLaw))
DEFINES += -DUSE_GAMMALAW_EOS
endif
Expand All @@ -52,44 +44,8 @@ endif
ifeq ($(Eos_Model),$(filter $(Eos_Model),Soave-Redlich-Kwong))
DEFINES += -DUSE_SRK_EOS
endif
INCLUDE_LOCATIONS += $(EOS_HOME)
VPATH_LOCATIONS += $(EOS_HOME)
Bpack += $(EOS_HOME)/Make.package
Blocs += $(EOS_HOME)

# Reactions
include $(REACTIONS_HOME)/Make.package
INCLUDE_LOCATIONS += $(REACTIONS_HOME)
VPATH_LOCATIONS += $(REACTIONS_HOME)
ifeq ($(Eos_Model), GammaLaw)
ifneq ($(Chemistry_Model), Null)
$(error Chemistry_Model definition not compatible with Eos_Model=GammaLaw)
endif
endif
CHEM_HOME = $(PELE_PHYSICS_HOME)/Support/Fuego/Mechanism/Models/$(Chemistry_Model)
CHEM_ALL = $(PELE_PHYSICS_HOME)/Support/Fuego/Mechanism/Models
VPATH_LOCATIONS += $(CHEM_HOME) $(CHEM_ALL)
Bpack += $(CHEM_HOME)/Make.package \
$(CHEM_ALL)/Make.package
Blocs += $(CHEM_HOME) $(CHEM_ALL)
Blocs += $(PELE_PHYSICS_HOME)/Support/Fuego/Evaluation

ifdef Chemistry_Model
CHEM_HOME = $(PELE_PHYSICS_HOME)/Support/Fuego/Mechanism/Models/$(Chemistry_Model)
Blocs += $(PELE_PHYSICS_HOME)/Support/Fuego/Evaluation
endif
VPATH_LOCATIONS += $(CHEM_HOME)
Bpack += $(CHEM_HOME)/Make.package
Blocs += $(CHEM_HOME)

# Transport
include $(TRAN_HOME)/Make.package
INCLUDE_LOCATIONS += $(TRAN_HOME)
VPATH_LOCATIONS += $(TRAN_HOME)
USE_FUEGO = FALSE

Blocs += $(PELE_PHYSICS_HOME)/Support/Fuego/Mechanism

# Transport model switches
ifeq ($(Transport_Model), Simple)
DEFINES += -DUSE_SIMPLE_TRANSPORT
endif
Expand All @@ -104,9 +60,20 @@ ifeq ($(Transport_Model), Sutherland)
DEFINES += -DUSE_SUTHERLAND_TRANSPORT
endif

# Utilities
include $(PELE_PHYSICS_HOME)/Utility/PMF/Make.package
# Chemistry Model
ifdef Chemistry_Model
ChemDir = Support/Mechanism/Models/$(Chemistry_Model)
endif

PPdirs := Utility/PMF Utility/TurbInflow Utility/PltFileManager Utility/Diagnostics
PPdirs += Source $(ChemDir) Reactions Eos Transport
Bpack += $(foreach dir, $(PPdirs), $(PELE_PHYSICS_HOME)/$(dir)/Make.package)
Blocs += $(foreach dir, $(PPdirs), $(PELE_PHYSICS_HOME)/$(dir))
include $(PELE_PHYSICS_HOME)/ThirdParty/Make.ThirdParty

#--------------
# AMReX sources
#--------------
Pdirs := Base Boundary Extern/amrdata AmrCore
ifeq ($(USE_EB), TRUE)
Pdirs += EB
Expand All @@ -130,7 +97,10 @@ endif
Bpack += $(foreach dir, $(Pdirs), $(AMREX_HOME)/Src/$(dir)/Make.package)
Blocs += $(foreach dir, $(Pdirs), $(AMREX_HOME)/Src/$(dir))

##Bdirs += $(PELE_ANALYSIS_HOME)/Tools/Util
#---------------------
# PeleAnalysis sources
#---------------------
Bdirs += $(PELE_ANALYSIS_HOME)/Tools/Util
Bpack += $(foreach dir, $(Bdirs), $(dir)/Make.package)
Blocs += $(foreach dir, $(Bdirs), $(dir))

Expand Down Expand Up @@ -159,7 +129,6 @@ AMReX_buildInfo.cpp:

include $(AMREX_HOME)/Tools/GNUMake/Make.rules


clean::
$(SILENT) $(RM) AMReX_buildInfo.cpp

Expand Down
7 changes: 5 additions & 2 deletions Tools/Util/util.H
Expand Up @@ -18,11 +18,14 @@ namespace analysis_util
amrex::Vector<std::string> GetElemNames();
amrex::Vector<std::string> GetSpecNames();

amrex::Vector<int> ReactionsWithXonL(int ispec);
amrex::Vector<int> ReactionsWithXonR(int ispec);
void getReactWithXOnL(amrex::Vector<int> &res, int ispec);
void getReactWithXOnR(amrex::Vector<int> &res, int ispec);

amrex::Vector<std::pair<std::string,int> > specCoeffsInReactions(int ireac);
int NumElemXinSpecY(const std::string& elem,
const std::string& spec);
int NumElemXinSpecY(int elem,
int spec);

//
// Data structure for generating chemical path diagrams,
Expand Down

0 comments on commit 23a6af5

Please sign in to comment.