diff --git a/applications/utilities/surface/surfaceSubset/surfaceSubset.C b/applications/utilities/surface/surfaceSubset/surfaceSubset.C index 9df166e6e2..1958355238 100644 --- a/applications/utilities/surface/surfaceSubset/surfaceSubset.C +++ b/applications/utilities/surface/surfaceSubset/surfaceSubset.C @@ -31,6 +31,7 @@ Description \*---------------------------------------------------------------------------*/ #include "triSurface.H" +#include "triSurfaceSearch.H" #include "argList.H" #include "OFstream.H" #include "IFstream.H" @@ -40,6 +41,7 @@ Description #include "indexedOctree.H" #include "treeDataTriSurface.H" #include "Random.H" +#include "volumeType.H" using namespace Foam; @@ -242,26 +244,16 @@ int main(int argc, char *argv[]) // Read surface to select on triSurface selectSurf(surfName); - // bb of surface - treeBoundBox bb(selectSurf.localPoints()); - - // Random number generator - Random rndGen(354543); - - // search engine - indexedOctree selectTree + triSurfaceSearch searchSelectSurf ( - treeDataTriSurface - ( - selectSurf, - indexedOctree::perturbTol() - ), - bb.extend(rndGen, 1e-4), // slightly randomize bb - 8, // maxLevel - 10, // leafsize - 3.0 // duplicity + selectSurf, + indexedOctree::perturbTol(), + 8 ); + const indexedOctree& selectTree = + searchSelectSurf.tree(); + // Check if face (centre) is in outside or inside. forAll(facesToSubset, faceI) { @@ -269,14 +261,13 @@ int main(int argc, char *argv[]) { const point fc(surf1[faceI].centre(surf1.points())); - indexedOctree::volumeType t = - selectTree.getVolumeType(fc); + volumeType t = selectTree.getVolumeType(fc); if ( outside - ? (t == indexedOctree::OUTSIDE) - : (t == indexedOctree::INSIDE) + ? (t == volumeType::OUTSIDE) + : (t == volumeType::INSIDE) ) { facesToSubset[faceI] = true; diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 033dd4f62c..4054ec39da 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -605,6 +605,7 @@ $(interpolationWeights)/splineInterpolationWeights/splineInterpolationWeights.C algorithms/indexedOctree/indexedOctreeName.C algorithms/indexedOctree/treeDataCell.C +algorithms/indexedOctree/volumeType.C algorithms/dynamicIndexedOctree/dynamicIndexedOctreeName.C diff --git a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C index b18b2892cb..92b2932510 100644 --- a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C +++ b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.C @@ -334,15 +334,14 @@ void Foam::dynamicIndexedOctree::recursiveSubDivision // Recurses to determine status of lowest level boxes. Level above is // combination of octants below. template -typename Foam::dynamicIndexedOctree::volumeType -Foam::dynamicIndexedOctree::calcVolumeType +Foam::volumeType Foam::dynamicIndexedOctree::calcVolumeType ( const label nodeI ) const { const node& nod = nodes_[nodeI]; - volumeType myType = UNKNOWN; + volumeType myType = volumeType::UNKNOWN; for (direction octant = 0; octant < nod.subNodes_.size(); octant++) { @@ -359,7 +358,7 @@ Foam::dynamicIndexedOctree::calcVolumeType { // Contents. Depending on position in box might be on either // side. - subType = MIXED; + subType = volumeType::MIXED; } else { @@ -378,13 +377,13 @@ Foam::dynamicIndexedOctree::calcVolumeType // Combine sub node types into type for treeNode. Result is 'mixed' if // types differ among subnodes. - if (myType == UNKNOWN) + if (myType == volumeType::UNKNOWN) { myType = subType; } else if (subType != myType) { - myType = MIXED; + myType = volumeType::MIXED; } } return myType; @@ -392,8 +391,7 @@ Foam::dynamicIndexedOctree::calcVolumeType template -typename Foam::dynamicIndexedOctree::volumeType -Foam::dynamicIndexedOctree::getVolumeType +Foam::volumeType Foam::dynamicIndexedOctree::getVolumeType ( const label nodeI, const point& sample @@ -403,22 +401,22 @@ Foam::dynamicIndexedOctree::getVolumeType direction octant = nod.bb_.subOctant(sample); - volumeType octantType = volumeType(nodeTypes_.get((nodeI<<3)+octant)); + volumeType octantType = volumeType::type(nodeTypes_.get((nodeI<<3)+octant)); - if (octantType == INSIDE) + if (octantType == volumeType::INSIDE) { return octantType; } - else if (octantType == OUTSIDE) + else if (octantType == volumeType::OUTSIDE) { return octantType; } - else if (octantType == UNKNOWN) + else if (octantType == volumeType::UNKNOWN) { // Can happen for e.g. non-manifold surfaces. return octantType; } - else if (octantType == MIXED) + else if (octantType == volumeType::MIXED) { labelBits index = nod.subNodes_[octant]; @@ -447,7 +445,7 @@ Foam::dynamicIndexedOctree::getVolumeType << "Empty subnode has invalid volume type MIXED." << abort(FatalError); - return UNKNOWN; + return volumeType::UNKNOWN; } } else @@ -462,14 +460,13 @@ Foam::dynamicIndexedOctree::getVolumeType << "Node has invalid volume type " << octantType << abort(FatalError); - return UNKNOWN; + return volumeType::UNKNOWN; } } template -typename Foam::dynamicIndexedOctree::volumeType -Foam::dynamicIndexedOctree::getSide +Foam::volumeType Foam::dynamicIndexedOctree::getSide ( const vector& outsideNormal, const vector& vec @@ -477,11 +474,11 @@ Foam::dynamicIndexedOctree::getSide { if ((outsideNormal&vec) >= 0) { - return OUTSIDE; + return volumeType::OUTSIDE; } else { - return INSIDE; + return volumeType::INSIDE; } } @@ -2582,15 +2579,14 @@ const Foam::labelList& Foam::dynamicIndexedOctree::findIndices // Determine type (inside/outside/mixed) per node. template -typename Foam::dynamicIndexedOctree::volumeType -Foam::dynamicIndexedOctree::getVolumeType +Foam::volumeType Foam::dynamicIndexedOctree::getVolumeType ( const point& sample ) const { if (nodes_.empty()) { - return UNKNOWN; + return volumeType::UNKNOWN; } if (nodeTypes_.size() != 8*nodes_.size()) @@ -2598,7 +2594,7 @@ Foam::dynamicIndexedOctree::getVolumeType // Calculate type for every octant of node. nodeTypes_.setSize(8*nodes_.size()); - nodeTypes_ = UNKNOWN; + nodeTypes_ = volumeType::UNKNOWN; calcVolumeType(0); @@ -2611,21 +2607,21 @@ Foam::dynamicIndexedOctree::getVolumeType forAll(nodeTypes_, i) { - volumeType type = volumeType(nodeTypes_.get(i)); + volumeType type = volumeType::type(nodeTypes_.get(i)); - if (type == UNKNOWN) + if (type == volumeType::UNKNOWN) { nUNKNOWN++; } - else if (type == MIXED) + else if (type == volumeType::MIXED) { nMIXED++; } - else if (type == INSIDE) + else if (type == volumeType::INSIDE) { nINSIDE++; } - else if (type == OUTSIDE) + else if (type == volumeType::OUTSIDE) { nOUTSIDE++; } diff --git a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.H b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.H index 0bbf7a0e2e..e0a298855f 100644 --- a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.H +++ b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicIndexedOctree.H @@ -43,6 +43,7 @@ SourceFiles #include "HashSet.H" #include "labelBits.H" #include "PackedList.H" +#include "volumeType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -83,16 +84,6 @@ public: // Data types - //- volume types - enum volumeType - { - UNKNOWN = 0, - MIXED = 1, - INSIDE = 2, - OUTSIDE = 3 - }; - - //- Tree node. Has up pointer and down pointers. class node { diff --git a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicTreeDataPoint.C b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicTreeDataPoint.C index ebc93a63c7..821e4ff500 100644 --- a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicTreeDataPoint.C +++ b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicTreeDataPoint.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -57,13 +57,13 @@ Foam::dynamicTreeDataPoint::shapePoints() const //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. // Only makes sense for closed surfaces. -Foam::label Foam::dynamicTreeDataPoint::getVolumeType +Foam::volumeType Foam::dynamicTreeDataPoint::getVolumeType ( const dynamicIndexedOctree& oc, const point& sample ) const { - return dynamicIndexedOctree::UNKNOWN; + return volumeType::UNKNOWN; } diff --git a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicTreeDataPoint.H b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicTreeDataPoint.H index 2cbdc00057..529d923b74 100644 --- a/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicTreeDataPoint.H +++ b/src/OpenFOAM/algorithms/dynamicIndexedOctree/dynamicTreeDataPoint.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,6 +43,7 @@ SourceFiles #include "pointField.H" #include "treeBoundBox.H" #include "linePointRef.H" +#include "volumeType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -92,7 +93,7 @@ public: //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. // Only makes sense for closed surfaces. - label getVolumeType + volumeType getVolumeType ( const dynamicIndexedOctree&, const point& diff --git a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C index 4b703bbb42..945f9d989c 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C +++ b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C @@ -356,15 +356,14 @@ Foam::label Foam::indexedOctree::compactContents // Recurses to determine status of lowest level boxes. Level above is // combination of octants below. template -typename Foam::indexedOctree::volumeType -Foam::indexedOctree::calcVolumeType +Foam::volumeType Foam::indexedOctree::calcVolumeType ( const label nodeI ) const { const node& nod = nodes_[nodeI]; - volumeType myType = UNKNOWN; + volumeType myType = volumeType::UNKNOWN; for (direction octant = 0; octant < nod.subNodes_.size(); octant++) { @@ -381,7 +380,7 @@ Foam::indexedOctree::calcVolumeType { // Contents. Depending on position in box might be on either // side. - subType = MIXED; + subType = volumeType::MIXED; } else { @@ -389,10 +388,7 @@ Foam::indexedOctree::calcVolumeType // of its bounding box. const treeBoundBox subBb = nod.bb_.subBbox(octant); - subType = volumeType - ( - shapes_.getVolumeType(*this, subBb.midpoint()) - ); + subType = shapes_.getVolumeType(*this, subBb.midpoint()); } // Store octant type @@ -400,13 +396,13 @@ Foam::indexedOctree::calcVolumeType // Combine sub node types into type for treeNode. Result is 'mixed' if // types differ among subnodes. - if (myType == UNKNOWN) + if (myType == volumeType::UNKNOWN) { myType = subType; } else if (subType != myType) { - myType = MIXED; + myType = volumeType::MIXED; } } return myType; @@ -414,8 +410,7 @@ Foam::indexedOctree::calcVolumeType template -typename Foam::indexedOctree::volumeType -Foam::indexedOctree::getVolumeType +Foam::volumeType Foam::indexedOctree::getVolumeType ( const label nodeI, const point& sample @@ -425,22 +420,22 @@ Foam::indexedOctree::getVolumeType direction octant = nod.bb_.subOctant(sample); - volumeType octantType = volumeType(nodeTypes_.get((nodeI<<3)+octant)); + volumeType octantType = volumeType::type(nodeTypes_.get((nodeI<<3)+octant)); - if (octantType == INSIDE) + if (octantType == volumeType::INSIDE) { return octantType; } - else if (octantType == OUTSIDE) + else if (octantType == volumeType::OUTSIDE) { return octantType; } - else if (octantType == UNKNOWN) + else if (octantType == volumeType::UNKNOWN) { // Can happen for e.g. non-manifold surfaces. return octantType; } - else if (octantType == MIXED) + else if (octantType == volumeType::MIXED) { labelBits index = nod.subNodes_[octant]; @@ -469,7 +464,7 @@ Foam::indexedOctree::getVolumeType << "Empty subnode has invalid volume type MIXED." << abort(FatalError); - return UNKNOWN; + return volumeType::UNKNOWN; } } else @@ -484,14 +479,13 @@ Foam::indexedOctree::getVolumeType << "Node has invalid volume type " << octantType << abort(FatalError); - return UNKNOWN; + return volumeType::UNKNOWN; } } template -typename Foam::indexedOctree::volumeType -Foam::indexedOctree::getSide +Foam::volumeType Foam::indexedOctree::getSide ( const vector& outsideNormal, const vector& vec @@ -499,11 +493,11 @@ Foam::indexedOctree::getSide { if ((outsideNormal&vec) >= 0) { - return OUTSIDE; + return volumeType::OUTSIDE; } else { - return INSIDE; + return volumeType::INSIDE; } } @@ -2972,23 +2966,29 @@ const Foam::labelList& Foam::indexedOctree::findIndices // Determine type (inside/outside/mixed) per node. template -typename Foam::indexedOctree::volumeType -Foam::indexedOctree::getVolumeType +Foam::volumeType Foam::indexedOctree::getVolumeType ( const point& sample ) const { if (nodes_.empty()) { - return UNKNOWN; + return volumeType::UNKNOWN; } +// // If the sample is not within the octree, then have to query shapes +// // directly +// if (!nodes_[0].bb_.contains(sample)) +// { +// return volumeType(shapes_.getVolumeType(*this, sample)); +// } + if (nodeTypes_.size() != 8*nodes_.size()) { // Calculate type for every octant of node. nodeTypes_.setSize(8*nodes_.size()); - nodeTypes_ = UNKNOWN; + nodeTypes_ = volumeType::UNKNOWN; calcVolumeType(0); @@ -3001,21 +3001,21 @@ Foam::indexedOctree::getVolumeType forAll(nodeTypes_, i) { - volumeType type = volumeType(nodeTypes_.get(i)); + volumeType type = volumeType::type(nodeTypes_.get(i)); - if (type == UNKNOWN) + if (type == volumeType::UNKNOWN) { nUNKNOWN++; } - else if (type == MIXED) + else if (type == volumeType::MIXED) { nMIXED++; } - else if (type == INSIDE) + else if (type == volumeType::INSIDE) { nINSIDE++; } - else if (type == OUTSIDE) + else if (type == volumeType::OUTSIDE) { nOUTSIDE++; } diff --git a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.H b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.H index 154cb34bd0..229993e406 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.H +++ b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.H @@ -42,6 +42,7 @@ SourceFiles #include "HashSet.H" #include "labelBits.H" #include "PackedList.H" +#include "volumeType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -74,16 +75,6 @@ public: // Data types - //- volume types - enum volumeType - { - UNKNOWN = 0, - MIXED = 1, - INSIDE = 2, - OUTSIDE = 3 - }; - - //- Tree node. Has up pointer and down pointers. class node { diff --git a/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.H b/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.H index fe65b9b9bd..c302f6cbec 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.H +++ b/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.H @@ -38,6 +38,7 @@ SourceFiles #include "polyMesh.H" #include "treeBoundBoxList.H" +#include "volumeType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -196,7 +197,7 @@ public: //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. // Only makes sense for closed surfaces. - label getVolumeType + volumeType getVolumeType ( const indexedOctree&, const point& @@ -207,7 +208,7 @@ public: "treeDataCell::getVolumeType" "(const indexedOctree&, const point&)" ); - return -1; + return volumeType::UNKNOWN; } //- Does (bb of) shape at index overlap bb diff --git a/src/OpenFOAM/algorithms/indexedOctree/volumeType.C b/src/OpenFOAM/algorithms/indexedOctree/volumeType.C new file mode 100644 index 0000000000..95868f6c0c --- /dev/null +++ b/src/OpenFOAM/algorithms/indexedOctree/volumeType.C @@ -0,0 +1,79 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 "volumeType.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + template<> + const char* Foam::NamedEnum + < + Foam::volumeType, + 4 + >::names[] = + { + "unknown", + "mixed", + "inside", + "outside" + }; +} + +const Foam::NamedEnum Foam::volumeType::names; + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Istream& Foam::operator>>(Istream& is, volumeType& vt) +{ + // Read beginning of volumeType + is.readBegin("volumeType"); + + int type; + is >> type; + + vt.t_ = static_cast(type); + + // Read end of volumeType + is.readEnd("volumeType"); + + // Check state of Istream + is.check("operator>>(Istream&, volumeType&)"); + + return is; +} + + +Foam::Ostream& Foam::operator<<(Ostream& os, const volumeType& vt) +{ + os << static_cast(vt.t_); + + return os; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/algorithms/indexedOctree/volumeType.H b/src/OpenFOAM/algorithms/indexedOctree/volumeType.H new file mode 100644 index 0000000000..7bdfc043e6 --- /dev/null +++ b/src/OpenFOAM/algorithms/indexedOctree/volumeType.H @@ -0,0 +1,127 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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::volumeType + +Description + +SourceFiles + volumeType.C + +\*---------------------------------------------------------------------------*/ + +#ifndef volumeType_H +#define volumeType_H + +#include "NamedEnum.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators + +class volumeType; +Istream& operator>>(Istream& is, volumeType&); +Ostream& operator<<(Ostream& os, const volumeType& C); + + +/*---------------------------------------------------------------------------*\ + Class volumeType Declaration +\*---------------------------------------------------------------------------*/ + +class volumeType +{ +public: + + //- Volume types + enum type + { + UNKNOWN = 0, + MIXED = 1, + INSIDE = 2, + OUTSIDE = 3 + }; + + +private: + + // Private data + + //- Volume type + type t_; + + +public: + + // Static data + + static const NamedEnum names; + + + // Constructors + + //- Construct null + volumeType() + : + t_(UNKNOWN) + {} + + //- Construct from components + volumeType(type t) + : + t_(t) + {} + + + // Member Functions + + operator type() const + { + return t_; + } + + + // IOstream operators + + friend Istream& operator>>(Istream& is, volumeType& vt); + friend Ostream& operator<<(Ostream& os, const volumeType& vt); +}; + + +//- Data associated with volumeType type are contiguous +template<> +inline bool contiguous() {return true;} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C index a45a06a6b2..f53968532c 100644 --- a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C +++ b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C @@ -31,6 +31,7 @@ License #include "labelPair.H" #include "searchableSurfacesQueries.H" #include "UPtrList.H" +#include "volumeType.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -1302,7 +1303,7 @@ void Foam::refinementSurfaces::findInside if (allGeometry_[surfaces_[surfI]].hasVolumeType()) { - List volType; + List volType; allGeometry_[surfaces_[surfI]].getVolumeType(pt, volType); forAll(volType, pointI) @@ -1312,11 +1313,11 @@ void Foam::refinementSurfaces::findInside if ( ( - volType[pointI] == triSurfaceMesh::INSIDE + volType[pointI] == volumeType::INSIDE && zoneInside_[surfI] == INSIDE ) || ( - volType[pointI] == triSurfaceMesh::OUTSIDE + volType[pointI] == volumeType::OUTSIDE && zoneInside_[surfI] == OUTSIDE ) ) diff --git a/src/mesh/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.C b/src/mesh/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.C index bc3289f18e..a7a44f3fbf 100644 --- a/src/mesh/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.C +++ b/src/mesh/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,6 +31,7 @@ License #include "searchableSurfaces.H" #include "orientedSurface.H" #include "pointIndexHit.H" +#include "volumeType.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -329,7 +330,7 @@ void Foam::shellSurfaces::findHigherLevel candidateMap.setSize(candidateI); // Do the expensive nearest test only for the candidate points. - List volType; + List volType; allGeometry_[shells_[shellI]].getVolumeType(candidates, volType); forAll(volType, i) @@ -340,11 +341,11 @@ void Foam::shellSurfaces::findHigherLevel ( ( modes_[shellI] == INSIDE - && volType[i] == searchableSurface::INSIDE + && volType[i] == volumeType::INSIDE ) || ( modes_[shellI] == OUTSIDE - && volType[i] == searchableSurface::OUTSIDE + && volType[i] == volumeType::OUTSIDE ) ) { diff --git a/src/meshTools/indexedOctree/treeDataEdge.C b/src/meshTools/indexedOctree/treeDataEdge.C index 9907053e6f..4d0b9b4d81 100644 --- a/src/meshTools/indexedOctree/treeDataEdge.C +++ b/src/meshTools/indexedOctree/treeDataEdge.C @@ -132,13 +132,13 @@ Foam::pointField Foam::treeDataEdge::shapePoints() const //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. // Only makes sense for closed surfaces. -Foam::label Foam::treeDataEdge::getVolumeType +Foam::volumeType Foam::treeDataEdge::getVolumeType ( const indexedOctree& oc, const point& sample ) const { - return indexedOctree::UNKNOWN; + return volumeType::UNKNOWN; } diff --git a/src/meshTools/indexedOctree/treeDataEdge.H b/src/meshTools/indexedOctree/treeDataEdge.H index a27ab39ff5..12fd0d6aa1 100644 --- a/src/meshTools/indexedOctree/treeDataEdge.H +++ b/src/meshTools/indexedOctree/treeDataEdge.H @@ -37,6 +37,7 @@ SourceFiles #include "treeBoundBoxList.H" #include "linePointRef.H" +#include "volumeType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -197,7 +198,7 @@ public: //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. // Only makes sense for closed surfaces. - label getVolumeType + volumeType getVolumeType ( const indexedOctree&, const point& diff --git a/src/meshTools/indexedOctree/treeDataFace.C b/src/meshTools/indexedOctree/treeDataFace.C index ccaf4d35fe..578a0de2ae 100644 --- a/src/meshTools/indexedOctree/treeDataFace.C +++ b/src/meshTools/indexedOctree/treeDataFace.C @@ -180,7 +180,7 @@ Foam::pointField Foam::treeDataFace::shapePoints() const //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. // Only makes sense for closed surfaces. -Foam::label Foam::treeDataFace::getVolumeType +Foam::volumeType Foam::treeDataFace::getVolumeType ( const indexedOctree& oc, const point& sample @@ -433,7 +433,7 @@ Foam::label Foam::treeDataFace::getVolumeType // - tolerances are wrong. (if e.g. face has zero area) // - or (more likely) surface is not closed. - return indexedOctree::UNKNOWN; + return volumeType::UNKNOWN; } diff --git a/src/meshTools/indexedOctree/treeDataFace.H b/src/meshTools/indexedOctree/treeDataFace.H index 1cf0c0d8e5..3867ba0206 100644 --- a/src/meshTools/indexedOctree/treeDataFace.H +++ b/src/meshTools/indexedOctree/treeDataFace.H @@ -40,6 +40,7 @@ SourceFiles #include "treeBoundBoxList.H" #include "PackedBoolList.H" #include "primitiveMesh.H" +#include "volumeType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -200,7 +201,7 @@ public: //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. // Only makes sense for closed surfaces. - label getVolumeType + volumeType getVolumeType ( const indexedOctree&, const point& diff --git a/src/meshTools/indexedOctree/treeDataPoint.C b/src/meshTools/indexedOctree/treeDataPoint.C index 24ada4a839..fd7f4404b4 100644 --- a/src/meshTools/indexedOctree/treeDataPoint.C +++ b/src/meshTools/indexedOctree/treeDataPoint.C @@ -92,13 +92,13 @@ Foam::pointField Foam::treeDataPoint::shapePoints() const //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. // Only makes sense for closed surfaces. -Foam::label Foam::treeDataPoint::getVolumeType +Foam::volumeType Foam::treeDataPoint::getVolumeType ( const indexedOctree& oc, const point& sample ) const { - return indexedOctree::UNKNOWN; + return volumeType::UNKNOWN; } diff --git a/src/meshTools/indexedOctree/treeDataPoint.H b/src/meshTools/indexedOctree/treeDataPoint.H index 5e09383079..020f60a11d 100644 --- a/src/meshTools/indexedOctree/treeDataPoint.H +++ b/src/meshTools/indexedOctree/treeDataPoint.H @@ -43,6 +43,7 @@ SourceFiles #include "pointField.H" #include "treeBoundBox.H" #include "linePointRef.H" +#include "volumeType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -172,7 +173,7 @@ public: //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. // Only makes sense for closed surfaces. - label getVolumeType + volumeType getVolumeType ( const indexedOctree&, const point& diff --git a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C index 2664849ab1..47d6f57d69 100644 --- a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C +++ b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C @@ -205,7 +205,7 @@ Foam::pointField Foam::treeDataPrimitivePatch::shapePoints() const //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. // Only makes sense for closed surfaces. template -Foam::label Foam::treeDataPrimitivePatch::getVolumeType +Foam::volumeType Foam::treeDataPrimitivePatch::getVolumeType ( const indexedOctree >& oc, const point& sample @@ -435,7 +435,7 @@ Foam::label Foam::treeDataPrimitivePatch::getVolumeType // - tolerances are wrong. (if e.g. face has zero area) // - or (more likely) surface is not closed. - return indexedOctree::UNKNOWN; + return volumeType::UNKNOWN; } diff --git a/src/meshTools/indexedOctree/treeDataPrimitivePatch.H b/src/meshTools/indexedOctree/treeDataPrimitivePatch.H index e28ce0d41e..9d43d2ba85 100644 --- a/src/meshTools/indexedOctree/treeDataPrimitivePatch.H +++ b/src/meshTools/indexedOctree/treeDataPrimitivePatch.H @@ -36,6 +36,7 @@ SourceFiles #define treeDataPrimitivePatch_H #include "treeBoundBoxList.H" +#include "volumeType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -213,7 +214,7 @@ public: //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. // Only makes sense for closed surfaces. - label getVolumeType + volumeType getVolumeType ( const indexedOctree >&, const point& diff --git a/src/meshTools/indexedOctree/treeDataTriSurface.C b/src/meshTools/indexedOctree/treeDataTriSurface.C index 3e1791dbd2..ef00434eb2 100644 --- a/src/meshTools/indexedOctree/treeDataTriSurface.C +++ b/src/meshTools/indexedOctree/treeDataTriSurface.C @@ -29,7 +29,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template<> -Foam::label Foam::treeDataPrimitivePatch::getVolumeType +Foam::volumeType Foam::treeDataPrimitivePatch::getVolumeType ( const indexedOctree >& oc, const point& sample @@ -60,21 +60,21 @@ Foam::label Foam::treeDataPrimitivePatch::getVolumeType if (t == triSurfaceTools::UNKNOWN) { - return indexedOctree >::UNKNOWN; + return volumeType::UNKNOWN; } else if (t == triSurfaceTools::INSIDE) { - return indexedOctree >::INSIDE; + return volumeType::INSIDE; } else if (t == triSurfaceTools::OUTSIDE) { - return indexedOctree >::OUTSIDE; + return volumeType::OUTSIDE; } else { FatalErrorIn("treeDataPrimitivePatch::getVolumeType(..)") << "problem" << abort(FatalError); - return indexedOctree >::UNKNOWN; + return volumeType::UNKNOWN; } } diff --git a/src/meshTools/indexedOctree/treeDataTriSurface.H b/src/meshTools/indexedOctree/treeDataTriSurface.H index e14c3b1812..fbc3d00b12 100644 --- a/src/meshTools/indexedOctree/treeDataTriSurface.H +++ b/src/meshTools/indexedOctree/treeDataTriSurface.H @@ -39,6 +39,7 @@ SourceFiles #include "triSurface.H" #include "point.H" #include "indexedOctree.H" +#include "volumeType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -48,7 +49,7 @@ namespace Foam //- Template specialisation of getVolumeType for treeDataTriSurface template<> - label treeDataPrimitivePatch::getVolumeType + volumeType treeDataPrimitivePatch::getVolumeType ( const indexedOctree >& oc, const point& sample diff --git a/src/meshTools/meshSearch/meshSearch.C b/src/meshTools/meshSearch/meshSearch.C index f05d317104..a28b88b625 100644 --- a/src/meshTools/meshSearch/meshSearch.C +++ b/src/meshTools/meshSearch/meshSearch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -947,9 +947,7 @@ Foam::List Foam::meshSearch::intersections bool Foam::meshSearch::isInside(const point& p) const { - return - boundaryTree().getVolumeType(p) - == indexedOctree::INSIDE; + return (boundaryTree().getVolumeType(p) == volumeType::INSIDE); } diff --git a/src/meshTools/searchableSurface/searchableBox.C b/src/meshTools/searchableSurface/searchableBox.C index 3503308e42..7d639b99f8 100644 --- a/src/meshTools/searchableSurface/searchableBox.C +++ b/src/meshTools/searchableSurface/searchableBox.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -583,7 +583,7 @@ void Foam::searchableBox::getVolumeType ) const { volType.setSize(points.size()); - volType = INSIDE; + volType = volumeType::INSIDE; forAll(points, pointI) { @@ -593,7 +593,7 @@ void Foam::searchableBox::getVolumeType { if (pt[dir] < min()[dir] || pt[dir] > max()[dir]) { - volType[pointI] = OUTSIDE; + volType[pointI] = volumeType::OUTSIDE; break; } } diff --git a/src/meshTools/searchableSurface/searchableCylinder.C b/src/meshTools/searchableSurface/searchableCylinder.C index 3231dd95cd..70d674d521 100644 --- a/src/meshTools/searchableSurface/searchableCylinder.C +++ b/src/meshTools/searchableSurface/searchableCylinder.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -673,7 +673,7 @@ void Foam::searchableCylinder::getVolumeType ) const { volType.setSize(points.size()); - volType = INSIDE; + volType = volumeType::INSIDE; forAll(points, pointI) { @@ -687,12 +687,12 @@ void Foam::searchableCylinder::getVolumeType if (parallel < 0) { // left of point1 endcap - volType[pointI] = OUTSIDE; + volType[pointI] = volumeType::OUTSIDE; } else if (parallel > magDir_) { // right of point2 endcap - volType[pointI] = OUTSIDE; + volType[pointI] = volumeType::OUTSIDE; } else { @@ -701,11 +701,11 @@ void Foam::searchableCylinder::getVolumeType if (mag(v) > radius_) { - volType[pointI] = OUTSIDE; + volType[pointI] = volumeType::OUTSIDE; } else { - volType[pointI] = INSIDE; + volType[pointI] = volumeType::INSIDE; } } } diff --git a/src/meshTools/searchableSurface/searchableSphere.C b/src/meshTools/searchableSurface/searchableSphere.C index 5f3e98af90..3d17b52d9f 100644 --- a/src/meshTools/searchableSurface/searchableSphere.C +++ b/src/meshTools/searchableSurface/searchableSphere.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -334,7 +334,7 @@ void Foam::searchableSphere::getVolumeType ) const { volType.setSize(points.size()); - volType = INSIDE; + volType = volumeType::INSIDE; forAll(points, pointI) { @@ -342,11 +342,11 @@ void Foam::searchableSphere::getVolumeType if (magSqr(pt - centre_) <= sqr(radius_)) { - volType[pointI] = INSIDE; + volType[pointI] = volumeType::INSIDE; } else { - volType[pointI] = OUTSIDE; + volType[pointI] = volumeType::OUTSIDE; } } } diff --git a/src/meshTools/searchableSurface/searchableSurface.C b/src/meshTools/searchableSurface/searchableSurface.C index decd4c7259..102b8cc8ef 100644 --- a/src/meshTools/searchableSurface/searchableSurface.C +++ b/src/meshTools/searchableSurface/searchableSurface.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,26 +30,12 @@ License namespace Foam { - defineTypeNameAndDebug(searchableSurface, 0); - defineRunTimeSelectionTable(searchableSurface, dict); - template<> - const char* Foam::NamedEnum - < - Foam::searchableSurface::volumeType, - 4 - >::names[] = - { - "unknown", - "mixed", - "inside", - "outside" - }; +defineTypeNameAndDebug(searchableSurface, 0); +defineRunTimeSelectionTable(searchableSurface, dict); + } -const Foam::NamedEnum - Foam::searchableSurface::volumeTypeNames; - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/searchableSurface/searchableSurface.H b/src/meshTools/searchableSurface/searchableSurface.H index ac2bf0874f..90224ae9ce 100644 --- a/src/meshTools/searchableSurface/searchableSurface.H +++ b/src/meshTools/searchableSurface/searchableSurface.H @@ -48,6 +48,7 @@ SourceFiles #include "pointIndexHit.H" #include "linePointRef.H" #include "objectRegistry.H" +#include "volumeType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -67,25 +68,6 @@ class searchableSurface : public regIOobject { -public: - - // Data types - - //- Volume types - enum volumeType - { - UNKNOWN = 0, - MIXED = 1, // not used. only here to maintain consistency with - // indexedOctree volumeType. - INSIDE = 2, - OUTSIDE = 3 - }; - - static const NamedEnum volumeTypeNames; - - -private: - // Private data const word name_; diff --git a/src/meshTools/searchableSurface/searchableSurfacesQueries.C b/src/meshTools/searchableSurface/searchableSurfacesQueries.C index c7f7157d7e..2073de3d76 100644 --- a/src/meshTools/searchableSurface/searchableSurfacesQueries.C +++ b/src/meshTools/searchableSurface/searchableSurfacesQueries.C @@ -735,7 +735,7 @@ void Foam::searchableSurfacesQueries::signedDistance const labelList& surfacesToTest, const pointField& samples, const scalarField& nearestDistSqr, - const searchableSurface::volumeType illegalHandling, + const volumeType illegalHandling, labelList& nearestSurfaces, scalarField& distance ) @@ -775,7 +775,7 @@ void Foam::searchableSurfacesQueries::signedDistance } // Calculate sideness of these surface points - List volType; + List volType; allSurfaces[surfacesToTest[testI]].getVolumeType(surfPoints, volType); // Push back to original @@ -784,13 +784,13 @@ void Foam::searchableSurfacesQueries::signedDistance label pointI = surfIndices[i]; scalar dist = mag(samples[pointI] - nearestInfo[pointI].hitPoint()); - searchableSurface::volumeType vT = volType[i]; + volumeType vT = volType[i]; - if (vT == searchableSurface::OUTSIDE) + if (vT == volumeType::OUTSIDE) { distance[pointI] = dist; } - else if (vT == searchableSurface::INSIDE) + else if (vT == volumeType::INSIDE) { distance[i] = -dist; } @@ -798,12 +798,12 @@ void Foam::searchableSurfacesQueries::signedDistance { switch (illegalHandling) { - case searchableSurface::OUTSIDE: + case volumeType::OUTSIDE: { distance[pointI] = dist; break; } - case searchableSurface::INSIDE: + case volumeType::INSIDE: { distance[pointI] = -dist; break; @@ -817,7 +817,7 @@ void Foam::searchableSurfacesQueries::signedDistance << " surface:" << allSurfaces[surfacesToTest[testI]].name() << " volType:" - << searchableSurface::volumeTypeNames[vT] + << volumeType::names[vT] << exit(FatalError); break; } diff --git a/src/meshTools/searchableSurface/searchableSurfacesQueries.H b/src/meshTools/searchableSurface/searchableSurfacesQueries.H index 3c85186a4b..529d4b94fa 100644 --- a/src/meshTools/searchableSurface/searchableSurfacesQueries.H +++ b/src/meshTools/searchableSurface/searchableSurfacesQueries.H @@ -206,7 +206,7 @@ public: const labelList& surfacesToTest, const pointField& samples, const scalarField& nearestDistSqr, - const searchableSurface::volumeType illegalHandling, + const volumeType illegalHandling, labelList& nearestSurfaces, scalarField& distance ); diff --git a/src/meshTools/searchableSurface/triSurfaceMesh.C b/src/meshTools/searchableSurface/triSurfaceMesh.C index f95f84c3f4..2222981793 100644 --- a/src/meshTools/searchableSurface/triSurfaceMesh.C +++ b/src/meshTools/searchableSurface/triSurfaceMesh.C @@ -740,7 +740,7 @@ void Foam::triSurfaceMesh::getVolumeType // - use cached volume type per each tree node // - cheat conversion since same values - volType[pointI] = static_cast(tree().getVolumeType(pt)); + volType[pointI] = tree().getVolumeType(pt); } indexedOctree::perturbTol() = oldTol; diff --git a/src/sampling/sampledSurface/distanceSurface/distanceSurface.C b/src/sampling/sampledSurface/distanceSurface/distanceSurface.C index 7d9c4eace4..2dafe3e98a 100644 --- a/src/sampling/sampledSurface/distanceSurface/distanceSurface.C +++ b/src/sampling/sampledSurface/distanceSurface/distanceSurface.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,6 +29,7 @@ License #include "volPointInterpolation.H" #include "addToRunTimeSelectionTable.H" #include "fvMesh.H" +#include "volumeType.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -94,19 +95,19 @@ void Foam::distanceSurface::createGeometry() if (signed_) { - List volType; + List volType; surfPtr_().getVolumeType(cc, volType); forAll(volType, i) { - searchableSurface::volumeType vT = volType[i]; + volumeType vT = volType[i]; - if (vT == searchableSurface::OUTSIDE) + if (vT == volumeType::OUTSIDE) { fld[i] = Foam::mag(cc[i] - nearest[i].hitPoint()); } - else if (vT == searchableSurface::INSIDE) + else if (vT == volumeType::INSIDE) { fld[i] = -Foam::mag(cc[i] - nearest[i].hitPoint()); } @@ -146,19 +147,19 @@ void Foam::distanceSurface::createGeometry() if (signed_) { - List volType; + List volType; surfPtr_().getVolumeType(cc, volType); forAll(volType, i) { - searchableSurface::volumeType vT = volType[i]; + volumeType vT = volType[i]; - if (vT == searchableSurface::OUTSIDE) + if (vT == volumeType::OUTSIDE) { fld[i] = Foam::mag(cc[i] - nearest[i].hitPoint()); } - else if (vT == searchableSurface::INSIDE) + else if (vT == volumeType::INSIDE) { fld[i] = -Foam::mag(cc[i] - nearest[i].hitPoint()); } @@ -203,20 +204,20 @@ void Foam::distanceSurface::createGeometry() if (signed_) { - List volType; + List volType; surfPtr_().getVolumeType(pts, volType); forAll(volType, i) { - searchableSurface::volumeType vT = volType[i]; + volumeType vT = volType[i]; - if (vT == searchableSurface::OUTSIDE) + if (vT == volumeType::OUTSIDE) { pointDistance_[i] = Foam::mag(pts[i] - nearest[i].hitPoint()); } - else if (vT == searchableSurface::INSIDE) + else if (vT == volumeType::INSIDE) { pointDistance_[i] = -Foam::mag(pts[i] - nearest[i].hitPoint());