Skip to content
Snippets Groups Projects
Commit dc8179f5 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: add some storage queries to PrimitivePatch

- for quantities such as face area/normals etc, it can be useful to
  calculate directly and avoid the overhead of caching all the values.

STYLE: comments, use HashTable lookup() method in whichPoint()
parent d1caaa05
Branches
Tags
No related merge requests found
...@@ -498,17 +498,8 @@ whichPoint ...@@ -498,17 +498,8 @@ whichPoint
const label gp const label gp
) const ) const
{ {
Map<label>::const_iterator fnd = meshPointMap().find(gp); // The point found, or -1 if not found
return meshPointMap().lookup(gp, -1);
if (fnd != meshPointMap().end())
{
return fnd();
}
else
{
// Not found
return -1;
}
} }
......
...@@ -3,7 +3,7 @@ ...@@ -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 | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -152,8 +152,8 @@ private: ...@@ -152,8 +152,8 @@ private:
//- Labels of mesh points //- Labels of mesh points
mutable labelList* meshPointsPtr_; mutable labelList* meshPointsPtr_;
//- Mesh point map. Given the global point index find its //- Mesh point map. Given the global point index find its
//location in the patch //- location in the patch
mutable Map<label>* meshPointMapPtr_; mutable Map<label>* meshPointMapPtr_;
//- Outside edge loops //- Outside edge loops
...@@ -301,7 +301,7 @@ public: ...@@ -301,7 +301,7 @@ public:
} }
// Access functions for demand driven data // Access functions for demand-driven data
// Topological data; no mesh required. // Topological data; no mesh required.
...@@ -329,8 +329,7 @@ public: ...@@ -329,8 +329,7 @@ public:
return edgei < nInternalEdges(); return edgei < nInternalEdges();
} }
//- Return list of boundary points, //- Return list of boundary points, address into LOCAL point list
// address into LOCAL point list
const labelList& boundaryPoints() const; const labelList& boundaryPoints() const;
//- Return face-face addressing //- Return face-face addressing
...@@ -354,13 +353,13 @@ public: ...@@ -354,13 +353,13 @@ public:
// Addressing into mesh // Addressing into mesh
//- Return labelList of mesh points in patch. They are constructed //- Return labelList of mesh points in patch.
// walking through the faces in incremental order and not sorted // They are constructed by walking through the faces in
// anymore. // incremental order and not sorted anymore.
const labelList& meshPoints() const; const labelList& meshPoints() const;
//- Mesh point map. Given the global point index find its //- Mesh point map.
// location in the patch // Given the global point index find its location in the patch
const Map<label>& meshPointMap() const; const Map<label>& meshPointMap() const;
//- Return pointField of points in patch //- Return pointField of points in patch
...@@ -374,11 +373,11 @@ public: ...@@ -374,11 +373,11 @@ public:
label whichPoint(const label gp) const; label whichPoint(const label gp) const;
//- Given an edge in local point labels, return its //- Given an edge in local point labels, return its
// index in the edge list. If the edge is not found, return -1 //- index in the edge list. If the edge is not found, return -1
label whichEdge(const edge&) const; label whichEdge(const edge&) const;
//- Return labels of patch edges in the global edge list using //- Return labels of patch edges in the global edge list using
// cell addressing //- cell addressing
labelList meshEdges labelList meshEdges
( (
const edgeList& allEdges, const edgeList& allEdges,
...@@ -387,7 +386,7 @@ public: ...@@ -387,7 +386,7 @@ public:
) const; ) const;
//- Return labels of patch edges in the global edge list using //- Return labels of patch edges in the global edge list using
// basic edge addressing. //- basic edge addressing.
labelList meshEdges labelList meshEdges
( (
const edgeList& allEdges, const edgeList& allEdges,
...@@ -410,6 +409,14 @@ public: ...@@ -410,6 +409,14 @@ public:
const Field<PointType>& pointNormals() const; const Field<PointType>& pointNormals() const;
// Storage Management
inline bool hasFaceAreas() const { return faceAreasPtr_; }
inline bool hasFaceCentres() const { return faceCentresPtr_; }
inline bool hasFaceNormals() const { return faceNormalsPtr_; }
inline bool hasPointNormals() const { return pointNormalsPtr_; }
// Other patch operations // Other patch operations
//- Project vertices of patch onto another patch //- Project vertices of patch onto another patch
...@@ -475,7 +482,7 @@ public: ...@@ -475,7 +482,7 @@ public:
virtual void movePoints(const Field<PointType>&); virtual void movePoints(const Field<PointType>&);
// Member operators // Member Operators
//- Assignment //- Assignment
void operator= void operator=
......
...@@ -60,8 +60,7 @@ calcAddressing() const ...@@ -60,8 +60,7 @@ calcAddressing() const
if (edgesPtr_ || faceFacesPtr_ || edgeFacesPtr_ || faceEdgesPtr_) if (edgesPtr_ || faceFacesPtr_ || edgeFacesPtr_ || faceEdgesPtr_)
{ {
// it is considered an error to attempt to recalculate // An error to recalculate if already allocated
// if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "addressing already calculated" << "addressing already calculated"
<< abort(FatalError); << abort(FatalError);
......
...@@ -46,10 +46,9 @@ calcBdryPoints() const ...@@ -46,10 +46,9 @@ calcBdryPoints() const
if (boundaryPointsPtr_) if (boundaryPointsPtr_)
{ {
// it is considered an error to attempt to recalculate // Error to recalculate if already allocated
// if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "edge types already calculated" << "boundaryPoints already calculated"
<< abort(FatalError); << abort(FatalError);
} }
......
...@@ -50,8 +50,7 @@ calcEdgeLoops() const ...@@ -50,8 +50,7 @@ calcEdgeLoops() const
if (edgeLoopsPtr_) if (edgeLoopsPtr_)
{ {
// it is considered an error to attempt to recalculate // An error to recalculate if already allocated
// if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "edge loops already calculated" << "edge loops already calculated"
<< abort(FatalError); << abort(FatalError);
......
...@@ -56,8 +56,7 @@ calcLocalPointOrder() const ...@@ -56,8 +56,7 @@ calcLocalPointOrder() const
if (localPointOrderPtr_) if (localPointOrderPtr_)
{ {
// it is considered an error to attempt to recalculate // An error to recalculate if already allocated
// if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "local point order already calculated" << "local point order already calculated"
<< abort(FatalError); << abort(FatalError);
......
...@@ -47,10 +47,9 @@ calcMeshData() const ...@@ -47,10 +47,9 @@ calcMeshData() const
<< endl; << endl;
} }
// It is considered an error to attempt to recalculate meshPoints
// if they have already been calculated.
if (meshPointsPtr_ || localFacesPtr_) if (meshPointsPtr_ || localFacesPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "meshPointsPtr_ or localFacesPtr_ already allocated" << "meshPointsPtr_ or localFacesPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
...@@ -157,10 +156,9 @@ calcMeshPointMap() const ...@@ -157,10 +156,9 @@ calcMeshPointMap() const
<< endl; << endl;
} }
// It is considered an error to attempt to recalculate meshPoints
// if they have already been calculated.
if (meshPointMapPtr_) if (meshPointMapPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "meshPointMapPtr_ already allocated" << "meshPointMapPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
...@@ -205,10 +203,9 @@ calcLocalPoints() const ...@@ -205,10 +203,9 @@ calcLocalPoints() const
<< endl; << endl;
} }
// It is considered an error to attempt to recalculate localPoints
// if they have already been calculated.
if (localPointsPtr_) if (localPointsPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "localPointsPtr_ already allocated" << "localPointsPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
...@@ -254,10 +251,9 @@ calcPointNormals() const ...@@ -254,10 +251,9 @@ calcPointNormals() const
<< endl; << endl;
} }
// It is considered an error to attempt to recalculate pointNormals
// if they have already been calculated.
if (pointNormalsPtr_) if (pointNormalsPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "pointNormalsPtr_ already allocated" << "pointNormalsPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
...@@ -318,10 +314,9 @@ calcFaceCentres() const ...@@ -318,10 +314,9 @@ calcFaceCentres() const
<< endl; << endl;
} }
// It is considered an error to attempt to recalculate faceCentres
// if they have already been calculated.
if (faceCentresPtr_) if (faceCentresPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "faceCentresPtr_ already allocated" << "faceCentresPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
...@@ -365,9 +360,9 @@ calcMagFaceAreas() const ...@@ -365,9 +360,9 @@ calcMagFaceAreas() const
<< endl; << endl;
} }
// It is an error to calculate these more than once.
if (magFaceAreasPtr_) if (magFaceAreasPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "magFaceAreasPtr_ already allocated" << "magFaceAreasPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
...@@ -410,10 +405,9 @@ calcFaceAreas() const ...@@ -410,10 +405,9 @@ calcFaceAreas() const
<< endl; << endl;
} }
// It is considered an error to attempt to recalculate faceNormals
// if they have already been calculated.
if (faceAreasPtr_) if (faceAreasPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "faceAreasPtr_ already allocated" << "faceAreasPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
...@@ -457,10 +451,9 @@ calcFaceNormals() const ...@@ -457,10 +451,9 @@ calcFaceNormals() const
<< endl; << endl;
} }
// It is considered an error to attempt to recalculate faceNormals
// if they have already been calculated.
if (faceNormalsPtr_) if (faceNormalsPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "faceNormalsPtr_ already allocated" << "faceNormalsPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
......
...@@ -51,8 +51,7 @@ calcPointEdges() const ...@@ -51,8 +51,7 @@ calcPointEdges() const
if (pointEdgesPtr_) if (pointEdgesPtr_)
{ {
// it is considered an error to attempt to recalculate // An error to recalculate if already allocated
// if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "pointEdges already calculated" << "pointEdges already calculated"
<< abort(FatalError); << abort(FatalError);
...@@ -89,8 +88,7 @@ calcPointFaces() const ...@@ -89,8 +88,7 @@ calcPointFaces() const
if (pointFacesPtr_) if (pointFacesPtr_)
{ {
// it is considered an error to attempt to recalculate // An error to recalculate if already allocated
// if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "pointFaces already calculated" << "pointFaces already calculated"
<< abort(FatalError); << abort(FatalError);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment