Go to the documentation of this file.
31 #include "PatchTools.H"
53 const edge&
e =
s.edges()[edgeI];
57 if (
e.otherVertex(localFace[i]) != -1)
174 const bool singleRegionName
178 names_(topDict.size()),
179 regionNames_(topDict.size()),
180 allSurfaces_(
identity(topDict.size()))
185 const word& key = iter().keyword();
190 <<
"Found non-dictionary entry " << iter()
191 <<
" in top-level dictionary " << topDict
207 namedIO().rename(key);
224 const wordList& localNames =
s.regions();
226 wordList& rNames = regionNames_[surfI];
229 if (singleRegionName && localNames.
size() == 1)
231 rNames[0] = names_[surfI];
235 forAll(localNames, regionI)
237 rNames[regionI] = names_[surfI] +
'_' + localNames[regionI];
248 const word& key = iter().keyword();
250 if (regionsDict.
isDict(key))
260 <<
"Unknown region name " << key
261 <<
" for surface " <<
s.name() <<
endl
262 <<
"Valid region names are " << localNames
266 rNames[index] =
word(regionDict.
lookup(
"name"));
276 names_.setSize(surfI);
277 regionNames_.setSize(surfI);
278 allSurfaces_.setSize(surfI);
286 const word& wantedName
295 const word& surfaceName,
299 label surfaceIndex = findSurfaceID(surfaceName);
432 const scalar initDistSqr,
433 const scalar convergenceDistSqr,
452 Info<<
"Checking for closedness." <<
endl;
455 bool hasError =
false;
459 if (!
operator[](surfI).hasVolumeType())
465 Info<<
" " << names()[surfI]
466 <<
" : not closed" <<
endl;
469 if (isA<triSurface>(
operator[](surfI)))
477 label nSingleEdges = 0;
480 if (edgeFaces[edgeI].size() == 1)
486 label nMultEdges = 0;
489 if (edgeFaces[edgeI].size() > 2)
495 if (report && (nSingleEdges != 0 || nMultEdges != 0))
497 Info<<
" connected to one face : "
498 << nSingleEdges <<
nl
499 <<
" connected to >2 faces : "
500 << nMultEdges <<
endl;
519 Info<<
"Checking for normal orientation." <<
endl;
522 bool hasError =
false;
526 if (isA<triSurface>(
operator[](surfI)))
544 Info<<
" " << names()[surfI]
545 <<
" : has multiple orientation zones ("
546 << nZones <<
")" <<
endl;
563 const scalar maxRatio,
569 Info<<
"Checking for size." <<
endl;
572 bool hasError =
false;
576 const boundBox& bb = operator[](i).bounds();
578 for (
label j = i+1; j < size(); j++)
580 scalar ratio = bb.
mag()/operator[](j).bounds().mag();
582 if (ratio > maxRatio || ratio < 1.0/maxRatio)
588 Info<<
" " << names()[i]
589 <<
" bounds differ from " << names()[j]
590 <<
" by more than a factor 100:" <<
nl
591 <<
" bounding box : " << bb <<
nl
592 <<
" bounding box : " << operator[](j).bounds()
611 const scalar tolerance,
618 Info<<
"Checking for intersection." <<
endl;
623 bool hasError =
false;
627 if (isA<triSurfaceMesh>(
operator[](i)))
641 const edge&
e = edges0[edgeI];
642 start[edgeI] = localPoints0[
e[0]];
643 end[edgeI] = localPoints0[
e[1]];
666 operator[](j).findLineAny(start, end, hits);
677 && (i != j || !connected(s0, edgeI, hits[edgeI]))
680 intersections.
append(hits[edgeI].hitPoint());
681 intersectionEdge.
append(1.0*edgeI);
690 Info<<
" " << names()[i]
691 <<
" intersects " << names()[j]
697 if (setWriter.valid())
702 names()[i] +
'_' + names()[j],
704 intersections.
xfer(),
707 wordList valueSetNames(1,
"edgeIndex");
716 setWriter().getFileName(track, valueSetNames)
718 Info<<
" Writing intersection locations to "
722 s0.searchableSurface::time().
path()
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);
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
label index() const
Return index.
bool checkIntersection(const scalar tol, const autoPtr< writer< scalar > > &, const bool report) const
Do surfaces self-intersect or intersect others.
scalar mag() const
The magnitude of the bounding box span.
A class for handling words, derived from 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)
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
#define forAll(list, i)
Loop across all elements in list.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
bool checkQuality(const scalar minQuality, const bool report) const
Check triangle quality.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
void findNearestIntersection(const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &surface2, List< pointIndexHit > &hit2) const
static bool connected(const triSurface &s, const label edgeI, const pointIndexHit &hit)
Is edge on face.
label nEdges() const
Return number of edges in patch.
label checkTopology(const bool report) const
All topological checks. Return number of failed checks.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
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.
IOoject and searching on triSurface.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void writeStats(const List< wordList > &, Ostream &) const
Write some stats.
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.
dimensioned< scalar > mag(const dimensioned< Type > &)
searchableSurfaces(const searchableSurfaces &)
Disallow default bitwise copy construct.
bool isDict(const word &) const
Check if entry is a sub-dictionary.
wordList patchTypes(nPatches)
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
scalarField samples(nIntervals, 0)
pointIndexHit facesIntersection(const scalar initialDistSqr, const scalar convergenceDistSqr, const point &start) const
Calculate point which is on a set of surfaces.
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Find any intersection. Return hit point information and.
scalar tolerance() const
Return tolerance to use in searches.
boundBox bounds() const
Calculate bounding box.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
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)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Pre-declare SubField and related Field type.
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.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
DynamicField< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
static boundBox bounds(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest)
Find the boundBox of the selected surfaces.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
static pointIndexHit facesIntersection(const PtrList< searchableSurface > &allSurfaces, const labelList &surfacesToTest, const scalar initDistSqr, const scalar convergenceDistSqr, const point &start)
Calculate point which is on a set of surfaces. WIP.
label findSurfaceRegionID(const word &surfaceName, const word ®ionName) const
label findSurfaceID(const word &name) const
Find index of surface. Return -1 if not found.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
A list of keyword definitions, which are a keyword followed by any number of values (e....
label capacity() const
Size of the underlying storage.
Base class for graphics format writing. Entry points are.
Holds list of sampling positions.
virtual tmp< pointField > points() const
Get the points that define the surface.
errorManip< error > abort(error &err)
const double e
Elementary charge.
static autoPtr< searchableSurface > New(const word &surfaceType, const IOobject &io, const dictionary &dict)
Return a reference to the selected searchableSurface.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().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))
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)
Xfer< List< T > > xfer()
Transfer contents to the Xfer container as a plain List.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void setSize(const label)
Reset size of List.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A triangular face using a FixedList of labels corresponding to mesh vertices.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Foam::autoPtr< IOobject > clone() const
Clone.
const dimensionedScalar e
Elementary charge.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
bool checkNormalOrientation(const bool report) const
Are all (triangulated) surfaces consistent normal orientation.
friend Ostream & operator(Ostream &, const PtrList< T > &)
Triangle with additional region number.
A bounding box defined in terms of the points at its extremities.
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.
Various functions to operate on Lists.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
fileName path() const
Return complete path.
defineTypeNameAndDebug(combustionModel, 0)
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.
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