38 namespace searchableSurfaces
65 const regIOobject& io,
69 const fileName fName(io.filePath(isGlobal));
74 <<
"Cannot find triSurface file starting from "
82 Foam::fileName Foam::searchableSurfaces::triSurface::relativeFilePath
84 const regIOobject& io,
91 if (!fName.isAbsolute())
105 const regIOobject& io,
106 const dictionary&
dict,
110 fileName dictFName, fName;
112 if (
dict.readIfPresent(
"file", dictFName,
false,
false))
114 fName = relativeFilePath(io, dictFName, isGlobal);
119 <<
"Cannot find triSurface file " << io.path()/dictFName
125 fName = io.filePath(isGlobal);
130 <<
"Cannot find triSurface file starting from "
139 bool Foam::searchableSurfaces::triSurface::addFaceToEdge
142 EdgeMap<label>& facesPerEdge
146 if (eFnd != facesPerEdge.end())
156 facesPerEdge.insert(
e, 1);
162 bool Foam::searchableSurfaces::triSurface::isSurfaceClosed()
const
175 EdgeMap<label> facesPerEdge(100);
176 forAll(pointFaces, pointi)
180 facesPerEdge.clear();
193 label nextPointi =
f[
f.fcIndex(fp)];
195 if (nextPointi > pointi)
197 bool okFace = addFaceToEdge
199 edge(pointi, nextPointi),
209 label prevPointi =
f[
f.rcIndex(fp)];
211 if (prevPointi > pointi)
213 bool okFace = addFaceToEdge
215 edge(pointi, prevPointi),
336 dict.lookup(
"file", false, false),
343 scalar scaleFactor = 0;
347 if (
dict.readIfPresent(
"scale", scaleFactor) && scaleFactor > 0)
359 if (
dict.readIfPresent(
"minQuality", minQuality_) && minQuality_ > 0)
362 <<
" : ignoring triangles with quality < "
363 << minQuality_ <<
" for normals calculation." <<
endl;
435 if (
dict.readIfPresent(
"file", fName_,
false,
false))
437 fName_ = relativeFilePath
445 scalar scaleFactor = 0;
449 if (
dict.readIfPresent(
"scale", scaleFactor) && scaleFactor > 0)
461 if (
dict.readIfPresent(
"minQuality", minQuality_) && minQuality_ > 0)
464 <<
" : ignoring triangles with quality < "
465 << minQuality_ <<
" for normals calculation." <<
endl;
519 const point& fc = centres[facei];
522 const point& pt = pts[
f[fp]];
548 return !indices.
empty();
566 if (edgeTree_.empty())
625 if (regions_.empty())
630 regions_[regionI] =
patches()[regionI].name();
639 if (surfaceClosed_ == -1)
641 if (isSurfaceClosed())
651 return surfaceClosed_ == 1;
749 if (minQuality_ >= 0)
760 label facei = info[i].index();
761 normal[i] =
s[facei].area(pts);
763 scalar qual =
s[facei].tri(pts).quality();
765 if (qual < minQuality_)
768 const labelList& fFaces = faceFaces[facei];
772 label nbrI = fFaces[j];
773 scalar nbrQual =
s[nbrI].tri(pts).quality();
777 normal[i] =
s[nbrI].area(pts);
782 normal[i] /=
mag(normal[i]) + vSmall;
797 label facei = info[i].index();
802 normal[i] =
s[facei].normal(pts);
829 if (!tree().bb().contains(pt))
832 volType[pointi] = tree().shapes().getVolumeType(tree(), pt);
837 volType[pointi] = tree().getVolumeType(pt);
867 fldPtr.
ptr()->store();
877 if (foundObject<triSurfaceLabelField>(
"values"))
890 values[i] =
fld[info[i].index()];
929 Foam::triSurface::write(fullPath);
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
friend class iterator
Declare friendship with the iterator.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const word & name() const
Return name.
streamFormat
Enumeration for the format of data in the stream.
compressionType
Enumeration for the format of data in the stream.
label size() const
Return the number of elements in the UList.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
A list of faces which address into the list of points.
const Field< PointType > & points() const
Return reference to global points.
std::remove_reference< ::Foam::List< labelledTri > >::type::value_type FaceType
A List obtained as a section of another List.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
T & operator[](const label)
Return element of UList.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
T * ptr()
Return object pointer for reuse.
A bounding box defined in terms of the points at its extremities.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
A class for handling file names.
bool isAbsolute() const
Return true if file name is absolute.
fileName path() const
Return directory path name (part before last /)
virtual fileName filePath(const bool globalFile, const IOobject &) const =0
Search for an object. globalFile : also check undecomposed case.
Non-pointer based hierarchical recursive searching.
static scalar & perturbTol()
Get the perturbation tolerance.
Triangle with additional region number.
Registry of regIOobjects.
const Time & time() const
Return time.
fileName objectPath() const
Return complete path + object name.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
static const word & geometryDir()
Return the geometry directory name.
const boundBox & bounds() const
Return const reference to boundBox.
A surface geometry formed of discrete facets, e.g. triangles and/or quadrilaterals,...
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
const indexedOctree< treeDataEdge > & edgeTree() const
Demand driven construction of octree for boundary edges.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared). Any point.
virtual void setField(const labelList &values)
WIP. Store element-wise field.
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp, const bool write=true) const
Write using given format, version and compression.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
virtual const wordList & regions() const
Names of regions.
virtual bool hasVolumeType() const
Whether supports volume type below. I.e. whether is closed.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
virtual ~triSurface()
Destructor.
void clearOut()
Clear storage.
virtual void setPoints(const pointField &)
Move points.
virtual tmp< pointField > points() const
Get the points that define the surface.
string & expand(const bool allowEmpty=false)
Expand initial tildes and all occurrences of environment variables.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
Standard boundBox + extra functionality for use in octree.
treeBoundBox extend(const scalar s) const
Return asymmetrically extended bounding box, with guaranteed.
Holds data for octree to work on an edges subset.
Helper class to search on triSurface. Creates an octree for each region of the surface and only searc...
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.
void clearOut()
Clear storage.
void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &info) const
Calculate all intersections from start to end.
void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
void findNearest(const pointField &samples, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
Triangulated surface description with patch information.
virtual void scalePoints(const scalar)
Scale points. A non-positive factor is ignored.
triSurface()
Construct null.
virtual void setPoints(const pointField &)
Move points.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;{ pointField positions(particles.size());label particlei=0;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter) { positions[particlei++]=iter().position(mesh);} for(i=0;i< pTraits< point >::nComponents;i++) { forAll(positions, particlei) { gmvFile<< component(positions[particlei], i)<< ' ';} gmvFile<< nl;}}forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const fvPatchList & patches
addToRunTimeSelectionTable(searchableSurface, box, dictionary)
defineTypeNameAndDebug(box, 0)
addBackwardCompatibleToRunTimeSelectionTable(searchableSurface, box, dictionary, searchableBox, "searchableBox")
barycentric coordinates(const polyMesh &mesh, const point &position, const label celli, const label facei, const label faceTrii, const scalar stepFraction)
Return the coordinates given the position and tet topology.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist as a file in the file system?
const fileOperation & fileHandler()
Get current file handler.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
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 mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const dimensionSet dimless
bool exists(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist (as directory or file) in the file system?
vectorField pointField
pointField is a vectorField.
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
List< labelList > labelListList
A List of labelList.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Field< label > labelField
Specialisation of Field<T> for label.
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
void magSqr(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
void invertManyToMany(const label len, const UList< InList > &, List< OutList > &)
Invert many-to-many.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=*(cellModeller::lookup("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, &mergedCyclicPolyPatch::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]
scalarField samples(nIntervals, 0)