155Foam::searchableSurfaceControl::searchableSurfaceControl
160 const conformationSurfaces& geometryToConformTo,
161 const scalar& defaultCellSize
164 cellSizeAndAlignmentControl
172 surfaceName_(controlFunctionDict.getOrDefault<word>(
"surface",
name)),
173 searchableSurface_(geometryToConformTo.geometry()[surfaceName_]),
174 geometryToConformTo_(geometryToConformTo),
175 cellSizeFunctions_(1),
176 regionToCellSizeFunctions_(searchableSurface_.regions().size(), -1),
182 cellSizeFunctions_.set
185 cellSizeFunction::New
196 PtrList<cellSizeFunction> regionCellSizeFunctions;
198 DynamicList<label> defaultCellSizeRegions;
200 label nRegionCellSizeFunctions = 0;
204 if (controlFunctionDict.found(
"regions"))
206 const dictionary& regionsDict = controlFunctionDict.subDict(
"regions");
207 const wordList& regionNames = searchableSurface_.regions();
209 label nRegions = regionsDict.size();
211 regionCellSizeFunctions.setSize(nRegions);
212 defaultCellSizeRegions.setCapacity(nRegions);
214 forAll(regionNames, regionI)
216 const word& regionName = regionNames[regionI];
218 label regionID = geometryToConformTo_.geometry().findSurfaceRegionID
224 if (regionsDict.found(regionName))
227 const dictionary& regionDict = regionsDict.subDict(regionName);
229 Info<< indent <<
"Region " << regionName
230 <<
" (ID = " << regionID <<
")" <<
" settings:"
234 regionCellSizeFunctions.set
236 nRegionCellSizeFunctions,
237 cellSizeFunction::New
242 labelList(1, regionID)
247 regionToCellSizeFunctions_[regionID] = nRegionCellSizeFunctions;
249 nRegionCellSizeFunctions++;
254 defaultCellSizeRegions.append(regionID);
259 if (defaultCellSizeRegions.empty() && !regionCellSizeFunctions.empty())
261 cellSizeFunctions_.transfer(regionCellSizeFunctions);
263 else if (nRegionCellSizeFunctions > 0)
265 regionCellSizeFunctions.setSize(nRegionCellSizeFunctions + 1);
267 regionCellSizeFunctions.set
269 nRegionCellSizeFunctions,
270 cellSizeFunction::New
283 if (regionToCellSizeFunctions_[regionI] == -1)
285 regionToCellSizeFunctions_[regionI] = nRegionCellSizeFunctions;
289 cellSizeFunctions_.transfer(regionCellSizeFunctions);
297 if (regionToCellSizeFunctions_[regionI] == -1)
299 regionToCellSizeFunctions_[regionI] = 0;
305 forAll(cellSizeFunctions_, funcI)
307 const label funcPriority = cellSizeFunctions_[funcI].priority();
309 if (funcPriority > maxPriority_)
311 maxPriority_ = funcPriority;
316 SortableList<label> functionPriorities(cellSizeFunctions_.size());
318 forAll(cellSizeFunctions_, funcI)
320 functionPriorities[funcI] = cellSizeFunctions_[funcI].priority();
323 functionPriorities.reverseSort();
326 invert(functionPriorities.size(), functionPriorities.indices());
328 cellSizeFunctions_.reorder(invertedFunctionPriorities);
330 Info<<
nl <<
indent <<
"There are " << cellSizeFunctions_.size()
331 <<
" region control functions" <<
endl;
350 pts = searchableSurface_.points();
352 alignments.setSize(
pts.
size());
354 const scalar nearFeatDistSqrCoeff = 1
e-8;
364 geometryToConformTo_.findFeaturePointNearest
367 nearFeatDistSqrCoeff,
372 scalar limitedCellSize = GREAT;
379 geometryToConformTo_.features()[infoFeature];
381 vectorField norms = features.featurePointNormals(info.index());
384 pointAlignment.reset(
new triad());
387 pointAlignment() += norms[nI];
390 pointAlignment().normalize();
391 pointAlignment().orthogonalize();
395 geometryToConformTo_.findEdgeNearest
398 nearFeatDistSqrCoeff,
406 geometryToConformTo_.features()[infoFeature];
408 vectorField norms = features.edgeNormals(info.index());
411 pointAlignment.reset(
new triad());
414 pointAlignment() += norms[nI];
417 pointAlignment().normalize();
418 pointAlignment().orthogonalize();
426 searchableSurface_.findNearest(ptField, distField, infoList);
429 searchableSurface_.getNormal(infoList, normals);
431 if (
mag(normals[0]) < SMALL)
436 pointAlignment.reset(
new triad(normals[0]));
438 if (infoList[0].hit())
443 - 2.0*normals[0]*defaultCellSize_;
446 searchableSurface_.findLineAny
464 if (!cellSize(
pts[pI], sizes[pI], priority))
466 sizes[pI] = defaultCellSize_;
472 sizes[pI] =
min(limitedCellSize, sizes[pI]);
474 alignments[pI] = pointAlignment();
488 const scalar nearFeatDistSqrCoeff = 1
e-8;
504 searchableSurface_.findNearest(ptField, distField, infoList);
506 if (infoList[0].hit())
508 searchableSurface_.getNormal(infoList, normals);
509 searchableSurface_.getRegion(infoList, region);
512 sizeFunctions()[regionToCellSizeFunctions_[region[0]]];
516 sizeFunc.sizeLocations
525 sizes.append(extraSizes);
538 bool anyFunctionFound =
false;
540 forAll(sizeFunctions(), funcI)
544 if (sizeFunc.priority() < priority)
551 if (sizeFunc.cellSize(pt, sizeI))
553 anyFunctionFound =
true;
555 if (sizeFunc.priority() == priority)
557 if (sizeI < cellSize)
566 priority = sizeFunc.priority();
571 Info<<
" sizeI " << sizeI
572 <<
" minSize " << cellSize <<
endl;
577 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.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void append(const T &val)
Append an element at the end of the list.
void setSize(label n)
Alias for resize().
void size(const label n)
Older name for setAddressableSize.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Abstract base class for specifying target cell sizes.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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 class for managing temporary objects.
Representation of a 3D Cartesian coordinate system as a Vector of row vectors.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Namespace for handling debugging switches.
List< word > wordList
List of word.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
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.
vector point
Point is a vector.
Field< triad > triadField
Specialisation of Field<T> for triad.
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
vectorField pointField
pointField is a vectorField.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
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.