From 9433898941cf30fe6e02bcf6f56c42a8b5d0c1b8 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 13 Oct 2022 11:23:35 +0200 Subject: [PATCH] ENH: support construction of pointIndexHit from pointHit STYLE: combine templated/non-templated headers (reduced clutter) STYLE: use hitPoint(const point&) combined setter - same as setHit() + setPoint(const point&) ENH: expose and use labelOctBits::pack method for addressing --- .../controlMeshRefinement.C | 4 +- .../dynamicIndexedOctree.C | 14 +- .../algorithms/indexedOctree/indexedOctree.C | 13 +- .../algorithms/indexedOctree/labelBits.H | 100 ++++-- .../algorithms/indexedOctree/volumeType.H | 2 +- .../Identifiers/LabelledItem/LabelledItem.H | 42 ++- .../Identifiers/LabelledItem/LabelledItemI.H | 66 ---- .../meshes/meshShapes/face/faceIntersection.C | 9 +- .../PrimitivePatchProjectPoints.C | 2 +- .../meshes/primitiveShapes/line/line.H | 2 +- .../primitiveShapes/objectHit/PointHit.H | 241 -------------- .../primitiveShapes/objectHit/PointIndexHit.H | 312 ------------------ .../objectHit/compat/PointHit.H | 11 + .../objectHit/compat/PointIndexHit.H | 11 + .../primitiveShapes/objectHit/objectHit.H | 24 +- .../primitiveShapes/objectHit/pointHit.H | 223 ++++++++++++- .../primitiveShapes/objectHit/pointIndexHit.H | 293 +++++++++++++++- .../objectHit/pointIndexHitIOList.H | 4 +- .../primitiveShapes/triangle/triangleI.H | 12 +- .../turbulentDFSEMInletFvPatchVectorField.C | 6 +- .../searchableCone/searchableCone.C | 9 +- .../searchableCylinder/searchableCylinder.C | 9 +- .../searchableSphere/searchableSphere.C | 3 +- .../searchableSurfaceCollection.C | 3 +- .../faceSources/regionToFace/regionToFace.C | 3 +- .../faceTriangulation/faceTriangulation.C | 3 +- .../triSurfaceTools/triSurfaceTools.C | 15 +- .../distributedTriSurfaceMesh.C | 4 +- .../surface/isoSurface/isoSurfaceCell.C | 9 +- 29 files changed, 689 insertions(+), 760 deletions(-) delete mode 100644 src/OpenFOAM/containers/Identifiers/LabelledItem/LabelledItemI.H delete mode 100644 src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H delete mode 100644 src/OpenFOAM/meshes/primitiveShapes/objectHit/PointIndexHit.H create mode 100644 src/OpenFOAM/meshes/primitiveShapes/objectHit/compat/PointHit.H create mode 100644 src/OpenFOAM/meshes/primitiveShapes/objectHit/compat/PointIndexHit.H diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C index 72fd134043..02d5d1709e 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C @@ -92,9 +92,7 @@ bool Foam::controlMeshRefinement::detectEdge magSqr(a - b) < tolSqr ) { - pointFound.setPoint(midPoint); - pointFound.setHit(); - + pointFound.hitPoint(midPoint); return true; } diff --git a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C index 2998a768db..9fbe9cc0d0 100644 --- a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C +++ b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C @@ -365,7 +365,7 @@ Foam::volumeType Foam::dynamicIndexedOctree::calcVolumeType } // Store octant type - nodeTypes_.set((nodeI<<3)+octant, subType); + nodeTypes_.set(labelBits::pack(nodeI, octant), subType); // Combine sub node types into type for treeNode. Result is 'mixed' if // types differ among subnodes. @@ -393,7 +393,11 @@ Foam::volumeType Foam::dynamicIndexedOctree::getVolumeType direction octant = nod.bb_.subOctant(sample); - volumeType octantType = volumeType::type(nodeTypes_.get((nodeI<<3)+octant)); + volumeType octantType = + volumeType::type + ( + nodeTypes_.get(labelBits::pack(nodeI, octant)) + ); if (octantType == volumeType::INSIDE) { @@ -1418,9 +1422,8 @@ void Foam::dynamicIndexedOctree::traverseNode { // Hit so pt is nearer than nearestPoint. // Update hit info - hitInfo.setHit(); + hitInfo.hitPoint(pt); hitInfo.setIndex(shapeI); - hitInfo.setPoint(pt); return; } } @@ -1456,9 +1459,8 @@ void Foam::dynamicIndexedOctree::traverseNode // Hit so pt is nearer than nearestPoint. nearestPoint = pt; // Update hit info - hitInfo.setHit(); + hitInfo.hitPoint(pt); hitInfo.setIndex(shapeI); - hitInfo.setPoint(pt); } } diff --git a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C index a9c99e965d..463fa65d8e 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C +++ b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C @@ -383,7 +383,7 @@ Foam::volumeType Foam::indexedOctree::calcVolumeType } // Store octant type - nodeTypes_.set((nodeI<<3)+octant, subType); + nodeTypes_.set(labelBits::pack(nodeI, octant), subType); // Combine sub node types into type for treeNode. Result is 'mixed' if // types differ among subnodes. @@ -411,7 +411,10 @@ Foam::volumeType Foam::indexedOctree::getVolumeType direction octant = nod.bb_.subOctant(sample); - volumeType octantType = volumeType::type(nodeTypes_.get((nodeI<<3)+octant)); + volumeType octantType = volumeType::type + ( + nodeTypes_.get(labelBits::pack(nodeI, octant)) + ); if (octantType == volumeType::INSIDE) { @@ -1448,9 +1451,8 @@ void Foam::indexedOctree::traverseNode { // Hit so pt is nearer than nearestPoint. // Update hit info - hitInfo.setHit(); + hitInfo.hitPoint(pt); hitInfo.setIndex(shapeI); - hitInfo.setPoint(pt); return; } } @@ -1480,9 +1482,8 @@ void Foam::indexedOctree::traverseNode // Hit so pt is nearer than nearestPoint. nearestPoint = pt; // Update hit info - hitInfo.setHit(); + hitInfo.hitPoint(pt); hitInfo.setIndex(shapeI); - hitInfo.setPoint(pt); } } diff --git a/src/OpenFOAM/algorithms/indexedOctree/labelBits.H b/src/OpenFOAM/algorithms/indexedOctree/labelBits.H index 86ca89028a..bddbe8801c 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/labelBits.H +++ b/src/OpenFOAM/algorithms/indexedOctree/labelBits.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,17 +28,15 @@ Class Foam::labelBits Description - A 29bits label and 3bits direction packed into single label - -SourceFiles + A 29bits (or 61bits) integer label with 3bits direction + (eg, octant) packed into single label \*---------------------------------------------------------------------------*/ -#ifndef labelBits_H -#define labelBits_H +#ifndef Foam_labelBits_H +#define Foam_labelBits_H #include "label.H" -//#include "uLabel.H" #include "direction.H" #include "error.H" @@ -46,20 +45,33 @@ SourceFiles namespace Foam { +// Forward Declarations +class labelBits; /*---------------------------------------------------------------------------*\ - Class labelBits Declaration + Class labelBits Declaration \*---------------------------------------------------------------------------*/ class labelBits { - // Private data + // Private Data + //- Integer value and (octant) direction label data_; - inline static label pack(const label val, const direction bits) +public: + + // Static Functions + + #ifdef FULLDEBUG + + //- Pack integer value and bits (octant) into a label + inline static label pack + ( + const label val, + const direction bits + ) { - #ifdef FULLDEBUG if (bits > 7 || (((val<<3)>>3) != val)) { FatalErrorInFunction @@ -68,51 +80,64 @@ class labelBits << label(8*sizeof(label)-3) << " bit representation" << abort(FatalError); } - #endif - return (val<<3) | bits; } -public: + #else + + //- Pack integer value and bits (octant) into a label + static constexpr label pack + ( + const label val, + const direction bits + ) noexcept + { + return (val<<3) | bits; + } + + #endif + // Constructors - //- Construct null - inline labelBits() + //- Default construct as zero initialized + constexpr labelBits() noexcept + : + data_(0) {} //- Construct from components - inline labelBits(const label val, const direction bits) + labelBits(const label val, const direction bits) : data_(pack(val, bits)) {} - //- Construct from Istream - inline labelBits(Istream& is) + //- Read construct from Istream + explicit labelBits(Istream& is) { is >> data_; } - // Member Functions - inline label val() const - { - return data_ >> 3; - } + //- The raw data value + label data() const noexcept { return data_; } - inline direction bits() const - { - return data_ & 7; - } + //- Return the integer value + label val() const noexcept { return (data_ >> 3); } - inline void setVal(const label val) + //- Return the octant direction + direction bits() const noexcept { return (data_ & 7); } + + //- Set the integer value + void setVal(const label val) { data_ = pack(val, bits()); } - inline void setBits(const direction bits) + //- Set the octant direction + void setBits(const direction bits) { data_ = pack(val(), bits); } @@ -120,26 +145,31 @@ public: // Member Operators - inline friend bool operator==(const labelBits& a, const labelBits& b) + inline friend + bool operator==(const labelBits& a, const labelBits& b) { return a.data_ == b.data_; } - inline friend bool operator!=(const labelBits& a, const labelBits& b) + inline friend + bool operator!=(const labelBits& a, const labelBits& b) { return !(a == b); } + // IOstream Operators - inline friend Istream& operator>>(Istream& is, labelBits& lb) + inline friend + Istream& operator>>(Istream& is, labelBits& rhs) { - return is >> lb.data_; + return is >> rhs.data_; } - inline friend Ostream& operator<<(Ostream& os, const labelBits& lb) + inline friend + Ostream& operator<<(Ostream& os, const labelBits& rhs) { - return os << lb.data_; + return os << rhs.data_; } }; diff --git a/src/OpenFOAM/algorithms/indexedOctree/volumeType.H b/src/OpenFOAM/algorithms/indexedOctree/volumeType.H index 8851b823e1..3b1486511a 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/volumeType.H +++ b/src/OpenFOAM/algorithms/indexedOctree/volumeType.H @@ -107,7 +107,7 @@ public: //- Construct from integer explicit volumeType(const int t) : - t_(static_cast(t)) + t_(static_cast(t & 0x3)) {} diff --git a/src/OpenFOAM/containers/Identifiers/LabelledItem/LabelledItem.H b/src/OpenFOAM/containers/Identifiers/LabelledItem/LabelledItem.H index 6d9fc14295..aae274df6d 100644 --- a/src/OpenFOAM/containers/Identifiers/LabelledItem/LabelledItem.H +++ b/src/OpenFOAM/containers/Identifiers/LabelledItem/LabelledItem.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,10 +40,11 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef LabelledItem_H -#define LabelledItem_H +#ifndef Foam_LabelledItem_H +#define Foam_LabelledItem_H #include "label.H" +#include "IOstreams.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -161,9 +162,40 @@ public: } // End namespace Foam -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template +inline Foam::Istream& Foam::operator>> +( + Istream& is, + LabelledItem& item +) +{ + is.readBegin("LabelledItem"); + is >> static_cast(item) >> item.index(); + is.readEnd("LabelledItem"); + + is.check(FUNCTION_NAME); + return is; +} + + +template +inline Foam::Ostream& Foam::operator<< +( + Ostream& os, + const LabelledItem& item +) +{ + // Output like Tuple2 + os << token::BEGIN_LIST + << static_cast(item) << token::SPACE + << item.index() + << token::END_LIST; + + return os; +} -#include "LabelledItemI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/Identifiers/LabelledItem/LabelledItemI.H b/src/OpenFOAM/containers/Identifiers/LabelledItem/LabelledItemI.H deleted file mode 100644 index d4061413ac..0000000000 --- a/src/OpenFOAM/containers/Identifiers/LabelledItem/LabelledItemI.H +++ /dev/null @@ -1,66 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2021 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "IOstreams.H" - -// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // - -template -inline Foam::Istream& Foam::operator>> -( - Istream& is, - LabelledItem& item -) -{ - is.readBegin("LabelledItem"); - is >> static_cast(item) >> item.index(); - is.readEnd("LabelledItem"); - - is.check(FUNCTION_NAME); - return is; -} - - -template -inline Foam::Ostream& Foam::operator<< -( - Ostream& os, - const LabelledItem& item -) -{ - // Output like Tuple2 - os << token::BEGIN_LIST - << static_cast(item) << token::SPACE - << item.index() - << token::END_LIST; - - return os; -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceIntersection.C b/src/OpenFOAM/meshes/meshShapes/face/faceIntersection.C index b5c00bd97b..92426d3688 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/faceIntersection.C +++ b/src/OpenFOAM/meshes/meshShapes/face/faceIntersection.C @@ -94,8 +94,7 @@ Foam::pointHit Foam::face::ray if (Foam::mag(curHit.distance()) < Foam::mag(nearestHitDist)) { nearestHitDist = curHit.distance(); - nearest.setHit(); - nearest.setPoint(curHit.hitPoint()); + nearest.hitPoint(curHit.hitPoint()); } } else if (!nearest.hit()) @@ -181,8 +180,7 @@ Foam::pointHit Foam::face::intersection if (Foam::mag(curHit.distance()) < Foam::mag(nearestHitDist)) { nearestHitDist = curHit.distance(); - nearest.setHit(); - nearest.setPoint(curHit.hitPoint()); + nearest.hitPoint(curHit.hitPoint()); } } } @@ -295,8 +293,7 @@ Foam::pointHit Foam::face::nearestPointClassify if (curHit.hit()) { - nearest.setHit(); - nearest.setPoint(curHit.hitPoint()); + nearest.hitPoint(curHit.hitPoint()); } else { diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchProjectPoints.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchProjectPoints.C index 658bb7b5c3..a1d6f0822d 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchProjectPoints.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchProjectPoints.C @@ -31,7 +31,7 @@ Description \*---------------------------------------------------------------------------*/ #include "boolList.H" -#include "PointHit.H" +#include "pointHit.H" #include "objectHit.H" #include "bandCompression.H" diff --git a/src/OpenFOAM/meshes/primitiveShapes/line/line.H b/src/OpenFOAM/meshes/primitiveShapes/line/line.H index d1c0d436fd..9639264fd5 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/line/line.H +++ b/src/OpenFOAM/meshes/primitiveShapes/line/line.H @@ -41,7 +41,7 @@ SourceFiles #include "point.H" #include "point2D.H" #include "vector.H" -#include "PointHit.H" +#include "pointHit.H" #include "FixedList.H" #include "UList.H" #include "Pair.H" diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H deleted file mode 100644 index eda6232aa6..0000000000 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H +++ /dev/null @@ -1,241 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::PointHit - -Description - Describes the interaction of a face and a point. - It carries the info of a successful hit and (if successful) - the interaction point. - -\*---------------------------------------------------------------------------*/ - -#ifndef PointHit_H -#define PointHit_H - -#include "bool.H" -#include "point.H" -#include "token.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class PointHit Declaration -\*---------------------------------------------------------------------------*/ - -template -class PointHit -{ - // Private Data - - //- Point of hit; for miss holds best estimate outside the object - PointType point_; - - //- Distance to hit point - scalar distance_; - - //- Hit success - bool hit_; - - //- Eligible miss - bool eligibleMiss_; - - -public: - - // Public Typedefs - - //- The point type - typedef PointType point_type; - - - // Constructors - - //- Default construct. A zero point with a large distance, - //- no hit, no eligible misses - PointHit() - : - point_(Zero), - distance_(GREAT), - hit_(false), - eligibleMiss_(false) - {} - - //- Construct from point with a large distance, - //- no hit, no eligible misses - explicit PointHit(const point_type& p) - : - point_(p), - distance_(GREAT), - hit_(false), - eligibleMiss_(false) - {} - - //- Construct from components - PointHit - ( - const bool hit, - const point_type& p, - const scalar dist, - const bool eligibleMiss = false - ) - : - point_(p), - distance_(dist), - hit_(hit), - eligibleMiss_(eligibleMiss) - {} - - - // Member Functions - - // Access - - //- Is there a hit - bool hit() const noexcept - { - return hit_; - } - - //- Is this an eligible miss - bool eligibleMiss() const noexcept - { - return eligibleMiss_; - } - - //- Return the point, no checks - const point_type& point() const noexcept - { - return point_; - } - - //- Return distance to hit - scalar distance() const noexcept - { - return distance_; - } - - //- Return the hit point. Fatal if not hit. - const point_type& hitPoint() const - { - if (!hit_) - { - FatalErrorInFunction - << "Requested a hit point, but it was not hit" - << abort(FatalError); - } - - return point_; - } - - //- Return the miss point. Fatal if hit. - const point_type& missPoint() const - { - if (hit_) - { - FatalErrorInFunction - << "Requested a miss point, but it was hit" - << abort(FatalError); - } - - return point_; - } - - //- The point, no checks - // \deprecated(2020-10) use point() - const point_type& rawPoint() const noexcept - { - return point_; - } - - - // Edit - - //- Set the hit status \em on - void setHit() noexcept - { - hit_ = true; - eligibleMiss_ = false; - } - - //- Set the hit status \em off and set the eligible miss status - void setMiss(const bool eligible) noexcept - { - hit_ = false; - eligibleMiss_ = eligible; - } - - //- Set the point - void setPoint(const point_type& p) - { - point_ = p; - } - - //- Set the distance - void setDistance(const scalar d) noexcept - { - distance_ = d; - } - - - // Member Operators - - //- Distance comparision operator, for sorting - template - bool operator<(const PointHit& rhs) const noexcept - { - return distance_ < rhs.distance_; - } -}; - - -// Ostream Operator - -template -inline Ostream& operator<<(Ostream& os, const PointHit& pHit) -{ - os << pHit.hit() << token::SPACE - << pHit.point() << token::SPACE - << pHit.distance() << token::SPACE - << pHit.eligibleMiss(); - - return os; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointIndexHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointIndexHit.H deleted file mode 100644 index cf8ef91cba..0000000000 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointIndexHit.H +++ /dev/null @@ -1,312 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020-2022 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::PointIndexHit - -Description - This class describes the interaction of (usually) a face and a point. - It carries the info of a successful hit and (if successful), - returns the interaction point. - - like pointHit but carries face (or cell, edge etc.) index - -SourceFiles - -\*---------------------------------------------------------------------------*/ - -#ifndef PointIndexHit_H -#define PointIndexHit_H - -#include "bool.H" -#include "point.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// Forward Declarations -template class PointIndexHit; - -template -inline Istream& operator>>(Istream& is, PointIndexHit& pHit); - -template -inline Ostream& operator<<(Ostream& os, const PointIndexHit& pHit); - -/*---------------------------------------------------------------------------*\ - Class PointIndexHit Declaration -\*---------------------------------------------------------------------------*/ - -template -class PointIndexHit -{ - // Private Data - - //- Hit success - bool hit_; - - //- Point of hit; invalid for misses - PointType point_; - - //- Label of face hit - label index_; - - -public: - - // Public Typedefs - - //- The point type - typedef PointType point_type; - - - // Constructors - - //- Default construct. A zero point, with no hit and index = -1 - PointIndexHit() - : - hit_(false), - point_(Zero), - index_(-1) - {} - - //- Construct from a point, with no hit and index = -1 - explicit PointIndexHit(const point_type& p) - : - hit_(false), - point_(p), - index_(-1) - {} - - //- Construct from components - PointIndexHit - ( - const bool success, - const point_type& p, - const label index - ) - : - hit_(success), - point_(p), - index_(index) - {} - - //- Construct from Istream - explicit PointIndexHit(Istream& is) - { - is >> *this; - } - - - // Member Functions - - // Access - - //- Is there a hit? - bool hit() const noexcept - { - return hit_; - } - - //- Return the hit index - label index() const noexcept - { - return index_; - } - - //- Return point, no checks - const point_type& point() const noexcept - { - return point_; - } - - //- Access the point, no checks - point_type& point() noexcept - { - return point_; - } - - //- Return hit point. Fatal if not hit. - const point_type& hitPoint() const - { - if (!hit_) - { - FatalErrorInFunction - << "Requested a hit point, but it was not hit" - << abort(FatalError); - } - return point_; - } - - //- Return miss point. Fatal if hit. - const point_type& missPoint() const - { - if (hit_) - { - FatalErrorInFunction - << "Requested a miss point, but it was hit" - << abort(FatalError); - } - return point_; - } - - //- The point, no checks. Same as point() - const point_type& rawPoint() const noexcept - { - return point_; - } - - //- The point, no checks. Same as point() - point_type& rawPoint() noexcept - { - return point_; - } - - - // Edit - - //- Set the hit status \em on - void setHit() noexcept - { - hit_ = true; - } - - //- Set the hit status \em off - void setMiss() noexcept - { - hit_ = false; - } - - //- Set the point - void setPoint(const point_type& p) - { - point_ = p; - } - - //- Set the index - void setIndex(const label index) noexcept - { - index_ = index; - } - - //- Set the point as \em hit and the hit-index - void hitPoint(const point_type& p, const label index) - { - point_ = p; - hit_ = true; - index_ = index; - } - - - // Write - - void write(Ostream& os) - { - os << (hit_ ? "hit:" : "miss:") - << point_ << " index:" << index_; - } - - - // Member Operators - - //- Test for equality of all components - bool operator==(const PointIndexHit& rhs) const - { - return - ( - hit_ == rhs.hit_ - && index_ == rhs.index_ - && point_ == rhs.point_ - ); - } - - //- Test for inequality of components - bool operator!=(const PointIndexHit& rhs) const - { - return !(*this == rhs); - } - - - // IO Operators - - friend Ostream& operator<<(Ostream& os, const PointIndexHit& pHit) - { - if (os.format() == IOstreamOption::ASCII) - { - os << pHit.hit_ << token::SPACE - << pHit.point_ << token::SPACE - << pHit.index_; - } - else - { - os.write - ( - reinterpret_cast(&pHit), - sizeof(PointIndexHit) - ); - } - - os.check(FUNCTION_NAME); - return os; - } - - - friend Istream& operator>>(Istream& is, PointIndexHit& pHit) - { - if (is.format() == IOstreamOption::ASCII) - { - is >> pHit.hit_ >> pHit.point_ >> pHit.index_; - } - else - { - // TODO (2019-08-06): - // cannot properly handle mixed-precision reading - // owing to bool and Point type. - - is.read - ( - reinterpret_cast(&pHit), - sizeof(PointIndexHit) - ); - } - - is.check(FUNCTION_NAME); - return is; - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/compat/PointHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/compat/PointHit.H new file mode 100644 index 0000000000..66ac51fad3 --- /dev/null +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/compat/PointHit.H @@ -0,0 +1,11 @@ +// Compatibility include. +// PointHit template combined into pointHit.H (OCT-2022) + +#ifndef FoamCompat_PointHit_H +#define FoamCompat_PointHit_H + +#include "pointHit.H" + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/compat/PointIndexHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/compat/PointIndexHit.H new file mode 100644 index 0000000000..1d0930d8e1 --- /dev/null +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/compat/PointIndexHit.H @@ -0,0 +1,11 @@ +// Compatibility include. +// PointIndexHit template combined into pointIndexHit.H (OCT-2022) + +#ifndef FoamCompat_PointIndexHit_H +#define FoamCompat_PointIndexHit_H + +#include "pointIndexHit.H" + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H index e4217a0885..6251dfef54 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H @@ -33,8 +33,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef objectHit_H -#define objectHit_H +#ifndef Foam_objectHit_H +#define Foam_objectHit_H #include "bool.H" #include "label.H" @@ -44,6 +44,10 @@ Description namespace Foam { +// Forward Declarations +class objectHit; +inline Ostream& operator<<(Ostream& os, const objectHit& obj); + /*---------------------------------------------------------------------------*\ Class objectHit Declaration \*---------------------------------------------------------------------------*/ @@ -63,7 +67,7 @@ public: // Constructors - //- Default construct. Nothing hit and object = -1 + //- Default construct. Nothing hit and object index = -1 constexpr objectHit() noexcept : hit_(false), @@ -110,7 +114,7 @@ public: // Edit - //- Reset to default construct state + //- Reset to default construct state (false, -1) void reset() noexcept { hit_ = false; @@ -129,21 +133,27 @@ public: hit_ = false; } + //- Set the hit object index + void setIndex(const label index) noexcept + { + index_ = index; + } + // Ostream Operator inline friend Ostream& operator<<(Ostream& os, const objectHit& obj) { - return os << obj.hit() << token::SPACE << obj.hitObject(); + return os << obj.hit() << token::SPACE << obj.index(); } }; -// Global Operators +// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * // inline bool operator==(const objectHit& a, const objectHit& b) { - return a.hit() == b.hit() && a.hitObject() == b.hitObject(); + return a.hit() == b.hit() && a.index() == b.index(); } diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointHit.H index 2abae313e7..71eaf5b3dd 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointHit.H +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointHit.H @@ -5,7 +5,8 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2011 OpenFOAM Foundation + Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -23,27 +24,233 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Typedef - Foam::pointHit +Class + Foam::PointHit Description - A PointIndexHit for 3D points. + Describes the interaction of a object and a (templated) point. + It carries the info of a successful hit and (if successful) + the interaction point. \*---------------------------------------------------------------------------*/ -#ifndef pointHit_H -#define pointHit_H +#ifndef Foam_pointHit_H +#define Foam_pointHit_H +#include "bool.H" #include "point.H" -#include "PointHit.H" +#include "token.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - typedef PointHit pointHit; + +// Forward Declarations +template class PointHit; + + +// Standard Types + +//- A PointHit with a 3D point +typedef PointHit pointHit; + + +/*---------------------------------------------------------------------------*\ + Class PointHit Declaration +\*---------------------------------------------------------------------------*/ + +template +class PointHit +{ + // Private Data + + //- Point of hit; for miss holds best estimate outside the object + PointType point_; + + //- Distance to hit point + scalar distance_; + + //- Hit success + bool hit_; + + //- Eligible miss + bool eligibleMiss_; + + +public: + + // Public Typedefs + + //- The point type + typedef PointType point_type; + + + // Constructors + + //- Default construct. A zero point with a large distance, + //- no hit, no eligible misses + PointHit() + : + point_(Zero), + distance_(GREAT), + hit_(false), + eligibleMiss_(false) + {} + + //- Construct from point with a large distance, + //- no hit, no eligible misses + explicit PointHit(const point_type& p) + : + point_(p), + distance_(GREAT), + hit_(false), + eligibleMiss_(false) + {} + + //- Construct from components + PointHit + ( + bool hit, + const point_type& p, + scalar dist, + bool eligibleMiss = false + ) + : + point_(p), + distance_(dist), + hit_(hit), + eligibleMiss_(eligibleMiss) + {} + + + // Member Functions + + // Access + + //- Is there a hit + bool hit() const noexcept + { + return hit_; + } + + //- Is this an eligible miss + bool eligibleMiss() const noexcept + { + return eligibleMiss_; + } + + //- Return the point, no checks + const point_type& point() const noexcept + { + return point_; + } + + //- Return distance to hit + scalar distance() const noexcept + { + return distance_; + } + + //- Return the hit point. Fatal if not hit. + const point_type& hitPoint() const + { + if (!hit_) + { + FatalErrorInFunction + << "Requested a hit point, but it was not hit" + << abort(FatalError); + } + + return point_; + } + + //- Return the miss point. Fatal if hit. + const point_type& missPoint() const + { + if (hit_) + { + FatalErrorInFunction + << "Requested a miss point, but it was hit" + << abort(FatalError); + } + + return point_; + } + + //- The point, no checks + // \deprecated(2020-10) use point() + const point_type& rawPoint() const noexcept { return point_; } + + + // Edit + + //- Set the hit status \em on + void setHit() noexcept + { + hit_ = true; + eligibleMiss_ = false; + } + + //- Set the hit status \em off and set the eligible miss status + void setMiss(const bool eligible) noexcept + { + hit_ = false; + eligibleMiss_ = eligible; + } + + //- Set the point + void setPoint(const point_type& p) + { + point_ = p; + } + + //- Set the distance + void setDistance(const scalar d) noexcept + { + distance_ = d; + } + + //- Set the point as \em hit. + void hitPoint(const point_type& p) + { + point_ = p; + hit_ = true; + eligibleMiss_ = false; + } + + + // Member Operators + + //- Distance comparision operator, for sorting + template + bool operator<(const PointHit& rhs) const noexcept + { + return distance_ < rhs.distance_; + } +}; + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +// Ostream Operator + +template +inline Ostream& operator<<(Ostream& os, const PointHit& pHit) +{ + os << pHit.hit() << token::SPACE + << pHit.point() << token::SPACE + << pHit.distance() << token::SPACE + << pHit.eligibleMiss(); + + return os; } + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHit.H index 08a9a28e05..65cbd54ad8 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHit.H +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHit.H @@ -5,8 +5,8 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -24,31 +24,304 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Typedef - Foam::pointIndexHit +Class + Foam::PointIndexHit Description - A PointIndexHit for 3D points. + This class describes the interaction of an object (often a face) + and a point. + It carries the info of a successful hit and (if successful), + returns the interaction point. + + Like pointHit but carries object (eg, face, cell, edge etc.) index \*---------------------------------------------------------------------------*/ -#ifndef pointIndexHit_H -#define pointIndexHit_H +#ifndef Foam_pointIndexHit_H +#define Foam_pointIndexHit_H -#include "point.H" -#include "PointIndexHit.H" +#include "pointHit.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { +// Forward Declarations +template class PointIndexHit; + +template +inline Istream& operator>>(Istream& is, PointIndexHit& pHit); + +template +inline Ostream& operator<<(Ostream& os, const PointIndexHit& pHit); + + +// Standard Types + +//- A PointIndexHit with a 3D point typedef PointIndexHit pointIndexHit; + +/*---------------------------------------------------------------------------*\ + Class PointIndexHit Declaration +\*---------------------------------------------------------------------------*/ + +template +class PointIndexHit +{ + // Private Data + + //- Hit success + bool hit_; + + //- Point of hit; invalid for misses + PointType point_; + + //- Label of object hit + label index_; + + +public: + + // Public Typedefs + + //- The point type + typedef PointType point_type; + + + // Constructors + + //- Default construct. A zero point, with no hit and index = -1 + PointIndexHit() + : + hit_(false), + point_(Zero), + index_(-1) + {} + + //- Construct from a point, with no hit and index = -1 + explicit PointIndexHit(const point_type& p) + : + hit_(false), + point_(p), + index_(-1) + {} + + //- Construct from hitPoint with index = -1 or specified + explicit PointIndexHit(const PointHit& p, label index = -1) + : + hit_(p.hit()), + point_(p.point()), + index_(index) + {} + + //- Construct from components + PointIndexHit(bool success, const point_type& p, label index) + : + hit_(success), + point_(p), + index_(index) + {} + + //- Construct from Istream + explicit PointIndexHit(Istream& is) + { + is >> *this; + } + + + // Member Functions + + // Access + + //- Is there a hit? + bool hit() const noexcept + { + return hit_; + } + + //- Return the hit index + label index() const noexcept + { + return index_; + } + + //- Return point, no checks + const point_type& point() const noexcept + { + return point_; + } + + //- Access the point, no checks + point_type& point() noexcept + { + return point_; + } + + //- Return hit point. Fatal if not hit. + const point_type& hitPoint() const + { + if (!hit_) + { + FatalErrorInFunction + << "Requested a hit point, but it was not hit" + << abort(FatalError); + } + return point_; + } + + //- Return miss point. Fatal if hit. + const point_type& missPoint() const + { + if (hit_) + { + FatalErrorInFunction + << "Requested a miss point, but it was hit" + << abort(FatalError); + } + return point_; + } + + //- The point, no checks. Same as point() + // \deprecated(2020-10) use point() + const point_type& rawPoint() const noexcept { return point_; } + + //- The point, no checks. Same as point() + // \deprecated(2020-10) use point() + point_type& rawPoint() noexcept { return point_; } + + + // Edit + + //- Set the hit status \em on + void setHit() noexcept + { + hit_ = true; + } + + //- Set the hit status \em off + void setMiss() noexcept + { + hit_ = false; + } + + //- Set the point + void setPoint(const point_type& p) + { + point_ = p; + } + + //- Set the index + void setIndex(const label index) noexcept + { + index_ = index; + } + + //- Set the point as \em hit without changing the hit-index + void hitPoint(const point_type& p) + { + point_ = p; + hit_ = true; + } + + //- Set the point as \em hit and set the hit-index + void hitPoint(const point_type& p, const label index) + { + point_ = p; + hit_ = true; + index_ = index; + } + + + // Write + + //- Report hit/miss status, point and index + void write(Ostream& os) + { + os << (hit_ ? "hit:" : "miss:") + << point_ << " index:" << index_; + } + + + // Member Operators + + //- Test for equality of all components + bool operator==(const PointIndexHit& rhs) const + { + return + ( + hit_ == rhs.hit_ + && index_ == rhs.index_ + && point_ == rhs.point_ + ); + } + + //- Test for inequality of components + bool operator!=(const PointIndexHit& rhs) const + { + return !(*this == rhs); + } + + + // IO Operators + + friend Ostream& operator<<(Ostream& os, const PointIndexHit& pHit) + { + if (os.format() == IOstreamOption::ASCII) + { + os << pHit.hit_ << token::SPACE + << pHit.point_ << token::SPACE + << pHit.index_; + } + else + { + os.write + ( + reinterpret_cast(&pHit), + sizeof(PointIndexHit) + ); + } + + os.check(FUNCTION_NAME); + return os; + } + + + friend Istream& operator>>(Istream& is, PointIndexHit& pHit) + { + if (is.format() == IOstreamOption::ASCII) + { + is >> pHit.hit_ >> pHit.point_ >> pHit.index_; + } + else + { + // TODO (2019-08-06): + // cannot properly handle mixed-precision reading + // owing to bool and Point type. + + is.read + ( + reinterpret_cast(&pHit), + sizeof(PointIndexHit) + ); + } + + is.check(FUNCTION_NAME); + return is; + } +}; + + +// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * // + //- Contiguous data for pointIndexHit template<> struct is_contiguous : is_contiguous {}; -} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHitIOList.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHitIOList.H index 9b748d88f5..2891c5a15b 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHitIOList.H +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/pointIndexHitIOList.H @@ -31,8 +31,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef pointIndexHitIOList_H -#define pointIndexHitIOList_H +#ifndef Foam_pointIndexHitIOList_H +#define Foam_pointIndexHitIOList_H #include "pointIndexHit.H" #include "IOList.H" diff --git a/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H b/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H index 45adc5fbc2..68cba504d9 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H +++ b/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H @@ -572,8 +572,7 @@ inline Foam::pointHit Foam::triangle::ray if (hit && eligible) { // Hit. Set distance to intersection. - inter.setHit(); - inter.setPoint(pInter); + inter.hitPoint(pInter); inter.setDistance(dist); } else @@ -671,8 +670,7 @@ inline Foam::pointHit Foam::triangle::intersection return intersection; } - intersection.setHit(); - intersection.setPoint(a_ + u*edge1 + v*edge2); + intersection.hitPoint(a_ + u*edge1 + v*edge2); intersection.setDistance(t); return intersection; @@ -898,8 +896,7 @@ inline Foam::pointHit Foam::triangle::nearestPoint else { // Hit on line - lnInfo.setHit(); - lnInfo.setPoint(triInfo.hitPoint()); + lnInfo.hitPoint(triInfo.hitPoint()); lnInfo.setDistance(0.0); triInfo.setDistance(0.0); } @@ -972,8 +969,7 @@ inline Foam::pointHit Foam::triangle::nearestPoint } else { - lnInfo.setHit(); - lnInfo.setPoint(nearestLinePoint); + lnInfo.hitPoint(nearestLinePoint); } } return triInfo; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C index 758ecc99d2..4c36356947 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C @@ -277,9 +277,8 @@ Foam::pointIndexHit Foam::turbulentDFSEMInletFvPatchVectorField::setNewPosition const face& tf = triFace_[triI]; const triPointRef tri(points[tf[0]], points[tf[1]], points[tf[2]]); - pos.setHit(); + pos.hitPoint(tri.randomPoint(rndGen_)); pos.setIndex(triToFace_[triI]); - pos.rawPoint() = tri.randomPoint(rndGen_); } } else @@ -302,9 +301,8 @@ Foam::pointIndexHit Foam::turbulentDFSEMInletFvPatchVectorField::setNewPosition const face& tf = triFace_[triI]; const triPointRef tri(points[tf[0]], points[tf[1]], points[tf[2]]); - pos.setHit(); + pos.hitPoint(tri.randomPoint(rndGen_)); pos.setIndex(triToFace_[triI]); - pos.rawPoint() = tri.randomPoint(rndGen_); } return pos; diff --git a/src/meshTools/searchableSurfaces/searchableCone/searchableCone.C b/src/meshTools/searchableSurfaces/searchableCone/searchableCone.C index 6200b1ff1b..582a6e9f2f 100644 --- a/src/meshTools/searchableSurfaces/searchableCone/searchableCone.C +++ b/src/meshTools/searchableSurfaces/searchableCone/searchableCone.C @@ -589,20 +589,17 @@ void Foam::searchableCone::findLineAll // Check tNear, tFar if (tNear>=0 && tNear <= magV) { - near.setPoint(start+tNear*V); - near.setHit(); + near.hitPoint(start+tNear*V); near.setIndex(0); if (tFar <= magV) { - far.setPoint(start+tFar*V); - far.setHit(); + far.hitPoint(start+tFar*V); far.setIndex(0); } } else if (tFar>=0 && tFar <= magV) { - near.setPoint(start+tFar*V); - near.setHit(); + near.hitPoint(start+tFar*V); near.setIndex(0); } } diff --git a/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.C b/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.C index ee1f2c88bc..e8d26197c6 100644 --- a/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.C +++ b/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.C @@ -417,21 +417,18 @@ void Foam::searchableCylinder::findLineAll // Check tNear, tFar if (tNear >= 0 && tNear <= magV) { - near.setPoint(start+tNear*V); - near.setHit(); + near.hitPoint(start+tNear*V); near.setIndex(0); if (tFar <= magV) { - far.setPoint(start+tFar*V); - far.setHit(); + far.hitPoint(start+tFar*V); far.setIndex(0); } } else if (tFar >= 0 && tFar <= magV) { - near.setPoint(start+tFar*V); - near.setHit(); + near.hitPoint(start+tFar*V); near.setIndex(0); } } diff --git a/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.C b/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.C index e665b31384..b79ed2feaa 100644 --- a/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.C +++ b/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.C @@ -577,12 +577,11 @@ Foam::pointIndexHit Foam::searchableSphere::findNearest if (nearestDistSqr >= sqr(magN - radii_[0])) { - info.setPoint + info.hitPoint ( origin_ + (magN < ROOTVSMALL ? vector(radii_[0],0,0) : (radii_[0]*n/magN)) ); - info.setHit(); info.setIndex(0); } diff --git a/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C b/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C index 27653a2900..ca2c4c145b 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C +++ b/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C @@ -105,8 +105,7 @@ void Foam::searchableSurfaceCollection::findNearest if (distSqr < minDistSqr[pointi]) { minDistSqr[pointi] = distSqr; - nearestInfo[pointi].setPoint(globalPt); - nearestInfo[pointi].setHit(); + nearestInfo[pointi].hitPoint(globalPt); nearestInfo[pointi].setIndex ( hitInfo[pointi].index() diff --git a/src/meshTools/topoSet/faceSources/regionToFace/regionToFace.C b/src/meshTools/topoSet/faceSources/regionToFace/regionToFace.C index 8d3e28b7c8..8bbec46fc4 100644 --- a/src/meshTools/topoSet/faceSources/regionToFace/regionToFace.C +++ b/src/meshTools/topoSet/faceSources/regionToFace/regionToFace.C @@ -170,8 +170,7 @@ void Foam::regionToFace::combine(topoSet& set, const bool add) const if (!ni.first().hit() || d2 < ni.second().first()) { ni.second().first() = d2; - ni.first().setHit(); - ni.first().setPoint(fc); + ni.first().hitPoint(fc); ni.first().setIndex(i); } } diff --git a/src/meshTools/triSurface/faceTriangulation/faceTriangulation.C b/src/meshTools/triSurface/faceTriangulation/faceTriangulation.C index 88afcb8885..f6cac88650 100644 --- a/src/meshTools/triSurface/faceTriangulation/faceTriangulation.C +++ b/src/meshTools/triSurface/faceTriangulation/faceTriangulation.C @@ -139,8 +139,7 @@ Foam::pointHit Foam::faceTriangulation::rayEdgeIntersect else { // Hit - result.setHit(); - result.setPoint(intersectPt); + result.hitPoint(intersectPt); result.setDistance(mag(intersectPt - rayOrigin)); } } diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C index 4d8660050d..a2062040bb 100644 --- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C +++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C @@ -847,15 +847,13 @@ Foam::surfaceLocation Foam::triSurfaceTools::cutEdge if (d[fp1] == 0.0) { - cut.setHit(); - cut.setPoint(points[f[fp1]]); + cut.hitPoint(points[f[fp1]]); cut.elementType() = triPointRef::POINT; cut.setIndex(s.localFaces()[triI][fp1]); } else if (d[fp2] == 0.0) { - cut.setHit(); - cut.setPoint(points[f[fp2]]); + cut.hitPoint(points[f[fp2]]); cut.elementType() = triPointRef::POINT; cut.setIndex(s.localFaces()[triI][fp2]); } @@ -870,8 +868,7 @@ Foam::surfaceLocation Foam::triSurfaceTools::cutEdge } else { - cut.setHit(); - cut.setPoint + cut.hitPoint ( (d[fp2]*points[f[fp1]] - d[fp1]*points[f[fp2]]) / (d[fp2] - d[fp1]) @@ -899,8 +896,7 @@ Foam::surfaceLocation Foam::triSurfaceTools::cutEdge << "triangle:" << f.tri(points) << " d:" << d << abort(FatalError); } - inters[interI].setHit(); - inters[interI].setPoint(points[f[fp0]]); + inters[interI].hitPoint(points[f[fp0]]); inters[interI].elementType() = triPointRef::POINT; inters[interI].setIndex(s.localFaces()[triI][fp0]); interI++; @@ -918,8 +914,7 @@ Foam::surfaceLocation Foam::triSurfaceTools::cutEdge << "triangle:" << f.tri(points) << " d:" << d << abort(FatalError); } - inters[interI].setHit(); - inters[interI].setPoint + inters[interI].hitPoint ( (d[fp0]*points[f[fp1]] - d[fp1]*points[f[fp0]]) / (d[fp0] - d[fp1]) diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index cdb27f6f36..fb2943864f 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -1596,7 +1596,7 @@ Foam::volumeType Foam::distributedTriSurfaceMesh::calcVolumeType } // Store octant type - nodeTypes.set((nodeI<<3)+octant, subType); + nodeTypes.set(labelBits::pack(nodeI, octant), subType); // Combine sub node types into type for treeNode. Result is 'mixed' if // types differ among subnodes. @@ -1625,7 +1625,7 @@ Foam::volumeType Foam::distributedTriSurfaceMesh::cachedVolumeType volumeType octantType = volumeType::type ( - tree().nodeTypes().get((nodeI<<3)+octant) + tree().nodeTypes().get(labelBits::pack(nodeI, octant)) ); if (octantType == volumeType::INSIDE) diff --git a/src/sampling/surface/isoSurface/isoSurfaceCell.C b/src/sampling/surface/isoSurface/isoSurfaceCell.C index 206a4b16f6..489f45a3e2 100644 --- a/src/sampling/surface/isoSurface/isoSurfaceCell.C +++ b/src/sampling/surface/isoSurface/isoSurfaceCell.C @@ -131,8 +131,7 @@ Foam::pointIndexHit Foam::isoSurfaceCell::collapseSurface if (localTris.size() == 1) { const labelledTri& tri = localTris[0]; - info.setPoint(tri.centre(localPoints)); - info.setHit(); + info.hitPoint(tri.centre(localPoints)); } else if (localTris.size() == 2) { @@ -157,7 +156,7 @@ Foam::pointIndexHit Foam::isoSurfaceCell::collapseSurface || (n0 & n1) >= 0 ) { - info.setPoint + info.hitPoint ( 0.5 * ( @@ -165,7 +164,6 @@ Foam::pointIndexHit Foam::isoSurfaceCell::collapseSurface + tri1.centre(localPoints) ) ); - info.setHit(); } } } @@ -204,8 +202,7 @@ Foam::pointIndexHit Foam::isoSurfaceCell::collapseSurface if (minCos > 0) { - info.setPoint(calcCentre(surf)); - info.setHit(); + info.hitPoint(calcCentre(surf)); } } }