Go to the documentation of this file.
47 bool Foam::searchableSurfaces::connected
54 const edge&
e =
s.edges()[edgeI];
56 const edge meshE(
mp[
e[0]],
mp[
e[1]]);
62 if (meshE.otherVertex(
f[i]) != -1)
71 vector eVec(meshE.vec(
s.points()));
72 scalar magEVec(
mag(eVec));
73 if (magEVec > ROOTVSMALL)
76 scalar magArea(
mag(
n));
77 if (magArea > ROOTVSMALL)
80 if (
mag(
n&(eVec/magEVec)) < SMALL)
98 Foam::searchableSurfaces::searchableSurfaces(
const label size)
196 Foam::searchableSurfaces::searchableSurfaces
200 const bool singleRegionName
204 names_(topDict.size()),
205 regionNames_(topDict.size()),
206 allSurfaces_(
identity(topDict.size()))
210 for (
const entry& dEntry : topDict)
212 if (!dEntry.isDict())
215 <<
"Found non-dictionary entry " << dEntry
216 <<
" in top-level dictionary " << topDict
220 const word&
key = dEntry.keyword();
232 namedIO().rename(
key);
249 const wordList& localNames =
s.regions();
251 wordList& rNames = regionNames_[surfI];
252 rNames.
setSize(localNames.size());
254 if (singleRegionName && localNames.size() == 1)
256 rNames[0] = names_[surfI];
260 forAll(localNames, regionI)
262 rNames[regionI] = names_[surfI] +
'_' + localNames[regionI];
271 for (
const entry& dEntry : regionsDict)
275 const word&
key = dEntry.keyword();
278 label index = localNames.find(
key);
283 <<
"Unknown region name " <<
key
284 <<
" for surface " <<
s.name() <<
nl
285 <<
"Valid region names are " << localNames
290 rNames[index] = regionDict.
get<
word>(
"name");
300 names_.setSize(surfI);
301 regionNames_.setSize(surfI);
302 allSurfaces_.setSize(surfI);
310 const word& wantedName
313 return names_.find(wantedName);
319 const word& surfaceName,
323 const label surfaceIndex = findSurfaceID(surfaceName);
325 return this->operator[](surfaceIndex).regions().find(
regionName);
453 Info<<
"Checking for closedness." <<
endl;
456 bool hasError =
false;
460 if (!
operator[](surfI).hasVolumeType())
467 <<
" : not closed" <<
endl;
470 if (isA<triSurface>(
operator[](surfI)))
478 label nSingleEdges = 0;
481 if (edgeFaces[edgeI].size() == 1)
487 label nMultEdges = 0;
490 if (edgeFaces[edgeI].size() > 2)
496 if (report && (nSingleEdges != 0 || nMultEdges != 0))
498 Info<<
" connected to one face : "
499 << nSingleEdges <<
nl
500 <<
" connected to >2 faces : "
501 << nMultEdges <<
endl;
520 Info<<
"Checking for normal orientation." <<
endl;
523 bool hasError =
false;
527 if (isA<triSurface>(
operator[](surfI)))
546 <<
" : has multiple orientation zones ("
564 const scalar maxRatio,
570 Info<<
"Checking for size." <<
endl;
573 bool hasError =
false;
577 const boundBox& bb = operator[](i).bounds();
579 for (label j = i+1; j < size(); j++)
581 scalar ratio = bb.
mag()/operator[](j).bounds().mag();
583 if (ratio > maxRatio || ratio < 1.0/maxRatio)
590 <<
" bounds differ from " <<
names()[j]
591 <<
" by more than a factor 100:" <<
nl
592 <<
" bounding box : " << bb <<
nl
593 <<
" bounding box : " << operator[](j).bounds()
612 const scalar tolerance,
619 Info<<
"Checking for intersection." <<
endl;
624 bool hasError =
false;
628 if (isA<triSurfaceMesh>(
operator[](i)))
642 const edge&
e = edges0[edgeI];
643 start[edgeI] = localPoints0[
e[0]];
644 end[edgeI] = localPoints0[
e[1]];
667 operator[](j).findLineAny(start,
end, hits);
678 && (i != j || !connected(s0, edgeI, hits[edgeI]))
681 intersections.append(hits[edgeI].hitPoint());
682 intersectionEdge.append(1.0*edgeI);
695 <<
" intersects " <<
names()[j]
707 std::move(intersections),
710 wordList valueSetNames(1,
"edgeIndex");
719 setWriter().getFileName(track, valueSetNames)
721 Info<<
" Writing intersection locations to "
725 s0.searchableSurface::time().
path()
756 const scalar minQuality,
762 Info<<
"Checking for triangle quality." <<
endl;
765 bool hasError =
false;
769 if (isA<triSurface>(
operator[](surfI)))
801 <<
" : has " << nBadTris <<
" bad quality triangles "
802 <<
" (quality < " << minQuality <<
")" <<
endl;
824 label noFailedChecks = 0;
826 if (checkClosed(report))
831 if (checkNormalOrientation(report))
835 return noFailedChecks;
841 const scalar maxRatio,
844 const scalar minQuality,
848 label noFailedChecks = 0;
850 if (maxRatio > 0 && checkSizes(maxRatio, report))
855 if (checkIntersection(tol, setWriter, report))
860 if (checkQuality(minQuality, report))
865 return noFailedChecks;
882 Info<<
" type : " <<
s.type() <<
nl
883 <<
" size : " <<
s.globalSize() <<
nl;
884 if (isA<triSurfaceMesh>(
s))
888 <<
" points : " << ts.
points()().size() <<
nl;
890 Info<<
" bounds : " <<
s.bounds() <<
nl
891 <<
" closed : " <<
Switch(
s.hasVolumeType()) <<
endl;
896 Info<<
" patches : ";
900 if (i < unique.size()-1)
919 const label surfI = findSurfaceID(surfName);
924 <<
"Surface named " << surfName <<
" not found." <<
nl
925 <<
"Available surface names: " << names_ <<
endl
929 return operator[](surfI);
938 const label surfI = findSurfaceID(surfName);
943 <<
"Surface named " << surfName <<
" not found." <<
nl
944 <<
"Available surface names: " << names_ <<
endl
948 return operator[](surfI);
A keyword and a list of tokens is an 'entry'.
List< label > labelList
A List of labels.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const dimensionedScalar mp
Proton mass.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
scalar mag() const
The magnitude of the bounding box span.
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
A class for handling words, derived from Foam::string.
A class for handling file names.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
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))
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
bool checkIntersection(const scalar tol, const autoPtr< writer< scalar >> &, const bool report) const
Do surfaces self-intersect or intersect others.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
bool checkQuality(const scalar minQuality, const bool report) const
Check triangle quality.
void findNearestIntersection(const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &surface2, List< pointIndexHit > &hit2) const
label nEdges() const
Number of edges in patch.
label checkTopology(const bool report) const
All topological checks. Return number of failed checks.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
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.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
IOoject and searching on triSurface.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void writeStats(const List< wordList > &, Ostream &) const
Write some stats.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
virtual Ostream & write(const char c)
Write character.
#define forAll(list, i)
Loop across all elements in list.
wordList patchTypes(nPatches)
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Find any intersection. Return hit point information and.
boundBox bounds() const
Calculate bounding box.
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.
bool checkClosed(const bool report) const
Are all surfaces closed and manifold.
Triangulated surface description with patch information.
void findNearest(const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest. Return -1 (and a miss()) or surface and nearest.
messageStream Info
Information stream (stdout output on master, null elsewhere)
void setSize(const label n)
Alias for resize()
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
void setSize(const label newLen)
Same as resize()
scalarField samples(nIntervals, Zero)
autoPtr< IOobject > clone() const
Clone.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
label findSurfaceRegionID(const word &surfaceName, const word ®ionName) const
label findSurfaceID(const word &name) const
Find index of surface. Return -1 if not found.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Holds list of sampling positions.
virtual tmp< pointField > points() const
Get the points that define the surface.
errorManip< error > abort(error &err)
Vector< scalar > vector
A scalar version of the templated Vector.
static autoPtr< searchableSurface > New(const word &surfaceType, const IOobject &io, const dictionary &dict)
Return a reference to the selected searchableSurface.
bool checkSizes(const scalar maxRatio, const bool report) const
Are all bounding boxes of similar size.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const Field< point_type > & localPoints() const
Return pointField of points in patch.
Output to file stream, using an OSstream.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
label checkGeometry(const scalar maxRatio, const scalar tolerance, const autoPtr< writer< scalar >> &setWriter, const scalar minQuality, const bool report) const
All geometric checks. Return number of failed checks.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static boundBox bounds(const PtrList< searchableSurface > &allSurfaces, const labelUList &surfacesToTest)
Find the boundBox of the selected surfaces.
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
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)
bool checkNormalOrientation(const bool report) const
Are all (triangulated) surfaces consistent normal orientation.
A triFace with additional (region) index.
A bounding box defined in terms of min/max extrema points.
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.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
Various functions to operate on Lists.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
fileName path() const
The complete path.
defineTypeNameAndDebug(combustionModel, 0)
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.
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.
triangle< point, const point & > triPointRef
A triangle using referred points.