From c17942c36932e02cde97bfe6b2308528f2422115 Mon Sep 17 00:00:00 2001 From: Sigfried Haering Date: Thu, 22 Aug 2024 09:58:14 -0700 Subject: [PATCH] style --- src/M2ulPhyS.hpp | 4 +- src/chemistry.cpp | 12 ++-- src/equation_of_state.cpp | 21 +++--- src/reactingFlow.cpp | 139 +++++++++++++++++++------------------- src/reactingFlow.hpp | 2 +- src/reaction.cpp | 5 +- src/table.cpp | 22 +++--- src/utils.cpp | 5 +- src/utils.hpp | 5 +- 9 files changed, 110 insertions(+), 105 deletions(-) diff --git a/src/M2ulPhyS.hpp b/src/M2ulPhyS.hpp index 0e2785e33..9a993534e 100644 --- a/src/M2ulPhyS.hpp +++ b/src/M2ulPhyS.hpp @@ -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 tableHost_; - + #ifdef HAVE_MASA VectorFunctionCoefficient *DenMMS_, *VelMMS_, *PreMMS_; VectorFunctionCoefficient *stateMMS_; diff --git a/src/chemistry.cpp b/src/chemistry.cpp index 6cd7d2679..e185f8a8d 100644 --- a/src/chemistry.cpp +++ b/src/chemistry.cpp @@ -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: { @@ -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); diff --git a/src/equation_of_state.cpp b/src/equation_of_state.cpp index 2a33a73c2..b3a88a9e3 100644 --- a/src/equation_of_state.cpp +++ b/src/equation_of_state.cpp @@ -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; diff --git a/src/reactingFlow.cpp b/src/reactingFlow.cpp index 215b70423..5459d053c 100644 --- a/src/reactingFlow.cpp +++ b/src/reactingFlow.cpp @@ -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); @@ -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; @@ -376,19 +376,22 @@ 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; @@ -396,10 +399,11 @@ ReactingFlow::ReactingFlow(mfem::ParMesh *pmesh, LoMachOptions *loMach_opts, tem 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); @@ -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)) { @@ -802,7 +806,6 @@ void ReactingFlow::initializeSelf() { Yn_gf_.GetTrueDofs(tmpR0_); setVectorFromScalar(tmpR0_, sp, &Yn_); } - } Ynm1_ = Yn_; Ynm2_ = Yn_; @@ -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; } } } @@ -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(); @@ -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); @@ -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() { @@ -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 @@ -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; } } } @@ -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; } } @@ -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]); } } @@ -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_); @@ -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); @@ -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 @@ -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_); @@ -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 &speciesType, ArgonColl *collisionIndex) { diff --git a/src/reactingFlow.hpp b/src/reactingFlow.hpp index ee010c8de..dab32524d 100644 --- a/src/reactingFlow.hpp +++ b/src/reactingFlow.hpp @@ -379,7 +379,7 @@ class ReactingFlow : public ThermoChemModelBase { void AddQtDirichletBC(Coefficient *coeff, Array &attr); void AddQtDirichletBC(ScalarFuncT *f, Array &attr); - void evalSubstepNumber(); + void evalSubstepNumber(); void readTableWrapper(std::string inputPath, TableInput &result); }; #endif // REACTINGFLOW_HPP_ diff --git a/src/reaction.cpp b/src/reaction.cpp index bf4963701..b84785e8d 100644 --- a/src/reaction.cpp +++ b/src/reaction.cpp @@ -61,7 +61,6 @@ MFEM_HOST_DEVICE double HoffertLien::computeRateCoefficient(const double &T_h, c MFEM_HOST_DEVICE Tabulated::Tabulated(const TableInput &input) : Reaction(TABULATED_RXN) { switch (input.order) { case 1: { - /* std::cout << "+ Ndata: " << input.Ndata << endl; std::cout << "+ xLogScale: " << input.xLogScale << endl; @@ -71,7 +70,7 @@ MFEM_HOST_DEVICE Tabulated::Tabulated(const TableInput &input) : Reaction(TABULA std::cout << " " << i << ". " << input.xdata[i] << " " << input.fdata[i] << endl; } */ - + table_ = new LinearTable(input); // std::cout << "LinearTable constructed!" << endl; } break; @@ -89,7 +88,7 @@ MFEM_HOST_DEVICE double Tabulated::computeRateCoefficient(const double &T_h, con const bool isElectronInvolved) { double temp = (isElectronInvolved) ? T_e : T_h; // std::cout << "...attempting to evaluate table for temp: " << temp << endl; - return table_->eval(temp); + return table_->eval(temp); } MFEM_HOST_DEVICE GridFunctionReaction::GridFunctionReaction(int comp) diff --git a/src/table.cpp b/src/table.cpp index 6172ff3a5..3d34c963d 100644 --- a/src/table.cpp +++ b/src/table.cpp @@ -59,14 +59,14 @@ MFEM_HOST_DEVICE int TableInterpolator::findInterval(const double &xEval) { if (xEval < xdata_[0]) { // std::cout << "caught less than " << xEval << " " << xdata_[0] << endl; first = 1; - } else if (xEval > xdata_[Ndata_-1]) { + } else if (xEval > xdata_[Ndata_ - 1]) { first = Ndata_ - 1; - } else { + } else { while (count > 0) { it = first; step = count / 2; it += step; - // std::cout << "iterating " << it << ") " << xEval << " " << xdata_[it] << endl; + // std::cout << "iterating " << it << ") " << xEval << " " << xdata_[it] << endl; if (xEval > xdata_[it]) { first = ++it; count -= step + 1; @@ -75,11 +75,11 @@ MFEM_HOST_DEVICE int TableInterpolator::findInterval(const double &xEval) { } } } - + // if xEval is outside the range, first has either 0 or Ndata_. Limit the value. - //first = max(1, min(Ndata_ - 1, first)); - - // We want the left index of the interval + // first = max(1, min(Ndata_ - 1, first)); + + // We want the left index of the interval return first - 1; } @@ -91,8 +91,9 @@ MFEM_HOST_DEVICE LinearTable::LinearTable(const TableInput &input) : TableInterpolator(input.Ndata, input.xdata, input.fdata, input.xLogScale, input.fLogScale) { assert(input.order == 1); - // std::cout << "LinearTable constructor: table range " << xdata_[0] << " : " << xdata_[Ndata_-1] << " and " << fdata_[0] << " : " << fdata_[Ndata_-1] << endl; - + // std::cout << "LinearTable constructor: table range " << xdata_[0] << " : " << xdata_[Ndata_-1] << " and " << + // fdata_[0] << " : " << fdata_[Ndata_-1] << endl; + for (int k = 0; k < Ndata_ - 1; k++) { a_[k] = (fLogScale_) ? log(fdata_[k]) : fdata_[k]; double df = (fLogScale_) ? (log(fdata_[k + 1]) - log(fdata_[k])) : (fdata_[k + 1] - fdata_[k]); @@ -106,7 +107,8 @@ MFEM_HOST_DEVICE double LinearTable::eval(const double &xEval) { double xt = (xLogScale_) ? log(xEval) : xEval; double ft = a_[index] + b_[index] * xt; if (fLogScale_) ft = exp(ft); - // std::cout << " (temp, index): (" << xEval << ", " << index << "): a " << a_[index] << " b " << b_[index] << " xt " << xt << " val " << ft << endl; + // std::cout << " (temp, index): (" << xEval << ", " << index << "): a " << a_[index] << " b " << b_[index] << " xt " + // << xt << " val " << ft << endl; return ft; } diff --git a/src/utils.cpp b/src/utils.cpp index 431612b93..1326777aa 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1240,8 +1240,7 @@ void makeContinuous(ParGridFunction &u) { } void readTable(MPI_Comm TPSCommWorld, std::string filename, bool xLogScale, bool fLogScale, int order, - std::list &tableHost, TableInput &result) { - + std::list &tableHost, TableInput &result) { int myrank; MPI_Comm_rank(TPSCommWorld, &myrank); const bool rank0 = (myrank == 0); @@ -1286,7 +1285,7 @@ void readTable(MPI_Comm TPSCommWorld, std::string filename, bool xLogScale, bool std::cout << " " << i << ". " << result.xdata[i] << " " << result.fdata[i] << endl; } */ - + return; } diff --git a/src/utils.hpp b/src/utils.hpp index 3456739d1..4f23c5d91 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -43,10 +43,10 @@ #include #include #include +#include #include #include #include -#include #include "dataStructures.hpp" #include "tps_mfem_wrap.hpp" @@ -104,7 +104,8 @@ bool h5ReadTable(const std::string &fileName, const std::string &datasetName, mf bool h5ReadBcastMultiColumnTable(const std::string &fileName, const std::string &datasetName, MPI_Comm TPSCommWorld, mfem::DenseMatrix &output, std::vector &tables); -void readTable(MPI_Comm TPSCommWorld, std::string filename, bool xLogScale, bool fLogScale, int order, std::list &tableHost, TableInput &result); +void readTable(MPI_Comm TPSCommWorld, std::string filename, bool xLogScale, bool fLogScale, int order, + std::list &tableHost, TableInput &result); // MFEM extensions