50 Foam::refinementRegions::refineModeNames_;
55 void Foam::refinementRegions::setAndCheckLevels
58 const dictionary&
dict
61 const searchableSurface& shell = allGeometry_[shells_[shelli]];
69 if (!allGeometry_[shells_[shelli]].hasVolumeType())
72 <<
"Shell " << shell.name()
73 <<
" is not closed so testing for '"
74 << refineModeNames_[modes_[shelli]]
75 <<
"' may fail." <<
endl;
81 if (
dict.found(
"levels") && !(
dict.found(
"level")))
84 const List<Tuple2<scalar, label>> distLevels(
dict.lookup(
"levels"));
86 if (distLevels.size() != 1)
89 <<
"For refinement mode "
90 << refineModeNames_[modes_[shelli]]
91 <<
" specify only one distance+level."
92 <<
" (its distance gets discarded)"
96 levels_[shelli][0] = distLevels[0].second();
100 if (
dict.found(
"levels"))
103 <<
"Found both 'level' and 'levels' entries, using 'level'."
112 Info<<
"Refinement level " << levels_[shelli][0]
113 <<
" for all cells inside " << shell.name() <<
endl;
117 Info<<
"Refinement level " << levels_[shelli][0]
118 <<
" for all cells outside " << shell.name() <<
endl;
127 if (!allGeometry_[shells_[shelli]].hasVolumeType())
130 <<
"Shell " << shell.name()
131 <<
" is not closed so testing for '"
132 << refineModeNames_[modes_[shelli]]
133 <<
"' may fail." <<
endl;
138 const Tuple2<scalar, label> distLevel(
dict.lookup(
"level"));
139 distances_[shelli][0] = distLevel.
first();
140 levels_[shelli][0] = distLevel.second();
144 Info<<
"Refinement level " << levels_[shelli][0]
145 <<
" for all cells inside " << shell.name()
146 <<
" within distance " << distances_[shelli][0] <<
endl;
150 Info<<
"Refinement level " << levels_[shelli][0]
151 <<
" for all cells outside " << shell.name()
152 <<
" within distance " << distances_[shelli][0] <<
endl;
157 const List<Tuple2<scalar, label>> distLevels(
dict.lookup(
"levels"));
160 distances_[shelli].
setSize(distLevels.size());
161 levels_[shelli].
setSize(distLevels.size());
165 distances_[shelli][j] = distLevels[j].
first();
166 levels_[shelli][j] = distLevels[j].second();
173 (distances_[shelli][j] <= distances_[shelli][j-1])
174 || (levels_[shelli][j] > levels_[shelli][j-1])
178 <<
"For refinement mode "
179 << refineModeNames_[modes_[shelli]]
180 <<
" : Refinement should be specified in order"
181 <<
" of increasing distance"
182 <<
" (and decreasing refinement level)." <<
endl
183 <<
"Distance:" << distances_[shelli][j]
184 <<
" refinementLevel:" << levels_[shelli][j]
192 Info<<
"Refinement level according to distance to "
193 << shell.name() <<
endl;
195 forAll(levels_[shelli], j)
197 Info<<
" level " << levels_[shelli][j]
198 <<
" for all cells within " << distances_[shelli][j]
199 <<
" metre." <<
endl;
206 void Foam::refinementRegions::orient()
211 bool hasSurface =
false;
215 const searchableSurface&
s = allGeometry_[shells_[shelli]];
217 if (modes_[shelli] != refineMode::distance && isA<triSurfaceMesh>(
s))
219 const triSurfaceMesh& shell = refCast<const triSurfaceMesh>(
s);
221 if (shell.triSurface::size())
223 tmp<pointField> tpoints(shell.points());
233 shellBb.min() =
min(shellBb.min(), pt);
234 shellBb.max() =
max(shellBb.max(), pt);
237 overallBb.min() =
min(overallBb.min(), shellBb.min());
238 overallBb.max() =
max(overallBb.max(), shellBb.max());
245 const point outsidePt = overallBb.
max() + overallBb.span();
251 const searchableSurface&
s = allGeometry_[shells_[shelli]];
255 modes_[shelli] != refineMode::distance
256 && isA<triSurfaceMesh>(
s)
259 triSurfaceMesh& shell =
const_cast<triSurfaceMesh&
>
261 refCast<const triSurfaceMesh>(
s)
281 Info<<
"refinementRegions : Flipped orientation of surface "
283 <<
" so point " << outsidePt <<
" is outside." <<
endl;
291 Foam::scalar Foam::refinementRegions::interpolate
293 const triSurfaceMesh& tsm,
304 tsm.triSurface::operator[](index)
305 ).pointToBarycentric(pt)
308 const labelledTri& lf = tsm.localFaces()[index];
310 return closeness[lf[0]]*bary[0]
311 + closeness[lf[1]]*bary[1]
312 + closeness[lf[2]]*bary[2];
316 void Foam::refinementRegions::findHigherLevel
320 const scalar level0EdgeLength,
324 const labelList& levels = levels_[shelli];
326 if (modes_[shelli] == refineMode::distance)
339 label candidatei = 0;
345 if (levels[leveli] > maxLevel[pointi])
347 candidates[candidatei] = pt[pointi];
348 candidateMap[candidatei] = pointi;
349 candidateDistSqr[candidatei] =
sqr(distances[leveli]);
355 candidates.setSize(candidatei);
356 candidateMap.setSize(candidatei);
357 candidateDistSqr.setSize(candidatei);
361 allGeometry_[shells_[shelli]].findNearest
377 mag(
nearInfo[candidatei].hitPoint()-candidates[candidatei])
380 label pointi = candidateMap[candidatei];
383 maxLevel[pointi] = levels[minDistI+1];
389 modes_[shelli] == refineMode::insideSpan
390 || modes_[shelli] == refineMode::outsideSpan
393 const triSurfaceMesh& tsm =
394 refCast<const triSurfaceMesh>(allGeometry_[shells_[shelli]]);
402 label candidatei = 0;
406 if (levels[0] > maxLevel[pointi])
408 candidates[candidatei] = pt[pointi];
409 candidateMap[candidatei] = pointi;
410 candidateDistSqr[candidatei] =
sqr(distances_[shelli][0]);
414 candidates.setSize(candidatei);
415 candidateMap.setSize(candidatei);
416 candidateDistSqr.setSize(candidatei);
430 cellsAcrossSpan_[shelli]*level0EdgeLength/(1 << (levels[0] - 1))
453 log2(cellsAcrossSpan_[shelli]*level0EdgeLength/span) + 1
456 maxLevel[candidateMap[candidatei]] =
min(levels[0], level);
460 maxLevel[candidateMap[candidatei]] = levels[0];
474 label candidatei = 0;
478 if (levels[0] > maxLevel[pointi])
480 candidates[candidatei] = pt[pointi];
481 candidateMap[candidatei] = pointi;
485 candidates.setSize(candidatei);
486 candidateMap.setSize(candidatei);
489 List<volumeType> volType;
490 allGeometry_[shells_[shelli]].getVolumeType(candidates, volType);
494 label pointi = candidateMap[i];
499 modes_[shelli] == refineMode::inside
503 modes_[shelli] == refineMode::outside
508 maxLevel[pointi] = levels[0];
523 allGeometry_(allGeometry)
531 const word& geomName = allGeometry_.
names()[geomi];
533 if (shellsDict.
found(geomName))
544 cellsAcrossSpan_.
setSize(shelli);
545 closeness_.setSize(shelli);
552 const word& geomName = allGeometry_.
names()[geomi];
561 shells_[shelli] = geomi;
562 modes_[shelli] = refineModeNames_.
read(
dict.lookup(
"mode"));
565 setAndCheckLevels(shelli,
dict);
575 if (isA<triSurfaceMesh>(surface))
577 dict.lookup(
"cellsAcrossSpan") >> cellsAcrossSpan_[shelli];
580 refCast<const triSurfaceMesh>(surface);
597 surface.searchableSurface::time().constant(),
600 surface.searchableSurface::time()
602 surface.searchableSurface::time(),
612 <<
"Surface " << surface.
name()
613 <<
" is not a triSurface as required by"
625 if (unmatchedKeys.
size() > 0)
630 ) <<
"Not all entries in refinementRegions dictionary were used."
631 <<
" The following entries were not used : "
647 label overallMax = 0;
651 overallMax =
max(overallMax,
max(levels_[shelli]));
658 void Foam::refinementRegions::findHigherLevel
662 const scalar level0EdgeLength,
671 findHigherLevel(pt, shelli, level0EdgeLength, maxLevel);
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A HashTable with keys but without contents.
List< Key > sortedToc() const
Return the table of contents as a sorted list.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
label size() const
Return number of elements in table.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const word & name() const
Return name.
void setSize(const label)
Reset size of List.
Initialise the NamedEnum HashTable from the static list of names.
Enum read(Istream &) const
Read a word from Istream and return the corresponding.
T & first()
Return the first element of the list.
static const boundBox invertedBox
A very large inverted boundBox: min/max == +/- vGreat.
A list of keyword definitions, which are a keyword followed by any number of values (e....
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
wordList toc() const
Return the table of contents.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
A keyword and a list of tokens is an 'entry'.
const keyType & keyword() const
Return keyword.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
static bool orient(triSurface &, const point &, const bool orientOutside)
Flip faces such that normals are consistent with point:
label maxLevel() const
Highest shell level.
refinementRegions(const searchableSurfaces &allGeometry, const dictionary &shellsDict)
Construct from geometry and dictionary.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
static const word & geometryDir()
Return the geometry directory name.
Container for searchableSurfaces.
const wordList & names() const
A surface geometry formed of discrete facets, e.g. triangles and/or quadrilaterals,...
A class for handling words, derived from string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
#define WarningInFunction
Report a warning using Foam::Warning.
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Tuple2< scalar, label > nearInfo
Private class for finding nearest.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
label log2(label i)
Return the log base 2 by successive bit-shifting of the given 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.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
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,.
Foam::DimensionedField< scalar, triSurfacePointGeoMesh > triSurfacePointScalarField
vectorField pointField
pointField is a vectorField.
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
vector point
Point is a vector.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
triangle< point, const point & > triPointRef
label readLabel(Istream &is)