ENH: searchableCone: generalised hollow cone/cylinder

This commit is contained in:
mattijs 2015-10-30 18:11:02 +00:00
parent d5d062cbfe
commit 30fd47e7bd
7 changed files with 287 additions and 21 deletions

View File

@ -83,7 +83,7 @@ Foam::tmp<Foam::pointField> Foam::searchableCone::points() const
}
void Foam::searchableCone::findNearest
void Foam::searchableCone::findNearestAndNormal
(
const point& sample,
const scalar nearestDistSqr,
@ -780,7 +780,7 @@ void Foam::searchableCone::findNearest
forAll(samples, i)
{
vector normal;
findNearest(samples[i], nearestDistSqr[i], info[i], normal);
findNearestAndNormal(samples[i], nearestDistSqr[i], info[i], normal);
}
}
@ -1054,7 +1054,7 @@ void Foam::searchableCone::getNormal
if (info[i].hit())
{
pointIndexHit nearInfo;
findNearest
findNearestAndNormal
(
info[i].hitPoint(),
Foam::sqr(GREAT),

View File

@ -100,7 +100,7 @@ class searchableCone
// Private Member Functions
//- Find nearest point on cylinder.
void findNearest
void findNearestAndNormal
(
const point& sample,
const scalar nearestDistSqr,
@ -236,14 +236,6 @@ public:
List<pointIndexHit>&
) const;
//- Find any intersection on line from start to end
virtual void findLineAny
(
const pointField& start,
const pointField& end,
List<pointIndexHit>&
) const;
//- Find all intersections in order from start to end
virtual void findLineAll
(
@ -252,6 +244,14 @@ public:
List<List<pointIndexHit> >&
) const;
//- Find any intersection on line from start to end
virtual void findLineAny
(
const pointField& start,
const pointField& end,
List<pointIndexHit>&
) const;
//- From a set of points and indices get the region
virtual void getRegion
(
@ -277,7 +277,7 @@ public:
// regIOobject implementation
bool writeData(Ostream&) const
virtual bool writeData(Ostream&) const
{
notImplemented("searchableCone::writeData(Ostream&) const");
return false;

View File

@ -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) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,8 +43,6 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
/*---------------------------------------------------------------------------*\
Class searchableCylinder Declaration
\*---------------------------------------------------------------------------*/

View File

@ -55,8 +55,7 @@ Foam::searchableRotatedBox::searchableRotatedBox
io.db(),
io.readOpt(),
io.writeOpt(),
false, //io.registerObject(),
io.globalObject()
false //io.registerObject(),
),
treeBoundBox(point::zero, dict.lookup("span"))
),

View File

@ -56,10 +56,8 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
/*---------------------------------------------------------------------------*\
Class searchableRotatedBox Declaration
Class searchableRotatedBox Declaration
\*---------------------------------------------------------------------------*/
class searchableRotatedBox
@ -145,6 +143,9 @@ public:
// Single point queries.
//- Inherit findNearest from searchableSurface
using searchableSurface::findNearest;
//- Calculate nearest point on surface.
// Returns
// - bool : any point found nearer than nearestDistSqr

View File

@ -0,0 +1,153 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 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 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "subTriSurfaceMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(subTriSurfaceMesh, 0);
addToRunTimeSelectionTable(searchableSurface, subTriSurfaceMesh, dict);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::wordList Foam::subTriSurfaceMesh::patchNames(const triSurface& s)
{
const geometricSurfacePatchList& patches = s.patches();
wordList names(patches.size());
forAll(patches, patchI)
{
names[patchI] = patches[patchI].name();
}
return names;
}
Foam::labelList Foam::subTriSurfaceMesh::selectedRegions
(
const triSurface& s,
const wordReList& regionNames
)
{
const wordList names(patchNames(s));
labelList regions(names.size());
label compactI = 0;
forAll(names, regionI)
{
const word& name = names[regionI];
forAll(regionNames, i)
{
if (regionNames[i].match(name))
{
regions[compactI++] = regionI;
}
}
}
regions.setSize(compactI);
return regions;
}
Foam::triSurface Foam::subTriSurfaceMesh::subset
(
const IOobject& io,
const dictionary& dict
)
{
const word subGeomName(dict.lookup("surface"));
const triSurfaceMesh& s =
io.db().lookupObject<triSurfaceMesh>(subGeomName);
const wordReList regionNames(dict.lookup("patches"));
labelList regionMap(selectedRegions(s, regionNames));
if (regionMap.size() == 0)
{
FatalIOErrorIn
(
"subTriSurfaceMesh::subset"
"(\n"
" const IOobject&,\n"
" const dictionary&\n"
")",
dict
) << "Found no regions in triSurface matching " << regionNames
<< ". Valid regions are " << patchNames(s)
<< exit(FatalIOError);
}
labelList reverseRegionMap(s.patches().size(), -1);
forAll(regionMap, i)
{
reverseRegionMap[regionMap[i]] = i;
}
boolList isSelected(s.size(), false);
forAll(s, triI)
{
if (reverseRegionMap[s.triSurface::operator[](triI).region()] != -1)
{
isSelected[triI] = true;
}
}
labelList pointMap;
labelList faceMap;
return s.subsetMesh(isSelected, pointMap, faceMap);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::subTriSurfaceMesh::subTriSurfaceMesh
(
const IOobject& io,
const dictionary& dict
)
:
triSurfaceMesh(io, subset(io, dict))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::subTriSurfaceMesh::~subTriSurfaceMesh()
{}
// ************************************************************************* //

View File

@ -0,0 +1,115 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 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 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 <http://www.gnu.org/licenses/>.
Class
Foam::subTriSurfaceMesh
Description
On-the-fly subset of triSurfaceMesh (based on selected patches)
Note
Example usage:
\verbatim
spheres.stl
{
type subTriSurfaceMesh;
// Surface to operate on. Avoid duplicate loading
surface spheres.stl;
// Regions to operate on (regular expressions allowed)
patches (solid1);
}
\endverbatim
SourceFiles
subTriSurfaceMesh.C
\*---------------------------------------------------------------------------*/
#ifndef subTriSurfaceMesh_H
#define subTriSurfaceMesh_H
#include "triSurfaceMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class subTriSurfaceMesh Declaration
\*---------------------------------------------------------------------------*/
class subTriSurfaceMesh
:
public triSurfaceMesh
{
// Private member functions
//- Extract patch names of triSurface
static wordList patchNames(const triSurface& s);
//- Select regions by name
static labelList selectedRegions
(
const triSurface& s,
const wordReList& regionNames
);
//- Subset triSurface based on regions
static triSurface subset(const IOobject&, const dictionary&);
public:
//- Runtime type information
TypeName("subTriSurfaceMesh");
// Constructors
//- Construct from IO and dictionary.
subTriSurfaceMesh
(
const IOobject& io,
const dictionary& dict
);
//- Destructor
virtual ~subTriSurfaceMesh();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //