FEATURE: New solver for potential flow on dynamic meshes. Author: Hrvoje Jasak. Merge: Dominik Christ.
This commit is contained in:
commit
8910693203
6 changed files with 271 additions and 3 deletions
3
applications/solvers/basic/potentialDyMFoam/Make/files
Normal file
3
applications/solvers/basic/potentialDyMFoam/Make/files
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
potentialDyMFoam.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/potentialDyMFoam
|
14
applications/solvers/basic/potentialDyMFoam/Make/options
Normal file
14
applications/solvers/basic/potentialDyMFoam/Make/options
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/dynamicMesh/dynamicFvMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
-ldynamicFvMesh \
|
||||||
|
-ldynamicMesh \
|
||||||
|
-lengine \
|
||||||
|
-lmeshTools \
|
||||||
|
-lfiniteVolume \
|
||||||
|
-llduSolvers \
|
||||||
|
-L$(MESQUITE_LIB_DIR) -lmesquite
|
57
applications/solvers/basic/potentialDyMFoam/correctPhi.H
Normal file
57
applications/solvers/basic/potentialDyMFoam/correctPhi.H
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
{
|
||||||
|
wordList pcorrTypes(p.boundaryField().types());
|
||||||
|
|
||||||
|
for (label i=0; i<p.boundaryField().size(); i++)
|
||||||
|
{
|
||||||
|
if (p.boundaryField()[i].fixesValue())
|
||||||
|
{
|
||||||
|
pcorrTypes[i] = fixedValueFvPatchScalarField::typeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
volScalarField pcorr
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"pcorr",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
dimensionedScalar("pcorr", p.dimensions(), 0.0),
|
||||||
|
pcorrTypes
|
||||||
|
);
|
||||||
|
|
||||||
|
// Initialise flux with interpolated velocity
|
||||||
|
phi = fvc::interpolate(U) & mesh.Sf();
|
||||||
|
|
||||||
|
if (pcorr.needReference())
|
||||||
|
{
|
||||||
|
fvc::makeRelative(phi, U);
|
||||||
|
adjustPhi(phi, U, pcorr);
|
||||||
|
fvc::makeAbsolute(phi, U);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++)
|
||||||
|
{
|
||||||
|
fvScalarMatrix pcorrEqn
|
||||||
|
(
|
||||||
|
fvm::laplacian(rAU, pcorr) == fvc::div(phi)
|
||||||
|
);
|
||||||
|
|
||||||
|
pcorrEqn.setReference(pRefCell, pRefValue);
|
||||||
|
pcorrEqn.solve();
|
||||||
|
|
||||||
|
if (nonOrth == nNonOrthCorr)
|
||||||
|
{
|
||||||
|
phi -= pcorrEqn.flux();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fluxes are corrected to absolute velocity and further corrected
|
||||||
|
// later. HJ, 6/Feb/2009
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "continuityErrs.H"
|
50
applications/solvers/basic/potentialDyMFoam/createFields.H
Normal file
50
applications/solvers/basic/potentialDyMFoam/createFields.H
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
Info<< "Reading field p\n" << endl;
|
||||||
|
volScalarField p
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"p",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "Reading field U\n" << endl;
|
||||||
|
volVectorField U
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"U",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
if (args.optionFound("resetU"))
|
||||||
|
{
|
||||||
|
U.internalField() = vector::zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
surfaceScalarField phi
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"phi",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
fvc::interpolate(U) & mesh.Sf()
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
label pRefCell = 0;
|
||||||
|
scalar pRefValue = 0.0;
|
||||||
|
setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue);
|
145
applications/solvers/basic/potentialDyMFoam/potentialDyMFoam.C
Normal file
145
applications/solvers/basic/potentialDyMFoam/potentialDyMFoam.C
Normal file
|
@ -0,0 +1,145 @@
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
potentialDyMFoam
|
||||||
|
|
||||||
|
Description
|
||||||
|
Transient solver for potential flow with dynamic mesh.
|
||||||
|
|
||||||
|
Author
|
||||||
|
Hrvoje Jasak, Wikki Ltd. All rights reserved.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "fvCFD.H"
|
||||||
|
#include "dynamicFvMesh.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::validOptions.insert("resetU", "");
|
||||||
|
argList::validOptions.insert("writep", "");
|
||||||
|
|
||||||
|
# include "setRootCase.H"
|
||||||
|
# include "createTime.H"
|
||||||
|
# include "createDynamicFvMesh.H"
|
||||||
|
# include "createFields.H"
|
||||||
|
# include "initTotalVolume.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Info<< "\nStarting time loop\n" << endl;
|
||||||
|
|
||||||
|
while (runTime.loop())
|
||||||
|
{
|
||||||
|
# include "readPISOControls.H"
|
||||||
|
# include "checkTotalVolume.H"
|
||||||
|
|
||||||
|
runTime++;
|
||||||
|
|
||||||
|
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||||
|
|
||||||
|
bool meshChanged = mesh.update();
|
||||||
|
reduce(meshChanged, orOp<bool>());
|
||||||
|
|
||||||
|
p.internalField() = 0;
|
||||||
|
|
||||||
|
if (args.optionFound("resetU"))
|
||||||
|
{
|
||||||
|
U.internalField() = vector::zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
# include "volContinuity.H"
|
||||||
|
|
||||||
|
// Solve potential flow equations
|
||||||
|
adjustPhi(phi, U, p);
|
||||||
|
|
||||||
|
for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++)
|
||||||
|
{
|
||||||
|
p.storePrevIter();
|
||||||
|
|
||||||
|
fvScalarMatrix pEqn
|
||||||
|
(
|
||||||
|
fvm::laplacian
|
||||||
|
(
|
||||||
|
dimensionedScalar
|
||||||
|
(
|
||||||
|
"1",
|
||||||
|
dimTime/p.dimensions()*dimensionSet(0, 2, -2, 0, 0),
|
||||||
|
1
|
||||||
|
),
|
||||||
|
p
|
||||||
|
)
|
||||||
|
==
|
||||||
|
fvc::div(phi)
|
||||||
|
);
|
||||||
|
|
||||||
|
pEqn.setReference(pRefCell, pRefValue);
|
||||||
|
pEqn.solve();
|
||||||
|
|
||||||
|
if (nonOrth == nNonOrthCorr)
|
||||||
|
{
|
||||||
|
phi -= pEqn.flux();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p.relax();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "continuity error = "
|
||||||
|
<< mag(fvc::div(phi))().weightedAverage(mesh.V()).value()
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
U = fvc::reconstruct(phi);
|
||||||
|
U.correctBoundaryConditions();
|
||||||
|
|
||||||
|
Info<< "Interpolated U error = "
|
||||||
|
<< (sqrt(sum(sqr((fvc::interpolate(U) & mesh.Sf()) - phi)))
|
||||||
|
/sum(mesh.magSf())).value()
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
// Calculate velocity magnitude
|
||||||
|
{
|
||||||
|
volScalarField magU = mag(U);
|
||||||
|
|
||||||
|
Info<< "mag(U): max: " << gMax(magU.internalField())
|
||||||
|
<< " min: " << gMin(magU.internalField()) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
runTime.write();
|
||||||
|
|
||||||
|
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||||
|
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||||
|
<< nl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
|
@ -32,7 +32,6 @@ Description
|
||||||
|
|
||||||
#include "fvCFD.H"
|
#include "fvCFD.H"
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -53,7 +52,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
adjustPhi(phi, U, p);
|
adjustPhi(phi, U, p);
|
||||||
|
|
||||||
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++)
|
||||||
{
|
{
|
||||||
p.storePrevIter();
|
p.storePrevIter();
|
||||||
|
|
||||||
|
@ -102,7 +101,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
volScalarField magU = mag(U);
|
volScalarField magU = mag(U);
|
||||||
|
|
||||||
Info << "mag(U): max: " << gMax(magU.internalField())
|
Info<< "mag(U): max: " << gMax(magU.internalField())
|
||||||
<< " min: " << gMin(magU.internalField()) << endl;
|
<< " min: " << gMin(magU.internalField()) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue