XiFoam: Added mesh-motion to replace XiEngineFoam

With the addition of mesh-motion to XiFoam and the new engine fvMeshMover the
XiEngineFoam kivaTest simple IC engine example now runs in XiFoam and
XiEngineFoam has been removed.  This simplifies maintenance provides greater
extensibility.
This commit is contained in:
Henry Weller
2021-11-05 22:32:42 +00:00
parent 941ea19930
commit 8f14b69fba
34 changed files with 99 additions and 362 deletions

View File

@ -1,3 +0,0 @@
XiEngineFoam.C
EXE = $(FOAM_APPBIN)/XiEngineFoam

View File

@ -1,29 +0,0 @@
EXE_INC = \
-I.. \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/engine/lnInclude \
-I$(LIB_SRC)/physicalProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/MomentumTransportModels/momentumTransportModels/lnInclude \
-I$(LIB_SRC)/MomentumTransportModels/compressible/lnInclude \
-I$(LIB_SRC)/ThermophysicalTransportModels/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/laminarFlameSpeed/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvModels \
-lfvConstraints \
-lsampling \
-lmeshTools \
-lengine \
-lmomentumTransportModels \
-lcompressibleMomentumTransportModels \
-lthermophysicalTransportModels \
-lfluidThermophysicalModels \
-lreactionThermophysicalModels \
-lspecie \
-llaminarFlameSpeedModels

View File

@ -1,16 +0,0 @@
fvVectorMatrix UEqn
(
fvm::ddt(rho, U)
+ fvm::div(phi, U)
+ turbulence->divDevTau(U)
==
fvModels.source(rho, U)
);
if (pimple.momentumPredictor())
{
solve(UEqn == -fvc::grad(p));
fvConstraints.constrain(U);
K = 0.5*magSqr(U);
}

View File

