polyMesh::setPoints: New function to reset the points

without calculating the mesh-motion fluxes or cache the old points.  Used for
efficient reconstruction of moving mesh cases run in parallel.
This commit is contained in:
Henry Weller
2022-06-14 00:21:51 +01:00
parent 6437de8082
commit 737d737b22
6 changed files with 71 additions and 10 deletions

View File

@ -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

View File

@ -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<polyMesh>(*this);
meshObject::movePoints<pointMesh>(*this);
const_cast<Time&>(time()).functionObjects().movePoints(*this);
}
Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
(
const pointField& newPoints

View File

@ -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<scalarField> movePoints(const pointField&);

View File

@ -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<fvMesh>(*this);
meshObject::movePoints<lduMesh>(*this);
}
Foam::tmp<Foam::scalarField> Foam::fvMesh::movePoints(const pointField& p)
{
// Set moving_ true

View File

@ -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<scalarField> movePoints(const pointField&);

View File

@ -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);
}
}