mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: reuse faceCentres if they already exist
This commit is contained in:
@ -540,15 +540,26 @@ void Foam::triSurfaceMesh::clearOut()
|
|||||||
|
|
||||||
Foam::tmp<Foam::pointField> Foam::triSurfaceMesh::coordinates() const
|
Foam::tmp<Foam::pointField> Foam::triSurfaceMesh::coordinates() const
|
||||||
{
|
{
|
||||||
auto tpts = tmp<pointField>::New(8);
|
auto tpts = tmp<pointField>::New();
|
||||||
auto& pts = tpts.ref();
|
auto& pts = tpts.ref();
|
||||||
|
|
||||||
// Use copy to calculate face centres so they don't get stored
|
if (triSurface::hasFaceCentres())
|
||||||
pts = PrimitivePatch<triSurface::FaceType, SubList, const pointField&>
|
{
|
||||||
(
|
// Can reuse existing values
|
||||||
SubList<triSurface::FaceType>(*this, triSurface::size()),
|
pts = triSurface::faceCentres();
|
||||||
triSurface::points()
|
}
|
||||||
).faceCentres();
|
else
|
||||||
|
{
|
||||||
|
typedef SubList<labelledTri> FaceListType;
|
||||||
|
|
||||||
|
// Calculate face centres from a copy to avoid incurring
|
||||||
|
// additional storage
|
||||||
|
pts = PrimitivePatch<labelledTri, SubList, const pointField&>
|
||||||
|
(
|
||||||
|
FaceListType(*this, triSurface::size()),
|
||||||
|
triSurface::points()
|
||||||
|
).faceCentres();
|
||||||
|
}
|
||||||
|
|
||||||
return tpts;
|
return tpts;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user