Go to the documentation of this file.
56 label&
count = facesPerEdge(
e, 0);
71 Pout<<
"triSurfaceMesh::isSurfaceClosed:"
72 <<
" determining closedness for surface with "
73 << triSurface::size() <<
" triangles" <<
endl;
93 for (
const label facei :
pFaces)
96 const label fp =
f.find(pointi);
104 const label nextPointi =
f[
f.fcIndex(fp)];
106 if (nextPointi > pointi)
110 edge(pointi, nextPointi),
118 Pout<<
"triSurfaceMesh::isSurfaceClosed :"
119 <<
" surface is open" <<
endl;
126 const label prevPointi =
f[
f.rcIndex(fp)];
128 if (prevPointi > pointi)
132 edge(pointi, prevPointi),
140 Pout<<
"triSurfaceMesh::isSurfaceClosed :"
141 <<
" surface is open" <<
endl;
155 Pout<<
"triSurfaceMesh::isSurfaceClosed :"
156 <<
" surface is open" <<
endl;
165 Pout<<
"triSurfaceMesh::isSurfaceClosed :"
166 <<
" surface is closed" <<
endl;
272 scalar scaleFactor{0};
276 <<
" : using scale " << scaleFactor <<
endl;
287 <<
" : ignoring triangles with quality < "
288 << minQuality_ <<
" for normals calculation." <<
endl;
331 Pout<<
"triSurfaceMesh(const IOobject& io) :"
334 <<
" from:" << actualFile <<
endl;
342 if (r ==
masterOnly && (actualFile != localFile))
353 Pout<<
"triSurfaceMesh(const IOobject& io) :"
354 <<
" loaded triangles:" << triSurface::size() <<
endl;
364 Pout<<
"triSurfaceMesh(const IOobject& io) :"
365 <<
" loaded triangles:" << triSurface::size() <<
endl;
376 Pout<<
"triSurfaceMesh(const IOobject& io) :"
377 <<
" loaded triangles:" << triSurface::size() <<
endl;
423 const bool searchGlobal(r == localOrGlobal || r == masterOnly);
435 fName_ = relativeFilePath
446 Pout<<
"triSurfaceMesh(const IOobject& io, const dictionary&) :"
449 <<
" from:" << actualFile <<
endl;
458 if (r == masterOnly && (actualFile != localFile))
464 triSurface s2(actualFile, surfType, scaleFactor);
470 Pout<<
"triSurfaceMesh(const IOobject& io) :"
471 <<
" loaded triangles:" << triSurface::size() <<
endl;
477 triSurface s2(actualFile, surfType, scaleFactor);
481 Pout<<
"triSurfaceMesh(const IOobject& io) :"
482 <<
" loaded triangles:" << triSurface::size() <<
endl;
489 triSurface s2(actualFile, surfType, scaleFactor);
493 Pout<<
"triSurfaceMesh(const IOobject& io) :"
494 <<
" loaded triangles:" << triSurface::size() <<
endl;
504 <<
" : using scale " << scaleFactor <<
endl;
516 <<
" : ignoring triangles with quality < "
517 << minQuality_ <<
" for normals calculation." <<
endl;
544 auto& pts = tpts.ref();
575 radiusSqr.setSize(size());
583 const point& fc = centres[facei];
584 for (
const label pointi :
f)
586 const point& pt = pts[pointi];
608 return !indices.empty();
616 Pout<<
"triSurfaceMesh::movePoints :"
627 const label
event = getEvent();
639 Pout<<
"triSurfaceMesh::movePoints: finished moving points" <<
endl;
647 if (edgeTree_.empty())
651 Pout<<
"triSurfaceMesh::edgeTree :"
652 <<
" constructing tree for " << nEdges() - nInternalEdges()
653 <<
" boundary edges" <<
endl;
659 identity(nEdges() - nInternalEdges(), nInternalEdges())
688 Pout<<
"triSurfaceMesh::edgeTree : "
689 <<
"calculating edge tree for bb:" << bb <<
endl;
717 Pout<<
"triSurfaceMesh::edgeTree :"
718 <<
" finished constructing tree for "
719 << nEdges() - nInternalEdges()
720 <<
" boundary edges" <<
endl;
730 if (regions_.empty())
744 if (surfaceClosed_ == -1)
746 if (isSurfaceClosed())
756 return surfaceClosed_ == 1;
765 const point outsidePt(bounds().
max() + 0.5*bounds().span());
769 Pout<<
"triSurfaceMesh::outsideVolumeType :"
770 <<
" triggering outsidePoint:" << outsidePt
771 <<
" orientation" <<
endl;
778 getVolumeType(
pointField(1, outsidePt), outsideVolTypes);
779 outsideVolType_ = outsideVolTypes[0];
783 Pout<<
"triSurfaceMesh::outsideVolumeType :"
784 <<
" finished outsidePoint:" << outsidePt
790 return outsideVolType_;
803 Pout<<
"triSurfaceMesh::findNearest :"
804 <<
" trying to find nearest for " <<
samples.size()
805 <<
" samples with max sphere "
812 Pout<<
"triSurfaceMesh::findNearest :"
813 <<
" finished trying to find nearest for " <<
samples.size()
814 <<
" samples" <<
endl;
829 Pout<<
"triSurfaceMesh::findNearest :"
830 <<
" trying to find nearest and region for " <<
samples.size()
831 <<
" samples with max sphere "
844 Pout<<
"triSurfaceMesh::findNearest :"
845 <<
" finished trying to find nearest and region for "
860 Pout<<
"triSurfaceMesh::findLine :"
861 <<
" intersecting with "
862 << start.size() <<
" rays" <<
endl;
867 Pout<<
"triSurfaceMesh::findLine :"
868 <<
" finished intersecting with "
869 << start.size() <<
" rays" <<
endl;
883 Pout<<
"triSurfaceMesh::findLineAny :"
884 <<
" intersecting with "
885 << start.size() <<
" rays" <<
endl;
890 Pout<<
"triSurfaceMesh::findLineAny :"
891 <<
" finished intersecting with "
892 << start.size() <<
" rays" <<
endl;
906 Pout<<
"triSurfaceMesh::findLineAll :"
907 <<
" intersecting with "
908 << start.size() <<
" rays" <<
endl;
913 Pout<<
"triSurfaceMesh::findLineAll :"
914 <<
" finished intersecting with "
915 << start.size() <<
" rays" <<
endl;
928 Pout<<
"triSurfaceMesh::getRegion :"
929 <<
" getting region for "
930 << info.size() <<
" triangles" <<
endl;
937 region[i] = triSurface::operator[](info[i].index()).region();
946 Pout<<
"triSurfaceMesh::getRegion :"
947 <<
" finished getting region for "
948 << info.size() <<
" triangles" <<
endl;
961 Pout<<
"triSurfaceMesh::getNormal :"
962 <<
" getting normal for "
963 << info.size() <<
" triangles" <<
endl;
969 normal.setSize(info.size());
971 if (minQuality_ >= 0)
982 const label facei = info[i].index();
983 normal[i] =
s[facei].unitNormal(pts);
985 scalar qual =
s[facei].tri(pts).quality();
987 if (qual < minQuality_)
990 const labelList& fFaces = faceFaces[facei];
992 for (
const label nbri : fFaces)
994 scalar nbrQual =
s[nbri].tri(pts).quality();
998 normal[i] =
s[nbri].unitNormal(pts);
1016 const label facei = info[i].index();
1019 normal[i] =
s[facei].unitNormal(pts);
1030 Pout<<
"triSurfaceMesh::getNormal :"
1031 <<
" finished getting normal for "
1032 << info.size() <<
" triangles" <<
endl;
1039 auto* fldPtr = getObjectPtr<triSurfaceLabelField>(
"values");
1043 (*fldPtr).field() =
values;
1068 Pout<<
"triSurfaceMesh::setField :"
1069 <<
" finished setting field for "
1081 const auto* fldPtr = getObjectPtr<triSurfaceLabelField>(
"values");
1085 const auto&
fld = *fldPtr;
1087 values.setSize(info.size());
1099 Pout<<
"triSurfaceMesh::setField :"
1100 <<
" finished getting field for "
1101 << info.size() <<
" triangles" <<
endl;
1117 Pout<<
"triSurfaceMesh::getVolumeType :"
1118 <<
" finding orientation for " <<
points.size()
1119 <<
" samples" <<
endl;
1128 if (tree().bb().contains(pt))
1131 volType[pointi] = tree().getVolumeType(pt);
1133 else if (hasVolumeType())
1138 outsideVolType_ = tree().shapes().getVolumeType(tree(), pt);
1140 volType[pointi] = outsideVolType_;
1145 volType[pointi] = tree().shapes().getVolumeType(tree(), pt);
1152 Pout<<
"triSurfaceMesh::getVolumeType :"
1153 <<
" finished finding orientation for " <<
points.size()
1154 <<
" samples" <<
endl;
1177 const_cast<triSurfaceMesh&
>(*this).searchableSurface::instance() =
int debug
Static debugging option.
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
vectorField pointField
pointField is a vectorField.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
treeBoundBox extend(Random &rndGen, const scalar s) const
Return slightly wider bounding box.
const labelListList & pointFaces() const
Return point-face addressing.
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Dimensionless.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
const word & name() const
Return name.
fileName localFilePath(const word &typeName, const bool search=true) const
Helper for filePath that searches locally.
A class for handling words, derived from Foam::string.
static Vector< Cmpt > uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
A class for handling file names.
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))
static std::string path(const std::string &str)
Return directory path name (part before last /)
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
static fileName relativeFilePath(const IOobject &io, const fileName &f, const bool isGlobal=true)
Return fileName.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
void findNearest(const pointField &samples, const scalarField &nearestDistSqr, const labelList ®ionIndices, List< pointIndexHit > &info) const
Find the nearest point on the surface out of the regions.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &info) const
Calculate all intersections from start to end.
A List obtained as a section of another List.
const fileName & instance() const
Standard boundBox with extra functionality for use in octree.
bool hasFaceCentres() const
const indexedOctree< treeDataEdge > & edgeTree() const
Demand driven construction of octree for boundary edges.
const Time & time() const
Return time.
static bool & parRun()
Is this a parallel run?
static word timeName(const scalar t, const int precision=precision_)
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
void clearOut()
Clear storage.
fileName caseSystem() const
void findNearest(const pointField &samples, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
IOoject and searching on triSurface.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const point & max() const
Maximum describing the bounding box.
label eventNo() const
Event number at last update.
Helper class to search on triSurface. Creates an octree for each region of the surface and only searc...
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
const geometricSurfacePatchList & patches() const
const Time & time() const
Return time.
virtual volumeType outsideVolumeType() const
If surface is closed, what is type of points outside bounds.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
triSurfaceMesh(const triSurfaceMesh &)=delete
No copy construct.
const point & min() const
Minimum describing the bounding box.
#define forAll(list, i)
Loop across all elements in list.
static scalar & perturbTol()
Get the perturbation tolerance.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
void invertManyToMany(const label len, const UList< InputIntListType > &input, List< OutputIntListType > &output)
Invert many-to-many.
const objectRegistry & db() const
Return the local objectRegistry.
virtual void movePoints(const pointField &)
Move points.
Registry of regIOobjects.
const fileName & local() const
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::HEX);labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells]=cellShape(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< SLList< face > > pFaces[nBCs]
virtual void movePoints(const pointField &pts)
Move points.
Field< label > labelField
Specialisation of Field<T> for label.
writeOption writeOpt() const
The write option.
void write(Ostream &os) const
Write to Ostream in simple OpenFOAM format.
Triangulated surface description with patch information.
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
static const Enum< volumeType::type > names
Names for the classification enumeration.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
PtrList< coordinateSystem > coordinates(solidRegions.size())
The IOstreamOption is a simple container for options an IOstream can normally have.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
Non-pointer based hierarchical recursive searching.
void transfer(triSurface &surf)
Alter contents by transferring (triangles, points) components.
Holds data for octree to work on an edges subset.
scalarField samples(nIntervals, Zero)
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
virtual const wordList & regions() const
Names of regions.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
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;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared). Any point.
void clearOut()
Clear storage.
fileName globalFilePath(const word &typeName, const bool search=true) const
Helper for filePath that searches up if in parallel.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const Field< point_type > & points() const
Return reference to global points.
Macros for easy insertion into run-time selection tables.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
virtual tmp< pointField > points() const
Get the points that define the surface.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
virtual void setField(const labelList &values)
WIP. Store element-wise field.
static bool master(const label communicator=0)
Am I the master process.
const word & system() const
Return system name.
void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
dimensionedSymmTensor sqr(const dimensionedVector &dv)
virtual ~triSurfaceMesh()
Destructor.
forAllConstIters(mixture.phases(), phase)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
dimensionedScalar sqrt(const dimensionedScalar &ds)
fileName caseConstant() const
readOption readOpt() const
The read option.
static bool addFaceToEdge(const edge &, EdgeMap< label > &)
Helper function for isSurfaceClosed.
string & expand(const bool allowEmpty=false)
static word meshSubDir
Return the mesh sub-directory name (usually "triSurface")
const dimensionedScalar e
Elementary charge.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
void clear()
Clear the list, i.e. set size to zero.
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
static const word null
An empty word.
const polyBoundaryMesh & patches
Foam::DimensionedField< label, triSurfaceGeoMesh > triSurfaceLabelField
Triangle with additional region number.
bool isSurfaceClosed() const
Check whether surface is closed without calculating any permanent.
A bounding box defined in terms of min/max extrema points.
void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
virtual const boundBox & bounds() const
Return const reference to boundBox.
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside/mixed) for point.
fileName objectPath() const
The complete path + object name.
void setSize(const label newSize)
Alias for resize(const label)
const word & constant() const
Return constant name.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
defineTypeNameAndDebug(combustionModel, 0)
virtual bool hasVolumeType() const
Whether supports volume type (below) - i.e. whether is closed.
const Field< point_type > & faceCentres() const
Return face centres for patch.
static bool isAbsolute(const std::string &str)
Return true if string starts with a '/'.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
A list of faces which address into the list of points.