PointIntegrateDataI.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) 2018-2020 OpenCFD Ltd.
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 \*---------------------------------------------------------------------------*/
27 
28 #include "polyMesh.H"
29 #include "transform.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class DataType>
35 :
36  valid_(false)
37 {}
38 
39 
40 template<class DataType>
42 (
43  const DataType& data
44 )
45 :
46  valid_(true),
47  data_(data)
48 {}
49 
50 
51 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
52 
53 template<class DataType>
54 template<class TrackingData>
55 inline bool Foam::PointIntegrateData<DataType>::valid(TrackingData& td) const
56 {
57  return valid_;
58 }
59 
60 
61 template<class DataType>
62 template<class TrackingData>
64 (
66  const scalar tol,
67  TrackingData& td
68 ) const
69 {
70  return true;
71 }
72 
73 
74 template<class DataType>
75 template<class TrackingData>
77 (
78  const polyPatch& patch,
79  const label patchPointi,
80  const point& pos,
81  TrackingData& td
82 )
83 {}
84 
85 
86 template<class DataType>
87 template<class TrackingData>
89 (
90  const polyPatch& patch,
91  const label patchPointi,
92  const point& pos,
93  TrackingData& td
94 )
95 {}
96 
97 
98 template<class DataType>
99 template<class TrackingData>
101 (
102  const tensor& rotTensor,
103  TrackingData& td
104 )
105 {
106  this->data_ = Foam::transform(rotTensor, this->data_);
107 }
108 
109 
110 template<class DataType>
111 template<class TrackingData>
113 (
114  const polyMesh& mesh,
115  const label pointI,
116  const label edgeI,
117  const PointIntegrateData<DataType>& edgeInfo,
118  const scalar tol,
119  TrackingData& td
120 )
121 {
122  // Update point from an edge
123  if (!valid_)
124  {
125  if (!edgeInfo.valid_)
126  {
127  FatalErrorInFunction<< "edgeInfo:" << edgeInfo << exit(FatalError);
128  }
129  this->operator=(edgeInfo);
130  return true;
131  }
132 
133  return false;
134 }
135 
136 
137 template<class DataType>
138 template<class TrackingData>
140 (
141  const polyMesh& mesh,
142  const label pointI,
143  const PointIntegrateData<DataType>& newPointInfo,
144  const scalar tol,
145  TrackingData& td
146 )
147 {
148  // Update point from coupled point
149  if (!valid_)
150  {
151  if (!newPointInfo.valid_)
152  {
153  FatalErrorInFunction<< "newPointInfo:" << newPointInfo
154  << exit(FatalError);
155  }
156  this->operator=(newPointInfo);
157  return true;
158  }
159 
160  return false;
161 }
162 
163 
164 template<class DataType>
165 template<class TrackingData>
167 (
168  const PointIntegrateData<DataType>& newPointInfo,
169  const scalar tol,
170  TrackingData& td
171 )
172 {
173  if (!valid_)
174  {
175  if (!newPointInfo.valid_)
176  {
177  FatalErrorInFunction<< "newPointInfo:" << newPointInfo
178  << exit(FatalError);
179  }
180  this->operator=(newPointInfo);
181  return true;
182  }
183 
184  return false;
185 }
186 
187 
188 template<class DataType>
189 template<class TrackingData>
191 (
192  const polyMesh& mesh,
193  const label edgeI,
194  const label pointI,
195  const PointIntegrateData<DataType>& pointInfo,
196  const scalar tol,
197  TrackingData& td
198 )
199 {
200  if (!valid_)
201  {
202  if (!pointInfo.valid(td))
203  {
204  FatalErrorInFunction<< "problem: invalid point:"
205  << mesh.points()[pointI]
206  << " data:" << pointInfo
207  << exit(FatalError);
208  }
209  this->data_ = pointInfo.data_ + td.edgeData_[edgeI];
210  this->valid_ = true;
211  return true;
212  }
213 
214  return false;
215 }
216 
217 
218 template<class DataType>
219 template<class TrackingData>
221 (
223  TrackingData& td
224 ) const
225 {
226  if (!valid_)
227  {
228  return false;
229  }
230  else if (!pi.valid_)
231  {
232  FatalErrorInFunction << "pi:" << pi
233  << exit(FatalError);
234  return false;
235  }
236  else
237  {
238  return this->data_ == pi.data_;
239  }
240 }
241 
242 
243 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
244 
245 template<class DataType>
247 (
249 ) const
250 {
251  return this->data_ == rhs.data_;
252 }
253 
254 
255 template<class DataType>
257 (
259 ) const
260 {
261  return !(*this == rhs);
262 }
263 
264 
265 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
266 
267 template<class DataType>
268 inline Foam::Ostream& Foam::operator<<
269 (
270  Ostream& os,
272 )
273 {
274  if (os.format() == IOstream::ASCII)
275  {
276  return os << rhs.valid_ << token::SPACE << rhs.data();
277  }
278  else
279  {
280  return os << rhs.valid_ << rhs.data();
281  }
282 }
283 
284 
285 template<class DataType>
286 inline Foam::Istream& Foam::operator>>
287 (
288  Istream& is,
289  PointIntegrateData<DataType>& rhs
290 )
291 {
292  return is >> rhs.valid_ >> rhs.data_;
293 }
294 
295 
296 // ************************************************************************* //
Foam::PointIntegrateData
Integrate along selected edges using PointEdgeWave.
Definition: PointIntegrateData.H:47
Foam::Tensor< scalar >
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1069
Foam::PointIntegrateData::valid
bool valid(TrackingData &td) const
Changed or contains original (invalid) value.
Definition: PointIntegrateDataI.H:55
Foam::IOstreamOption::format
streamFormat format() const noexcept
Get the current stream format.
Definition: IOstreamOption.H:286
Foam::PointIntegrateData::enterDomain
void enterDomain(const polyPatch &patch, const label patchPointi, const point &pos, TrackingData &td)
Convert relative origin to absolute by adding entering point.
Definition: PointIntegrateDataI.H:89
Foam::PointIntegrateData::PointIntegrateData
PointIntegrateData()
Default construct.
Definition: PointIntegrateDataI.H:34
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
polyMesh.H
Foam::PointIntegrateData::sameGeometry
bool sameGeometry(const PointIntegrateData< DataType > &, const scalar tol, TrackingData &td) const
Check for identical geometrical data (eg, cyclics checking)
Definition: PointIntegrateDataI.H:64
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::FatalError
error FatalError
os
OBJstream os(runTime.globalPath()/outputName)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::PointIntegrateData::updateEdge
bool updateEdge(const polyMesh &mesh, const label edgeI, const label pointI, const PointIntegrateData< DataType > &pointInfo, const scalar tol, TrackingData &td)
Influence of point on edge.
Definition: PointIntegrateDataI.H:191
Foam::PointIntegrateData::transform
void transform(const tensor &rotTensor, TrackingData &td)
Apply rotation matrix to the data.
Definition: PointIntegrateDataI.H:101
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::IOstreamOption::ASCII
"ascii" (normal default)
Definition: IOstreamOption.H:72
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::constant::mathematical::pi
constexpr scalar pi(M_PI)
Foam::PointIntegrateData::equal
bool equal(const PointIntegrateData< DataType > &, TrackingData &td) const
Test for equality, with TrackingData.
Definition: PointIntegrateDataI.H:221
Foam::PointIntegrateData::updatePoint
bool updatePoint(const polyMesh &mesh, const label pointI, const label edgeI, const PointIntegrateData< DataType > &edgeInfo, const scalar tol, TrackingData &td)
Influence of edge on point.
Definition: PointIntegrateDataI.H:113
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::Vector< scalar >
Foam::token::SPACE
Space [isspace].
Definition: token.H:125
Foam::PointIntegrateData::leaveDomain
void leaveDomain(const polyPatch &patch, const label patchPointi, const point &pos, TrackingData &td)
Definition: PointIntegrateDataI.H:77
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
transform.H
3D tensor transformation operations.
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:55
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:177