diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index 9f849c58945b11d04d9193da1fe201653c09f01d..743a34eeec0d69ea3afa111d516b724c3f4714ae 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -65,6 +65,7 @@ $(searchableSurface)/searchableSurfaces.C $(searchableSurface)/searchableSurfacesQueries.C $(searchableSurface)/searchableSurfaceWithGaps.C $(searchableSurface)/triSurfaceMesh.C +$(searchableSurface)/closedTriSurfaceMesh.C topoSets = sets/topoSets $(topoSets)/cellSet.C diff --git a/src/meshTools/searchableSurface/closedTriSurfaceMesh.C b/src/meshTools/searchableSurface/closedTriSurfaceMesh.C new file mode 100644 index 0000000000000000000000000000000000000000..32064188a57b3b9dfb505e16543e89b9c29bbd54 --- /dev/null +++ b/src/meshTools/searchableSurface/closedTriSurfaceMesh.C @@ -0,0 +1,71 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "closedTriSurfaceMesh.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + +defineTypeNameAndDebug(closedTriSurfaceMesh, 0); +addToRunTimeSelectionTable(searchableSurface, closedTriSurfaceMesh, dict); + +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::closedTriSurfaceMesh::closedTriSurfaceMesh(const IOobject& io, const triSurface& s) +: + triSurfaceMesh(io, s) +{} + + +Foam::closedTriSurfaceMesh::closedTriSurfaceMesh(const IOobject& io) +: + triSurfaceMesh(io) +{} + + +Foam::closedTriSurfaceMesh::closedTriSurfaceMesh +( + const IOobject& io, + const dictionary& dict +) +: + triSurfaceMesh(io, dict) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::closedTriSurfaceMesh::~closedTriSurfaceMesh() +{} + + +// ************************************************************************* // diff --git a/src/meshTools/searchableSurface/closedTriSurfaceMesh.H b/src/meshTools/searchableSurface/closedTriSurfaceMesh.H new file mode 100644 index 0000000000000000000000000000000000000000..4ae351d6620288b8129067444c01d05dbebe3d33 --- /dev/null +++ b/src/meshTools/searchableSurface/closedTriSurfaceMesh.H @@ -0,0 +1,112 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::closedTriSurfaceMesh + +Description + A triSurfaceMesh where it is forced to check volumeTypes, used for surfaces + that are topologically non-manifold (small holes or multiple parts) but are + geometrically essentially closed + +SourceFiles + closedTriSurfaceMesh.C + +\*---------------------------------------------------------------------------*/ + +#ifndef closedTriSurfaceMesh_H +#define closedTriSurfaceMesh_H + +#include "triSurfaceMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class closedTriSurfaceMesh Declaration +\*---------------------------------------------------------------------------*/ + +class closedTriSurfaceMesh +: + public triSurfaceMesh +{ +private: + + //- Disallow default bitwise copy construct + closedTriSurfaceMesh(const closedTriSurfaceMesh&); + + //- Disallow default bitwise assignment + void operator=(const closedTriSurfaceMesh&); + + +public: + + //- Runtime type information + TypeName("closedTriSurfaceMesh"); + + + // Constructors + + //- Construct from triSurface + closedTriSurfaceMesh(const IOobject&, const triSurface&); + + //- Construct read. + closedTriSurfaceMesh(const IOobject& io); + + //- Construct from IO and dictionary (used by searchableSurface). + // Dictionary may contain a 'scale' entry (eg, 0.001: mm -> m) + closedTriSurfaceMesh + ( + const IOobject& io, + const dictionary& dict + ); + + + // Destructor + + virtual ~closedTriSurfaceMesh(); + + // Member Functions + + //- Whether supports volume type, forcing to true to force getVolumeType + // queries for this type + virtual bool hasVolumeType() const + { + return true; + } + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/searchableSurface/searchableBox.C b/src/meshTools/searchableSurface/searchableBox.C index cb9ca7e4426cbc0397baf64d7188f2f9f5e1213e..64e3273eb095c411c36de208364fbf08684b33d3 100644 --- a/src/meshTools/searchableSurface/searchableBox.C +++ b/src/meshTools/searchableSurface/searchableBox.C @@ -170,7 +170,9 @@ Foam::searchableBox::searchableBox : searchableSurface(io), treeBoundBox(bb) -{} +{ + bounds() = static_cast<boundBox>(*this); +} Foam::searchableBox::searchableBox @@ -181,7 +183,9 @@ Foam::searchableBox::searchableBox : searchableSurface(io), treeBoundBox(dict.lookup("min"), dict.lookup("max")) -{} +{ + bounds() = static_cast<boundBox>(*this); +} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/src/meshTools/searchableSurface/searchableCylinder.C b/src/meshTools/searchableSurface/searchableCylinder.C index fcaa42194aab42ce1f06f9e199f215548b92c627..2aafe100ee373964caeedd6344821fa41450e7ab 100644 --- a/src/meshTools/searchableSurface/searchableCylinder.C +++ b/src/meshTools/searchableSurface/searchableCylinder.C @@ -352,6 +352,22 @@ void Foam::searchableCylinder::findLineAll } +Foam::boundBox Foam::searchableCylinder::calcBounds() const +{ + // Approximating the boundBox by the extents of spheres, centred at the + // endpoints, of the same radius as the cylinder + + pointField bbPoints(4); + + bbPoints[0] = point1_ + radius_*vector::one; + bbPoints[1] = point1_ - radius_*vector::one; + bbPoints[2] = point2_ + radius_*vector::one; + bbPoints[3] = point2_ - radius_*vector::one; + + return boundBox(bbPoints); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::searchableCylinder::searchableCylinder @@ -368,7 +384,9 @@ Foam::searchableCylinder::searchableCylinder magDir_(mag(point2_-point1_)), unitDir_((point2_-point1_)/magDir_), radius_(radius) -{} +{ + bounds() = calcBounds(); +} Foam::searchableCylinder::searchableCylinder @@ -383,7 +401,9 @@ Foam::searchableCylinder::searchableCylinder magDir_(mag(point2_-point1_)), unitDir_((point2_-point1_)/magDir_), radius_(readScalar(dict.lookup("radius"))) -{} +{ + bounds() = calcBounds(); +} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/src/meshTools/searchableSurface/searchableCylinder.H b/src/meshTools/searchableSurface/searchableCylinder.H index cae0f058db2863db95ff479381d207c8ad9e57cf..254267db3a2630b53c9bd58f6c5d05ad80053b29 100644 --- a/src/meshTools/searchableSurface/searchableCylinder.H +++ b/src/meshTools/searchableSurface/searchableCylinder.H @@ -97,6 +97,8 @@ private: pointIndexHit& far ) const; + //- Return the boundBox of the cylinder + boundBox calcBounds() const; //- Disallow default bitwise copy construct searchableCylinder(const searchableCylinder&); diff --git a/src/meshTools/searchableSurface/searchablePlate.C b/src/meshTools/searchableSurface/searchablePlate.C index c72e28a7de2015c425cc0229fb818b3a166b298b..3babc3a4bc47a4a05dfa018fa16db17cbc39c986 100644 --- a/src/meshTools/searchableSurface/searchablePlate.C +++ b/src/meshTools/searchableSurface/searchablePlate.C @@ -227,6 +227,8 @@ Foam::searchablePlate::searchablePlate << " normal:" << vector::componentNames[normalDir_] << endl; } + + bounds() = boundBox(origin_, origin_ + span_); } @@ -249,6 +251,8 @@ Foam::searchablePlate::searchablePlate << " normal:" << vector::componentNames[normalDir_] << endl; } + + bounds() = boundBox(origin_, origin_ + span_); } diff --git a/src/meshTools/searchableSurface/searchablePlate.H b/src/meshTools/searchableSurface/searchablePlate.H index 7bc900f554bd3dc7a281873cf4b850077d5cf695..d839891c442dde41b89855984566e4ce35a21edf 100644 --- a/src/meshTools/searchableSurface/searchablePlate.H +++ b/src/meshTools/searchableSurface/searchablePlate.H @@ -93,7 +93,6 @@ private: const point& end ) const; - //- Disallow default bitwise copy construct searchablePlate(const searchablePlate&); diff --git a/src/meshTools/searchableSurface/searchableSphere.C b/src/meshTools/searchableSurface/searchableSphere.C index 287ae6743c2bb508c0ef64322036fac617123dcd..1de89fa019e7bcb89f5d223f9f2adfcd26d13179 100644 --- a/src/meshTools/searchableSurface/searchableSphere.C +++ b/src/meshTools/searchableSurface/searchableSphere.C @@ -133,7 +133,13 @@ Foam::searchableSphere::searchableSphere searchableSurface(io), centre_(centre), radius_(radius) -{} +{ + bounds() = boundBox + ( + centre_ + radius_*vector::one, + centre_ - radius_*vector::one + ); +} Foam::searchableSphere::searchableSphere @@ -145,7 +151,13 @@ Foam::searchableSphere::searchableSphere searchableSurface(io), centre_(dict.lookup("centre")), radius_(readScalar(dict.lookup("radius"))) -{} +{ + bounds() = boundBox + ( + centre_ + radius_*vector::one, + centre_ - radius_*vector::one + ); +} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/src/meshTools/searchableSurface/searchableSurface.H b/src/meshTools/searchableSurface/searchableSurface.H index 35b9dc9fb5a1ff9f3ba054492f7130ab2beee4a2..0ee49f729a7290493f2f93312887f6aaaa4f95c0 100644 --- a/src/meshTools/searchableSurface/searchableSurface.H +++ b/src/meshTools/searchableSurface/searchableSurface.H @@ -43,6 +43,7 @@ SourceFiles #define searchableSurface_H #include "pointField.H" +#include "boundBox.H" #include "typeInfo.H" #include "runTimeSelectionTables.H" #include "pointIndexHit.H" @@ -87,6 +88,8 @@ private: const word name_; + boundBox bounds_; + // Private Member Functions @@ -174,6 +177,17 @@ public: // Member Functions + //- Return const reference to boundBox + const boundBox& bounds() const + { + return bounds_; + } + + //- Return non-const access to the boundBox to allow it to be set. + boundBox& bounds() + { + return bounds_; + } //- Names of regions. virtual const wordList& regions() const = 0; diff --git a/src/meshTools/searchableSurface/searchableSurfacesQueries.C b/src/meshTools/searchableSurface/searchableSurfacesQueries.C index b0d6322a740b3fe42012a114fa4687a24d89aac8..8ae7e0b1cc63c7a2dd245dee55198c831933f3d7 100644 --- a/src/meshTools/searchableSurface/searchableSurfacesQueries.C +++ b/src/meshTools/searchableSurface/searchableSurfacesQueries.C @@ -688,6 +688,27 @@ void Foam::searchableSurfacesQueries::findNearest } +Foam::boundBox Foam::searchableSurfacesQueries::bounds +( + const PtrList<searchableSurface>& allSurfaces, + const labelList& surfacesToTest +) +{ + pointField bbPoints(2*surfacesToTest.size()); + + forAll(surfacesToTest, testI) + { + const searchableSurface& surface(allSurfaces[surfacesToTest[testI]]); + + bbPoints[2*testI] = surface.bounds().min(); + + bbPoints[2*testI + 1] = surface.bounds().max(); + } + + return boundBox(bbPoints); +} + + //- Calculate point which is on a set of surfaces. Foam::pointIndexHit Foam::searchableSurfacesQueries::facesIntersection ( diff --git a/src/meshTools/searchableSurface/searchableSurfacesQueries.H b/src/meshTools/searchableSurface/searchableSurfacesQueries.H index e6c6ce3bb9f250656b9c4d4a8cc5200319b7c793..7e336fc68fe5f1ea0c03db83cf2c51626a5f0248 100644 --- a/src/meshTools/searchableSurface/searchableSurfacesQueries.H +++ b/src/meshTools/searchableSurface/searchableSurfacesQueries.H @@ -172,6 +172,12 @@ public: List<pointIndexHit>& ); + //- Find the boundBox of the selected surfaces + static boundBox bounds + ( + const PtrList<searchableSurface>& allSurfaces, + const labelList& surfacesToTest + ); // Single point queries diff --git a/src/meshTools/searchableSurface/triSurfaceMesh.C b/src/meshTools/searchableSurface/triSurfaceMesh.C index 877f2643414d78b9fc986fa2d765b56aac04b816..8a2ea1ae79712b8af2a9279d2181c20456889fb8 100644 --- a/src/meshTools/searchableSurface/triSurfaceMesh.C +++ b/src/meshTools/searchableSurface/triSurfaceMesh.C @@ -238,7 +238,9 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io, const triSurface& s) ), triSurface(s), surfaceClosed_(-1) -{} +{ + bounds() = boundBox(points()); +} Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io) @@ -280,7 +282,9 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io) ) ), surfaceClosed_(-1) -{} +{ + bounds() = boundBox(points()); +} Foam::triSurfaceMesh::triSurfaceMesh @@ -334,6 +338,8 @@ Foam::triSurfaceMesh::triSurfaceMesh { triSurface::scalePoints(scaleFactor); } + + bounds() = boundBox(points()); }