Go to the documentation of this file.
37 void Foam::refinementFeatures::read
39 const objectRegistry& io,
40 const PtrList<dictionary>& featDicts
45 const dictionary&
dict = featDicts[featI];
49 meshRefinement::get<fileName>
66 "extendedFeatureEdgeMesh",
73 const fileName fName(typeFilePath<extendedFeatureEdgeMesh>(extFeatObj));
84 Info<<
"Read extendedFeatureEdgeMesh " << extFeatObj.name()
86 eMeshPtr().writeStats(
Info);
90 set(featI,
new extendedFeatureEdgeMesh(extFeatObj, eMeshPtr()));
107 const fileName fName(typeFilePath<featureEdgeMesh>(featObj));
112 <<
"Could not open " << featObj.objectPath()
118 const edgeMesh& eMesh = eMeshPtr();
122 Info<<
"Read edgeMesh " << featObj.name() <<
nl
124 eMesh.writeStats(
Info);
132 labelList oldToNew(eMesh.points().size(), -1);
133 DynamicField<point> newPoints(eMesh.points().size());
134 forAll(pointEdges, pointi)
136 if (pointEdges[pointi].size() > 2)
138 oldToNew[pointi] = newPoints.size();
139 newPoints.append(eMesh.points()[pointi]);
144 label nFeatures = newPoints.size();
147 if (oldToNew[pointi] == -1)
149 oldToNew[pointi] = newPoints.size();
150 newPoints.append(eMesh.points()[pointi]);
155 const edgeList& edges = eMesh.edges();
159 const edge&
e = edges[edgeI];
160 newEdges[edgeI] = edge
171 extendedEdgeMesh eeMesh
183 List<extendedEdgeMesh::sideVolumeType>(0),
197 set(featI,
new extendedFeatureEdgeMesh(featObj, eeMesh));
200 const extendedEdgeMesh& eMesh = operator[](featI);
202 if (
dict.found(
"levels"))
204 List<Tuple2<scalar, label>> distLevels(
dict.lookup(
"levels"));
209 <<
" : levels should be at least size 1" <<
endl
210 <<
"levels : " <<
dict.lookup(
"levels")
214 distances_[featI].
setSize(distLevels.size());
215 levels_[featI].
setSize(distLevels.size());
219 distances_[featI][j] = distLevels[j].first();
220 levels_[featI][j] = distLevels[j].second();
222 if (levels_[featI][j] < 0)
225 <<
"Feature " << featFileName
226 <<
" has illegal refinement level " << levels_[featI][j]
235 (distances_[featI][j] <= distances_[featI][j-1])
236 || (levels_[featI][j] > levels_[featI][j-1])
240 <<
" : Refinement should be specified in order"
241 <<
" of increasing distance"
242 <<
" (and decreasing refinement level)." <<
endl
243 <<
"Distance:" << distances_[featI][j]
244 <<
" refinementLevel:" << levels_[featI][j]
257 meshRefinement::get<label>
271 Info<<
"Refinement level according to distance to "
272 << featFileName <<
" (" << eMesh.points().size() <<
" points, "
273 << eMesh.edges().size() <<
" edges)." <<
endl;
276 Info<<
" level " << levels_[featI][j]
277 <<
" for all cells within " << distances_[featI][j]
278 <<
" metre." <<
endl;
285 void Foam::refinementFeatures::buildTrees(
const label featI)
287 const extendedEdgeMesh& eMesh = operator[](featI);
289 const edgeList& edges = eMesh.edges();
300 bb.min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
301 bb.max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
306 new indexedOctree<treeDataEdge>
328 new indexedOctree<treeDataPoint>
330 treeDataPoint(
points, featurePoints),
341 void Foam::refinementFeatures::findHigherLevel
348 const labelList& levels = levels_[featI];
359 label candidateI = 0;
365 if (levels[levelI] > maxLevel[pointi])
367 candidates[candidateI] = pt[pointi];
368 candidateMap[candidateI] = pointi;
369 candidateDistSqr[candidateI] =
sqr(distances[levelI]);
375 candidates.setSize(candidateI);
376 candidateMap.setSize(candidateI);
377 candidateDistSqr.setSize(candidateI);
380 const indexedOctree<treeDataEdge>& tree = edgeTrees_[featI];
382 List<pointIndexHit>
nearInfo(candidates.size());
383 forAll(candidates, candidateI)
385 nearInfo[candidateI] = tree.findNearest
387 candidates[candidateI],
388 candidateDistSqr[candidateI]
401 mag(
nearInfo[candidateI].hitPoint()-candidates[candidateI])
404 label pointi = candidateMap[candidateI];
407 maxLevel[pointi] = levels[minDistI+1];
418 if (!regionEdgeTreesPtr_.valid())
420 regionEdgeTreesPtr_.reset
441 bb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
442 bb.
max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
465 return *regionEdgeTreesPtr_;
479 distances_(featDicts.size()),
480 levels_(featDicts.size()),
481 edgeTrees_(featDicts.size()),
482 pointTrees_(featDicts.size()),
570 const scalar maxRatio,
578 os<<
"Checking for size." <<
endl;
581 bool hasError =
false;
588 for (
label j = i+1; j < size(); j++)
593 scalar ratio = bb.
mag()/bb2.mag();
595 if (ratio > maxRatio || ratio < 1.0/maxRatio)
601 os <<
" " << em.
name()
602 <<
" bounds differ from " << em2.
name()
603 <<
" by more than a factor 100:" <<
nl
604 <<
" bounding box : " << bb <<
nl
605 <<
" bounding box : " << bb2
620 os <<
" " << em.
name()
621 <<
" bounds not fully contained in mesh"<<
nl
622 <<
" bounding box : " << bb <<
nl
623 <<
" mesh bounding box : " <<
meshBb
651 nearNormal.setSize(
samples.size());
671 distSqr = nearestDistSqr[sampleI];
678 nearFeature[sampleI] = featI;
689 nearNormal[sampleI] =
e.unitVec(td.points());
710 nearNormal.setSize(
samples.size());
717 forAll(regionTrees, featI)
732 distSqr = nearestDistSqr[sampleI];
736 pointIndexHit info = regionTree.findNearest(sample, distSqr);
742 nearFeature[sampleI] = featI;
752 nearNormal[sampleI] =
e.unitVec(td.
points());
825 forAll(pointTrees_, featI)
836 if (nearFeature[sampleI] != -1)
842 distSqr = nearestDistSqr[sampleI];
849 nearFeature[sampleI] = featI;
863 void Foam::refinementFeatures::findHigherLevel
875 findHigherLevel(pt, featI, maxLevel);
882 scalar overallMax = -GREAT;
885 overallMax =
max(overallMax,
max(distances_[featI]));
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
const labelList & pointLabels() const
The original point ids.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
treeBoundBox extend(Random &rndGen, const scalar s) const
Return slightly wider bounding box.
static autoPtr< extendedEdgeMesh > New(const fileName &name, const word &ext)
Select constructed from filename (explicit extension)
Tuple2< scalar, label > nearInfo
Private class for finding nearest.
label index() const
Return index.
scalar mag() const
The magnitude of the bounding box span.
const word & name() const
Return name.
List< edge > edgeList
A List of edges.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
static constexpr const zero Zero
Global zero.
void findNearestPoint(const pointField &samples, const scalarField &nearestDistSqr, labelList &nearFeature, List< pointIndexHit > &nearInfo) const
Find nearest feature point. Sets.
Standard boundBox with extra functionality for use in octree.
bool read(const char *buf, int32_t &val)
Same as readInt32.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
bool hit() const
Is there a hit.
const labelList & regionEdges() const
Return the feature edges which are on the boundary between.
scalar maxDistance() const
Highest distance of all features.
const Type & shapes() const
Reference to shape.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const point & max() const
Maximum describing the bounding box.
List< treeBoundBox > meshBb(1, treeBoundBox(boundBox(coarseMesh.points(), false)).extend(rndGen, 1e-3))
Ostream & incrIndent(Ostream &os)
Increment the indent level.
const point & min() const
Minimum describing the bounding box.
#define forAll(list, i)
Loop across all elements in list.
Field< vector > vectorField
Specialisation of Field<T> for vector.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
bool checkSizes(const scalar maxRatio, const boundBox &meshBb, const bool report, Ostream &os) const
Check sizes - return true if error and stream to os.
Registry of regIOobjects.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
messageStream Info
Information stream (uses stdout - output is on the master only)
const Point & hitPoint() const
Return hit point.
const pointField & points() const
Return points.
const edgeList & edges() const
Non-pointer based hierarchical recursive searching.
Holds data for octree to work on an edges subset.
scalarField samples(nIntervals, Zero)
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
const edgeList & edges() const
Return edges.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
const extendedFeatureEdgeMesh * set(const label i) const
Return const pointer to element (if set) or nullptr.
static const fileName null
An empty fileName.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const pointField & points() const
const PtrList< indexedOctree< treeDataEdge > > & regionEdgeTrees() const
List< labelList > labelListList
A List of labelList.
Description of feature edges and points.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
void findNearestRegionEdge(const pointField &samples, const scalarField &nearestDistSqr, labelList &nearFeature, List< pointIndexHit > &nearInfo, vectorField &nearNormal) const
Find nearest point on nearest region edge. Sets.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const dimensionedScalar e
Elementary charge.
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
const labelList & edgeLabels() const
A bounding box defined in terms of min/max extrema points.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
refinementFeatures(const objectRegistry &io, const PtrList< dictionary > &featDicts, const bool dryRun=false)
Construct from description.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
vector point
Point is a vector.
void setSize(const label newSize)
Alias for resize(const label)
void findNearestEdge(const pointField &samples, const scalarField &nearestDistSqr, labelList &nearFeature, List< pointIndexHit > &nearInfo, vectorField &nearNormal) const
Find nearest point on nearest feature edge. Sets.
static autoPtr< edgeMesh > New(const fileName &name, const word &ext)
Select constructed from filename (explicit extension)
static bool canRead(const fileName &name, bool verbose=false)
Can we read this file format?