43 cellSizeAndAlignmentControl,
44 searchableSurfaceControl,
157 const dictionary& controlFunctionDict,
158 const conformationSurfaces& geometryToConformTo,
159 const scalar& defaultCellSize
162 cellSizeAndAlignmentControl
170 surfaceName_(controlFunctionDict.lookupOrDefault<word>(
"surface", name)),
171 searchableSurface_(geometryToConformTo.geometry()[surfaceName_]),
172 geometryToConformTo_(geometryToConformTo),
173 cellSizeFunctions_(1),
174 regionToCellSizeFunctions_(searchableSurface_.regions().size(), -1),
180 cellSizeFunctions_.set
194 PtrList<cellSizeFunction> regionCellSizeFunctions;
196 DynamicList<label> defaultCellSizeRegions;
198 label nRegionCellSizeFunctions = 0;
202 if (controlFunctionDict.found(
"regions"))
204 const dictionary& regionsDict = controlFunctionDict.subDict(
"regions");
205 const wordList& regionNames = searchableSurface_.regions();
207 label nRegions = regionsDict.size();
209 regionCellSizeFunctions.setSize(nRegions);
210 defaultCellSizeRegions.setCapacity(nRegions);
212 forAll(regionNames, regionI)
214 const word& regionName = regionNames[regionI];
216 label regionID = geometryToConformTo_.geometry().findSurfaceRegionID
222 if (regionsDict.found(regionName))
225 const dictionary& regionDict = regionsDict.subDict(regionName);
228 <<
" (ID = " << regionID <<
")" <<
" settings:" 232 regionCellSizeFunctions.set
234 nRegionCellSizeFunctions,
245 regionToCellSizeFunctions_[regionID] = nRegionCellSizeFunctions;
247 nRegionCellSizeFunctions++;
252 defaultCellSizeRegions.append(regionID);
257 if (defaultCellSizeRegions.empty() && !regionCellSizeFunctions.empty())
259 cellSizeFunctions_.transfer(regionCellSizeFunctions);
261 else if (nRegionCellSizeFunctions > 0)
263 regionCellSizeFunctions.setSize(nRegionCellSizeFunctions + 1);
265 regionCellSizeFunctions.set
267 nRegionCellSizeFunctions,
277 const wordList& regionNames = searchableSurface_.regions();
279 forAll(regionNames, regionI)
281 if (regionToCellSizeFunctions_[regionI] == -1)
283 regionToCellSizeFunctions_[regionI] = nRegionCellSizeFunctions;
287 cellSizeFunctions_.transfer(regionCellSizeFunctions);
291 const wordList& regionNames = searchableSurface_.regions();
293 forAll(regionNames, regionI)
295 if (regionToCellSizeFunctions_[regionI] == -1)
297 regionToCellSizeFunctions_[regionI] = 0;
303 forAll(cellSizeFunctions_, funcI)
305 const label funcPriority = cellSizeFunctions_[funcI].priority();
307 if (funcPriority > maxPriority_)
309 maxPriority_ = funcPriority;
314 SortableList<label> functionPriorities(cellSizeFunctions_.size());
316 forAll(cellSizeFunctions_, funcI)
318 functionPriorities[funcI] = cellSizeFunctions_[funcI].priority();
321 functionPriorities.reverseSort();
324 invert(functionPriorities.size(), functionPriorities.indices());
326 cellSizeFunctions_.reorder(invertedFunctionPriorities);
328 Info<<
nl <<
indent <<
"There are " << cellSizeFunctions_.size()
329 <<
" region control functions" <<
endl;
348 pts = searchableSurface_.points();
349 sizes.setSize(pts.size());
350 alignments.setSize(pts.size());
352 const scalar nearFeatDistSqrCoeff = 1
e-8;
362 geometryToConformTo_.findFeaturePointNearest
365 nearFeatDistSqrCoeff,
370 scalar limitedCellSize = great;
372 autoPtr<triad> pointAlignment;
376 const extendedFeatureEdgeMesh& features =
377 geometryToConformTo_.features()[infoFeature];
379 vectorField norms = features.featurePointNormals(info.index());
382 pointAlignment.set(
new triad());
385 pointAlignment() += norms[nI];
388 pointAlignment().normalise();
389 pointAlignment().orthogonalise();
393 geometryToConformTo_.findEdgeNearest
396 nearFeatDistSqrCoeff,
403 const extendedFeatureEdgeMesh& features =
404 geometryToConformTo_.features()[infoFeature];
406 vectorField norms = features.edgeNormals(info.index());
409 pointAlignment.set(
new triad());
412 pointAlignment() += norms[nI];
415 pointAlignment().normalise();
416 pointAlignment().orthogonalise();
424 searchableSurface_.findNearest(ptField, distField, infoList);
427 searchableSurface_.getNormal(infoList, normals);
429 if (
mag(normals[0]) < small)
431 normals[0] =
vector(1, 1, 1);
434 pointAlignment.set(
new triad(normals[0]));
436 if (infoList[0].hit())
440 infoList[0].hitPoint()
443 List<pointIndexHit> intersectionList;
444 searchableSurface_.findLineAny
463 if (!cellSize(pts[pI], sizes[pI], priority))
471 sizes[pI] =
min(limitedCellSize, sizes[pI]);
473 alignments[pI] = pointAlignment();
480 DynamicList<Foam::point>& pts,
481 DynamicList<scalar>& sizes
484 const tmp<pointField> tmpPoints = searchableSurface_.points();
487 const scalar nearFeatDistSqrCoeff = 1
e-8;
501 ptField[0] = points[pI];
503 searchableSurface_.findNearest(ptField, distField, infoList);
505 if (infoList[0].hit())
507 searchableSurface_.getNormal(infoList, normals);
508 searchableSurface_.getRegion(infoList, region);
510 const cellSizeFunction& sizeFunc =
511 sizeFunctions()[regionToCellSizeFunctions_[region[0]]];
515 sizeFunc.sizeLocations
524 sizes.append(extraSizes);
537 bool anyFunctionFound =
false;
539 forAll(sizeFunctions(), funcI)
541 const cellSizeFunction& sizeFunc = sizeFunctions()[funcI];
543 if (sizeFunc.priority() < priority)
550 if (sizeFunc.cellSize(pt, sizeI))
552 anyFunctionFound =
true;
554 if (sizeFunc.priority() == priority)
556 if (sizeI < cellSize)
565 priority = sizeFunc.priority();
570 Info<<
" sizeI " << sizeI
571 <<
" minSize " << cellSize <<
endl;
576 return anyFunctionFound;
const word & name() const
#define forAll(list, i)
Loop across all elements in list.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & indent(Ostream &os)
Indent stream.
bool cellSize(const Foam::point &pt, scalar &cellSize, label &priority) const
Ostream & endl(Ostream &os)
Add newline and flush stream.
searchableSurfaceControl(const Time &runTime, const word &name, const dictionary &controlFunctionDict, const conformationSurfaces &geometryToConformTo, const scalar &defaultCellSize)
Construct from dictionary and references to conformalVoronoiMesh and.
PointIndexHit< point > pointIndexHit
Vector< scalar > vector
A scalar version of the templated Vector.
Macros for easy insertion into run-time selection tables.
static const Vector< scalar > min
const scalar & defaultCellSize_
vectorField pointField
pointField is a vectorField.
labelList invert(const label len, const labelUList &)
Invert one-to-one map. Unmapped elements will be -1.
virtual void cellSizeFunctionVertices(DynamicList< Foam::point > &pts, DynamicList< scalar > &sizes) const
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void append(const T &)
Append an element at the end of the list.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
List< label > labelList
A List of labels.
virtual void initialVertices(pointField &pts, scalarField &sizes, triadField &alignments) const
Field< triad > triadField
Specialisation of Field<T> for triad.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
List< word > wordList
A List of words.
~searchableSurfaceControl()
Destructor.
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
const doubleScalar e
Elementary charge.
static autoPtr< cellSizeFunction > New(const dictionary &cellSizeFunctionDict, const searchableSurface &surface, const scalar &defaultCellSize, const labelList regionIndices)
Return a reference to the selected cellSizeFunction.
Ostream & incrIndent(Ostream &os)
Increment the indent level.