34 Foam::refinementRegions::refineModeNames_
46 void Foam::refinementRegions::setAndCheckLevels
49 const dictionary&
dict
52 const searchableSurface& shell = allGeometry_[shells_[shelli]];
58 if (!allGeometry_[shells_[shelli]].hasVolumeType())
61 <<
"Shell " << shell.name()
62 <<
" is not closed so testing for '"
63 << refineModeNames_[
mode]
64 <<
"' may fail." <<
endl;
71 Info<<
"Refinement level " << levels_[shelli][0] <<
" for all cells "
73 <<
' ' << shell.name() <<
endl;
77 if (!allGeometry_[shells_[shelli]].hasVolumeType())
80 <<
"Shell " << shell.name()
81 <<
" is not closed so testing for '"
82 << refineModeNames_[
mode]
83 <<
"' may fail." <<
endl;
88 const Tuple2<scalar, label> distLevel(
dict.lookup(
"level"));
89 distances_[shelli][0] = distLevel.
first();
90 levels_[shelli][0] = distLevel.second();
92 Info<<
"Refinement level " << levels_[shelli][0] <<
" for all cells "
94 <<
' ' << shell.name() <<
" within distance "
95 << distances_[shelli][0] <<
endl;
102 distances_[shelli].
setSize(distLevels.size());
103 levels_[shelli].
setSize(distLevels.size());
107 distances_[shelli][j] = distLevels[j].
first();
108 levels_[shelli][j] = distLevels[j].second();
115 (distances_[shelli][j] <= distances_[shelli][j-1])
116 || (levels_[shelli][j] > levels_[shelli][j-1])
120 <<
"For refinement mode "
121 << refineModeNames_[
mode]
122 <<
" : Refinement should be specified in order"
123 <<
" of increasing distance"
124 <<
" (and decreasing refinement level)." <<
endl
125 <<
"Distance:" << distances_[shelli][j]
126 <<
" refinementLevel:" << levels_[shelli][j]
134 Info<<
"Refinement level according to distance to "
135 << shell.name() <<
endl;
137 forAll(levels_[shelli], j)
139 Info<<
" level " << levels_[shelli][j]
140 <<
" for all cells within " << distances_[shelli][j]
148 void Foam::refinementRegions::orient()
153 bool hasSurface =
false;
157 const searchableSurface&
s = allGeometry_[shells_[shelli]];
161 modes_[shelli] != refineMode::distance
162 && isA<searchableSurfaces::triSurface>(
s)
165 const searchableSurfaces::triSurface& shell =
166 refCast<const searchableSurfaces::triSurface>(
s);
168 if (shell.triSurface::size())
170 tmp<pointField> tpoints(shell.points());
180 shellBb.min() =
min(shellBb.min(), pt);
181 shellBb.max() =
max(shellBb.max(), pt);
184 overallBb.min() =
min(overallBb.min(), shellBb.min());
185 overallBb.max() =
max(overallBb.max(), shellBb.max());
192 const point outsidePt = overallBb.
max() + overallBb.span();
198 const searchableSurface&
s = allGeometry_[shells_[shelli]];
202 modes_[shelli] != refineMode::distance
203 && isA<searchableSurfaces::triSurface>(
s)
206 searchableSurfaces::triSurface& shell =
207 const_cast<searchableSurfaces::triSurface&
>
209 refCast<const searchableSurfaces::triSurface>(
s)
229 Info<<
"refinementRegions : Flipped orientation of surface "
231 <<
" so point " << outsidePt <<
" is outside." <<
endl;
239 Foam::scalar Foam::refinementRegions::interpolate
241 const searchableSurfaces::triSurface& tsm,
252 tsm.Foam::triSurface::operator[](index)
253 ).pointToBarycentric(pt)
256 const labelledTri& lf = tsm.localFaces()[index];
258 return closeness[lf[0]]*bary[0]
259 + closeness[lf[1]]*bary[1]
260 + closeness[lf[2]]*bary[2];
264 void Foam::refinementRegions::findHigherLevel
268 const scalar level0EdgeLength,
272 const labelList& levels = levels_[shelli];
274 if (modes_[shelli] == refineMode::distance)
287 label candidatei = 0;
293 if (levels[leveli] > maxLevel[pointi])
295 candidates[candidatei] = pt[pointi];
296 candidateMap[candidatei] = pointi;
297 candidateDistSqr[candidatei] =
sqr(distances[leveli]);
303 candidates.setSize(candidatei);
304 candidateMap.setSize(candidatei);
305 candidateDistSqr.setSize(candidatei);
309 allGeometry_[shells_[shelli]].findNearest
325 mag(
nearInfo[candidatei].hitPoint()-candidates[candidatei])
328 label pointi = candidateMap[candidatei];
331 maxLevel[pointi] = levels[minDistI+1];
337 modes_[shelli] == refineMode::insideSpan
338 || modes_[shelli] == refineMode::outsideSpan
341 const searchableSurfaces::triSurface& tsm =
342 refCast<const searchableSurfaces::triSurface>
343 (allGeometry_[shells_[shelli]]);
351 label candidatei = 0;
355 if (levels[0] > maxLevel[pointi])
357 candidates[candidatei] = pt[pointi];
358 candidateMap[candidatei] = pointi;
359 candidateDistSqr[candidatei] =
sqr(distances_[shelli][0]);
363 candidates.setSize(candidatei);
364 candidateMap.setSize(candidatei);
365 candidateDistSqr.setSize(candidatei);
379 cellsAcrossSpan_[shelli]*level0EdgeLength/(1 << (levels[0] - 1))
402 log2(cellsAcrossSpan_[shelli]*level0EdgeLength/span) + 1
405 maxLevel[candidateMap[candidatei]] =
min(levels[0], level);
409 maxLevel[candidateMap[candidatei]] = levels[0];
423 label candidatei = 0;
427 if (levels[0] > maxLevel[pointi])
429 candidates[candidatei] = pt[pointi];
430 candidateMap[candidatei] = pointi;
434 candidates.setSize(candidatei);
435 candidateMap.setSize(candidatei);
439 allGeometry_[shells_[shelli]].getVolumeType(candidates, volType);
443 label pointi = candidateMap[i];
448 modes_[shelli] == refineMode::inside
452 modes_[shelli] == refineMode::outside
457 maxLevel[pointi] = levels[0];
472 allGeometry_(allGeometry)
480 const word& geomName = allGeometry_.
names()[geomi];
482 if (shellsDict.
found(geomName))
493 cellsAcrossSpan_.
setSize(shelli);
494 closeness_.setSize(shelli);
501 const word& geomName = allGeometry_.
names()[geomi];
510 shells_[shelli] = geomi;
511 modes_[shelli] = refineModeNames_.
read(
dict.lookup(
"mode"));
514 setAndCheckLevels(shelli,
dict);
524 if (isA<searchableSurfaces::triSurface>(surface))
526 dict.lookup(
"cellsAcrossSpan") >> cellsAcrossSpan_[shelli];
543 surface.searchableSurface::time().constant(),
546 surface.searchableSurface::time()
548 surface.searchableSurface::time(),
557 <<
"Surface " << surface.
name()
558 <<
" is not a triSurface as required by"
570 if (unmatchedKeys.
size() > 0)
575 ) <<
"Not all entries in refinementRegions dictionary were used."
576 <<
" The following entries were not used : "
592 label overallMax = 0;
596 overallMax =
max(overallMax,
max(levels_[shelli]));
603 void Foam::refinementRegions::findHigherLevel
607 const scalar level0EdgeLength,
616 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.
refineMode
Volume refinement controls.
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)
mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file mode.
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)