ENH: change from triSurface to meshedSurface storage for iso-surfaces

- this makes it easier to reuse the code, and sampledSurface expect
  a face (not a labelledFace), so this also eliminates a translation
  level and simplifies memory management.

- before/after comparison of the sampled iso-surfaces tested with
  iso-surfaces from interFoam/RAS/angledDuct tutorial (serial and
  parallel)
This commit is contained in:
Mark Olesen
2016-11-29 17:24:26 +01:00
parent 5e9d916fd3
commit 3c41b80b38
15 changed files with 130 additions and 162 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -49,7 +49,6 @@ void Foam::distanceSurface::createGeometry()
} }
// Clear any stored topologies // Clear any stored topologies
facesPtr_.clear();
isoSurfCellPtr_.clear(); isoSurfCellPtr_.clear();
isoSurfPtr_.clear(); isoSurfPtr_.clear();
@ -339,8 +338,7 @@ Foam::distanceSurface::distanceSurface
zoneKey_(keyType::null), zoneKey_(keyType::null),
needsUpdate_(true), needsUpdate_(true),
isoSurfCellPtr_(nullptr), isoSurfCellPtr_(nullptr),
isoSurfPtr_(nullptr), isoSurfPtr_(nullptr)
facesPtr_(nullptr)
{ {
// dict.readIfPresent("zone", zoneKey_); // dict.readIfPresent("zone", zoneKey_);
// //
@ -395,8 +393,7 @@ Foam::distanceSurface::distanceSurface
zoneKey_(keyType::null), zoneKey_(keyType::null),
needsUpdate_(true), needsUpdate_(true),
isoSurfCellPtr_(nullptr), isoSurfCellPtr_(nullptr),
isoSurfPtr_(nullptr), isoSurfPtr_(nullptr)
facesPtr_(nullptr)
{} {}
@ -419,13 +416,9 @@ bool Foam::distanceSurface::expire()
if (debug) if (debug)
{ {
Pout<< "distanceSurface::expire :" Pout<< "distanceSurface::expire :"
<< " have-facesPtr_:" << facesPtr_.valid() << " needsUpdate:" << needsUpdate_ << endl;
<< " needsUpdate_:" << needsUpdate_ << endl;
} }
// Clear any stored topologies
facesPtr_.clear();
// Clear derived data // Clear derived data
clearGeom(); clearGeom();
@ -445,8 +438,7 @@ bool Foam::distanceSurface::update()
if (debug) if (debug)
{ {
Pout<< "distanceSurface::update :" Pout<< "distanceSurface::update :"
<< " have-facesPtr_:" << facesPtr_.valid() << " needsUpdate:" << needsUpdate_ << endl;
<< " needsUpdate_:" << needsUpdate_ << endl;
} }
if (!needsUpdate_) if (!needsUpdate_)

View File

@ -97,9 +97,6 @@ class distanceSurface
//- Constructed iso surface //- Constructed iso surface
autoPtr<isoSurface> isoSurfPtr_; autoPtr<isoSurface> isoSurfPtr_;
//- Triangles converted to faceList
mutable autoPtr<faceList> facesPtr_;
// Private Member Functions // Private Member Functions
@ -179,18 +176,7 @@ public:
//- Faces of surface //- Faces of surface
virtual const faceList& faces() const virtual const faceList& faces() const
{ {
if (facesPtr_.empty()) return surface().surfFaces();
{
const triSurface& s = surface();
facesPtr_.reset(new faceList(s.size()));
forAll(s, i)
{
facesPtr_()[i] = s[i].triFaceFace();
}
}
return facesPtr_;
} }
//- Const access to per-face zone/region information //- Const access to per-face zone/region information
@ -219,7 +205,7 @@ public:
//- The underlying surface //- The underlying surface
const triSurface& surface() const const meshedSurface& surface() const
{ {
if (cell_) if (cell_)
{ {
@ -231,6 +217,7 @@ public:
} }
} }
//- Sample field on surface //- Sample field on surface
virtual tmp<scalarField> sample virtual tmp<scalarField> sample
( (

View File

@ -37,6 +37,7 @@ License
#include "surfaceIntersection.H" #include "surfaceIntersection.H"
#include "intersectedSurface.H" #include "intersectedSurface.H"
#include "searchableBox.H" #include "searchableBox.H"
#include "triSurface.H"
#include "triSurfaceMesh.H" #include "triSurfaceMesh.H"
#include "triPoints.H" #include "triPoints.H"
@ -687,7 +688,6 @@ void Foam::isoSurface::calcSnappedPoint
pointField collapsedPoint(mesh_.nPoints(), point::max); pointField collapsedPoint(mesh_.nPoints(), point::max);
// Work arrays // Work arrays
DynamicList<point, 64> localTriPoints(100); DynamicList<point, 64> localTriPoints(100);
@ -1342,6 +1342,7 @@ Foam::isoSurface::isoSurface
const scalar mergeTol const scalar mergeTol
) )
: :
MeshStorage(),
mesh_(cVals.mesh()), mesh_(cVals.mesh()),
pVals_(pVals), pVals_(pVals),
iso_(iso), iso_(iso),
@ -1582,6 +1583,9 @@ Foam::isoSurface::isoSurface
} }
// Use a triSurface as a temporary for various operations
triSurface tmpsurf;
{ {
DynamicList<point> triPoints(3*nCutCells_); DynamicList<point> triPoints(3*nCutCells_);
DynamicList<label> triMeshCells(nCutCells_); DynamicList<label> triMeshCells(nCutCells_);
@ -1633,15 +1637,12 @@ Foam::isoSurface::isoSurface
// Merge points and compact out non-valid triangles // Merge points and compact out non-valid triangles
labelList triMap; // merged to unmerged triangle labelList triMap; // merged to unmerged triangle
triSurface::operator= tmpsurf = stitchTriPoints
( (
stitchTriPoints true, // check for duplicate tris
( triPoints,
true, // check for duplicate tris triPointMergeMap_, // unmerged to merged point
triPoints, triMap
triPointMergeMap_, // unmerged to merged point
triMap
)
); );
if (debug) if (debug)
@ -1682,17 +1683,33 @@ Foam::isoSurface::isoSurface
if (debug) if (debug)
{ {
Pout<< "isoSurface : checking " << size() Pout<< "isoSurface : checking " << tmpsurf.size()
<< " triangles for validity." << endl; << " triangles for validity." << endl;
forAll(*this, triI) forAll(tmpsurf, facei)
{ {
triSurfaceTools::validTri(*this, triI); triSurfaceTools::validTri(tmpsurf, facei);
} }
fileName stlFile = mesh_.time().path() + ".stl"; fileName stlFile = mesh_.time().path() + ".stl";
Pout<< "Dumping surface to " << stlFile << endl; Pout<< "Dumping surface to " << stlFile << endl;
triSurface::write(stlFile); tmpsurf.write(stlFile);
}
// Transfer to mesh storage
{
faceList faces;
tmpsurf.triFaceFaces(faces);
// An iso-surface has no zones
surfZoneList zones(0);
// Reset primitive data (points, faces and zones)
this->MeshStorage::reset
(
tmpsurf.xferPoints(), faces.xfer(), zones.xfer()
);
} }
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -57,18 +57,18 @@ Description
SourceFiles SourceFiles
isoSurface.C isoSurface.C
isoSurfaceTemplates.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef isoSurface_H #ifndef isoSurface_H
#define isoSurface_H #define isoSurface_H
#include "triSurface.H"
#include "labelPair.H"
#include "pointIndexHit.H"
#include "PackedBoolList.H" #include "PackedBoolList.H"
#include "volFields.H" #include "volFields.H"
#include "slicedVolFields.H" #include "slicedVolFields.H"
#include "MeshedSurface.H"
#include "MeshedSurfacesFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -78,6 +78,7 @@ namespace Foam
class fvMesh; class fvMesh;
class plane; class plane;
class treeBoundBox; class treeBoundBox;
class triSurface;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class isoSurface Declaration Class isoSurface Declaration
@ -85,8 +86,12 @@ class treeBoundBox;
class isoSurface class isoSurface
: :
public triSurface public meshedSurface
{ {
// Private typedefs for convenience
typedef meshedSurface MeshStorage;
// Private data // Private data
enum segmentCutType enum segmentCutType
@ -379,7 +384,7 @@ class isoSurface
static triSurface subsetMesh static triSurface subsetMesh
( (
const triSurface& s, const triSurface&,
const labelList& newToOldFaces, const labelList& newToOldFaces,
labelList& oldToNewPoints, labelList& oldToNewPoints,
labelList& newToOldPoints labelList& newToOldPoints
@ -413,7 +418,7 @@ public:
// Member Functions // Member Functions
//- For every triangle the original cell in mesh //- For every face, the original cell in mesh
const labelList& meshCells() const const labelList& meshCells() const
{ {
return meshCells_; return meshCells_;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -24,16 +24,17 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "isoSurfaceCell.H" #include "isoSurfaceCell.H"
#include "isoSurface.H"
#include "dictionary.H" #include "dictionary.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "mergePoints.H" #include "mergePoints.H"
#include "tetMatcher.H" #include "tetMatcher.H"
#include "syncTools.H" #include "syncTools.H"
#include "triSurface.H"
#include "triSurfaceTools.H" #include "triSurfaceTools.H"
#include "addToRunTimeSelectionTable.H"
#include "Time.H" #include "Time.H"
#include "triPoints.H" #include "triPoints.H"
#include "isoSurface.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -1310,6 +1311,7 @@ Foam::isoSurfaceCell::isoSurfaceCell
const scalar mergeTol const scalar mergeTol
) )
: :
MeshStorage(),
mesh_(mesh), mesh_(mesh),
cVals_(cVals), cVals_(cVals),
pVals_(pVals), pVals_(pVals),
@ -1398,6 +1400,9 @@ Foam::isoSurfaceCell::isoSurfaceCell
} }
// Use a triSurface as a temporary for various operations
triSurface tmpsurf;
{ {
DynamicList<point> triPoints(nCutCells_); DynamicList<point> triPoints(nCutCells_);
DynamicList<label> triMeshCells(nCutCells_); DynamicList<label> triMeshCells(nCutCells_);
@ -1448,16 +1453,13 @@ Foam::isoSurfaceCell::isoSurfaceCell
// Merge points and compact out non-valid triangles // Merge points and compact out non-valid triangles
labelList triMap; labelList triMap; // merged to unmerged triangle
triSurface::operator= tmpsurf = stitchTriPoints
( (
stitchTriPoints regularise, // check for duplicate tris
( triPoints,
regularise, // check for duplicate tris triPointMergeMap_, // unmerged to merged point
triPoints, triMap // merged to unmerged triangle
triPointMergeMap_, // unmerged to merged point
triMap // merged to unmerged triangle
)
); );
if (debug) if (debug)
@ -1498,12 +1500,12 @@ Foam::isoSurfaceCell::isoSurfaceCell
if (debug) if (debug)
{ {
Pout<< "isoSurfaceCell : checking " << size() Pout<< "isoSurfaceCell : checking " << tmpsurf.size()
<< " triangles for validity." << endl; << " triangles for validity." << endl;
forAll(*this, triI) forAll(tmpsurf, triI)
{ {
triSurfaceTools::validTri(*this, triI); triSurfaceTools::validTri(tmpsurf, triI);
} }
} }
@ -1520,7 +1522,7 @@ Foam::isoSurfaceCell::isoSurfaceCell
// Calculate addressing // Calculate addressing
calcAddressing calcAddressing
( (
*this, tmpsurf,
faceEdges, faceEdges,
edgeFace0, edgeFace0,
edgeFace1, edgeFace1,
@ -1554,21 +1556,33 @@ Foam::isoSurfaceCell::isoSurfaceCell
labelList subsetPointMap; labelList subsetPointMap;
labelList reversePointMap; labelList reversePointMap;
triSurface::operator= tmpsurf = subsetMesh
( (
subsetMesh tmpsurf,
( subsetTriMap,
*this, reversePointMap,
subsetTriMap, subsetPointMap
reversePointMap,
subsetPointMap
)
); );
meshCells_ = labelField(meshCells_, subsetTriMap); meshCells_ = labelField(meshCells_, subsetTriMap);
inplaceRenumber(reversePointMap, triPointMergeMap_); inplaceRenumber(reversePointMap, triPointMergeMap_);
} }
} }
// Transfer to mesh storage
{
faceList faces;
tmpsurf.triFaceFaces(faces);
// An iso-surface has no zones
surfZoneList zones(0);
// Reset primitive data (points, faces and zones)
this->MeshStorage::reset
(
tmpsurf.xferPoints(), faces.xfer(), zones.xfer()
);
}
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -38,17 +38,19 @@ Description
SourceFiles SourceFiles
isoSurfaceCell.C isoSurfaceCell.C
isoSurfaceCellTemplates.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef isoSurfaceCell_H #ifndef isoSurfaceCell_H
#define isoSurfaceCell_H #define isoSurfaceCell_H
#include "triSurface.H"
#include "labelPair.H" #include "labelPair.H"
#include "pointIndexHit.H" #include "pointIndexHit.H"
#include "PackedBoolList.H" #include "PackedBoolList.H"
#include "boundBox.H" #include "boundBox.H"
#include "MeshedSurface.H"
#include "MeshedSurfacesFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,7 +58,7 @@ namespace Foam
{ {
class polyMesh; class polyMesh;
class plane; class triSurface;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class isoSurfaceCell Declaration Class isoSurfaceCell Declaration
@ -64,8 +66,12 @@ class plane;
class isoSurfaceCell class isoSurfaceCell
: :
public triSurface public meshedSurface
{ {
// Private typedefs for convenience
typedef meshedSurface MeshStorage;
// Private data // Private data
enum segmentCutType enum segmentCutType
@ -301,7 +307,7 @@ class isoSurfaceCell
static triSurface subsetMesh static triSurface subsetMesh
( (
const triSurface& s, const triSurface&,
const labelList& newToOldFaces, const labelList& newToOldFaces,
labelList& oldToNewPoints, labelList& oldToNewPoints,
labelList& newToOldPoints labelList& newToOldPoints
@ -331,7 +337,7 @@ public:
// Member Functions // Member Functions
//- For every face original cell in mesh //- For every face, the original cell in mesh
const labelList& meshCells() const const labelList& meshCells() const
{ {
return meshCells_; return meshCells_;

View File

@ -24,9 +24,9 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "isoSurfaceCell.H" #include "isoSurfaceCell.H"
#include "isoSurface.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "tetMatcher.H" #include "tetMatcher.H"
#include "isoSurface.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -556,7 +556,7 @@ Foam::isoSurfaceCell::interpolate
return isoSurface::interpolate return isoSurface::interpolate
( (
points().size(), this->points().size(),
triPointMergeMap_, triPointMergeMap_,
interpolatedPoints_, interpolatedPoints_,
interpolatedOldPoints_, interpolatedOldPoints_,

View File

@ -842,7 +842,7 @@ Foam::isoSurface::interpolate
return interpolate return interpolate
( (
points().size(), this->points().size(),
triPointMergeMap_, triPointMergeMap_,
interpolatedPoints_, interpolatedPoints_,
interpolatedOldPoints_, interpolatedOldPoints_,

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -393,7 +393,6 @@ bool Foam::sampledIsoSurface::updateGeometry() const
// Clear any stored topo // Clear any stored topo
surfPtr_.clear(); surfPtr_.clear();
facesPtr_.clear();
// Clear derived data // Clear derived data
clearGeom(); clearGeom();
@ -448,7 +447,7 @@ bool Foam::sampledIsoSurface::updateGeometry() const
<< nl; << nl;
} }
Pout<< " points : " << points().size() << nl Pout<< " points : " << points().size() << nl
<< " tris : " << surface().size() << nl << " faces : " << surface().size() << nl
<< " cut cells : " << surface().meshCells().size() << " cut cells : " << surface().meshCells().size()
<< endl; << endl;
} }
@ -476,7 +475,6 @@ Foam::sampledIsoSurface::sampledIsoSurface
zoneID_(dict.lookupOrDefault("zone", word::null), mesh.cellZones()), zoneID_(dict.lookupOrDefault("zone", word::null), mesh.cellZones()),
exposedPatchName_(word::null), exposedPatchName_(word::null),
surfPtr_(nullptr), surfPtr_(nullptr),
facesPtr_(nullptr),
prevTimeIndex_(-1), prevTimeIndex_(-1),
storedVolFieldPtr_(nullptr), storedVolFieldPtr_(nullptr),
volFieldPtr_(nullptr), volFieldPtr_(nullptr),
@ -535,7 +533,6 @@ bool Foam::sampledIsoSurface::needsUpdate() const
bool Foam::sampledIsoSurface::expire() bool Foam::sampledIsoSurface::expire()
{ {
surfPtr_.clear(); surfPtr_.clear();
facesPtr_.clear();
subMeshPtr_.clear(); subMeshPtr_.clear();
// Clear derived data // Clear derived data

View File

@ -83,9 +83,6 @@ class sampledIsoSurface
mutable autoPtr<isoSurface> surfPtr_; mutable autoPtr<isoSurface> surfPtr_;
//- Triangles converted to faceList
mutable autoPtr<faceList> facesPtr_;
// Recreated for every isoSurface // Recreated for every isoSurface
@ -185,18 +182,7 @@ public:
//- Faces of surface //- Faces of surface
virtual const faceList& faces() const virtual const faceList& faces() const
{ {
if (facesPtr_.empty()) return surface().surfFaces();
{
const triSurface& s = surface();
facesPtr_.reset(new faceList(s.size()));
forAll(s, i)
{
facesPtr_()[i] = s[i].triFaceFace();
}
}
return facesPtr_;
} }
//- Const access to per-face zone/region information //- Const access to per-face zone/region information

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -59,9 +59,6 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const
prevTimeIndex_ = fvm.time().timeIndex(); prevTimeIndex_ = fvm.time().timeIndex();
// Clear any stored topo
facesPtr_.clear();
// Clear derived data // Clear derived data
sampledSurface::clearGeom(); sampledSurface::clearGeom();
@ -142,7 +139,7 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const
cellAvg[celli] /= nPointCells[celli]; cellAvg[celli] /= nPointCells[celli];
} }
const isoSurfaceCell iso isoSurfaceCell iso
( (
fvm, fvm,
cellAvg, cellAvg,
@ -155,13 +152,13 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const
const_cast<sampledIsoSurfaceCell&> const_cast<sampledIsoSurfaceCell&>
( (
*this *this
).triSurface::operator=(iso); ).transfer(static_cast<meshedSurface&>(iso));
meshCells_ = iso.meshCells(); meshCells_ = iso.meshCells();
} }
else else
{ {
//- Direct from cell field and point field. Gives bad continuity. //- Direct from cell field and point field. Gives bad continuity.
const isoSurfaceCell iso isoSurfaceCell iso
( (
fvm, fvm,
cellFld.primitiveField(), cellFld.primitiveField(),
@ -174,7 +171,7 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const
const_cast<sampledIsoSurfaceCell&> const_cast<sampledIsoSurfaceCell&>
( (
*this *this
).triSurface::operator=(iso); ).transfer(static_cast<meshedSurface&>(iso));
meshCells_ = iso.meshCells(); meshCells_ = iso.meshCells();
} }
@ -189,7 +186,7 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const
<< " isoValue : " << isoVal_ << nl << " isoValue : " << isoVal_ << nl
<< " bounds : " << bounds_ << nl << " bounds : " << bounds_ << nl
<< " points : " << points().size() << nl << " points : " << points().size() << nl
<< " tris : " << triSurface::size() << nl << " faces : " << MeshStorage::size() << nl
<< " cut cells : " << meshCells_.size() << endl; << " cut cells : " << meshCells_.size() << endl;
} }
@ -207,13 +204,13 @@ Foam::sampledIsoSurfaceCell::sampledIsoSurfaceCell
) )
: :
sampledSurface(name, mesh, dict), sampledSurface(name, mesh, dict),
MeshStorage(),
isoField_(dict.lookup("isoField")), isoField_(dict.lookup("isoField")),
isoVal_(readScalar(dict.lookup("isoValue"))), isoVal_(readScalar(dict.lookup("isoValue"))),
bounds_(dict.lookupOrDefault("bounds", boundBox::greatBox)), bounds_(dict.lookupOrDefault("bounds", boundBox::greatBox)),
regularise_(dict.lookupOrDefault("regularise", true)), regularise_(dict.lookupOrDefault("regularise", true)),
average_(dict.lookupOrDefault("average", true)), average_(dict.lookupOrDefault("average", true)),
zoneKey_(keyType::null), zoneKey_(keyType::null),
facesPtr_(nullptr),
prevTimeIndex_(-1), prevTimeIndex_(-1),
meshCells_(0) meshCells_(0)
{} {}
@ -237,8 +234,6 @@ bool Foam::sampledIsoSurfaceCell::needsUpdate() const
bool Foam::sampledIsoSurfaceCell::expire() bool Foam::sampledIsoSurfaceCell::expire()
{ {
facesPtr_.clear();
// Clear derived data // Clear derived data
sampledSurface::clearGeom(); sampledSurface::clearGeom();

View File

@ -38,7 +38,8 @@ SourceFiles
#define sampledIsoSurfaceCell_H #define sampledIsoSurfaceCell_H
#include "sampledSurface.H" #include "sampledSurface.H"
#include "triSurface.H" #include "MeshedSurface.H"
#include "MeshedSurfacesFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -52,10 +53,10 @@ namespace Foam
class sampledIsoSurfaceCell class sampledIsoSurfaceCell
: :
public sampledSurface, public sampledSurface,
public triSurface public meshedSurface
{ {
//- Private typedef for convenience // Private typedefs for convenience
typedef triSurface MeshStorage; typedef meshedSurface MeshStorage;
// Private data // Private data
@ -77,9 +78,6 @@ class sampledIsoSurfaceCell
//- If restricted to zones, name of this zone or a regular expression //- If restricted to zones, name of this zone or a regular expression
keyType zoneKey_; keyType zoneKey_;
//- Triangles converted to faceList
mutable autoPtr<faceList> facesPtr_;
// Recreated for every isoSurface // Recreated for every isoSurface
@ -154,18 +152,7 @@ public:
//- Faces of surface //- Faces of surface
virtual const faceList& faces() const virtual const faceList& faces() const
{ {
if (facesPtr_.empty()) return MeshStorage::surfFaces();
{
const triSurface& s = *this;
facesPtr_.reset(new faceList(s.size()));
forAll(s, i)
{
facesPtr_()[i] = s[i].triFaceFace();
}
}
return facesPtr_;
} }
//- Const access to per-face zone/region information //- Const access to per-face zone/region information

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -55,7 +55,6 @@ void Foam::sampledCuttingPlane::createGeometry()
} }
// Clear any stored topologies // Clear any stored topologies
facesPtr_.clear();
isoSurfPtr_.ptr(); isoSurfPtr_.ptr();
pointDistance_.clear(); pointDistance_.clear();
cellDistancePtr_.clear(); cellDistancePtr_.clear();
@ -273,8 +272,7 @@ Foam::sampledCuttingPlane::sampledCuttingPlane
needsUpdate_(true), needsUpdate_(true),
subMeshPtr_(nullptr), subMeshPtr_(nullptr),
cellDistancePtr_(nullptr), cellDistancePtr_(nullptr),
isoSurfPtr_(nullptr), isoSurfPtr_(nullptr)
facesPtr_(nullptr)
{ {
if (zoneID_.index() != -1) if (zoneID_.index() != -1)
{ {
@ -318,13 +316,9 @@ bool Foam::sampledCuttingPlane::expire()
if (debug) if (debug)
{ {
Pout<< "sampledCuttingPlane::expire :" Pout<< "sampledCuttingPlane::expire :"
<< " have-facesPtr_:" << facesPtr_.valid() << " needsUpdate:" << needsUpdate_ << endl;
<< " needsUpdate_:" << needsUpdate_ << endl;
} }
// Clear any stored topologies
facesPtr_.clear();
// Clear derived data // Clear derived data
clearGeom(); clearGeom();
@ -344,8 +338,7 @@ bool Foam::sampledCuttingPlane::update()
if (debug) if (debug)
{ {
Pout<< "sampledCuttingPlane::update :" Pout<< "sampledCuttingPlane::update :"
<< " have-facesPtr_:" << facesPtr_.valid() << " needsUpdate:" << needsUpdate_ << endl;
<< " needsUpdate_:" << needsUpdate_ << endl;
} }
if (!needsUpdate_) if (!needsUpdate_)

View File

@ -96,9 +96,6 @@ class sampledCuttingPlane
//autoPtr<isoSurfaceCell> isoSurfPtr_; //autoPtr<isoSurfaceCell> isoSurfPtr_;
autoPtr<isoSurface> isoSurfPtr_; autoPtr<isoSurface> isoSurfPtr_;
//- Triangles converted to faceList
mutable autoPtr<faceList> facesPtr_;
// Private Member Functions // Private Member Functions
@ -168,18 +165,7 @@ public:
//- Faces of surface //- Faces of surface
virtual const faceList& faces() const virtual const faceList& faces() const
{ {
if (facesPtr_.empty()) return surface().surfFaces();
{
const triSurface& s = surface();
facesPtr_.reset(new faceList(s.size()));
forAll(s, i)
{
facesPtr_()[i] = s[i].triFaceFace();
}
}
return facesPtr_;
} }
//- Const access to per-face zone/region information //- Const access to per-face zone/region information

View File

@ -65,7 +65,6 @@ namespace Foam
class nearestEqOp class nearestEqOp
{ {
public: public:
void operator()(nearInfo& x, const nearInfo& y) const void operator()(nearInfo& x, const nearInfo& y) const
@ -110,6 +109,7 @@ Foam::sampledTriSurfaceMesh::nonCoupledboundaryTree() const
treeBoundBox overallBb(mesh().points()); treeBoundBox overallBb(mesh().points());
Random rndGen(123456); Random rndGen(123456);
// Extend slightly and make 3D
overallBb = overallBb.extend(rndGen, 1e-4); overallBb = overallBb.extend(rndGen, 1e-4);
overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
@ -189,7 +189,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
{ {
if (cellTree.bb().contains(fc[triI])) if (cellTree.bb().contains(fc[triI]))
{ {
label index = cellTree.findInside(fc[triI]); const label index = cellTree.findInside(fc[triI]);
if (index != -1) if (index != -1)
{ {
nearest[triI].first() = 0.0; nearest[triI].first() = 0.0;
@ -535,6 +535,7 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
) )
: :
sampledSurface(name, mesh), sampledSurface(name, mesh),
MeshStorage(),
surface_ surface_
( (
IOobject IOobject
@ -565,6 +566,7 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
) )
: :
sampledSurface(name, mesh, dict), sampledSurface(name, mesh, dict),
MeshStorage(),
surface_ surface_
( (
IOobject IOobject
@ -596,6 +598,7 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
) )
: :
sampledSurface(name, mesh), sampledSurface(name, mesh),
MeshStorage(),
surface_ surface_
( (
IOobject IOobject