Backported interIbFoam, porousSimpleIbFoam and simpleIbFoam (setFluxRequired, solutionControls) to vanilla 3.0.1 format

This commit is contained in:
Vanja Skuric 2016-05-07 10:31:37 +02:00
parent 685dad16cb
commit b99c3261a7
18 changed files with 41 additions and 102 deletions

View file

@ -16,7 +16,7 @@
UEqn.relax(); UEqn.relax();
if (momentumPredictor) if (pimple.momentumPredictor())
{ {
solve solve
( (

View file

@ -38,7 +38,7 @@
mesh.schemesDict().setFluxRequired(pcorr.name()); mesh.schemesDict().setFluxRequired(pcorr.name());
for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) while(pimple.correctNonOrthogonal())
{ {
fvScalarMatrix pcorrEqn fvScalarMatrix pcorrEqn
( (
@ -48,7 +48,7 @@
pcorrEqn.setReference(pdRefCell, pdRefValue); pcorrEqn.setReference(pdRefCell, pdRefValue);
pcorrEqn.solve(); pcorrEqn.solve();
if (nonOrth == nNonOrthCorr) if (pimple.finalNonOrthogonalIter())
{ {
phi -= pcorrEqn.flux(); phi -= pcorrEqn.flux();
} }

View file

@ -128,6 +128,8 @@
); );
} }
mesh.schemesDict().setFluxRequired(pd.name());
// Construct interface from alpha1 distribution // Construct interface from alpha1 distribution
interfaceProperties interface(alpha1, U, twoPhaseProperties); interfaceProperties interface(alpha1, U, twoPhaseProperties);

View file

@ -45,6 +45,7 @@ Author
#include "interfaceProperties.H" #include "interfaceProperties.H"
#include "twoPhaseMixture.H" #include "twoPhaseMixture.H"
#include "turbulenceModel.H" #include "turbulenceModel.H"
#include "pimpleControl.H"
#include "immersedBoundaryFvPatch.H" #include "immersedBoundaryFvPatch.H"
#include "immersedBoundaryAdjustPhi.H" #include "immersedBoundaryAdjustPhi.H"
@ -56,8 +57,10 @@ int main(int argc, char *argv[])
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
# include "createMesh.H" # include "createMesh.H"
pimpleControl pimple(mesh);
# include "readGravitationalAcceleration.H" # include "readGravitationalAcceleration.H"
# include "readPIMPLEControls.H"
# include "initContinuityErrs.H" # include "initContinuityErrs.H"
# include "createFields.H" # include "createFields.H"
# include "createIbMasks.H" # include "createIbMasks.H"
@ -72,7 +75,6 @@ int main(int argc, char *argv[])
while (runTime.run()) while (runTime.run())
{ {
# include "readPIMPLEControls.H"
# include "readTimeControls.H" # include "readTimeControls.H"
# include "immersedBoundaryCourantNo.H" # include "immersedBoundaryCourantNo.H"
# include "setDeltaT.H" # include "setDeltaT.H"
@ -82,8 +84,7 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
// Pressure-velocity corrector // Pressure-velocity corrector
int oCorr = 0; while (pimple.loop())
do
{ {
twoPhaseProperties.correct(); twoPhaseProperties.correct();
@ -92,7 +93,7 @@ int main(int argc, char *argv[])
# include "UEqn.H" # include "UEqn.H"
// --- PISO loop // --- PISO loop
for (int corr = 0; corr < nCorr; corr++) while (pimple.correct())
{ {
# include "pEqn.H" # include "pEqn.H"
} }
@ -117,7 +118,7 @@ int main(int argc, char *argv[])
} }
turbulence->correct(); turbulence->correct();
} while (++oCorr < nOuterCorr); }
runTime.write(); runTime.write();

View file

@ -1,5 +1,6 @@
{ {
scalar limitMagU = readScalar(pimple.lookup("limitMagU")); scalar limitMagU =
readScalar(mesh.solutionDict().subDict("PIMPLE").lookup("limitMagU"));
volScalarField magU(mag(U)); volScalarField magU(mag(U));

View file

@ -1,5 +1,5 @@
{ {
if (nOuterCorr != 1) if (!pimple.firstIter())
{ {
pd.storePrevIter(); pd.storePrevIter();
} }
@ -29,7 +29,7 @@
)*rUAf*mesh.magSf(); )*rUAf*mesh.magSf();
for(int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) while (pimple.correctNonOrthogonal())
{ {
fvScalarMatrix pdEqn fvScalarMatrix pdEqn
( (
@ -38,23 +38,20 @@
pdEqn.setReference(pdRefCell, pdRefValue); pdEqn.setReference(pdRefCell, pdRefValue);
if (corr == nCorr - 1 && nonOrth == nNonOrthCorr) pdEqn.solve
{ (
pdEqn.solve(mesh.solutionDict().solver(pd.name() + "Final")); mesh.solutionDict().solver(pd.select(pimple.finalInnerIter()))
} );
else
{
pdEqn.solve(mesh.solutionDict().solver(pd.name()));
}
if (nonOrth == nNonOrthCorr)
if (pimple.finalNonOrthogonalIter())
{ {
phi -= pdEqn.flux(); phi -= pdEqn.flux();
} }
} }
// Explicitly relax pressure except for last corrector // Explicitly relax pressure except for last corrector
if (oCorr != nOuterCorr - 1) if (!pimple.finalIter())
{ {
pd.relax(); pd.relax();
} }

View file

@ -9,9 +9,4 @@
pZones.addResistance(UEqn()); pZones.addResistance(UEqn());
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

@ -32,7 +32,7 @@
label pRefCell = 0; label pRefCell = 0;
scalar pRefValue = 0.0; scalar pRefValue = 0.0;
setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue);
mesh.schemesDict().setFluxRequired(p.name());
singlePhaseTransportModel laminarTransport(U, phi); singlePhaseTransportModel laminarTransport(U, phi);

View file

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

View file

@ -14,7 +14,7 @@
adjustPhi(phi, U, p); adjustPhi(phi, U, p);
// Non-orthogonal pressure corrector loop // Non-orthogonal pressure corrector loop
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) while (simple.correctNonOrthogonal())
{ {
fvScalarMatrix pEqn fvScalarMatrix pEqn
( (
@ -23,18 +23,9 @@
pEqn.setReference(pRefCell, pRefValue); pEqn.setReference(pRefCell, pRefValue);
// Retain the residual from the first iteration pEqn.solve();
if (nonOrth == 0)
{
eqnResidual = pEqn.solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);
}
else
{
pEqn.solve();
}
if (nonOrth == nNonOrthCorr) if (simple.finalNonOrthogonalIter())
{ {
phi -= pEqn.flux(); phi -= pEqn.flux();
} }

View file

@ -37,6 +37,7 @@ Author
#include "singlePhaseTransportModel.H" #include "singlePhaseTransportModel.H"
#include "RASModel.H" #include "RASModel.H"
#include "porousZones.H" #include "porousZones.H"
#include "simpleControl.H"
#include "immersedBoundaryFvPatch.H" #include "immersedBoundaryFvPatch.H"
#include "immersedBoundaryAdjustPhi.H" #include "immersedBoundaryAdjustPhi.H"
@ -48,6 +49,9 @@ int main(int argc, char *argv[])
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
# include "createMesh.H" # include "createMesh.H"
simpleControl simple(mesh);
# include "createIbMasks.H" # include "createIbMasks.H"
# include "createFields.H" # include "createFields.H"
# include "initContinuityErrs.H" # include "initContinuityErrs.H"
@ -60,9 +64,6 @@ int main(int argc, char *argv[])
{ {
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
# include "readSIMPLEControls.H"
# include "initConvergenceCheck.H"
p.storePrevIter(); p.storePrevIter();
// Pressure-velocity SIMPLE corrector // Pressure-velocity SIMPLE corrector
@ -78,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"
} }
Info<< "End\n" << endl; Info<< "End\n" << endl;

View file

@ -7,9 +7,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

@ -32,7 +32,7 @@
label pRefCell = 0; label pRefCell = 0;
scalar pRefValue = 0.0; scalar pRefValue = 0.0;
setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue);
mesh.schemesDict().setFluxRequired(p.name());
singlePhaseTransportModel laminarTransport(U, phi); singlePhaseTransportModel laminarTransport(U, phi);

View file

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

View file

@ -14,7 +14,7 @@
adjustPhi(phi, U, p); adjustPhi(phi, U, p);
// Non-orthogonal pressure corrector loop // Non-orthogonal pressure corrector loop
for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) while (simple.correctNonOrthogonal())
{ {
fvScalarMatrix pEqn fvScalarMatrix pEqn
( (
@ -23,18 +23,9 @@
pEqn.setReference(pRefCell, pRefValue); pEqn.setReference(pRefCell, pRefValue);
// Retain the residual from the first iteration pEqn.solve();
if (nonOrth == 0)
{
eqnResidual = pEqn.solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);
}
else
{
pEqn.solve();
}
if (nonOrth == nNonOrthCorr) if (simple.finalNonOrthogonalIter())
{ {
phi -= pEqn.flux(); phi -= pEqn.flux();
} }

View file

@ -36,6 +36,7 @@ Author
#include "fvCFD.H" #include "fvCFD.H"
#include "singlePhaseTransportModel.H" #include "singlePhaseTransportModel.H"
#include "RASModel.H" #include "RASModel.H"
#include "simpleControl.H"
#include "immersedBoundaryFvPatch.H" #include "immersedBoundaryFvPatch.H"
#include "immersedBoundaryAdjustPhi.H" #include "immersedBoundaryAdjustPhi.H"
@ -47,6 +48,9 @@ int main(int argc, char *argv[])
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
# include "createMesh.H" # include "createMesh.H"
simpleControl simple(mesh);
# include "createIbMasks.H" # include "createIbMasks.H"
# include "createFields.H" # include "createFields.H"
# include "initContinuityErrs.H" # include "initContinuityErrs.H"
@ -59,9 +63,6 @@ int main(int argc, char *argv[])
{ {
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
# include "readSIMPLEControls.H"
# include "initConvergenceCheck.H"
p.storePrevIter(); p.storePrevIter();
// Pressure-velocity SIMPLE corrector // Pressure-velocity SIMPLE corrector
@ -77,8 +78,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"
} }
Info<< "End\n" << endl; Info<< "End\n" << endl;