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 surfaceLocation_H
49 #define surfaceLocation_H
50 
51 #include "pointIndexHit.H"
52 #include "triPointRef.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 Ostream& operator<<(Ostream&, const InfoProxy<surfaceLocation>&);
67 
68 /*---------------------------------------------------------------------------*\
69  Class surfaceLocation Declaration
70 \*---------------------------------------------------------------------------*/
71 
72 class surfaceLocation
73 :
74  public pointIndexHit
75 {
76  // Private Data
77 
78  triPointRef::proxType elementType_;
79 
80  label triangle_;
81 
82 
83 public:
84 
85  // Constructors
86 
87  //- Default construct
89  :
90  pointIndexHit(),
91  elementType_(triPointRef::NONE),
92  triangle_(-1)
93  {}
94 
95  //- Construct from components
97  (
98  const pointIndexHit& pHit,
100  const label triangle
101  )
102  :
103  pointIndexHit(pHit),
104  elementType_(elementType),
105  triangle_(triangle)
106  {}
107 
108  //- Construct from Istream
109  explicit surfaceLocation(Istream& is)
110  :
111  pointIndexHit(is),
112  elementType_(triPointRef::proxType(readLabel(is))),
113  triangle_(readLabel(is))
114  {}
115 
116 
117  // Member Functions
118 
120  {
121  return elementType_;
122  }
123 
124  triPointRef::proxType elementType() const noexcept
125  {
126  return elementType_;
127  }
128 
129  label& triangle() noexcept
130  {
131  return triangle_;
132  }
133 
134  label triangle() const noexcept
135  {
136  return triangle_;
137  }
138 
139  //- Normal. Approximate for points.
140  vector normal(const triSurface& s) const;
141 
142  //- Return info proxy, to print information to a stream
144  {
145  return *this;
146  }
147 
148  //- Write info about selected face index to a stream
149  void write(Ostream& os, const triSurface& s) const;
150 
151 
152  // IOstream Operators
153 
154  friend Istream& operator>>(Istream& is, surfaceLocation& sl);
155 
156  friend Ostream& operator<<(Ostream& os, const surfaceLocation& sl);
157 
158  friend Ostream& operator<<
159  (
160  Ostream& os,
162  );
163 };
164 
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 } // End namespace Foam
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 #endif
173 
174 // ************************************************************************* //
Foam::surfaceLocation::write
void write(Ostream &os, const triSurface &s) const
Write info about selected face index to a stream.
Definition: surfaceLocation.C:72
pointIndexHit.H
Foam::InfoProxy
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:47
s
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))
Definition: gmvOutputSpray.H:25
InfoProxy.H
Foam::surfaceLocation
Contains information about location on a triSurface.
Definition: surfaceLocation.H:71
Foam::surfaceLocation::surfaceLocation
surfaceLocation(Istream &is)
Construct from Istream.
Definition: surfaceLocation.H:108
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
triPointRef.H
Foam::surfaceLocation::elementType
triPointRef::proxType elementType() const noexcept
Definition: surfaceLocation.H:123
Foam::triangle
A triangle primitive used to calculate face normals and swept volumes.
Definition: triangle.H:59
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::PointIndexHit
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:52
Foam::triSurface
Triangulated surface description with patch information.
Definition: triSurface.H:76
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::surfaceLocation::operator>>
friend Istream & operator>>(Istream &is, surfaceLocation &sl)
Foam::surfaceLocation::normal
vector normal(const triSurface &s) const
Normal. Approximate for points.
Definition: surfaceLocation.C:34
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::pointIndexHit
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
Definition: pointIndexHit.H:46
Foam::surfaceLocation::triangle
label & triangle() noexcept
Definition: surfaceLocation.H:128
Foam::triangle::proxType
proxType
The proximity classifications.
Definition: triangle.H:93
Foam::Vector< scalar >
Foam::readLabel
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition: label.H:66
Foam::surfaceLocation::elementType
triPointRef::proxType & elementType() noexcept
Definition: surfaceLocation.H:118
Foam::surfaceLocation::operator<<
friend Ostream & operator<<(Ostream &os, const surfaceLocation &sl)
Foam::surfaceLocation::info
InfoProxy< surfaceLocation > info() const
Return info proxy, to print information to a stream.
Definition: surfaceLocation.H:142
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::surfaceLocation::triangle
label triangle() const noexcept
Definition: surfaceLocation.H:133
Foam::surfaceLocation::surfaceLocation
surfaceLocation()
Default construct.
Definition: surfaceLocation.H:87