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();
255 treeBoundBox bb(points);
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]
351 forAll(nearInfo, candidatei)
353 if (nearInfo[candidatei].hit())
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)
542 const point& sample = samples[samplei];
545 if (nearInfo[samplei].hit())
547 distSqr =
magSqr(nearInfo[samplei].hitPoint()-sample);
551 distSqr = nearestDistSqr[samplei];
558 nearFeature[samplei] = feati;
567 const edge&
e = td.edges()[nearInfo[samplei].index()];
568 nearNormal[samplei] = e.
vec(td.points());
569 nearNormal[samplei] /=
mag(nearNormal[samplei])+vSmall;
597 forAll(regionTrees, feati)
603 const point& sample = samples[samplei];
606 if (nearInfo[samplei].hit())
608 distSqr =
magSqr(nearInfo[samplei].hitPoint()-sample);
612 distSqr = nearestDistSqr[samplei];
616 pointIndexHit info = regionTree.findNearest(sample, distSqr);
622 nearFeature[samplei] = feati;
630 const edge&
e = td.
edges()[nearInfo[samplei].index()];
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)
713 const point& sample = samples[samplei];
716 if (nearFeature[samplei] != -1)
718 distSqr =
magSqr(nearInfo[samplei].hitPoint()-sample);
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]));
List< labelList > labelListList
A List of labelList.
static autoPtr< extendedEdgeMesh > New(const fileName &, const word &ext)
Select constructed from filename (explicit extension)
#define forAll(list, i)
Loop across all elements in list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const pointField & points() const
bool set(const label) const
Is element set.
errorManipArg< error, int > exit(error &err, const int errNo=1)
refinementFeatures(const objectRegistry &io, const PtrList< dictionary > &featDicts)
Construct from description.
scalar maxDistance() const
Highest distance of all features.
void findNearestPoint(const pointField &samples, const scalarField &nearestDistSqr, labelList &nearFeature, List< pointIndexHit > &nearInfo) const
Find nearest feature point. Sets:
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static autoPtr< edgeMesh > New(const fileName &, const word &ext)
Select constructed from filename (explicit extension)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void size(const label)
Override size to be inconsistent with allocated storage.
Description of feature edges and points.
const T & operator[](const label) const
Return element const reference.
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
Holds data for octree to work on an edges subset.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Tuple2< scalar, label > nearInfo
Private class for finding nearest.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
PointIndexHit< point > pointIndexHit
const labelList & regionEdges() const
Return the feature edges which are on the boundary between.
T & first()
Return the first element of the list.
const Point & hitPoint() const
Return hit point.
vectorField pointField
pointField is a vectorField.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
static const word & geometryDir()
Return the geometry directory name.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const edgeList & edges() const
Return edges.
bool hit() const
Is there a hit.
const Type & shapes() const
Reference to shape.
List< label > labelList
A List of labels.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
vector vec(const pointField &) const
Return the vector (end - start)
const pointField & points() const
Return points.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
label size() const
Return the number of elements in the UPtrList.
void setSize(const label)
Reset size of List.
void findNearestRegionEdge(const pointField &samples, const scalarField &nearestDistSqr, labelList &nearFeature, List< pointIndexHit > &nearInfo, vectorField &nearNormal) const
Find nearest point on nearest region edge. Sets:
const edgeList & edges() const
Non-pointer based hierarchical recursive searching.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
static bool canRead(const fileName &, const bool verbose=false)
Can we read this file format?
const PtrList< indexedOctree< treeDataEdge > > & regionEdgeTrees() const
void findNearestEdge(const pointField &samples, const scalarField &nearestDistSqr, labelList &nearFeature, List< pointIndexHit > &nearInfo, vectorField &nearNormal) const
Find nearest point on nearest feature edge. Sets:
Standard boundBox + extra functionality for use in octree.
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,.
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
const doubleScalar e
Elementary charge.
Registry of regIOobjects.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
label index() const
Return index.
treeBoundBox extend(const scalar s) const
Return asymetrically extended bounding box, with guaranteed.