45 cellSizeAndAlignmentControl,
46 searchableSurfaceControl,
155 Foam::searchableSurfaceControl::searchableSurfaceControl
159 const dictionary& controlFunctionDict,
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
196 PtrList<cellSizeFunction> regionCellSizeFunctions;
198 DynamicList<label> defaultCellSizeRegions;
200 label nRegionCellSizeFunctions = 0;
204 if (controlFunctionDict.found(
"regions"))
206 const dictionary& regionsDict = controlFunctionDict.subDict(
"regions");
209 label nRegions = regionsDict.size();
211 regionCellSizeFunctions.setSize(nRegions);
212 defaultCellSizeRegions.setCapacity(nRegions);
218 label regionID = geometryToConformTo_.geometry().findSurfaceRegionID
230 <<
" (ID = " << regionID <<
")" <<
" settings:" 234 regionCellSizeFunctions.set
236 nRegionCellSizeFunctions,
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,
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;
374 autoPtr<triad> pointAlignment;
378 const extendedFeatureEdgeMesh& features =
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,
405 const extendedFeatureEdgeMesh& features =
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)
433 normals[0] = vector::one;
436 pointAlignment.reset(
new triad(normals[0]));
438 if (infoList[0].hit())
443 - 2.0*normals[0]*defaultCellSize_;
445 List<pointIndexHit> intersectionList;
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();
481 DynamicList<Foam::point>&
pts,
482 DynamicList<scalar>& sizes
485 const tmp<pointField> tmpPoints = searchableSurface_.points();
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);
511 const cellSizeFunction& sizeFunc =
512 sizeFunctions()[regionToCellSizeFunctions_[region[0]]];
516 sizeFunc.sizeLocations
525 sizes.append(extraSizes);
538 bool anyFunctionFound =
false;
540 forAll(sizeFunctions(), funcI)
542 const cellSizeFunction& sizeFunc = 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;
const word & name() const
void size(const label n)
Older name for setAddressableSize.
Ostream & indent(Ostream &os)
Indent stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
bool cellSize(const Foam::point &pt, scalar &cellSize, label &priority) const
void append(const T &val)
Append an element at the end of the list.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
const scalar & defaultCellSize_
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
virtual void cellSizeFunctionVertices(DynamicList< Foam::point > &pts, DynamicList< scalar > &sizes) const
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
virtual void initialVertices(pointField &pts, scalarField &sizes, triadField &alignments) const
Field< triad > triadField
Specialisation of Field<T> for triad.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
List< word > wordList
List of word.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
~searchableSurfaceControl()
Destructor.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< vector > vectorField
Specialisation of Field<T> for vector.
static autoPtr< cellSizeFunction > New(const dictionary &cellSizeFunctionDict, const searchableSurface &surface, const scalar &defaultCellSize, const labelList regionIndices)
Return a reference to the selected cellSizeFunction.
List< label > labelList
A List of labels.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)