From 823641ab9b36a41890b0c921e010f03a16c780c0 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Wed, 16 Mar 2022 20:03:53 +0000 Subject: [PATCH] ENH: refactored mesh movePoints to enable meshPhi update in the fvGeometryScheme --- src/OpenFOAM/meshes/polyMesh/polyMesh.C | 23 +++--- src/OpenFOAM/meshes/polyMesh/polyMesh.H | 4 +- .../meshes/primitiveMesh/primitiveMesh.C | 40 +++------- .../meshes/primitiveMesh/primitiveMesh.H | 6 +- .../primitiveMeshCellCentresAndVols.C | 5 +- .../primitiveMeshFaceCentresAndAreas.C | 1 + .../basic/basicFvGeometryScheme.C | 65 +++++++-------- .../fvGeometryScheme/fvGeometryScheme.C | 80 +++++++++++++++++-- .../fvGeometryScheme/fvGeometryScheme.H | 13 ++- .../highAspectRatioFvGeometryScheme.C | 3 + .../stabilised/stabilisedFvGeometryScheme.C | 2 + src/finiteVolume/fvMesh/fvMesh.C | 54 ++++++------- src/finiteVolume/fvMesh/fvMesh.H | 2 +- 13 files changed, 176 insertions(+), 122 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index f9e96254f1..466c82fde1 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -1156,10 +1156,7 @@ const Foam::pointField& Foam::polyMesh::oldCellCentres() const } -Foam::tmp Foam::polyMesh::movePoints -( - const pointField& newPoints -) +void Foam::polyMesh::movePoints(const pointField& newPoints) { DebugInFunction << "Moving points for time " << time().value() @@ -1227,11 +1224,17 @@ Foam::tmp Foam::polyMesh::movePoints tetBasePtIsPtr_->eventNo() = getEvent(); } - tmp sweptVols = primitiveMesh::movePoints - ( - points_, - oldPoints() - ); + // Currently a no-op; earlier versions set meshPhi and call + // primitiveMesh::clearGeom + (void)primitiveMesh::movePoints(points_, oldPoints()); + + // Update the mesh geometry (via fvGeometryScheme) + // - updateGeom is virtual -> calls fvMesh::updateGeom (or higher) + // - fvMesh::updateGeom defers to surfaceInterpolation::updateGeom(), + // which defers to fvGeometryScheme::movePoints() + // - set the mesh flux + // - clear out/recalculate stale geometry + updateGeom(); // Adjust parallel shared points if (globalMeshDataPtr_) @@ -1279,8 +1282,6 @@ Foam::tmp Foam::polyMesh::movePoints // e.g. fvMesh::write since meshPhi not yet complete. polyMesh::write(); } - - return sweptVols; } diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H index ac41ac9625..b5512d75fb 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H @@ -556,8 +556,8 @@ public: return (moving() || topoChanging()); } - //- Move points, returns volumes swept by faces in motion - virtual tmp movePoints(const pointField&); + //- Move points + virtual void movePoints(const pointField&); //- Reset motion void resetMotion() const; diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C index 997a8113bd..a680acbc8a 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -136,7 +137,7 @@ bool Foam::primitiveMesh::calcPointOrder // Internal points are points that are not used by a boundary face. // Map from old to new position - oldToNew.setSize(nPoints); + oldToNew.resize_nocopy(nPoints); oldToNew = -1; @@ -144,14 +145,12 @@ bool Foam::primitiveMesh::calcPointOrder // from 0 inside oldToNew. (shifted up later on) label nBoundaryPoints = 0; - for (label facei = nInternalFaces; facei < faces.size(); facei++) + for (label facei = nInternalFaces; facei < faces.size(); ++facei) { const face& f = faces[facei]; - forAll(f, fp) + for (label pointi : f) { - label pointi = f[fp]; - if (oldToNew[pointi] == -1) { oldToNew[pointi] = nBoundaryPoints++; @@ -184,10 +183,8 @@ bool Foam::primitiveMesh::calcPointOrder { const face& f = faces[facei]; - forAll(f, fp) + for (label pointi : f) { - label pointi = f[fp]; - if (oldToNew[pointi] == -1) { if (pointi >= nInternalPoints) @@ -318,35 +315,17 @@ void Foam::primitiveMesh::resetGeometry } -Foam::tmp Foam::primitiveMesh::movePoints +void Foam::primitiveMesh::movePoints ( const pointField& newPoints, const pointField& oldPoints ) { - if (newPoints.size() < nPoints() || oldPoints.size() < nPoints()) - { - FatalErrorInFunction - << "Cannot move points: size of given point list smaller " - << "than the number of active points" - << abort(FatalError); - } - - // Create swept volumes - const faceList& fcs = faces(); - - auto tsweptVols = tmp::New(fcs.size()); - auto& sweptVols = tsweptVols.ref(); - - forAll(fcs, facei) - { - sweptVols[facei] = fcs[facei].sweptVol(oldPoints, newPoints); - } + // Note: the following clearout is now handled by the fvGeometryScheme + // triggered by the call to updateGeom() in polyMesh::movePoints // Force recalculation of all geometric data with new points - clearGeom(); - - return tsweptVols; + //clearGeom(); } @@ -361,7 +340,6 @@ const Foam::cellShapeList& Foam::primitiveMesh::cellShapes() const } - void Foam::primitiveMesh::updateGeom() { if (!faceCentresPtr_ || !faceAreasPtr_) diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H index 5bcda5e24d..b369cdc68b 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -598,8 +598,8 @@ public: // Mesh motion - //- Move points, returns volumes swept by faces in motion - tmp movePoints + //- Move points + void movePoints ( const pointField& p, const pointField& oldP diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellCentresAndVols.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellCentresAndVols.C index 71eb30e7b9..56c83e4306 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellCentresAndVols.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellCentresAndVols.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,11 +53,11 @@ void Foam::primitiveMesh::calcCellCentresAndVols() const } // set the accumulated cell centre to zero vector - cellCentresPtr_ = new vectorField(nCells()); + cellCentresPtr_ = new vectorField(nCells(), Zero); vectorField& cellCtrs = *cellCentresPtr_; // Initialise cell volumes to 0 - cellVolumesPtr_ = new scalarField(nCells()); + cellVolumesPtr_ = new scalarField(nCells(), Zero); scalarField& cellVols = *cellVolumesPtr_; // Make centres and volumes diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFaceCentresAndAreas.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFaceCentresAndAreas.C index f3577d04ec..138baedde7 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFaceCentresAndAreas.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFaceCentresAndAreas.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. diff --git a/src/finiteVolume/fvMesh/fvGeometryScheme/basic/basicFvGeometryScheme.C b/src/finiteVolume/fvMesh/fvGeometryScheme/basic/basicFvGeometryScheme.C index cd24048b6b..58da31adbe 100644 --- a/src/finiteVolume/fvMesh/fvGeometryScheme/basic/basicFvGeometryScheme.C +++ b/src/finiteVolume/fvMesh/fvGeometryScheme/basic/basicFvGeometryScheme.C @@ -55,11 +55,14 @@ Foam::basicFvGeometryScheme::basicFvGeometryScheme void Foam::basicFvGeometryScheme::movePoints() { + fvGeometryScheme::movePoints(); + if (debug) { Pout<< "basicFvGeometryScheme::movePoints() : " << "recalculating primitiveMesh centres" << endl; } + // Use lower level to calculate the geometry const_cast(mesh_).primitiveMesh::updateGeom(); } @@ -74,9 +77,8 @@ Foam::tmp Foam::basicFvGeometryScheme::weights() const << endl; } - tmp tweights - ( - new surfaceScalarField + auto tweights = + tmp::New ( IOobject ( @@ -89,9 +91,9 @@ Foam::tmp Foam::basicFvGeometryScheme::weights() const ), mesh_, dimless - ) - ); - surfaceScalarField& weights = tweights.ref(); + ); + + auto& weights = tweights.ref(); weights.setOriented(); // Set local references to mesh data @@ -128,7 +130,7 @@ Foam::tmp Foam::basicFvGeometryScheme::weights() const } } - surfaceScalarField::Boundary& wBf = weights.boundaryFieldRef(); + auto& wBf = weights.boundaryFieldRef(); forAll(mesh_.boundary(), patchi) { @@ -159,9 +161,8 @@ Foam::basicFvGeometryScheme::deltaCoeffs() const // needed to make sure deltaCoeffs are calculated for parallel runs. (void)mesh_.weights(); - tmp tdeltaCoeffs - ( - new surfaceScalarField + auto tdeltaCoeffs = + tmp::New ( IOobject ( @@ -174,14 +175,14 @@ Foam::basicFvGeometryScheme::deltaCoeffs() const ), mesh_, dimless/dimLength - ) - ); - surfaceScalarField& deltaCoeffs = tdeltaCoeffs.ref(); + ); + + auto& deltaCoeffs = tdeltaCoeffs.ref(); deltaCoeffs.setOriented(); // Set local references to mesh data - const volVectorField& C = mesh_.C(); + const vectorField& C = mesh_.cellCentres(); const labelUList& owner = mesh_.owner(); const labelUList& neighbour = mesh_.neighbour(); @@ -190,8 +191,7 @@ Foam::basicFvGeometryScheme::deltaCoeffs() const deltaCoeffs[facei] = 1.0/mag(C[neighbour[facei]] - C[owner[facei]]); } - surfaceScalarField::Boundary& deltaCoeffsBf = - deltaCoeffs.boundaryFieldRef(); + auto& deltaCoeffsBf = deltaCoeffs.boundaryFieldRef(); forAll(deltaCoeffsBf, patchi) { @@ -220,9 +220,8 @@ Foam::basicFvGeometryScheme::nonOrthDeltaCoeffs() const // needed to make sure deltaCoeffs are calculated for parallel runs. weights(); - tmp tnonOrthDeltaCoeffs - ( - new surfaceScalarField + auto tnonOrthDeltaCoeffs = + tmp::New ( IOobject ( @@ -235,9 +234,9 @@ Foam::basicFvGeometryScheme::nonOrthDeltaCoeffs() const ), mesh_, dimless/dimLength - ) - ); - surfaceScalarField& nonOrthDeltaCoeffs = tnonOrthDeltaCoeffs.ref(); + ); + + auto& nonOrthDeltaCoeffs = tnonOrthDeltaCoeffs.ref(); nonOrthDeltaCoeffs.setOriented(); @@ -266,8 +265,7 @@ Foam::basicFvGeometryScheme::nonOrthDeltaCoeffs() const nonOrthDeltaCoeffs[facei] = 1.0/max(unitArea & delta, 0.05*mag(delta)); } - surfaceScalarField::Boundary& nonOrthDeltaCoeffsBf = - nonOrthDeltaCoeffs.boundaryFieldRef(); + auto& nonOrthDeltaCoeffsBf = nonOrthDeltaCoeffs.boundaryFieldRef(); forAll(nonOrthDeltaCoeffsBf, patchi) { @@ -306,9 +304,8 @@ Foam::basicFvGeometryScheme::nonOrthCorrectionVectors() const << endl; } - tmp tnonOrthCorrectionVectors - ( - new surfaceVectorField + auto tnonOrthCorrectionVectors = + tmp::New ( IOobject ( @@ -321,9 +318,9 @@ Foam::basicFvGeometryScheme::nonOrthCorrectionVectors() const ), mesh_, dimless - ) - ); - surfaceVectorField& corrVecs = tnonOrthCorrectionVectors.ref(); + ); + + auto& corrVecs = tnonOrthCorrectionVectors.ref(); corrVecs.setOriented(); // Set local references to mesh data @@ -337,8 +334,8 @@ Foam::basicFvGeometryScheme::nonOrthCorrectionVectors() const forAll(owner, facei) { - vector unitArea = Sf[facei]/magSf[facei]; - vector delta = C[neighbour[facei]] - C[owner[facei]]; + vector unitArea(Sf[facei]/magSf[facei]); + vector delta(C[neighbour[facei]] - C[owner[facei]]); corrVecs[facei] = unitArea - delta*NonOrthDeltaCoeffs[facei]; } @@ -347,7 +344,7 @@ Foam::basicFvGeometryScheme::nonOrthCorrectionVectors() const // and calculated consistently with internal corrections for // coupled patches - surfaceVectorField::Boundary& corrVecsBf = corrVecs.boundaryFieldRef(); + auto& corrVecsBf = corrVecs.boundaryFieldRef(); forAll(corrVecsBf, patchi) { @@ -361,7 +358,7 @@ Foam::basicFvGeometryScheme::nonOrthCorrectionVectors() const } else { - const fvsPatchScalarField& patchNonOrthDeltaCoeffs = + const auto& patchNonOrthDeltaCoeffs = NonOrthDeltaCoeffs.boundaryField()[patchi]; const vectorField patchDeltas(mesh_.boundary()[patchi].delta()); diff --git a/src/finiteVolume/fvMesh/fvGeometryScheme/fvGeometryScheme/fvGeometryScheme.C b/src/finiteVolume/fvMesh/fvGeometryScheme/fvGeometryScheme/fvGeometryScheme.C index 250576f050..4c18f0daa7 100644 --- a/src/finiteVolume/fvMesh/fvGeometryScheme/fvGeometryScheme/fvGeometryScheme.C +++ b/src/finiteVolume/fvMesh/fvGeometryScheme/fvGeometryScheme/fvGeometryScheme.C @@ -26,6 +26,8 @@ License \*---------------------------------------------------------------------------*/ #include "fvGeometryScheme.H" +#include "fvMesh.H" +#include "surfaceFields.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -37,10 +39,63 @@ namespace Foam } +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +bool Foam::fvGeometryScheme::setMeshPhi() const +{ + if (!mesh_.moving()) + { + return false; + } + + const pointField& oldPoints = mesh_.oldPoints(); + const pointField& currPoints = mesh_.points(); + + if (oldPoints.size() != currPoints.size()) + { + FatalErrorInFunction + << "Old and current points sizes must be the same. " + << "Old points:" << oldPoints.size() + << " Current points:" << currPoints.size() + << abort(FatalError); + } + + const faceList& faces = mesh_.faces(); + const scalar rdt = 1.0/mesh_.time().deltaTValue(); + + auto& meshPhi = const_cast(mesh_).setPhi(); + auto& meshPhii = meshPhi.primitiveFieldRef(); + forAll(meshPhii, facei) + { + const face& f = faces[facei]; + meshPhii[facei] = f.sweptVol(oldPoints, currPoints)*rdt; + } + + auto& meshPhiBf = meshPhi.boundaryFieldRef(); + for (auto& meshPhip : meshPhiBf) + { + if (!meshPhip.size()) + { + // Empty patches + continue; + } + + const auto& pp = meshPhip.patch().patch(); + + forAll(pp, facei) + { + const face& f = pp[facei]; + meshPhip[facei] = f.sweptVol(oldPoints, currPoints)*rdt; + } + } + + return true; +} + + // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // -Foam::tmp -Foam::fvGeometryScheme::New +Foam::tmp Foam::fvGeometryScheme::New ( const fvMesh& mesh, const dictionary& dict, @@ -55,10 +110,7 @@ Foam::fvGeometryScheme::New : dict.getOrDefault("type", defaultScheme) ); - if (debug) - { - InfoInFunction << "Geometry scheme = " << schemeName << endl; - } + DebugInFunction << "Geometry scheme = " << schemeName << endl; auto* ctorPtr = dictConstructorTable(schemeName); @@ -77,4 +129,20 @@ Foam::fvGeometryScheme::New } +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fvGeometryScheme::movePoints() +{ + if (mesh_.moving()) + { + // Set the mesh motion fluxes + setMeshPhi(); + + // Clear out old geometry + // Note: this recreates the old primitiveMesh::movePoints behaviour + const_cast(mesh_).primitiveMesh::clearGeom(); + } +} + + // ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/fvGeometryScheme/fvGeometryScheme/fvGeometryScheme.H b/src/finiteVolume/fvMesh/fvGeometryScheme/fvGeometryScheme/fvGeometryScheme.H index a8a4f03673..2265800f4b 100644 --- a/src/finiteVolume/fvMesh/fvGeometryScheme/fvGeometryScheme/fvGeometryScheme.H +++ b/src/finiteVolume/fvMesh/fvGeometryScheme/fvGeometryScheme/fvGeometryScheme.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -69,10 +69,18 @@ class fvGeometryScheme protected: + // Protected Data + //- Hold reference to mesh const fvMesh& mesh_; + // Protected Member Functions + + //- Set the mesh motion flux + bool setMeshPhi() const; + + public: //- Runtime type information @@ -127,8 +135,7 @@ public: } //- Update basic geometric properties from provided points - virtual void movePoints() - {} + virtual void movePoints(); //- Return linear difference weighting factors virtual tmp weights() const = 0; diff --git a/src/finiteVolume/fvMesh/fvGeometryScheme/highAspectRatio/highAspectRatioFvGeometryScheme.C b/src/finiteVolume/fvMesh/fvGeometryScheme/highAspectRatio/highAspectRatioFvGeometryScheme.C index 7a1d59aa46..89e08fd377 100644 --- a/src/finiteVolume/fvMesh/fvGeometryScheme/highAspectRatio/highAspectRatioFvGeometryScheme.C +++ b/src/finiteVolume/fvMesh/fvGeometryScheme/highAspectRatio/highAspectRatioFvGeometryScheme.C @@ -387,6 +387,9 @@ Foam::highAspectRatioFvGeometryScheme::highAspectRatioFvGeometryScheme void Foam::highAspectRatioFvGeometryScheme::movePoints() { + //basicFvGeometryScheme::movePoints(); + fvGeometryScheme::movePoints(); + if (debug) { Pout<< "highAspectRatioFvGeometryScheme::movePoints() : " diff --git a/src/finiteVolume/fvMesh/fvGeometryScheme/stabilised/stabilisedFvGeometryScheme.C b/src/finiteVolume/fvMesh/fvGeometryScheme/stabilised/stabilisedFvGeometryScheme.C index d141017041..78d10ceb65 100644 --- a/src/finiteVolume/fvMesh/fvGeometryScheme/stabilised/stabilisedFvGeometryScheme.C +++ b/src/finiteVolume/fvMesh/fvGeometryScheme/stabilised/stabilisedFvGeometryScheme.C @@ -157,6 +157,8 @@ Foam::stabilisedFvGeometryScheme::stabilisedFvGeometryScheme void Foam::stabilisedFvGeometryScheme::movePoints() { + fvGeometryScheme::movePoints(); + if (debug) { Pout<< "stabilisedFvGeometryScheme::movePoints() : " diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index d84884c852..8281d1f7d9 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -90,18 +90,22 @@ void Foam::fvMesh::updateGeomNotOldVol() { (void)V(); } + if (haveSf) { (void)Sf(); } + if (haveMagSf) { (void)magSf(); } + if (haveCP) { (void)C(); } + if (haveCf) { (void)Cf(); @@ -277,7 +281,7 @@ bool Foam::fvMesh::init(const bool doInit) // doing anything with primitiveMesh::cellCentres etc. (void)geometry(); - // Intialise my data + // Initialise my data polyMesh::init(doInit); } @@ -285,6 +289,10 @@ bool Foam::fvMesh::init(const bool doInit) // and set the storage of V00 if (fileHandler().isFile(time().timePath()/dbDir()/"V0")) { + // Set the moving flag early in case the demand-driven geometry + // construction checks for it + moving(true); + V0Ptr_ = new DimensionedField ( IOobject @@ -306,6 +314,10 @@ bool Foam::fvMesh::init(const bool doInit) // mesh to be moving if (fileHandler().isFile(time().timePath()/dbDir()/"meshPhi")) { + // Set the moving flag early in case the demand-driven geometry + // construction checks for it + moving(true); + phiPtr_ = new surfaceScalarField ( IOobject @@ -339,8 +351,6 @@ bool Foam::fvMesh::init(const bool doInit) V() ); } - - moving(true); } // Assume something changed @@ -643,7 +653,7 @@ void Foam::fvMesh::removeFvBoundary() Foam::polyMesh::readUpdateState Foam::fvMesh::readUpdate() { - DebugInFunction << "Updating fvMesh. "; + DebugInFunction << "Updating fvMesh"; polyMesh::readUpdateState state = polyMesh::readUpdate(); @@ -861,7 +871,8 @@ void Foam::fvMesh::mapFields(const mapPolyMesh& meshMap) } -Foam::tmp Foam::fvMesh::movePoints(const pointField& p) + +void Foam::fvMesh::movePoints(const pointField& p) { DebugInFunction << endl; @@ -873,12 +884,8 @@ Foam::tmp Foam::fvMesh::movePoints(const pointField& p) } - // Move the polyMesh and set the mesh motion fluxes to the swept-volumes - - scalar rDeltaT = 1.0/time().deltaTValue(); - - tmp tsweptVols = polyMesh::movePoints(p); - scalarField& sweptVols = tsweptVols.ref(); + // Move the polyMesh and initialise the mesh motion fluxes field + // Note: mesh flux updated by the fvGeometryScheme if (!phiPtr_) { @@ -895,7 +902,7 @@ Foam::tmp Foam::fvMesh::movePoints(const pointField& p) false ), *this, - dimVolume/dimTime + dimensionedScalar(dimVolume/dimTime, Zero) ); } else @@ -907,19 +914,7 @@ Foam::tmp Foam::fvMesh::movePoints(const pointField& p) } } - surfaceScalarField& phi = *phiPtr_; - phi.primitiveFieldRef() = - scalarField::subField(sweptVols, nInternalFaces()); - phi.primitiveFieldRef() *= rDeltaT; - - const fvPatchList& patches = boundary(); - - surfaceScalarField::Boundary& phibf = phi.boundaryFieldRef(); - forAll(patches, patchi) - { - phibf[patchi] = patches[patchi].patchSlice(sweptVols); - phibf[patchi] *= rDeltaT; - } + polyMesh::movePoints(p); // Update or delete the local geometric properties as early as possible so // they can be used if necessary. These get recreated here instead of @@ -929,20 +924,21 @@ Foam::tmp Foam::fvMesh::movePoints(const pointField& p) // should use the local geometric properties. updateGeomNotOldVol(); - // Update other local data boundary_.movePoints(); - surfaceInterpolation::movePoints(); + + // Clear weights, deltaCoeffs, nonOrthoDeltaCoeffs, nonOrthCorrectionVectors + surfaceInterpolation::clearOut(); meshObject::movePoints(*this); meshObject::movePoints(*this); - - return tsweptVols; } void Foam::fvMesh::updateGeom() { + DebugInFunction << endl; + // Let surfaceInterpolation handle geometry calculation. Note: this does // lower levels updateGeom surfaceInterpolation::updateGeom(); diff --git a/src/finiteVolume/fvMesh/fvMesh.H b/src/finiteVolume/fvMesh/fvMesh.H index a8a7d09631..defd0f228e 100644 --- a/src/finiteVolume/fvMesh/fvMesh.H +++ b/src/finiteVolume/fvMesh/fvMesh.H @@ -469,7 +469,7 @@ public: using surfaceInterpolation::movePoints; //- Move points, returns volumes swept by faces in motion - virtual tmp movePoints(const pointField&); + virtual void movePoints(const pointField&); //- Update all geometric data. This gets redirected up from //- primitiveMesh level