Merge solution control backport. Auther: Vanja Skuric & FSB team. Merge: Henrik Rusche

This commit is contained in:
Henrik Rusche 2016-06-07 13:45:11 +02:00
commit 78ad89f025
88 changed files with 974 additions and 937 deletions

View file

@ -10,9 +10,4 @@
UEqn.relax(); UEqn.relax();
eqnResidual = solve solve(UEqn == -fvc::grad(p));
(
UEqn == -fvc::grad(p)
).initialResidual();
maxResidual = max(eqnResidual, maxResidual);

View file

@ -1,9 +0,0 @@
// check convergence
if (maxResidual < convergenceCriterion)
{
Info<< "reached convergence criterion: " << convergenceCriterion << endl;
runTime.writeAndEnd();
Info<< "latestTime = " << runTime.timeName() << endl;
}

View file

@ -39,3 +39,5 @@
thermo thermo
) )
); );
mesh.schemesDict().setFluxRequired(p.name());

View file

@ -23,8 +23,7 @@
hEqn.relax(); hEqn.relax();
eqnResidual = hEqn.solve().initialResidual(); hEqn.solve();
maxResidual = max(eqnResidual, maxResidual);
// Bounding of enthalpy taken out // Bounding of enthalpy taken out
thermo.correct(); thermo.correct();

View file

@ -1,7 +0,0 @@
// initialize values for convergence checks
scalar eqnResidual = 1, maxResidual = 0;
scalar convergenceCriterion = 0;
pimple.readIfPresent("convergence", convergenceCriterion);

View file

@ -7,7 +7,7 @@
// Needs to be outside of loop since p is changing, but psi and rho are not // Needs to be outside of loop since p is changing, but psi and rho are not
surfaceScalarField rhoReff = rhof - psisf*fvc::interpolate(p); surfaceScalarField rhoReff = rhof - psisf*fvc::interpolate(p);
for (int corr = 0; corr < nCorr; corr++) while (pimple.correct())
{ {
U = rUA*UEqn.H(); U = rUA*UEqn.H();
@ -20,7 +20,7 @@
p.storePrevIter(); p.storePrevIter();
for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) while (pimple.correctNonOrthogonal())
{ {
fvScalarMatrix pEqn fvScalarMatrix pEqn
( (
@ -30,16 +30,10 @@
- fvm::laplacian(rho*rUA, p) - fvm::laplacian(rho*rUA, p)
); );
// Retain the residual from the first pressure solution pEqn.solve();
eqnResidual = pEqn.solve().initialResidual();
if (corr == 0 && nonOrth == 0)
{
maxResidual = max(eqnResidual, maxResidual);
}
// Calculate the flux // Calculate the flux
if (nonOrth == nNonOrthCorr) if (pimple.finalNonOrthogonalIter())
{ {
phi = phid2 + pEqn.flux(); phi = phid2 + pEqn.flux();
} }

View file

@ -36,6 +36,7 @@ Author
#include "basicPsiThermo.H" #include "basicPsiThermo.H"
#include "basicRhoThermo.H" #include "basicRhoThermo.H"
#include "RASModel.H" #include "RASModel.H"
#include "pimpleControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -46,9 +47,11 @@ int main(int argc, char *argv[])
# include "createTime.H" # include "createTime.H"
# include "createMesh.H" # include "createMesh.H"
pimpleControl pimple(mesh);
# include "createThermo.H" # include "createThermo.H"
# include "createFields.H" # include "createFields.H"
# include "readPIMPLEControls.H"
# include "initContinuityErrs.H" # include "initContinuityErrs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -59,11 +62,8 @@ int main(int argc, char *argv[])
{ {
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
# include "readPIMPLEControls.H"
# include "readFieldBounds.H" # include "readFieldBounds.H"
# include "initConvergenceCheck.H"
# include "UEqn.H" # include "UEqn.H"
# include "pEqn.H" # include "pEqn.H"
@ -79,8 +79,6 @@ int main(int argc, char *argv[])
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl; << nl << endl;
# include "convergenceCheck.H"
} }
# include "clearThermo.H" # include "clearThermo.H"

View file

@ -13,9 +13,4 @@
UEqn.relax(); UEqn.relax();
eqnResidual = solve solve(UEqn == -fvc::grad(p));
(
UEqn == -fvc::grad(p)
).initialResidual();
maxResidual = max(eqnResidual, maxResidual);

View file

@ -1,9 +0,0 @@
// check convergence
if (maxResidual < convergenceCriterion)
{
Info<< "reached convergence criterion: " << convergenceCriterion << endl;
runTime.writeAndEnd();
Info<< "latestTime = " << runTime.timeName() << endl;
}

View file

@ -80,3 +80,5 @@
mesh mesh
); );
i == h - 0.5*(magSqr(Urot) - magSqr(Urel)); i == h - 0.5*(magSqr(Urot) - magSqr(Urel));
mesh.schemesDict().setFluxRequired(p.name());

View file

@ -18,8 +18,7 @@
iEqn.relax(); iEqn.relax();
eqnResidual = iEqn.solve().initialResidual(); iEqn.solve();
maxResidual = max(eqnResidual, maxResidual);
// From rothalpy, calculate enthalpy after solution of rothalpy equation // From rothalpy, calculate enthalpy after solution of rothalpy equation
h = i + 0.5*(magSqr(Urot) - magSqr(Urel)); h = i + 0.5*(magSqr(Urot) - magSqr(Urel));

View file

@ -1,7 +0,0 @@
// initialize values for convergence checks
scalar eqnResidual = 1, maxResidual = 0;
scalar convergenceCriterion = 0;
pimple.readIfPresent("convergence", convergenceCriterion);

View file

@ -7,7 +7,7 @@
// Needs to be outside of loop since p is changing, but psi and rho are not // Needs to be outside of loop since p is changing, but psi and rho are not
surfaceScalarField rhoReff = rhof - psisf*fvc::interpolate(p); surfaceScalarField rhoReff = rhof - psisf*fvc::interpolate(p);
for (int corr = 0; corr < nCorr; corr++) while (pimple.correct())
{ {
U = rUA*UEqn.H(); U = rUA*UEqn.H();
@ -20,7 +20,7 @@
p.storePrevIter(); p.storePrevIter();
for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) while (pimple.correctNonOrthogonal())
{ {
fvScalarMatrix pEqn fvScalarMatrix pEqn
( (
@ -30,16 +30,10 @@
- fvm::laplacian(rho*rUA, p) - fvm::laplacian(rho*rUA, p)
); );
// Retain the residual from the first pressure solution pEqn.solve();
eqnResidual = pEqn.solve().initialResidual();
if (corr == 0 && nonOrth == 0)
{
maxResidual = max(eqnResidual, maxResidual);
}
// Calculate the flux // Calculate the flux
if (nonOrth == nNonOrthCorr) if (pimple.finalNonOrthogonalIter())
{ {
phi = phid2 + pEqn.flux(); phi = phid2 + pEqn.flux();
} }

View file

@ -43,6 +43,7 @@ GE CONFIDENTIAL INFORMATION 2016 General Electric Company. All Rights Reserved
#include "basicRhoThermo.H" #include "basicRhoThermo.H"
#include "RASModel.H" #include "RASModel.H"
#include "MRFZones.H" #include "MRFZones.H"
#include "pimpleControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -53,9 +54,11 @@ int main(int argc, char *argv[])
# include "createTime.H" # include "createTime.H"
# include "createMesh.H" # include "createMesh.H"
pimpleControl pimple(mesh);
# include "createThermo.H" # include "createThermo.H"
# include "createFields.H" # include "createFields.H"
# include "readPIMPLEControls.H"
# include "initContinuityErrs.H" # include "initContinuityErrs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -66,11 +69,8 @@ int main(int argc, char *argv[])
{ {
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
# include "readPIMPLEControls.H"
# include "readFieldBounds.H" # include "readFieldBounds.H"
# include "initConvergenceCheck.H"
# include "UEqn.H" # include "UEqn.H"
# include "pEqn.H" # include "pEqn.H"
@ -86,8 +86,6 @@ int main(int argc, char *argv[])
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl; << nl << endl;
# include "convergenceCheck.H"
} }
# include "clearThermo.H" # include "clearThermo.H"

View file

@ -154,3 +154,5 @@
aMesh, aMesh,
dimensionedScalar("one", dimless, 0.01) dimensionedScalar("one", dimless, 0.01)
); );
aMesh.schemesDict().setFluxRequired("h");

View file

@ -125,6 +125,7 @@ Foam::multiphaseMixture::multiphaseMixture
forAllIter(PtrDictionary<phase>, phases_, iter) forAllIter(PtrDictionary<phase>, phases_, iter)
{ {
alphaTable_.add(iter()); alphaTable_.add(iter());
mesh_.schemesDict().setFluxRequired(iter().volScalarField::name());
} }
} }

View file

@ -102,7 +102,7 @@ int main(int argc, char *argv[])
//# include "waveCourantNo.H" //# include "waveCourantNo.H"
int iCorr = 0; int iCorr = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar initialResidual = 0; scalar initialResidual = 0;
scalar relativeResidual = 1; scalar relativeResidual = 1;
//scalar forceResidual = 1; //scalar forceResidual = 1;

View file

