Reformulate uwriteIbMasks utility as a calc

This commit is contained in:
Hrvoje Jasak 2017-12-06 21:19:44 +00:00
parent 0a05264824
commit b661362e53
2 changed files with 79 additions and 15 deletions

View file

@ -1,9 +1,11 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/postProcessing/postCalc \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/immersedBoundary/immersedBoundary/lnInclude -I$(LIB_SRC)/immersedBoundary/immersedBoundary/lnInclude
EXE_LIBS = \ EXE_LIBS = \
$(FOAM_LIBBIN)/postCalc.o \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools \ -lmeshTools \
-lsurfMesh \ -lsurfMesh \

View file

@ -29,32 +29,94 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvCFD.H" #include "calc.H"
#include "fvc.H"
#include "fvMatrices.H"
#include "immersedBoundaryFvPatch.H" #include "immersedBoundaryFvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[]) void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
{ {
# include "setRootCase.H" Info<< nl << "Calculating gamma" << endl;
# include "createTime.H" volScalarField gamma
# include "createMesh.H" (
# include "createIbMasks.H" IOobject
(
"gamma",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("one", dimless, 0)
);
gamma.internalField() = mesh.V()/mesh.cellVolumes();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< nl << "Calculating sGamma" << endl;
surfaceScalarField sGamma
(
IOobject
(
"sGamma",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("one", dimless, 0)
);
Info<< "Time = " << runTime.timeName() << nl << endl; const surfaceScalarField& magSf = mesh.magSf();
const scalarField magFaceAreas = mag(mesh.faceAreas());
cellIbMask.write(); sGamma.internalField() =
cellIbMaskExt.write(); magSf.internalField()/
scalarField::subField(magFaceAreas, mesh.nInternalFaces());
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" forAll (mesh.boundary(), patchI)
<< " ClockTime = " << runTime.elapsedClockTime() << " s" {
<< nl << endl; if (!isA<immersedBoundaryFvPatch>(mesh.boundary()[patchI]))
{
sGamma.boundaryField()[patchI] =
magSf.boundaryField()[patchI]/
mesh.boundary()[patchI].patchSlice(magFaceAreas);
Info<< "End\n" << endl; gamma.boundaryField()[patchI] =
sGamma.boundaryField()[patchI];
}
}
return 0; gamma.write();
sGamma.write();
// Check consistency of face area vectors
Info<< nl << "Calculating divSf" << endl;
volVectorField divSf
(
"divSf",
fvc::div(mesh.Sf())
);
divSf.write();
// Check divergence of face area vectors
scalarField magDivSf = mag(divSf)().internalField();
Info<< "Face areas divergence (min, max, average): "
<< "(" << min(magDivSf) << " " << max(magDivSf)
<< " " << average(magDivSf) << ")"
<< endl;
if (max(magDivSf) > 1e-9)
{
WarningIn("writeIbMasks")
<< "Possible problem with immersed boundary face area vectors: "
<< max(magDivSf)
<< endl;
}
} }