surfaceLocation.H
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) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 Class
28  Foam::surfaceLocation
29 
30 Description
31  Contains information about location on a triSurface
32 
33  Access to data:
34  - pointIndexHit provides
35  - location
36  - bool: hit/miss
37  - index (of triangle/point/edge)
38  - elementType() provides
39  - what index above relates to. In triangle::proxType
40  - triangle() provides
41  - last known triangle
42 
43 SourceFiles
44  surfaceLocation.C
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef Foam_surfaceLocation_H
49 #define Foam_surfaceLocation_H
50 
51 #include "pointIndexHit.H"
52 #include "triangle.H"
53 #include "InfoProxy.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 // Forward Declarations
61 class surfaceLocation;
62 class triSurface;
63 
64 Istream& operator>>(Istream&, surfaceLocation&);
65 Ostream& operator<<(Ostream&, const surfaceLocation&);
66 
67 Ostream& operator<<(Ostream&, const InfoProxy<surfaceLocation>&);
68 
69 
70 /*---------------------------------------------------------------------------*\
71  Class surfaceLocation Declaration
72 \*---------------------------------------------------------------------------*/
73 
74 class surfaceLocation
75 :
76  public pointIndexHit
77 {
78  // Private Data
79 
80  triPointRef::proxType elementType_;
81 
82  label triangle_;
83 
84 
85 public:
86 
87  // Constructors
88 
89  //- Default construct
91  :
92  pointIndexHit(),
93  elementType_(triPointRef::NONE),
94  triangle_(-1)
95  {}
96 
97  //- Construct from components
99  (
100  const pointIndexHit& pHit,
102  const label triangle
103  )
104  :
105  pointIndexHit(pHit),
106  elementType_(elementType),
107  triangle_(triangle)
108  {}
109 
110  //- Construct from Istream
111  explicit surfaceLocation(Istream& is)
112  :
113  pointIndexHit(is),
114  elementType_(triPointRef::proxType(readLabel(is))),
115  triangle_(readLabel(is))
116  {}
117 
118 
119  // Member Functions
120 
122  {
123  return elementType_;
124  }
125 
127  {
128  return elementType_;
129  }
130 
131  label& triangle() noexcept
132  {
133  return triangle_;
134  }
135 
136  label triangle() const noexcept
137  {
138  return triangle_;
139  }
140 
141  //- Normal. Approximate for points.
142  vector normal(const triSurface& s) const;
143 
144  //- Return info proxy,
145  //- to print information to a stream
146  InfoProxy<surfaceLocation> info() const noexcept { return *this; }
147 
148  //- Write info about selected face index to a stream
149  void write(Ostream& os, const triSurface& s) const;
150 
152  // IOstream Operators
153 
154  friend Istream& operator>>(Istream& is, surfaceLocation& sl);
155 
156  friend Ostream& operator<<(Ostream& os, const surfaceLocation& sl);
157 };
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
triPointRef::proxType & elementType() noexcept
A triangle primitive used to calculate face normals and swept volumes. Uses referred points...
Definition: triangle.H:217
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition: label.H:63
This class describes the interaction of an object (often a face) and a point. It carries the info of ...
Definition: pointIndexHit.H:44
friend Istream & operator>>(Istream &is, surfaceLocation &sl)
proxType
Proximity classifications.
Definition: triangle.H:237
Istream & operator>>(Istream &, directionInfo &)
label & triangle() noexcept
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
InfoProxy< surfaceLocation > info() const noexcept
Return info proxy, to print information to a stream.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
A helper class for outputting values to Ostream.
Definition: ensightCells.H:43
void write(Ostream &os, const triSurface &s) const
Write info about selected face index to a stream.
surfaceLocation()
Default construct.
vector normal(const triSurface &s) const
Normal. Approximate for points.
Contains information about location on a triSurface.
Triangulated surface description with patch information.
Definition: triSurface.H:71
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
friend Ostream & operator<<(Ostream &os, const surfaceLocation &sl)
Namespace for OpenFOAM.