39 NamedEnum<shellSurfaces::refineMode, 5>::
52 Foam::shellSurfaces::refineModeNames_;
57 void Foam::shellSurfaces::setAndCheckLevels
66 <<
"For refinement mode " 67 << refineModeNames_[modes_[shelli]]
68 <<
" specify only one distance+level." 69 <<
" (its distance gets discarded)" 74 distances_[shelli].setSize(distLevels.size());
75 levels_[shelli].setSize(distLevels.size());
79 distances_[shelli][j] = distLevels[j].first();
80 levels_[shelli][j] = distLevels[j].second();
87 (distances_[shelli][j] <= distances_[shelli][j-1])
88 || (levels_[shelli][j] > levels_[shelli][j-1])
92 <<
"For refinement mode " 93 << refineModeNames_[modes_[shelli]]
94 <<
" : Refinement should be specified in order" 95 <<
" of increasing distance" 96 <<
" (and decreasing refinement level)." <<
endl 97 <<
"Distance:" << distances_[shelli][j]
98 <<
" refinementLevel:" << levels_[shelli][j]
108 Info<<
"Refinement level according to distance to " 111 forAll(levels_[shelli], j)
113 Info<<
" level " << levels_[shelli][j]
114 <<
" for all cells within " << distances_[shelli][j]
115 <<
" metre." <<
endl;
120 if (!allGeometry_[shells_[shelli]].hasVolumeType())
123 <<
"Shell " << shell.
name()
124 <<
" does not support testing for " 125 << refineModeNames_[modes_[shelli]] <<
endl 126 <<
"Probably it is not closed." 130 if (modes_[shelli] == refineMode::inside)
132 Info<<
"Refinement level " << levels_[shelli][0]
133 <<
" for all cells inside " << shell.
name() <<
endl;
137 Info<<
"Refinement level " << levels_[shelli][0]
138 <<
" for all cells outside " << shell.
name() <<
endl;
144 void Foam::shellSurfaces::orient()
149 bool hasSurface =
false;
159 if (shell.triSurface::size())
165 boundBox shellBb(points[0], points[0]);
169 const point& pt = points[i];
182 const point outsidePt = overallBb.
max() + overallBb.
span();
193 && isA<triSurfaceMesh>(s)
198 refCast<const triSurfaceMesh>(
s)
218 Info<<
"shellSurfaces : Flipped orientation of surface " 220 <<
" so point " << outsidePt <<
" is outside." <<
endl;
228 Foam::scalar Foam::shellSurfaces::interpolate
241 tsm.triSurface::operator[](index)
247 return closeness[lf[0]]*bary[0]
248 + closeness[lf[1]]*bary[1]
249 + closeness[lf[2]]*bary[2];
253 void Foam::shellSurfaces::findHigherLevel
257 const scalar level0EdgeLength,
261 const labelList& levels = levels_[shelli];
276 label candidateI = 0;
282 if (levels[levelI] > maxLevel[pointi])
284 candidates[candidateI] = pt[pointi];
285 candidateMap[candidateI] = pointi;
286 candidateDistSqr[candidateI] =
sqr(distances[levelI]);
292 candidates.setSize(candidateI);
293 candidateMap.setSize(candidateI);
294 candidateDistSqr.setSize(candidateI);
298 allGeometry_[shells_[shelli]].findNearest
306 forAll(nearInfo, candidateI)
308 if (nearInfo[candidateI].hit())
314 mag(nearInfo[candidateI].hitPoint()-candidates[candidateI])
317 label pointi = candidateMap[candidateI];
320 maxLevel[pointi] = levels[minDistI+1];
326 modes_[shelli] == refineMode::insideSpan
327 || modes_[shelli] == refineMode::outsideSpan
331 refCast<const triSurfaceMesh>(allGeometry_[shells_[shelli]]);
339 label candidateI = 0;
343 if (levels[0] > maxLevel[pointi])
345 candidates[candidateI] = pt[pointi];
346 candidateMap[candidateI] = pointi;
347 candidateDistSqr[candidateI] =
sqr(distances_[shelli][0]);
351 candidates.setSize(candidateI);
352 candidateMap.setSize(candidateI);
353 candidateDistSqr.setSize(candidateI);
367 cellsAcrossSpan_[shelli]*level0EdgeLength/(1 << (levels[0] - 1))
371 forAll(nearInfo, candidateI)
373 if (nearInfo[candidateI].hit())
381 nearInfo[candidateI].rawPoint(),
382 nearInfo[candidateI].index()
390 log2(cellsAcrossSpan_[shelli]*level0EdgeLength/span) + 1
393 maxLevel[candidateMap[candidateI]] =
min(levels[0], level);
397 maxLevel[candidateMap[candidateI]] = levels[0];
411 label candidateI = 0;
415 if (levels[0] > maxLevel[pointi])
417 candidates[candidateI] = pt[pointi];
418 candidateMap[candidateI] = pointi;
422 candidates.
setSize(candidateI);
423 candidateMap.setSize(candidateI);
427 allGeometry_[shells_[shelli]].getVolumeType(candidates, volType);
431 label pointi = candidateMap[i];
436 modes_[shelli] == refineMode::inside
440 modes_[shelli] == refineMode::outside
445 maxLevel[pointi] = levels[0];
460 allGeometry_(allGeometry)
468 const word& geomName = allGeometry_.names()[geomI];
470 if (shellsDict.
found(geomName))
477 shells_.setSize(shelli);
478 modes_.setSize(shelli);
479 distances_.setSize(shelli);
480 levels_.setSize(shelli);
481 cellsAcrossSpan_.setSize(shelli);
482 closeness_.setSize(shelli);
487 forAll(allGeometry_.names(), geomI)
489 const word& geomName = allGeometry_.names()[geomI];
498 shells_[shelli] = geomI;
499 modes_[shelli] = refineModeNames_.read(dict.
lookup(
"mode"));
502 setAndCheckLevels(shelli, dict.
lookup(
"levels"));
506 modes_[shelli] == refineMode::insideSpan
507 || modes_[shelli] == refineMode::outsideSpan
512 if (isA<triSurfaceMesh>(surface))
514 dict.
lookup(
"cellsAcrossSpan") >> cellsAcrossSpan_[shelli];
517 refCast<const triSurfaceMesh>(surface);
529 modes_[shelli] == refineMode::insideSpan
534 surface.searchableSurface::time().constant(),
536 surface.searchableSurface::time(),
548 <<
"Surface " << surface.
name()
549 <<
" is not a triSurface as required by" 551 << refineModeNames_[refineMode::insideSpan]
552 <<
" and " << refineModeNames_[refineMode::outsideSpan]
561 if (unmatchedKeys.size() > 0)
566 ) <<
"Not all entries in refinementRegions dictionary were used." 567 <<
" The following entries were not used : " 568 << unmatchedKeys.sortedToc()
583 label overallMax = 0;
587 overallMax =
max(overallMax,
max(levels_[shelli]));
594 void Foam::shellSurfaces::findHigherLevel
598 const scalar level0EdgeLength,
607 findHigherLevel(pt, shelli, level0EdgeLength, 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.
A triangle primitive used to calculate face areas and swept volumes.
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)
barycentric2D pointToBarycentric(const point &pt) const
Calculate the barycentric coordinates from the given point.
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.
label log2(label i)
Return the log base 2 by successive bit-shifting of the given label.
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.
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void size(const label)
Override size to be inconsistent with allocated storage.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
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.
scalar distance(const vector &p1, const vector &p2)
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.
Templated 2D Barycentric derived from VectorSpace. Has 3 components, one of which is redundant...
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.
Triangle with additional region number.
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.
bool set(const Key &, const T &newElmt)
Assign a new hashedEntry, overwriting existing entries.
static const boundBox invertedBox
A very large inverted boundBox: min/max == +/- vGreat.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
const wordList & names() const
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
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.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
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.