48bool Foam::searchableSurfaces::connected
52 const pointIndexHit& hit
55 const edge&
e =
s.edges()[edgeI];
57 const edge meshE(mp[
e[0]], mp[
e[1]]);
63 if (meshE.otherVertex(
f[i]) != -1)
72 vector eVec(meshE.vec(
s.points()));
73 scalar magEVec(
mag(eVec));
74 if (magEVec > ROOTVSMALL)
77 scalar magArea(
mag(
n));
78 if (magArea > ROOTVSMALL)
81 if (
mag(
n&(eVec/magEVec)) < SMALL)
99Foam::searchableSurfaces::searchableSurfaces(
const label size)
197Foam::searchableSurfaces::searchableSurfaces
201 const bool singleRegionName
205 names_(topDict.
size()),
206 regionNames_(topDict.
size()),
211 for (
const entry& dEntry : topDict)
213 if (!dEntry.isDict())
216 <<
"Found non-dictionary entry " << dEntry
217 <<
" in top-level dictionary " << topDict
221 const word& key = dEntry.keyword();
224 names_[surfI] =
dict.getOrDefault<
word>(
"name", key);
233 namedIO().rename(key);
250 const wordList& localNames =
s.regions();
252 wordList& rNames = regionNames_[surfI];
255 if (singleRegionName && localNames.
size() == 1)
257 rNames[0] = names_[surfI];
261 forAll(localNames, regionI)
263 rNames[regionI] = names_[surfI] +
'_' + localNames[regionI];
268 if (
dict.found(
"regions"))
270 const dictionary& regionsDict = dict.subDict(
"regions");
272 for (const entry& dEntry : regionsDict)
276 const word& key = dEntry.keyword();
277 const dictionary& regionDict = dEntry.dict();
279 label index = localNames.find(key);
284 <<
"Unknown region name " << key
285 <<
" for surface " << s.name() << nl
286 <<
"Valid region names are " << localNames
291 rNames[index] = regionDict.get<word>(
"name");
301 names_.setSize(surfI);
302 regionNames_.setSize(surfI);
303 allSurfaces_.setSize(surfI);
314 return names_.find(wantedName);
320 const word& surfaceName,
454 Info<<
"Checking for closedness." <<
endl;
457 bool hasError =
false;
461 if (!
operator[](surfI).hasVolumeType())
468 <<
" : not closed" <<
endl;
479 label nSingleEdges = 0;
482 if (edgeFaces[edgeI].size() == 1)
488 label nMultEdges = 0;
491 if (edgeFaces[edgeI].size() > 2)
497 if (report && (nSingleEdges != 0 || nMultEdges != 0))
499 Info<<
" connected to one face : "
500 << nSingleEdges <<
nl
501 <<
" connected to >2 faces : "
502 << nMultEdges <<
endl;
521 Info<<
"Checking for normal orientation." <<
endl;
524 bool hasError =
false;
547 <<
" : has multiple orientation zones ("
548 << nZones <<
")" <<
endl;
565 const scalar maxRatio,
571 Info<<
"Checking for size." <<
endl;
574 bool hasError =
false;
578 const boundBox& bb = operator[](i).bounds();
580 for (label j = i+1; j < size(); j++)
582 scalar ratio = bb.mag()/operator[](j).bounds().mag();
584 if (ratio > maxRatio || ratio < 1.0/maxRatio)
591 <<
" bounds differ from " <<
names()[j]
592 <<
" by more than a factor 100:" <<
nl
593 <<
" bounding box : " << bb <<
nl
594 <<
" bounding box : " << operator[](j).bounds()
613 const scalar tolerance,
614 autoPtr<coordSetWriter>& setWriter,
620 Info<<
"Checking for intersection." <<
endl;
625 bool hasError =
false;
635 const edgeList& edges0 = s0.edges();
636 const pointField& localPoints0 = s0.localPoints();
643 const edge&
e = edges0[edgeI];
644 start[edgeI] = localPoints0[
e[0]];
645 end[edgeI] = localPoints0[
e[1]];
668 operator[](j).findLineAny(start, end, hits);
679 && (i != j || !connected(s0, edgeI, hits[edgeI]))
682 intersections.append(hits[edgeI].
point());
683 intersectionEdge.append(edgeI);
696 <<
" intersects " <<
names()[j]
701 if (setWriter && setWriter->enabled())
708 std::move(intersections),
713 auto&
writer = *setWriter;
720 s0.searchableSurface::time().path()
721 / (track.name() +
"_edgeIndex")
730 Info<<
" Wrote intersection locations to "
753 const scalar minQuality,
759 Info<<
"Checking for triangle quality." <<
endl;
762 bool hasError =
false;
798 <<
" : has " << nBadTris <<
" bad quality triangles "
799 <<
" (quality < " << minQuality <<
")" <<
endl;
821 label noFailedChecks = 0;
823 if (checkClosed(report))
828 if (checkNormalOrientation(report))
832 return noFailedChecks;
838 const scalar maxRatio,
840 autoPtr<coordSetWriter>& setWriter,
841 const scalar minQuality,
845 label noFailedChecks = 0;
847 if (maxRatio > 0 && checkSizes(maxRatio, report))
852 if (checkIntersection(tol, setWriter, report))
857 if (checkQuality(minQuality, report))
862 return noFailedChecks;
877 const searchableSurface&
s = operator[](surfI);
879 Info<<
" type : " <<
s.type() <<
nl
880 <<
" size : " <<
s.globalSize() <<
nl;
883 const triSurfaceMesh& ts =
dynamic_cast<const triSurfaceMesh&
>(
s);
884 Info<<
" edges : " << ts.nEdges() <<
nl
885 <<
" points : " << ts.points()().size() <<
nl;
887 Info<<
" bounds : " <<
s.bounds() <<
nl
888 <<
" closed : " <<
Switch(
s.hasVolumeType()) <<
endl;
893 Info<<
" patches : ";
897 if (i < unique.size()-1)
916 const label surfI = findSurfaceID(surfName);
921 <<
"Surface named " << surfName <<
" not found." <<
nl
922 <<
"Available surface names: " << names_ <<
endl
926 return operator[](surfI);
935 const label surfI = findSurfaceID(surfName);
940 <<
"Surface named " << surfName <<
" not found." <<
nl
941 <<
"Available surface names: " << names_ <<
endl
945 return operator[](surfI);
Various functions to operate on Lists.
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edgesCentres")))
Dynamically sized Field. Similar to DynamicList, but inheriting from a Field instead of a List.
void append(const T &val)
Append an element at the end of the list.
label capacity() const noexcept
Size of the underlying storage.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
fileName path() const
The complete path for the object (with instance, local,...).
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(label n)
Alias for resize().
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
label nEdges() const
Number of edges in patch.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const searchableSurface * set(const label i) const
void setSize(const label n)
Same as resize().
constexpr PtrList() noexcept
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bounding box defined in terms of min/max extrema points.
scalar mag() const
The magnitude/length of the bounding box diagonal.
Holds list of sampling positions.
const word & name() const noexcept
The coord-set name.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
A keyword and a list of tokens is an 'entry'.
A class for handling file names.
A triFace with additional (region) index.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
static autoPtr< searchableSurface > New(const word &surfaceType, const IOobject &io, const dictionary &dict)
Return a reference to the selected searchableSurface.
static void findNearestIntersection(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &surface2, List< pointIndexHit > &hit2)
Find intersections of edge nearest to both endpoints.
static void findAnyIntersection(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &)
Find any intersection. Return hit point information and.
static void findAllIntersections(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &start, const pointField &end, labelListList &surfaces, List< List< pointIndexHit > > &surfaceHits)
Find all intersections in order from start to end. Returns for.
static void findNearest(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &)
Find nearest. Return -1 (and a miss()) or surface and nearest.
static boundBox bounds(const PtrList< searchableSurface > &allSurfaces, const labelUList &surfacesToTest)
Find the boundBox of the selected surfaces.
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
bool checkQuality(const scalar minQuality, const bool report) const
Check triangle quality.
bool checkIntersection(const scalar tol, autoPtr< coordSetWriter > &setWriter, const bool report) const
Do surfaces self-intersect or intersect others.
boundBox bounds() const
Calculate bounding box.
label findSurfaceRegionID(const word &surfaceName, const word ®ionName) const
bool checkClosed(const bool report) const
Are all surfaces closed and manifold.
bool checkSizes(const scalar maxRatio, const bool report) const
Are all bounding boxes of similar size.
const searchableSurface & operator[](const word &) const
Return const reference to searchableSurface by name.
void findAllIntersections(const pointField &start, const pointField &end, labelListList &surfaces, List< List< pointIndexHit > > &) const
Find all intersections in order from start to end. Returns for.
label checkTopology(const bool report) const
All topological checks. Return number of failed checks.
label checkGeometry(const scalar maxRatio, const scalar tolerance, autoPtr< coordSetWriter > &setWriter, const scalar minQuality, const bool report) const
All geometric checks. Return number of failed checks.
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Find any intersection. Return hit point information and.
void writeStats(const List< wordList > &, Ostream &) const
Write some stats.
bool checkNormalOrientation(const bool report) const
Are all (triangulated) surfaces consistent normal orientation.
void findNearest(const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest. Return -1 (and a miss()) or surface and nearest.
label findSurfaceID(const word &name) const
Find index of surface. Return -1 if not found.
void findNearestIntersection(const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &surface2, List< pointIndexHit > &hit2) const
IOoject and searching on triSurface.
virtual tmp< pointField > points() const
Get the points that define the surface.
Triangulated surface description with patch information.
scalar quality() const
Return quality: Ratio of triangle and circum-circle.
void close()
End the file contents and close the file after writing.
virtual bool open(const fileName &file, bool parallel=UPstream::parRun())
Open file for writing (creates parent directory).
void write(const word &fieldName, const UList< Type > &field)
Write primitive field of CellData (Poly or Line) or PointData values.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
List< label > sortedToc(const UList< bool > &bools)
Return the (sorted) values corresponding to 'true' entries.
List< edge > edgeList
List of edge.
List< word > wordList
List of word.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
errorManip< error > abort(error &err)
vector point
Point is a vector.
triangle< point, const point & > triPointRef
A triangle using referred points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
wordList patchTypes(nPatches)
#define forAll(list, i)
Loop across all elements in list.
scalarField samples(nIntervals, Zero)