diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C index 82dc592c6a..fadb41dab1 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C @@ -540,15 +540,26 @@ void Foam::triSurfaceMesh::clearOut() Foam::tmp Foam::triSurfaceMesh::coordinates() const { - auto tpts = tmp::New(8); + auto tpts = tmp::New(); auto& pts = tpts.ref(); - // Use copy to calculate face centres so they don't get stored - pts = PrimitivePatch - ( - SubList(*this, triSurface::size()), - triSurface::points() - ).faceCentres(); + if (triSurface::hasFaceCentres()) + { + // Can reuse existing values + pts = triSurface::faceCentres(); + } + else + { + typedef SubList FaceListType; + + // Calculate face centres from a copy to avoid incurring + // additional storage + pts = PrimitivePatch + ( + FaceListType(*this, triSurface::size()), + triSurface::points() + ).faceCentres(); + } return tpts; }