treeDataTriSurface.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "treeDataTriSurface.H"
30#include "triSurfaceTools.H"
31
32// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34template<>
36(
38 const point& sample
39) const
40{
41 // Find nearest face to sample
42 const pointIndexHit info = oc.findNearest(sample, sqr(GREAT));
43
44 if (info.index() == -1)
45 {
47 << "Could not find " << sample << " in octree."
48 << abort(FatalError);
49 }
50
51 // Get actual intersection point on face
52 const label facei = info.index();
53
54 const triSurfaceTools::sideType t = triSurfaceTools::surfaceSide
55 (
56 patch_,
57 sample,
58 facei
59 );
60
61 if (t == triSurfaceTools::UNKNOWN)
62 {
63 return volumeType::UNKNOWN;
64 }
65 else if (t == triSurfaceTools::INSIDE)
66 {
67 return volumeType::INSIDE;
68 }
69 else if (t == triSurfaceTools::OUTSIDE)
70 {
71 return volumeType::OUTSIDE;
72 }
73 else
74 {
76 << "problem" << abort(FatalError);
77 return volumeType::UNKNOWN;
78 }
79}
80
81
82// ************************************************************************* //
Minimal example by using system/controlDict.functions:
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:66
label index() const noexcept
Return the hit index.
Non-pointer based hierarchical recursive searching.
Definition: indexedOctree.H:74
Encapsulation of data needed to search on PrimitivePatches.
volumeType getVolumeType(const indexedOctree< treeDataPrimitivePatch< PatchType > > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
sideType
On which side of surface.
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition: volumeType.H:61
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
dimensionedSymmTensor sqr(const dimensionedVector &dv)
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError