46 const regIOobject& io,
53 ? io.globalFilePath(typeName)
54 : io.localFilePath(typeName)
59 <<
"Cannot find triSurfaceMesh starting from " 69 const regIOobject& io,
76 if (!fName.isAbsolute())
94 const regIOobject& io,
95 const dictionary& dict,
100 if (dict.readIfPresent(
"file", fName,
false,
false))
102 fName = relativeFilePath(io, fName, isGlobal);
107 <<
"Cannot find triSurfaceMesh at " << fName
116 ? io.globalFilePath(typeName)
117 : io.localFilePath(typeName)
123 <<
"Cannot find triSurfaceMesh starting from " 132 bool Foam::triSurfaceMesh::addFaceToEdge
135 EdgeMap<label>& facesPerEdge
139 if (eFnd != facesPerEdge.end())
149 facesPerEdge.insert(e, 1);
155 bool Foam::triSurfaceMesh::isSurfaceClosed()
const 168 EdgeMap<label> facesPerEdge(100);
169 forAll(pointFaces, pointi)
171 const labelList& pFaces = pointFaces[pointi];
173 facesPerEdge.
clear();
185 label nextPointi = f[f.fcIndex(fp)];
187 if (nextPointi > pointi)
189 bool okFace = addFaceToEdge
191 edge(pointi, nextPointi),
201 label prevPointi = f[f.rcIndex(fp)];
203 if (prevPointi > pointi)
205 bool okFace = addFaceToEdge
207 edge(pointi, prevPointi),
261 Foam::triSurfaceMesh::triSurfaceMesh(
const IOobject& io)
290 Foam::triSurfaceMesh::triSurfaceMesh
313 checkFile(static_cast<const searchableSurface&>(*
this), dict,
true)
322 fName_ = relativeFilePath
324 static_cast<const searchableSurface&>(*
this),
330 scalar scaleFactor = 0;
334 if (dict.
readIfPresent(
"scale", scaleFactor) && scaleFactor > 0)
346 if (dict.
readIfPresent(
"minQuality", minQuality_) && minQuality_ > 0)
349 <<
" : ignoring triangles with quality < " 350 << minQuality_ <<
" for normals calculation." <<
endl;
355 Foam::triSurfaceMesh::triSurfaceMesh(
const IOobject& io,
const bool isGlobal)
387 Foam::triSurfaceMesh::triSurfaceMesh
411 checkFile(static_cast<const searchableSurface&>(*
this), dict, isGlobal)
420 fName_ = relativeFilePath
422 static_cast<const searchableSurface&>(*
this),
428 scalar scaleFactor = 0;
432 if (dict.
readIfPresent(
"scale", scaleFactor) && scaleFactor > 0)
444 if (dict.
readIfPresent(
"minQuality", minQuality_) && minQuality_ > 0)
447 <<
" : ignoring triangles with quality < " 448 << minQuality_ <<
" for normals calculation." <<
endl;
501 const point& fc = centres[facei];
504 const point& pt = pts[f[fp]];
526 return !indices.
empty();
541 if (edgeTree_.empty())
572 bb = bb.
extend(rndGen, 1e-4);
573 bb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
574 bb.
max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
606 if (regions_.
empty())
611 regions_[regionI] =
patches()[regionI].name();
620 if (surfaceClosed_ == -1)
622 if (isSurfaceClosed())
632 return surfaceClosed_ == 1;
730 if (minQuality_ >= 0)
741 label facei = info[i].index();
742 normal[i] = s[facei].normal(pts);
744 scalar qual = s[facei].tri(pts).quality();
746 if (qual < minQuality_)
749 const labelList& fFaces = faceFaces[facei];
753 label nbrI = fFaces[j];
754 scalar nbrQual = s[nbrI].tri(pts).quality();
758 normal[i] = s[nbrI].normal(pts);
763 normal[i] /=
mag(normal[i]) + VSMALL;
778 label facei = info[i].index();
783 normal[i] = s[facei].normal(pts);
784 normal[i] /=
mag(normal[i]) + VSMALL;
818 fldPtr.
ptr()->store();
828 if (foundObject<triSurfaceLabelField>(
"values"))
841 values[i] = fld[info[i].index()];
861 const point& pt = points[pointi];
863 if (!
tree().bb().contains(pt))
866 volType[pointi] =
tree().shapes().getVolumeType(
tree(), pt);
871 volType[pointi] =
tree().getVolumeType(pt);
911 triSurface::write(fullPath);
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
List< labelList > labelListList
A List of labelList.
label nPoints() const
Return number of points supporting patch faces.
label maxTreeDepth() const
Return max tree depth of octree.
Field< label > labelField
Specialisation of Field<T> for label.
#define forAll(list, i)
Loop across all elements in list.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
A class for handling file names.
void clearOut()
Clear storage.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void clearOut()
Clear storage.
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.
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared). Any point.
T & operator[](const label)
Return element of UList.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual tmp< pointField > points() const
Get the points that define the surface.
T & ref() const
Return non-const reference or generate a fatal error.
virtual ~triSurfaceMesh()
Destructor.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void size(const label)
Override size to be inconsistent with allocated storage.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
virtual void setField(const labelList &values)
WIP. Store element-wise field.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static scalar & perturbTol()
Get the perturbation tolerance.
Helper class to search on triSurface. Creates an octree for each region of the surface and only searc...
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Holds data for octree to work on an edges subset.
label nInternalEdges() const
Number of internal edges.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
const Field< point > & faceCentres() const
Return face centres for patch.
A bounding box defined in terms of the points at its extremities.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
virtual void scalePoints(const scalar)
Scale points. A non-positive factor is ignored.
T * ptr()
Return object pointer for reuse.
Macros for easy insertion into run-time selection tables.
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp, const bool valid) const
Write using given format, version and compression.
void findNearest(const pointField &samples, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
virtual bool hasVolumeType() const
Whether supports volume type below. I.e. whether is closed.
virtual void movePoints(const pointField &)
Move points.
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
A list of faces which address into the list of points.
A List obtained as a section of another List.
const labelListList & faceFaces() const
Return face-face addressing.
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))
vectorField pointField
pointField is a vectorField.
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 findLine(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &info) const
Calculate all intersections from start to end.
bool isAbsolute() const
Return true if file name is absolute.
void clear()
Clear the list, i.e. set size to zero.
void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
const fileName & local() const
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
cachedRandom rndGen(label(0), -1)
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
streamFormat
Enumeration for the format of data in the stream.
const Field< point > & points() const
Return reference to global points.
static const word null
An empty word.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
List< label > labelList
A List of labels.
virtual fileName filePath(const bool checkGlobal, const IOobject &, const word &typeName) const =0
Search for an object. checkGlobal : also check undecomposed case.
Triangle with additional region number.
const fileOperation & fileHandler()
Get current file handler.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Simple random number generator.
compressionType
Enumeration for the format of data in the stream.
bool isFile(const fileName &, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
dimensioned< scalar > magSqr(const dimensioned< Type > &)
const Field< point > & localPoints() const
Return pointField of points in patch.
label nEdges() const
Return number of edges in patch.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
const indexedOctree< treeDataEdge > & edgeTree() const
Demand driven construction of octree for boundary edges.
const Time & time() const
Return time.
defineTypeNameAndDebug(combustionModel, 0)
treeBoundBox extend(Random &, const scalar s) const
Return slightly wider bounding box.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
word name(const complex &)
Return a string representation of a complex.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
void setSize(const label)
Reset size of List.
const point & max() const
Maximum describing the bounding box.
const geometricSurfacePatchList & patches() const
writeOption writeOpt() const
const fileName & instance() const
triSurface()
Construct null.
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
vector point
Point is a vector.
Non-pointer based hierarchical recursive searching.
string & expand(const bool allowEmpty=false)
Expand initial tildes and all occurences of environment variables.
virtual label size() const
Range of local indices that can be returned.
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.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
scalar tolerance() const
Return tolerance to use in searches.
void invertManyToMany(const label len, const UList< InList > &, List< OutList > &)
Invert many-to-many.
Standard boundBox + extra functionality for use in octree.
dimensioned< scalar > mag(const dimensioned< Type > &)
fileName path() const
Return directory path name (part before last /)
const boundBox & bounds() const
Return const reference to boundBox.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
const point & min() const
Minimum describing the bounding box.
A class for managing temporary objects.
Registry of regIOobjects.
const objectRegistry & db() const
Return the local objectRegistry.
friend class iterator
Declare friendship with the iterator.
Triangulated surface description with patch information.
readOption readOpt() const
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
label size() const
Return the number of elements in the UList.
fileName objectPath() const
Return complete path + object name.
const indexedOctree< treeDataTriSurface > & tree() const
Demand driven construction of the octree.
virtual const wordList & regions() const
Names of regions.
bool exists(const fileName &, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.