From 38dd1a845d72ec2c70c642907a911f67a9436e37 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Mon, 26 Jun 2017 14:09:12 +0100 Subject: [PATCH] TDACChemistryModel: improved reporting of CPU time Added a grow time and better allocate the CPU time to either add or grow. This gives much more information to the user and helps changing the settings accordingly. Patch contributed by Francesco Contino --- .../TDACChemistryModel/TDACChemistryModel.C | 24 +++++++++++++++---- .../TDACChemistryModel/TDACChemistryModel.H | 3 +++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C index 33a6d6a13..d2da9b19e 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C @@ -123,6 +123,7 @@ Foam::TDACChemistryModel::TDACChemistryModel if (tabulation_->log()) { cpuAddFile_ = logFile("cpu_add.out"); + cpuGrowFile_ = logFile("cpu_grow.out"); cpuRetrieveFile_ = logFile("cpu_retrieve.out"); } @@ -613,6 +614,7 @@ Foam::scalar Foam::TDACChemistryModel::solve clockTime_.timeIncrement(); scalar reduceMechCpuTime_ = 0; scalar addNewLeafCpuTime_ = 0; + scalar growCpuTime_ = 0; scalar solveChemistryCpuTime_ = 0; scalar searchISATCpuTime_ = 0; @@ -703,17 +705,20 @@ Foam::scalar Foam::TDACChemistryModel::solve // (it will either expand the current data or add a new stored point). else { - clockTime_.timeIncrement(); + // Store total time waiting to attribute to add or grow + scalar timeTmp = clockTime_.timeIncrement(); + if (reduced) { // Reduce mechanism change the number of species (only active) mechRed_->reduceMechanism(c, Ti, pi); nActiveSpecies += mechRed_->NsSimp(); nAvg++; + scalar timeIncr = clockTime_.timeIncrement(); + reduceMechCpuTime_ += timeIncr; + timeTmp += timeIncr; } - reduceMechCpuTime_ += clockTime_.timeIncrement(); - // Calculate the chemical source terms while (timeLeft > SMALL) { @@ -742,7 +747,11 @@ Foam::scalar Foam::TDACChemistryModel::solve timeLeft -= dt; } - solveChemistryCpuTime_ += clockTime_.timeIncrement(); + { + scalar timeIncr = clockTime_.timeIncrement(); + solveChemistryCpuTime_ += timeIncr; + timeTmp += timeIncr; + } // If tabulation is used, we add the information computed here to // the stored points (either expand or add) @@ -768,13 +777,14 @@ Foam::scalar Foam::TDACChemistryModel::solve if (growOrAdd) { this->setTabulationResultsAdd(celli); + addNewLeafCpuTime_ += clockTime_.timeIncrement() + timeTmp; } else { this->setTabulationResultsGrow(celli); + growCpuTime_ += clockTime_.timeIncrement() + timeTmp; } } - addNewLeafCpuTime_ += clockTime_.timeIncrement(); // When operations are done and if mechanism reduction is active, // the number of species (which also affects nEqns) is set back @@ -822,6 +832,10 @@ Foam::scalar Foam::TDACChemistryModel::solve << this->time().timeOutputValue() << " " << searchISATCpuTime_ << endl; + cpuGrowFile_() + << this->time().timeOutputValue() + << " " << growCpuTime_ << endl; + cpuAddFile_() << this->time().timeOutputValue() << " " << addNewLeafCpuTime_ << endl; diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.H index 1e65270db..71af571b6 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.H @@ -111,6 +111,9 @@ class TDACChemistryModel //- Log file for the average time spent adding tabulated data autoPtr cpuAddFile_; + //- Log file for the average time spent growing tabulated data + autoPtr cpuGrowFile_; + //- Log file for the average time spent retrieving tabulated data autoPtr cpuRetrieveFile_;