surfaceLocation.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::surfaceLocation
26 
27 Description
28  Contains information about location on a triSurface
29 
30  Access to data:
31  - pointIndexHit provides
32  - location
33  - bool: hit/miss
34  - index (of triangle/point/edge)
35  - elementType() provides
36  - what index above relates to. In triangle::proxType
37  - triangle() provides
38  - last known triangle
39 
40 SourceFiles
41  surfaceLocation.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef surfaceLocation_H
46 #define surfaceLocation_H
47 
48 #include "pointIndexHit.H"
49 #include "triPointRef.H"
50 #include "InfoProxy.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 // Forward declaration of classes
58 class triSurface;
59 
60 
61 // Forward declaration of friend functions and operators
62 
63 class surfaceLocation;
64 
65 Istream& operator>>(Istream&, surfaceLocation&);
66 Ostream& operator<<(Ostream&, const surfaceLocation&);
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 public:
85 
86 
87  // Constructors
88 
89  //- Construct null
91  :
92  pointIndexHit(),
93  elementType_(triPointRef::NONE),
94  triangle_(-1)
95  {}
96 
97  //- Construct from components
99  (
100  const pointIndexHit& pih,
102  const label triangle
103  )
104  :
105  pointIndexHit(pih),
106  elementType_(elementType),
107  triangle_(triangle)
108  {}
109 
110  //- Construct from Istream
112  :
113  pointIndexHit(is),
114  elementType_(triPointRef::proxType(readLabel(is))),
115  triangle_(readLabel(is))
116  {}
117 
118 
119  // Member Functions
122  {
123  return elementType_;
124  }
127  {
128  return elementType_;
129  }
131  label& triangle()
132  {
133  return triangle_;
134  }
136  label triangle() const
137  {
138  return triangle_;
139  }
140 
141  //- Normal. Approximate for points.
142  vector normal(const triSurface& s) const;
143 
144  //- Return info proxy.
145  // Used to print token information to a stream
147  {
148  return *this;
149  }
150 
151  //- Write info to os
152  void write(Ostream& os, const triSurface& s) const;
153 
154 
155  // IOstream Operators
156 
157  friend Istream& operator>>(Istream& is, surfaceLocation& sl);
158 
159  friend Ostream& operator<<(Ostream& os, const surfaceLocation& sl);
160 
161  friend Ostream& operator<<
162  (
163  Ostream&,
165  );
166 };
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace Foam
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #endif
176 
177 // ************************************************************************* //
A triangle primitive used to calculate face areas and swept volumes.
Definition: triangle.H:57
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:53
friend Istream & operator>>(Istream &is, surfaceLocation &sl)
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().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))
proxType
Return types for classify.
Definition: triangle.H:89
triPointRef::proxType & elementType()
Istream & operator>>(Istream &, directionInfo &)
label readLabel(Istream &is)
Definition: label.H:64
InfoProxy< surfaceLocation > info() const
Return info proxy.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:45
void write(Ostream &os, const triSurface &s) const
Write info to os.
Ostream & operator<<(Ostream &, const ensightPart &)
surfaceLocation()
Construct null.
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:66
friend Ostream & operator<<(Ostream &os, const surfaceLocation &sl)
Namespace for OpenFOAM.