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