@ -86,7 +86,7 @@ int main(int argc, char *argv[])
//# include "waveCourantNo.H" //# include "waveCourantNo.H"
int iCorr = 0; int iCorr = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar initialResidual = 0; scalar initialResidual = 0;
scalar relativeResidual = 1; scalar relativeResidual = 1;
//scalar forceResidual = 1; //scalar forceResidual = 1;

View file

@ -70,7 +70,7 @@ int main(int argc, char *argv[])
int iCorr = 0; int iCorr = 0;
scalar initialResidual = 0; scalar initialResidual = 0;
scalar relativeResidual = 1.0; scalar relativeResidual = 1.0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
lduMatrix::debug = 0; lduMatrix::debug = 0;
do do

View file

@ -60,7 +60,7 @@ int main(int argc, char *argv[])
int iCorr = 0; int iCorr = 0;
scalar initialResidual = 0; scalar initialResidual = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar relativeResidual = 1.0; scalar relativeResidual = 1.0;
lduMatrix::debug=0; lduMatrix::debug=0;

View file

@ -62,7 +62,7 @@ int main(int argc, char *argv[])
int iCorr = 0; int iCorr = 0;
scalar initialResidual = 0; scalar initialResidual = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar relativeResidual = 1.0; scalar relativeResidual = 1.0;
lduMatrix::debug = 0; lduMatrix::debug = 0;

View file

@ -73,7 +73,7 @@ int main(int argc, char *argv[])
# include "readSolidMechanicsControls.H" # include "readSolidMechanicsControls.H"
int iCorr = 0; int iCorr = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar initialResidual = 1.0; scalar initialResidual = 1.0;
scalar relativeResidual = 1.0; scalar relativeResidual = 1.0;
lduMatrix::debug = 0; lduMatrix::debug = 0;

View file

@ -103,7 +103,7 @@ int main(int argc, char *argv[])
//# include "waveCourantNo.H" //# include "waveCourantNo.H"
int iCorr = 0; int iCorr = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar initialResidual = 0; scalar initialResidual = 0;
scalar relativeResidual = 1; scalar relativeResidual = 1;
//scalar forceResidual = 1; //scalar forceResidual = 1;

View file

@ -78,7 +78,7 @@ int main(int argc, char *argv[])
# include "readSolidMechanicsControls.H" # include "readSolidMechanicsControls.H"
int iCorr = 0; int iCorr = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar initialResidual = 1.0; scalar initialResidual = 1.0;
lduMatrix::debug = 0; lduMatrix::debug = 0;

View file

@ -67,7 +67,7 @@ int main(int argc, char *argv[])
# include "readSolidMechanicsControls.H" # include "readSolidMechanicsControls.H"
int iCorr = 0; int iCorr = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar initialResidual = 1.0; scalar initialResidual = 1.0;
scalar relativeResidual = 1.0; scalar relativeResidual = 1.0;
lduMatrix::debug = 0; lduMatrix::debug = 0;

View file

@ -64,7 +64,7 @@ int main(int argc, char *argv[])
int iCorr = 0; int iCorr = 0;
scalar initialResidual = 0; scalar initialResidual = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar relativeResidual = GREAT; scalar relativeResidual = GREAT;
lduMatrix::debug = 0; lduMatrix::debug = 0;

View file

@ -80,7 +80,7 @@ int main(int argc, char *argv[])
# include "readSolidMechanicsControls.H" # include "readSolidMechanicsControls.H"
int iCorr = 0; int iCorr = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar initialResidual = 0; scalar initialResidual = 0;
scalar relativeResidual = 1.0; scalar relativeResidual = 1.0;
lduMatrix::debug = 0; lduMatrix::debug = 0;

View file

@ -65,7 +65,7 @@ int main(int argc, char *argv[])
# include "readSolidMechanicsControls.H" # include "readSolidMechanicsControls.H"
int iCorr = 0; int iCorr = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar initialResidual = 1.0; scalar initialResidual = 1.0;
scalar relativeResidual = 1.0; scalar relativeResidual = 1.0;
scalar plasticResidual = 1.0; scalar plasticResidual = 1.0;

View file

@ -69,7 +69,7 @@ int main(int argc, char *argv[])
# include "readSolidMechanicsControls.H" # include "readSolidMechanicsControls.H"
int iCorr = 0; int iCorr = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar initialResidual = 1.0; scalar initialResidual = 1.0;
scalar relativeResidual = 1.0; scalar relativeResidual = 1.0;
// lduMatrix::debug = 0; // lduMatrix::debug = 0;

View file

@ -66,8 +66,8 @@ int main(int argc, char *argv[])
scalar initialResidual = 1.0; scalar initialResidual = 1.0;
scalar relResT = 1.0; scalar relResT = 1.0;
scalar relResU = 1.0; scalar relResU = 1.0;
lduMatrix::solverPerformance solverPerfU; lduSolverPerformance solverPerfU;
lduMatrix::solverPerformance solverPerfT; lduSolverPerformance solverPerfT;
lduMatrix::debug = 0; lduMatrix::debug = 0;
// solve energy equation for temperature // solve energy equation for temperature

View file

@ -2,7 +2,7 @@
# include "readSolidMechanicsControls.H" # include "readSolidMechanicsControls.H"
int iCorr = 0; int iCorr = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar initialResidual = 0; scalar initialResidual = 0;
lduMatrix::debug = 0; lduMatrix::debug = 0;

View file

@ -2,7 +2,7 @@
# include "readSolidMechanicsControls.H" # include "readSolidMechanicsControls.H"
int iCorr = 0; int iCorr = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar initialResidual = 0; scalar initialResidual = 0;
lduMatrix::debug = 0; lduMatrix::debug = 0;

View file

@ -11,7 +11,7 @@
Info << "lambda = " << average(lambda.internalField()) << endl; Info << "lambda = " << average(lambda.internalField()) << endl;
int iCorr = 0; int iCorr = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar initialResidual = 0; scalar initialResidual = 0;
scalar err = GREAT; scalar err = GREAT;

View file

@ -73,7 +73,7 @@ int main(int argc, char *argv[])
Info << "average lambda = " << average(lambdaf.internalField()) << endl; Info << "average lambda = " << average(lambdaf.internalField()) << endl;
int iCorr = 0; int iCorr = 0;
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
scalar initialResidual = 1.0; scalar initialResidual = 1.0;
scalar residual = 1.0; scalar residual = 1.0;
surfaceSymmTensorField DSigmaCorrf = fvc::interpolate(DSigmaCorr); surfaceSymmTensorField DSigmaCorrf = fvc::interpolate(DSigmaCorr);

View file

@ -61,6 +61,65 @@ void faMeshDecomposition::distributeFaces()
) )
); );
// If faMesh's fvPatch is a part of the global face zones, faces of that
// patch will be present on all processors. Because of that, looping
// through faceProcAddressing will decompose global faMesh faces to the
// very last processor regardless of where fvPatch is really decomposed.
// Since global faces which do not belong to specific processor are
// located at the end of the faceProcAddressing, cutting it at
// i = owner.size() will correctly decompose faMesh faces.
// Vanja Skuric, 2016-04-21
if (decompositionDict_.found("globalFaceZones"))
{
labelList faceProcAddressing
(
labelIOList
(
IOobject
(
"faceProcAddressing",
"constant",
procMesh.meshSubDir,
procMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
);
const label ownerSize =
(
labelIOList
(
IOobject
(
"owner",
"constant",
procMesh.meshSubDir,
procMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
).size();
labelHashSet faceProcAddressingHash(ownerSize);
for (int i = 0; i < ownerSize; ++i)
{
faceProcAddressingHash.insert(faceProcAddressing[i]);
}
forAll (faceLabels(), faceI)
{
if (faceProcAddressingHash.found(faceLabels()[faceI] + 1))
{
faceToProc_[faceI] = procI;
}
}
}
else
{
labelHashSet faceProcAddressingHash labelHashSet faceProcAddressingHash
( (
labelIOList labelIOList
@ -85,6 +144,7 @@ void faMeshDecomposition::distributeFaces()
} }
} }
} }
}
Info<< "\nFinished decomposition in " Info<< "\nFinished decomposition in "
<< decompositionTime.elapsedCpuTime() << decompositionTime.elapsedCpuTime()

View file

@ -93,7 +93,7 @@ protected:
} }
// Holds recent solver performance // Holds recent solver performance
lduMatrix::solverPerformance solverPerf_; lduSolverPerformance solverPerf_;
public: public:
@ -125,7 +125,7 @@ public:
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh&);
//- Return recent solver performance //- Return recent solver performance
const lduMatrix::solverPerformance& solverPerformance() const const lduSolverPerformance& solverPerformance() const
{ {
return solverPerf_; return solverPerf_;
} }

View file

