64 auto fnd = facesPerEdge.
find(
e);
67 label&
count = fnd.val();
77 <<
"Incorrect matched edge " << fnd.key()
103 Pout<<
"triSurfaceMesh::isSurfaceClosed:" 104 <<
" determining closedness for surface with " 212 const triSurface& ts = *
this;
213 EdgeMap<label> facesPerEdge(2*ts.size());
214 for (
const auto&
f : ts)
219 const bool okFace = addFaceToEdge(
f.edge(fp), facesPerEdge);
225 Pout<<
"triSurfaceMesh::isSurfaceClosed :" 226 <<
" surface is non-manifold" <<
endl;
235 bool haveWarned =
false;
238 if (iter.val() != 2 && iter.val() != -1)
242 Pout<<
"triSurfaceMesh::isSurfaceClosed :" 243 <<
" surface is open" <<
endl;
252 if (iter.val() == -1)
259 <<
" is closed but has inconsistent face orientation" 261 <<
" at edge " <<
pts[iter.key().first()]
262 <<
pts[iter.key().second()]
264 <<
" This means it probably cannot be used" 265 <<
" for inside/outside queries." 266 <<
" Suppressing further messages." <<
endl;
276 Pout<<
"triSurfaceMesh::isSurfaceClosed :" 277 <<
" surface is closed" <<
endl;
371 static_cast<const searchableSurface&>(*
this),
379 scalar scaleFactor{0};
380 if (
dict.getOrDefault(
"scale", scaleFactor) && scaleFactor > 0)
383 <<
" : using scale " << scaleFactor <<
endl;
392 <<
" : ignoring triangles with quality < " 401 searchableSurface(
io),
408 searchableSurface::instance(),
417 triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
420 outsideVolType_(volumeType::UNKNOWN)
427 const fileName actualFile
430 ?
io.globalFilePath(typeName)
431 :
io.localFilePath(typeName)
441 Pout<<
"triSurfaceMesh(const IOobject& io) :" 442 <<
" loading surface " <<
io.objectPath()
443 <<
" local filePath:" <<
io.localFilePath(typeName)
444 <<
" from:" << actualFile <<
endl;
450 const fileName localFile(
io.localFilePath(typeName));
455 && ((actualFile.empty() || actualFile != localFile))
467 Pout<<
"triSurfaceMesh(const IOobject& io) :" 478 Pout<<
"triSurfaceMesh(const IOobject& io) :" 490 Pout<<
"triSurfaceMesh(const IOobject& io) :" 534 const scalar scaleFactor(
dict.getOrDefault<scalar>(
"scale", 0));
541 ?
io.globalFilePath(typeName)
542 :
io.localFilePath(typeName)
555 static_cast<const searchableSurface&>(*
this),
564 Pout<<
"triSurfaceMesh(const IOobject& io, const dictionary&) :" 565 <<
" loading surface " <<
io.objectPath()
566 <<
" local filePath:" <<
io.localFilePath(typeName)
567 <<
" from:" << actualFile <<
endl;
578 const fileName localFile(
io.localFilePath(typeName));
583 && ((actualFile.empty() || actualFile != localFile))
590 triSurface s2(actualFile, surfType, scaleFactor);
596 Pout<<
"triSurfaceMesh(const IOobject& io) :" 603 triSurface s2(actualFile, surfType, scaleFactor);
607 Pout<<
"triSurfaceMesh(const IOobject& io) :" 615 triSurface s2(actualFile, surfType, scaleFactor);
619 Pout<<
"triSurfaceMesh(const IOobject& io) :" 630 <<
" : using scale " << scaleFactor <<
endl;
641 <<
" : ignoring triangles with quality < " 669 auto&
pts = tpts.ref();
708 const point& fc = centres[facei];
709 for (
const label pointi :
f)
711 radiusSqr[facei] =
max(radiusSqr[facei], fc.distSqr(
pts[pointi]));
740 Pout<<
"triSurfaceMesh::movePoints :" 751 const label
event = getEvent();
763 Pout<<
"triSurfaceMesh::movePoints: finished moving points" <<
endl;
775 Pout<<
"triSurfaceMesh::edgeTree :" 776 <<
" constructing tree for " << nEdges() - nInternalEdges()
777 <<
" boundary edges" <<
endl;
781 const labelRange bEdges(nInternalEdges(), nBoundaryEdges());
807 Pout<<
"triSurfaceMesh::edgeTree : " 808 <<
"calculating edge tree for bb:" << bb <<
endl;
811 const scalar oldTol =
832 Pout<<
"triSurfaceMesh::edgeTree :" 833 <<
" finished constructing tree for " 834 << nEdges() - nInternalEdges()
835 <<
" boundary edges" <<
endl;
845 if (regions_.empty())
859 if (surfaceClosed_ == -1)
861 if (isSurfaceClosed())
871 return surfaceClosed_ == 1;
880 const point outsidePt(bounds().
max() + 0.5*bounds().span());
884 Pout<<
"triSurfaceMesh::outsideVolumeType :" 885 <<
" triggering outsidePoint:" << outsidePt
886 <<
" orientation" <<
endl;
893 getVolumeType(
pointField(1, outsidePt), outsideVolTypes);
894 outsideVolType_ = outsideVolTypes[0];
898 Pout<<
"triSurfaceMesh::outsideVolumeType :" 899 <<
" finished outsidePoint:" << outsidePt
905 return outsideVolType_;
918 Pout<<
"triSurfaceMesh::findNearest :" 919 <<
" trying to find nearest for " <<
samples.
size()
920 <<
" samples with max sphere " 927 Pout<<
"triSurfaceMesh::findNearest :" 928 <<
" finished trying to find nearest for " <<
samples.
size()
929 <<
" samples" <<
endl;
944 Pout<<
"triSurfaceMesh::findNearest :" 945 <<
" trying to find nearest and region for " <<
samples.
size()
946 <<
" samples with max sphere " 959 Pout<<
"triSurfaceMesh::findNearest :" 960 <<
" finished trying to find nearest and region for " 975 Pout<<
"triSurfaceMesh::findLine :" 976 <<
" intersecting with " 982 Pout<<
"triSurfaceMesh::findLine :" 983 <<
" finished intersecting with " 998 Pout<<
"triSurfaceMesh::findLineAny :" 999 <<
" intersecting with " 1000 << start.
size() <<
" rays" <<
endl;
1005 Pout<<
"triSurfaceMesh::findLineAny :" 1006 <<
" finished intersecting with " 1007 << start.
size() <<
" rays" <<
endl;
1021 Pout<<
"triSurfaceMesh::findLineAll :" 1022 <<
" intersecting with " 1023 << start.
size() <<
" rays" <<
endl;
1028 Pout<<
"triSurfaceMesh::findLineAll :" 1029 <<
" finished intersecting with " 1030 << start.
size() <<
" rays" <<
endl;
1043 Pout<<
"triSurfaceMesh::getRegion :" 1044 <<
" getting region for " 1045 << info.
size() <<
" triangles" <<
endl;
1061 Pout<<
"triSurfaceMesh::getRegion :" 1062 <<
" finished getting region for " 1063 << info.
size() <<
" triangles" <<
endl;
1076 Pout<<
"triSurfaceMesh::getNormal :" 1077 <<
" getting normal for " 1078 << info.
size() <<
" triangles" <<
endl;
1081 const triSurface&
s = *
this;
1086 if (minQuality_ >= 0)
1097 const label facei = info[i].index();
1098 normal[i] =
s[facei].unitNormal(
pts);
1100 scalar qual =
s[facei].tri(
pts).quality();
1102 if (qual < minQuality_)
1105 const labelList& fFaces = faceFaces[facei];
1107 for (
const label nbri : fFaces)
1109 scalar nbrQual =
s[nbri].tri(
pts).quality();
1113 normal[i] =
s[nbri].unitNormal(
pts);
1131 const label facei = info[i].index();
1134 normal[i] =
s[facei].unitNormal(
pts);
1145 Pout<<
"triSurfaceMesh::getNormal :" 1146 <<
" finished getting normal for " 1147 << info.
size() <<
" triangles" <<
endl;
1154 auto* fldPtr = getObjectPtr<triSurfaceLabelField>(
"values");
1158 (*fldPtr).field() =
values;
1184 Pout<<
"triSurfaceMesh::setField :" 1185 <<
" finished setting field for " 1197 const auto* fldPtr = getObjectPtr<triSurfaceLabelField>(
"values");
1201 const auto&
fld = *fldPtr;
1215 Pout<<
"triSurfaceMesh::setField :" 1216 <<
" finished getting field for " 1217 << info.
size() <<
" triangles" <<
endl;
1228 const scalar oldTol =
1233 Pout<<
"triSurfaceMesh::getVolumeType :" 1234 <<
" finding orientation for " <<
points.
size()
1235 <<
" samples" <<
endl;
1244 if (
tree().bb().contains(pt))
1247 volType[pointi] =
tree().getVolumeType(pt);
1249 else if (hasVolumeType())
1254 outsideVolType_ =
tree().shapes().getVolumeType(
tree(), pt);
1256 volType[pointi] = outsideVolType_;
1261 volType[pointi] =
tree().shapes().getVolumeType(
tree(), pt);
1269 Pout<<
"triSurfaceMesh::getVolumeType :" 1270 <<
" finished finding orientation for " <<
points.
size()
1271 <<
" samples" <<
endl;
1279 const bool writeOnProc
1294 const_cast<triSurfaceMesh&
>(*this).searchableSurface::instance() =
1308 if (!fullPath.isAbsolute())
1319 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.
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.
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")
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
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.
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 List obtained as a section of another List.
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.
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.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
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)