40 const objectRegistry&
io,
41 const PtrList<dictionary>& featDicts
46 const dictionary&
dict = featDicts[featI];
50 meshRefinement::get<fileName>
67 "extendedFeatureEdgeMesh",
74 const fileName fName(typeFilePath<extendedFeatureEdgeMesh>(extFeatObj));
85 Info<<
"Read extendedFeatureEdgeMesh " << extFeatObj.name()
87 eMeshPtr().writeStats(
Info);
91 set(featI,
new extendedFeatureEdgeMesh(extFeatObj, eMeshPtr()));
108 const fileName fName(typeFilePath<featureEdgeMesh>(featObj));
113 <<
"Could not open " << featObj.objectPath()
119 const edgeMesh& eMesh = eMeshPtr();
123 Info<<
"Read edgeMesh " << featObj.name() <<
nl
125 eMesh.writeStats(
Info);
133 labelList oldToNew(eMesh.points().size(), -1);
134 DynamicField<point> newPoints(eMesh.points().size());
135 forAll(pointEdges, pointi)
137 if (pointEdges[pointi].
size() > 2)
139 oldToNew[pointi] = newPoints.size();
140 newPoints.append(eMesh.points()[pointi]);
145 label nFeatures = newPoints.size();
148 if (oldToNew[pointi] == -1)
150 oldToNew[pointi] = newPoints.size();
151 newPoints.append(eMesh.points()[pointi]);
156 const edgeList& edges = eMesh.edges();
160 const edge&
e = edges[edgeI];
161 newEdges[edgeI] = edge
172 extendedEdgeMesh eeMesh
184 List<extendedEdgeMesh::sideVolumeType>(0),
198 set(featI,
new extendedFeatureEdgeMesh(featObj, eeMesh));
201 const extendedEdgeMesh& eMesh =
operator[](featI);
205 List<Tuple2<scalar, label>> distLevels(
dict.
lookup(
"levels"));
210 <<
" : levels should be at least size 1" <<
endl
215 distances_[featI].
setSize(distLevels.size());
216 levels_[featI].
setSize(distLevels.size());
220 distances_[featI][j] = distLevels[j].
first();
221 levels_[featI][j] = distLevels[j].second();
223 if (levels_[featI][j] < 0)
226 <<
"Feature " << featFileName
227 <<
" has illegal refinement level " << levels_[featI][j]
236 (distances_[featI][j] <= distances_[featI][j-1])
237 || (levels_[featI][j] > levels_[featI][j-1])
241 <<
" : Refinement should be specified in order"
242 <<
" of increasing distance"
243 <<
" (and decreasing refinement level)." <<
endl
244 <<
"Distance:" << distances_[featI][j]
245 <<
" refinementLevel:" << levels_[featI][j]
258 meshRefinement::get<label>
272 Info<<
"Refinement level according to distance to "
273 << featFileName <<
" (" << eMesh.points().size() <<
" points, "
274 << eMesh.edges().size() <<
" edges)." <<
endl;
277 Info<<
" level " << levels_[featI][j]
278 <<
" for all cells within " << distances_[featI][j]
279 <<
" metre." <<
endl;
286void Foam::refinementFeatures::buildTrees(
const label featI)
288 const extendedEdgeMesh& eMesh = operator[](featI);
290 const edgeList& edges = eMesh.edges();
301 bb.min() -= point::uniform(ROOTVSMALL);
302 bb.max() += point::uniform(ROOTVSMALL);
307 new indexedOctree<treeDataEdge>
329 new indexedOctree<treeDataPoint>
331 treeDataPoint(
points, featurePoints),
342void Foam::refinementFeatures::findHigherLevel
349 const labelList& levels = levels_[featI];
360 label candidateI = 0;
366 if (levels[levelI] > maxLevel[pointi])
368 candidates[candidateI] = pt[pointi];
369 candidateMap[candidateI] = pointi;
370 candidateDistSqr[candidateI] =
sqr(distances[levelI]);
376 candidates.setSize(candidateI);
377 candidateMap.setSize(candidateI);
378 candidateDistSqr.setSize(candidateI);
381 const indexedOctree<treeDataEdge>& tree = edgeTrees_[featI];
383 List<pointIndexHit> nearInfo(candidates.size());
384 forAll(candidates, candidateI)
386 nearInfo[candidateI] = tree.findNearest
388 candidates[candidateI],
389 candidateDistSqr[candidateI]
394 forAll(nearInfo, candidateI)
396 if (nearInfo[candidateI].hit())
402 mag(nearInfo[candidateI].hitPoint()-candidates[candidateI])
405 label pointi = candidateMap[candidateI];
408 maxLevel[pointi] = levels[minDistI+1];
419 if (!regionEdgeTreesPtr_)
421 regionEdgeTreesPtr_.reset
466 return *regionEdgeTreesPtr_;
480 distances_(featDicts.size()),
481 levels_(featDicts.size()),
482 edgeTrees_(featDicts.size()),
483 pointTrees_(featDicts.size()),
571 const scalar maxRatio,
579 os<<
"Checking for size." <<
endl;
582 bool hasError =
false;
589 for (label j = i+1; j < size(); j++)
594 scalar ratio = bb.
mag()/bb2.
mag();
596 if (ratio > maxRatio || ratio < 1.0/maxRatio)
603 <<
" bounds differ from " << em2.
name()
604 <<
" by more than a factor 100:" <<
nl
605 <<
" bounding box : " << bb <<
nl
606 <<
" bounding box : " << bb2
622 <<
" bounds not fully contained in mesh"<<
nl
623 <<
" bounding box : " << bb <<
nl
624 <<
" mesh bounding box : " <<
meshBb
659 if (tree.
shapes().size() > 0)
666 if (nearInfo[sampleI].hit())
672 distSqr = nearestDistSqr[sampleI];
679 nearFeature[sampleI] = featI;
688 const edge&
e = td.
edges()[nearInfo[sampleI].index()];
690 nearNormal[sampleI] =
e.unitVec(td.
points());
718 forAll(regionTrees, featI)
727 if (nearInfo[sampleI].hit())
733 distSqr = nearestDistSqr[sampleI];
743 nearFeature[sampleI] = featI;
751 const edge&
e = td.
edges()[nearInfo[sampleI].index()];
753 nearNormal[sampleI] =
e.unitVec(td.
points());
826 forAll(pointTrees_, featI)
830 if (tree.
shapes().pointLabels().size() > 0)
837 if (nearFeature[sampleI] != -1)
843 distSqr = nearestDistSqr[sampleI];
850 nearFeature[sampleI] = featI;
864void Foam::refinementFeatures::findHigherLevel
876 findHigherLevel(pt, featI, maxLevel);
883 scalar overallMax = -GREAT;
886 overallMax =
max(overallMax,
max(distances_[featI]));
Minimal example by using system/controlDict.functions:
const word & name() const noexcept
Return the object name.
const Time & time() const
Return Time associated with the objectRegistry.
void setSize(const label n)
Alias for resize()
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
label index() const noexcept
Return the hit index.
bool hit() const noexcept
Is there a hit?
const point_type & hitPoint() const
Return hit point. Fatal if not hit.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const extendedFeatureEdgeMesh * set(const label i) const
virtual bool read()
Re-read model coefficients if they have changed.
const word & constant() const
Return constant name.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
T & first()
Return the first element of the list.
void size(const label n)
Older name for setAddressableSize.
const T & operator[](const label i) const
Return const reference to the element.
label size() const noexcept
The number of elements in the list.
A bounding box defined in terms of min/max extrema points.
const point & min() const
Minimum describing the bounding box.
const point & max() const
Maximum describing the bounding box.
scalar mag() const
The magnitude of the bounding box span.
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
const pointField & points() const noexcept
Return points.
const edgeList & edges() const noexcept
Return edges.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Description of feature edges and points.
const labelList & regionEdges() const
Return the feature edges which are on the boundary between.
static bool canRead(const fileName &name, bool verbose=false)
Can we read this file format?
static const fileName null
An empty fileName.
void checkSizes() const
Check that all components of sizes() are non-negative.
Non-pointer based hierarchical recursive searching.
const Type & shapes() const
Reference to shape.
@ REGEX
Regular expression.
Registry of regIOobjects.
Encapsulates queries for features.
void findNearestPoint(const pointField &samples, const scalarField &nearestDistSqr, labelList &nearFeature, List< pointIndexHit > &nearInfo) const
Find nearest feature point. Sets.
scalar maxDistance() const
Highest distance of all features.
void findNearestRegionEdge(const pointField &samples, const scalarField &nearestDistSqr, labelList &nearFeature, List< pointIndexHit > &nearInfo, vectorField &nearNormal) const
Find nearest point on nearest region edge. Sets.
void findNearestEdge(const pointField &samples, const scalarField &nearestDistSqr, labelList &nearFeature, List< pointIndexHit > &nearInfo, vectorField &nearNormal) const
Find nearest point on nearest feature edge. Sets.
const PtrList< indexedOctree< treeDataEdge > > & regionEdgeTrees() const
Standard boundBox with extra functionality for use in octree.
treeBoundBox extend(Random &rndGen, const scalar s) const
Return slightly wider bounding box.
Holds data for octree to work on an edges subset.
const edgeList & edges() const
const pointField & points() const
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
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.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
List< labelList > labelListList
A List of labelList.
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0)
List< edge > edgeList
A List of edges.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a)
List< treeBoundBox > meshBb(1, treeBoundBox(boundBox(coarseMesh.points(), false)).extend(rndGen, 1e-3))
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
scalarField samples(nIntervals, Zero)