@ -1,151 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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.
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
XiEngineFoam
Description
Solver for internal combustion engines.
Combusting RANS code using the b-Xi two-equation model.
Xi may be obtained by either the solution of the Xi transport
equation or from an algebraic expression. Both approaches are
based on Gulder's flame speed correlation which has been shown
to be appropriate by comparison with the results from the
spectral model.
Strain effects are encorporated directly into the Xi equation
but not in the algebraic approximation. Further work need to be
done on this issue, particularly regarding the enhanced removal rate
caused by flame compression. Analysis using results of the spectral
model will be required.
For cases involving very lean Propane flames or other flames which are
very strain-sensitive, a transport equation for the laminar flame
speed is present. This equation is derived using heuristic arguments
involving the strain time scale and the strain-rate at extinction.
the transport velocity is the same as that for the Xi equation.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "engineMesh.H"
#include "psiuReactionThermo.H"
#include "compressibleMomentumTransportModels.H"
#include "fluidThermophysicalTransportModel.H"
#include "laminarFlameSpeed.H"
#include "ignition.H"
#include "Switch.H"
#include "OFstream.H"
#include "mathematicalConstants.H"
#include "pimpleControl.H"
#include "fvModels.H"
#include "fvConstraints.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#define CREATE_MESH createEngineMesh.H
#include "postProcess.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createEngineMesh.H"
#include "createControl.H"
#include "readCombustionProperties.H"
#include "createFields.H"
#include "createFieldRefs.H"
#include "createRhoUfIfPresent.H"
#include "initContinuityErrs.H"
#include "createEngineTimeControls.H"
#include "compressibleCourantNo.H"
#include "setInitialDeltaT.H"
#include "startSummary.H"
turbulence->validate();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (pimple.run(runTime))
{
#include "readEngineTimeControls.H"
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
Info<< "Crank angle = " << runTime.timeName() << endl;
mesh.move();
#include "rhoEqn.H"
// --- Pressure-velocity PIMPLE corrector loop
while (pimple.loop())
{
#include "UEqn.H"
#include "ftEqn.H"
#include "bEqn.H"
#include "EauEqn.H"
#include "EaEqn.H"
if (!ign.ignited())
{
thermo.heu() == thermo.he();
}
// --- Pressure corrector loop
while (pimple.correct())
{
#include "pEqn.H"
}
if (pimple.turbCorr())
{
turbulence->correct();
thermophysicalTransport->correct();
}
}
#include "logSummary.H"
rho = thermo.rho();
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -1,22 +0,0 @@
{
const scalar meanp = p.weightedAverage(mesh.V()).value();
const scalar meanT = thermo.T().weightedAverage(mesh.V()).value();
const scalar meanup =
(sqrt((2.0/3.0)*turbulence->k()))().weightedAverage(mesh.V()).value();
const scalar meanc = 1 - b.weightedAverage(mesh.V()).value();
if (Pstream::master())
{
Info<< "Mean pressure:" << meanp << endl;
Info<< "Mean temperature:" << meanT << endl;
Info<< "Mean u':" << meanup << endl;
logSummaryFile()
<< runTime.userTimeValue() << tab
<< meanp << tab
<< meanT << tab
<< meanup << tab
<< meanc
<< endl;
}
}

View File

@ -1,96 +0,0 @@
rho = thermo.rho();
volScalarField rAU(1.0/UEqn.A());
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
if (pimple.transonic())
{
surfaceScalarField phid
(
"phid",
fvc::interpolate(psi)
*(
(
fvc::flux(HbyA)
+ MRF.zeroFilter
(
rhorAUf*fvc::ddtCorr(rho, U, phi, rhoUf)
/fvc::interpolate(rho)
)
)
)
);
fvc::makeRelative(phid, psi, U);
MRF.makeRelative(fvc::interpolate(psi), phid);
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix pEqn
(
fvm::ddt(psi, p)
+ fvm::div(phid, p)
- fvm::laplacian(rhorAUf, p)
==
fvModels.source(psi, p, rho.name())
);
pEqn.solve();
if (pimple.finalNonOrthogonalIter())
{
phi == pEqn.flux();
}
}
}
else
{
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::interpolate(rho)*fvc::flux(HbyA)
+ MRF.zeroFilter(rhorAUf*fvc::ddtCorr(rho, U, phi, rhoUf))
);
fvc::makeRelative(phiHbyA, rho, U);
MRF.makeRelative(fvc::interpolate(rho), phiHbyA);
// Update the pressure BCs to ensure flux consistency
constrainPressure(p, rho, U, phiHbyA, rhorAUf, MRF);
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix pEqn
(
fvm::ddt(psi, p)
+ fvc::div(phiHbyA)
- fvm::laplacian(rhorAUf, p)
==
fvModels.source(psi, p, rho.name())
);
pEqn.solve();
if (pimple.finalNonOrthogonalIter())
{
phi = phiHbyA + pEqn.flux();
}
}
}
#include "rhoEqn.H"
#include "compressibleContinuityErrs.H"
U = HbyA - rAU*fvc::grad(p);
U.correctBoundaryConditions();
fvConstraints.constrain(U);
K = 0.5*magSqr(U);
// Correct rhoUf if the mesh is moving
fvc::correctRhoUf(rhoUf, rho, U, phi);
if (thermo.dpdt())
{
dpdt = fvc::ddt(p) - fvc::div(fvc::meshPhi(rho, U), p);
}

View File

@ -1,16 +0,0 @@
Info<< "Total cylinder mass: " << fvc::domainIntegrate(rho).value() << endl;
autoPtr<OFstream> logSummaryFile;
if (Pstream::master())
{
logSummaryFile = new OFstream
(
runTime.rootPath()/runTime.globalCaseName()
/("logSummary." + runTime.timeName() + ".dat")
);
logSummaryFile()
<< "# CA" << " p" << " T" << " u'" << " c"
<< endl;
}

View File

