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)
201 const bool singleRegionName
205 names_(topDict.size()),
206 regionNames_(topDict.size()),
207 allSurfaces_(
identity(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();
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];
272 for (
const entry& dEntry : regionsDict)
276 const word& key = dEntry.keyword();
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");
302 regionNames_.setSize(surfI);
311 const word& wantedName
314 return names_.find(wantedName);
320 const word& surfaceName,
324 const label surfaceIndex = findSurfaceID(surfaceName);
326 return this->operator[](surfaceIndex).regions().find(
regionName);
442 return searchableSurfacesQueries::bounds
454 Info<<
"Checking for closedness." <<
endl;
457 bool hasError =
false;
461 if (!
operator[](surfI).hasVolumeType())
467 Info<<
" " << names()[surfI]
468 <<
" : not closed" <<
endl;
471 if (isA<triSurface>(
operator[](surfI)))
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;
528 if (isA<triSurface>(
operator[](surfI)))
546 Info<<
" " << names()[surfI]
547 <<
" : has multiple orientation zones ("
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)
590 Info<<
" " << names()[i]
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,
620 Info<<
"Checking for intersection." <<
endl;
625 bool hasError =
false;
629 if (isA<triSurfaceMesh>(
operator[](i)))
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].hitPoint());
683 intersectionEdge.
append(edgeI);
695 Info<<
" " << names()[i]
696 <<
" intersects " << names()[j]
701 if (setWriter && setWriter->enabled())
706 names()[i] +
'_' + names()[j],
708 std::move(intersections),
713 auto&
writer = *setWriter;
720 s0.searchableSurface::time().
path()
721 / (track.
name() +
"_edgeIndex")
726 writer.write(
"edgeIndex", intersectionEdge);
730 Info<<
" Wrote intersection locations to "
753 const scalar minQuality,
759 Info<<
"Checking for triangle quality." <<
endl;
762 bool hasError =
false;
766 if (isA<triSurface>(
operator[](surfI)))
797 Info<<
" " << names()[surfI]
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,
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;
875 Info<<
" " << names()[surfI] <<
':' <<
endl;
879 Info<<
" type : " <<
s.type() <<
nl
880 <<
" size : " <<
s.globalSize() <<
nl;
881 if (isA<triSurfaceMesh>(
s))
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::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
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.
autoPtr< IOobject > clone() const
Clone.
void setSize(const 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 newLen)
Same as resize()
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
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 of the bounding box span.
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,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A keyword and a list of tokens is an 'entry'.
friend Ostream & operator(Ostream &, const faMatrix< Type > &)
A class for handling file names.
void checkSizes() const
Check that all components of sizes() are non-negative.
A triFace with additional (region) index.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
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.
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.
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.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
void close()
End the file contents and close the file after writing.
virtual bool open(const fileName &file, bool parallel=Pstream::parRun())
Open file for writing (creates parent directory).
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Foam::word regionName(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))
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
triangle< point, const point & > triPointRef
A triangle using referred points.
errorManip< error > abort(error &err)
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
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)