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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::surfaceLocation
28 
29 Description
30  Contains information about location on a triSurface
31 
32  Access to data:
33  - pointIndexHit provides
34  - location
35  - bool: hit/miss
36  - index (of triangle/point/edge)
37  - elementType() provides
38  - what index above relates to. In triangle::proxType
39  - triangle() provides
40  - last known triangle
41 
42 SourceFiles
43  surfaceLocation.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef surfaceLocation_H
48 #define surfaceLocation_H
49 
50 #include "pointIndexHit.H"
51 #include "triPointRef.H"
52 #include "InfoProxy.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 // Forward declaration of classes
60 class triSurface;
61 
62 
63 // Forward declaration of friend functions and operators
64 
65 class surfaceLocation;
66 
67 Istream& operator>>(Istream&, surfaceLocation&);
68 Ostream& operator<<(Ostream&, const surfaceLocation&);
69 Ostream& operator<<(Ostream&, const InfoProxy<surfaceLocation>&);
70 
71 
72 /*---------------------------------------------------------------------------*\
73  Class surfaceLocation Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 class surfaceLocation
77 :
78  public pointIndexHit
79 {
80  // Private data
81 
82  triPointRef::proxType elementType_;
83 
84  label triangle_;
85 
86 public:
87 
88 
89  // Constructors
90 
91  //- Construct null
93  :
94  pointIndexHit(),
95  elementType_(triPointRef::NONE),
96  triangle_(-1)
97  {}
98 
99  //- Construct from components
101  (
102  const pointIndexHit& pih,
104  const label triangle
105  )
106  :
107  pointIndexHit(pih),
108  elementType_(elementType),
109  triangle_(triangle)
110  {}
111 
112  //- Construct from Istream
114  :
115  pointIndexHit(is),
116  elementType_(triPointRef::proxType(readLabel(is))),
117  triangle_(readLabel(is))
118  {}
119 
120 
121  // Member Functions
122 
124  {
125  return elementType_;
126  }
127 
129  {
130  return elementType_;
131  }
132 
133  label& triangle()
134  {
135  return triangle_;
136  }
137 
138  label triangle() const
139  {
140  return triangle_;
141  }
142 
143  //- Normal. Approximate for points.
144  vector normal(const triSurface& s) const;
145 
146  //- Return info proxy.
147  // Used to print token information to a stream
149  {
150  return *this;
151  }
152 
153  //- Write info to os
154  void write(Ostream& os, const triSurface& s) const;
155 
156 
157  // IOstream Operators
158 
159  friend Istream& operator>>(Istream& is, surfaceLocation& sl);
160 
161  friend Ostream& operator<<(Ostream& os, const surfaceLocation& sl);
162 
163  friend Ostream& operator<<
164  (
165  Ostream&,
167  );
168 };
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 } // End namespace Foam
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
Foam::surfaceLocation::write
void write(Ostream &os, const triSurface &s) const
Write info to os.
Definition: surfaceLocation.C:69
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:75
Foam::surfaceLocation::surfaceLocation
surfaceLocation(Istream &is)
Construct from Istream.
Definition: surfaceLocation.H:112
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:228
triPointRef.H
Foam::surfaceLocation::elementType
triPointRef::proxType & elementType()
Definition: surfaceLocation.H:122
Foam::triangle
A triangle primitive used to calculate face normals and swept volumes.
Definition: triangle.H:62
Foam::PointIndexHit
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:55
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::triSurface
Triangulated surface description with patch information.
Definition: triSurface.H:70
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:33
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::surfaceLocation::elementType
triPointRef::proxType elementType() const
Definition: surfaceLocation.H:127
Foam::pointIndexHit
PointIndexHit< point > pointIndexHit
Definition: pointIndexHit.H:45
Foam::surfaceLocation::triangle
label triangle() const
Definition: surfaceLocation.H:137
Foam::triangle::proxType
proxType
Return types for classify.
Definition: triangle.H:97
Foam::Vector< scalar >
Foam::readLabel
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition: label.H:70
Foam::surfaceLocation::operator<<
friend Ostream & operator<<(Ostream &os, const surfaceLocation &sl)
Foam::surfaceLocation::info
InfoProxy< surfaceLocation > info() const
Return info proxy.
Definition: surfaceLocation.H:147
Foam::surfaceLocation::triangle
label & triangle()
Definition: surfaceLocation.H:132
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102
Foam::surfaceLocation::surfaceLocation
surfaceLocation()
Construct null.
Definition: surfaceLocation.H:91