@ -21,31 +21,45 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>. along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "error.H"
#include "objectRegistry.H"
#include "foamTime.H"
#include "faSchemes.H" #include "faSchemes.H"
#include "objectRegistry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
Foam::debug::debugSwitch Foam::debug::debugSwitch
faSchemes::debug Foam::faSchemes::debug
( (
"faSchemes", "faSchemes",
false false
); );
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::faSchemes::clear()
{
ddtSchemes_.clear();
defaultDdtScheme_.clear();
d2dt2Schemes_.clear();
defaultD2dt2Scheme_.clear();
interpolationSchemes_.clear();
defaultInterpolationScheme_.clear();
divSchemes_.clear(); // optional
defaultDivScheme_.clear();
gradSchemes_.clear(); // optional
defaultGradScheme_.clear();
lnGradSchemes_.clear();
defaultLnGradScheme_.clear();
laplacianSchemes_.clear(); // optional
defaultLaplacianScheme_.clear();
fluxRequired_.clear();
defaultFluxRequired_ = false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
faSchemes::faSchemes(const objectRegistry& obr) Foam::faSchemes::faSchemes(const objectRegistry& obr)
: :
IOdictionary IOdictionary
( (
@ -59,21 +73,106 @@ faSchemes::faSchemes(const objectRegistry& obr)
IOobject::NO_WRITE IOobject::NO_WRITE
) )
), ),
ddtSchemes_(ITstream("ddtSchemes", tokenList())()), ddtSchemes_
defaultDdtScheme_("default", tokenList()), (
d2dt2Schemes_(ITstream("d2dt2Schemes", tokenList())()), ITstream
defaultD2dt2Scheme_("default", tokenList()), (
interpolationSchemes_(ITstream("interpolationSchemes", tokenList())()), objectPath() + "::ddtSchemes",
defaultInterpolationScheme_("default", tokenList()), tokenList()
divSchemes_(ITstream("divSchemes", tokenList())()), )()
defaultDivScheme_("default", tokenList()), ),
gradSchemes_(ITstream("gradSchemes", tokenList())()), defaultDdtScheme_
defaultGradScheme_("default", tokenList()), (
lnGradSchemes_(ITstream("lnGradSchemes", tokenList())()), ddtSchemes_.name() + "::default",
defaultLnGradScheme_("default", tokenList()), tokenList()
laplacianSchemes_(ITstream("laplacianSchemes", tokenList())()), ),
defaultLaplacianScheme_("default", tokenList()), d2dt2Schemes_
fluxRequired_(ITstream("fluxRequired", tokenList())()) (
ITstream
(
objectPath() + "::d2dt2Schemes",
tokenList()
)()
),
defaultD2dt2Scheme_
(
d2dt2Schemes_.name() + "::default",
tokenList()
),
interpolationSchemes_
(
ITstream
(
objectPath() + "::interpolationSchemes",
tokenList()
)()
),
defaultInterpolationScheme_
(
interpolationSchemes_.name() + "::default",
tokenList()
),
divSchemes_
(
ITstream
(
objectPath() + "::divSchemes",
tokenList()
)()
),
defaultDivScheme_
(
divSchemes_.name() + "::default",
tokenList()
),
gradSchemes_
(
ITstream
(
objectPath() + "::gradSchemes",
tokenList()
)()
),
defaultGradScheme_
(
gradSchemes_.name() + "::default",
tokenList()
),
lnGradSchemes_
(
ITstream
(
objectPath() + "::snGradSchemes",
tokenList()
)()
),
defaultLnGradScheme_
(
lnGradSchemes_.name() + "::default",
tokenList()
),
laplacianSchemes_
(
ITstream
(
objectPath() + "::laplacianSchemes",
tokenList()
)()
),
defaultLaplacianScheme_
(
laplacianSchemes_.name() + "::default",
tokenList()
),
fluxRequired_
(
ITstream
(
objectPath() + "::fluxRequired",
tokenList()
)()
),
defaultFluxRequired_(false)
{ {
if (!headerOk()) if (!headerOk())
{ {
@ -85,6 +184,8 @@ faSchemes::faSchemes(const objectRegistry& obr)
) << "faSchemes dictionary not found. Creating default." ) << "faSchemes dictionary not found. Creating default."
<< endl; << endl;
} }
regIOobject::write();
} }
read(); read();
@ -93,27 +194,58 @@ faSchemes::faSchemes(const objectRegistry& obr)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool faSchemes::read() bool Foam::faSchemes::read()
{ {
bool readOk = false; if (regIOobject::read())
if (headerOk())
{
readOk = regIOobject::read();
}
if (readOk)
{ {
const dictionary& dict = schemesDict(); const dictionary& dict = schemesDict();
// ddt Schemes // persistent settings across reads is incorrect
clear();
if (dict.found("ddtSchemes")) if (dict.found("ddtSchemes"))
{ {
ddtSchemes_ = dict.subDict("ddtSchemes"); ddtSchemes_ = dict.subDict("ddtSchemes");
} }
else if (dict.found("timeScheme"))
{
// For backward compatibility.
// The timeScheme will be deprecated with warning or removed
WarningIn("fvSchemes::read()")
<< "Using deprecated 'timeScheme' instead of 'ddtSchemes'"
<< nl << endl;
word schemeName(dict.lookup("timeScheme"));
if (schemeName == "EulerImplicit")
{
schemeName = "Euler";
}
else if (schemeName == "BackwardDifferencing")
{
schemeName = "backward";
}
else if (schemeName == "SteadyState")
{
schemeName = "steadyState";
}
else else
{ {
ddtSchemes_.add("default", "none"); FatalIOErrorIn("fvSchemes::read()", dict.lookup("timeScheme"))
<< "\n Only EulerImplicit, BackwardDifferencing and "
"SteadyState\n are supported by the old timeScheme "
"specification.\n Please use ddtSchemes instead."
<< exit(FatalIOError);
}
ddtSchemes_.set("default", schemeName);
ddtSchemes_.lookup("default")[0].lineNumber() =
dict.lookup("timeScheme").lineNumber();
}
else
{
ddtSchemes_.set("default", "none");
} }
if if
@ -126,7 +258,6 @@ bool faSchemes::read()
} }
// d2dt2 schemes
if (dict.found("d2dt2Schemes")) if (dict.found("d2dt2Schemes"))
{ {
d2dt2Schemes_ = dict.subDict("d2dt2Schemes"); d2dt2Schemes_ = dict.subDict("d2dt2Schemes");
@ -134,29 +265,30 @@ bool faSchemes::read()
else if (dict.found("timeScheme")) else if (dict.found("timeScheme"))
{ {
// For backward compatibility. // For backward compatibility.
// The timeScheme will be deprecated with warning or removed in 2.4. // The timeScheme will be deprecated with warning or removed
WarningIn("fvSchemes::read()")
<< "Using deprecated 'timeScheme' instead of 'd2dt2Schemes'"
<< nl << endl;
word timeSchemeName(dict.lookup("timeScheme")); word schemeName(dict.lookup("timeScheme"));
if (timeSchemeName == "EulerImplicit") if (schemeName == "EulerImplicit")
{ {
timeSchemeName = "Euler"; schemeName = "Euler";
} }
else if (timeSchemeName == "SteadyState") else if (schemeName == "SteadyState")
{ {
timeSchemeName = "steadyState"; schemeName = "steadyState";
} }
if (d2dt2Schemes_.found("default")) d2dt2Schemes_.set("default", schemeName);
{
d2dt2Schemes_.remove("default");
}
d2dt2Schemes_.add("default", timeSchemeName); d2dt2Schemes_.lookup("default")[0].lineNumber() =
dict.lookup("timeScheme").lineNumber();
} }
else else
{ {
d2dt2Schemes_.add("default", "none"); d2dt2Schemes_.set("default", "none");
} }
if if
@ -169,7 +301,6 @@ bool faSchemes::read()
} }
// Interpolation schemes
if (dict.found("interpolationSchemes")) if (dict.found("interpolationSchemes"))
{ {
interpolationSchemes_ = dict.subDict("interpolationSchemes"); interpolationSchemes_ = dict.subDict("interpolationSchemes");
@ -190,15 +321,9 @@ bool faSchemes::read()
} }
// Div schemes
if (dict.found("divSchemes")) if (dict.found("divSchemes"))
{ {
divSchemes_ = dict.subDict("divSchemes"); divSchemes_ = dict.subDict("divSchemes");
}
else
{
divSchemes_.add("default", "none");
} }
if if
@ -210,16 +335,9 @@ bool faSchemes::read()
defaultDivScheme_ = divSchemes_.lookup("default"); defaultDivScheme_ = divSchemes_.lookup("default");
} }
// Grad schemes
if (dict.found("gradSchemes")) if (dict.found("gradSchemes"))
{ {
gradSchemes_ = dict.subDict("gradSchemes"); gradSchemes_ = dict.subDict("gradSchemes");
}
else
{
gradSchemes_.add("default", "none");
} }
if if
@ -232,12 +350,11 @@ bool faSchemes::read()
} }
// lnGrad schemes
if (dict.found("lnGradSchemes")) if (dict.found("lnGradSchemes"))
{ {
lnGradSchemes_ = dict.subDict("lnGradSchemes"); lnGradSchemes_ = dict.subDict("lnGradSchemes");
} }
else else if (!lnGradSchemes_.found("default"))
{ {
lnGradSchemes_.add("default", "corrected"); lnGradSchemes_.add("default", "corrected");
} }
@ -252,15 +369,9 @@ bool faSchemes::read()
} }
// laplacian schemes
if (dict.found("laplacianSchemes")) if (dict.found("laplacianSchemes"))
{ {
laplacianSchemes_ = dict.subDict("laplacianSchemes"); laplacianSchemes_ = dict.subDict("laplacianSchemes");
}
else
{
laplacianSchemes_.add("default", "none");
} }
if if
@ -273,18 +384,30 @@ bool faSchemes::read()
} }
// Flux required
if (dict.found("fluxRequired")) if (dict.found("fluxRequired"))
{ {
fluxRequired_ = dict.subDict("fluxRequired"); fluxRequired_ = dict.subDict("fluxRequired");
if
(
fluxRequired_.found("default")
&& word(fluxRequired_.lookup("default")) != "none"
)
{
defaultFluxRequired_ = Switch(fluxRequired_.lookup("default"));
} }
} }
return readOk; return true;
}
else
{
return false;
}
} }
const dictionary& faSchemes::schemesDict() const const Foam::dictionary& Foam::faSchemes::schemesDict() const
{ {
if (found("select")) if (found("select"))
{ {
@ -297,18 +420,14 @@ const dictionary& faSchemes::schemesDict() const
} }
ITstream& faSchemes::ddtScheme(const word& name) const Foam::ITstream& Foam::faSchemes::ddtScheme(const word& name) const
{ {
if (debug) if (debug)
{ {
Info<< "Lookup ddtScheme for " << name << endl; Info<< "Lookup ddtScheme for " << name << endl;
} }
if if (ddtSchemes_.found(name) || defaultDdtScheme_.empty())
(
ddtSchemes_.found(name)
|| !defaultDdtScheme_.size()
)
{ {
return ddtSchemes_.lookup(name); return ddtSchemes_.lookup(name);
} }
@ -320,18 +439,14 @@ ITstream& faSchemes::ddtScheme(const word& name) const
} }
ITstream& faSchemes::d2dt2Scheme(const word& name) const Foam::ITstream& Foam::faSchemes::d2dt2Scheme(const word& name) const
{ {
if (debug) if (debug)
{ {
Info<< "Lookup d2dt2Scheme for " << name << endl; Info<< "Lookup d2dt2Scheme for " << name << endl;
} }
if if (d2dt2Schemes_.found(name) || defaultD2dt2Scheme_.empty())
(
d2dt2Schemes_.found(name)
|| !defaultD2dt2Scheme_.size()
)
{ {
return d2dt2Schemes_.lookup(name); return d2dt2Schemes_.lookup(name);
} }
@ -343,12 +458,17 @@ ITstream& faSchemes::d2dt2Scheme(const word& name) const
} }
ITstream& faSchemes::interpolationScheme(const word& name) const Foam::ITstream& Foam::faSchemes::interpolationScheme(const word& name) const
{ {
if (debug)
{
Info<< "Lookup interpolationScheme for " << name << endl;
}
if if
( (
interpolationSchemes_.found(name) interpolationSchemes_.found(name)
|| !defaultInterpolationScheme_.size() || defaultInterpolationScheme_.empty()
) )
{ {
return interpolationSchemes_.lookup(name); return interpolationSchemes_.lookup(name);
@ -361,9 +481,14 @@ ITstream& faSchemes::interpolationScheme(const word& name) const
} }
ITstream& faSchemes::divScheme(const word& name) const Foam::ITstream& Foam::faSchemes::divScheme(const word& name) const
{ {
if (divSchemes_.found(name) || !defaultDivScheme_.size()) if (debug)
{
Info<< "Lookup divScheme for " << name << endl;
}
if (divSchemes_.found(name) || defaultDivScheme_.empty())
{ {
return divSchemes_.lookup(name); return divSchemes_.lookup(name);
} }
@ -375,9 +500,14 @@ ITstream& faSchemes::divScheme(const word& name) const
} }
ITstream& faSchemes::gradScheme(const word& name) const Foam::ITstream& Foam::faSchemes::gradScheme(const word& name) const
{ {
if (gradSchemes_.found(name) || !defaultGradScheme_.size()) if (debug)
{
Info<< "Lookup gradScheme for " << name << endl;
}
if (gradSchemes_.found(name) || defaultGradScheme_.empty())
{ {
return gradSchemes_.lookup(name); return gradSchemes_.lookup(name);
} }
@ -389,9 +519,14 @@ ITstream& faSchemes::gradScheme(const word& name) const
} }
ITstream& faSchemes::lnGradScheme(const word& name) const Foam::ITstream& Foam::faSchemes::lnGradScheme(const word& name) const
{ {
if (lnGradSchemes_.found(name) || !defaultLnGradScheme_.size()) if (debug)
{
Info<< "Lookup snGradScheme for " << name << endl;
}
if (lnGradSchemes_.found(name) || defaultLnGradScheme_.empty())
{ {
return lnGradSchemes_.lookup(name); return lnGradSchemes_.lookup(name);
} }
@ -403,9 +538,14 @@ ITstream& faSchemes::lnGradScheme(const word& name) const
} }
ITstream& faSchemes::laplacianScheme(const word& name) const Foam::ITstream& Foam::faSchemes::laplacianScheme(const word& name) const
{ {
if (laplacianSchemes_.found(name) || !defaultLaplacianScheme_.size()) if (debug)
{
Info<< "Lookup laplacianScheme for " << name << endl;
}
if (laplacianSchemes_.found(name) || defaultLaplacianScheme_.empty())
{ {
return laplacianSchemes_.lookup(name); return laplacianSchemes_.lookup(name);
} }
@ -417,13 +557,24 @@ ITstream& faSchemes::laplacianScheme(const word& name) const
} }
bool faSchemes::fluxRequired(const word& name) const void Foam::faSchemes::setFluxRequired(const word& name) const
{
if (debug)
{
Info<< "Setting fluxRequired for " << name << endl;
}
fluxRequired_.add(name, true, true);
}
bool Foam::faSchemes::fluxRequired(const word& name) const
{ {
return fluxRequired_.found(name); return fluxRequired_.found(name);
} }
bool faSchemes::writeData(Ostream& os) const bool Foam::faSchemes::writeData(Ostream& os) const
{ {
// Write dictionaries // Write dictionaries
os << nl << "ddtSchemes"; os << nl << "ddtSchemes";
@ -454,8 +605,4 @@ bool faSchemes::writeData(Ostream& os) const
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View file

@ -53,8 +53,6 @@ class faSchemes
: :
public IOdictionary public IOdictionary
{ {
private:
// Private data // Private data
dictionary ddtSchemes_; dictionary ddtSchemes_;
@ -78,13 +76,19 @@ private:
dictionary laplacianSchemes_; dictionary laplacianSchemes_;
ITstream defaultLaplacianScheme_; ITstream defaultLaplacianScheme_;
dictionary fluxRequired_; mutable dictionary fluxRequired_;
bool defaultFluxRequired_;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct and assignment //- Clear the dictionaries and streams before reading
void clear();
//- Disallow default bitwise copy construct
faSchemes(const faSchemes&); faSchemes(const faSchemes&);
//- Disallow default bitwise assignment
void operator=(const faSchemes&); void operator=(const faSchemes&);
@ -120,6 +124,8 @@ public:
ITstream& laplacianScheme(const word& name) const; ITstream& laplacianScheme(const word& name) const;
void setFluxRequired(const word& name) const;
bool fluxRequired(const word& name) const; bool fluxRequired(const word& name) const;

View file

@ -329,6 +329,40 @@ laplacian
} }
template<class Type>
tmp<faMatrix<Type> >
laplacian
(
const edgeTensorField& gamma,
const GeometricField<Type, faPatchField, areaMesh>& vf,
const word& name
)
{
const faMesh& mesh = vf.mesh();
return fam::laplacian
(
(mesh.Le() & gamma & mesh.Le())/sqr(mesh.magLe()),
vf,
name
);
}
template<class Type>
tmp<faMatrix<Type> >
laplacian
(
const tmp<edgeTensorField>& tgamma,
const GeometricField<Type, faPatchField, areaMesh>& vf,
const word& name
)
{
tmp<faMatrix<Type> > Laplacian = fam::laplacian(tgamma(), vf, name);
tgamma.clear();
return Laplacian;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fam } // End namespace fam

View file

@ -180,6 +180,23 @@ namespace fam
const tmp<edgeTensorField>&, const tmp<edgeTensorField>&,
const GeometricField<Type, faPatchField, areaMesh>& const GeometricField<Type, faPatchField, areaMesh>&
); );
template<class Type>
tmp<faMatrix<Type> > laplacian
(
const edgeTensorField&,
const GeometricField<Type, faPatchField, areaMesh>&,
const word& name
);
template<class Type>
tmp<faMatrix<Type> > laplacian
(
const tmp<edgeTensorField>&,
const GeometricField<Type, faPatchField, areaMesh>&,
const word& name
);
} }

View file

@ -63,7 +63,7 @@ bool Foam::pimpleControl::criteriaSatisfied()
bool achieved = true; bool achieved = true;
bool checked = false; // safety that some checks were indeed performed bool checked = false; // safety that some checks were indeed performed
const dictionary& solverDict = mesh_.solverPerformanceDict(); const dictionary& solverDict = mesh_.solutionDict().solverPerformanceDict();
forAllConstIter(dictionary, solverDict, iter) forAllConstIter(dictionary, solverDict, iter)
{ {
const word& variableName = iter().keyword(); const word& variableName = iter().keyword();
@ -190,7 +190,7 @@ bool Foam::pimpleControl::loop()
} }
corr_ = 0; corr_ = 0;
mesh_.data::remove("finalIteration"); mesh_.solutionDict().remove("finalIteration");
return false; return false;
} }
@ -202,7 +202,7 @@ bool Foam::pimpleControl::loop()
Info<< algorithmName_ << ": converged in " << corr_ - 1 Info<< algorithmName_ << ": converged in " << corr_ - 1
<< " iterations" << endl; << " iterations" << endl;
mesh_.data::remove("finalIteration"); mesh_.solutionDict().remove("finalIteration");
corr_ = 0; corr_ = 0;
converged_ = false; converged_ = false;
@ -213,7 +213,7 @@ bool Foam::pimpleControl::loop()
Info<< algorithmName_ << ": iteration " << corr_ << endl; Info<< algorithmName_ << ": iteration " << corr_ << endl;
storePrevIterFields(); storePrevIterFields();
mesh_.data::add("finalIteration", true); mesh_.solutionDict().add("finalIteration", true);
converged_ = true; converged_ = true;
} }
} }
@ -221,7 +221,7 @@ bool Foam::pimpleControl::loop()
{ {
if (finalIter()) if (finalIter())
{ {
mesh_.data::add("finalIteration", true); mesh_.solutionDict().add("finalIteration", true);
} }
if (corr_ <= nCorrPIMPLE_) if (corr_ <= nCorrPIMPLE_)

View file

@ -52,7 +52,7 @@ bool Foam::simpleControl::criteriaSatisfied()
bool achieved = true; bool achieved = true;
bool checked = false; // safety that some checks were indeed performed bool checked = false; // safety that some checks were indeed performed
const dictionary& solverDict = mesh_.solverPerformanceDict(); const dictionary& solverDict = mesh_.solutionDict().solverPerformanceDict();
forAllConstIter(dictionary, solverDict, iter) forAllConstIter(dictionary, solverDict, iter)
{ {
const word& variableName = iter().keyword(); const word& variableName = iter().keyword();

View file

@ -28,7 +28,6 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::debug::debugSwitch Foam::debug::debugSwitch
Foam::fvSchemes::debug Foam::fvSchemes::debug
( (
@ -586,5 +585,35 @@ bool Foam::fvSchemes::fluxRequired(const word& name) const
} }
} }
bool Foam::fvSchemes::writeData(Ostream& os) const
{
// Write dictionaries
os << nl << "ddtSchemes";
ddtSchemes_.write(os, true);
os << nl << "d2dt2Schemes";
d2dt2Schemes_.write(os, true);
os << nl << "interpolationSchemes";
interpolationSchemes_.write(os, true);
os << nl << "divSchemes";
divSchemes_.write(os, true);
os << nl << "gradSchemes";
gradSchemes_.write(os, true);
os << nl << "snGradSchemes";
snGradSchemes_.write(os, true);
os << nl << "laplacianSchemes";
laplacianSchemes_.write(os, true);
os << nl << "fluxRequired";
fluxRequired_.write(os, true);
return true;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -184,6 +184,12 @@ public:
//- Read the fvSchemes //- Read the fvSchemes
bool read(); bool read();
// Write
//- WriteData function required for regIOobject write operation
virtual bool writeData(Ostream&) const;
}; };

View file

@ -1390,7 +1390,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::relax(const fvMatrix<Type>& m)
template<class Type> template<class Type>
Foam::lduMatrix::solverPerformance Foam::solve Foam::lduSolverPerformance Foam::solve
( (
fvMatrix<Type>& fvm, fvMatrix<Type>& fvm,
const dictionary& solverControls const dictionary& solverControls
@ -1400,13 +1400,13 @@ Foam::lduMatrix::solverPerformance Foam::solve
} }
template<class Type> template<class Type>
Foam::lduMatrix::solverPerformance Foam::solve Foam::lduSolverPerformance Foam::solve
( (
const tmp<fvMatrix<Type> >& tfvm, const tmp<fvMatrix<Type> >& tfvm,
const dictionary& solverControls const dictionary& solverControls
) )
{ {
lduMatrix::solverPerformance solverPerf = lduSolverPerformance solverPerf =
const_cast<fvMatrix<Type>&>(tfvm()).solve(solverControls); const_cast<fvMatrix<Type>&>(tfvm()).solve(solverControls);
tfvm.clear(); tfvm.clear();
@ -1416,18 +1416,18 @@ Foam::lduMatrix::solverPerformance Foam::solve
template<class Type> template<class Type>
Foam::lduMatrix::solverPerformance Foam::solve(fvMatrix<Type>& fvm) Foam::lduSolverPerformance Foam::solve(fvMatrix<Type>& fvm)
{ {
return fvm.solve(); return fvm.solve();
} }
template<class Type> template<class Type>
Foam::lduMatrix::solverPerformance Foam::solve Foam::lduSolverPerformance Foam::solve
( (
const tmp<fvMatrix<Type> >& tfvm const tmp<fvMatrix<Type> >& tfvm
) )
{ {
lduMatrix::solverPerformance solverPerf = lduSolverPerformance solverPerf =
const_cast<fvMatrix<Type>&>(tfvm()).solve(); const_cast<fvMatrix<Type>&>(tfvm()).solve();
tfvm.clear(); tfvm.clear();

View file

@ -363,7 +363,7 @@ public:
//- Solve returning the solution statistics. //- Solve returning the solution statistics.
// Use the given solver controls // Use the given solver controls
lduMatrix::solverPerformance solve(const dictionary&); lduSolverPerformance solve(const dictionary&);
//- Solve returning the solution statistics. //- Solve returning the solution statistics.
// Solver controls read from fvSolution // Solver controls read from fvSolution

View file

@ -52,7 +52,7 @@ void Foam::fvMatrix<Type>::setComponentReference
template<class Type> template<class Type>
Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve Foam::lduSolverPerformance Foam::fvMatrix<Type>::solve
( (
const dictionary& solverControls const dictionary& solverControls
) )
@ -140,7 +140,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve
cmpt cmpt
); );
lduMatrix::solverPerformance solverPerf; lduSolverPerformance solverPerf;
// Solver call // Solver call
solverPerf = lduMatrix::solver::New solverPerf = lduMatrix::solver::New
@ -170,14 +170,14 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve
psi.correctBoundaryConditions(); psi.correctBoundaryConditions();
psi_.mesh().setSolverPerformance(psi_.name(), solverPerfVec); psi_.mesh().solutionDict().setSolverPerformance(psi_.name(), solverPerfVec);
return solverPerfVec; return solverPerfVec;
} }
template<class Type> template<class Type>
Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve() Foam::lduSolverPerformance Foam::fvMatrix<Type>::solve()
{ {
return solve(psi_.mesh().solutionDict().solverDict(psi_.name())); return solve(psi_.mesh().solutionDict().solverDict(psi_.name()));
} }

View file

@ -55,7 +55,7 @@ void Foam::fvMatrix<Foam::scalar>::setComponentReference
template<> template<>
Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve Foam::lduSolverPerformance Foam::fvMatrix<Foam::scalar>::solve
( (
const dictionary& solverControls const dictionary& solverControls
) )
@ -104,7 +104,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve
psi.correctBoundaryConditions(); psi.correctBoundaryConditions();
psi_.mesh().setSolverPerformance(psi_.name(), solverPerf); psi_.mesh().solutionDict().setSolverPerformance(psi_.name(), solverPerf);
return solverPerf; return solverPerf;
} }

