34 void Foam::refinementFeatures::read
36 const objectRegistry& io,
37 const PtrList<dictionary>& featDicts
42 const dictionary&
dict = featDicts[feati];
44 fileName featFileName(
dict.lookup(
"file"));
49 typeIOobject<extendedFeatureEdgeMesh> extFeatObj
53 "extendedFeatureEdgeMesh",
60 const fileName fName(extFeatObj.filePath());
69 Info<<
"Read extendedFeatureEdgeMesh " << extFeatObj.name()
71 eMeshPtr().writeStats(
Info);
74 set(feati,
new extendedFeatureEdgeMesh(extFeatObj, eMeshPtr()));
80 typeIOobject<featureEdgeMesh> featObj
91 const fileName fName(featObj.filePath());
98 ) <<
"Could not open "
99 << featObj.objectPath()
106 const edgeMesh& eMesh = eMeshPtr();
108 Info<<
"Read edgeMesh " << featObj.name() <<
nl
110 eMesh.writeStats(
Info);
118 labelList oldToNew(eMesh.points().size(), -1);
119 DynamicField<point> newPoints(eMesh.points().size());
120 forAll(pointEdges, pointi)
122 if (pointEdges[pointi].
size() > 2)
124 oldToNew[pointi] = newPoints.size();
125 newPoints.append(eMesh.points()[pointi]);
130 label nFeatures = newPoints.size();
133 if (oldToNew[pointi] == -1)
135 oldToNew[pointi] = newPoints.size();
136 newPoints.append(eMesh.points()[pointi]);
141 const edgeList& edges = eMesh.edges();
145 const edge&
e = edges[edgei];
146 newEdges[edgei] = edge
157 extendedEdgeMesh eeMesh
169 List<extendedEdgeMesh::sideVolumeType>(0),
183 set(feati,
new extendedFeatureEdgeMesh(featObj, eeMesh));
186 const extendedEdgeMesh& eMesh =
operator[](feati);
188 if (
dict.found(
"levels"))
190 List<Tuple2<scalar, label>> distLevels(
dict[
"levels"]);
195 <<
" : levels should be at least size 1" <<
endl
196 <<
"levels : " <<
dict[
"levels"]
200 distances_[feati].
setSize(distLevels.size());
201 levels_[feati].
setSize(distLevels.size());
205 distances_[feati][j] = distLevels[j].
first();
206 levels_[feati][j] = distLevels[j].second();
213 (distances_[feati][j] <= distances_[feati][j-1])
214 || (levels_[feati][j] > levels_[feati][j-1])
218 <<
" : Refinement should be specified in order"
219 <<
" of increasing distance"
220 <<
" (and decreasing refinement level)." <<
endl
221 <<
"Distance:" << distances_[feati][j]
222 <<
" refinementLevel:" << levels_[feati][j]
235 Info<<
"Refinement level according to distance to "
236 << featFileName <<
" (" << eMesh.points().size() <<
" points, "
237 << eMesh.edges().size() <<
" edges)." <<
endl;
240 Info<<
" level " << levels_[feati][j]
241 <<
" for all cells within " << distances_[feati][j]
242 <<
" metre." <<
endl;
248 void Foam::refinementFeatures::buildTrees(
const label feati)
250 const extendedEdgeMesh& eMesh = operator[](feati);
252 const edgeList& edges = eMesh.edges();
259 bb = bb.extend(1
e-4);
264 new indexedOctree<treeDataEdge>
286 new indexedOctree<treeDataPoint>
288 treeDataPoint(
points, featurePoints),
299 void Foam::refinementFeatures::findHigherLevel
306 const labelList& levels = levels_[feati];
317 label candidatei = 0;
323 if (levels[leveli] > maxLevel[pointi])
325 candidates[candidatei] = pt[pointi];
326 candidateMap[candidatei] = pointi;
327 candidateDistSqr[candidatei] =
sqr(distances[leveli]);
333 candidates.setSize(candidatei);
334 candidateMap.setSize(candidatei);
335 candidateDistSqr.setSize(candidatei);
338 const indexedOctree<treeDataEdge>& tree = edgeTrees_[feati];
340 List<pointIndexHit>
nearInfo(candidates.size());
341 forAll(candidates, candidatei)
343 nearInfo[candidatei] = tree.findNearest
345 candidates[candidatei],
346 candidateDistSqr[candidatei]
359 mag(
nearInfo[candidatei].hitPoint()-candidates[candidatei])
362 label pointi = candidateMap[candidatei];
365 maxLevel[pointi] = levels[minDistI+1];
376 if (!regionEdgeTreesPtr_.valid())
378 regionEdgeTreesPtr_.reset
417 return regionEdgeTreesPtr_();
430 distances_(featDicts.size()),
431 levels_(featDicts.size()),
432 edgeTrees_(featDicts.size()),
433 pointTrees_(featDicts.size())
538 if (tree.
shapes().size() > 0)
551 distSqr = nearestDistSqr[samplei];
558 nearFeature[samplei] = feati;
568 nearNormal[samplei] =
e.vec(td.
points());
569 nearNormal[samplei] /=
mag(nearNormal[samplei])+vSmall;
597 forAll(regionTrees, feati)
612 distSqr = nearestDistSqr[samplei];
616 pointIndexHit info = regionTree.findNearest(sample, distSqr);
622 nearFeature[samplei] = feati;
631 nearNormal[samplei] =
e.vec(td.
points());
632 nearNormal[samplei] /=
mag(nearNormal[samplei])+vSmall;
705 forAll(pointTrees_, feati)
709 if (tree.
shapes().pointLabels().size() > 0)
716 if (nearFeature[samplei] != -1)
722 distSqr = nearestDistSqr[samplei];
729 nearFeature[samplei] = feati;
743 void Foam::refinementFeatures::findHigherLevel
755 findHigherLevel(pt, feati, maxLevel);
762 scalar overallMax = -great;
765 overallMax =
max(overallMax,
max(distances_[feati]));
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
const Point & hitPoint() const
Return hit point.
label index() const
Return index.
bool hit() const
Is there a hit.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
bool set(const label) const
Is element set.
T & first()
Return the first element of the list.
label size() const
Return the number of elements in the UPtrList.
const T & operator[](const label) const
Return element const reference.
const edgeList & edges() const
Return edges.
static autoPtr< edgeMesh > New(const fileName &, const word &ext)
Select constructed from filename (explicit extension)
const pointField & points() const
Return points.
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 autoPtr< extendedEdgeMesh > New(const fileName &, const word &ext)
Select constructed from filename (explicit extension)
static bool canRead(const fileName &, const bool verbose=false)
Can we read this file format?
Non-pointer based hierarchical recursive searching.
const Type & shapes() const
Reference to shape.
Registry of regIOobjects.
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
refinementFeatures(const objectRegistry &io, const PtrList< dictionary > &featDicts)
Construct from description.
static const word & geometryDir()
Return the geometry directory name.
Standard boundBox + extra functionality for use in octree.
treeBoundBox extend(const scalar s) const
Return asymmetrically extended bounding box, with guaranteed.
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.
Tuple2< scalar, label > nearInfo
Private class for finding nearest.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
Ostream & endl(Ostream &os)
Add newline and flush stream.
label findLower(const ListType &, typename ListType::const_reference, const label stary, const BinaryOp &bop)
Find last element < given value in sorted list and return index,.
vectorField pointField
pointField is a vectorField.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< labelList > labelListList
A List of labelList.
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Field< vector > vectorField
Specialisation of Field<T> for vector.
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
scalarField samples(nIntervals, 0)