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-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 // * * * * * * * * * * * * * * * * 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 polyPatch& patch,
76  const label patchFacei,
77  const transformer& transform,
78  TrackingData& td
79 )
80 {}
81 
82 
83 template<class TrackingData>
85 (
86  const polyMesh&,
87  const label thisCelli,
88  const label neighbourFacei,
89  const refinementData& neighbourInfo,
90  const scalar tol,
91  TrackingData& td
92 )
93 {
94  if (!valid(td))
95  {
97  << abort(FatalError);
98  return false;
99  }
100 
101 
102  // Check if more than 2:1 ratio. This is when I am not refined but neighbour
103  // is and neighbour already had higher cell level.
104  if
105  (
106  neighbourInfo.isRefined()
107  && !isRefined()
108  && neighbourInfo.refinementCount() > refinementCount()
109  )
110  {
111  count_ = refinementCount();
112  return true;
113  }
114 
115 
116 
117  // Count from neighbour face by the time it reaches the current cell.
118  label transportedFaceCount;
119 
120  if (neighbourInfo.isRefined())
121  {
122  // refined so passes through two cells.
123  transportedFaceCount = max(0, neighbourInfo.count()-2);
124  }
125  else
126  {
127  // unrefined.
128  transportedFaceCount = max(0, neighbourInfo.count()-1);
129  }
130 
131  if (count_ >= transportedFaceCount)
132  {
133  return false;
134  }
135  else
136  {
137  count_ = transportedFaceCount;
138 
139  return true;
140  }
141 }
142 
143 
144 // Update face with neighbouring cell information
145 template<class TrackingData>
147 (
148  const polyMesh&,
149  const label thisFacei,
150  const label neighbourCelli,
151  const refinementData& neighbourInfo,
152  const scalar tol,
153  TrackingData& td
154 )
155 {
156  // From cell to its faces.
157  if (!valid(td))
158  {
159  refinementCount_ = neighbourInfo.refinementCount();
160  count_ = neighbourInfo.count();
161 
162  return true;
163  }
164 
165  if (count_ >= neighbourInfo.count())
166  {
167  return false;
168  }
169  else
170  {
171  refinementCount_ = neighbourInfo.refinementCount();
172  count_ = neighbourInfo.count();
173 
174  return true;
175  }
176 }
177 
178 
179 // Update face with coupled face information
180 template<class TrackingData>
182 (
183  const polyMesh&,
184  const label thisFacei,
185  const refinementData& neighbourInfo,
186  const scalar tol,
187  TrackingData& td
188 )
189 {
190  // From face to face (e.g. coupled faces)
191  if (!valid(td))
192  {
193  refinementCount_ = neighbourInfo.refinementCount();
194  count_ = neighbourInfo.count();
195 
196  return true;
197  }
198 
199  if (count_ >= neighbourInfo.count())
200  {
201  return false;
202  }
203  else
204  {
205  refinementCount_ = neighbourInfo.refinementCount();
206  count_ = neighbourInfo.count();
207 
208  return true;
209  }
210 }
211 
212 
213 template<class TrackingData>
215 (
216  const refinementData& rhs,
217  TrackingData& td
218 ) const
219 {
220  return operator==(rhs);
221 }
222 
223 
224 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
225 
227  const
228 {
229  return count() == rhs.count() && refinementCount() == rhs.refinementCount();
230 }
231 
232 
234  const
235 {
236  return !(*this == rhs);
237 }
238 
239 
240 // ************************************************************************* //
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
Transfers refinement levels such that slow transition between levels is maintained....
bool operator!=(const refinementData &) const
bool equal(const refinementData &, TrackingData &td) const
Same (like operator==)
bool isRefined() const
bool sameGeometry(const polyMesh &, const refinementData &, const scalar, TrackingData &td) const
Check for identical geometrical data. Used for cyclics checking.
label count() const
bool updateCell(const polyMesh &, const label thisCelli, const label neighbourFacei, const refinementData &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring face.
label refinementCount() const
bool updateFace(const polyMesh &, const label thisFacei, const label neighbourCelli, const refinementData &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
bool valid(TrackingData &td) const
Check whether origin has been changed at all or.
void transform(const polyPatch &patch, const label patchFacei, const transformer &transform, TrackingData &td)
Transform across an interface.
refinementData()
Construct null.
bool operator==(const refinementData &) const
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)
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 > &)
errorManip< error > abort(error &err)
Definition: errorManip.H:131
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:504
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
error FatalError
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.