From 7e22440dc54cfaa912cf33be58badb764a498c60 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sat, 7 Jan 2017 16:29:15 +0000 Subject: [PATCH] TDACChemistryModel: Added support for variable time-step and LTS in ISAT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New reactingFoam tutorial counterFlowFlame2DLTS_GRI_TDAC demonstrates this new functionality. Additionally the ISAT table growth algorithm has been further optimized providing an overall speedup of between 15% and 38% for the tests run so far. Updates to TDAC and ISAT provided by Francesco Contino. Implementation updated and integrated into OpenFOAM-dev by Henry G. Weller, CFD Direct Ltd with the help of Francesco Contino. Original code providing all algorithms for chemistry reduction and tabulation contributed by Francesco Contino, Tommaso Lucchini, Gianluca D’Errico, Hervé Jeanmart, Nicolas Bourgeois and Stéphane Backaert. --- .../TDACChemistryModel/TDACChemistryModel.C | 97 +- .../TDACChemistryModel/TDACChemistryModel.H | 29 +- .../TDACChemistryModel/tabulation/ISAT/ISAT.C | 126 +- .../TDACChemistryModel/tabulation/ISAT/ISAT.H | 13 +- .../tabulation/ISAT/binaryNode/binaryNode.C | 54 +- .../tabulation/ISAT/binaryNode/binaryNode.H | 9 +- .../tabulation/ISAT/binaryTree/binaryTree.C | 109 +- .../tabulation/ISAT/binaryTree/binaryTree.H | 4 +- .../ISAT/chemPointISAT/chemPointISAT.C | 256 +- .../ISAT/chemPointISAT/chemPointISAT.H | 82 +- .../chemistryTabulationMethod.C | 5 +- .../chemistryTabulationMethod.H | 14 +- .../noChemistryTabulation.H | 7 +- .../counterFlowFlame2DLTS_GRI_TDAC/0/CH4 | 48 + .../counterFlowFlame2DLTS_GRI_TDAC/0/CO2 | 48 + .../counterFlowFlame2DLTS_GRI_TDAC/0/H2O | 48 + .../counterFlowFlame2DLTS_GRI_TDAC/0/N2 | 48 + .../counterFlowFlame2DLTS_GRI_TDAC/0/O2 | 47 + .../counterFlowFlame2DLTS_GRI_TDAC/0/T | 47 + .../counterFlowFlame2DLTS_GRI_TDAC/0/U | 46 + .../counterFlowFlame2DLTS_GRI_TDAC/0/Ydefault | 48 + .../counterFlowFlame2DLTS_GRI_TDAC/0/alphat | 45 + .../counterFlowFlame2DLTS_GRI_TDAC/0/p | 44 + .../constant/chemistryProperties | 137 + .../constant/combustionProperties | 27 + .../constant/reactions | 28 + .../constant/reactionsGRI | 5590 +++++++++++++++++ .../constant/thermo.compressibleGas | 152 + .../constant/thermo.compressibleGasGRI | 1391 ++++ .../constant/thermophysicalProperties | 36 + .../constant/turbulenceProperties | 21 + .../system/blockMeshDict | 82 + .../system/controlDict | 48 + .../system/decomposeParDict | 29 + .../system/fvSchemes | 57 + .../system/fvSolution | 83 + 36 files changed, 8750 insertions(+), 205 deletions(-) create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/0/CH4 create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/0/CO2 create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/0/H2O create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/0/N2 create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/0/O2 create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/0/T create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/0/U create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/0/Ydefault create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/0/alphat create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/0/p create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/constant/chemistryProperties create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/constant/combustionProperties create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/constant/reactions create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/constant/reactionsGRI create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/constant/thermo.compressibleGas create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/constant/thermo.compressibleGasGRI create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/constant/thermophysicalProperties create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/constant/turbulenceProperties create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/system/blockMeshDict create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/system/controlDict create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/system/decomposeParDict create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/system/fvSchemes create mode 100644 tutorials/combustion/reactingFoam/laminar/counterFlowFlame2DLTS_GRI_TDAC/system/fvSolution 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