@ -57,6 +57,7 @@ Description
#include "ignition.H"
#include "Switch.H"
#include "pimpleControl.H"
#include "CorrectPhi.H"
#include "fvModels.H"
#include "fvConstraints.H"
@ -69,28 +70,44 @@ int main(int argc, char *argv[])
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createMesh.H"
#include "createControl.H"
#include "createDyMControls.H"
#include "initContinuityErrs.H"
#include "readCombustionProperties.H"
#include "createFields.H"
#include "createFieldRefs.H"
#include "initContinuityErrs.H"
#include "createTimeControls.H"
#include "compressibleCourantNo.H"
#include "setInitialDeltaT.H"
#include "createRhoUfIfPresent.H"
turbulence->validate();
#include "compressibleCourantNo.H"
#include "setInitialDeltaT.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (pimple.run(runTime))
{
#include "readTimeControls.H"
#include "readDyMControls.H"
// Store divrhoU from the previous mesh so that it can be mapped
// and used in correctPhi to ensure the corrected phi has the
// same divergence
autoPtr<volScalarField> divrhoU;
if (correctPhi)
{
divrhoU = new volScalarField
(
"divrhoU",
fvc::div(fvc::absolute(phi, rho, U))
);
}
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
Info<< "Time = " << runTime.userTimeName() << nl << endl;
#include "rhoEqn.H"
@ -98,10 +115,48 @@ int main(int argc, char *argv[])
// --- Pressure-velocity PIMPLE corrector loop
while (pimple.loop())
{
if (pimple.firstPimpleIter() || moveMeshOuterCorrectors)
{
// Store momentum to set rhoUf for introduced faces.
autoPtr<volVectorField> rhoU;
if (rhoUf.valid())
{
rhoU = new volVectorField("rhoU", rho*U);
}
fvModels.preUpdateMesh();
// Do any mesh changes
mesh.update();
if (mesh.changing())
{
MRF.update();
if (correctPhi)
{
#include "correctPhi.H"
}
if (checkMeshCourantNo)
{
#include "meshCourantNo.H"
}
}
}
if
(
!pimple.simpleRho()
&& pimple.firstPimpleIter()
)
{
#include "rhoEqn.H"
}
fvModels.correct();
#include "UEqn.H"
#include "ftEqn.H"
#include "bEqn.H"
#include "EauEqn.H"

View File

@ -0,0 +1 @@
#include "../../compressible/rhoPimpleFoam/correctPhi.H"

View File

@ -11,11 +11,18 @@ if (pimple.transonic())
"phid",
fvc::interpolate(psi)
*(
(
fvc::flux(HbyA)
+ rhorAUf*fvc::ddtCorr(rho, U, phi)/fvc::interpolate(rho)
+ MRF.zeroFilter
(
rhorAUf*fvc::ddtCorr(rho, U, phi, rhoUf)
/fvc::interpolate(rho)
)
)
)
);
fvc::makeRelative(phid, psi, U);
MRF.makeRelative(fvc::interpolate(psi), phid);
while (pimple.correctNonOrthogonal())
@ -42,13 +49,12 @@ else
surfaceScalarField phiHbyA
(
"phiHbyA",
(
fvc::flux(rho*HbyA)
+ rhorAUf*fvc::ddtCorr(rho, U, phi)
)
fvc::interpolate(rho)*fvc::flux(HbyA)
+ MRF.zeroFilter(rhorAUf*fvc::ddtCorr(rho, U, phi, rhoUf))
);
MRF.makeRelative(phiHbyA);
fvc::makeRelative(phiHbyA, rho, U);
MRF.makeRelative(fvc::interpolate(rho), phiHbyA);
// Update the pressure BCs to ensure flux consistency
constrainPressure(p, rho, U, phiHbyA, rhorAUf, MRF);
@ -81,7 +87,15 @@ U.correctBoundaryConditions();
fvConstraints.constrain(U);
K = 0.5*magSqr(U);
// Correct rhoUf if the mesh is moving
fvc::correctRhoUf(rhoUf, rho, U, phi);
if (thermo.dpdt())
{
dpdt = fvc::ddt(p);
if (mesh.moving())
{
dpdt -= fvc::div(fvc::meshPhi(rho, U), p);
}
}

View File

@ -38,10 +38,6 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifndef CREATE_TIME
#define CREATE_TIME createTime.H
#endif
#ifndef CREATE_MESH
#define CREATE_MESH createMesh.H
#endif
@ -84,7 +80,7 @@ if (argList::postProcess(argc, argv))
return 0;
}
#include INCLUDE_FILE(CREATE_TIME)
#include "createTime.H"
Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
#include INCLUDE_FILE(CREATE_MESH)

View File

@ -10,19 +10,22 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object engineGeometry;
object dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
engineMesh layered;
mover
{
type layeredEngine;
conRodLength conRodLength [0 1 0 0 0 0 0] 0.147;
libs ("libfvMeshMovers.so");
bore bore [0 1 0 0 0 0 0] 0.092;
stroke stroke [0 1 0 0 0 0 0] 0.08423;
clearance clearance [0 1 0 0 0 0 0] 0.00115;
conRodLength 0.147;
bore 0.092;
stroke 0.08423;
clearance 0.00115;
pistonLayers 0;
}
// ************************************************************************* //

View File

@ -10,11 +10,11 @@ FoamFile
format ascii;
class dictionary;
location "system";
object controlDict.1st;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application XiEngineFoam;
application XiFoam;
startFrom startTime;

View File

@ -66,6 +66,7 @@ PIMPLE
nCorrectors 2;
nNonOrthogonalCorrectors 1;
momentumPredictor yes;
correctPhi no;
}