diff --git a/applications/utilities/mesh/manipulation/deformedGeom/deformedGeom.C b/applications/utilities/mesh/manipulation/deformedGeom/deformedGeom.C index 38d0db536f..8df490a7d9 100644 --- a/applications/utilities/mesh/manipulation/deformedGeom/deformedGeom.C +++ b/applications/utilities/mesh/manipulation/deformedGeom/deformedGeom.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -85,7 +85,7 @@ int main(int argc, char *argv[]) + scaleFactor*pInterp.interpolate(U)().primitiveField() ); - mesh.polyMesh::movePoints(newPoints); + mesh.setPoints(newPoints); mesh.write(); } else diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 97d837505d..ea800d3786 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -1216,6 +1216,50 @@ void Foam::polyMesh::setUpToDatePoints(regIOobject& io) const } +void Foam::polyMesh::setPoints(const pointField& newPoints) +{ + if (debug) + { + InfoInFunction + << "Set points for time " << time().value() + << " index " << time().timeIndex() << endl; + } + + primitiveMesh::clearGeom(); + + points_ = newPoints; + + setPointsInstance(time().timeName()); + + // Adjust parallel shared points + if (globalMeshDataPtr_.valid()) + { + globalMeshDataPtr_().movePoints(points_); + } + + // Force recalculation of all geometric data with new points + + bounds_ = boundBox(points_); + boundary_.movePoints(points_); + + pointZones_.movePoints(points_); + faceZones_.movePoints(points_); + cellZones_.movePoints(points_); + + // Cell tree might become invalid + cellTreePtr_.clear(); + + // Reset valid directions (could change with rotation) + geometricD_ = Zero; + solutionD_ = Zero; + + meshObject::movePoints(*this); + meshObject::movePoints(*this); + + const_cast(time()).functionObjects().movePoints(*this); +} + + Foam::tmp Foam::polyMesh::movePoints ( const pointField& newPoints diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H index aa33522dad..9074d2918a 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H @@ -540,6 +540,10 @@ public: return moving() || topoChanged(); } + //- Reset the points + // without storing old points or returning swept volumes + virtual void setPoints(const pointField&); + //- Move points, returns volumes swept by faces in motion virtual tmp movePoints(const pointField&); diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index 70c723fe26..dc38680d87 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -142,9 +142,6 @@ void Foam::fvMesh::clearGeom() deleteDemandDrivenData(phiPtr_); deleteDemandDrivenData(V0Ptr_); deleteDemandDrivenData(V00Ptr_); - - // Mesh motion flux cannot be deleted here because the old-time flux - // needs to be saved. } @@ -680,9 +677,6 @@ void Foam::fvMesh::reset(const fvMesh& newMesh) // Clear any non-updateable addressing clearAddressing(true); - // Clear mesh motion flux - deleteDemandDrivenData(phiPtr_); - const polyPatchList& newBoundary = newMesh.boundaryMesh(); labelList patchSizes(newBoundary.size()); labelList patchStarts(newBoundary.size()); @@ -1012,6 +1006,21 @@ void Foam::fvMesh::mapFields(const polyTopoChangeMap& map) } +void Foam::fvMesh::setPoints(const pointField& p) +{ + polyMesh::setPoints(p); + + clearGeom(); + + // Update other local data + boundary_.movePoints(); + surfaceInterpolation::movePoints(); + + meshObject::movePoints(*this); + meshObject::movePoints(*this); +} + + Foam::tmp Foam::fvMesh::movePoints(const pointField& p) { // Set moving_ true diff --git a/src/finiteVolume/fvMesh/fvMesh.H b/src/finiteVolume/fvMesh/fvMesh.H index 69856e0594..b5829fa759 100644 --- a/src/finiteVolume/fvMesh/fvMesh.H +++ b/src/finiteVolume/fvMesh/fvMesh.H @@ -489,6 +489,10 @@ public: //- Redistribute or update using the given distribution map virtual void distribute(const polyDistributionMap& map); + //- Reset the points + // without storing old points or returning swept volumes + virtual void setPoints(const pointField&); + //- Move points, returns volumes swept by faces in motion virtual tmp movePoints(const pointField&); diff --git a/src/parallel/parallel/domainDecomposition.C b/src/parallel/parallel/domainDecomposition.C index e140b0b9d0..7eecb0788f 100644 --- a/src/parallel/parallel/domainDecomposition.C +++ b/src/parallel/parallel/domainDecomposition.C @@ -61,7 +61,7 @@ void Foam::domainDecomposition::decomposePoints() if (pointsCompare == -1) { - procMesh.polyMesh::movePoints + procMesh.setPoints ( pointField ( @@ -94,7 +94,7 @@ void Foam::domainDecomposition::reconstructPoints() completePoints.rmap(procMesh.points(), procPointAddressing_[proci]); } - completeMesh_->polyMesh::movePoints(completePoints); + completeMesh_->setPoints(completePoints); } }