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-------------------------------------------------------------------------------
10License
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
33template<class DataType>
35:
36 valid_(false)
37{}
38
39
40template<class DataType>
42(
43 const DataType& data
44)
45:
46 valid_(true),
47 data_(data)
48{}
49
50
51// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
52
53template<class DataType>
54template<class TrackingData>
55inline bool Foam::PointIntegrateData<DataType>::valid(TrackingData& td) const
56{
57 return valid_;
58}
59
60
61template<class DataType>
62template<class TrackingData>
64(
66 const scalar tol,
67 TrackingData& td
68) const
69{
70 return true;
71}
72
73
74template<class DataType>
75template<class TrackingData>
77(
78 const polyPatch& patch,
79 const label patchPointi,
80 const point& pos,
81 TrackingData& td
82)
83{}
84
85
86template<class DataType>
87template<class TrackingData>
89(
90 const polyPatch& patch,
91 const label patchPointi,
92 const point& pos,
93 TrackingData& td
94)
95{}
96
97
98template<class DataType>
99template<class TrackingData>
101(
102 const tensor& rotTensor,
103 TrackingData& td
104)
105{
106 this->data_ = Foam::transform(rotTensor, this->data_);
107}
108
109
110template<class DataType>
111template<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
137template<class DataType>
138template<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
164template<class DataType>
165template<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
188template<class DataType>
189template<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
218template<class DataType>
219template<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
245template<class DataType>
247(
249) const
250{
251 return this->data_ == rhs.data_;
252}
253
254
255template<class DataType>
257(
259) const
260{
261 return !(*this == rhs);
262}
263
264
265// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
266
267template<class DataType>
268inline 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
285template<class DataType>
286inline 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// ************************************************************************* //
streamFormat format() const noexcept
Get the current stream format.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Integrate along selected edges using PointEdgeWave.
bool equal(const PointIntegrateData< DataType > &, TrackingData &td) const
Test for equality, with TrackingData.
void leaveDomain(const polyPatch &patch, const label patchPointi, const point &pos, TrackingData &td)
void enterDomain(const polyPatch &patch, const label patchPointi, const point &pos, TrackingData &td)
Convert relative origin to absolute by adding entering point.
bool valid(TrackingData &td) const
Changed or contains original (invalid) value.
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.
PointIntegrateData()
Default construct.
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.
bool sameGeometry(const PointIntegrateData< DataType > &, const scalar tol, TrackingData &td) const
Check for identical geometrical data (eg, cyclics checking)
bool valid() const
True if all internal ids are non-negative.
Database for solution data, solver performance and other reduced data.
Definition: data.H:58
Default transformation behaviour.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1083
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
@ SPACE
Space [isspace].
Definition: token.H:125
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
OBJstream os(runTime.globalPath()/outputName)
dimensionedScalar pos(const dimensionedScalar &ds)
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
3D tensor transformation operations.