diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C index 5cc8103d9c1df63f2f5607d5c67695c70c77f016..d82ca60a81a8bd539870a09d49c6fff891bad4a7 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C @@ -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); } diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.H b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.H index 893274dd25cfe4bc8693905c6823c4e7118f7184..b98ceb520756f0a1e430a5036be0b2b4036441cf 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.H +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.H @@ -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= diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C index bbfcad9f2dac66add314d93a4477d15b71d12b98..f95ecfe35fba31510164091fe0707ab9da26bfd2 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C @@ -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); diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchBdryPoints.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchBdryPoints.C index 96516bfa0965c1fc48ce6bba9a929ca1d2453920..01e4e69662ea916a782dad70065bf51884335e56 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchBdryPoints.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchBdryPoints.C @@ -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); } diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C index 48094cce32ca0ed649f42d0d94964690cf0af5dd..1e0ccb4f438f9b49715137637fab6041c8676dd4 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C @@ -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); diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchLocalPointOrder.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchLocalPointOrder.C index 2a6ab9621a4987f063cc937b922710910a81db1a..235c1fec65ea9ed3dbae9d046a5ab5e3110dda38 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchLocalPointOrder.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchLocalPointOrder.C @@ -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); diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchMeshData.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchMeshData.C index 9a76270169c9c7e4de2a84777819fef9cc5d2318..9e4fab2405831de8fd3afc944bd44cb90d5e526f 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchMeshData.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchMeshData.C @@ -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); diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchPointAddressing.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchPointAddressing.C index 212396e419b0ee8064ec8cb5c90c6381e09a5d76..3e11f57425a84f50cee15fbb9fa929cfbc23d6ac 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchPointAddressing.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchPointAddressing.C @@ -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);