33 Foam::refinementRegions::refineModeNames_
45 void Foam::refinementRegions::setAndCheckLevels
48 const dictionary&
dict
51 const searchableSurface& shell = allGeometry_[shells_[shelli]];
59 if (!allGeometry_[shells_[shelli]].hasVolumeType())
62 <<
"Shell " << shell.name()
63 <<
" is not closed so testing for '"
64 << refineModeNames_[modes_[shelli]]
65 <<
"' may fail." <<
endl;
71 if (
dict.found(
"levels") && !(
dict.found(
"level")))
74 const List<Tuple2<scalar, label>> distLevels(
dict.lookup(
"levels"));
76 if (distLevels.size() != 1)
79 <<
"For refinement mode "
80 << refineModeNames_[modes_[shelli]]
81 <<
" specify only one distance+level."
82 <<
" (its distance gets discarded)"
86 levels_[shelli][0] = distLevels[0].second();
90 if (
dict.found(
"levels"))
93 <<
"Found both 'level' and 'levels' entries, using 'level'."
102 Info<<
"Refinement level " << levels_[shelli][0]
103 <<
" for all cells inside " << shell.name() <<
endl;
107 Info<<
"Refinement level " << levels_[shelli][0]
108 <<
" for all cells outside " << shell.name() <<
endl;
117 if (!allGeometry_[shells_[shelli]].hasVolumeType())
120 <<
"Shell " << shell.name()
121 <<
" is not closed so testing for '"
122 << refineModeNames_[modes_[shelli]]
123 <<
"' may fail." <<
endl;
128 const Tuple2<scalar, label> distLevel(
dict.lookup(
"level"));
129 distances_[shelli][0] = distLevel.
first();
130 levels_[shelli][0] = distLevel.second();
134 Info<<
"Refinement level " << levels_[shelli][0]
135 <<
" for all cells inside " << shell.name()
136 <<
" within distance " << distances_[shelli][0] <<
endl;
140 Info<<
"Refinement level " << levels_[shelli][0]
141 <<
" for all cells outside " << shell.name()
142 <<
" within distance " << distances_[shelli][0] <<
endl;
147 const List<Tuple2<scalar, label>> distLevels(
dict.lookup(
"levels"));
150 distances_[shelli].
setSize(distLevels.size());
151 levels_[shelli].
setSize(distLevels.size());
155 distances_[shelli][j] = distLevels[j].
first();
156 levels_[shelli][j] = distLevels[j].second();
163 (distances_[shelli][j] <= distances_[shelli][j-1])
164 || (levels_[shelli][j] > levels_[shelli][j-1])
168 <<
"For refinement mode "
169 << refineModeNames_[modes_[shelli]]
170 <<
" : Refinement should be specified in order"
171 <<
" of increasing distance"
172 <<
" (and decreasing refinement level)." <<
endl
173 <<
"Distance:" << distances_[shelli][j]
174 <<
" refinementLevel:" << levels_[shelli][j]
182 Info<<
"Refinement level according to distance to "
183 << shell.name() <<
endl;
185 forAll(levels_[shelli], j)
187 Info<<
" level " << levels_[shelli][j]
188 <<
" for all cells within " << distances_[shelli][j]
189 <<
" metre." <<
endl;
196 void Foam::refinementRegions::orient()
201 bool hasSurface =
false;
205 const searchableSurface&
s = allGeometry_[shells_[shelli]];
209 modes_[shelli] != refineMode::distance
210 && isA<searchableSurfaces::triSurface>(
s)
213 const searchableSurfaces::triSurface& shell =
214 refCast<const searchableSurfaces::triSurface>(
s);
216 if (shell.triSurface::size())
218 tmp<pointField> tpoints(shell.points());
228 shellBb.min() =
min(shellBb.min(), pt);
229 shellBb.max() =
max(shellBb.max(), pt);
232 overallBb.min() =
min(overallBb.min(), shellBb.min());
233 overallBb.max() =
max(overallBb.max(), shellBb.max());
240 const point outsidePt = overallBb.
max() + overallBb.span();
246 const searchableSurface&
s = allGeometry_[shells_[shelli]];
250 modes_[shelli] != refineMode::distance
251 && isA<searchableSurfaces::triSurface>(
s)
254 searchableSurfaces::triSurface& shell =
255 const_cast<searchableSurfaces::triSurface&
>
257 refCast<const searchableSurfaces::triSurface>(
s)
277 Info<<
"refinementRegions : Flipped orientation of surface "
279 <<
" so point " << outsidePt <<
" is outside." <<
endl;
287 Foam::scalar Foam::refinementRegions::interpolate
289 const searchableSurfaces::triSurface& tsm,
300 tsm.Foam::triSurface::operator[](index)
301 ).pointToBarycentric(pt)
304 const labelledTri& lf = tsm.localFaces()[index];
306 return closeness[lf[0]]*bary[0]
307 + closeness[lf[1]]*bary[1]
308 + closeness[lf[2]]*bary[2];
312 void Foam::refinementRegions::findHigherLevel
316 const scalar level0EdgeLength,
320 const labelList& levels = levels_[shelli];
322 if (modes_[shelli] == refineMode::distance)
335 label candidatei = 0;
341 if (levels[leveli] > maxLevel[pointi])
343 candidates[candidatei] = pt[pointi];
344 candidateMap[candidatei] = pointi;
345 candidateDistSqr[candidatei] =
sqr(distances[leveli]);
351 candidates.setSize(candidatei);
352 candidateMap.setSize(candidatei);
353 candidateDistSqr.setSize(candidatei);
357 allGeometry_[shells_[shelli]].findNearest
373 mag(
nearInfo[candidatei].hitPoint()-candidates[candidatei])
376 label pointi = candidateMap[candidatei];
379 maxLevel[pointi] = levels[minDistI+1];
385 modes_[shelli] == refineMode::insideSpan
386 || modes_[shelli] == refineMode::outsideSpan
389 const searchableSurfaces::triSurface& tsm =
390 refCast<const searchableSurfaces::triSurface>
391 (allGeometry_[shells_[shelli]]);
399 label candidatei = 0;
403 if (levels[0] > maxLevel[pointi])
405 candidates[candidatei] = pt[pointi];
406 candidateMap[candidatei] = pointi;
407 candidateDistSqr[candidatei] =
sqr(distances_[shelli][0]);
411 candidates.setSize(candidatei);
412 candidateMap.setSize(candidatei);
413 candidateDistSqr.setSize(candidatei);
427 cellsAcrossSpan_[shelli]*level0EdgeLength/(1 << (levels[0] - 1))
450 log2(cellsAcrossSpan_[shelli]*level0EdgeLength/span) + 1
453 maxLevel[candidateMap[candidatei]] =
min(levels[0], level);
457 maxLevel[candidateMap[candidatei]] = levels[0];
471 label candidatei = 0;
475 if (levels[0] > maxLevel[pointi])
477 candidates[candidatei] = pt[pointi];
478 candidateMap[candidatei] = pointi;
482 candidates.setSize(candidatei);
483 candidateMap.setSize(candidatei);
486 List<volumeType> volType;
487 allGeometry_[shells_[shelli]].getVolumeType(candidates, volType);
491 label pointi = candidateMap[i];
496 modes_[shelli] == refineMode::inside
500 modes_[shelli] == refineMode::outside
505 maxLevel[pointi] = levels[0];
520 allGeometry_(allGeometry)
528 const word& geomName = allGeometry_.
names()[geomi];
530 if (shellsDict.
found(geomName))
541 cellsAcrossSpan_.
setSize(shelli);
542 closeness_.setSize(shelli);
549 const word& geomName = allGeometry_.
names()[geomi];
558 shells_[shelli] = geomi;
559 modes_[shelli] = refineModeNames_.
read(
dict.lookup(
"mode"));
562 setAndCheckLevels(shelli,
dict);
572 if (isA<searchableSurfaces::triSurface>(surface))
574 dict.lookup(
"cellsAcrossSpan") >> cellsAcrossSpan_[shelli];
577 refCast<const searchableSurfaces::triSurface>
595 surface.searchableSurface::time().constant(),
598 surface.searchableSurface::time()
600 surface.searchableSurface::time(),
610 <<
"Surface " << surface.
name()
611 <<
" is not a triSurface as required by"
623 if (unmatchedKeys.
size() > 0)
628 ) <<
"Not all entries in refinementRegions dictionary were used."
629 <<
" The following entries were not used : "
645 label overallMax = 0;
649 overallMax =
max(overallMax,
max(levels_[shelli]));
656 void Foam::refinementRegions::findHigherLevel
660 const scalar level0EdgeLength,
669 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 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:
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 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(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,.
vectorField pointField
pointField is a vectorField.
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
vector point
Point is a vector.
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
DimensionedField< scalar, triSurfacePointGeoMesh, Field > triSurfacePointScalarField
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
triangle< point, const point & > triPointRef
label readLabel(Istream &is)