Implicit treatment of coupled boundary conditions

This commit is contained in:
Sergio Ferraris
2021-08-03 20:08:49 +00:00
committed by Andrew Heather
parent 11e0db96d3
commit 53af23b9fb
308 changed files with 12354 additions and 527 deletions

View File

@ -21,6 +21,7 @@ EXE_INC = \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionFaModels\lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -54,6 +54,7 @@ Description
#include "loopControl.H"
#include "pressureControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
@ -80,6 +81,8 @@ int main(int argc, char *argv[])
#include "solidRegionDiffusionNo.H"
#include "setInitialMultiRegionDeltaT.H"
#include "createCoupledRegions.H"
while (runTime.run())
{
#include "readTimeControls.H"
@ -109,8 +112,6 @@ int main(int argc, char *argv[])
forAll(fluidRegions, i)
{
Info<< "\nSolving for fluid region "
<< fluidRegions[i].name() << endl;
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionPIMPLEControls.H"
#include "solveFluid.H"
@ -118,13 +119,35 @@ int main(int argc, char *argv[])
forAll(solidRegions, i)
{
Info<< "\nSolving for solid region "
<< solidRegions[i].name() << endl;
#include "setRegionSolidFields.H"
#include "readSolidMultiRegionPIMPLEControls.H"
#include "solveSolid.H"
}
if (coupled)
{
Info<< "\nSolving energy coupled regions " << endl;
fvMatrixAssemblyPtr->solve();
#include "correctThermos.H"
forAll(fluidRegions, i)
{
#include "setRegionFluidFields.H"
#include "readFluidMultiRegionPIMPLEControls.H"
Info<< "\nSolving for fluid region "
<< fluidRegions[i].name() << endl;
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
#include "pEqn.H"
}
turbulence.correct();
rho = thermo.rho();
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
}
}
// Additional loops for energy solution only
if (!oCorr && nOuterCorr > 1)
{
@ -152,10 +175,28 @@ int main(int argc, char *argv[])
#include "readSolidMultiRegionPIMPLEControls.H"
#include "solveSolid.H"
}
if (coupled)
{
Info<< "\nSolving energy coupled regions " << endl;
fvMatrixAssemblyPtr->solve();
#include "correctThermos.H"
forAll(fluidRegions, i)
{
#include "setRegionFluidFields.H"
rho = thermo.rho();
}
}
}
}
}
if (coupled)
{
fvMatrixAssemblyPtr->clear();
}
runTime.write();
runTime.printExecutionTime(Info);

View File

@ -3,6 +3,7 @@ EXE_INC = \
-I./fluid \
-I./solid \
-I../solid \
-I./../include \
-I$(LIB_SRC)/finiteVolume/cfdTools \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
@ -35,3 +36,4 @@ EXE_LIBS = \
-lregionModels \
-lsampling \
-lregionFaModels

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -66,6 +66,7 @@ int main(int argc, char *argv[])
#include "createTime.H"
#include "createMeshes.H"
#include "createFields.H"
#include "createCoupledRegions.H"
#include "initContinuityErrs.H"
while (runTime.loop())
@ -83,13 +84,27 @@ int main(int argc, char *argv[])
forAll(solidRegions, i)
{
Info<< "\nSolving for solid region "
<< solidRegions[i].name() << endl;
#include "setRegionSolidFields.H"
#include "readSolidMultiRegionSIMPLEControls.H"
#include "solveSolid.H"
}
if (coupled)
{
Info<< "\nSolving energy coupled regions" << endl;
fvMatrixAssemblyPtr->solve();
#include "correctThermos.H"
forAll(fluidRegions, i)
{
#include "setRegionFluidFields.H"
#include "readSolidMultiRegionSIMPLEControls.H"
#include "pEqn.H"
turb.correct();
}
}
// Additional loops for energy solution only
{
loopControl looping(runTime, "SIMPLE", "energyCoupling");
@ -116,9 +131,27 @@ int main(int argc, char *argv[])
#include "readSolidMultiRegionSIMPLEControls.H"
#include "solveSolid.H"
}
if (coupled)
{
Info<< "\nSolving energy coupled regions.. " << endl;
fvMatrixAssemblyPtr->solve();
#include "correctThermos.H"
forAll(fluidRegions, i)
{
#include "setRegionFluidFields.H"
turb.correct();
}
}
}
}
if (coupled)
{
fvMatrixAssemblyPtr->clear();
}
runTime.write();
runTime.printExecutionTime(Info);

View File

@ -20,13 +20,20 @@
fvOptions.constrain(EEqn);
EEqn.solve();
if (coupled)
{
fvMatrixAssemblyPtr->addFvMatrix(EEqn);
}
else
{
EEqn.solve();
fvOptions.correct(he);
fvOptions.correct(he);
thermo.correct();
rad.correct();
thermo.correct();
rad.correct();
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
}
}

