mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -47,19 +47,21 @@ void Foam::solutionControl::read(const bool absTolOnly)
|
|||||||
|
|
||||||
// Read residual information
|
// Read residual information
|
||||||
const dictionary residualDict(solnDict.subOrEmptyDict("residualControl"));
|
const dictionary residualDict(solnDict.subOrEmptyDict("residualControl"));
|
||||||
DynamicList<fieldData> data(residualDict.toc().size());
|
|
||||||
wordHashSet fieldNames;
|
DynamicList<fieldData> data(residualControl_);
|
||||||
|
|
||||||
forAllConstIter(dictionary, residualDict, iter)
|
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;
|
fieldData fd;
|
||||||
fd.name = iter().keyword().c_str();
|
fd.name = fName.c_str();
|
||||||
|
|
||||||
if (absTolOnly)
|
if (absTolOnly)
|
||||||
{
|
{
|
||||||
fd.absTol = readScalar(residualDict.lookup(iter().keyword()));
|
fd.absTol = readScalar(residualDict.lookup(fName));
|
||||||
fd.relTol = -1;
|
fd.relTol = -1;
|
||||||
fd.initialResidual = -1;
|
fd.initialResidual = -1;
|
||||||
}
|
}
|
||||||
@ -83,17 +85,62 @@ void Foam::solutionControl::read(const bool absTolOnly)
|
|||||||
|
|
||||||
data.append(fd);
|
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);
|
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)
|
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;
|
return i;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,7 +88,11 @@ protected:
|
|||||||
virtual void read(const bool absTolOnly);
|
virtual void read(const bool absTolOnly);
|
||||||
|
|
||||||
//- Return index of field in residualControl_ if present
|
//- 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
|
//- Return true if all convergence checks are satisfied
|
||||||
virtual bool criteriaSatisfied() = 0;
|
virtual bool criteriaSatisfied() = 0;
|
||||||
|
|||||||
@ -41,12 +41,16 @@ void Foam::solutionControl::storePrevIter() const
|
|||||||
{
|
{
|
||||||
GeoField& fld = const_cast<GeoField&>(*iter());
|
GeoField& fld = const_cast<GeoField&>(*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)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< algorithmName_ << ": storing previous iter for "
|
Info<< algorithmName_ << ": storing previous iter for "
|
||||||
<< fld.name() << endl;
|
<< fName << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
fld.storePrevIter();
|
fld.storePrevIter();
|
||||||
|
|||||||
Reference in New Issue
Block a user