Go to the documentation of this file.
65 <<
"Cannot find triSurfaceMesh starting from "
106 if (
dict.readIfPresent(
"file", fName, keyType::LITERAL))
110 fName = relativeFilePath(io, rawFName, isGlobal);
115 <<
"Cannot find triSurfaceMesh " << rawFName
132 <<
"Cannot find triSurfaceMesh starting from "
162 Pout<<
"triSurfaceMesh::isSurfaceClosed:"
163 <<
" determining closedness for surface with "
164 << triSurface::size() <<
" triangles" <<
endl;
183 facesPerEdge.
clear();
187 const label fp =
f.find(pointi);
195 const label nextPointi =
f[
f.fcIndex(fp)];
197 if (nextPointi > pointi)
201 edge(pointi, nextPointi),
209 Pout<<
"triSurfaceMesh::isSurfaceClosed :"
210 <<
" surface is open" <<
endl;
217 const label prevPointi =
f[
f.rcIndex(fp)];
219 if (prevPointi > pointi)
223 edge(pointi, prevPointi),
231 Pout<<
"triSurfaceMesh::isSurfaceClosed :"
232 <<
" surface is open" <<
endl;
246 Pout<<
"triSurfaceMesh::isSurfaceClosed :"
247 <<
" surface is open" <<
endl;
256 Pout<<
"triSurfaceMesh::isSurfaceClosed :"
257 <<
" surface is closed" <<
endl;
356 fName_ = relativeFilePath
364 scalar scaleFactor = 0;
383 <<
" : ignoring triangles with quality < "
384 << minQuality_ <<
" for normals calculation." <<
endl;
427 Pout<<
"triSurfaceMesh(const IOobject& io) :"
430 <<
" from:" << actualFile <<
endl;
438 if (r ==
masterOnly && (actualFile != localFile))
449 Pout<<
"triSurfaceMesh(const IOobject& io) :"
450 <<
" loaded triangles:" << triSurface::size() <<
endl;
460 Pout<<
"triSurfaceMesh(const IOobject& io) :"
461 <<
" loaded triangles:" << triSurface::size() <<
endl;
472 Pout<<
"triSurfaceMesh(const IOobject& io) :"
473 <<
" loaded triangles:" << triSurface::size() <<
endl;
514 const bool searchGlobal(r == localOrGlobal || r == masterOnly);
526 fName_ = relativeFilePath
537 Pout<<
"triSurfaceMesh(const IOobject& io, const dictionary&) :"
540 <<
" from:" << actualFile <<
endl;
548 if (r == masterOnly && (actualFile != localFile))
560 Pout<<
"triSurfaceMesh(const IOobject& io) :"
561 <<
" loaded triangles:" << triSurface::size() <<
endl;
571 Pout<<
"triSurfaceMesh(const IOobject& io) :"
572 <<
" loaded triangles:" << triSurface::size() <<
endl;
583 Pout<<
"triSurfaceMesh(const IOobject& io) :"
584 <<
" loaded triangles:" << triSurface::size() <<
endl;
590 scalar scaleFactor = 0;
608 <<
" : ignoring triangles with quality < "
609 << minQuality_ <<
" for normals calculation." <<
endl;
636 auto& pts = tpts.ref();
656 radiusSqr.setSize(size());
664 const point& fc = centres[facei];
665 for (
const label pointi :
f)
667 const point& pt = pts[pointi];
689 return !indices.empty();
697 Pout<<
"triSurfaceMesh::movePoints :"
708 const label event = getEvent();
720 Pout<<
"triSurfaceMesh::movePoints: finished moving points" <<
endl;
728 if (edgeTree_.empty())
732 Pout<<
"triSurfaceMesh::edgeTree :"
733 <<
" constructing tree for " << nEdges() - nInternalEdges()
734 <<
" boundary edges" <<
endl;
740 identity(nEdges() - nInternalEdges(), nInternalEdges())
762 bb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
763 bb.
max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
769 Pout<<
"triSurfaceMesh::edgeTree : "
770 <<
"calculating edge tree for bb:" << bb <<
endl;
798 Pout<<
"triSurfaceMesh::edgeTree :"
799 <<
" finished constructing tree for "
800 << nEdges() - nInternalEdges()
801 <<
" boundary edges" <<
endl;
811 if (regions_.empty())
825 if (surfaceClosed_ == -1)
827 if (isSurfaceClosed())
837 return surfaceClosed_ == 1;
846 const point outsidePt(bounds().
max() + 0.5*bounds().span());
850 Pout<<
"triSurfaceMesh::outsideVolumeType :"
851 <<
" triggering outsidePoint:" << outsidePt
852 <<
" orientation" <<
endl;
859 getVolumeType(
pointField(1, outsidePt), outsideVolTypes);
860 outsideVolType_ = outsideVolTypes[0];
864 Pout<<
"triSurfaceMesh::outsideVolumeType :"
865 <<
" finished outsidePoint:" << outsidePt
871 return outsideVolType_;
884 Pout<<
"triSurfaceMesh::findNearest :"
885 <<
" trying to find nearest for " <<
samples.size()
886 <<
" samples with max sphere "
893 Pout<<
"triSurfaceMesh::findNearest :"
894 <<
" finished trying to find nearest for " <<
samples.size()
895 <<
" samples" <<
endl;
910 Pout<<
"triSurfaceMesh::findNearest :"
911 <<
" trying to find nearest and region for " <<
samples.size()
912 <<
" samples with max sphere "
925 Pout<<
"triSurfaceMesh::findNearest :"
926 <<
" finished trying to find nearest and region for "
941 Pout<<
"triSurfaceMesh::findLine :"
942 <<
" intersecting with "
948 Pout<<
"triSurfaceMesh::findLine :"
949 <<
" finished intersecting with "
964 Pout<<
"triSurfaceMesh::findLineAny :"
965 <<
" intersecting with "
971 Pout<<
"triSurfaceMesh::findLineAny :"
972 <<
" finished intersecting with "
987 Pout<<
"triSurfaceMesh::findLineAll :"
988 <<
" intersecting with "
994 Pout<<
"triSurfaceMesh::findLineAll :"
995 <<
" finished intersecting with "
1009 Pout<<
"triSurfaceMesh::getRegion :"
1010 <<
" getting region for "
1011 << info.size() <<
" triangles" <<
endl;
1018 region[i] = triSurface::operator[](info[i].index()).region();
1027 Pout<<
"triSurfaceMesh::getRegion :"
1028 <<
" finished getting region for "
1029 << info.size() <<
" triangles" <<
endl;
1042 Pout<<
"triSurfaceMesh::getNormal :"
1043 <<
" getting normal for "
1044 << info.size() <<
" triangles" <<
endl;
1050 normal.setSize(info.size());
1052 if (minQuality_ >= 0)
1063 const label facei = info[i].index();
1064 normal[i] =
s[facei].unitNormal(pts);
1066 scalar qual =
s[facei].tri(pts).quality();
1068 if (qual < minQuality_)
1071 const labelList& fFaces = faceFaces[facei];
1073 for (
const label nbri : fFaces)
1075 scalar nbrQual =
s[nbri].tri(pts).quality();
1079 normal[i] =
s[nbri].unitNormal(pts);
1097 const label facei = info[i].index();
1100 normal[i] =
s[facei].unitNormal(pts);
1111 Pout<<
"triSurfaceMesh::getNormal :"
1112 <<
" finished getting normal for "
1113 << info.size() <<
" triangles" <<
endl;
1120 auto* fldPtr = getObjectPtr<triSurfaceLabelField>(
"values");
1124 (*fldPtr).field() =
values;
1149 Pout<<
"triSurfaceMesh::setField :"
1150 <<
" finished setting field for "
1162 const auto* fldPtr = getObjectPtr<triSurfaceLabelField>(
"values");
1166 const auto&
fld = *fldPtr;
1168 values.setSize(info.size());
1180 Pout<<
"triSurfaceMesh::setField :"
1181 <<
" finished getting field for "
1182 << info.size() <<
" triangles" <<
endl;
1198 Pout<<
"triSurfaceMesh::getVolumeType :"
1199 <<
" finding orientation for " <<
points.size()
1200 <<
" samples" <<
endl;
1209 if (tree().bb().contains(pt))
1212 volType[pointi] = tree().getVolumeType(pt);
1214 else if (hasVolumeType())
1219 outsideVolType_ = tree().shapes().getVolumeType(tree(), pt);
1221 volType[pointi] = outsideVolType_;
1226 volType[pointi] = tree().shapes().getVolumeType(tree(), pt);
1233 Pout<<
"triSurfaceMesh::getVolumeType :"
1234 <<
" finished finding orientation for " <<
points.size()
1235 <<
" samples" <<
endl;
1260 const_cast<triSurfaceMesh&
>(*this).searchableSurface::instance() =
1290 triSurface::write(fullPath);
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.
bool exists(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static fileName relativeFilePath(const IOobject &, const fileName &, const bool isGlobal)
Return fileName. If fileName is relative gets treated local to.
const word & name() const
Return name.
const Field< point > & points() const
Return reference to global points.
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.
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.
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.
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.
virtual fileName filePath(const bool checkGlobal, const IOobject &, const word &typeName, const bool search=true) const =0
Search for an object. checkGlobal : also check undecomposed case.
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?
const fileOperation & fileHandler()
Get current file handler.
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.
static fileName checkFile(const IOobject &io, const bool isGlobal)
Return fileName to load IOobject from.
Registry of regIOobjects.
const fileName & local() const
virtual void scalePoints(const scalar scaleFactor)
Scale points. A non-positive factor is ignored.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
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.
Representation of a major/minor version number.
Field< label > labelField
Specialisation of Field<T> for label.
writeOption writeOpt() const
The write option.
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())
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.
streamFormat
Data format (ascii | binary)
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,...
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 void setField(const labelList &values)
WIP. Store element-wise field.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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.
label ListType::const_reference const label start
string & expand(const bool allowEmpty=false)
static word meshSubDir
Return the mesh sub-directory name (usually "triSurface")
const Field< PointType > & faceCentres() const
Return face centres for patch.
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.
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.
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED)
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.
vector point
Point is a vector.
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.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp, const bool valid) const
Write using given format, version and compression.
defineTypeNameAndDebug(combustionModel, 0)
virtual bool hasVolumeType() const
Whether supports volume type (below) - i.e. whether is closed.
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.