View File

@ -2,7 +2,7 @@
MRF.correctBoundaryVelocity(U);
tmp<fvVectorMatrix> tUEqn
UEqn =
(
fvm::div(phi, U)
+ MRF.DDt(rho, U)
@ -10,7 +10,6 @@
==
fvOptions(rho, U)
);
fvVectorMatrix& UEqn = tUEqn.ref();
UEqn.relax();

View File

@ -21,6 +21,8 @@ PtrList<dimensionedScalar> rhoMin(fluidRegions.size());
PtrList<IOMRFZoneList> MRFfluid(fluidRegions.size());
PtrList<fv::options> fluidFvOptions(fluidRegions.size());
PtrList<fvVectorMatrix> UEqFluid(fluidRegions.size());
const uniformDimensionedVectorField& g = meshObjects::gravity::New(runTime);
// Populate fluid field pointer lists
@ -222,5 +224,11 @@ forAll(fluidRegions, i)
new fv::options(fluidRegions[i])
);
UEqFluid.set
(
i,
new fvVectorMatrix(UFluid[i], dimForce)
);
turbulence[i].validate();
}

View File

@ -2,7 +2,7 @@
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_rgh));
tUEqn.clear();
//tUEqn.clear();
surfaceScalarField phig(-rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf());

View File

@ -22,6 +22,8 @@
IOMRFZoneList& MRF = MRFfluid[i];
fv::options& fvOptions = fluidFvOptions[i];
fvVectorMatrix& UEqn = UEqFluid[i];
const dimensionedScalar initialMass
(
"initialMass",

View File

@ -12,8 +12,10 @@
#include "UEqn.H"
#include "EEqn.H"
#include "pEqn.H"
turb.correct();
if (!coupled)
{
#include "pEqn.H"
turb.correct();
}
}
}

View File

@ -16,13 +16,21 @@
fvOptions.constrain(hEqn);
hEqn.solve();
if (coupled)
{
fvMatrixAssemblyPtr->addFvMatrix(hEqn);
}
else
{
Info<< "\nSolving for solid region "
<< solidRegions[i].name() << endl;
fvOptions.correct(h);
hEqn.solve();
fvOptions.correct(h);
thermo.correct();
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
}
}
thermo.correct();
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
}

View File

@ -7,6 +7,7 @@ EXE_INC = \
-I${phaseSystem}/twoPhaseCompressibleTurbulenceModels/lnInclude \
-I${phaseSystem}/multiphaseSystem/lnInclude \
-I./fluid \
-I./solid \
-I../solid \
-I../fluid \
-I../include \

View File

@ -0,0 +1,39 @@
if (finalIter)
{
mesh.data::add("finalIteration", true);
}
{
for (int nonOrth=0; nonOrth<=nNonOrthCorr; ++nonOrth)
{
fvScalarMatrix hEqn
(
fvm::ddt(betav*rho, h)
- (
thermo.isotropic()
? fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)")
: fvm::laplacian(betav*taniAlpha(), h, "laplacian(alpha,h)")
)
==
fvOptions(rho, h)
);
hEqn.relax();
fvOptions.constrain(hEqn);
hEqn.solve(mesh.solver(h.select(finalIter)));
fvOptions.correct(h);
}
thermo.correct();
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
}
if (finalIter)
{
mesh.data::remove("finalIteration");
}

View File

@ -27,13 +27,19 @@
fvOptions.constrain(EEqn);
EEqn.solve(mesh.solver(he.select(finalIter)));
if (coupled)
{
fvMatrixAssemblyPtr->addFvMatrix(EEqn);
}
else
{
EEqn.solve(mesh.solver(he.select(finalIter)));
fvOptions.correct(he);
fvOptions.correct(he);
thermo.correct();
rad.correct();
thermo.correct();
rad.correct();
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
}
}

View File

@ -2,7 +2,7 @@
MRF.correctBoundaryVelocity(U);
tmp<fvVectorMatrix> tUEqn
UEqn =
(
fvm::ddt(rho, U) + fvm::div(phi, U)
+ MRF.DDt(rho, U)
@ -10,7 +10,6 @@
==
fvOptions(rho, U)
);
fvVectorMatrix& UEqn = tUEqn.ref();
UEqn.relax();

View File

@ -16,6 +16,8 @@ PtrList<multivariateSurfaceInterpolationScheme<scalar>::fieldTable>
fieldsFluid(fluidRegions.size());
PtrList<volScalarField> QdotFluid(fluidRegions.size());
PtrList<fvVectorMatrix> UEqFluid(fluidRegions.size());
List<scalar> initialMassFluid(fluidRegions.size());
List<bool> frozenFlowFluid(fluidRegions.size(), false);
@ -293,6 +295,12 @@ forAll(fluidRegions, i)
new fv::options(fluidRegions[i])
);
UEqFluid.set
(
i,
new fvVectorMatrix(UFluid[i], dimForce)
);
turbulenceFluid[i].validate();
pRefCellFluid[i] = -1;

