107 const fileName& fName,
108 const fileName& objectName
115 "triSurfaceMesh::checkFile(const fileName&, const fileName&)" 116 ) <<
"Cannot find triSurfaceMesh starting from " 123 bool Foam::triSurfaceMesh::addFaceToEdge
126 EdgeMap<label>& facesPerEdge
130 if (eFnd != facesPerEdge.end())
140 facesPerEdge.insert(e, 1);
146 bool Foam::triSurfaceMesh::isSurfaceClosed()
const 159 EdgeMap<label> facesPerEdge(100);
160 forAll(pointFaces, pointI)
162 const labelList& pFaces = pointFaces[pointI];
164 facesPerEdge.
clear();
176 label nextPointI = f[f.fcIndex(fp)];
178 if (nextPointI > pointI)
180 bool okFace = addFaceToEdge
182 edge(pointI, nextPointI),
192 label prevPointI = f[f.rcIndex(fp)];
194 if (prevPointI > pointI)
196 bool okFace = addFaceToEdge
198 edge(pointI, prevPointI),
252 Foam::triSurfaceMesh::triSurfaceMesh(
const IOobject& io)
300 Foam::triSurfaceMesh::triSurfaceMesh
345 scalar scaleFactor = 0;
349 if (dict.
readIfPresent(
"scale", scaleFactor) && scaleFactor > 0)
361 if (dict.
readIfPresent(
"minQuality", minQuality_) && minQuality_ > 0)
364 <<
" : ignoring triangles with quality < " 365 << minQuality_ <<
" for normals calculation." <<
endl;
419 const point& fc = centres[faceI];
422 const point& pt = pts[f[fp]];
444 return !indices.
empty();
459 if (edgeTree_.empty())
479 static_cast<const triSurface&>(*
this),
490 bb = bb.
extend(rndGen, 1e-4);
491 bb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
492 bb.
max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
524 if (regions_.
empty())
529 regions_[regionI] =
patches()[regionI].name();
539 if (surfaceClosed_ == -1)
541 if (isSurfaceClosed())
551 return surfaceClosed_ == 1;
649 if (minQuality_ >= 0)
660 label faceI = info[i].index();
661 normal[i] = s[faceI].normal(pts);
663 scalar qual = s[faceI].tri(pts).quality();
665 if (qual < minQuality_)
668 const labelList& fFaces = faceFaces[faceI];
672 label nbrI = fFaces[j];
673 scalar nbrQual = s[nbrI].tri(pts).quality();
677 normal[i] = s[nbrI].normal(pts);
682 normal[i] /=
mag(normal[i]) + VSMALL;
697 label faceI = info[i].index();
702 normal[i] = s[faceI].normal(pts);
703 normal[i] /=
mag(normal[i]) + VSMALL;
737 fldPtr.
ptr()->store();
747 if (foundObject<triSurfaceLabelField>(
"values"))
760 values[i] = fld[info[i].index()];
780 const point& pt = points[pointI];
782 if (!
tree().bb().contains(pt))
785 volType[pointI] =
tree().shapes().getVolumeType(
tree(), pt);
790 volType[pointI] =
tree().getVolumeType(pt);
816 triSurface::write(fullPath);
void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &info) const
Calculate all intersections from start to end.
Simple random number generator.
cachedRandom rndGen(label(0),-1)
const point & min() const
Minimum describing the bounding box.
T * ptr()
Return object pointer for reuse.
static scalar & perturbTol()
Get the perturbation tolerance.
const labelListList & faceFaces() const
Return face-face addressing.
readOption readOpt() const
void invertManyToMany(const label len, const UList< InList > &, List< OutList > &)
Invert many-to-many.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
vector point
Point is a vector.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
fileName filePath() const
Return complete path + object name if the file exists.
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 ))
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
const indexedOctree< treeDataEdge > & edgeTree() const
Demand driven construction of octree for boundary edges.
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
dimensioned< scalar > mag(const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
virtual label size() const
Range of local indices that can be returned.
bool empty() const
Return true if the UList is empty (ie, size() is zero).
dimensioned< scalar > magSqr(const dimensioned< Type > &)
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared). Any point.
Triangulated surface description with patch information.
Field< label > labelField
Specialisation of Field<T> for label.
virtual bool hasVolumeType() const
Whether supports volume type below. I.e. whether is closed.
const fileName & local() const
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Standard boundBox + extra functionality for use in octree.
void size(const label)
Override size to be inconsistent with allocated storage.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const fileName & instance() const
triSurface()
Construct null.
const boundBox & bounds() const
Return const reference to boundBox.
void clearOut()
Clear storage.
fileName path() const
Return directory path name (part before last /)
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
virtual void movePoints(const pointField &)
Move points.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Helper class to search on triSurface. Creates an octree for each region of the surface and only searc...
virtual ~triSurfaceMesh()
Destructor.
label nPoints() const
Return number of points supporting patch faces.
vectorField pointField
pointField is a vectorField.
void clearOut()
Clear storage.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const
Get all intersections in order from start to end.
T & operator[](const label)
Return element of UList.
const Field< point > & localPoints() const
Return pointField of points in patch.
void clear()
Clear the list, i.e. set size to zero.
scalar tolerance() const
Return tolerance to use in searches.
Triangle with additional region number.
const Field< point > & faceCentres() const
Return face centres for patch.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const geometricSurfacePatchList & patches() const
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.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const indexedOctree< treeDataTriSurface > & tree() const
Demand driven construction of the octree.
treeBoundBox extend(Random &, const scalar s) const
Return slightly wider bounding box.
streamFormat
Enumeration for the format of data in the stream.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
writeOption writeOpt() const
fileName objectPath() const
Return complete path + object name.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp) const
Write using given format, version and compression.
Macros for easy insertion into run-time selection tables.
virtual tmp< pointField > points() const
Get the points that define the surface.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
const point & max() const
Maximum describing the bounding box.
static void calcBounds(const PrimitivePatch< Face, FaceList, PointField, PointType > &p, boundBox &bb, label &nPoints)
const word & name() const
Return name.
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){const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject( name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE ))
void findNearest(const pointField &samples, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
A bounding box defined in terms of the points at its extremities.
Non-pointer based hierarchical recursive searching.
A list of faces which address into the list of points.
compressionType
Enumeration for the format of data in the stream.
Holds data for octree to work on an edges subset.
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
label nInternalEdges() const
Number of internal edges.
Registry of regIOobjects.
List< label > labelList
A List of labels.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
A class for handling file names.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
label size() const
Return the number of elements in the UList.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
virtual void movePoints(const pointField &)
Move points.
void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
A List obtained as a section of another List.
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
label maxTreeDepth() const
Return max tree depth of octree.
const Time & time() const
Return time.
bool isFile(const fileName &, const bool checkGzip=true)
Does the name exist as a FILE in the file system?
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
label nEdges() const
Return number of edges in patch.
List< labelList > labelListList
A List of labelList.
const objectRegistry & db() const
Return the local objectRegistry.
friend class iterator
Declare friendship with the iterator.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A class for managing temporary objects.
const Field< point > & points() const
Return reference to global points.
virtual void setField(const labelList &values)
WIP. Store element-wise field.
virtual void scalePoints(const scalar)
Scale points. A non-positive factor is ignored.
virtual const wordList & regions() const
Names of regions.
defineTypeNameAndDebug(combustionModel, 0)