46 cellSizeAndAlignmentControl,
47 searchableSurfaceControl,
160 const dictionary& controlFunctionDict,
161 const conformationSurfaces& geometryToConformTo,
162 const scalar& defaultCellSize
165 cellSizeAndAlignmentControl
173 surfaceName_(controlFunctionDict.getOrDefault<word>(
"surface",
name)),
174 searchableSurface_(geometryToConformTo.geometry()[surfaceName_]),
175 geometryToConformTo_(geometryToConformTo),
176 cellSizeFunctions_(1),
177 regionToCellSizeFunctions_(searchableSurface_.regions().size(), -1),
183 cellSizeFunctions_.set
186 cellSizeFunction::New
197 PtrList<cellSizeFunction> regionCellSizeFunctions;
199 DynamicList<label> defaultCellSizeRegions;
201 label nRegionCellSizeFunctions = 0;
205 if (controlFunctionDict.found(
"regions"))
207 const dictionary& regionsDict = controlFunctionDict.subDict(
"regions");
210 label nRegions = regionsDict.size();
212 regionCellSizeFunctions.setSize(nRegions);
213 defaultCellSizeRegions.setCapacity(nRegions);
219 label regionID = geometryToConformTo_.geometry().findSurfaceRegionID
228 const dictionary& regionDict = regionsDict.subDict(
regionName);
231 <<
" (ID = " << regionID <<
")" <<
" settings:"
235 regionCellSizeFunctions.set
237 nRegionCellSizeFunctions,
238 cellSizeFunction::New
248 regionToCellSizeFunctions_[regionID] = nRegionCellSizeFunctions;
250 nRegionCellSizeFunctions++;
255 defaultCellSizeRegions.append(regionID);
260 if (defaultCellSizeRegions.empty() && !regionCellSizeFunctions.empty())
262 cellSizeFunctions_.transfer(regionCellSizeFunctions);
264 else if (nRegionCellSizeFunctions > 0)
266 regionCellSizeFunctions.setSize(nRegionCellSizeFunctions + 1);
268 regionCellSizeFunctions.set
270 nRegionCellSizeFunctions,
271 cellSizeFunction::New
284 if (regionToCellSizeFunctions_[regionI] == -1)
286 regionToCellSizeFunctions_[regionI] = nRegionCellSizeFunctions;
290 cellSizeFunctions_.transfer(regionCellSizeFunctions);
298 if (regionToCellSizeFunctions_[regionI] == -1)
300 regionToCellSizeFunctions_[regionI] = 0;
306 forAll(cellSizeFunctions_, funcI)
308 const label funcPriority = cellSizeFunctions_[funcI].priority();
310 if (funcPriority > maxPriority_)
312 maxPriority_ = funcPriority;
317 SortableList<label> functionPriorities(cellSizeFunctions_.size());
319 forAll(cellSizeFunctions_, funcI)
321 functionPriorities[funcI] = cellSizeFunctions_[funcI].priority();
324 functionPriorities.reverseSort();
327 invert(functionPriorities.size(), functionPriorities.indices());
329 cellSizeFunctions_.reorder(invertedFunctionPriorities);
331 Info<<
nl <<
indent <<
"There are " << cellSizeFunctions_.size()
332 <<
" region control functions" <<
endl;
351 pts = searchableSurface_.points();
352 sizes.setSize(pts.size());
353 alignments.setSize(pts.size());
355 const scalar nearFeatDistSqrCoeff = 1
e-8;
365 geometryToConformTo_.findFeaturePointNearest
368 nearFeatDistSqrCoeff,
373 scalar limitedCellSize = GREAT;
375 autoPtr<triad> pointAlignment;
379 const extendedFeatureEdgeMesh& features =
380 geometryToConformTo_.features()[infoFeature];
382 vectorField norms = features.featurePointNormals(info.index());
385 pointAlignment.reset(
new triad());
388 pointAlignment() += norms[nI];
391 pointAlignment().normalize();
392 pointAlignment().orthogonalize();
396 geometryToConformTo_.findEdgeNearest
399 nearFeatDistSqrCoeff,
406 const extendedFeatureEdgeMesh& features =
407 geometryToConformTo_.features()[infoFeature];
409 vectorField norms = features.edgeNormals(info.index());
412 pointAlignment.reset(
new triad());
415 pointAlignment() += norms[nI];
418 pointAlignment().normalize();
419 pointAlignment().orthogonalize();
427 searchableSurface_.findNearest(ptField, distField, infoList);
430 searchableSurface_.getNormal(infoList, normals);
432 if (
mag(normals[0]) < SMALL)
434 normals[0] = vector::one;
437 pointAlignment.reset(
new triad(normals[0]));
439 if (infoList[0].hit())
443 infoList[0].hitPoint()
444 - 2.0*normals[0]*defaultCellSize_;
446 List<pointIndexHit> intersectionList;
447 searchableSurface_.findLineAny
466 if (!cellSize(pts[pI], sizes[pI], priority))
468 sizes[pI] = defaultCellSize_;
474 sizes[pI] =
min(limitedCellSize, sizes[pI]);
476 alignments[pI] = pointAlignment();
483 DynamicList<Foam::point>& pts,
484 DynamicList<scalar>& sizes
487 const tmp<pointField> tmpPoints = searchableSurface_.points();
490 const scalar nearFeatDistSqrCoeff = 1
e-8;
506 searchableSurface_.findNearest(ptField, distField, infoList);
508 if (infoList[0].hit())
510 searchableSurface_.getNormal(infoList, normals);
511 searchableSurface_.getRegion(infoList, region);
513 const cellSizeFunction& sizeFunc =
514 sizeFunctions()[regionToCellSizeFunctions_[region[0]]];
518 sizeFunc.sizeLocations
527 sizes.append(extraSizes);
540 bool anyFunctionFound =
false;
542 forAll(sizeFunctions(), funcI)
544 const cellSizeFunction& sizeFunc = sizeFunctions()[funcI];
546 if (sizeFunc.priority() < priority)
553 if (sizeFunc.cellSize(pt, sizeI))
555 anyFunctionFound =
true;
557 if (sizeFunc.priority() == priority)
559 if (sizeI < cellSize)
568 priority = sizeFunc.priority();
573 Info<<
" sizeI " << sizeI
574 <<
" minSize " << cellSize <<
endl;
579 return anyFunctionFound;
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
void append(const T &val)
Append an element at the end of the list.
static const complex min
complex (-VGREAT,-VGREAT)
virtual void cellSizeFunctionVertices(DynamicList< Foam::point > &pts, DynamicList< scalar > &sizes) const
~searchableSurfaceControl()
Destructor.
bool cellSize(const Foam::point &pt, scalar &cellSize, label &priority) const
virtual void initialVertices(pointField &pts, scalarField &sizes, triadField &alignments) const
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Foam::word regionName(Foam::polyMesh::defaultRegion)
List< word > wordList
A List of words.
List< label > labelList
A List of labels.
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
Field< triad > triadField
Specialisation of Field<T> for triad.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & indent(Ostream &os)
Indent stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Field< vector > vectorField
Specialisation of Field<T> for vector.
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.