View File

@ -49,6 +49,8 @@
IOMRFZoneList& MRF = MRFfluid[i];
fv::options& fvOptions = fluidFvOptions[i];
fvVectorMatrix& UEqn = UEqFluid[i];
const dimensionedScalar initialMass
(
"initialMass",

View File

@ -18,15 +18,20 @@ else
#include "YEqn.H"
#include "EEqn.H"
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
if (!coupled)
{
#include "pEqn.H"
Info<< "\nSolving for fluid region " << fluidRegions[i].name() << endl;
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
#include "pEqn.H"
}
turbulence.correct();
rho = thermo.rho();
}
turbulence.correct();
rho = thermo.rho();
}
if (finalIter)

View File

@ -0,0 +1,20 @@
forAll(fluidRegions, i)
{
rhoThermo& thermo = thermoFluid[i];
radiation::radiationModel& rad = radiation[i];
fv::options& fvOptions = fluidFvOptions[i];
volScalarField& he = thermo.he();
fvOptions.correct(he);
thermo.correct();
rad.correct();
}
forAll(solidRegions, i)
{
solidThermo& thermo = thermos[i];
fv::options& fvOptions = solidHeatSources[i];
volScalarField& h = thermo.he();
fvOptions.correct(h);
thermo.correct();
}

View File

@ -0,0 +1,51 @@
fvSolution solutionDict(runTime);
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false));
autoPtr<fvMatrix<scalar>> fvMatrixAssemblyPtr;
forAll(fluidRegions, i)
{
const rhoThermo& thermo = refCast<const rhoThermo>(thermoFluid[i]);
const auto& bpsi = thermo.T().boundaryField();
forAll (bpsi, patchI)
{
if (bpsi[patchI].useImplicit())
{
coupled = true;
}
}
}
forAll(solidRegions, i)
{
solidThermo& thermo = thermos[i];
const auto& bpsi = thermo.T().boundaryField();
forAll (bpsi, patchI)
{
if (bpsi[patchI].useImplicit())
{
coupled = true;
}
}
}
forAll(fluidRegions, i)
{
const rhoThermo& thermo = refCast<const rhoThermo>(thermoFluid[i]);
if (coupled)
{
Info << "Create fvMatrixAssembly." << endl;
fvMatrixAssemblyPtr.reset
(
new fvMatrix<scalar>
(
thermo.he(),
dimEnergy/dimTime
)
);
break;
}
}

View File

@ -1,39 +1,45 @@
if (finalIter)
{
mesh.data::add("finalIteration", true);
}
fvScalarMatrix hEqn
(
fvm::ddt(betav*rho, h)
- (
thermo.isotropic()
? fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)")
: fvm::laplacian(betav*taniAlpha(), h, "laplacian(alpha,h)")
)
==
fvOptions(rho, h)
);
{
for (int nonOrth=0; nonOrth<=nNonOrthCorr; ++nonOrth)
hEqn.relax();
fvOptions.constrain(hEqn);
if (coupled)
{
fvScalarMatrix hEqn
(
fvm::ddt(betav*rho, h)
- (
thermo.isotropic()
? fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)")
: fvm::laplacian(betav*taniAlpha(), h, "laplacian(alpha,h)")
)
==
fvOptions(rho, h)
);
fvMatrixAssemblyPtr->addFvMatrix(hEqn);
}
else
{
Info<< "\nSolving for solid region "<< solidRegions[i].name() << endl;
hEqn.relax();
fvOptions.constrain(hEqn);
if (finalIter)
{
mesh.data::add("finalIteration", true);
}
hEqn.solve(mesh.solver(h.select(finalIter)));
fvOptions.correct(h);
thermo.correct();
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
if (finalIter)
{
mesh.data::remove("finalIteration");
}
}
thermo.correct();
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
}
if (finalIter)
{
mesh.data::remove("finalIteration");
}

View File

@ -11,6 +11,7 @@ else
phiHbyA += MRF.zeroFilter(fvc::interpolate(rAU));
}
MRF.makeRelative(phiHbyA);
if (p.needReference())

View File

@ -1,5 +1,6 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
@ -9,6 +10,7 @@ EXE_INC = \
LIB_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lgeometricVoF \
-ltwoPhaseMixture \
-linterfaceProperties \

View File

@ -1,6 +1,7 @@
EXE_INC = \
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude
@ -8,4 +9,5 @@ LIB_LIBS = \
-ltwoPhaseMixture \
-ltwoPhaseProperties \
-lincompressibleTransportModels \
-lfiniteVolume
-lfiniteVolume \
-lmeshTools