34 Foam::refinementRegions::refineModeNames_
46 void Foam::refinementRegions::setAndCheckLevels
49 const dictionary&
dict
52 const searchableSurface& shell = allGeometry_[shells_[shelli]];
60 if (!allGeometry_[shells_[shelli]].hasVolumeType())
63 <<
"Shell " << shell.name()
64 <<
" is not closed so testing for '"
65 << refineModeNames_[modes_[shelli]]
66 <<
"' may fail." <<
endl;
72 if (
dict.found(
"levels") && !(
dict.found(
"level")))
77 if (distLevels.size() != 1)
80 <<
"For refinement mode "
81 << refineModeNames_[modes_[shelli]]
82 <<
" specify only one distance+level."
83 <<
" (its distance gets discarded)"
87 levels_[shelli][0] = distLevels[0].second();
91 if (
dict.found(
"levels"))
94 <<
"Found both 'level' and 'levels' entries, using 'level'."
103 Info<<
"Refinement level " << levels_[shelli][0]
104 <<
" for all cells inside " << shell.name() <<
endl;
108 Info<<
"Refinement level " << levels_[shelli][0]
109 <<
" for all cells outside " << shell.name() <<
endl;
118 if (!allGeometry_[shells_[shelli]].hasVolumeType())
121 <<
"Shell " << shell.name()
122 <<
" is not closed so testing for '"
123 << refineModeNames_[modes_[shelli]]
124 <<
"' may fail." <<
endl;
129 const Tuple2<scalar, label> distLevel(
dict.lookup(
"level"));
130 distances_[shelli][0] = distLevel.
first();
131 levels_[shelli][0] = distLevel.second();
135 Info<<
"Refinement level " << levels_[shelli][0]
136 <<
" for all cells inside " << shell.name()
137 <<
" within distance " << distances_[shelli][0] <<
endl;
141 Info<<
"Refinement level " << levels_[shelli][0]
142 <<
" for all cells outside " << shell.name()
143 <<
" within distance " << distances_[shelli][0] <<
endl;
151 distances_[shelli].
setSize(distLevels.size());
152 levels_[shelli].
setSize(distLevels.size());
156 distances_[shelli][j] = distLevels[j].
first();
157 levels_[shelli][j] = distLevels[j].second();
164 (distances_[shelli][j] <= distances_[shelli][j-1])
165 || (levels_[shelli][j] > levels_[shelli][j-1])
169 <<
"For refinement mode "
170 << refineModeNames_[modes_[shelli]]
171 <<
" : Refinement should be specified in order"
172 <<
" of increasing distance"
173 <<
" (and decreasing refinement level)." <<
endl
174 <<
"Distance:" << distances_[shelli][j]
175 <<
" refinementLevel:" << levels_[shelli][j]
183 Info<<
"Refinement level according to distance to "
184 << shell.name() <<
endl;
186 forAll(levels_[shelli], j)
188 Info<<
" level " << levels_[shelli][j]
189 <<
" for all cells within " << distances_[shelli][j]
190 <<
" metre." <<
endl;
197 void Foam::refinementRegions::orient()
202 bool hasSurface =
false;
206 const searchableSurface&
s = allGeometry_[shells_[shelli]];
210 modes_[shelli] != refineMode::distance
211 && isA<searchableSurfaces::triSurface>(
s)
214 const searchableSurfaces::triSurface& shell =
215 refCast<const searchableSurfaces::triSurface>(
s);
217 if (shell.triSurface::size())
219 tmp<pointField> tpoints(shell.points());
229 shellBb.min() =
min(shellBb.min(), pt);
230 shellBb.max() =
max(shellBb.max(), pt);
233 overallBb.min() =
min(overallBb.min(), shellBb.min());
234 overallBb.max() =
max(overallBb.max(), shellBb.max());
241 const point outsidePt = overallBb.
max() + overallBb.span();
247 const searchableSurface&
s = allGeometry_[shells_[shelli]];
251 modes_[shelli] != refineMode::distance
252 && isA<searchableSurfaces::triSurface>(
s)
255 searchableSurfaces::triSurface& shell =
256 const_cast<searchableSurfaces::triSurface&
>
258 refCast<const searchableSurfaces::triSurface>(
s)
278 Info<<
"refinementRegions : Flipped orientation of surface "
280 <<
" so point " << outsidePt <<
" is outside." <<
endl;
288 Foam::scalar Foam::refinementRegions::interpolate
290 const searchableSurfaces::triSurface& tsm,
301 tsm.Foam::triSurface::operator[](index)
302 ).pointToBarycentric(pt)
305 const labelledTri& lf = tsm.localFaces()[index];
307 return closeness[lf[0]]*bary[0]
308 + closeness[lf[1]]*bary[1]
309 + closeness[lf[2]]*bary[2];
313 void Foam::refinementRegions::findHigherLevel
317 const scalar level0EdgeLength,
321 const labelList& levels = levels_[shelli];
323 if (modes_[shelli] == refineMode::distance)
336 label candidatei = 0;
342 if (levels[leveli] > maxLevel[pointi])
344 candidates[candidatei] = pt[pointi];
345 candidateMap[candidatei] = pointi;
346 candidateDistSqr[candidatei] =
sqr(distances[leveli]);
352 candidates.setSize(candidatei);
353 candidateMap.setSize(candidatei);
354 candidateDistSqr.setSize(candidatei);
358 allGeometry_[shells_[shelli]].findNearest
374 mag(
nearInfo[candidatei].hitPoint()-candidates[candidatei])
377 label pointi = candidateMap[candidatei];
380 maxLevel[pointi] = levels[minDistI+1];
386 modes_[shelli] == refineMode::insideSpan
387 || modes_[shelli] == refineMode::outsideSpan
390 const searchableSurfaces::triSurface& tsm =
391 refCast<const searchableSurfaces::triSurface>
392 (allGeometry_[shells_[shelli]]);
400 label candidatei = 0;
404 if (levels[0] > maxLevel[pointi])
406 candidates[candidatei] = pt[pointi];
407 candidateMap[candidatei] = pointi;
408 candidateDistSqr[candidatei] =
sqr(distances_[shelli][0]);
412 candidates.setSize(candidatei);
413 candidateMap.setSize(candidatei);
414 candidateDistSqr.setSize(candidatei);
428 cellsAcrossSpan_[shelli]*level0EdgeLength/(1 << (levels[0] - 1))
451 log2(cellsAcrossSpan_[shelli]*level0EdgeLength/span) + 1
454 maxLevel[candidateMap[candidatei]] =
min(levels[0], level);
458 maxLevel[candidateMap[candidatei]] = levels[0];
472 label candidatei = 0;
476 if (levels[0] > maxLevel[pointi])
478 candidates[candidatei] = pt[pointi];
479 candidateMap[candidatei] = pointi;
483 candidates.setSize(candidatei);
484 candidateMap.setSize(candidatei);
488 allGeometry_[shells_[shelli]].getVolumeType(candidates, volType);
492 label pointi = candidateMap[i];
497 modes_[shelli] == refineMode::inside
501 modes_[shelli] == refineMode::outside
506 maxLevel[pointi] = levels[0];
521 allGeometry_(allGeometry)
529 const word& geomName = allGeometry_.
names()[geomi];
531 if (shellsDict.
found(geomName))
542 cellsAcrossSpan_.
setSize(shelli);
543 closeness_.setSize(shelli);
550 const word& geomName = allGeometry_.
names()[geomi];
559 shells_[shelli] = geomi;
560 modes_[shelli] = refineModeNames_.
read(
dict.lookup(
"mode"));
563 setAndCheckLevels(shelli,
dict);
573 if (isA<searchableSurfaces::triSurface>(surface))
575 dict.lookup(
"cellsAcrossSpan") >> cellsAcrossSpan_[shelli];
592 surface.searchableSurface::time().constant(),
595 surface.searchableSurface::time()
597 surface.searchableSurface::time(),
606 <<
"Surface " << surface.
name()
607 <<
" is not a triSurface as required by"
619 if (unmatchedKeys.
size() > 0)
624 ) <<
"Not all entries in refinementRegions dictionary were used."
625 <<
" The following entries were not used : "
641 label overallMax = 0;
645 overallMax =
max(overallMax,
max(levels_[shelli]));
652 void Foam::refinementRegions::findHigherLevel
656 const scalar level0EdgeLength,
665 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.
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.
A primitive field of type <Type> with automated input and output.
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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:
Motion of the mesh specified as a list of pointMeshMovers.
refinementRegions(const searchableSurfaceList &allGeometry, const dictionary &shellsDict)
Construct from geometry and dictionary.
label maxLevel() const
Highest shell level.
Container for searchableSurfaces.
const wordList & names() const
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
static const word & geometryDir()
Return the geometry directory name.
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(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::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.
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,.
IOField< scalar > scalarIOField
scalarField with IO.
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.
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
triangle< point, const point & > triPointRef
label readLabel(Istream &is)
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)