64 auto fnd = facesPerEdge.
find(
e);
67 label&
count = fnd.val();
77 <<
"Incorrect matched edge " << fnd.key()
103 Pout<<
"triSurfaceMesh::isSurfaceClosed:" 105 <<
" determining closedness for surface with " 213 const triSurface& ts = *
this;
214 EdgeMap<label> facesPerEdge(2*ts.size());
215 for (
const auto&
f : ts)
220 const bool okFace = addFaceToEdge(
f.edge(fp), facesPerEdge);
226 Pout<<
"triSurfaceMesh::isSurfaceClosed :" 228 <<
" surface is non-manifold" <<
endl;
237 bool haveWarned =
false;
240 if (iter.val() != 2 && iter.val() != -1)
244 Pout<<
"triSurfaceMesh::isSurfaceClosed :" 246 <<
" surface is open" <<
endl;
255 if (iter.val() == -1)
262 <<
" is closed but has inconsistent face orientation" 264 <<
" at edge " <<
pts[iter.key().first()]
265 <<
pts[iter.key().second()]
267 <<
" This means it probably cannot be used" 268 <<
" for inside/outside queries." 269 <<
" Suppressing further messages." <<
endl;
279 Pout<<
"triSurfaceMesh::isSurfaceClosed :" 281 <<
" surface is closed" <<
endl;
375 static_cast<const searchableSurface&>(*
this),
383 scalar scaleFactor{0};
384 if (
dict.getOrDefault(
"scale", scaleFactor) && scaleFactor > 0)
387 <<
" : using scale " << scaleFactor <<
endl;
396 <<
" : ignoring triangles with quality < " 405 searchableSurface(
io),
412 searchableSurface::instance(),
421 triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
424 outsideVolType_(volumeType::UNKNOWN)
431 const fileName actualFile
434 ?
io.globalFilePath(typeName)
435 :
io.localFilePath(typeName)
445 Pout<<
"triSurfaceMesh(const IOobject& io) :" 446 <<
" loading surface " <<
io.objectPath()
447 <<
" local filePath:" <<
io.localFilePath(typeName)
448 <<
" from:" << actualFile <<
endl;
454 const fileName localFile(
io.localFilePath(typeName));
459 && ((actualFile.empty() || actualFile != localFile))
471 Pout<<
"triSurfaceMesh(const IOobject& io) :" 482 Pout<<
"triSurfaceMesh(const IOobject& io) :" 494 Pout<<
"triSurfaceMesh(const IOobject& io) :" 538 const scalar scaleFactor(
dict.getOrDefault<scalar>(
"scale", 0));
545 ?
io.globalFilePath(typeName)
546 :
io.localFilePath(typeName)
559 static_cast<const searchableSurface&>(*
this),
568 Pout<<
"triSurfaceMesh(const IOobject& io, const dictionary&) :" 569 <<
" loading surface " <<
io.objectPath()
570 <<
" local filePath:" <<
io.localFilePath(typeName)
571 <<
" from:" << actualFile <<
endl;
582 const fileName localFile(
io.localFilePath(typeName));
587 && ((actualFile.empty() || actualFile != localFile))
594 triSurface s2(actualFile, surfType, scaleFactor);
600 Pout<<
"triSurfaceMesh(const IOobject& io) :" 607 triSurface s2(actualFile, surfType, scaleFactor);
611 Pout<<
"triSurfaceMesh(const IOobject& io) :" 619 triSurface s2(actualFile, surfType, scaleFactor);
623 Pout<<
"triSurfaceMesh(const IOobject& io) :" 634 <<
" : using scale " << scaleFactor <<
endl;
645 <<
" : ignoring triangles with quality < " 673 auto&
pts = tpts.ref();
712 const point& fc = centres[facei];
713 for (
const label pointi :
f)
715 radiusSqr[facei] =
max(radiusSqr[facei], fc.distSqr(
pts[pointi]));
744 Pout<<
"triSurfaceMesh::movePoints :" 756 const label
event = getEvent();
768 Pout<<
"triSurfaceMesh::movePoints: finished moving points" <<
endl;
780 Pout<<
"triSurfaceMesh::edgeTree :" 782 <<
" constructing tree for " << nEdges() - nInternalEdges()
783 <<
" boundary edges" <<
endl;
787 const labelRange bEdges(nInternalEdges(), nBoundaryEdges());
813 Pout<<
"triSurfaceMesh::edgeTree : " 814 <<
"calculating edge tree for bb:" << bb <<
endl;
817 const scalar oldTol =
838 Pout<<
"triSurfaceMesh::edgeTree :" 839 <<
" finished constructing tree for " 840 << nEdges() - nInternalEdges()
841 <<
" boundary edges" <<
endl;
851 if (regions_.empty())
865 if (surfaceClosed_ == -1)
867 if (isSurfaceClosed())
877 return surfaceClosed_ == 1;
886 const point outsidePt(bounds().
max() + 0.5*bounds().span());
890 Pout<<
"triSurfaceMesh::outsideVolumeType :" 892 <<
" triggering outsidePoint:" << outsidePt
893 <<
" orientation" <<
endl;
900 getVolumeType(
pointField(1, outsidePt), outsideVolTypes);
901 outsideVolType_ = outsideVolTypes[0];
905 Pout<<
"triSurfaceMesh::outsideVolumeType :" 906 <<
" finished outsidePoint:" << outsidePt
912 return outsideVolType_;
920 Pout<<
"triSurfaceMesh::flip :" 922 <<
" with current orientation " 931 triSurface&
s = *
this;
968 Pout<<
"triSurfaceMesh::findNearest :" 970 <<
" trying to find nearest for " <<
samples.
size()
971 <<
" samples with max sphere " 978 Pout<<
"triSurfaceMesh::findNearest :" 979 <<
" finished trying to find nearest for " <<
samples.
size()
980 <<
" samples" <<
endl;
995 Pout<<
"triSurfaceMesh::findNearest :" 997 <<
" trying to find nearest and region for " <<
samples.
size()
998 <<
" samples with max sphere " 1011 Pout<<
"triSurfaceMesh::findNearest :" 1012 <<
" finished trying to find nearest and region for " 1027 Pout<<
"triSurfaceMesh::findLine :" 1029 <<
" intersecting with " 1030 << start.
size() <<
" rays" <<
endl;
1035 Pout<<
"triSurfaceMesh::findLine :" 1036 <<
" finished intersecting with " 1037 << start.
size() <<
" rays" <<
endl;
1051 Pout<<
"triSurfaceMesh::findLineAny :" 1053 <<
" intersecting with " 1054 << start.
size() <<
" rays" <<
endl;
1059 Pout<<
"triSurfaceMesh::findLineAny :" 1060 <<
" finished intersecting with " 1061 << start.
size() <<
" rays" <<
endl;
1075 Pout<<
"triSurfaceMesh::findLineAll :" 1077 <<
" intersecting with " 1078 << start.
size() <<
" rays" <<
endl;
1083 Pout<<
"triSurfaceMesh::findLineAll :" 1084 <<
" finished intersecting with " 1085 << start.
size() <<
" rays" <<
endl;
1098 Pout<<
"triSurfaceMesh::getRegion :" 1100 <<
" getting region for " 1101 << info.
size() <<
" triangles" <<
endl;
1117 Pout<<
"triSurfaceMesh::getRegion :" 1118 <<
" finished getting region for " 1119 << info.
size() <<
" triangles" <<
endl;
1132 Pout<<
"triSurfaceMesh::getNormal :" 1134 <<
" getting normal for " 1135 << info.
size() <<
" triangles" <<
endl;
1138 const triSurface&
s = *
this;
1143 if (minQuality_ >= 0)
1154 const label facei = info[i].index();
1155 normal[i] =
s[facei].unitNormal(
pts);
1157 scalar qual =
s[facei].tri(
pts).quality();
1159 if (qual < minQuality_)
1162 const labelList& fFaces = faceFaces[facei];
1164 for (
const label nbri : fFaces)
1166 scalar nbrQual =
s[nbri].tri(
pts).quality();
1170 normal[i] =
s[nbri].unitNormal(
pts);
1188 const label facei = info[i].index();
1191 normal[i] =
s[facei].unitNormal(
pts);
1202 Pout<<
"triSurfaceMesh::getNormal :" 1203 <<
" finished getting normal for " 1204 << info.
size() <<
" triangles" <<
endl;
1211 auto* fldPtr = getObjectPtr<triSurfaceLabelField>(
"values");
1215 (*fldPtr).field() =
values;
1241 Pout<<
"triSurfaceMesh::setField :" 1243 <<
" finished setting field for " 1255 const auto* fldPtr = getObjectPtr<triSurfaceLabelField>(
"values");
1259 const auto&
fld = *fldPtr;
1273 Pout<<
"triSurfaceMesh::setField :" 1275 <<
" finished getting field for " 1276 << info.
size() <<
" triangles" <<
endl;
1287 const scalar oldTol =
1292 Pout<<
"triSurfaceMesh::getVolumeType :" 1294 <<
" finding orientation for " <<
points.
size()
1295 <<
" samples" <<
endl;
1304 if (
tree().bb().contains(pt))
1307 volType[pointi] =
tree().getVolumeType(pt);
1309 else if (hasVolumeType())
1314 outsideVolType_ =
tree().shapes().getVolumeType(
tree(), pt);
1316 volType[pointi] = outsideVolType_;
1321 volType[pointi] =
tree().shapes().getVolumeType(
tree(), pt);
1329 Pout<<
"triSurfaceMesh::getVolumeType :" 1330 <<
" finished finding orientation for " <<
points.
size()
1331 <<
" samples" <<
endl;
1339 const bool writeOnProc
1354 const_cast<triSurfaceMesh&
>(*this).searchableSurface::instance() =
1368 if (!fullPath.isAbsolute())
1379 if (!
mkDir(fullPath.path()))
DimensionedField< label, triSurfaceGeoMesh > triSurfaceLabelField
static scalar & perturbTol() noexcept
Get the perturbation tolerance.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
Field< label > labelField
Specialisation of Field<T> for label.
void size(const label n)
Older name for setAddressableSize.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
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.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared). Any point.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const word & name() const noexcept
Return the object name.
void inflate(const scalar factor)
Expand box by factor*mag(span) in all dimensions.
virtual tmp< pointField > points() const
Get the points that define the surface.
virtual ~triSurfaceMesh()
Destructor.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
A range or interval of labels defined by a start and a size.
constexpr char nl
The newline '\n' character (0x0a)
label eventNo() const noexcept
Event number at last update.
bool empty() const noexcept
True if List is empty (ie, size() is zero)
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
virtual void movePoints(const pointField &pts)
Move points.
scalarField samples(nIntervals, Zero)
virtual void setField(const labelList &values)
WIP. Store element-wise field.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
static bool addFaceToEdge(const edge &, EdgeMap< label > &)
Helper function for isSurfaceClosed.
void transfer(triSurface &surf)
Alter contents by transferring (triangles, points) components.
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.
A bounding box defined in terms of min/max extrema points.
A simple container for options an IOstream can normally have.
static std::string path(const std::string &str)
Return directory path name (part before last /)
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
static void broadcast(Type &value, const int communicator=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
const dimensionSet dimless
Dimensionless.
An enumeration wrapper for classification of a location as being inside/outside of a volume...
bool isSurfaceClosed() const
Check whether surface is closed without calculating any permanent.
void flip()
Flip orientation.
virtual const boundBox & bounds() const
Return const reference to boundBox.
List< labelList > labelListList
List of labelList.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
void write(Ostream &os) const
Write to Ostream in simple OpenFOAM format.
fileName objectPath() const
The complete path + object name.
Macros for easy insertion into run-time selection tables.
static word meshSubDir
Return the mesh sub-directory name (usually "triSurface")
void findNearest(const pointField &samples, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
#define forAll(list, i)
Loop across all elements in list.
IOoject and searching on triSurface.
T & operator[](const label i)
Return element of UList.
fileName caseSystem() const
Return the system name for the case, which is ../system() for parallel runs.
virtual bool hasVolumeType() const
Whether supports volume type (below) - i.e. whether is closed.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
virtual void flip()
Flip triangles, outsideVolumeType and all cached inside/outside.
static fileName relativeFilePath(const IOobject &io, const fileName &f, const bool isGlobal=true)
Return fileName.
A list of faces which address into the list of points.
A non-owning sub-view of a List (allocated or unallocated storage).
const geometricSurfacePatchList & patches() const noexcept
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside/mixed) for point.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
label count(const char *clsName) const
The number of objects of the given class name.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &info) const
Calculate all intersections from start to end.
A class for handling words, derived from Foam::string.
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
const Time & time() const noexcept
Return time registry.
void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
const word & system() const noexcept
Return system name.
const Field< point_type > & faceCentres() const
Return face centres for patch.
Tree tree(triangles.begin(), triangles.end())
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
static const word null
An empty word.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
A triFace with additional (region) index.
const Field< point_type > & points() const noexcept
Return reference to global points.
A location inside the volume.
A location outside the volume.
const Time & time() const noexcept
Return Time associated with the objectRegistry.
fileName caseConstant() const
Return the constant name for the case, which is ../constant() for parallel runs.
bool hasFaceCentres() const
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
label size() const noexcept
The number of elements in the container.
const indexedOctree< treeDataEdge > & edgeTree() const
Demand driven construction of octree for boundary edges.
const word & constant() const noexcept
Return constant name.
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
const fileName & instance() const noexcept
Read access to instance path component.
scalar minQuality_
Optional min triangle quality. Triangles below this get.
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 getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
triSurface()
Default construct.
PtrList< coordinateSystem > coordinates(solidRegions.size())
vector point
Point is a vector.
Non-pointer based hierarchical recursive searching.
#define WarningInFunction
Report a warning using Foam::Warning.
string & expand(const bool allowEmpty=false)
Inplace expand initial tags, tildes, and all occurrences of environment variables as per stringOps::e...
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
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.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
const polyBoundaryMesh & patches
Automatically write from objectRegistry::writeObject()
Standard boundBox with extra functionality for use in octree.
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< label > labelList
A List of labels.
IntType size() const noexcept
The size of the range.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
Registry of regIOobjects.
virtual volumeType outsideVolumeType() const
If surface is closed, what is type of points outside bounds.
triSurfaceMesh(const triSurfaceMesh &)=delete
No copy construct.
Triangulated surface description with patch information.
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))
fileName fName_
Supplied fileName override.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Request registration (bool: true)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
virtual const wordList & regions() const
Names of regions.
forAllConstIters(mixture.phases(), phase)
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static const Enum< volumeType::type > names
Names for the classification enumeration.
static int compare(const edge &a, const edge &b)
Compare edges.
static constexpr const zero Zero
Global zero (0)