refinementDataI.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 :
33  refinementCount_(-1),
34  count_(-1)
35 {}
36 
37 
39 (
40  const label refinementCount,
41  const label count
42 )
43 :
44  refinementCount_(refinementCount),
45  count_(count)
46 {}
47 
48 
49 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
50 
51 template<class TrackingData>
52 inline bool Foam::refinementData::valid(TrackingData& td) const
53 {
54  return count_ != -1;
55 }
56 
57 
58 // No geometric data so never any problem on cyclics
59 template<class TrackingData>
61 (
62  const polyMesh&,
63  const refinementData&,
64  const scalar,
65  TrackingData& td
66 ) const
67 {
68  return true;
69 }
70 
71 
72 // No geometric data.
73 template<class TrackingData>
75 (
76  const polyMesh&,
77  const polyPatch& patch,
78  const label patchFacei,
79  const point& faceCentre,
80  TrackingData& td
81 )
82 {}
83 
84 
85 // No geometric data.
86 template<class TrackingData>
88 (
89  const polyMesh&,
90  const tensor& rotTensor,
91  TrackingData& td
92 )
93 {}
94 
95 
96 // No geometric data.
97 template<class TrackingData>
99 (
100  const polyMesh&,
101  const polyPatch& patch,
102  const label patchFacei,
103  const point& faceCentre,
104  TrackingData& td
105 )
106 {}
107 
108 
109 // Update cell with neighbouring face information
110 template<class TrackingData>
112 (
113  const polyMesh&,
114  const label thisCelli,
115  const label neighbourFacei,
116  const refinementData& neighbourInfo,
117  const scalar tol,
118  TrackingData& td
119 )
120 {
121  if (!valid(td))
122  {
124  << abort(FatalError);
125  return false;
126  }
127 
128 
129  // Check if more than 2:1 ratio. This is when I am not refined but neighbour
130  // is and neighbour already had higher cell level.
131  if
132  (
133  neighbourInfo.isRefined()
134  && !isRefined()
135  && neighbourInfo.refinementCount() > refinementCount()
136  )
137  {
138  count_ = refinementCount();
139  return true;
140  }
141 
142 
143 
144  // Count from neighbour face by the time it reaches the current cell.
145  label transportedFaceCount;
146 
147  if (neighbourInfo.isRefined())
148  {
149  // refined so passes through two cells.
150  transportedFaceCount = max(0, neighbourInfo.count()-2);
151  }
152  else
153  {
154  // unrefined.
155  transportedFaceCount = max(0, neighbourInfo.count()-1);
156  }
157 
158  if (count_ >= transportedFaceCount)
159  {
160  return false;
161  }
162  else
163  {
164  count_ = transportedFaceCount;
165 
166  return true;
167  }
168 }
169 
170 
171 // Update face with neighbouring cell information
172 template<class TrackingData>
174 (
175  const polyMesh&,
176  const label thisFacei,
177  const label neighbourCelli,
178  const refinementData& neighbourInfo,
179  const scalar tol,
180  TrackingData& td
181 )
182 {
183  // From cell to its faces.
184  if (!valid(td))
185  {
186  refinementCount_ = neighbourInfo.refinementCount();
187  count_ = neighbourInfo.count();
188 
189  return true;
190  }
191 
192  if (count_ >= neighbourInfo.count())
193  {
194  return false;
195  }
196  else
197  {
198  refinementCount_ = neighbourInfo.refinementCount();
199  count_ = neighbourInfo.count();
200 
201  return true;
202  }
203 }
204 
205 
206 // Update face with coupled face information
207 template<class TrackingData>
209 (
210  const polyMesh&,
211  const label thisFacei,
212  const refinementData& neighbourInfo,
213  const scalar tol,
214  TrackingData& td
215 )
216 {
217  // From face to face (e.g. coupled faces)
218  if (!valid(td))
219  {
220  refinementCount_ = neighbourInfo.refinementCount();
221  count_ = neighbourInfo.count();
222 
223  return true;
224  }
225 
226  if (count_ >= neighbourInfo.count())
227  {
228  return false;
229  }
230  else
231  {
232  refinementCount_ = neighbourInfo.refinementCount();
233  count_ = neighbourInfo.count();
234 
235  return true;
236  }
237 }
238 
239 
240 template<class TrackingData>
241 inline bool Foam::refinementData::equal
242 (
243  const refinementData& rhs,
244  TrackingData& td
245 ) const
246 {
247  return operator==(rhs);
248 }
249 
250 
251 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
252 
253 inline bool Foam::refinementData::operator==
254 (
255  const refinementData& rhs
256 ) const
257 {
258  return count_ == rhs.count_ && refinementCount_ == rhs.refinementCount_;
259 }
260 
261 
262 inline bool Foam::refinementData::operator!=
263 (
264  const refinementData& rhs
265 ) const
266 {
267  return !(*this == rhs);
268 }
269 
270 
271 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::refinementData::leaveDomain
void leaveDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &td)
Convert any absolute coordinates into relative to (patch)face.
Definition: refinementDataI.H:75
Foam::refinementData
Transfers refinement levels such that slow transition between levels is maintained....
Definition: refinementData.H:62
Foam::refinementData::refinementCount
label refinementCount() const
Definition: refinementData.H:87
Foam::refinementData::valid
bool valid(TrackingData &td) const
Changed or contains original (invalid) value.
Definition: refinementDataI.H:52
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::refinementData::refinementData
refinementData()
Default construct.
Definition: refinementDataI.H:31
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::refinementData::equal
bool equal(const refinementData &, TrackingData &td) const
Test for equality, with TrackingData.
Definition: refinementDataI.H:242
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::refinementData::isRefined
bool isRefined() const
Definition: refinementData.H:105
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:77
Foam::refinementData::enterDomain
void enterDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &td)
Reverse of leaveDomain.
Definition: refinementDataI.H:99
Foam::Vector< scalar >
Foam::refinementData::updateCell
bool updateCell(const polyMesh &, const label thisCelli, const label neighbourFacei, const refinementData &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring face.
Definition: refinementDataI.H:112
Foam::refinementData::updateFace
bool updateFace(const polyMesh &, const label thisFacei, const label neighbourCelli, const refinementData &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
Definition: refinementDataI.H:174
Foam::refinementData::count
label count() const
Definition: refinementData.H:96
Foam::refinementData::sameGeometry
bool sameGeometry(const polyMesh &, const refinementData &, const scalar, TrackingData &td) const
Check for identical geometrical data (eg, cyclics checking)
Definition: refinementDataI.H:61
Foam::refinementData::transform
void transform(const polyMesh &, const tensor &, TrackingData &td)
Apply rotation matrix to any coordinates.
Definition: refinementDataI.H:88