diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C index de13a49d01..ec67e628c0 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,12 +37,26 @@ Foam::TDACChemistryModel::TDACChemistryModel ) : chemistryModel(mesh, phaseName), + timeSteps_(0), NsDAC_(this->nSpecie_), - completeC_(this->nSpecie_,0.0), + completeC_(this->nSpecie_, 0), reactionsDisabled_(this->reactions_.size(), false), - completeToSimplifiedIndex_(this->nSpecie_,-1), + specieComp_(this->nSpecie_), + completeToSimplifiedIndex_(this->nSpecie_, -1), simplifiedToCompleteIndex_(this->nSpecie_), - specieComp_(this->nSpecie_) + tabulationResults_ + ( + IOobject + ( + "TabulationResults", + this->time().timeName(), + this->mesh(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + 0 + ) { basicMultiComponentMixture& composition = this->thermo().composition(); @@ -53,7 +67,7 @@ Foam::TDACChemistryModel::TDACChemistryModel dynamicCast&>(this->thermo()) .specieComposition(); - forAll(specieComp_,i) + forAll(specieComp_, i) { specieComp_[i] = specComp[this->Y()[i].name()]; } @@ -579,8 +593,13 @@ Foam::scalar Foam::TDACChemistryModel::solve const DeltaTType& deltaT ) { + // Increment counter of time-step + timeSteps_++; + const bool reduced = mechRed_->active(); + label nAdditionalEqn = (tabulation_->variableTimeStep() ? 1:0); + basicMultiComponentMixture& composition = this->thermo().composition(); // CPU time analysis @@ -625,9 +644,9 @@ Foam::scalar Foam::TDACChemistryModel::solve scalarField c0(this->nSpecie_); // Composition vector (Yi, T, p) - scalarField phiq(this->nEqns()); + scalarField phiq(this->nEqns() + nAdditionalEqn); - scalarField Rphiq(this->nEqns()); + scalarField Rphiq(this->nEqns() + nAdditionalEqn); forAll(rho, celli) { @@ -643,6 +662,11 @@ Foam::scalar Foam::TDACChemistryModel::solve } phiq[this->nSpecie()]=Ti; phiq[this->nSpecie()+1]=pi; + if (tabulation_->variableTimeStep()) + { + phiq[this->nSpecie()+2] = deltaT[celli]; + } + // Initialise time progress scalar timeLeft = deltaT[celli]; @@ -668,7 +692,7 @@ Foam::scalar Foam::TDACChemistryModel::solve // This position is reached when tabulation is not used OR // if the solution is not retrieved. // In the latter case, it adds the information to the tabulation - // (it will either expand the current data or add a new stored poin). + // (it will either expand the current data or add a new stored point). else { clockTime_.timeIncrement(); @@ -720,12 +744,28 @@ Foam::scalar Foam::TDACChemistryModel::solve { Rphiq[i] = c[i]/rhoi*this->specieThermo_[i].W(); } - - Rphiq[Rphiq.size()-2] = Ti; - Rphiq[Rphiq.size()-1] = pi; - tabulation_->add(phiq, Rphiq, rhoi); + if (tabulation_->variableTimeStep()) + { + Rphiq[Rphiq.size()-3] = Ti; + Rphiq[Rphiq.size()-2] = pi; + Rphiq[Rphiq.size()-1] = deltaT[celli]; + } + else + { + Rphiq[Rphiq.size()-2] = Ti; + Rphiq[Rphiq.size()-1] = pi; + } + label growOrAdd = + tabulation_->add(phiq, Rphiq, rhoi, deltaT[celli]); + if (growOrAdd) + { + this->setTabulationResultsAdd(celli); + } + else + { + this->setTabulationResultsGrow(celli); + } } - addNewLeafCpuTime_ += clockTime_.timeIncrement(); // When operations are done and if mechanism reduction is active, @@ -840,4 +880,35 @@ Foam::scalar Foam::TDACChemistryModel::solve } +template +void Foam::TDACChemistryModel::setTabulationResultsAdd +( + const label celli +) +{ + tabulationResults_[celli] = 0.0; +} + + +template +void Foam::TDACChemistryModel::setTabulationResultsGrow +( + const label celli +) +{ + tabulationResults_[celli] = 1.0; +} + + +template +void Foam::TDACChemistryModel:: +setTabulationResultsRetrieve +( + const label celli +) +{ + tabulationResults_[celli] = 2.0; +} + + // ************************************************************************* // diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.H index 52a8f0860f..fd92c6a641 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -85,14 +85,16 @@ class TDACChemistryModel { // Private member data + label timeSteps_; + // Mechanism reduction label NsDAC_; scalarField completeC_; scalarField simplifiedC_; Field reactionsDisabled_; + List> specieComp_; Field