refinementDataI.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-2018 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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
27 
28 // Null constructor
30 :
31  refinementCount_(-1),
32  count_(-1)
33 {}
34 
35 
36 // Construct from components
38 (
39  const label refinementCount,
40  const label count
41 )
42 :
43  refinementCount_(refinementCount),
44  count_(count)
45 {}
46 
47 
48 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
49 
50 template<class TrackingData>
51 inline bool Foam::refinementData::valid(TrackingData& td) const
52 {
53  return count_ != -1;
54 }
55 
56 
57 // No geometric data so never any problem on cyclics
58 template<class TrackingData>
60 (
61  const polyMesh&,
62  const refinementData&,
63  const scalar,
64  TrackingData& td
65 ) const
66 {
67  return true;
68 }
69 
70 
71 // No geometric data.
72 template<class TrackingData>
74 (
75  const polyMesh&,
76  const polyPatch& patch,
77  const label patchFacei,
78  const point& faceCentre,
79  TrackingData& td
80 )
81 {}
82 
83 
84 // No geometric data.
85 template<class TrackingData>
87 (
88  const polyMesh&,
89  const tensor& rotTensor,
90  TrackingData& td
91 )
92 {}
93 
94 
95 // No geometric data.
96 template<class TrackingData>
98 (
99  const polyMesh&,
100  const polyPatch& patch,
101  const label patchFacei,
102  const point& faceCentre,
103  TrackingData& td
104 )
105 {}
106 
107 
108 // Update cell with neighbouring face information
109 template<class TrackingData>
111 (
112  const polyMesh&,
113  const label thisCelli,
114  const label neighbourFacei,
115  const refinementData& neighbourInfo,
116  const scalar tol,
117  TrackingData& td
118 )
119 {
120  if (!valid(td))
121  {
123  << abort(FatalError);
124  return false;
125  }
126 
127 
128  // Check if more than 2:1 ratio. This is when I am not refined but neighbour
129  // is and neighbour already had higher cell level.
130  if
131  (
132  neighbourInfo.isRefined()
133  && !isRefined()
134  && neighbourInfo.refinementCount() > refinementCount()
135  )
136  {
137  count_ = refinementCount();
138  return true;
139  }
140 
141 
142 
143  // Count from neighbour face by the time it reaches the current cell.
144  label transportedFaceCount;
145 
146  if (neighbourInfo.isRefined())
147  {
148  // refined so passes through two cells.
149  transportedFaceCount = max(0, neighbourInfo.count()-2);
150  }
151  else
152  {
153  // unrefined.
154  transportedFaceCount = max(0, neighbourInfo.count()-1);
155  }
156 
157  if (count_ >= transportedFaceCount)
158  {
159  return false;
160  }
161  else
162  {
163  count_ = transportedFaceCount;
164 
165  return true;
166  }
167 }
168 
169 
170 // Update face with neighbouring cell information
171 template<class TrackingData>
173 (
174  const polyMesh&,
175  const label thisFacei,
176  const label neighbourCelli,
177  const refinementData& neighbourInfo,
178  const scalar tol,
179  TrackingData& td
180 )
181 {
182  // From cell to its faces.
183  if (!valid(td))
184  {
185  refinementCount_ = neighbourInfo.refinementCount();
186  count_ = neighbourInfo.count();
187 
188  return true;
189  }
190 
191  if (count_ >= neighbourInfo.count())
192  {
193  return false;
194  }
195  else
196  {
197  refinementCount_ = neighbourInfo.refinementCount();
198  count_ = neighbourInfo.count();
199 
200  return true;
201  }
202 }
203 
204 
205 // Update face with coupled face information
206 template<class TrackingData>
208 (
209  const polyMesh&,
210  const label thisFacei,
211  const refinementData& neighbourInfo,
212  const scalar tol,
213  TrackingData& td
214 )
215 {
216  // From face to face (e.g. coupled faces)
217  if (!valid(td))
218  {
219  refinementCount_ = neighbourInfo.refinementCount();
220  count_ = neighbourInfo.count();
221 
222  return true;
223  }
224 
225  if (count_ >= neighbourInfo.count())
226  {
227  return false;
228  }
229  else
230  {
231  refinementCount_ = neighbourInfo.refinementCount();
232  count_ = neighbourInfo.count();
233 
234  return true;
235  }
236 }
237 
238 
239 template<class TrackingData>
240 inline bool Foam::refinementData::equal
241 (
242  const refinementData& rhs,
243  TrackingData& td
244 ) const
245 {
246  return operator==(rhs);
247 }
248 
249 
250 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
251 
253  const
254 {
255  return count() == rhs.count() && refinementCount() == rhs.refinementCount();
256 }
257 
258 
260  const
261 {
262  return !(*this == rhs);
263 }
264 
265 
266 // ************************************************************************* //
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
refinementData()
Construct null.
error FatalError
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
bool updateCell(const polyMesh &, const label thisCelli, const label neighbourFacei, const refinementData &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring face.
bool updateFace(const polyMesh &, const label thisFacei, const label neighbourCelli, const refinementData &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
bool sameGeometry(const polyMesh &, const refinementData &, const scalar, TrackingData &td) const
Check for identical geometrical data. Used for cyclics checking.
label refinementCount() const
void leaveDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &td)
Convert any absolute coordinates into relative to (patch)face.
bool isRefined() const
void enterDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &td)
Reverse of leaveDomain.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
label count() const
Transfers refinement levels such that slow transition between levels is maintained. Used in FaceCellWave.
void transform(const polyMesh &, const tensor &, TrackingData &td)
Apply rotation matrix to any coordinates.
bool operator==(const refinementData &) const
bool equal(const refinementData &, TrackingData &td) const
Same (like operator==)
bool valid(TrackingData &td) const
Check whether origin has been changed at all or.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
bool operator!=(const refinementData &) const