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();
223 names_[surfI] =
dict.getOrDefault<
word>(
"name",
key);
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];
267 if (
dict.found(
"regions"))
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");
301 regionNames_.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)))
472 const triSurface&
s =
dynamic_cast<const triSurface&
>
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)))
529 const triSurface&
s =
dynamic_cast<const triSurface&
>
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,
613 const autoPtr<writer<scalar>>& setWriter,
619 Info<<
"Checking for intersection." <<
endl;
624 bool hasError =
false;
628 if (isA<triSurfaceMesh>(
operator[](i)))
630 const triSurfaceMesh& s0 =
dynamic_cast<const triSurfaceMesh&
>
634 const edgeList& edges0 = s0.edges();
635 const pointField& localPoints0 = s0.localPoints();
642 const edge&
e = edges0[edgeI];
643 start[edgeI] = localPoints0[
e[0]];
644 end[edgeI] = localPoints0[
e[1]];
650 List<pointIndexHit> hits;
667 operator[](j).findLineAny(start,
end, hits);
670 DynamicField<point> intersections(edges0.size()/100);
671 DynamicField<scalar> intersectionEdge(intersections.capacity());
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");
711 List<const scalarField*> valueSets
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)))
771 const triSurface&
s =
dynamic_cast<const triSurface&
>
779 const labelledTri&
f =
s[facei];
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,
843 const autoPtr<writer<scalar>>& setWriter,
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;
880 const searchableSurface&
s = operator[](surfI);
882 Info<<
" type : " <<
s.type() <<
nl
883 <<
" size : " <<
s.globalSize() <<
nl;
884 if (isA<triSurfaceMesh>(
s))
886 const triSurfaceMesh& ts =
dynamic_cast<const triSurfaceMesh&
>(
s);
887 Info<<
" edges : " << ts.nEdges() <<
nl
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.
vectorField pointField
pointField is a vectorField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const dimensionedScalar mp
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
void set(List< bool > &bools, const labelRange &range)
List< edge > edgeList
A List of edges.
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
bool checkIntersection(const scalar tol, const autoPtr< writer< scalar >> &, const bool report) const
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
bool checkQuality(const scalar minQuality, const bool report) const
void findNearestIntersection(const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &surface2, List< pointIndexHit > &hit2) const
label checkTopology(const bool report) const
label capacity() const noexcept
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 > &)
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)
void writeStats(const List< wordList > &, Ostream &) const
const T * set(const label i) const
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
A HashTable with keys but without contents that is similar to std::unordered_set.
wordList patchTypes(nPatches)
List< word > wordList
A List of words.
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
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)
Generic templated field type.
bool checkClosed(const bool report) const
Triangulated surface description with patch information.
void findNearest(const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
void setSize(const label n)
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
void setSize(const label newLen)
scalarField samples(nIntervals, Zero)
autoPtr< IOobject > clone() const
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
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const searchableSurface & operator[](const word &) const
OBJstream os(runTime.globalPath()/outputName)
constexpr auto end(C &c) -> decltype(c.end())
Holds list of sampling positions.
virtual tmp< pointField > points() const
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)
bool checkSizes(const scalar maxRatio, const bool report) const
errorManipArg< error, int > exit(error &err, const int errNo=1)
const Field< point_type > & localPoints() const
Output to file stream, using an OSstream.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
List< labelList > labelListList
A List of labelList.
label checkGeometry(const scalar maxRatio, const scalar tolerance, const autoPtr< writer< scalar >> &setWriter, const scalar minQuality, const bool report) const
#define FatalErrorInFunction
static boundBox bounds(const PtrList< searchableSurface > &allSurfaces, const labelUList &surfacesToTest)
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const dimensionedScalar e
labelList identity(const label len, label start=0)
bool checkNormalOrientation(const bool report) const
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)
HashSet< word, Hash< word > > wordHashSet
A HashSet with word keys and string hasher.
Various functions to operate on Lists.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys and label hasher.
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)
DynamicField< T, SizeMin > & append(const T &val)
defineTypeNameAndDebug(combustionModel, 0)
void findAllIntersections(const pointField &start, const pointField &end, labelListList &surfaces, List< List< pointIndexHit >> &) const
static void findNearest(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &)
triangle< point, const point & > triPointRef
A triangle using referred points.