Go to the documentation of this file.
38 void Foam::refinementFeatures::read
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()));
100 io.time().constant(),
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);
203 if (
dict.found(
"levels"))
205 List<Tuple2<scalar, label>> distLevels(
dict.lookup(
"levels"));
210 <<
" : levels should be at least size 1" <<
endl
211 <<
"levels : " <<
dict.lookup(
"levels")
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;
286 void Foam::refinementFeatures::buildTrees(
const label featI)
288 const extendedEdgeMesh& eMesh = operator[](featI);
290 const edgeList& edges = eMesh.edges();
307 new indexedOctree<treeDataEdge>
329 new indexedOctree<treeDataPoint>
331 treeDataPoint(
points, featurePoints),
342 void 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]
402 mag(
nearInfo[candidateI].hitPoint()-candidates[candidateI])
405 label pointi = candidateMap[candidateI];
408 maxLevel[pointi] = levels[minDistI+1];
419 if (!regionEdgeTreesPtr_.valid())
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)
602 os <<
" " << em.
name()
603 <<
" bounds differ from " << em2.
name()
604 <<
" by more than a factor 100:" <<
nl
605 <<
" bounding box : " << bb <<
nl
606 <<
" bounding box : " << bb2
621 os <<
" " << em.
name()
622 <<
" bounds not fully contained in mesh"<<
nl
623 <<
" bounding box : " << bb <<
nl
624 <<
" mesh bounding box : " <<
meshBb
652 nearNormal.setSize(
samples.size());
672 distSqr = nearestDistSqr[sampleI];
679 nearFeature[sampleI] = featI;
690 nearNormal[sampleI] =
e.unitVec(td.points());
711 nearNormal.setSize(
samples.size());
718 forAll(regionTrees, featI)
733 distSqr = nearestDistSqr[sampleI];
737 pointIndexHit info = regionTree.findNearest(sample, distSqr);
743 nearFeature[sampleI] = featI;
753 nearNormal[sampleI] =
e.unitVec(td.
points());
826 forAll(pointTrees_, featI)
837 if (nearFeature[sampleI] != -1)
843 distSqr = nearestDistSqr[sampleI];
850 nearFeature[sampleI] = featI;
864 void Foam::refinementFeatures::findHigherLevel
876 findHigherLevel(pt, featI, maxLevel);
883 scalar overallMax = -GREAT;
886 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.
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.
static Vector< Cmpt > uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
static autoPtr< edgeMesh > New(const fileName &name, const word &fileType)
Read construct from filename with given format.
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 (0)
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)
Tuple2< scalar, label > nearInfo
Private class for finding nearest.
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...
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.
static autoPtr< extendedEdgeMesh > New(const fileName &name, const word &fileType)
Select constructed from filename with given file format.
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...
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 bool canRead(const fileName &name, bool verbose=false)
Can we read this file format?