diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.H b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.H index 4c227eb778..e35cdd379f 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.H @@ -53,7 +53,7 @@ class lduMesh; class lduMatrix; /*---------------------------------------------------------------------------*\ - Class GAMGAgglomeration Declaration + Class GAMGAgglomeration Declaration \*---------------------------------------------------------------------------*/ class GAMGAgglomeration diff --git a/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.C b/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.C index 1e4eadce04..a238d94e0a 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.C @@ -47,19 +47,21 @@ void Foam::solutionControl::read(const bool absTolOnly) // Read residual information const dictionary residualDict(solnDict.subOrEmptyDict("residualControl")); - DynamicList data(residualDict.toc().size()); - wordHashSet fieldNames; + + DynamicList data(residualControl_); forAllConstIter(dictionary, residualDict, iter) { - if (fieldNames.insert(iter().keyword())) + const word& fName = iter().keyword(); + const label fieldI = applyToField(fName, false); + if (fieldI == -1) { fieldData fd; - fd.name = iter().keyword().c_str(); + fd.name = fName.c_str(); if (absTolOnly) { - fd.absTol = readScalar(residualDict.lookup(iter().keyword())); + fd.absTol = readScalar(residualDict.lookup(fName)); fd.relTol = -1; fd.initialResidual = -1; } @@ -83,17 +85,62 @@ void Foam::solutionControl::read(const bool absTolOnly) data.append(fd); } + else + { + fieldData& fd = data[fieldI]; + if (absTolOnly) + { + fd.absTol = readScalar(residualDict.lookup(fName)); + } + else + { + if (iter().isDict()) + { + const dictionary& fieldDict(iter().dict()); + fd.absTol = readScalar(fieldDict.lookup("tolerance")); + fd.relTol = readScalar(fieldDict.lookup("relTol")); + } + else + { + FatalErrorIn("bool Foam::solutionControl::read()") + << "Residual data for " << iter().keyword() + << " must be specified as a dictionary" + << exit(FatalError); + } + } + } } residualControl_.transfer(data); + + if (debug) + { + forAll(residualControl_, i) + { + const fieldData& fd = residualControl_[i]; + Info<< "residualControl[" << i << "]:" << nl + << " name : " << fd.name << nl + << " absTol : " << fd.absTol << nl + << " relTol : " << fd.relTol << nl + << " iniResid : " << fd.initialResidual << endl; + } + } } -Foam::label Foam::solutionControl::applyToField(const word& fieldName) const +Foam::label Foam::solutionControl::applyToField +( + const word& fieldName, + const bool useRegEx +) const { forAll(residualControl_, i) { - if (residualControl_[i].name.match(fieldName)) + if (useRegEx && residualControl_[i].name.match(fieldName)) + { + return i; + } + else if (residualControl_[i].name == fieldName) { return i; } diff --git a/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.H b/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.H index 82dd73dd9a..94a8b41305 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.H +++ b/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.H @@ -88,7 +88,11 @@ protected: virtual void read(const bool absTolOnly); //- Return index of field in residualControl_ if present - virtual label applyToField(const word& fieldName) const; + virtual label applyToField + ( + const word& fieldName, + const bool useRegEx = true + ) const; //- Return true if all convergence checks are satisfied virtual bool criteriaSatisfied() = 0; diff --git a/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControlTemplates.C b/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControlTemplates.C index a0f0a3579b..2b20a75ae2 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControlTemplates.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControlTemplates.C @@ -41,12 +41,16 @@ void Foam::solutionControl::storePrevIter() const { GeoField& fld = const_cast(*iter()); - if (mesh_.relaxField(fld.name())) + const word& fName = fld.name(); + + size_t prevIterField = fName.find("PrevIter"); + + if ((prevIterField == word::npos) && mesh_.relaxField(fName)) { if (debug) { Info<< algorithmName_ << ": storing previous iter for " - << fld.name() << endl; + << fName << endl; } fld.storePrevIter();