From ec3f650fdb505ebe20f849b3bb1c443c0973a111 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Sat, 30 Dec 2017 09:29:43 +0000 Subject: [PATCH] Improvements and fvPatch virtual functions for immersed boundary support --- src/finiteVolume/fvMesh/fvMesh.C | 25 ++++++++- src/finiteVolume/fvMesh/fvMesh.H | 2 +- src/finiteVolume/fvMesh/fvMeshGeometry.C | 39 ++++++++++--- .../fvMesh/fvPatches/fvPatch/fvPatch.C | 55 ++++++++++--------- .../fvMesh/fvPatches/fvPatch/fvPatch.H | 11 ++++ 5 files changed, 93 insertions(+), 39 deletions(-) diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index 268e56da4..ee4598ef5 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -48,6 +48,13 @@ defineTypeNameAndDebug(Foam::fvMesh, 0); void Foam::fvMesh::clearGeomNotOldVol() { + if (debug) + { + InfoIn("void Foam::fvMesh::clearGeomNotOldVol()") + << "Clearing geometry but not old volumes" + << endl; + } + deleteDemandDrivenData(VPtr_); deleteDemandDrivenData(SfPtr_); @@ -59,6 +66,13 @@ void Foam::fvMesh::clearGeomNotOldVol() void Foam::fvMesh::clearGeom() { + if (debug) + { + InfoIn("void Foam::fvMesh::clearGeomNotOldVol()") + << "Clearing geometry" + << endl; + } + clearGeomNotOldVol(); deleteDemandDrivenData(V0Ptr_); @@ -75,6 +89,13 @@ void Foam::fvMesh::clearGeom() void Foam::fvMesh::clearAddressing() { + if (debug) + { + InfoIn("void Foam::fvMesh::clearAddressing()") + << "Clearing addressing" + << endl; + } + deleteDemandDrivenData(lduPtr_); // Geometry dependent object updated through call-back @@ -569,11 +590,9 @@ void Foam::fvMesh::updateMesh(const mapPolyMesh& mpm) void Foam::fvMesh::syncUpdateMesh() { - // Update polyMesh. This needs to keep volume existent! + // Update polyMesh. This needs to keep cell volumes polyMesh::syncUpdateMesh(); - // Not sure how much clean-up is needed here. HJ, 27/Nov/2009 - surfaceInterpolation::clearOut(); clearGeomNotOldVol(); diff --git a/src/finiteVolume/fvMesh/fvMesh.H b/src/finiteVolume/fvMesh/fvMesh.H index 1ea79365c..5edf00dda 100644 --- a/src/finiteVolume/fvMesh/fvMesh.H +++ b/src/finiteVolume/fvMesh/fvMesh.H @@ -353,7 +353,7 @@ public: //- Return cell face motion fluxes surfaceScalarField& setPhi(); - //- Return old-time cell volumes + //- Set old-time cell volumes DimensionedField& setV0(); diff --git a/src/finiteVolume/fvMesh/fvMeshGeometry.C b/src/finiteVolume/fvMesh/fvMeshGeometry.C index eb8c03d4e..e5286a3fb 100644 --- a/src/finiteVolume/fvMesh/fvMeshGeometry.C +++ b/src/finiteVolume/fvMesh/fvMeshGeometry.C @@ -249,9 +249,8 @@ void fvMesh::makePhi() const { if (debug) { - Info<< "void fvMesh::makePhi() const : " - << "reading old time flux field if present and creating " - << "zero current time flux field" + InfoIn("void fvMesh::makePhi() const") + << "Preparing mesh flux field" << endl; } @@ -267,12 +266,12 @@ void fvMesh::makePhi() const // Reading old time mesh motion flux if it exists and // creating zero current time mesh motion flux - scalar t0 = this->time().value() - this->time().deltaT().value(); + scalar t0 = time().value() - time().deltaT().value(); IOobject meshPhiHeader ( "meshPhi", - this->time().timeName(t0), + time().timeName(t0), *this, IOobject::NO_READ ); @@ -290,7 +289,7 @@ void fvMesh::makePhi() const IOobject ( "meshPhi", - this->time().timeName(t0), + time().timeName(t0), *this, IOobject::MUST_READ, IOobject::AUTO_WRITE @@ -317,7 +316,7 @@ void fvMesh::makePhi() const IOobject ( "meshPhi", - this->time().timeName(), + time().timeName(), *this, IOobject::NO_READ, IOobject::AUTO_WRITE @@ -338,20 +337,39 @@ void fvMesh::updatePhi(const scalarField& sweptVols) const makePhi(); } - surfaceScalarField& phi = *phiPtr_; - scalar rDeltaT = 1.0/time().deltaT().value(); + surfaceScalarField& phi = *phiPtr_; + phi.internalField() = scalarField::subField(sweptVols, nInternalFaces()); phi.internalField() *= rDeltaT; const fvPatchList& patches = boundary(); + // Calculate regular values first and then allow patches to update them + // HJ, 15/Dec/2017 forAll (patches, patchI) { phi.boundaryField()[patchI] = patches[patchI].patchSlice(sweptVols); phi.boundaryField()[patchI] *= rDeltaT; } + + // Make sure V and V0 are constructed before the correction + // HJ, 22/Dec/2017 + V0(); + V(); + + // Boundary update. Used in complex geometries, eg. immersed boundary + // HJ, 29/Nov/2017 + forAll (phi.boundaryField(), patchI) + { + boundary()[patchI].updatePhi + ( + *VPtr_, + *V0Ptr_, + phi + ); + } } @@ -425,6 +443,9 @@ DimensionedField& fvMesh::setV0() << "Setting old cell volumes" << endl; } + // Update time index + curTimeIndex_ = time().timeIndex(); + V0Ptr_ = new DimensionedField ( IOobject diff --git a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.C b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.C index 2ec012d4a..4fd439f4e 100644 --- a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.C @@ -43,6 +43,35 @@ defineRunTimeSelectionTable(fvPatch, polyPatch); addToRunTimeSelectionTable(fvPatch, fvPatch, polyPatch); +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +void fvPatch::makeWeights(fvsPatchScalarField& w) const +{ + w = 1.0; +} + + +void fvPatch::makeDeltaCoeffs(fvsPatchScalarField& dc) const +{ + dc = 1.0/(nf() & delta()); +} + + +void fvPatch::makeCorrVecs(fvsPatchVectorField& cv) const +{ + cv = vector::zero; +} + + +void fvPatch::initMovePoints() +{} + + +void fvPatch::movePoints() +{} + + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // fvPatch::fvPatch(const polyPatch& p, const fvBoundaryMesh& bm) @@ -152,32 +181,6 @@ tmp fvPatch::delta() const } -void fvPatch::makeWeights(fvsPatchScalarField& w) const -{ - w = 1.0; -} - - -void fvPatch::makeDeltaCoeffs(fvsPatchScalarField& dc) const -{ - dc = 1.0/(nf() & delta()); -} - - -void fvPatch::makeCorrVecs(fvsPatchVectorField& cv) const -{ - cv = vector::zero; -} - - -void fvPatch::initMovePoints() -{} - - -void fvPatch::movePoints() -{} - - const scalarField& fvPatch::deltaCoeffs() const { return boundaryMesh().mesh().deltaCoeffs().boundaryField()[index()]; diff --git a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H index c1530b72e..007131324 100644 --- a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H @@ -43,8 +43,10 @@ SourceFiles #include "tmp.H" #include "primitiveFields.H" #include "SubField.H" +#include "DimensionedField.H" #include "fvPatchFieldsFwd.H" #include "fvsPatchFieldsFwd.H" +#include "surfaceFieldsFwd.H" #include "slicedVolFieldsFwd.H" #include "slicedSurfaceFieldsFwd.H" #include "autoPtr.H" @@ -105,6 +107,15 @@ protected: virtual void makeV(scalarField&) const {} + //- Update mesh motion fluxes + virtual void updatePhi + ( + DimensionedField& V, + DimensionedField& V0, + surfaceScalarField& phi + ) const + {} + // Discretisation correction functions