Coupled solver updates: bounding
This commit is contained in:
parent
5e0c89e3c7
commit
6ba095ba56
6 changed files with 82 additions and 5 deletions
32
applications/solvers/coupled/pUCoupledFoam/boundPU.H
Normal file
32
applications/solvers/coupled/pUCoupledFoam/boundPU.H
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
// Bound the pressure
|
||||
dimensionedScalar p1 = min(p);
|
||||
dimensionedScalar p2 = max(p);
|
||||
|
||||
if (p1 < pMin || p2 > pMax)
|
||||
{
|
||||
Info<< "p: " << p1.value() << " " << p2.value()
|
||||
<< ". Bounding." << endl;
|
||||
|
||||
p.max(pMin);
|
||||
p.min(pMax);
|
||||
p.correctBoundaryConditions();
|
||||
}
|
||||
|
||||
// Bound the velocity
|
||||
volScalarField magU = mag(U);
|
||||
dimensionedScalar U1 = max(magU);
|
||||
|
||||
if (U1 > UMax)
|
||||
{
|
||||
Info<< "U: " << U1.value() << ". Bounding." << endl;
|
||||
|
||||
volScalarField Ulimiter = pos(magU - UMax)*UMax/(magU + smallU)
|
||||
+ neg(magU - UMax);
|
||||
Ulimiter.max(scalar(0));
|
||||
Ulimiter.min(scalar(1));
|
||||
|
||||
U *= Ulimiter;
|
||||
U.correctBoundaryConditions();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
// Check convergence
|
||||
if (maxResidual < convergenceCriterion)
|
||||
{
|
||||
Info<< "reached convergence criterion: " << convergenceCriterion << endl;
|
||||
runTime.writeAndEnd();
|
||||
Info<< "latestTime = " << runTime.timeName() << endl;
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
// initialize values for convergence checks
|
||||
|
||||
scalar maxResidual = 0;
|
||||
scalar convergenceCriterion = 0;
|
|
@ -52,11 +52,14 @@ int main(int argc, char *argv[])
|
|||
# include "createMesh.H"
|
||||
# include "createFields.H"
|
||||
# include "initContinuityErrs.H"
|
||||
# include "readBlockSolverControls.H"
|
||||
# include "initConvergenceCheck.H"
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
while (runTime.loop())
|
||||
{
|
||||
# include "readBlockSolverControls.H"
|
||||
# include "readFieldBounds.H"
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
p.storePrevIter();
|
||||
|
@ -74,7 +77,7 @@ int main(int argc, char *argv[])
|
|||
# include "couplingTerms.H"
|
||||
|
||||
// Solve the block matrix
|
||||
UpEqn.solve();
|
||||
maxResidual = cmptMax(UpEqn.solve().initialResidual());
|
||||
|
||||
// Retrieve solution
|
||||
UpEqn.retrieveSolution(0, U.internalField());
|
||||
|
@ -87,6 +90,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
# include "continuityErrs.H"
|
||||
|
||||
# include "boundPU.H"
|
||||
|
||||
p.relax();
|
||||
|
||||
turbulence->correct();
|
||||
|
@ -95,6 +100,8 @@ int main(int argc, char *argv[])
|
|||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||
<< nl << endl;
|
||||
|
||||
# include "convergenceCheck.H"
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
label pRefCell = 0;
|
||||
scalar pRefValue = 0;
|
||||
setRefCell(p, mesh.solutionDict().subDict("blockSolver"), pRefCell, pRefValue);
|
||||
label pRefCell = 0;
|
||||
scalar pRefValue = 0;
|
||||
setRefCell
|
||||
(
|
||||
p,
|
||||
mesh.solutionDict().subDict("blockSolver"),
|
||||
pRefCell,
|
||||
pRefValue
|
||||
);
|
||||
|
||||
mesh.solutionDict().subDict("blockSolver").readIfPresent
|
||||
(
|
||||
"convergence",
|
||||
convergenceCriterion
|
||||
);
|
||||
|
|
14
applications/solvers/coupled/pUCoupledFoam/readFieldBounds.H
Normal file
14
applications/solvers/coupled/pUCoupledFoam/readFieldBounds.H
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Read field bounds
|
||||
dictionary fieldBounds = mesh.solutionDict().subDict("fieldBounds");
|
||||
|
||||
// Pressure bounds
|
||||
dimensionedScalar pMin("pMin", p.dimensions(), 0);
|
||||
dimensionedScalar pMax("pMax", p.dimensions(), 0);
|
||||
|
||||
fieldBounds.lookup(p.name()) >> pMin.value() >> pMax.value();
|
||||
|
||||
// Velocity bound
|
||||
dimensionedScalar UMax("UMax", U.dimensions(), 0);
|
||||
|
||||
fieldBounds.lookup(U.name()) >> UMax.value();
|
||||
dimensionedScalar smallU("smallU", dimVelocity, 1e-10);
|
Reference in a new issue