FreeFOAM The Cross-Platform CFD Toolkit
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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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 
27 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
28 
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 // Null constructor
34 :
35  refinementCount_(-1),
36  count_(-1)
37 {}
38 
39 
40 // Construct from components
42 (
43  const label refinementCount,
44  const label count
45 )
46 :
47  refinementCount_(refinementCount),
48  count_(count)
49 {}
50 
51 
52 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
53 
54 inline bool Foam::refinementData::valid() const
55 {
56  return count_ != -1;
57 }
58 
59 
60 // No geometric data so never any problem on cyclics
62 (
63  const polyMesh&,
64  const refinementData&,
65  const scalar
66 ) const
67 {
68  return true;
69 }
70 
71 
72 // No geometric data.
74 (
75  const polyMesh&,
76  const polyPatch& patch,
77  const label patchFaceI,
78  const point& faceCentre
79 )
80 {}
81 
82 
83 // No geometric data.
85 (
86  const polyMesh&,
87  const tensor& rotTensor
88 )
89 {}
90 
91 
92 // No geometric data.
94 (
95  const polyMesh&,
96  const polyPatch& patch,
97  const label patchFaceI,
98  const point& faceCentre
99 )
100 {}
101 
102 
103 // Update cell with neighbouring face information
105 (
106  const polyMesh&,
107  const label thisCellI,
108  const label neighbourFaceI,
109  const refinementData& neighbourInfo,
110  const scalar tol
111 )
112 {
113  if (!valid())
114  {
115  FatalErrorIn("refinementData::updateCell") << "problem"
116  << abort(FatalError);
117  return false;
118  }
119 
120 
121  // Check if more than 2:1 ratio. This is when I am not refined but neighbour
122  // is and neighbour already had higher cell level.
123  if
124  (
125  neighbourInfo.isRefined()
126  && !isRefined()
127  && neighbourInfo.refinementCount() > refinementCount()
128  )
129  {
130  count_ = refinementCount();
131  return true;
132  }
133 
134 
135 
136  // Count from neighbour face by the time it reaches the current cell.
137  label transportedFaceCount;
138 
139  if (neighbourInfo.isRefined())
140  {
141  // refined so passes through two cells.
142  transportedFaceCount = max(0, neighbourInfo.count()-2);
143  }
144  else
145  {
146  // unrefined.
147  transportedFaceCount = max(0, neighbourInfo.count()-1);
148  }
149 
150  if (count_ >= transportedFaceCount)
151  {
152  return false;
153  }
154  else
155  {
156  count_ = transportedFaceCount;
157 
158  return true;
159  }
160 }
161 
162 
163 // Update face with neighbouring cell information
165 (
166  const polyMesh&,
167  const label thisFaceI,
168  const label neighbourCellI,
169  const refinementData& neighbourInfo,
170  const scalar tol
171 )
172 {
173  // From cell to its faces.
174  if (!valid())
175  {
176  refinementCount_ = neighbourInfo.refinementCount();
177  count_ = neighbourInfo.count();
178 
179  return true;
180  }
181 
182  if (count_ >= neighbourInfo.count())
183  {
184  return false;
185  }
186  else
187  {
188  refinementCount_ = neighbourInfo.refinementCount();
189  count_ = neighbourInfo.count();
190 
191  return true;
192  }
193 }
194 
195 
196 // Update face with coupled face information
198 (
199  const polyMesh&,
200  const label thisFaceI,
201  const refinementData& neighbourInfo,
202  const scalar tol
203 )
204 {
205  // From face to face (e.g. coupled faces)
206  if (!valid())
207  {
208  refinementCount_ = neighbourInfo.refinementCount();
209  count_ = neighbourInfo.count();
210 
211  return true;
212  }
213 
214  if (count_ >= neighbourInfo.count())
215  {
216  return false;
217  }
218  else
219  {
220  refinementCount_ = neighbourInfo.refinementCount();
221  count_ = neighbourInfo.count();
222 
223  return true;
224  }
225 }
226 
227 
228 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
229 
231  const
232 {
233  return count() == rhs.count() && refinementCount() == rhs.refinementCount();
234 }
235 
236 
238  const
239 {
240  return !(*this == rhs);
241 }
242 
243 
244 // ************************ vim: set sw=4 sts=4 et: ************************ //