Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigfried Haering committed Aug 22, 2024
1 parent 1729cce commit c17942c
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 105 deletions.
4 changes: 2 additions & 2 deletions src/M2ulPhyS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,12 @@ class M2ulPhyS : public TPS::PlasmaSolver {
// a serial mesh, finite element space, and grid function
// for use if we want to write a serial file
Mesh *serial_mesh;

// I/O organizer
IODataOrganizer ioData;

std::list<mfem::DenseMatrix> tableHost_;

#ifdef HAVE_MASA
VectorFunctionCoefficient *DenMMS_, *VelMMS_, *PreMMS_;
VectorFunctionCoefficient *stateMMS_;
Expand Down
12 changes: 6 additions & 6 deletions src/chemistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ MFEM_HOST_DEVICE Chemistry::Chemistry(GasMixture *mixture, const ChemistryInput
reactions_[r] = new HoffertLien(A, b, E);
} break;
case TABULATED_RXN: {

/*
/*
std::cout << "+ Ndata: " << inputs.reactionInputs[r].tableInput.Ndata << endl;
std::cout << "+ xLogScale: " << inputs.reactionInputs[r].tableInput.xLogScale << endl;
std::cout << "+ fLogScale: " << inputs.reactionInputs[r].tableInput.fLogScale << endl;
std::cout << "+ order: " << inputs.reactionInputs[r].tableInput.order << endl;
for (int i = 0; i < inputs.reactionInputs[r].tableInput.Ndata; i++) {
std::cout << " " << i << ". " << inputs.reactionInputs[r].tableInput.xdata[i] << " " << inputs.reactionInputs[r].tableInput.fdata[i] << endl;
std::cout << " " << i << ". " << inputs.reactionInputs[r].tableInput.xdata[i] << " " <<
inputs.reactionInputs[r].tableInput.fdata[i] << endl;
}
*/
*/

reactions_[r] = new Tabulated(inputs.reactionInputs[r].tableInput);
} break;
case GRIDFUNCTION_RXN: {
Expand Down Expand Up @@ -165,7 +165,7 @@ MFEM_HOST_DEVICE void Chemistry::computeForwardRateCoeffs(const double &T_h, con
const double Thlim = max(T_h, min_temperature_);
const double Telim = max(T_e, min_temperature_);

// std::cout << " chemistry numReactions: " << numReactions_ << endl;
// std::cout << " chemistry numReactions: " << numReactions_ << endl;
for (int r = 0; r < numReactions_; r++) {
// std::cout << "kfwd computeRateCoeff for reaction number: " << r+1 << endl;
bool isElectronInvolved = isElectronInvolvedAt(r);
Expand Down
21 changes: 12 additions & 9 deletions src/equation_of_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,21 +545,24 @@ MFEM_HOST_DEVICE PerfectMixture::PerfectMixture(PerfectMixtureInput inputs, int
SetSpeciesStateIndices();

// We assume the background species is neutral.
if(gasParams[(iBackground) + GasParams::SPECIES_CHARGES * numSpecies] != 0.0) {
std::cout << "(" << iBackground << ") Error: background species not nuetral: " << gasParams[(iBackground) + GasParams::SPECIES_CHARGES * numSpecies] << endl;
}
if (gasParams[(iBackground) + GasParams::SPECIES_CHARGES * numSpecies] != 0.0) {
std::cout << "(" << iBackground << ") Error: background species not nuetral: "
<< gasParams[(iBackground) + GasParams::SPECIES_CHARGES * numSpecies] << endl;
}
assert(gasParams[(iBackground) + GasParams::SPECIES_CHARGES * numSpecies] == 0.0);
// TODO(kevin): release electron species enforcing.
assert(inputs.isElectronIncluded);
// We assume the background species and electron have zero formation energy.
if(gasParams[(iElectron) + GasParams::FORMATION_ENERGY * numSpecies] != 0.0) {
std::cout << "(" << iElectron << ") Error: electron formation energy non-zero: " << gasParams[(iElectron) + GasParams::FORMATION_ENERGY * numSpecies] << endl;
if (gasParams[(iElectron) + GasParams::FORMATION_ENERGY * numSpecies] != 0.0) {
std::cout << "(" << iElectron << ") Error: electron formation energy non-zero: "
<< gasParams[(iElectron) + GasParams::FORMATION_ENERGY * numSpecies] << endl;
}
assert(gasParams[(iElectron) + GasParams::FORMATION_ENERGY * numSpecies] == 0.0);
if(gasParams[(iBackground) + GasParams::FORMATION_ENERGY * numSpecies] != 0.0) {
std::cout << "(" << iBackground << ") Error: background formation energy non-zero: " << gasParams[(iBackground) + GasParams::FORMATION_ENERGY * numSpecies] << endl;
}
assert(gasParams[(iBackground) + GasParams::FORMATION_ENERGY * numSpecies] == 0.0);
if (gasParams[(iBackground) + GasParams::FORMATION_ENERGY * numSpecies] != 0.0) {
std::cout << "(" << iBackground << ") Error: background formation energy non-zero: "
<< gasParams[(iBackground) + GasParams::FORMATION_ENERGY * numSpecies] << endl;
}
assert(gasParams[(iBackground) + GasParams::FORMATION_ENERGY * numSpecies] == 0.0);

for (int sp = 0; sp < gpudata::MAXSPECIES; sp++) {
molarCV_[sp] = -1.0;
Expand Down
139 changes: 70 additions & 69 deletions src/reactingFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ ReactingFlow::ReactingFlow(mfem::ParMesh *pmesh, LoMachOptions *loMach_opts, tem
tpsP_->getRequiredInput((basepath + "/name").c_str(), speciesName);
InputSpeciesNames[i - 1] = speciesName;

//if(rank0_) {
// std::cout << i << "): " << speciesName << " | " << gasParams_((i - 1), GasParams::FORMATION_ENERGY) << " | " << initialMassFraction_(i - 1) << endl;
//}
// if(rank0_) {
// std::cout << i << "): " << speciesName << " | " << gasParams_((i - 1), GasParams::FORMATION_ENERGY) << " | " <<
// initialMassFraction_(i - 1) << endl;
// }

if(rank0_) {
if (rank0_) {
std::cout << i << "): " << speciesName << endl;
}

}

tpsP_->getRequiredInput("species/background_index", backgroundIndex);
Expand All @@ -204,7 +204,7 @@ ReactingFlow::ReactingFlow(mfem::ParMesh *pmesh, LoMachOptions *loMach_opts, tem
}

// input file species index.
// if(rank0_) std::cout << "Species found in input file: " << nSpecies_ << endl;
// if(rank0_) std::cout << "Species found in input file: " << nSpecies_ << endl;
for (int sp = 0; sp < nSpecies_; sp++) {
if (sp == backgroundIndex - 1) {
targetIdx = nSpecies_ - 1;
Expand Down Expand Up @@ -376,30 +376,34 @@ ReactingFlow::ReactingFlow(mfem::ParMesh *pmesh, LoMachOptions *loMach_opts, tem
tpsP_->getInput((inputPath + "/f_log").c_str(), chemistryInput_.reactionInputs[r - 1].tableInput.fLogScale, false);
tpsP_->getInput((inputPath + "/order").c_str(), chemistryInput_.reactionInputs[r - 1].tableInput.order, 1);
tpsP_->getRequiredInput((inputPath + "/filename").c_str(), filename);
readTable(MPI_COMM_WORLD, filename, chemistryInput_.reactionInputs[r - 1].tableInput.xLogScale, chemistryInput_.reactionInputs[r - 1].tableInput.fLogScale, chemistryInput_.reactionInputs[r - 1].tableInput.order, tableHost_, chemistryInput_.reactionInputs[r - 1].tableInput);
readTable(MPI_COMM_WORLD, filename, chemistryInput_.reactionInputs[r - 1].tableInput.xLogScale,
chemistryInput_.reactionInputs[r - 1].tableInput.fLogScale, chemistryInput_.reactionInputs[r - 1].tableInput.order,
tableHost_, chemistryInput_.reactionInputs[r - 1].tableInput);
*/

/*
std::cout << "Table input dump from filename: " << filename << endl;
std::cout << "+ Ndata: " << chemistryInput_.reactionInputs[r - 1].tableInput.Ndata << endl;
std::cout << "+ xLogScale: " << chemistryInput_.reactionInputs[r - 1].tableInput.xLogScale << endl;
std::cout << "+ fLogScale: " << chemistryInput_.reactionInputs[r - 1].tableInput.fLogScale << endl;
std::cout << "+ order: " << chemistryInput_.reactionInputs[r - 1].tableInput.order << endl;
for (int i = 0; i < chemistryInput_.reactionInputs[r - 1].tableInput.Ndata; i++) {
std::cout << " " << i << ". " << chemistryInput_.reactionInputs[r - 1].tableInput.xdata[i] << " " << chemistryInput_.reactionInputs[r - 1].tableInput.fdata[i] << endl;
}
*/
/*
std::cout << "Table input dump from filename: " << filename << endl;
std::cout << "+ Ndata: " << chemistryInput_.reactionInputs[r - 1].tableInput.Ndata << endl;
std::cout << "+ xLogScale: " << chemistryInput_.reactionInputs[r - 1].tableInput.xLogScale << endl;
std::cout << "+ fLogScale: " << chemistryInput_.reactionInputs[r - 1].tableInput.fLogScale << endl;
std::cout << "+ order: " << chemistryInput_.reactionInputs[r - 1].tableInput.order << endl;
for (int i = 0; i < chemistryInput_.reactionInputs[r - 1].tableInput.Ndata; i++) {
std::cout << " " << i << ". " << chemistryInput_.reactionInputs[r - 1].tableInput.xdata[i] << " " <<
chemistryInput_.reactionInputs[r - 1].tableInput.fdata[i] << endl;
}
*/

/*
std::cout << "+ Ndata: " << chemistryInput_.reactionInputs[r - 1].tableInput.Ndata << endl;
std::cout << "+ xLogScale: " << chemistryInput_.reactionInputs[r - 1].tableInput.xLogScale << endl;
std::cout << "+ fLogScale: " << chemistryInput_.reactionInputs[r - 1].tableInput.fLogScale << endl;
std::cout << "+ order: " << chemistryInput_.reactionInputs[r - 1].tableInput.order << endl;
for (int i = 0; i < chemistryInput_.reactionInputs[r - 1].tableInput.Ndata; i++) {
std::cout << " " << i << ". " << chemistryInput_.reactionInputs[r - 1].tableInput.xdata[i] << " " << chemistryInput_.reactionInputs[r - 1].tableInput.fdata[i] << endl;
std::cout << " " << i << ". " << chemistryInput_.reactionInputs[r - 1].tableInput.xdata[i] << " " <<
chemistryInput_.reactionInputs[r - 1].tableInput.fdata[i] << endl;
}
*/

} else {
grvy_printf(GRVY_ERROR, "\nUnknown reaction_model -> %s", model.c_str());
exit(ERROR);
Expand Down Expand Up @@ -472,10 +476,10 @@ ReactingFlow::ReactingFlow(mfem::ParMesh *pmesh, LoMachOptions *loMach_opts, tem
// will be over-written if dynamic is active
tpsP_->getInput("loMach/reactingFlow/sub-steps", nSub_, 2);
tpsP_->getInput("loMach/reactingFlow/dynamic-substep", dynamic_substepping_, true);
if(dynamic_substepping_) nSub_ = 2;
if (dynamic_substepping_) nSub_ = 2;

// default value is purely empirical atm
tpsP_->getInput("loMach/reactingFlow/dynamic-fraction", stabFrac_, 100);
tpsP_->getInput("loMach/reactingFlow/dynamic-fraction", stabFrac_, 100);

// Check time marching order. Operator split (i.e., nSub_ > 1) not supported for order > 1.
if ((nSub_ > 1) && (time_coeff_.order > 1)) {
Expand Down Expand Up @@ -802,7 +806,6 @@ void ReactingFlow::initializeSelf() {
Yn_gf_.GetTrueDofs(tmpR0_);
setVectorFromScalar(tmpR0_, sp, &Yn_);
}

}
Ynm1_ = Yn_;
Ynm2_ = Yn_;
Expand All @@ -818,10 +821,10 @@ void ReactingFlow::initializeSelf() {
for (int i = 0; i < sDofInt_; i++) {
state[0] = d_Rho[i];
for (int sp = 0; sp < nActiveSpecies_; sp++) {
//for (int sp = 0; sp < nSpecies_; sp++) {
// state[dim_ + 1 + sp + 1] = d_Rho[i] * d_Yn[i + sp * sDofInt_];
// for (int sp = 0; sp < nSpecies_; sp++) {
// state[dim_ + 1 + sp + 1] = d_Rho[i] * d_Yn[i + sp * sDofInt_];
state[dim_ + sp + 1] = d_Rho[i] * d_Yn[i + sp * sDofInt_];
// std::cout << "*state[" << dim_ + sp + 1 << "] <= Yn:" << d_Yn[i + sp * sDofInt_] << endl;
// std::cout << "*state[" << dim_ + sp + 1 << "] <= Yn:" << d_Yn[i + sp * sDofInt_] << endl;
}
}
}
Expand Down Expand Up @@ -1388,8 +1391,8 @@ void ReactingFlow::step() {
substepState();

// number of substeps
if(dynamic_substepping_) evalSubstepNumber();
if (dynamic_substepping_) evalSubstepNumber();

for (int iSub = 0; iSub < nSub_; iSub++) {
// update wdot quantities at full substep in Yn/Tn state
updateMixture();
Expand Down Expand Up @@ -1429,22 +1432,21 @@ void ReactingFlow::step() {
}

void ReactingFlow::evalSubstepNumber() {

double myMaxProd = 0.0;
double maxProd;
double deltaYn, Ynp1;

updateMixture();
updateThermoP();
updateDensity(0.0);
speciesProduction();

{
const double *dataProd = prodY_.HostRead();
for (int i = 0; i < sDofInt_; i++) {
const double *dataProd = prodY_.HostRead();
for (int i = 0; i < sDofInt_; i++) {
for (int sp = 0; sp < nSpecies_; sp++) {
myMaxProd = std::max(std::abs(dataProd[i + sp * sDofInt_]), maxProd);
}
}
}
}
MPI_Reduce(&myMaxProd, &maxProd, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
Expand All @@ -1455,7 +1457,7 @@ void ReactingFlow::evalSubstepNumber() {
// deltaYn/nSub < 1/100
// nSub > deltaYn * 100
nSub_ = stabFrac_ * std::ceil(deltaYn);
nSub_ = std::max(nSub_, 2);
nSub_ = std::max(nSub_, 2);
}

void ReactingFlow::temperatureStep() {
Expand Down Expand Up @@ -1695,7 +1697,7 @@ void ReactingFlow::speciesSubstep(int iSpec, int iSub) {
double *data = tmpR0_.HostReadWrite();
for (int i = 0; i < sDofInt_; i++) {
data[i] = max(data[i], 0.0);
}
}
}

// Yn now has full state at substep
Expand Down Expand Up @@ -1732,35 +1734,35 @@ void ReactingFlow::speciesProduction() {
// species (mass) densities are used and need to be filled
state[0] = dataRho[i];
for (int sp = 0; sp < nActiveSpecies_; sp++) {
// for (int sp = 0; sp < nSpecies_; sp++) {
// for (int sp = 0; sp < nSpecies_; sp++) {
state[dim_ + 1 + sp + 1] = dataRho[i] * dataY[i + sp * sDofInt_];
}

// Evaluate the mole densities (from mass densities)
mixture_->computeNumberDensities(state, n_sp);
//for (int sp = 0; sp < nSpecies_; sp++) {
// std::cout << "mole density at species " << sp << ": " << n_sp[sp] << endl;
//}
// for (int sp = 0; sp < nSpecies_; sp++) {
// std::cout << "mole density at species " << sp << ": " << n_sp[sp] << endl;
// }

// Evaluate the chemical source terms
chemistry_->computeForwardRateCoeffs(Th, Te, i, kfwd.HostWrite());
//for (int sp = 0; sp < nReactions_; sp++) {
// std::cout << "kfwd(" << sp << "):" << kfwd[sp] << endl;
//}
// for (int sp = 0; sp < nReactions_; sp++) {
// std::cout << "kfwd(" << sp << "):" << kfwd[sp] << endl;
// }
chemistry_->computeEquilibriumConstants(Th, Te, keq.HostWrite());
//for (int sp = 0; sp < nReactions_; sp++) {
// std::cout << "keq(" << sp << "):" << keq[sp] << endl;
//}
// for (int sp = 0; sp < nReactions_; sp++) {
// std::cout << "keq(" << sp << "):" << keq[sp] << endl;
// }
chemistry_->computeProgressRate(n_sp, kfwd, keq, progressRate);
//for (int sp = 0; sp < nReactions_; sp++) {
// std::cout << "progressRate(" << sp << "):" << progressRate[sp] << endl;
//}
// for (int sp = 0; sp < nReactions_; sp++) {
// std::cout << "progressRate(" << sp << "):" << progressRate[sp] << endl;
// }
chemistry_->computeCreationRate(progressRate, creationRate);

// Place sources into storage for use in speciesStep
for (int sp = 0; sp < nSpecies_; sp++) {
dataProd[i + sp * sDofInt_] = creationRate[sp];
//std::cout << "P_Yn(" << sp << "):" << creationRate[sp] << endl;
// std::cout << "P_Yn(" << sp << "):" << creationRate[sp] << endl;
}
}
}
Expand All @@ -1785,7 +1787,7 @@ void ReactingFlow::heatOfFormation() {
hspecies = (molarCP * T + gasParams_(n, GasParams::FORMATION_ENERGY)) / gasParams_(n, GasParams::SPECIES_MW);
h_hw[i] -= hspecies * h_prodY[i + n * sDofInt_];
}
//std::cout << "HoF: " << h_hw[i] << endl;
// std::cout << "HoF: " << h_hw[i] << endl;
}
}

Expand Down Expand Up @@ -1885,14 +1887,14 @@ void ReactingFlow::initializeViz(ParaViewDataCollection &pvdc) {
pvdc.RegisterField("Qt", &Qt_gf_);

// this method is broken in that it assumes 3 entries
//pvdc.RegisterField("species", &YnFull_gf_);
// pvdc.RegisterField("species", &YnFull_gf_);

vizSpecFields_.clear();
vizSpecNames_.clear();
vizSpecNames_.clear();
for (int sp = 0; sp < nSpecies_; sp++) {
vizSpecFields_.push_back(new ParGridFunction(sfes_, YnFull_gf_, (sp*sDof_)));
vizSpecFields_.push_back(new ParGridFunction(sfes_, YnFull_gf_, (sp * sDof_)));
vizSpecNames_.push_back(std::string("Yn_" + speciesNames_[sp]));
pvdc.RegisterField(vizSpecNames_[sp], vizSpecFields_[sp]);
pvdc.RegisterField(vizSpecNames_[sp], vizSpecFields_[sp]);
}
}

Expand Down Expand Up @@ -1968,7 +1970,7 @@ void ReactingFlow::updateMixture() {
dataR[i] = Rgas_ / dataM[i];
}
}

// can use mixture calls directly for this
for (int sp = 0; sp < nSpecies_; sp++) {
setScalarFromVector(Yn_, sp, &tmpR0a_);
Expand Down Expand Up @@ -2003,20 +2005,20 @@ void ReactingFlow::updateMixture() {
// Set up conserved state (just the mass densities, which is all we need here)
state[0] = d_Rho[i];
for (int sp = 0; sp < nActiveSpecies_; sp++) {
// for (int sp = 0; sp < nSpecies_; sp++) {
// state[dim_ + 1 + sp + 1] = d_Rho[i] * d_Yn[i + sp * sDofInt_];
// for (int sp = 0; sp < nSpecies_; sp++) {
// state[dim_ + 1 + sp + 1] = d_Rho[i] * d_Yn[i + sp * sDofInt_];
state[dim_ + sp + 1] = d_Rho[i] * d_Yn[i + sp * sDofInt_];
//std::cout << "state[" << dim_ + sp + 1 << "] <= Yn:" << d_Yn[i + sp * sDofInt_] << endl;
// std::cout << "state[" << dim_ + sp + 1 << "] <= Yn:" << d_Yn[i + sp * sDofInt_] << endl;
}

// Evaluate the mole densities (from mass densities)
/*
if (rank0_) {
std::cout << "calling compute number density..." << endl;
if (rank0_) {
std::cout << "calling compute number density..." << endl;
for (int sp = 0; sp <= nActiveSpecies_ + dim_; sp++) {
// for (int sp = 0; sp <= nSpecies_ + dim_; sp++) {
std::cout << "state[" << sp << "]: " << state[sp] << endl;
}
// for (int sp = 0; sp <= nSpecies_ + dim_; sp++) {
std::cout << "state[" << sp << "]: " << state[sp] << endl;
}
}
*/
mixture_->computeNumberDensities(state, n_sp);
Expand All @@ -2027,7 +2029,7 @@ void ReactingFlow::updateMixture() {
// (units J/m^3), which is rho*Cp, where rho is the mixture
// density (kg/m^3) and Cp is the is the mixture mass specific
// heat (units J/(kg*K).
mixture_->GetMixtureCp(n_sp, d_Rho[i], cpMix);
mixture_->GetMixtureCp(n_sp, d_Rho[i], cpMix);

// Everything else expects CpMix_gf_ to be the mixture mass Cp
// (with units J/(kg*K)), so divide by mixture density
Expand Down Expand Up @@ -2191,10 +2193,10 @@ void ReactingFlow::updateDensity(double tStep) {
}
rn_gf_.SetFromTrueDofs(rn_);

//for (int i = 0; i < sDofInt_; i++) {
// std::cout << "density: "<< rn_(i) << endl;
//}
// for (int i = 0; i < sDofInt_; i++) {
// std::cout << "density: "<< rn_(i) << endl;
// }

MsRho_form_->Update();
MsRho_form_->Assemble();
MsRho_form_->FormSystemMatrix(empty, MsRho_);
Expand Down Expand Up @@ -2383,7 +2385,6 @@ void ReactingFlow::readTableWrapper(std::string inputPath, TableInput &result) {
std::cout << " " << i << ". " << result.xdata[i] << " " << result.fdata[i] << endl;
}
*/

}

void ReactingFlow::identifyCollisionType(const Array<ArgonSpcs> &speciesType, ArgonColl *collisionIndex) {
Expand Down
Loading

0 comments on commit c17942c

Please sign in to comment.