View file

@ -56,7 +56,7 @@ void fvMatrix<scalar>::setComponentReference
); );
template<> template<>
lduMatrix::solverPerformance fvMatrix<scalar>::solve lduSolverPerformance fvMatrix<scalar>::solve
( (
const dictionary& const dictionary&
); );

View file

@ -103,7 +103,6 @@ Foam::fvMesh::fvMesh(const IOobject& io)
: :
polyMesh(io), polyMesh(io),
surfaceInterpolation(*this), surfaceInterpolation(*this),
data(static_cast<const objectRegistry&>(*this)),
boundary_(*this, boundaryMesh()), boundary_(*this, boundaryMesh()),
lduPtr_(NULL), lduPtr_(NULL),
curTimeIndex_(time().timeIndex()), curTimeIndex_(time().timeIndex()),
@ -206,7 +205,6 @@ Foam::fvMesh::fvMesh
: :
polyMesh(io, points, faces, allOwner, allNeighbour, syncPar), polyMesh(io, points, faces, allOwner, allNeighbour, syncPar),
surfaceInterpolation(*this), surfaceInterpolation(*this),
data(static_cast<const objectRegistry&>(*this)),
boundary_(*this), boundary_(*this),
lduPtr_(NULL), lduPtr_(NULL),
curTimeIndex_(time().timeIndex()), curTimeIndex_(time().timeIndex()),
@ -237,7 +235,6 @@ Foam::fvMesh::fvMesh
: :
polyMesh(io, points, faces, cells, syncPar), polyMesh(io, points, faces, cells, syncPar),
surfaceInterpolation(*this), surfaceInterpolation(*this),
data(static_cast<const objectRegistry&>(*this)),
boundary_(*this), boundary_(*this),
lduPtr_(NULL), lduPtr_(NULL),
curTimeIndex_(time().timeIndex()), curTimeIndex_(time().timeIndex()),
@ -285,7 +282,6 @@ Foam::fvMesh::fvMesh
syncPar syncPar
), ),
surfaceInterpolation(*this), surfaceInterpolation(*this),
data(static_cast<const objectRegistry&>(*this)),
boundary_(*this), boundary_(*this),
lduPtr_(NULL), lduPtr_(NULL),
curTimeIndex_(time().timeIndex()), curTimeIndex_(time().timeIndex()),

