mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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()
This commit is contained in:
@ -498,17 +498,8 @@ whichPoint
|
||||
const label gp
|
||||
) const
|
||||
{
|
||||
Map<label>::const_iterator fnd = meshPointMap().find(gp);
|
||||
|
||||
if (fnd != meshPointMap().end())
|
||||
{
|
||||
return fnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not found
|
||||
return -1;
|
||||
}
|
||||
// The point found, or -1 if not found
|
||||
return meshPointMap().lookup(gp, -1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -152,8 +152,8 @@ private:
|
||||
//- Labels of mesh points
|
||||
mutable labelList* meshPointsPtr_;
|
||||
|
||||
//- Mesh point map. Given the global point index find its
|
||||
//location in the patch
|
||||
//- Mesh point map. Given the global point index find its
|
||||
//- location in the patch
|
||||
mutable Map<label>* meshPointMapPtr_;
|
||||
|
||||
//- Outside edge loops
|
||||
@ -301,7 +301,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// Access functions for demand driven data
|
||||
// Access functions for demand-driven data
|
||||
|
||||
// Topological data; no mesh required.
|
||||
|
||||
@ -329,8 +329,7 @@ public:
|
||||
return edgei < nInternalEdges();
|
||||
}
|
||||
|
||||
//- Return list of boundary points,
|
||||
// address into LOCAL point list
|
||||
//- Return list of boundary points, address into LOCAL point list
|
||||
const labelList& boundaryPoints() const;
|
||||
|
||||
//- Return face-face addressing
|
||||
@ -354,13 +353,13 @@ public:
|
||||
|
||||
// Addressing into mesh
|
||||
|
||||
//- Return labelList of mesh points in patch. They are constructed
|
||||
// walking through the faces in incremental order and not sorted
|
||||
// anymore.
|
||||
//- Return labelList of mesh points in patch.
|
||||
// They are constructed by walking through the faces in
|
||||
// incremental order and not sorted anymore.
|
||||
const labelList& meshPoints() const;
|
||||
|
||||
//- Mesh point map. Given the global point index find its
|
||||
// location in the patch
|
||||
//- Mesh point map.
|
||||
// Given the global point index find its location in the patch
|
||||
const Map<label>& meshPointMap() const;
|
||||
|
||||
//- Return pointField of points in patch
|
||||
@ -374,11 +373,11 @@ public:
|
||||
label whichPoint(const label gp) const;
|
||||
|
||||
//- 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;
|
||||
|
||||
//- Return labels of patch edges in the global edge list using
|
||||
// cell addressing
|
||||
//- cell addressing
|
||||
labelList meshEdges
|
||||
(
|
||||
const edgeList& allEdges,
|
||||
@ -387,7 +386,7 @@ public:
|
||||
) const;
|
||||
|
||||
//- Return labels of patch edges in the global edge list using
|
||||
// basic edge addressing.
|
||||
//- basic edge addressing.
|
||||
labelList meshEdges
|
||||
(
|
||||
const edgeList& allEdges,
|
||||
@ -410,6 +409,14 @@ public:
|
||||
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
|
||||
|
||||
//- Project vertices of patch onto another patch
|
||||
@ -475,7 +482,7 @@ public:
|
||||
virtual void movePoints(const Field<PointType>&);
|
||||
|
||||
|
||||
// Member operators
|
||||
// Member Operators
|
||||
|
||||
//- Assignment
|
||||
void operator=
|
||||
|
||||
@ -60,8 +60,7 @@ calcAddressing() const
|
||||
|
||||
if (edgesPtr_ || faceFacesPtr_ || edgeFacesPtr_ || faceEdgesPtr_)
|
||||
{
|
||||
// it is considered an error to attempt to recalculate
|
||||
// if already allocated
|
||||
// An error to recalculate if already allocated
|
||||
FatalErrorInFunction
|
||||
<< "addressing already calculated"
|
||||
<< abort(FatalError);
|
||||
|
||||
@ -46,10 +46,9 @@ calcBdryPoints() const
|
||||
|
||||
if (boundaryPointsPtr_)
|
||||
{
|
||||
// it is considered an error to attempt to recalculate
|
||||
// if already allocated
|
||||
// Error to recalculate if already allocated
|
||||
FatalErrorInFunction
|
||||
<< "edge types already calculated"
|
||||
<< "boundaryPoints already calculated"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
|
||||
@ -50,8 +50,7 @@ calcEdgeLoops() const
|
||||
|
||||
if (edgeLoopsPtr_)
|
||||
{
|
||||
// it is considered an error to attempt to recalculate
|
||||
// if already allocated
|
||||
// An error to recalculate if already allocated
|
||||
FatalErrorInFunction
|
||||
<< "edge loops already calculated"
|
||||
<< abort(FatalError);
|
||||
|
||||
@ -56,8 +56,7 @@ calcLocalPointOrder() const
|
||||
|
||||
if (localPointOrderPtr_)
|
||||
{
|
||||
// it is considered an error to attempt to recalculate
|
||||
// if already allocated
|
||||
// An error to recalculate if already allocated
|
||||
FatalErrorInFunction
|
||||
<< "local point order already calculated"
|
||||
<< abort(FatalError);
|
||||
|
||||
@ -47,10 +47,9 @@ calcMeshData() const
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// It is considered an error to attempt to recalculate meshPoints
|
||||
// if they have already been calculated.
|
||||
if (meshPointsPtr_ || localFacesPtr_)
|
||||
{
|
||||
// An error to recalculate if already allocated
|
||||
FatalErrorInFunction
|
||||
<< "meshPointsPtr_ or localFacesPtr_ already allocated"
|
||||
<< abort(FatalError);
|
||||
@ -157,10 +156,9 @@ calcMeshPointMap() const
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// It is considered an error to attempt to recalculate meshPoints
|
||||
// if they have already been calculated.
|
||||
if (meshPointMapPtr_)
|
||||
{
|
||||
// An error to recalculate if already allocated
|
||||
FatalErrorInFunction
|
||||
<< "meshPointMapPtr_ already allocated"
|
||||
<< abort(FatalError);
|
||||
@ -205,10 +203,9 @@ calcLocalPoints() const
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// It is considered an error to attempt to recalculate localPoints
|
||||
// if they have already been calculated.
|
||||
if (localPointsPtr_)
|
||||
{
|
||||
// An error to recalculate if already allocated
|
||||
FatalErrorInFunction
|
||||
<< "localPointsPtr_ already allocated"
|
||||
<< abort(FatalError);
|
||||
@ -254,10 +251,9 @@ calcPointNormals() const
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// It is considered an error to attempt to recalculate pointNormals
|
||||
// if they have already been calculated.
|
||||
if (pointNormalsPtr_)
|
||||
{
|
||||
// An error to recalculate if already allocated
|
||||
FatalErrorInFunction
|
||||
<< "pointNormalsPtr_ already allocated"
|
||||
<< abort(FatalError);
|
||||
@ -318,10 +314,9 @@ calcFaceCentres() const
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// It is considered an error to attempt to recalculate faceCentres
|
||||
// if they have already been calculated.
|
||||
if (faceCentresPtr_)
|
||||
{
|
||||
// An error to recalculate if already allocated
|
||||
FatalErrorInFunction
|
||||
<< "faceCentresPtr_ already allocated"
|
||||
<< abort(FatalError);
|
||||
@ -365,9 +360,9 @@ calcMagFaceAreas() const
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// It is an error to calculate these more than once.
|
||||
if (magFaceAreasPtr_)
|
||||
{
|
||||
// An error to recalculate if already allocated
|
||||
FatalErrorInFunction
|
||||
<< "magFaceAreasPtr_ already allocated"
|
||||
<< abort(FatalError);
|
||||
@ -410,10 +405,9 @@ calcFaceAreas() const
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// It is considered an error to attempt to recalculate faceNormals
|
||||
// if they have already been calculated.
|
||||
if (faceAreasPtr_)
|
||||
{
|
||||
// An error to recalculate if already allocated
|
||||
FatalErrorInFunction
|
||||
<< "faceAreasPtr_ already allocated"
|
||||
<< abort(FatalError);
|
||||
@ -457,10 +451,9 @@ calcFaceNormals() const
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// It is considered an error to attempt to recalculate faceNormals
|
||||
// if they have already been calculated.
|
||||
if (faceNormalsPtr_)
|
||||
{
|
||||
// An error to recalculate if already allocated
|
||||
FatalErrorInFunction
|
||||
<< "faceNormalsPtr_ already allocated"
|
||||
<< abort(FatalError);
|
||||
|
||||
@ -51,8 +51,7 @@ calcPointEdges() const
|
||||
|
||||
if (pointEdgesPtr_)
|
||||
{
|
||||
// it is considered an error to attempt to recalculate
|
||||
// if already allocated
|
||||
// An error to recalculate if already allocated
|
||||
FatalErrorInFunction
|
||||
<< "pointEdges already calculated"
|
||||
<< abort(FatalError);
|
||||
@ -89,8 +88,7 @@ calcPointFaces() const
|
||||
|
||||
if (pointFacesPtr_)
|
||||
{
|
||||
// it is considered an error to attempt to recalculate
|
||||
// if already allocated
|
||||
// An error to recalculate if already allocated
|
||||
FatalErrorInFunction
|
||||
<< "pointFaces already calculated"
|
||||
<< abort(FatalError);
|
||||
|
||||
Reference in New Issue
Block a user