43 NamedEnum<shellSurfaces::refineMode, 3>::
59 void Foam::shellSurfaces::setAndCheckLevels
62 const List<Tuple2<scalar, label> >& distLevels
65 if (modes_[shellI] !=
DISTANCE && distLevels.size() != 1)
69 "shellSurfaces::shellSurfaces"
70 "(const searchableSurfaces&, const dictionary&)"
71 ) <<
"For refinement mode "
72 << refineModeNames_[modes_[shellI]]
73 <<
" specify only one distance+level."
74 <<
" (its distance gets discarded)"
78 distances_[shellI].
setSize(distLevels.size());
79 levels_[shellI].
setSize(distLevels.size());
83 distances_[shellI][j] = distLevels[j].first();
84 levels_[shellI][j] = distLevels[j].second();
91 (distances_[shellI][j] <= distances_[shellI][j-1])
92 || (levels_[shellI][j] > levels_[shellI][j-1])
97 "shellSurfaces::shellSurfaces"
98 "(const searchableSurfaces&, const dictionary&)"
99 ) <<
"For refinement mode "
100 << refineModeNames_[modes_[shellI]]
101 <<
" : Refinement should be specified in order"
102 <<
" of increasing distance"
103 <<
" (and decreasing refinement level)." <<
endl
104 <<
"Distance:" << distances_[shellI][j]
105 <<
" refinementLevel:" << levels_[shellI][j]
111 const searchableSurface& shell = allGeometry_[shells_[shellI]];
115 Info<<
"Refinement level according to distance to "
116 << shell.name() <<
endl;
117 forAll(levels_[shellI], j)
119 Info<<
" level " << levels_[shellI][j]
120 <<
" for all cells within " << distances_[shellI][j]
121 <<
" meter." <<
endl;
126 if (!allGeometry_[shells_[shellI]].hasVolumeType())
130 "shellSurfaces::shellSurfaces"
131 "(const searchableSurfaces&"
132 ", const PtrList<dictionary>&)"
133 ) <<
"Shell " << shell.name()
134 <<
" does not support testing for "
135 << refineModeNames_[modes_[shellI]] <<
endl
136 <<
"Probably it is not closed."
140 if (modes_[shellI] ==
INSIDE)
142 Info<<
"Refinement level " << levels_[shellI][0]
143 <<
" for all cells inside " << shell.name() <<
endl;
147 Info<<
"Refinement level " << levels_[shellI][0]
148 <<
" for all cells outside " << shell.name() <<
endl;
157 void Foam::shellSurfaces::orient()
162 bool hasSurface =
false;
166 const searchableSurface& s = allGeometry_[shells_[shellI]];
168 if (modes_[shellI] != DISTANCE && isA<triSurfaceMesh>(s))
170 const triSurfaceMesh& shell = refCast<const triSurfaceMesh>(s);
172 if (shell.triSurface::size())
178 boundBox shellBb(points[0], points[0]);
180 for (label i = 0; i < points.size(); i++)
182 const point& pt = points[i];
183 shellBb.
min() =
min(shellBb.min(), pt);
184 shellBb.max() =
max(shellBb.max(), pt);
187 overallBb.min() =
min(overallBb.min(), shellBb.min());
188 overallBb.max() =
max(overallBb.max(), shellBb.max());
195 const point outsidePt = overallBb.
max() + overallBb.span();
201 const searchableSurface& s = allGeometry_[shells_[shellI]];
203 if (modes_[shellI] != DISTANCE && isA<triSurfaceMesh>(s))
205 triSurfaceMesh& shell =
const_cast<triSurfaceMesh&
>
207 refCast<const triSurfaceMesh>(s)
227 Info<<
"shellSurfaces : Flipped orientation of surface "
229 <<
" so point " << outsidePt <<
" is outside." <<
endl;
238 void Foam::shellSurfaces::findHigherLevel
245 const labelList& levels = levels_[shellI];
247 if (modes_[shellI] == DISTANCE)
260 label candidateI = 0;
266 if (levels[levelI] > maxLevel[pointI])
268 candidates[candidateI] = pt[pointI];
269 candidateMap[candidateI] = pointI;
270 candidateDistSqr[candidateI] =
sqr(distances[levelI]);
276 candidates.setSize(candidateI);
277 candidateMap.setSize(candidateI);
278 candidateDistSqr.setSize(candidateI);
282 allGeometry_[shells_[shellI]].findNearest
290 forAll(nearInfo, candidateI)
292 if (nearInfo[candidateI].hit())
298 mag(nearInfo[candidateI].hitPoint()-candidates[candidateI])
301 label pointI = candidateMap[candidateI];
304 maxLevel[pointI] = levels[minDistI+1];
317 label candidateI = 0;
321 if (levels[0] > maxLevel[pointI])
323 candidates[candidateI] = pt[pointI];
324 candidateMap[candidateI] = pointI;
328 candidates.setSize(candidateI);
329 candidateMap.setSize(candidateI);
332 List<searchableSurface::volumeType> volType;
333 allGeometry_[shells_[shellI]].getVolumeType(candidates, volType);
337 label pointI = candidateMap[i];
342 modes_[shellI] == INSIDE
346 modes_[shellI] == OUTSIDE
351 maxLevel[pointI] = levels[0];
366 allGeometry_(allGeometry)
368 shells_.setSize(shellDicts.
size());
369 modes_.setSize(shellDicts.
size());
370 distances_.setSize(shellDicts.
size());
371 levels_.setSize(shellDicts.
size());
373 forAll(shellDicts, shellI)
379 shells_[shellI] = allGeometry_.findSurfaceID(name);
381 if (shells_[shellI] == -1)
385 "shellSurfaces::shellSurfaces"
386 "(const searchableSurfaces&, const PtrList<dictionary>&)"
387 ) <<
"No surface called " << name <<
endl
388 <<
"Valid surfaces are " << allGeometry_.names()
392 modes_[shellI] = refineModeNames_.read(dict.
lookup(
"refineMode"));
395 setAndCheckLevels(shellI, dict.
lookup(
"levels"));
411 allGeometry_(allGeometry)
413 shells_.setSize(shellsDict.
size());
414 modes_.setSize(shellsDict.
size());
415 distances_.setSize(shellsDict.
size());
416 levels_.setSize(shellsDict.
size());
421 shells_[shellI] = allGeometry_.findSurfaceID(iter().keyword());
423 if (shells_[shellI] == -1)
427 "shellSurfaces::shellSurfaces"
428 "(const searchableSurfaces&, const dictionary>&"
429 ) <<
"No surface called " << iter().keyword() <<
endl
430 <<
"Valid surfaces are " << allGeometry_.names()
435 modes_[shellI] = refineModeNames_.
read(dict.
lookup(
"mode"));
438 setAndCheckLevels(shellI, dict.
lookup(
"levels"));
455 label overallMax = 0;
458 overallMax =
max(overallMax,
max(levels_[shellI]));
464 void Foam::shellSurfaces::findHigherLevel
476 findHigherLevel(pt, shellI, maxLevel);