From d530bc254aa09997fe5b51867a52c3e7bcea66b2 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 6 Jul 2018 11:03:28 +0200 Subject: [PATCH] STYLE: code cleanup searchableSurface (issue #929) - improve doxygen entries for searchable surfaces. - support selection of searchable surfaces with shorter names. Eg, type box | cylinder | ...; vs type searchableBox | searchableCylinder | ...; --- .../closedTriSurfaceMesh.C | 12 +- .../closedTriSurfaceMesh.H | 9 +- .../searchableBox/searchableBox.C | 50 ++++--- .../searchableBox/searchableBox.H | 26 ++-- .../searchableCone/searchableCone.C | 103 ++++++------- .../searchableCone/searchableCone.H | 55 +++---- .../searchableCylinder/searchableCylinder.C | 70 +++++---- .../searchableCylinder/searchableCylinder.H | 36 +++-- .../searchableDisk/searchableDisk.C | 36 +++-- .../searchableDisk/searchableDisk.H | 36 +++-- .../searchableExtrudedCircle.C | 11 +- .../searchableExtrudedCircle.H | 22 ++- .../searchablePlane/searchablePlane.C | 24 +-- .../searchablePlane/searchablePlane.H | 24 +-- .../searchablePlate/searchablePlate.C | 36 +++-- .../searchablePlate/searchablePlate.H | 18 ++- .../searchableRotatedBox.C | 41 +++--- .../searchableRotatedBox.H | 27 +++- .../searchableSphere/searchableSphere.C | 46 +++--- .../searchableSphere/searchableSphere.H | 42 ++++-- .../searchableSurface/searchableSurface.C | 14 +- .../searchableSurface/searchableSurface.H | 15 +- .../searchableSurfaceCollection.C | 40 +++-- .../searchableSurfaceCollection.H | 24 +-- .../searchableSurfaceWithGaps.C | 30 ++-- .../searchableSurfaceWithGaps.H | 29 ++-- .../searchableSurfaces/searchableSurfaces.C | 14 +- .../searchableSurfaces/searchableSurfaces.H | 37 ++++- .../searchableSurfacesQueries.C | 6 +- .../searchableSurfacesQueries.H | 4 +- .../subTriSurfaceMesh/subTriSurfaceMesh.C | 45 +++--- .../subTriSurfaceMesh/subTriSurfaceMesh.H | 10 +- .../triSurfaceMesh/triSurfaceMesh.C | 139 ++++++++---------- .../triSurfaceMesh/triSurfaceMesh.H | 25 +++- .../system/snappyHexMeshDict | 3 +- .../compartmentFire/system/snappyHexMeshDict | 9 +- .../RAS/membrane/system/snappyHexMeshDict | 2 +- .../RAS/aerofoilNACA0012/system/blockMeshDict | 2 +- .../system/snappyHexMeshDict | 2 +- .../aerofoilNACA0012/system/blockMeshDict | 2 +- .../injectorPipe/system/snappyHexMeshDict | 9 +- .../iglooWithFridges/system/snappyHexMeshDict | 19 ++- .../system/snappyHexMeshDict | 3 +- .../building/steady/system/snappyHexMeshDict | 2 +- .../system/snappyHexMeshDict | 4 +- .../system/snappyHexMeshDict | 4 +- .../RAS/TJunctionFan/system/createBafflesDict | 2 +- .../RAS/propeller/system/snappyHexMeshDict | 15 +- .../system/snappyHexMeshDict | 5 +- .../mixerVesselAMI2D/system/blockMeshDict.m4 | 16 +- .../motorBike/system/snappyHexMeshDict | 9 +- .../motorBike/system/snappyHexMeshDict | 9 +- .../rotorDisk/system/snappyHexMeshDict | 2 +- .../turbineSiting/system/snappyHexMeshDict | 15 +- .../system/snappyHexMeshDict | 4 +- .../cyclone/system/snappyHexMeshDict | 3 +- .../mixerVesselAMI2D/system/blockMeshDict.m4 | 16 +- .../mesh/blockMesh/pipe/system/blockMeshDict | 6 +- .../blockMesh/sphere/system/blockMeshDict | 2 +- .../blockMesh/sphere7/system/blockMeshDict | 2 +- .../system/blockMeshDict | 4 +- .../foamyHexMesh/blob/system/foamyHexMeshDict | 6 +- .../blob/system/snappyHexMeshDict | 8 +- .../simpleShapes/system/foamyHexMeshDict | 7 +- .../square/system/foamyQuadMeshDict | 6 +- .../system/snappyHexMeshDict | 38 ++--- .../system/snappyHexMeshDict | 2 +- .../system/snappyHexMeshDict | 9 +- .../flange/system/snappyHexMeshDict | 9 +- .../gap_detection/system/snappyHexMeshDict | 10 +- .../RAS/DTCHull/system/snappyHexMeshDict | 3 +- .../DTCHullMoving/system/snappyHexMeshDict | 3 +- .../system/createBafflesDict | 2 +- .../mixerVesselAMI/system/snappyHexMeshDict | 3 +- .../RAS/motorBike/system/snappyHexMeshDict | 2 +- .../sloshingCylinder/system/blockMeshDict | 8 +- .../sloshingCylinder/system/snappyHexMeshDict | 2 +- .../propeller/system/snappyHexMeshDict | 16 +- .../cavitatingBullet/system/snappyHexMeshDict | 7 +- .../mixerVesselAMI2D/system/blockMeshDict.m4 | 16 +- .../motorBike/system/snappyHexMeshDict | 9 +- .../system/snappyHexMeshDict | 11 +- 82 files changed, 804 insertions(+), 700 deletions(-) diff --git a/src/meshTools/searchableSurfaces/closedTriSurfaceMesh/closedTriSurfaceMesh.C b/src/meshTools/searchableSurfaces/closedTriSurfaceMesh/closedTriSurfaceMesh.C index b5ea3d9ec7..91ff585771 100644 --- a/src/meshTools/searchableSurfaces/closedTriSurfaceMesh/closedTriSurfaceMesh.C +++ b/src/meshTools/searchableSurfaces/closedTriSurfaceMesh/closedTriSurfaceMesh.C @@ -30,10 +30,8 @@ License namespace Foam { - -defineTypeNameAndDebug(closedTriSurfaceMesh, 0); -addToRunTimeSelectionTable(searchableSurface, closedTriSurfaceMesh, dict); - + defineTypeNameAndDebug(closedTriSurfaceMesh, 0); + addToRunTimeSelectionTable(searchableSurface, closedTriSurfaceMesh, dict); } @@ -65,10 +63,4 @@ Foam::closedTriSurfaceMesh::closedTriSurfaceMesh {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::closedTriSurfaceMesh::~closedTriSurfaceMesh() -{} - - // ************************************************************************* // diff --git a/src/meshTools/searchableSurfaces/closedTriSurfaceMesh/closedTriSurfaceMesh.H b/src/meshTools/searchableSurfaces/closedTriSurfaceMesh/closedTriSurfaceMesh.H index 3d53f3e4b6..7fba476649 100644 --- a/src/meshTools/searchableSurfaces/closedTriSurfaceMesh/closedTriSurfaceMesh.H +++ b/src/meshTools/searchableSurfaces/closedTriSurfaceMesh/closedTriSurfaceMesh.H @@ -52,7 +52,8 @@ class closedTriSurfaceMesh : public triSurfaceMesh { -private: + + // Private Member Functions //- No copy construct closedTriSurfaceMesh(const closedTriSurfaceMesh&) = delete; @@ -76,7 +77,7 @@ public: closedTriSurfaceMesh(const IOobject& io); //- Construct from IO and dictionary (used by searchableSurface). - // Dictionary may contain a 'scale' entry (eg, 0.001: mm -> m) + // Dictionary may contain a 'scale' entry (eg, 0.001: mm to m) closedTriSurfaceMesh ( const IOobject& io, @@ -84,9 +85,9 @@ public: ); - // Destructor + //- Destructor + virtual ~closedTriSurfaceMesh() = default; - virtual ~closedTriSurfaceMesh(); // Member Functions diff --git a/src/meshTools/searchableSurfaces/searchableBox/searchableBox.C b/src/meshTools/searchableSurfaces/searchableBox/searchableBox.C index 244c931ddd..d3daaa1852 100644 --- a/src/meshTools/searchableSurfaces/searchableBox/searchableBox.C +++ b/src/meshTools/searchableSurfaces/searchableBox/searchableBox.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,7 +32,19 @@ License namespace Foam { defineTypeNameAndDebug(searchableBox, 0); - addToRunTimeSelectionTable(searchableSurface, searchableBox, dict); + addToRunTimeSelectionTable + ( + searchableSurface, + searchableBox, + dict + ); + addNamedToRunTimeSelectionTable + ( + searchableSurface, + searchableBox, + dict, + box + ); } @@ -47,6 +59,7 @@ void Foam::searchableBox::projectOntoCoordPlane { // Set point info.rawPoint()[dir] = planePt[dir]; + // Set face if (planePt[dir] == min()[dir]) { @@ -92,7 +105,7 @@ Foam::pointIndexHit Foam::searchableBox::findNearest // (for internal points) per direction what nearest cube side is point near; - for (direction dir = 0; dir < vector::nComponents; dir++) + for (direction dir = 0; dir < vector::nComponents; ++dir) { if (info.rawPoint()[dir] < min()[dir]) { @@ -188,7 +201,7 @@ Foam::searchableBox::searchableBox ) : searchableSurface(io), - treeBoundBox(dict.lookup("min"), dict.lookup("max")) + treeBoundBox(dict.get("min"), dict.get("max")) { if (!contains(midpoint())) { @@ -201,12 +214,6 @@ Foam::searchableBox::searchableBox } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::searchableBox::~searchableBox() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // const Foam::wordList& Foam::searchableBox::regions() const @@ -222,8 +229,8 @@ const Foam::wordList& Foam::searchableBox::regions() const Foam::tmp Foam::searchableBox::coordinates() const { - tmp tCtrs(new pointField(6)); - pointField& ctrs = tCtrs.ref(); + auto tctrs = tmp::New(6); + auto& ctrs = tctrs.ref(); const pointField pts(treeBoundBox::points()); const faceList& fcs = treeBoundBox::faces; @@ -233,7 +240,7 @@ Foam::tmp Foam::searchableBox::coordinates() const ctrs[i] = fcs[i].centre(pts); } - return tCtrs; + return tctrs; } @@ -255,9 +262,9 @@ void Foam::searchableBox::boundingSpheres const face& f = fcs[i]; centres[i] = f.centre(pts); - forAll(f, fp) + for (const label pointi : f) { - const point& pt = pts[f[fp]]; + const point& pt = pts[pointi]; radiusSqr[i] = Foam::max ( @@ -303,7 +310,7 @@ Foam::pointIndexHit Foam::searchableBox::findNearestOnEdge // (for internal points) per direction what nearest cube side is point near; - for (direction dir = 0; dir < vector::nComponents; dir++) + for (direction dir = 0; dir < vector::nComponents; ++dir) { if (info.rawPoint()[dir] < min()[dir]) { @@ -405,7 +412,7 @@ Foam::pointIndexHit Foam::searchableBox::findLine { info.setHit(); - for (direction dir = 0; dir < vector::nComponents; dir++) + for (direction dir = 0; dir < vector::nComponents; ++dir) { if (info.rawPoint()[dir] == min()[dir]) { @@ -602,20 +609,23 @@ void Foam::searchableBox::getVolumeType ) const { volType.setSize(points.size()); - volType = volumeType::INSIDE; forAll(points, pointi) { const point& pt = points[pointi]; - for (direction dir = 0; dir < vector::nComponents; dir++) + volumeType vt = volumeType::INSIDE; + + for (direction dir=0; dir < vector::nComponents; ++dir) { if (pt[dir] < min()[dir] || pt[dir] > max()[dir]) { - volType[pointi] = volumeType::OUTSIDE; + vt = volumeType::OUTSIDE; break; } } + + volType[pointi] = vt; } } diff --git a/src/meshTools/searchableSurfaces/searchableBox/searchableBox.H b/src/meshTools/searchableSurfaces/searchableBox/searchableBox.H index be85f6bf7d..73a8b6c61e 100644 --- a/src/meshTools/searchableSurfaces/searchableBox/searchableBox.H +++ b/src/meshTools/searchableSurfaces/searchableBox/searchableBox.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,14 @@ Class Description Searching on bounding box + \heading Dictionary parameters + \table + Property | Description | Required | Default + type | box / searchableBox | selector | + min | minimum point for bounding box | yes | + max | maximum point for bounding box | yes | + \endtable + SourceFiles searchableBox.C @@ -43,8 +51,6 @@ SourceFiles namespace Foam { -// Forward declaration of classes - /*---------------------------------------------------------------------------*\ Class searchableBox Declaration \*---------------------------------------------------------------------------*/ @@ -54,8 +60,6 @@ class searchableBox public searchableSurface, public treeBoundBox { -private: - // Private Member Data mutable wordList regions_; @@ -109,14 +113,15 @@ public: ); //- Destructor - virtual ~searchableBox(); + virtual ~searchableBox() = default; // Member Functions + //- Names of regions virtual const wordList& regions() const; - //- Whether supports volume type below + //- Whether surface supports volume type (below) virtual bool hasVolumeType() const { return true; @@ -248,12 +253,11 @@ public: vectorField& normal ) const; - //- Determine type (inside/outside/mixed) for point. unknown if - // cannot be determined (e.g. non-manifold surface) + //- Determine type (inside/outside) for points. virtual void getVolumeType ( - const pointField&, - List& + const pointField& points, + List& volType ) const; diff --git a/src/meshTools/searchableSurfaces/searchableCone/searchableCone.C b/src/meshTools/searchableSurfaces/searchableCone/searchableCone.C index 4174a8abab..a28dc3600d 100644 --- a/src/meshTools/searchableSurfaces/searchableCone/searchableCone.C +++ b/src/meshTools/searchableSurfaces/searchableCone/searchableCone.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2015 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,7 +31,19 @@ License namespace Foam { defineTypeNameAndDebug(searchableCone, 0); - addToRunTimeSelectionTable(searchableSurface, searchableCone, dict); + addToRunTimeSelectionTable + ( + searchableSurface, + searchableCone, + dict + ); + addNamedToRunTimeSelectionTable + ( + searchableSurface, + searchableCone, + dict, + cone + ); } @@ -39,9 +51,7 @@ namespace Foam Foam::tmp Foam::searchableCone::coordinates() const { - tmp tCtrs(new pointField(1, 0.5*(point1_ + point2_))); - - return tCtrs; + return tmp::New(1, 0.5*(point1_ + point2_)); } @@ -71,13 +81,13 @@ void Foam::searchableCone::boundingSpheres Foam::tmp Foam::searchableCone::points() const { - tmp tPts(new pointField(2)); - pointField& pts = tPts.ref(); + auto tpts = tmp::New(2); + auto& pts = tpts.ref(); pts[0] = point1_; pts[1] = point2_; - return tPts; + return tpts; } @@ -92,7 +102,7 @@ void Foam::searchableCone::findNearestAndNormal vector v(sample - point1_); // Decompose sample-point1 into normal and parallel component - scalar parallel = (v & unitDir_); + const scalar parallel = (v & unitDir_); // Remove the parallel component and normalise v -= parallel*unitDir_; @@ -338,8 +348,8 @@ void Foam::searchableCone::findLineAll vector point1End(end-cone.point1_); // Quick rejection of complete vector outside endcaps - scalar s1 = point1Start&(cone.unitDir_); - scalar s2 = point1End&(cone.unitDir_); + scalar s1 = point1Start & (cone.unitDir_); + scalar s2 = point1End & (cone.unitDir_); if ((s1 < 0.0 && s2 < 0.0) || (s1 > cone.magDir_ && s2 > cone.magDir_)) { @@ -735,12 +745,12 @@ Foam::searchableCone::searchableCone ) : searchableSurface(io), - point1_(dict.lookup("point1")), - radius1_(readScalar(dict.lookup("radius1"))), - innerRadius1_(dict.lookupOrDefault("innerRadius1", 0.0)), - point2_(dict.lookup("point2")), - radius2_(readScalar(dict.lookup("radius2"))), - innerRadius2_(dict.lookupOrDefault("innerRadius2", 0.0)), + point1_(dict.get("point1")), + radius1_(dict.get("radius1")), + innerRadius1_(dict.lookupOrDefault("innerRadius1", 0)), + point2_(dict.get("point2")), + radius2_(dict.get("radius2")), + innerRadius2_(dict.lookupOrDefault("innerRadius2", 0)), magDir_(mag(point2_-point1_)), unitDir_((point2_-point1_)/magDir_) { @@ -748,12 +758,6 @@ Foam::searchableCone::searchableCone } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::searchableCone::~searchableCone() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // const Foam::wordList& Foam::searchableCone::regions() const @@ -775,6 +779,7 @@ void Foam::searchableCone::findNearest ) const { info.setSize(samples.size()); + forAll(samples, i) { vector normal; @@ -1071,48 +1076,36 @@ void Foam::searchableCone::getVolumeType ) const { volType.setSize(points.size()); - volType = volumeType::INSIDE; - forAll(points, pointI) + forAll(points, pointi) { - const point& pt = points[pointI]; + const point& pt = points[pointi]; + + volType[pointi] = volumeType::OUTSIDE; vector v(pt - point1_); // Decompose sample-point1 into normal and parallel component - scalar parallel = v & unitDir_; - scalar comp = parallel; - scalar compInner = parallel; + const scalar parallel = (v & unitDir_); - - scalar radius_sec = radius1_+comp*(radius2_-radius1_)/magDir_; - - scalar radius_sec_inner = - innerRadius1_ - +compInner*(innerRadius2_-innerRadius1_)/magDir_; - - if (parallel < 0) + // Quick rejection. Left of point1 endcap, or right of point2 endcap + if (parallel < 0 || parallel > magDir_) { - // Left of point1 endcap - volType[pointI] = volumeType::OUTSIDE; + continue; } - else if (parallel > magDir_) + + const scalar radius_sec = + radius1_ + parallel * (radius2_-radius1_)/magDir_; + + const scalar radius_sec_inner = + innerRadius1_ + parallel * (innerRadius2_-innerRadius1_)/magDir_; + + // Remove the parallel component + v -= parallel*unitDir_; + + if (mag(v) >= radius_sec_inner && mag(v) <= radius_sec) { - // Right of point2 endcap - volType[pointI] = volumeType::OUTSIDE; - } - else - { - // Remove the parallel component - v -= parallel*unitDir_; - if (mag(v) >= radius_sec_inner && mag(v) <= radius_sec) - { - volType[pointI] = volumeType::INSIDE; - } - else - { - volType[pointI] = volumeType::OUTSIDE; - } + volType[pointi] = volumeType::INSIDE; } } } diff --git a/src/meshTools/searchableSurfaces/searchableCone/searchableCone.H b/src/meshTools/searchableSurfaces/searchableCone/searchableCone.H index 25ad87f5c0..9681ea3b38 100644 --- a/src/meshTools/searchableSurfaces/searchableCone/searchableCone.H +++ b/src/meshTools/searchableSurfaces/searchableCone/searchableCone.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2015 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,15 +27,16 @@ Class Description Searching on (optionally hollow) cone. - \heading Function object usage + \heading Dictionary parameters \table - Property | Description | Required | Default value - point1 | coordinate of endpoint | yes | - radius1 | radius at point1 | yes | yes - innerRadius1 | inner radius at point1 | no | - point2 | coordinate of endpoint | yes | - radius2 | radius at point2 | yes | yes - innerRadius2 | inner radius at point2 | no | + Property | Description | Required | Default + type | code / searchableCone | selector | + point1 | coordinate of endpoint | yes | + radius1 | radius at point1 | yes | + innerRadius1| inner radius at point1 | no | 0 + point2 | coordinate of endpoint | yes | + radius2 | radius at point2 | yes | + innerRadius2| inner radius at point2 | no | 0 \endtable Note @@ -145,22 +146,22 @@ class searchableCone public: //- Runtime type information - TypeName("searchableCone"); + TypeName("searchableCone"); // Constructors //- Construct from components - searchableCone - ( - const IOobject& io, - const point& point1, - const scalar radius1, - const scalar innerRadius1, - const point& point2, - const scalar radius2, - const scalar innerRadius2 - ); + searchableCone + ( + const IOobject& io, + const point& point1, + const scalar radius1, + const scalar innerRadius1, + const point& point2, + const scalar radius2, + const scalar innerRadius2 + ); //- Construct from dictionary (used by searchableSurface) searchableCone @@ -171,15 +172,15 @@ public: //- Destructor - - virtual ~searchableCone(); + virtual ~searchableCone() = default; // Member Functions + //- Names of regions virtual const wordList& regions() const; - //- Whether supports volume type below + //- Whether supports volume type (below) virtual bool hasVolumeType() const { return true; @@ -262,12 +263,12 @@ public: vectorField& normal ) const; - //- Determine type (inside/outside/mixed) for point. unknown if - // cannot be determined (e.g. non-manifold surface) + //- Determine type (inside/outside/mixed) for point. + // Unknown if cannot be determined (e.g. non-manifold surface) virtual void getVolumeType ( - const pointField&, - List& + const pointField& points, + List& volType ) const; diff --git a/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.C b/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.C index 6ffd74f8ca..7557567aaf 100644 --- a/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.C +++ b/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,7 +31,19 @@ License namespace Foam { defineTypeNameAndDebug(searchableCylinder, 0); - addToRunTimeSelectionTable(searchableSurface, searchableCylinder, dict); + addToRunTimeSelectionTable + ( + searchableSurface, + searchableCylinder, + dict + ); + addNamedToRunTimeSelectionTable + ( + searchableSurface, + searchableCylinder, + dict, + cylinder + ); } @@ -39,9 +51,7 @@ namespace Foam Foam::tmp Foam::searchableCylinder::coordinates() const { - tmp tCtrs(new pointField(1, 0.5*(point1_ + point2_))); - - return tCtrs; + return tmp::New(1, 0.5*(point1_ + point2_)); } @@ -64,13 +74,13 @@ void Foam::searchableCylinder::boundingSpheres Foam::tmp Foam::searchableCylinder::points() const { - tmp tPts(new pointField(2)); - pointField& pts = tPts.ref(); + auto tpts = tmp::New(2); + auto& pts = tpts.ref(); pts[0] = point1_; pts[1] = point2_; - return tPts; + return tpts; } @@ -180,7 +190,7 @@ Foam::pointIndexHit Foam::searchableCylinder::findNearest Foam::scalar Foam::searchableCylinder::radius2(const point& pt) const { const vector x = (pt-point1_) ^ unitDir_; - return x&x; + return (x & x); } @@ -500,22 +510,16 @@ Foam::searchableCylinder::searchableCylinder ) : searchableSurface(io), - point1_(dict.lookup("point1")), - point2_(dict.lookup("point2")), + point1_(dict.get("point1")), + point2_(dict.get("point2")), magDir_(mag(point2_-point1_)), unitDir_((point2_-point1_)/magDir_), - radius_(readScalar(dict.lookup("radius"))) + radius_(dict.get("radius")) { bounds() = calcBounds(); } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::searchableCylinder::~searchableCylinder() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // const Foam::wordList& Foam::searchableCylinder::regions() const @@ -660,7 +664,7 @@ void Foam::searchableCylinder::getNormal vector v(info[i].hitPoint() - point1_); // Decompose sample-point1 into normal and parallel component - scalar parallel = (v & unitDir_); + const scalar parallel = (v & unitDir_); // Remove the parallel component and normalise v -= parallel*unitDir_; @@ -728,25 +732,21 @@ void Foam::searchableCylinder::getVolumeType ) const { volType.setSize(points.size()); - volType = volumeType::INSIDE; forAll(points, pointi) { const point& pt = points[pointi]; + volType[pointi] = volumeType::OUTSIDE; + vector v(pt - point1_); // Decompose sample-point1 into normal and parallel component - scalar parallel = v & unitDir_; + const scalar parallel = (v & unitDir_); - if (parallel < 0) + // Quick rejection. Left of point1 endcap, or right of point2 endcap + if (parallel < 0 || parallel > magDir_) { - // left of point1 endcap - volType[pointi] = volumeType::OUTSIDE; - } - else if (parallel > magDir_) - { - // right of point2 endcap volType[pointi] = volumeType::OUTSIDE; } else @@ -754,14 +754,12 @@ void Foam::searchableCylinder::getVolumeType // Remove the parallel component v -= parallel*unitDir_; - if (mag(v) > radius_) - { - volType[pointi] = volumeType::OUTSIDE; - } - else - { - volType[pointi] = volumeType::INSIDE; - } + volType[pointi] = + ( + mag(v) <= radius_ + ? volumeType::INSIDE + : volumeType::OUTSIDE + ); } } } diff --git a/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.H b/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.H index 9c44b8bb78..69a5688ea7 100644 --- a/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.H +++ b/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,7 +25,16 @@ Class Foam::searchableCylinder Description - Searching on cylinder + Searching on a cylinder. + + \heading Dictionary parameters + \table + Property | Description | Required | Default + type | cylinder / searchableCylinder | selector | + point1 | coordinate of endpoint | yes | + point2 | coordinate of endpoint | yes | + radius | cylinder radius | yes | + \endtable SourceFiles searchableCylinder.C @@ -55,10 +64,10 @@ private: // Private Member Data - //- 'left' point + //- The 'left' point const point point1_; - //- 'right' point + //- The 'right' point const point point2_; //- Length of vector point2-point1 @@ -67,7 +76,7 @@ private: //- Normalised vector point2-point1 const vector unitDir_; - //- Radius squared + //- The radius const scalar radius_; //- Names of regions @@ -119,8 +128,8 @@ public: searchableCylinder ( const IOobject& io, - const point&, - const point&, + const point& point1, + const point& point2, const scalar radius ); @@ -131,12 +140,14 @@ public: const dictionary& dict ); + //- Destructor - virtual ~searchableCylinder(); + virtual ~searchableCylinder() = default; // Member Functions + //- Names of regions virtual const wordList& regions() const; //- Whether supports volume type below @@ -170,7 +181,6 @@ public: virtual bool overlaps(const boundBox& bb) const { NotImplemented; - return false; } @@ -220,12 +230,12 @@ public: vectorField& normal ) const; - //- Determine type (inside/outside/mixed) for point. unknown if - // cannot be determined (e.g. non-manifold surface) + //- Determine type (inside/outside/mixed) for point. + // Unknown if cannot be determined (e.g. non-manifold surface) virtual void getVolumeType ( - const pointField&, - List& + const pointField& points, + List& volType ) const; diff --git a/src/meshTools/searchableSurfaces/searchableDisk/searchableDisk.C b/src/meshTools/searchableSurfaces/searchableDisk/searchableDisk.C index 0ed845d2e5..d75dff8ede 100644 --- a/src/meshTools/searchableSurfaces/searchableDisk/searchableDisk.C +++ b/src/meshTools/searchableSurfaces/searchableDisk/searchableDisk.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2014-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,10 +30,20 @@ License namespace Foam { - -defineTypeNameAndDebug(searchableDisk, 0); -addToRunTimeSelectionTable(searchableSurface, searchableDisk, dict); - + defineTypeNameAndDebug(searchableDisk, 0); + addToRunTimeSelectionTable + ( + searchableSurface, + searchableDisk, + dict + ); + addNamedToRunTimeSelectionTable + ( + searchableSurface, + searchableDisk, + dict, + disk + ); } @@ -50,7 +60,7 @@ Foam::pointIndexHit Foam::searchableDisk::findNearest vector v(sample - origin_); // Decompose sample-origin into normal and parallel component - scalar parallel = (v & normal_); + const scalar parallel = (v & normal_); // Remove the parallel component and normalise v -= parallel*normal_; @@ -90,7 +100,7 @@ void Foam::searchableDisk::findLine vector v(start - origin_); // Decompose sample-origin into normal and parallel component - scalar parallel = (v & normal_); + const scalar parallel = (v & normal_); if (sign(parallel) == sign((end - origin_) & normal_)) { @@ -160,9 +170,9 @@ Foam::searchableDisk::searchableDisk ) : searchableSurface(io), - origin_(dict.lookup("origin")), - normal_(dict.lookup("normal")), - radius_(readScalar(dict.lookup("radius"))) + origin_(dict.get("origin")), + normal_(dict.get("normal")), + radius_(dict.get("radius")) { normal_ /= mag(normal_); @@ -183,12 +193,6 @@ Foam::searchableDisk::searchableDisk } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::searchableDisk::~searchableDisk() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // const Foam::wordList& Foam::searchableDisk::regions() const diff --git a/src/meshTools/searchableSurfaces/searchableDisk/searchableDisk.H b/src/meshTools/searchableSurfaces/searchableDisk/searchableDisk.H index 1f66f47fa9..dbe3f9d247 100644 --- a/src/meshTools/searchableSurfaces/searchableDisk/searchableDisk.H +++ b/src/meshTools/searchableSurfaces/searchableDisk/searchableDisk.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2014-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,15 @@ Description Searching on circular disk given as origin, normal (gets normalised) and radius + \heading Dictionary parameters + \table + Property | Description | Required | Default + type | disk / searchableDisk | selector | + origin | centre of disk | yes | + normal | normal vector | yes | + radius | disk radius | yes | + \endtable + SourceFiles searchableDisk.C @@ -45,7 +54,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class searchableDisk Declaration + Class searchableDisk Declaration \*---------------------------------------------------------------------------*/ class searchableDisk @@ -56,13 +65,13 @@ private: // Private Member Data - //- origin + //- Origin const point origin_; - //- normal + //- Normal vector normal_; - //- radius + //- Radius const scalar radius_; //- Names of regions @@ -120,14 +129,15 @@ public: ); //- Destructor - virtual ~searchableDisk(); + virtual ~searchableDisk() = default; // Member Functions + //- Names of regions virtual const wordList& regions() const; - //- Whether supports volume type below + //- Whether supports volume type (below) virtual bool hasVolumeType() const { return false; @@ -143,8 +153,7 @@ public: // Usually the element centres (should be of length size()). virtual tmp coordinates() const { - tmp tCtrs(new pointField(1, origin_)); - return tCtrs; + return tmp::New(1, origin_); } //- Get bounding spheres (centre and radius squared), one per element. @@ -165,7 +174,6 @@ public: virtual bool overlaps(const boundBox& bb) const { NotImplemented; - return false; } @@ -215,12 +223,12 @@ public: vectorField& normal ) const; - //- Determine type (inside/outside/mixed) for point. unknown if - // cannot be determined (e.g. non-manifold surface) + //- Determine type (inside/outside/mixed) for point. + // Unknown if cannot be determined (e.g. non-manifold surface) virtual void getVolumeType ( - const pointField&, - List& + const pointField& points, + List& volType ) const; diff --git a/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C b/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C index 3d1b3f76c2..f531578355 100644 --- a/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C +++ b/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C @@ -43,6 +43,13 @@ namespace Foam searchableExtrudedCircle, dict ); + addNamedToRunTimeSelectionTable + ( + searchableSurface, + searchableExtrudedCircle, + dict, + extrudedCircle + ); } @@ -61,7 +68,7 @@ Foam::searchableExtrudedCircle::searchableExtrudedCircle ( IOobject ( - dict.lookup("file"), // name + dict.get("file"), // name io.time().constant(), // instance "geometry", // local io.time(), // registry @@ -71,7 +78,7 @@ Foam::searchableExtrudedCircle::searchableExtrudedCircle ).objectPath() ) ), - radius_(readScalar(dict.lookup("radius"))) + radius_(dict.get("radius")) { const edgeMesh& eMesh = eMeshPtr_(); diff --git a/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.H b/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.H index 83ac445ed4..482a8c5b3e 100644 --- a/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.H +++ b/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.H @@ -25,7 +25,18 @@ Class Foam::searchableExtrudedCircle Description - Searching on edgemesh with constant radius + Searching on edgeMesh with constant radius + + \heading Dictionary parameters + \table + Property | Description | Required | Default + type | extrudedCircle / searchableExtrudedCircle | selector | + file | The name of the edge mesh | yes | + radius | Search radius around the edges | yes | + \endtable + +Note + The edge mesh file is to be located in the constant/geometry directory. SourceFiles searchableExtrudedCircle.C @@ -43,10 +54,10 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward declarations class edgeMesh; class treeDataEdge; -template class indexedOctree; +template class indexedOctree; /*---------------------------------------------------------------------------*\ Class searchableExtrudedCircle Declaration @@ -102,6 +113,7 @@ public: // Member Functions + //- Names of regions virtual const wordList& regions() const; //- Whether supports volume type below @@ -206,8 +218,8 @@ public: vectorField& normal ) const; - //- Determine type (inside/outside/mixed) for point. unknown if - // cannot be determined (e.g. non-manifold surface) + //- Determine type (inside/outside/mixed) for point. + // Unknown if cannot be determined (e.g. non-manifold surface) virtual void getVolumeType ( const pointField&, diff --git a/src/meshTools/searchableSurfaces/searchablePlane/searchablePlane.C b/src/meshTools/searchableSurfaces/searchablePlane/searchablePlane.C index a5e7b0430d..9a9577c7f9 100644 --- a/src/meshTools/searchableSurfaces/searchablePlane/searchablePlane.C +++ b/src/meshTools/searchableSurfaces/searchablePlane/searchablePlane.C @@ -31,10 +31,20 @@ License namespace Foam { - -defineTypeNameAndDebug(searchablePlane, 0); -addToRunTimeSelectionTable(searchableSurface, searchablePlane, dict); - + defineTypeNameAndDebug(searchablePlane, 0); + addToRunTimeSelectionTable + ( + searchableSurface, + searchablePlane, + dict + ); + addNamedToRunTimeSelectionTable + ( + searchableSurface, + searchablePlane, + dict, + plane + ); } @@ -115,12 +125,6 @@ Foam::searchablePlane::searchablePlane } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::searchablePlane::~searchablePlane() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // const Foam::wordList& Foam::searchablePlane::regions() const diff --git a/src/meshTools/searchableSurfaces/searchablePlane/searchablePlane.H b/src/meshTools/searchableSurfaces/searchablePlane/searchablePlane.H index 66e63c4de9..33518a4668 100644 --- a/src/meshTools/searchableSurfaces/searchablePlane/searchablePlane.H +++ b/src/meshTools/searchableSurfaces/searchablePlane/searchablePlane.H @@ -25,7 +25,15 @@ Class Foam::searchablePlane Description - Searching on (infinite) plane. See plane.H + Searching on (infinite) plane. + The dictionary specifications are identical to the Foam::plane + requirements. + + \heading Dictionary parameters + \table + Property | Description | Required | Default + type | plane / searchablePlane | selector | + \endtable SourceFiles searchablePlane.C @@ -43,8 +51,6 @@ SourceFiles namespace Foam { -// Forward declaration of classes - /*---------------------------------------------------------------------------*\ Class searchablePlane Declaration \*---------------------------------------------------------------------------*/ @@ -58,6 +64,7 @@ private: // Private Member Data + //- Names of regions mutable wordList regions_; @@ -103,11 +110,12 @@ public: ); //- Destructor - virtual ~searchablePlane(); + virtual ~searchablePlane() = default; // Member Functions + //- Names of regions virtual const wordList& regions() const; //- Whether supports volume type below @@ -126,8 +134,7 @@ public: // Usually the element centres (should be of length size()). virtual tmp coordinates() const { - tmp tCtrs(new pointField(1, refPoint())); - return tCtrs; + return tmp::New(1, refPoint()); } //- Get bounding spheres (centre and radius squared), one per element. @@ -149,7 +156,6 @@ public: virtual bool overlaps(const boundBox& bb) const { NotImplemented; - return false; } @@ -199,8 +205,8 @@ public: vectorField& normal ) const; - //- Determine type (inside/outside/mixed) for point. unknown if - // cannot be determined (e.g. non-manifold surface) + //- Determine type (inside/outside/mixed) for point. + // Unknown if cannot be determined (e.g. non-manifold surface) virtual void getVolumeType ( const pointField&, diff --git a/src/meshTools/searchableSurfaces/searchablePlate/searchablePlate.C b/src/meshTools/searchableSurfaces/searchablePlate/searchablePlate.C index 5d168e6c0f..865d13ebbf 100644 --- a/src/meshTools/searchableSurfaces/searchablePlate/searchablePlate.C +++ b/src/meshTools/searchableSurfaces/searchablePlate/searchablePlate.C @@ -32,7 +32,19 @@ License namespace Foam { defineTypeNameAndDebug(searchablePlate, 0); - addToRunTimeSelectionTable(searchableSurface, searchablePlate, dict); + addToRunTimeSelectionTable + ( + searchableSurface, + searchablePlate, + dict + ); + addNamedToRunTimeSelectionTable + ( + searchableSurface, + searchablePlate, + dict, + plate + ); } @@ -42,7 +54,7 @@ Foam::direction Foam::searchablePlate::calcNormal(const point& span) { direction normalDir = 3; - for (direction dir = 0; dir < vector::nComponents; dir++) + for (direction dir = 0; dir < vector::nComponents; ++dir) { if (span[dir] < 0) { @@ -96,7 +108,7 @@ Foam::pointIndexHit Foam::searchablePlate::findNearest info.rawPoint()[normalDir_] = origin_[normalDir_]; // Clip to edges if outside - for (direction dir = 0; dir < vector::nComponents; dir++) + for (direction dir = 0; dir < vector::nComponents; ++dir) { if (dir != normalDir_) { @@ -158,7 +170,7 @@ Foam::pointIndexHit Foam::searchablePlate::findLine info.rawPoint()[normalDir_] = origin_[normalDir_]; // Clip to edges - for (direction dir = 0; dir < vector::nComponents; dir++) + for (direction dir = 0; dir < vector::nComponents; ++dir) { if (dir != normalDir_) { @@ -236,8 +248,8 @@ Foam::searchablePlate::searchablePlate ) : searchableSurface(io), - origin_(dict.lookup("origin")), - span_(dict.lookup("span")), + origin_(dict.get("origin")), + span_(dict.get("span")), normalDir_(calcNormal(span_)) { if (debug) @@ -253,12 +265,6 @@ Foam::searchablePlate::searchablePlate } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::searchablePlate::~searchablePlate() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // const Foam::wordList& Foam::searchablePlate::regions() const @@ -297,8 +303,8 @@ void Foam::searchablePlate::boundingSpheres Foam::tmp Foam::searchablePlate::points() const { - tmp tPts(new pointField(4)); - pointField& pts = tPts.ref(); + auto tpts = tmp::New(4); + auto& pts = tpts.ref(); pts[0] = origin_; pts[2] = origin_ + span_; @@ -319,7 +325,7 @@ Foam::tmp Foam::searchablePlate::points() const pts[3] = origin_ + point(0, span_.y(), 0); } - return tPts; + return tpts; } diff --git a/src/meshTools/searchableSurfaces/searchablePlate/searchablePlate.H b/src/meshTools/searchableSurfaces/searchablePlate/searchablePlate.H index 6d85baeb74..b313541094 100644 --- a/src/meshTools/searchableSurfaces/searchablePlate/searchablePlate.H +++ b/src/meshTools/searchableSurfaces/searchablePlate/searchablePlate.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,11 +30,21 @@ Description Plate defined as origin and span. One of the components of span has to be 0 which defines the normal direction. E.g. + \verbatim span = (Sx Sy 0) // plate in x-y plane origin = (Ox Oy Oz) + \endverbatim now plane is from (Ox Oy Oz) to (Ox+Sx Oy+Sy Oz) + \heading Dictionary parameters + \table + Property | Description | Required | Default + type | plate / searchablePlate | selector | + origin | centre of the plate | yes | + span | The plate dimensions | yes | + \endtable + SourceFiles searchablePlate.C @@ -51,8 +61,6 @@ SourceFiles namespace Foam { -// Forward declaration of classes - /*---------------------------------------------------------------------------*\ Class searchablePlate Declaration \*---------------------------------------------------------------------------*/ @@ -72,6 +80,7 @@ private: //- Coordinate direction which is normal const direction normalDir_; + //- Names of regions mutable wordList regions_; @@ -127,11 +136,12 @@ public: //- Destructor - virtual ~searchablePlate(); + virtual ~searchablePlate() = default; // Member Functions + //- Names of regions virtual const wordList& regions() const; //- Whether supports volume type below diff --git a/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C b/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C index ab2329e744..13e85223e3 100644 --- a/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C +++ b/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2014 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,7 +32,19 @@ License namespace Foam { defineTypeNameAndDebug(searchableRotatedBox, 0); - addToRunTimeSelectionTable(searchableSurface, searchableRotatedBox, dict); + addToRunTimeSelectionTable + ( + searchableSurface, + searchableRotatedBox, + dict + ); + addNamedToRunTimeSelectionTable + ( + searchableSurface, + searchableRotatedBox, + dict, + rotatedBox + ); } @@ -57,26 +69,20 @@ Foam::searchableRotatedBox::searchableRotatedBox io.writeOpt(), false //io.registerObject(), ), - treeBoundBox(Zero, dict.lookup("span")) + treeBoundBox(Zero, dict.get("span")) ), transform_ ( "rotation", - dict.lookup("origin"), - dict.lookup("e3"), - dict.lookup("e1") + dict.get("origin"), + dict.get("e3"), + dict.get("e1") ) { points_ = transform_.globalPosition(box_.points()); } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::searchableRotatedBox::~searchableRotatedBox() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // const Foam::wordList& Foam::searchableRotatedBox::regions() const @@ -135,10 +141,8 @@ bool Foam::searchableRotatedBox::overlaps(const boundBox& bb) const // 3a. my edges through bb faces const edgeList& edges = treeBoundBox::edges; - forAll(edges, edgeI) + for (const edge& e : edges) { - const edge& e = edges[edgeI]; - point inter; if (treeBb.intersects(points_[e[0]], points_[e[1]], inter)) { @@ -150,15 +154,12 @@ bool Foam::searchableRotatedBox::overlaps(const boundBox& bb) const const pointField bbPoints(bb.points()); - forAll(fcs, faceI) + for (const face& f : fcs) { - const face& f = fcs[faceI]; point fc = f.centre(points_); - forAll(edges, edgeI) + for (const edge& e : edges) { - const edge& e = edges[edgeI]; - pointHit inter = f.intersection ( bbPoints[e[0]], diff --git a/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.H b/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.H index 9ac77123ba..cb28c26c29 100644 --- a/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.H +++ b/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2014 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,12 +33,22 @@ Description E.g. box with sides 1 1 1 rotated 45 degrees around z-axis at origin (0.5 0.5 0.5) \verbatim - span (1 1 1); + span (1 1 1); origin (0.5 0.5 0.5); e1 (1 1 0); e3 (0 0 1); \endverbatim + \heading Dictionary parameters + \table + Property | Description | Required | Default + type | rotatedBox / searchableRotatedBox | selector | + span | The box dimensions | yes | + origin | The box corner | yes | + e1 | Local x-axis of the box | yes | + e3 | Local z-axis of the box | yes | + \endtable + SourceFiles searchableRotatedBox.C @@ -68,13 +78,13 @@ private: // Private Member Data - //- box in local coordinate system + //- Box in local coordinate system searchableBox box_; - //- transformation from local to global coordinates + //- Transformation from local to global coordinates coordinateSystem transform_; - //- (global) corner points (in treeBoundBox order) + //- The (global) corner points (in treeBoundBox order) pointField points_; @@ -104,11 +114,12 @@ public: //- Destructor - virtual ~searchableRotatedBox(); + virtual ~searchableRotatedBox() = default; // Member Functions + //- Names of regions virtual const wordList& regions() const; //- Whether supports volume type below @@ -236,8 +247,8 @@ public: // cannot be determined (e.g. non-manifold surface) virtual void getVolumeType ( - const pointField&, - List& + const pointField& points, + List& volType ) const; diff --git a/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.C b/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.C index 512edb0740..16b9430ad4 100644 --- a/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.C +++ b/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,10 +30,20 @@ License namespace Foam { - -defineTypeNameAndDebug(searchableSphere, 0); -addToRunTimeSelectionTable(searchableSurface, searchableSphere, dict); - + defineTypeNameAndDebug(searchableSphere, 0); + addToRunTimeSelectionTable + ( + searchableSurface, + searchableSphere, + dict + ); + addNamedToRunTimeSelectionTable + ( + searchableSurface, + searchableSphere, + dict, + sphere + ); } @@ -148,8 +158,8 @@ Foam::searchableSphere::searchableSphere ) : searchableSurface(io), - centre_(dict.lookup("centre")), - radius_(readScalar(dict.lookup("radius"))) + centre_(dict.get("centre")), + radius_(dict.get("radius")) { bounds() = boundBox ( @@ -159,12 +169,6 @@ Foam::searchableSphere::searchableSphere } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::searchableSphere::~searchableSphere() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::searchableSphere::overlaps(const boundBox& bb) const @@ -351,20 +355,18 @@ void Foam::searchableSphere::getVolumeType ) const { volType.setSize(points.size()); - volType = volumeType::INSIDE; + + const scalar rad2 = sqr(radius_); forAll(points, pointi) { const point& pt = points[pointi]; - if (magSqr(pt - centre_) <= sqr(radius_)) - { - volType[pointi] = volumeType::INSIDE; - } - else - { - volType[pointi] = volumeType::OUTSIDE; - } + volType[pointi] = + ( + (magSqr(pt - centre_) <= rad2) + ? volumeType::INSIDE : volumeType::OUTSIDE + ); } } diff --git a/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.H b/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.H index 214343ea58..69ee3ce22a 100644 --- a/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.H +++ b/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,14 @@ Class Description Searching on sphere + \heading Dictionary parameters + \table + Property | Description | Required | Default + type | sphere / searchableSphere | selector | + centre | The sphere centre | yes | + radius | The (outside) radius of sphere | yes | + \endtable + SourceFiles searchableSphere.C @@ -43,10 +51,8 @@ SourceFiles namespace Foam { -// Forward declaration of classes - /*---------------------------------------------------------------------------*\ - Class searchableSphere Declaration + Class searchableSphere Declaration \*---------------------------------------------------------------------------*/ class searchableSphere @@ -57,10 +63,10 @@ private: // Private Member Data - //- Centre point + //- Centre point of the sphere const point centre_; - //- Radius + //- The outer radius of the sphere const scalar radius_; //- Names of regions @@ -105,7 +111,12 @@ public: // Constructors //- Construct from components - searchableSphere(const IOobject& io, const point&, const scalar radius); + searchableSphere + ( + const IOobject& io, + const point& centre, + const scalar radius + ); //- Construct from dictionary (used by searchableSurface) searchableSphere @@ -114,15 +125,17 @@ public: const dictionary& dict ); + //- Destructor - virtual ~searchableSphere(); + virtual ~searchableSphere() = default; // Member Functions + //- Names of regions virtual const wordList& regions() const; - //- Whether supports volume type below + //- Whether supports volume type (below) virtual bool hasVolumeType() const { return true; @@ -138,8 +151,7 @@ public: // Usually the element centres (should be of length size()). virtual tmp coordinates() const { - tmp tCtrs(new pointField(1, centre_)); - return tCtrs; + return tmp::New(1, centre_); } //- Get bounding spheres (centre and radius squared), one per element. @@ -205,12 +217,12 @@ public: vectorField& normal ) const; - //- Determine type (inside/outside/mixed) for point. unknown if - // cannot be determined (e.g. non-manifold surface) + //- Determine type (inside/outside/mixed) for point. + // Unknown if cannot be determined (e.g. non-manifold surface) virtual void getVolumeType ( - const pointField&, - List& + const pointField& points, + List& volType ) const; diff --git a/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.C b/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.C index 2b1a224a75..d7f2fab032 100644 --- a/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.C +++ b/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,14 +67,14 @@ Foam::searchableSurface::searchableSurface(const IOobject& io) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::searchableSurface::~searchableSurface() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +bool Foam::searchableSurface::hasVolumeType() const +{ + return false; +} + + void Foam::searchableSurface::findNearest ( const pointField& sample, diff --git a/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.H b/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.H index 2a5579f221..b64a48d78c 100644 --- a/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.H +++ b/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -55,7 +55,7 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward declarations class objectRegistry; class mapDistribute; class treeBoundBox; @@ -155,7 +155,7 @@ public: //- Destructor - virtual ~searchableSurface(); + virtual ~searchableSurface() = default; // Member Functions @@ -188,8 +188,9 @@ public: //- Names of regions virtual const wordList& regions() const = 0; - //- Whether supports volume type below - virtual bool hasVolumeType() const = 0; + //- Whether supports volume type (below). + // This is false for the base class. + virtual bool hasVolumeType() const; //- Range of local indices that can be returned virtual label size() const = 0; @@ -335,8 +336,8 @@ public: vectorField& normal ) const = 0; - //- Determine type (inside/outside) for point. unknown if - // cannot be determined (e.g. non-manifold surface) + //- Determine type (inside/outside) for point. + // Unknown if cannot be determined (e.g. non-manifold surface) virtual void getVolumeType ( const pointField&, diff --git a/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C b/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C index 953d153860..79603ea10b 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C +++ b/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C @@ -33,15 +33,13 @@ License namespace Foam { - -defineTypeNameAndDebug(searchableSurfaceCollection, 0); -addToRunTimeSelectionTable -( - searchableSurface, - searchableSurfaceCollection, - dict -); - + defineTypeNameAndDebug(searchableSurfaceCollection, 0); + addToRunTimeSelectionTable + ( + searchableSurface, + searchableSurfaceCollection, + dict + ); } @@ -182,7 +180,7 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection scale_(dict.size()), transform_(dict.size()), subGeom_(dict.size()), - mergeSubRegions_(dict.lookup("mergeSubRegions")), + mergeSubRegions_(dict.get("mergeSubRegions")), indexOffset_(dict.size()+1) { Info<< "SearchableCollection : " << name() << endl; @@ -197,7 +195,7 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection const dictionary& subDict = dict.subDict(instance_[surfI]); - scale_[surfI] = subDict.lookup("scale"); + subDict.read("scale", scale_[surfI]); transform_.set ( surfI, @@ -207,7 +205,7 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection ) ); - const word subGeomName(subDict.lookup("surface")); + const word subGeomName(subDict.get("surface")); //Pout<< "Trying to find " << subGeomName << endl; const searchableSurface& s = @@ -223,7 +221,7 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection << exit(FatalError); } - subGeom_.set(surfI, &const_cast(s)); + subGeom_.set(surfI, &(const_cast(s))); indexOffset_[surfI] = startIndex; startIndex += subGeom_[surfI].size(); @@ -303,9 +301,9 @@ const Foam::wordList& Foam::searchableSurfaceCollection::regions() const { const wordList& subRegions = subGeom_[surfI].regions(); - forAll(subRegions, i) + for (const word& regionName : subRegions) { - allRegions.append(instance_[surfI] + "_" + subRegions[i]); + allRegions.append(instance_[surfI] + "_" + regionName); } } } @@ -324,8 +322,8 @@ Foam::label Foam::searchableSurfaceCollection::size() const Foam::tmp Foam::searchableSurfaceCollection::coordinates() const { - tmp tCtrs(new pointField(size())); - pointField& ctrs = tCtrs.ref(); + auto tctrs = tmp::New(size()); + auto& ctrs = tctrs.ref(); // Append individual coordinates label coordI = 0; @@ -347,7 +345,7 @@ Foam::searchableSurfaceCollection::coordinates() const } } - return tCtrs; + return tctrs; } @@ -399,8 +397,8 @@ Foam::searchableSurfaceCollection::points() const nPoints += subGeom_[surfI].points()().size(); } - tmp tPts(new pointField(nPoints)); - pointField& pts = tPts.ref(); + auto tpts = tmp::New(nPoints); + auto& pts = tpts.ref(); // Append individual coordinates nPoints = 0; @@ -422,7 +420,7 @@ Foam::searchableSurfaceCollection::points() const } } - return tPts; + return tpts; } diff --git a/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.H b/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.H index 222c1477e1..f35b64d3f7 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.H +++ b/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.H @@ -28,6 +28,13 @@ Description Set of transformed searchableSurfaces. Does not do boolean operations so when meshing might find parts 'inside'. + \heading Dictionary parameters + \table + Property | Description | Required | Default + type | searchableSurfaceCollection | selector | + mergeSubRegions | boolean | yes | + \endtable + SourceFiles searchableSurfaceCollection.C @@ -40,7 +47,6 @@ SourceFiles #include "treeBoundBox.H" #include "coordinateSystem.H" #include "UPtrList.H" -#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -70,13 +76,13 @@ class searchableSurfaceCollection UPtrList subGeom_; - Switch mergeSubRegions_; + bool mergeSubRegions_; //- Offsets for indices coming from different surfaces // (sized with size() of each surface) labelList indexOffset_; - //- Region names + //- Names of regions mutable wordList regions_; //- From individual regions to collection regions @@ -164,9 +170,10 @@ public: return transform_; } + //- Names of regions virtual const wordList& regions() const; - //- Whether supports volume type below + //- Whether supports volume type (below) virtual bool hasVolumeType() const { return false; @@ -194,7 +201,6 @@ public: virtual bool overlaps(const boundBox& bb) const { NotImplemented; - return false; } @@ -244,12 +250,12 @@ public: vectorField& normal ) const; - //- Determine type (inside/outside/mixed) for point. unknown if - // cannot be determined (e.g. non-manifold surface) + //- Determine type (inside/outside/mixed) for point. + // Unknown if cannot be determined (e.g. non-manifold surface) virtual void getVolumeType ( - const pointField&, - List& + const pointField& points, + List& volType ) const; // Other diff --git a/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.C b/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.C index 7af6d6c8e8..6721a4bb5a 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.C +++ b/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.C @@ -32,10 +32,13 @@ License namespace Foam { - -defineTypeNameAndDebug(searchableSurfaceWithGaps, 0); -addToRunTimeSelectionTable(searchableSurface, searchableSurfaceWithGaps, dict); - + defineTypeNameAndDebug(searchableSurfaceWithGaps, 0); + addToRunTimeSelectionTable + ( + searchableSurface, + searchableSurfaceWithGaps, + dict + ); } @@ -178,26 +181,21 @@ Foam::searchableSurfaceWithGaps::searchableSurfaceWithGaps ) : searchableSurface(io), - gap_(readScalar(dict.lookup("gap"))), + gap_(dict.get("gap")), subGeom_(1) { - const word subGeomName(dict.lookup("surface")); + const word subGeomName(dict.get("surface")); - const searchableSurface& s = - io.db().lookupObject(subGeomName); - - subGeom_.set(0, &const_cast(s)); + subGeom_.set + ( + 0, + io.db().lookupObjectRefPtr(subGeomName) + ); bounds() = subGeom_[0].bounds(); } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::searchableSurfaceWithGaps::~searchableSurfaceWithGaps() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::searchableSurfaceWithGaps::findLine diff --git a/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.H b/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.H index fd0ad48be2..936a020dfd 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.H +++ b/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.H @@ -42,14 +42,20 @@ Description sphere { - type searchableSurfaceWithGaps; - // Underlying surface - surface sphere.stl; - // Perturb distance - gap 1e-3; + type searchableSurfaceWithGaps; + surface sphere.stl; // Underlying surface + gap 1e-3; // Perturb distance } \endverbatim + \heading Dictionary parameters + \table + Property | Description | Required | Default + type | searchableSurfaceWithGaps | selector | + surface | Name of the underlying surface | yes | + gap | Gap tolerance in meters | yes | + \endtable + SourceFiles searchableSurfaceWithGaps.C @@ -67,8 +73,6 @@ SourceFiles namespace Foam { -// Forward declaration of classes - /*---------------------------------------------------------------------------*\ Class searchableSurfaceWithGaps Declaration \*---------------------------------------------------------------------------*/ @@ -137,23 +141,24 @@ public: ); //- Destructor - virtual ~searchableSurfaceWithGaps(); + virtual ~searchableSurfaceWithGaps() = default; // Member Functions + //- The underlying searchableSurface const searchableSurface& surface() const { return subGeom_[0]; } - + //- Name of regions virtual const wordList& regions() const { return surface().regions(); } - //- Whether supports volume type below + //- Whether supports volume type (below) virtual bool hasVolumeType() const { return surface().hasVolumeType(); @@ -259,8 +264,8 @@ public: surface().getNormal(info, normal); } - //- Determine type (inside/outside/mixed) for point. unknown if - // cannot be determined (e.g. non-manifold surface) + //- Determine type (inside/outside/mixed) for points. + // Unknown if cannot be determined (e.g. non-manifold surface) virtual void getVolumeType ( const pointField& samples, diff --git a/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C b/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C index 6b2dc1470a..b989f7b503 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C +++ b/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C @@ -65,7 +65,6 @@ bool Foam::searchableSurfaces::connected // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct with length. Foam::searchableSurfaces::searchableSurfaces(const label size) : PtrList(size), @@ -90,7 +89,7 @@ Foam::searchableSurfaces::searchableSurfaces(const label size) // // // Make IOobject with correct name // autoPtr namedIO(io.clone()); -// namedIO().rename(dict.lookup("name")); +// namedIO().rename(dict.get("name")); // // // Create and hook surface // set @@ -98,7 +97,7 @@ Foam::searchableSurfaces::searchableSurfaces(const label size) // surfI, // searchableSurface::New // ( -// dict.lookup("type"), +// dict.get("type"), // namedIO(), // dict // ) @@ -140,7 +139,7 @@ Foam::searchableSurfaces::searchableSurfaces(const label size) // << exit(FatalError); // } // -// globalNames[index] = word(regionDict.lookup("name")); +// globalNames[index] = regionDict.get("name"); // } // } // } @@ -193,8 +192,7 @@ Foam::searchableSurfaces::searchableSurfaces const dictionary& dict = topDict.subDict(key); - names_[surfI] = key; - dict.readIfPresent("name", names_[surfI]); + names_[surfI] = dict.lookupOrDefault("name", key); // Make IOobject with correct name autoPtr namedIO(io.clone()); @@ -211,7 +209,7 @@ Foam::searchableSurfaces::searchableSurfaces surfI, searchableSurface::New ( - dict.lookup("type"), + dict.get("type"), namedIO(), dict ) @@ -262,7 +260,7 @@ Foam::searchableSurfaces::searchableSurfaces << exit(FatalError); } - rNames[index] = word(regionDict.lookup("name")); + rNames[index] = regionDict.get("name"); } } } diff --git a/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.H b/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.H index bcec55ed07..7397eafc4f 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.H +++ b/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.H @@ -26,6 +26,28 @@ Class Description Container for searchableSurfaces. + The collection is specified as a dictionary. For example, + + \verbatim + geometry + { + surface1 + { + type ...; + } + surface2 + { + type ...; + } + } + \endverbatim + + \heading The Sub-dictionary parameters + \table + Property | Description | Required | Default + name | alternative name for surface | no | dict name + regions | Region names sub-dictionary | no | + \endtable SourceFiles searchableSurfaces.C @@ -44,7 +66,7 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward declarations class triSurface; /*---------------------------------------------------------------------------*\ @@ -99,10 +121,11 @@ public: ////- Construct from list of dictionaries //searchableSurfaces(const IOobject&, const PtrList&); - //- Construct from dictionary and whether to construct names always - // as surfaceName "_" regionName (singleRegionName false) or - // for single region surfaces as surfaceName only (singleRegionName - // true) + //- Construct from dictionary. + // \param singleRegionName controls if names are constructed as + // surfaceName "_" regionName (singleRegionName false) or for + // single region surfaces as surfaceName only (singleRegionName + // true) searchableSurfaces ( const IOobject&, @@ -113,21 +136,25 @@ public: // Member Functions + //- Surface names, not region names const wordList& names() const { return names_; } + //- Surface names, not region names wordList& names() { return names_; } + //- Region names per surface const List& regionNames() const { return regionNames_; } + //- Region names per surface List& regionNames() { return regionNames_; diff --git a/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.C b/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.C index cbf2b64764..4020fb3dc0 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.C +++ b/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.C @@ -659,14 +659,14 @@ void Foam::searchableSurfacesQueries::signedDistance Foam::boundBox Foam::searchableSurfacesQueries::bounds ( const PtrList& allSurfaces, - const labelList& surfacesToTest + const labelUList& surfacesToTest ) { boundBox bb(boundBox::invertedBox); - forAll(surfacesToTest, testi) + for (const label surfi : surfacesToTest) { - bb.add(allSurfaces[surfacesToTest[testi]].bounds()); + bb.add(allSurfaces[surfi].bounds()); } return bb; diff --git a/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.H b/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.H index bf863e96cf..7f3944df6a 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.H +++ b/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.H @@ -42,7 +42,7 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward declarations class plane; class pointConstraint; @@ -171,7 +171,7 @@ public: static boundBox bounds ( const PtrList& allSurfaces, - const labelList& surfacesToTest + const labelUList& surfacesToTest ); }; diff --git a/src/meshTools/searchableSurfaces/subTriSurfaceMesh/subTriSurfaceMesh.C b/src/meshTools/searchableSurfaces/subTriSurfaceMesh/subTriSurfaceMesh.C index 37378dc796..ff7a935112 100644 --- a/src/meshTools/searchableSurfaces/subTriSurfaceMesh/subTriSurfaceMesh.C +++ b/src/meshTools/searchableSurfaces/subTriSurfaceMesh/subTriSurfaceMesh.C @@ -30,22 +30,26 @@ License namespace Foam { - -defineTypeNameAndDebug(subTriSurfaceMesh, 0); -addToRunTimeSelectionTable(searchableSurface, subTriSurfaceMesh, dict); - + defineTypeNameAndDebug(subTriSurfaceMesh, 0); + addToRunTimeSelectionTable + ( + searchableSurface, + subTriSurfaceMesh, + dict + ); } + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::wordList Foam::subTriSurfaceMesh::patchNames(const triSurface& s) { - const geometricSurfacePatchList& patches = s.patches(); + const auto& patches = s.patches(); wordList names(patches.size()); - forAll(patches, patchI) + forAll(patches, patchi) { - names[patchI] = patches[patchI].name(); + names[patchi] = patches[patchi].name(); } return names; } @@ -54,30 +58,25 @@ Foam::wordList Foam::subTriSurfaceMesh::patchNames(const triSurface& s) Foam::labelList Foam::subTriSurfaceMesh::selectedRegions ( const triSurface& s, - const UList& regionNames + const wordRes& regionNameMatcher ) { const wordList names(patchNames(s)); - labelList regions(names.size()); + labelList regionIds(names.size()); - label compactI = 0; + label count = 0; - forAll(names, regionI) + forAll(names, regioni) { - const word& name = names[regionI]; - - forAll(regionNames, i) + if (regionNameMatcher.match(names[regioni])) { - if (regionNames[i].match(name)) - { - regions[compactI++] = regionI; - } + regionIds[count++] = regioni; } } - regions.setSize(compactI); + regionIds.setSize(count); - return regions; + return regionIds; } @@ -87,16 +86,16 @@ Foam::triSurface Foam::subTriSurfaceMesh::subset const dictionary& dict ) { - const word subGeomName(dict.lookup("surface")); + const word subGeomName(dict.get("surface")); const triSurfaceMesh& s = io.db().lookupObject(subGeomName); - const wordRes regionNames(dict.lookup("patches")); + const wordRes regionNames(dict.get("patches")); labelList regionMap(selectedRegions(s, regionNames)); - if (regionMap.size() == 0) + if (regionMap.empty()) { FatalIOErrorInFunction(dict) << "Found no regions in triSurface matching " << regionNames diff --git a/src/meshTools/searchableSurfaces/subTriSurfaceMesh/subTriSurfaceMesh.H b/src/meshTools/searchableSurfaces/subTriSurfaceMesh/subTriSurfaceMesh.H index 637f6a1025..ec78b0cdd8 100644 --- a/src/meshTools/searchableSurfaces/subTriSurfaceMesh/subTriSurfaceMesh.H +++ b/src/meshTools/searchableSurfaces/subTriSurfaceMesh/subTriSurfaceMesh.H @@ -43,6 +43,13 @@ Note } \endverbatim + \heading Dictionary parameters + \table + Property | Description | Required | Default + type | subTriSurfaceMesh | selector | + surface | Name of the underlying surface | yes | + patches | List of surface region names or regexs | yes | + \endtable SourceFiles subTriSurfaceMesh.C @@ -76,7 +83,7 @@ class subTriSurfaceMesh static labelList selectedRegions ( const triSurface& s, - const UList& regionNames + const wordRes& regionNameMatcher ); //- Subset triSurface based on regions @@ -101,6 +108,7 @@ public: //- Destructor virtual ~subTriSurfaceMesh() = default; + }; diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C index 473fc1b964..d65893028f 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,9 +37,11 @@ namespace Foam { defineTypeNameAndDebug(triSurfaceMesh, 0); addToRunTimeSelectionTable(searchableSurface, triSurfaceMesh, dict); - word triSurfaceMesh::meshSubDir = "triSurface"; } +Foam::word Foam::triSurfaceMesh::meshSubDir = "triSurface"; + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::fileName Foam::triSurfaceMesh::checkFile @@ -136,19 +138,13 @@ bool Foam::triSurfaceMesh::addFaceToEdge EdgeMap