pointEdgeLayerInfoI.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) 2023 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 \*---------------------------------------------------------------------------*/
25 
26 #include "pointEdgeLayerInfo.H"
27 #include "polyMesh.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 :
33  layer_(-labelMax)
34 {}
35 
36 
38 :
39  layer_(2*pointLayer - 1)
40 {}
41 
42 
43 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
44 
46 {
47  if ((layer_ + 1) % 2 != 0)
48  {
50  << "Point layer index requested from edge layer info"
51  << exit(FatalError);
52  }
53 
54  return (layer_ + 1)/2;
55 }
56 
57 
59 {
60  if (layer_ % 2 != 0)
61  {
63  << "Edge layer index requested from point layer info"
64  << exit(FatalError);
65  }
66 
67  return layer_/2;
68 }
69 
70 
71 template<class TrackingData>
72 inline bool Foam::pointEdgeLayerInfo::valid(TrackingData& td) const
73 {
74  return layer_ != -labelMax;
75 }
76 
77 
78 template<class TrackingData>
80 (
81  const pointEdgeLayerInfo& l,
82  const scalar tol,
83  TrackingData& td
84 ) const
85 {
86  return true;
87 }
88 
89 
90 template<class TrackingData>
92 (
93  const polyPatch& patch,
94  const label patchFacei,
95  const transformer& transform,
96  TrackingData& td
97 )
98 {}
99 
100 
101 template<class TrackingData>
103 (
104  const polyMesh& mesh,
105  const label pointi,
106  const label edgei,
107  const pointEdgeLayerInfo& edgeInfo,
108  const scalar tol,
109  TrackingData& td
110 )
111 {
112  if (!valid(td))
113  {
114  layer_ = edgeInfo.layer_ + 1;
115  return true;
116  }
117 
118  if (!edgeInfo.valid(td) || layer_ < edgeInfo.layer_)
119  {
120  return false;
121  }
122 
124  << "Layer information collided. This is not a layered mesh"
125  << exit(FatalError);
126 
127  return false;
128 }
129 
130 
131 template<class TrackingData>
133 (
134  const polyMesh& mesh,
135  const label pointi,
136  const pointEdgeLayerInfo& newPointInfo,
137  const scalar tol,
138  TrackingData& td
139 )
140 {
141  if (!valid(td))
142  {
143  layer_ = newPointInfo.layer_;
144  return true;
145  }
146 
148  << "Layer information collided. This is not a layered mesh"
149  << exit(FatalError);
150 
151  return false;
152 }
153 
154 
155 template<class TrackingData>
157 (
158  const pointEdgeLayerInfo& newPointInfo,
159  const scalar tol,
160  TrackingData& td
161 )
162 {
163  layer_ = newPointInfo.layer_;
164  return true;
165 }
166 
167 
168 template<class TrackingData>
170 (
171  const polyMesh& mesh,
172  const label edgei,
173  const label pointi,
174  const pointEdgeLayerInfo& pointInfo,
175  const scalar tol,
176  TrackingData& td
177 )
178 {
179  if (!valid(td))
180  {
181  layer_ = pointInfo.layer_ + 1;
182  return true;
183  }
184 
185  layer_ = -labelMax;
186  return false;
187 }
188 
189 
190 template<class TrackingData>
192 (
193  const pointEdgeLayerInfo& rhs,
194  TrackingData& td
195 ) const
196 {
197  return operator==(rhs);
198 }
199 
200 
201 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
202 
203 inline bool Foam::pointEdgeLayerInfo::operator==
204 (
205  const Foam::pointEdgeLayerInfo& rhs
206 ) const
207 {
208  return layer_ == rhs.layer_;
209 }
210 
211 
212 inline bool Foam::pointEdgeLayerInfo::operator!=
213 (
214  const Foam::pointEdgeLayerInfo& rhs
215 ) const
216 {
217  return !(*this == rhs);
218 }
219 
220 
221 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
222 
224 {
225  return os << l.layer_;
226 }
227 
228 
230 {
231  return is >> l.layer_;
232 }
233 
234 
235 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Class to be used with PointEdgeWave which enumerates layers of points.
bool updateEdge(const polyMesh &mesh, const label edgei, const label pointi, const pointEdgeLayerInfo &pointInfo, const scalar tol, TrackingData &td)
Influence of point on edge.
bool updatePoint(const polyMesh &mesh, const label pointi, const label edgei, const pointEdgeLayerInfo &edgeInfo, const scalar tol, TrackingData &td)
Influence of edge on point.
bool sameGeometry(const pointEdgeLayerInfo &, const scalar tol, TrackingData &td) const
Check for identical geometrical data. Used for cyclics checking.
bool valid(TrackingData &td) const
Check whether info has been changed at all or.
bool equal(const pointEdgeLayerInfo &, TrackingData &td) const
Same (like operator==)
pointEdgeLayerInfo()
Construct null.
label pointLayer() const
Return the point layer index.
label edgeLayer() const
Return the edge layer index.
void transform(const polyPatch &patch, const label patchPointi, const transformer &transform, TrackingData &td)
Transform across an interface.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
bool valid(const PtrList< ModelType > &l)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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:59
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Istream & operator>>(Istream &, pistonPointEdgeData &)
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:504
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
error FatalError
static const label labelMax
Definition: label.H:62