46 const regIOobject& io,
50 const fileName fName(io.filePath(typeName, isGlobal));
55 <<
"Cannot find triSurfaceMesh file starting from "
65 const regIOobject& io,
72 if (!fName.isAbsolute())
91 const regIOobject& io,
92 const dictionary&
dict,
96 fileName dictFName, fName;
100 fName = relativeFilePath(io, dictFName, isGlobal);
105 <<
"Cannot find triSurfaceMesh file " << io.path()/dictFName
111 fName = io.filePath(typeName, isGlobal);
116 <<
"Cannot find triSurfaceMesh file starting from "
125 bool Foam::triSurfaceMesh::addFaceToEdge
128 EdgeMap<label>& facesPerEdge
132 if (eFnd != facesPerEdge.end())
142 facesPerEdge.insert(
e, 1);
148 bool Foam::triSurfaceMesh::isSurfaceClosed()
const
161 EdgeMap<label> facesPerEdge(100);
162 forAll(pointFaces, pointi)
166 facesPerEdge.clear();
180 if (nextPointi > pointi)
182 bool okFace = addFaceToEdge
184 edge(pointi, nextPointi),
196 if (prevPointi > pointi)
198 bool okFace = addFaceToEdge
200 edge(pointi, prevPointi),
314 dict.lookup(
"file", false, false),
321 scalar scaleFactor = 0;
325 if (
dict.readIfPresent(
"scale", scaleFactor) && scaleFactor > 0)
337 if (
dict.readIfPresent(
"minQuality", minQuality_) && minQuality_ > 0)
340 <<
" : ignoring triangles with quality < "
341 << minQuality_ <<
" for normals calculation." <<
endl;
409 if (
dict.readIfPresent(
"file", fName_,
false,
false))
411 fName_ = relativeFilePath
419 scalar scaleFactor = 0;
423 if (
dict.readIfPresent(
"scale", scaleFactor) && scaleFactor > 0)
435 if (
dict.readIfPresent(
"minQuality", minQuality_) && minQuality_ > 0)
438 <<
" : ignoring triangles with quality < "
439 << minQuality_ <<
" for normals calculation." <<
endl;
483 centres = coordinates();
492 const point& fc = centres[facei];
495 const point& pt = pts[
f[fp]];
517 return !indices.
empty();
532 if (edgeTree_.empty())
591 if (regions_.empty())
596 regions_[regionI] =
patches()[regionI].name();
605 if (surfaceClosed_ == -1)
607 if (isSurfaceClosed())
617 return surfaceClosed_ == 1;
715 if (minQuality_ >= 0)
726 label facei = info[i].index();
727 normal[i] =
s[facei].area(pts);
729 scalar qual =
s[facei].tri(pts).quality();
731 if (qual < minQuality_)
734 const labelList& fFaces = faceFaces[facei];
738 label nbrI = fFaces[j];
739 scalar nbrQual =
s[nbrI].tri(pts).quality();
743 normal[i] =
s[nbrI].area(pts);
748 normal[i] /=
mag(normal[i]) + vSmall;
763 label facei = info[i].index();
768 normal[i] =
s[facei].normal(pts);
795 if (!tree().bb().contains(pt))
798 volType[pointi] = tree().shapes().getVolumeType(tree(), pt);
803 volType[pointi] = tree().getVolumeType(pt);
833 fldPtr.
ptr()->store();
843 if (foundObject<triSurfaceLabelField>(
"values"))
856 values[i] =
fld[info[i].index()];
895 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.
label rcIndex(const label i) const
Return the reverse circular index, i.e. the previous index.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
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 keyword definitions, which are a keyword followed by any number of values (e....
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
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 word &typeName) 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.
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.
A surface geometry formed of discrete facets, e.g. triangles and/or quadrilaterals,...
triSurfaceMesh(const IOobject &, const triSurface &)
Construct from triSurface.
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
virtual ~triSurfaceMesh()
Destructor.
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.
void clearOut()
Clear storage.
virtual void setPoints(const pointField &)
Move points.
virtual tmp< pointField > points() const
Get the points that define the surface.
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.
virtual void setPoints(const pointField &)
Move points.
static const word null
An empty word.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;{ pointField positions(particles.size());label particlei=0;forAllConstIter(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(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
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.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const fvPatchList & patches
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.
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
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.
word name(const bool)
Return a word representation of a bool.
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.
List< labelList > labelListList
A List of labelList.
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Field< label > labelField
Specialisation of Field<T> for label.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
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)