mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: searchableCone: searching on (optionally hollow) cone.
Initial implementation. Still goes wrong on r1 == r2.
This commit is contained in:
@ -65,6 +65,7 @@ searchableSurface = searchableSurface
|
||||
$(searchableSurface)/searchableBox.C
|
||||
$(searchableSurface)/searchableRotatedBox.C
|
||||
$(searchableSurface)/searchableCylinder.C
|
||||
$(searchableSurface)/searchableCone.C
|
||||
$(searchableSurface)/searchableDisk.C
|
||||
$(searchableSurface)/searchablePlane.C
|
||||
$(searchableSurface)/searchablePlate.C
|
||||
|
||||
1126
src/meshTools/searchableSurface/searchableCone.C
Normal file
1126
src/meshTools/searchableSurface/searchableCone.C
Normal file
File diff suppressed because it is too large
Load Diff
296
src/meshTools/searchableSurface/searchableCone.H
Normal file
296
src/meshTools/searchableSurface/searchableCone.H
Normal file
@ -0,0 +1,296 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::searchableCone
|
||||
|
||||
Description
|
||||
Searching on (optionally hollow) cone.
|
||||
|
||||
\heading Function object usage
|
||||
\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 |
|
||||
\endtable
|
||||
|
||||
Note
|
||||
Initial implementation, might suffer from robustness (e.g. radius1==radius2)
|
||||
|
||||
SourceFiles
|
||||
searchableCone.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef searchableCone_H
|
||||
#define searchableCone_H
|
||||
|
||||
#include "searchableSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class searchableCone Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class searchableCone
|
||||
:
|
||||
public searchableSurface
|
||||
{
|
||||
// Private Member Data
|
||||
|
||||
//- 'Left' point
|
||||
const point point1_;
|
||||
|
||||
//- Outer radius at point1
|
||||
const scalar radius1_;
|
||||
|
||||
//- Inner radius at point1
|
||||
const scalar innerRadius1_;
|
||||
|
||||
|
||||
//- 'Right' point
|
||||
const point point2_;
|
||||
|
||||
//- Outer radius at point2
|
||||
const scalar radius2_;
|
||||
|
||||
//- Inner radius at point2
|
||||
const scalar innerRadius2_;
|
||||
|
||||
|
||||
//- Length of vector point2-point1
|
||||
const scalar magDir_;
|
||||
|
||||
//- Normalised vector point2-point1
|
||||
const vector unitDir_;
|
||||
|
||||
|
||||
//- Names of regions
|
||||
mutable wordList regions_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Find nearest point on cylinder.
|
||||
void findNearest
|
||||
(
|
||||
const point& sample,
|
||||
const scalar nearestDistSqr,
|
||||
pointIndexHit & nearInfo,
|
||||
vector& normal
|
||||
) const;
|
||||
|
||||
//- Determine radial coordinate (squared)
|
||||
static scalar radius2(const searchableCone& cone, const point& pt);
|
||||
|
||||
//- Find both intersections with cone. innerRadii supplied externally.
|
||||
void findLineAll
|
||||
(
|
||||
const searchableCone& cone,
|
||||
const scalar innerRadius1,
|
||||
const scalar innerRadius2,
|
||||
const point& start,
|
||||
const point& end,
|
||||
pointIndexHit& near,
|
||||
pointIndexHit& far
|
||||
) const;
|
||||
|
||||
//- Insert a hit if it differs (by a tolerance) from the existing ones
|
||||
void insertHit
|
||||
(
|
||||
const point& start,
|
||||
const point& end,
|
||||
List<pointIndexHit>& info,
|
||||
const pointIndexHit& hit
|
||||
) const;
|
||||
|
||||
//- Return the boundBox of the cylinder
|
||||
boundBox calcBounds() const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
searchableCone(const searchableCone&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const searchableCone&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
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
|
||||
);
|
||||
|
||||
//- Construct from dictionary (used by searchableSurface)
|
||||
searchableCone
|
||||
(
|
||||
const IOobject& io,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
|
||||
virtual ~searchableCone();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual const wordList& regions() const;
|
||||
|
||||
//- Whether supports volume type below
|
||||
virtual bool hasVolumeType() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Range of local indices that can be returned.
|
||||
virtual label size() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
//- Get representative set of element coordinates
|
||||
// Usually the element centres (should be of length size()).
|
||||
virtual tmp<pointField> coordinates() const;
|
||||
|
||||
//- Get bounding spheres (centre and radius squared), one per element.
|
||||
// Any point on element is guaranteed to be inside.
|
||||
virtual void boundingSpheres
|
||||
(
|
||||
pointField& centres,
|
||||
scalarField& radiusSqr
|
||||
) const;
|
||||
|
||||
//- Get the points that define the surface.
|
||||
virtual tmp<pointField> points() const;
|
||||
|
||||
//- Does any part of the surface overlap the supplied bound box?
|
||||
virtual bool overlaps(const boundBox& bb) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"searchableCone::overlaps(const boundBox&) const"
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Multiple point queries.
|
||||
|
||||
//- Find nearest point on cylinder
|
||||
virtual void findNearest
|
||||
(
|
||||
const pointField& sample,
|
||||
const scalarField& nearestDistSqr,
|
||||
List<pointIndexHit>&
|
||||
) const;
|
||||
|
||||
//- Find nearest intersection on line from start to end
|
||||
virtual void findLine
|
||||
(
|
||||
const pointField& start,
|
||||
const pointField& end,
|
||||
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
|
||||
(
|
||||
const pointField& start,
|
||||
const pointField& end,
|
||||
List<List<pointIndexHit> >&
|
||||
) const;
|
||||
|
||||
//- From a set of points and indices get the region
|
||||
virtual void getRegion
|
||||
(
|
||||
const List<pointIndexHit>&,
|
||||
labelList& region
|
||||
) const;
|
||||
|
||||
//- From a set of points and indices get the normal
|
||||
virtual void getNormal
|
||||
(
|
||||
const List<pointIndexHit>&,
|
||||
vectorField& normal
|
||||
) const;
|
||||
|
||||
//- Determine type (inside/outside/mixed) for point. unknown if
|
||||
// cannot be determined (e.g. non-manifold surface)
|
||||
virtual void getVolumeType
|
||||
(
|
||||
const pointField&,
|
||||
List<volumeType>&
|
||||
) const;
|
||||
|
||||
|
||||
// regIOobject implementation
|
||||
|
||||
bool writeData(Ostream&) const
|
||||
{
|
||||
notImplemented("searchableCone::writeData(Ostream&) const");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user