44 NamedEnum<shellSurfaces::refineMode, 3>::
60 void Foam::shellSurfaces::setAndCheckLevels
66 if (modes_[shellI] != DISTANCE && distLevels.size() != 1)
69 <<
"For refinement mode " 70 << refineModeNames_[modes_[shellI]]
71 <<
" specify only one distance+level." 72 <<
" (its distance gets discarded)" 76 distances_[shellI].setSize(distLevels.size());
77 levels_[shellI].setSize(distLevels.size());
81 distances_[shellI][j] = distLevels[j].first();
82 levels_[shellI][j] = distLevels[j].second();
89 (distances_[shellI][j] <= distances_[shellI][j-1])
90 || (levels_[shellI][j] > levels_[shellI][j-1])
94 <<
"For refinement mode " 95 << refineModeNames_[modes_[shellI]]
96 <<
" : Refinement should be specified in order" 97 <<
" of increasing distance" 98 <<
" (and decreasing refinement level)." <<
endl 99 <<
"Distance:" << distances_[shellI][j]
100 <<
" refinementLevel:" << levels_[shellI][j]
108 if (modes_[shellI] == DISTANCE)
110 Info<<
"Refinement level according to distance to " 112 forAll(levels_[shellI], j)
114 Info<<
" level " << levels_[shellI][j]
115 <<
" for all cells within " << distances_[shellI][j]
116 <<
" metre." <<
endl;
121 if (!allGeometry_[shells_[shellI]].hasVolumeType())
124 <<
"Shell " << shell.
name()
125 <<
" does not support testing for " 126 << refineModeNames_[modes_[shellI]] <<
endl 127 <<
"Probably it is not closed." 131 if (modes_[shellI] == INSIDE)
133 Info<<
"Refinement level " << levels_[shellI][0]
134 <<
" for all cells inside " << shell.
name() <<
endl;
138 Info<<
"Refinement level " << levels_[shellI][0]
139 <<
" for all cells outside " << shell.
name() <<
endl;
148 void Foam::shellSurfaces::orient()
153 bool hasSurface =
false;
159 if (modes_[shellI] != DISTANCE && isA<triSurfaceMesh>(s))
163 if (shell.triSurface::size())
169 boundBox shellBb(points[0], points[0]);
173 const point& pt = points[i];
186 const point outsidePt = overallBb.
max() + overallBb.
span();
194 if (modes_[shellI] != DISTANCE && isA<triSurfaceMesh>(s))
198 refCast<const triSurfaceMesh>(
s)
218 Info<<
"shellSurfaces : Flipped orientation of surface " 220 <<
" so point " << outsidePt <<
" is outside." <<
endl;
229 void Foam::shellSurfaces::findHigherLevel
236 const labelList& levels = levels_[shellI];
238 if (modes_[shellI] == DISTANCE)
251 label candidateI = 0;
257 if (levels[levelI] > maxLevel[pointi])
259 candidates[candidateI] = pt[pointi];
260 candidateMap[candidateI] = pointi;
261 candidateDistSqr[candidateI] =
sqr(distances[levelI]);
267 candidates.setSize(candidateI);
268 candidateMap.setSize(candidateI);
269 candidateDistSqr.setSize(candidateI);
273 allGeometry_[shells_[shellI]].findNearest
281 forAll(nearInfo, candidateI)
283 if (nearInfo[candidateI].hit())
289 mag(nearInfo[candidateI].hitPoint()-candidates[candidateI])
292 label pointi = candidateMap[candidateI];
295 maxLevel[pointi] = levels[minDistI+1];
308 label candidateI = 0;
312 if (levels[0] > maxLevel[pointi])
314 candidates[candidateI] = pt[pointi];
315 candidateMap[candidateI] = pointi;
319 candidates.
setSize(candidateI);
320 candidateMap.setSize(candidateI);
324 allGeometry_[shells_[shellI]].getVolumeType(candidates, volType);
328 label pointi = candidateMap[i];
333 modes_[shellI] == INSIDE
337 modes_[shellI] == OUTSIDE
342 maxLevel[pointi] = levels[0];
357 allGeometry_(allGeometry)
365 const word& geomName = allGeometry_.names()[geomI];
367 if (shellsDict.
found(geomName))
375 shells_.setSize(shellI);
376 modes_.setSize(shellI);
377 distances_.setSize(shellI);
378 levels_.setSize(shellI);
383 forAll(allGeometry_.names(), geomI)
385 const word& geomName = allGeometry_.names()[geomI];
394 shells_[shellI] = geomI;
395 modes_[shellI] = refineModeNames_.read(dict.
lookup(
"mode"));
398 setAndCheckLevels(shellI, dict.
lookup(
"levels"));
404 if (unmatchedKeys.size() > 0)
409 ) <<
"Not all entries in refinementRegions dictionary were used." 410 <<
" The following entries were not used : " 411 << unmatchedKeys.sortedToc()
427 label overallMax = 0;
430 overallMax =
max(overallMax,
max(levels_[shellI]));
436 void Foam::shellSurfaces::findHigherLevel
448 findHigherLevel(pt, shellI, maxLevel);
shellSurfaces(const searchableSurfaces &allGeometry, const dictionary &shellsDict)
Construct from geometry and dictionary.
A HashTable with keys but without contents.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
const keyType & keyword() const
Return keyword.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 2-tuple for storing two objects of different types.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
virtual tmp< pointField > points() const
Get the points that define the surface.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool orient(triSurface &, const point &, const bool orientOutside)
Flip faces such that normals are consistent with point:
#define forAllReverse(list, i)
Reverse loop across all elements in list.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
A bounding box defined in terms of the points at its extremities.
label maxLevel() const
Highest shell level.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
Initialise the NamedEnum HashTable from the static list of names.
bool erase(T *p)
Remove the specified element from the list and delete it.
wordList toc() const
Return the table of contents.
IOoject and searching on triSurface.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A class for handling words, derived from string.
Container for searchableSurfaces.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void setSize(const label)
Reset size of List.
const point & max() const
Maximum describing the bounding box.
static const boundBox invertedBox
A very large inverted boundBox: min/max == +/- vGreat.
const wordList & names() const
vector span() const
The bounding box span (from minimum to maximum)
label findLower(const ListType &, typename ListType::const_reference, const label stary, const BinaryOp &bop)
Find last element < given value in sorted list and return index,.
dimensioned< scalar > mag(const dimensioned< Type > &)
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
const point & min() const
Minimum describing the bounding box.
Tuple2< scalar, label > nearInfo
Private class for finding nearest.
A keyword and a list of tokens is an 'entry'.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.