View file

@ -52,7 +52,6 @@ SourceFiles
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "fvBoundaryMesh.H" #include "fvBoundaryMesh.H"
#include "surfaceInterpolation.H" #include "surfaceInterpolation.H"
#include "data.H"
#include "DimensionedField.H" #include "DimensionedField.H"
#include "volFieldsFwd.H" #include "volFieldsFwd.H"
#include "surfaceFieldsFwd.H" #include "surfaceFieldsFwd.H"
@ -77,8 +76,7 @@ class fvMesh
: :
public polyMesh, public polyMesh,
public lduMesh, public lduMesh,
public surfaceInterpolation, public surfaceInterpolation
public data
{ {
// Private data // Private data

View file

@ -242,7 +242,6 @@ lduMatrix = matrices/lduMatrix
$(lduMatrix)/lduMatrix/lduMatrix.C $(lduMatrix)/lduMatrix/lduMatrix.C
$(lduMatrix)/lduMatrix/lduMatrixOperations.C $(lduMatrix)/lduMatrix/lduMatrixOperations.C
$(lduMatrix)/lduMatrix/lduMatrixATmul.C $(lduMatrix)/lduMatrix/lduMatrixATmul.C
$(lduMatrix)/lduMatrix/lduMatrixTests.C
$(lduMatrix)/lduMatrix/lduMatrixUpdateMatrixInterfaces.C $(lduMatrix)/lduMatrix/lduMatrixUpdateMatrixInterfaces.C
$(lduMatrix)/lduMatrix/lduMatrixSolver.C $(lduMatrix)/lduMatrix/lduMatrixSolver.C
$(lduMatrix)/lduMatrix/lduMatrixSmoother.C $(lduMatrix)/lduMatrix/lduMatrixSmoother.C
@ -641,8 +640,6 @@ $(writers)/gnuplotGraph/gnuplotGraph.C
$(writers)/xmgrGraph/xmgrGraph.C $(writers)/xmgrGraph/xmgrGraph.C
$(writers)/jplotGraph/jplotGraph.C $(writers)/jplotGraph/jplotGraph.C
meshes/data/data.C
primitives/BlockCoeff/blockCoeffBase.C primitives/BlockCoeff/blockCoeffBase.C
primitives/BlockCoeff/scalarBlockCoeff.C primitives/BlockCoeff/scalarBlockCoeff.C
primitives/BlockCoeff/sphericalTensorBlockCoeff.C primitives/BlockCoeff/sphericalTensorBlockCoeff.C
@ -733,6 +730,8 @@ $(BlockLduSmoothers)/BlockILUCpSmoother/blockILUCpSmoothers.C
BlockLduSolvers = matrices/blockLduMatrix/BlockLduSolvers BlockLduSolvers = matrices/blockLduMatrix/BlockLduSolvers
$(BlockLduSolvers)/blockVectorNSolvers.C $(BlockLduSolvers)/blockVectorNSolvers.C
$(BlockLduSolvers)/BlockLduSolver/blockLduSolvers.C $(BlockLduSolvers)/BlockLduSolver/blockLduSolvers.C
$(BlockLduSolvers)/BlockLduSolver/BlockSolverPerformances.C
$(BlockLduSolvers)/BlockLduSolver/BlockSolverPerformanceVectorN.C
$(BlockLduSolvers)/BlockDiagonal/blockDiagonalSolvers.C $(BlockLduSolvers)/BlockDiagonal/blockDiagonalSolvers.C
$(BlockLduSolvers)/BlockGaussSeidel/blockGaussSeidelSolvers.C $(BlockLduSolvers)/BlockGaussSeidel/blockGaussSeidelSolvers.C
$(BlockLduSolvers)/BlockCG/blockCGSolvers.C $(BlockLduSolvers)/BlockCG/blockCGSolvers.C

View file

@ -27,7 +27,6 @@ License
#include "foamTime.H" #include "foamTime.H"
#include "demandDrivenData.H" #include "demandDrivenData.H"
#include "dictionary.H" #include "dictionary.H"
#include "data.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -34,7 +34,7 @@ bool Foam::BlockSolverPerformance<Type>::checkConvergence
const scalar RelTolerance const scalar RelTolerance
) )
{ {
if (BlockLduMatrix<Type>::debug >= 2) if (debug >= 2)
{ {
Info<< solverName_ Info<< solverName_
<< ": Iteration " << nIterations_ << ": Iteration " << nIterations_
@ -92,7 +92,7 @@ bool Foam::BlockSolverPerformance<Type>::checkSingularity
template<class Type> template<class Type>
void Foam::BlockSolverPerformance<Type>::print() const void Foam::BlockSolverPerformance<Type>::print() const
{ {
if (BlockLduMatrix<Type>::debug) if (debug)
{ {
Info<< solverName_ << ": Solving for " << fieldName_; Info<< solverName_ << ": Solving for " << fieldName_;
@ -111,4 +111,65 @@ void Foam::BlockSolverPerformance<Type>::print() const
} }
template<class Type>
bool Foam::BlockSolverPerformance<Type>::operator!=
(
const BlockSolverPerformance<Type>& bsp
) const
{
return
(
solverName() != bsp.solverName()
|| fieldName() != bsp.fieldName()
|| initialResidual() != bsp.initialResidual()
|| finalResidual() != bsp.finalResidual()
|| nIterations() != bsp.nIterations()
|| converged() != bsp.converged()
|| singular() != bsp.singular()
);
}
template<class Type>
Foam::Istream& Foam::operator>>
(
Istream& is,
typename Foam::BlockSolverPerformance<Type>& bsp
)
{
is.readBeginList("BlockSolverPerformance<Type>");
is >> bsp.solverName_
>> bsp.fieldName_
>> bsp.initialResidual_
>> bsp.finalResidual_
>> bsp.nIterations_
>> bsp.converged_
>> bsp.singular_;
is.readEndList("BlockSolverPerformance<Type>");
return is;
}
template<class Type>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const typename Foam::BlockSolverPerformance<Type>& bsp
)
{
os << token::BEGIN_LIST
<< bsp.solverName_ << token::SPACE
<< bsp.fieldName_ << token::SPACE
<< bsp.initialResidual_ << token::SPACE
<< bsp.finalResidual_ << token::SPACE
<< bsp.nIterations_ << token::SPACE
<< bsp.converged_ << token::SPACE
<< bsp.singular_ << token::SPACE
<< token::END_LIST;
return os;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -51,6 +51,9 @@ namespace Foam
template<class Type> template<class Type>
class BlockSolverPerformance; class BlockSolverPerformance;
template<class Type>
Istream& operator>>(Istream&, BlockSolverPerformance<Type>&);
template<class Type> template<class Type>
Ostream& operator<<(Ostream&, const BlockSolverPerformance<Type>&); Ostream& operator<<(Ostream&, const BlockSolverPerformance<Type>&);
@ -88,8 +91,24 @@ class BlockSolverPerformance
public: public:
// Static data
// Declare name of the class and its debug switch
ClassName("BlockSolverPerformance");
// Constructors // Constructors
//- Construct without solver and field name
BlockSolverPerformance()
:
initialResidual_(pTraits<Type>::zero),
finalResidual_(pTraits<Type>::zero),
nIterations_(0),
converged_(false),
singular_(false)
{}
//- Construct with solver and field name //- Construct with solver and field name
BlockSolverPerformance BlockSolverPerformance
( (
@ -120,6 +139,18 @@ public:
return solverName_; return solverName_;
} }
//- Return solver name
word& solverName()
{
return solverName_;
}
//- Return field name
const word& fieldName() const
{
return fieldName_;
}
//- Return initial residual //- Return initial residual
const Type& initialResidual() const const Type& initialResidual() const
{ {
@ -192,6 +223,26 @@ public:
//- Print summary of solver performance //- Print summary of solver performance
void print() const; void print() const;
// Member Operators
bool operator!=(const BlockSolverPerformance<Type>&) const;
// Friend functions
friend Istream& operator>> <Type>
(
Istream&,
BlockSolverPerformance<Type>&
);
friend Ostream& operator<< <Type>
(
Ostream&,
const BlockSolverPerformance<Type>&
);
}; };

View file

@ -0,0 +1,53 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
Description
BlockSolverPerformance static data members
Author
Vanja Skuric, FMENA Zagreb. All rights reserved.
\*---------------------------------------------------------------------------*/
#include "coeffFields.H"
#include "BlockSolverPerformanceVectorN.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
#define makeNamedTemplateTypeNameAndDebug(type, Type, args...) \
defineNamedTemplateTypeNameAndDebug(BlockSolverPerformance##Type, 1);
forAllVectorNTypes(makeNamedTemplateTypeNameAndDebug);
#undef makeNamedTemplateTypeNameAndDebug
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,66 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
BlockSolverPerformance
Description
Typedefs for BlockSolverPerformance
Author
Vanja Skuric, FMENA Zagreb. All rights reserved.
\*---------------------------------------------------------------------------*/
#ifndef BlockSolverPerformanceVectorN_H
#define BlockSolverPerformanceVectorN_H
#include "BlockSolverPerformances.H"
#include "VectorTensorNFieldsFwd.H"
#include "ExpandTensorNField.H"
#include "VectorNFieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeTypedef(type, Type, args...) \
typedef BlockSolverPerformance<type> BlockSolverPerformance##Type;
forAllVectorNTypes(makeTypedef)
#undef makeTypedef
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,52 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
Description
BlockSolverPerformance static data members
Author
Vanja Skuric, FMENA Zagreb. All rights reserved.
\*---------------------------------------------------------------------------*/
#include "BlockSolverPerformances.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineNamedTemplateTypeNameAndDebug(BlockSolverPerformanceScalar, 1);
defineNamedTemplateTypeNameAndDebug(BlockSolverPerformanceVector, 1);
defineNamedTemplateTypeNameAndDebug(BlockSolverPerformanceSphericalTensor, 1);
defineNamedTemplateTypeNameAndDebug(BlockSolverPerformanceSymmTensor, 1);
defineNamedTemplateTypeNameAndDebug(BlockSolverPerformanceTensor, 1);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,64 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
BlockSolverPerformance
Description
Typedefs for BlockSolverPerformance
Author
Vanja Skuric, FMENA Zagreb. All rights reserved.
\*---------------------------------------------------------------------------*/
#ifndef BlockSolverPerformances_H
#define BlockSolverPerformances_H
#include "BlockSolverPerformance.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef BlockSolverPerformance<scalar> BlockSolverPerformanceScalar;
typedef BlockSolverPerformance<vector> BlockSolverPerformanceVector;
typedef BlockSolverPerformance<sphericalTensor>
BlockSolverPerformanceSphericalTensor;
typedef BlockSolverPerformance<symmTensor> BlockSolverPerformanceSymmTensor;
typedef BlockSolverPerformance<tensor> BlockSolverPerformanceTensor;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -42,7 +42,6 @@ SourceFiles
lduMatrixOperations.C lduMatrixOperations.C
lduMatrixSolver.C lduMatrixSolver.C
lduMatrixPreconditioner.C lduMatrixPreconditioner.C
lduMatrixTests.C
lduMatrixUpdateMatrixInterfaces.C lduMatrixUpdateMatrixInterfaces.C
lduMatrixBufferedUpdateMatrixInterfaces.C lduMatrixBufferedUpdateMatrixInterfaces.C
@ -60,6 +59,7 @@ SourceFiles
#include "autoPtr.H" #include "autoPtr.H"
#include "runTimeSelectionTables.H" #include "runTimeSelectionTables.H"
#include "profilingTrigger.H" #include "profilingTrigger.H"
#include "lduSolverPerformance.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -93,181 +93,6 @@ class lduMatrix
public: public:
//- Class returned by the solver, containing performance statistics
class solverPerformance
{
// Private Data
//- Name of solver
word solverName_;
//- Name of field
word fieldName_;
//- Initial residual
scalar initialResidual_;
//- Final residual
scalar finalResidual_;
//- Number of iterations
label noIterations_;
//- Has the solver converged?
bool converged_;
//- Has the solver indicated a singular matrix?
bool singular_;
public:
// Constructors
//- Construct null
solverPerformance()
:
initialResidual_(0),
finalResidual_(0),
noIterations_(0),
converged_(false),
singular_(false)
{}
//- Construct from components
solverPerformance
(
const word& solverName,
const word& fieldName,
const scalar iRes = 0,
const scalar fRes = 0,
const label nIter = 0,
const bool converged = false,
const bool singular = false
)
:
solverName_(solverName),
fieldName_(fieldName),
initialResidual_(iRes),
finalResidual_(fRes),
noIterations_(nIter),
converged_(converged),
singular_(singular)
{}
// Member functions
//- Return solver name
const word& solverName() const
{
return solverName_;
}
//- Return access to solver name
word& solverName()
{
return solverName_;
}
//- Return field name
const word& fieldName() const
{
return fieldName_;
}
//- Return access to field name
word& fieldName()
{
return fieldName_;
}
//- Return initial residual
scalar initialResidual() const
{
return initialResidual_;
}
//- Return initial residual
scalar& initialResidual()
{
return initialResidual_;
}
//- Return final residual
scalar finalResidual() const
{
return finalResidual_;
}
//- Return final residual
scalar& finalResidual()
{
return finalResidual_;
}
//- Return number of iterations
label nIterations() const
{
return noIterations_;
}
//- Return number of iterations
label& nIterations()
{
return noIterations_;
}
//- Has the solver converged?
bool converged() const
{
return converged_;
}
//- Is the matrix singular?
bool singular() const
{
return singular_;
}
//- Convergence test
bool checkConvergence
(
const scalar tolerance,
const scalar relTolerance
);
//- Singularity test
bool checkSingularity(const scalar residual);
//- Print summary of solver performance
void print() const;
// Member Operators
bool operator!=(const solverPerformance&) const;
// Ostream Operator
friend Istream& operator>>
(
Istream&,
solverPerformance&
);
friend Ostream& operator<<
(
Ostream&,
const solverPerformance&
);
};
//- Abstract base-class for lduMatrix solvers //- Abstract base-class for lduMatrix solvers
class solver class solver
{ {
@ -322,10 +147,10 @@ public:
} }
//- Is the stop criterion reached //- Is the stop criterion reached
bool stop(lduMatrix::solverPerformance& solverPerf) const; bool stop(lduSolverPerformance& solverPerf) const;
//- Is the converrgence criterion reached //- Is the converrgence criterion reached
bool converged(lduMatrix::solverPerformance& solverPerf) const; bool converged(lduSolverPerformance& solverPerf) const;
//- Read the control parameters from the dictionary //- Read the control parameters from the dictionary
virtual void readControls(); virtual void readControls();
@ -491,7 +316,7 @@ public:
//- Read and reset the solver parameters from the given stream //- Read and reset the solver parameters from the given stream
virtual void read(const dictionary&); virtual void read(const dictionary&);
virtual solverPerformance solve virtual lduSolverPerformance solve
( (
scalarField& x, scalarField& x,
const scalarField& b, const scalarField& b,
@ -1048,7 +873,6 @@ public:
// Helper typedefs // Helper typedefs
typedef lduMatrix::solver lduSolver; typedef lduMatrix::solver lduSolver;
typedef lduMatrix::solverPerformance lduSolverPerformance;
typedef lduMatrix::preconditioner lduPreconditioner; typedef lduMatrix::preconditioner lduPreconditioner;
typedef lduMatrix::smoother lduSmoother; typedef lduMatrix::smoother lduSmoother;

View file

@ -207,7 +207,7 @@ Foam::scalar Foam::lduMatrix::solver::normFactor
bool Foam::lduMatrix::solver::stop bool Foam::lduMatrix::solver::stop
( (
lduMatrix::solverPerformance& solverPerf lduSolverPerformance& solverPerf
) const ) const
{ {
if (solverPerf.nIterations() < minIter_) if (solverPerf.nIterations() < minIter_)
@ -221,7 +221,7 @@ bool Foam::lduMatrix::solver::stop
bool Foam::lduMatrix::solver::converged bool Foam::lduMatrix::solver::converged
( (
lduMatrix::solverPerformance& solverPerf lduSolverPerformance& solverPerf
) const ) const
{ {
if if

View file

@ -1,165 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
Description
Convergence and singularity tests for solvers.
\*---------------------------------------------------------------------------*/
#include "lduMatrix.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
bool Foam::lduMatrix::solverPerformance::checkConvergence
(
const scalar Tolerance,
const scalar RelTolerance
)
{
if (debug >= 2)
{
Info<< solverName_
<< ": Iteration " << noIterations_
<< " residual = " << finalResidual_
<< endl;
}
if
(
finalResidual_ < Tolerance // Abs. tolerance
|| (
RelTolerance > SMALL
&& finalResidual_ <= RelTolerance*initialResidual_ // Rel. tolerance
)
// || (solverName == "symSolve" && iter == 0)
)
{
converged_ = true;
}
else
{
converged_ = false;
}
return converged_;
}
bool Foam::lduMatrix::solverPerformance::checkSingularity
(
const scalar residual
)
{
if (residual > VSMALL)
{
singular_ = false;
}
else
{
singular_ = true;
}
return singular_;
}
void Foam::lduMatrix::solverPerformance::print() const
{
if (debug)
{
Info<< solverName_ << ": Solving for " << fieldName_;
if (singular())
{
Info<< ": solution singularity" << endl;
}
else
{
Info<< ", Initial residual = " << initialResidual_
<< ", Final residual = " << finalResidual_
<< ", No Iterations " << noIterations_
<< endl;
}
}
}
bool Foam::lduSolverPerformance::operator!=
(
const lduSolverPerformance& sp
) const
{
return
(
solverName() != sp.solverName()
|| fieldName() != sp.fieldName()
|| initialResidual() != sp.initialResidual()
|| finalResidual() != sp.finalResidual()
|| nIterations() != sp.nIterations()
|| converged() != sp.converged()
|| singular() != sp.singular()
);
}
Foam::Istream& Foam::operator>>
(
Istream& is,
lduSolverPerformance& sp
)
{
is.readBeginList("SolverPerformance<Type>");
is >> sp.solverName_
>> sp.fieldName_
>> sp.initialResidual_
>> sp.finalResidual_
>> sp.noIterations_
>> sp.converged_
>> sp.singular_;
is.readEndList("SolverPerformance<Type>");
return is;
}
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const lduSolverPerformance& sp
)
{
os << token::BEGIN_LIST
<< sp.solverName_ << token::SPACE
<< sp.fieldName_ << token::SPACE
<< sp.initialResidual_ << token::SPACE
<< sp.finalResidual_ << token::SPACE
<< sp.noIterations_ << token::SPACE
<< sp.converged_ << token::SPACE
<< sp.singular_ << token::SPACE
<< token::END_LIST;
return os;
}
// ************************************************************************* //

View file

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
Typedef
Foam::lduSolverPerformance
Description
BlockSolverPerformance instantiated for a scalar and lduMatrix
\*---------------------------------------------------------------------------*/
#ifndef lduSolverPerformance_H
#define lduSolverPerformance_H
#include "BlockSolverPerformance.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef BlockSolverPerformance<scalar> lduSolverPerformance;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -30,7 +30,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::lduMatrix::solverPerformance Foam::GAMGSolver::solve Foam::lduSolverPerformance Foam::GAMGSolver::solve
( (
scalarField& x, scalarField& x,
const scalarField& b, const scalarField& b,

View file

@ -59,7 +59,7 @@ Foam::diagonalSolver::diagonalSolver
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::lduMatrix::solverPerformance Foam::diagonalSolver::solve Foam::lduSolverPerformance Foam::diagonalSolver::solve
( (
scalarField& x, scalarField& x,
const scalarField& b, const scalarField& b,

View file

@ -146,7 +146,8 @@ Foam::solution::solution(const objectRegistry& obr, const fileName& dictName)
eqnRelaxDict_(dictionary::null), eqnRelaxDict_(dictionary::null),
fieldRelaxDefault_(0), fieldRelaxDefault_(0),
eqnRelaxDefault_(0), eqnRelaxDefault_(0),
solvers_(dictionary::null) solvers_(dictionary::null),
prevTimeIndex_(0)
{ {
if (!headerOk()) if (!headerOk())
{ {
@ -162,6 +163,8 @@ Foam::solution::solution(const objectRegistry& obr, const fileName& dictName)
} }
read(solutionDict()); read(solutionDict());
set("solverPerformance", dictionary());
} }
@ -408,5 +411,46 @@ bool Foam::solution::writeData(Ostream& os) const
return true; return true;
} }
const Foam::dictionary& Foam::solution::solverPerformanceDict() const
{
return subDict("solverPerformance");
}
void Foam::solution::setSolverPerformance
(
const word& name,
const lduSolverPerformance& sp
) const
{
dictionary& dict = const_cast<dictionary&>(solverPerformanceDict());
List<lduSolverPerformance> perfs;
if (prevTimeIndex_ != this->time().timeIndex())
{
// Reset solver performance between iterations
prevTimeIndex_ = this->time().timeIndex();
dict.clear();
}
else
{
dict.readIfPresent(name, perfs);
}
// Append to list
perfs.setSize(perfs.size()+1, sp);
dict.set(name, perfs);
}
void Foam::solution::setSolverPerformance
(
const lduSolverPerformance& sp
) const
{
setSolverPerformance(sp.fieldName(), sp);
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -37,6 +37,7 @@ SourceFiles
#include "IOdictionary.H" #include "IOdictionary.H"
#include "debugSwitch.H" #include "debugSwitch.H"
#include "lduSolverPerformance.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -74,6 +75,9 @@ class solution
//- Dictionary of solver parameters for all the fields //- Dictionary of solver parameters for all the fields
dictionary solvers_; dictionary solvers_;
//- Previously used time-index, used for reset between iterations
mutable label prevTimeIndex_;
// Private Member Functions // Private Member Functions
@ -144,6 +148,24 @@ public:
//- Return the solver controls dictionary for the given field //- Return the solver controls dictionary for the given field
const dictionary& solver(const word& name) const; const dictionary& solver(const word& name) const;
//- Return the dictionary of solver performance data
// which includes initial and final residuals for convergence
// checking
const dictionary& solverPerformanceDict() const;
//- Add/set the solverPerformance entry for the named field
void setSolverPerformance
(
const word& name,
const lduSolverPerformance&
) const;
//- Add/set the solverPerformance entry, using its fieldName
void setSolverPerformance
(
const lduSolverPerformance&
) const;
// Edit // Edit

View file

@ -1,99 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "data.H"
#include "foamTime.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
int Foam::data::debug(Foam::debug::debugSwitchFromDict("data", false));
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::data::data(const objectRegistry& obr)
:
IOdictionary
(
IOobject
(
"data",
obr.time().system(),
obr,
IOobject::NO_READ,
IOobject::NO_WRITE
)
),
prevTimeIndex_(0)
{
set("solverPerformance", dictionary());
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::dictionary& Foam::data::solverPerformanceDict() const
{
return subDict("solverPerformance");
}
void Foam::data::setSolverPerformance
(
const word& name,
const lduSolverPerformance& sp
) const
{
dictionary& dict = const_cast<dictionary&>(solverPerformanceDict());
List<lduSolverPerformance> perfs;
if (prevTimeIndex_ != this->time().timeIndex())
{
// Reset solver performance between iterations
prevTimeIndex_ = this->time().timeIndex();
dict.clear();
}
else
{
dict.readIfPresent(name, perfs);
}
// Append to list
perfs.setSize(perfs.size()+1, sp);
dict.set(name, perfs);
}
void Foam::data::setSolverPerformance
(
const lduSolverPerformance& sp
) const
{
setSolverPerformance(sp.fieldName(), sp);
}
// ************************************************************************* //

View file

@ -1,116 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::data
Description
Database for solution data, solver performance and other reduced data.
fvMesh is derived from data so that all fields have access to the data from
the mesh reference they hold.
SourceFiles
data.C
\*---------------------------------------------------------------------------*/
#ifndef data_H
#define data_H
#include "IOdictionary.H"
#include "lduMatrix.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class data Declaration
\*---------------------------------------------------------------------------*/
class data
:
public IOdictionary
{
// Private data
//- Previously used time-index, used for reset between iterations
mutable label prevTimeIndex_;
// Private Member Functions
//- Disallow default bitwise copy construct
data(const data&);
//- Disallow default bitwise assignment
void operator=(const data&);
public:
//- Debug switch
static int debug;
// Constructors
//- Construct for objectRegistry
data(const objectRegistry& obr);
// Member Functions
// Access
//- Return the dictionary of solver performance data
// which includes initial and final residuals for convergence
// checking
const dictionary& solverPerformanceDict() const;
//- Add/set the solverPerformance entry for the named field
void setSolverPerformance
(
const word& name,
const lduSolverPerformance&
) const;
//- Add/set the solverPerformance entry, using its fieldName
void setSolverPerformance
(
const lduSolverPerformance&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -66,7 +66,6 @@ divSchemes
laplacianSchemes { default Gauss linear corrected; } laplacianSchemes { default Gauss linear corrected; }
interpolationSchemes { default linear; } interpolationSchemes { default linear; }
snGradSchemes { default corrected; } snGradSchemes { default corrected; }
fluxRequired { default yes; }
EOF EOF
} }
# #

View file

@ -45,8 +45,4 @@ interpolationSchemes
snGradSchemes snGradSchemes
{} {}
fluxRequired
{}
// ************************************************************************* // // ************************************************************************* //

View file

@ -72,12 +72,6 @@ snGradSchemes
default limited 0.5; default limited 0.5;
} }
fluxRequired
{
default no;
p;
}
mixingPlane mixingPlane
{ {
default areaAveraging; default areaAveraging;
@ -86,22 +80,4 @@ mixingPlane
omega areaAveraging; omega areaAveraging;
} }
// ************************************************************************* // // ************************************************************************* //

View file

@ -72,12 +72,6 @@ snGradSchemes
default limited 0.5; default limited 0.5;
} }
fluxRequired
{
default no;
p;
}
mixingPlane mixingPlane
{ {
default areaAveraging; default areaAveraging;

View file

@ -52,11 +52,4 @@ snGradSchemes
default corrected; default corrected;
} }
fluxRequired
{
default no;
p_rgh;
p;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -46,9 +46,4 @@ snGradSchemes
default uncorrected; default uncorrected;
} }
fluxRequired
{
default no;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -49,10 +49,5 @@ snGradSchemes
default corrected; default corrected;
} }
fluxRequired
{
h;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -50,9 +50,5 @@ snGradSchemes
default corrected; default corrected;
} }
fluxRequired
{
h;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -48,9 +48,4 @@ snGradSchemes
default corrected; default corrected;
} }
fluxRequired
{
p;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -48,9 +48,4 @@ snGradSchemes
default corrected; default corrected;
} }
fluxRequired
{
p;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -51,9 +51,4 @@ snGradSchemes
default corrected; default corrected;
} }
fluxRequired
{
p;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -50,11 +50,4 @@ snGradSchemes
default corrected; default corrected;
} }
fluxRequired
{
default no;
pcorr;
p;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -49,9 +49,5 @@ snGradSchemes
default corrected; default corrected;
} }
fluxRequired
{
default yes;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -49,9 +49,5 @@ snGradSchemes
default corrected; default corrected;
} }
fluxRequired
{
default yes;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -47,9 +47,4 @@ snGradSchemes
default none; default none;
} }
fluxRequired
{
p;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -44,8 +44,4 @@ snGradSchemes
{ {
} }
fluxRequired
{
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -43,8 +43,4 @@ snGradSchemes
{ {
} }
fluxRequired
{
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -48,8 +48,4 @@ snGradSchemes
default none; default none;
} }
fluxRequired
{
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -43,8 +43,4 @@ snGradSchemes
{ {
} }
fluxRequired
{
}
// ************************************************************************* // // ************************************************************************* //