diff --git a/dafoam/pyDAFoam.py b/dafoam/pyDAFoam.py index 6c2ba427..f8e74910 100755 --- a/dafoam/pyDAFoam.py +++ b/dafoam/pyDAFoam.py @@ -474,6 +474,7 @@ def __init__(self): "PCMatUpdateInterval": 1, "reduceIO": True, "additionalOutput": ["None"], + "readZeroFields": True, } ## At which iteration should we start the averaging of objective functions. diff --git a/src/adjoint/DASolver/DAPimpleFoam/DAPimpleFoam.C b/src/adjoint/DASolver/DAPimpleFoam/DAPimpleFoam.C index 1186bf99..ee510683 100755 --- a/src/adjoint/DASolver/DAPimpleFoam/DAPimpleFoam.C +++ b/src/adjoint/DASolver/DAPimpleFoam/DAPimpleFoam.C @@ -121,11 +121,15 @@ label DAPimpleFoam::solvePrimal( // change the run status daOptionPtr_->setOption("runStatus", "solvePrimal"); - // we need to read in the states from the 0 folder every time we start the primal - // here we read in all time levels runTime.setTime(0.0, 0); - this->readStateVars(0.0, 0); - this->readStateVars(0.0, 1); + // if readZeroFields, we need to read in the states from the 0 folder every time + // we start the primal here we read in all time levels + label readZeroFields = daOptionPtr_->getAllOptions().subDict("unsteadyAdjoint").getLabel("readZeroFields"); + if (readZeroFields) + { + this->readStateVars(0.0, 0); + this->readStateVars(0.0, 1); + } // call correctNut, this is equivalent to turbulence->validate(); daTurbulenceModelPtr_->updateIntermediateVariables(); diff --git a/src/adjoint/DASolver/DARhoPimpleFoam/DARhoPimpleFoam.C b/src/adjoint/DASolver/DARhoPimpleFoam/DARhoPimpleFoam.C index b53f1fad..b3a8eeb8 100755 --- a/src/adjoint/DASolver/DARhoPimpleFoam/DARhoPimpleFoam.C +++ b/src/adjoint/DASolver/DARhoPimpleFoam/DARhoPimpleFoam.C @@ -126,11 +126,15 @@ label DARhoPimpleFoam::solvePrimal( // change the run status daOptionPtr_->setOption("runStatus", "solvePrimal"); - // we need to read in the states from the 0 folder every time we start the primal - // here we read in all time levels runTime.setTime(0.0, 0); - this->readStateVars(0.0, 0); - this->readStateVars(0.0, 1); + // if readZeroFields, we need to read in the states from the 0 folder every time + // we start the primal here we read in all time levels + label readZeroFields = daOptionPtr_->getAllOptions().subDict("unsteadyAdjoint").getLabel("readZeroFields"); + if (readZeroFields) + { + this->readStateVars(0.0, 0); + this->readStateVars(0.0, 1); + } // call correctNut, this is equivalent to turbulence->validate(); daTurbulenceModelPtr_->updateIntermediateVariables();