Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
mattijs 2011-10-25 15:35:56 +01:00
commit d666fda130
4 changed files with 66 additions and 11 deletions

View File

@ -53,7 +53,7 @@ class lduMesh;
class lduMatrix;
/*---------------------------------------------------------------------------*\
Class GAMGAgglomeration Declaration
Class GAMGAgglomeration Declaration
\*---------------------------------------------------------------------------*/
class GAMGAgglomeration

View File

@ -47,19 +47,21 @@ void Foam::solutionControl::read(const bool absTolOnly)
// Read residual information
const dictionary residualDict(solnDict.subOrEmptyDict("residualControl"));
DynamicList<fieldData> data(residualDict.toc().size());
wordHashSet fieldNames;
DynamicList<fieldData> 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;
}

View File

@ -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;

View File

@ -41,12 +41,16 @@ void Foam::solutionControl::storePrevIter() const
{
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)
{
Info<< algorithmName_ << ": storing previous iter for "
<< fld.name() << endl;
<< fName << endl;
}
fld.storePrevIter();