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)
436 Pout<<
"triSurfaceMesh(const IOobject& io) :" 437 <<
" loading surface " <<
io.objectPath()
438 <<
" local filePath:" <<
io.localFilePath(typeName)
439 <<
" from:" << actualFile <<
endl;
445 const fileName localFile(
io.localFilePath(typeName));
450 && ((actualFile.empty() || actualFile != localFile))
462 Pout<<
"triSurfaceMesh(const IOobject& io) :" 473 Pout<<
"triSurfaceMesh(const IOobject& io) :" 485 Pout<<
"triSurfaceMesh(const IOobject& io) :" 529 const scalar scaleFactor(
dict.getOrDefault<scalar>(
"scale", 0));
536 ?
io.globalFilePath(typeName)
537 :
io.localFilePath(typeName)
545 static_cast<const searchableSurface&>(*
this),
554 Pout<<
"triSurfaceMesh(const IOobject& io, const dictionary&) :" 555 <<
" loading surface " <<
io.objectPath()
556 <<
" local filePath:" <<
io.localFilePath(typeName)
557 <<
" from:" << actualFile <<
endl;
568 const fileName localFile(
io.localFilePath(typeName));
573 && ((actualFile.empty() || actualFile != localFile))
580 triSurface s2(actualFile, surfType, scaleFactor);
586 Pout<<
"triSurfaceMesh(const IOobject& io) :" 593 triSurface s2(actualFile, surfType, scaleFactor);
597 Pout<<
"triSurfaceMesh(const IOobject& io) :" 605 triSurface s2(actualFile, surfType, scaleFactor);
609 Pout<<
"triSurfaceMesh(const IOobject& io) :" 620 <<
" : using scale " << scaleFactor <<
endl;
631 <<
" : ignoring triangles with quality < " 659 auto&
pts = tpts.ref();
698 const point& fc = centres[facei];
699 for (
const label pointi :
f)
701 radiusSqr[facei] =
max(radiusSqr[facei], fc.distSqr(
pts[pointi]));
730 Pout<<
"triSurfaceMesh::movePoints :" 741 const label
event = getEvent();
753 Pout<<
"triSurfaceMesh::movePoints: finished moving points" <<
endl;
765 Pout<<
"triSurfaceMesh::edgeTree :" 766 <<
" constructing tree for " << nEdges() - nInternalEdges()
767 <<
" boundary edges" <<
endl;
771 const labelRange bEdges(nInternalEdges(), nBoundaryEdges());
797 Pout<<
"triSurfaceMesh::edgeTree : " 798 <<
"calculating edge tree for bb:" << bb <<
endl;
801 const scalar oldTol =
822 Pout<<
"triSurfaceMesh::edgeTree :" 823 <<
" finished constructing tree for " 824 << nEdges() - nInternalEdges()
825 <<
" boundary edges" <<
endl;
835 if (regions_.empty())
849 if (surfaceClosed_ == -1)
851 if (isSurfaceClosed())
861 return surfaceClosed_ == 1;
870 const point outsidePt(bounds().
max() + 0.5*bounds().span());
874 Pout<<
"triSurfaceMesh::outsideVolumeType :" 875 <<
" triggering outsidePoint:" << outsidePt
876 <<
" orientation" <<
endl;
883 getVolumeType(
pointField(1, outsidePt), outsideVolTypes);
884 outsideVolType_ = outsideVolTypes[0];
888 Pout<<
"triSurfaceMesh::outsideVolumeType :" 889 <<
" finished outsidePoint:" << outsidePt
895 return outsideVolType_;
908 Pout<<
"triSurfaceMesh::findNearest :" 909 <<
" trying to find nearest for " <<
samples.
size()
910 <<
" samples with max sphere " 917 Pout<<
"triSurfaceMesh::findNearest :" 918 <<
" finished trying to find nearest for " <<
samples.
size()
919 <<
" samples" <<
endl;
934 Pout<<
"triSurfaceMesh::findNearest :" 935 <<
" trying to find nearest and region for " <<
samples.
size()
936 <<
" samples with max sphere " 949 Pout<<
"triSurfaceMesh::findNearest :" 950 <<
" finished trying to find nearest and region for " 965 Pout<<
"triSurfaceMesh::findLine :" 966 <<
" intersecting with " 972 Pout<<
"triSurfaceMesh::findLine :" 973 <<
" finished intersecting with " 988 Pout<<
"triSurfaceMesh::findLineAny :" 989 <<
" intersecting with " 995 Pout<<
"triSurfaceMesh::findLineAny :" 996 <<
" finished intersecting with " 1011 Pout<<
"triSurfaceMesh::findLineAll :" 1012 <<
" intersecting with " 1013 << start.
size() <<
" rays" <<
endl;
1018 Pout<<
"triSurfaceMesh::findLineAll :" 1019 <<
" finished intersecting with " 1020 << start.
size() <<
" rays" <<
endl;
1033 Pout<<
"triSurfaceMesh::getRegion :" 1034 <<
" getting region for " 1035 << info.
size() <<
" triangles" <<
endl;
1051 Pout<<
"triSurfaceMesh::getRegion :" 1052 <<
" finished getting region for " 1053 << info.
size() <<
" triangles" <<
endl;
1066 Pout<<
"triSurfaceMesh::getNormal :" 1067 <<
" getting normal for " 1068 << info.
size() <<
" triangles" <<
endl;
1071 const triSurface&
s = *
this;
1076 if (minQuality_ >= 0)
1087 const label facei = info[i].index();
1088 normal[i] =
s[facei].unitNormal(
pts);
1090 scalar qual =
s[facei].tri(
pts).quality();
1092 if (qual < minQuality_)
1095 const labelList& fFaces = faceFaces[facei];
1097 for (
const label nbri : fFaces)
1099 scalar nbrQual =
s[nbri].tri(
pts).quality();
1103 normal[i] =
s[nbri].unitNormal(
pts);
1121 const label facei = info[i].index();
1124 normal[i] =
s[facei].unitNormal(
pts);
1135 Pout<<
"triSurfaceMesh::getNormal :" 1136 <<
" finished getting normal for " 1137 << info.
size() <<
" triangles" <<
endl;
1144 auto* fldPtr = getObjectPtr<triSurfaceLabelField>(
"values");
1148 (*fldPtr).field() =
values;
1173 Pout<<
"triSurfaceMesh::setField :" 1174 <<
" finished setting field for " 1186 const auto* fldPtr = getObjectPtr<triSurfaceLabelField>(
"values");
1190 const auto&
fld = *fldPtr;
1204 Pout<<
"triSurfaceMesh::setField :" 1205 <<
" finished getting field for " 1206 << info.
size() <<
" triangles" <<
endl;
1217 const scalar oldTol =
1222 Pout<<
"triSurfaceMesh::getVolumeType :" 1223 <<
" finding orientation for " <<
points.
size()
1224 <<
" samples" <<
endl;
1233 if (
tree().bb().contains(pt))
1236 volType[pointi] =
tree().getVolumeType(pt);
1238 else if (hasVolumeType())
1243 outsideVolType_ =
tree().shapes().getVolumeType(
tree(), pt);
1245 volType[pointi] = outsideVolType_;
1250 volType[pointi] =
tree().shapes().getVolumeType(
tree(), pt);
1258 Pout<<
"triSurfaceMesh::getVolumeType :" 1259 <<
" finished finding orientation for " <<
points.
size()
1260 <<
" samples" <<
endl;
1283 const_cast<triSurfaceMesh&
>(*this).searchableSurface::instance() =
1297 if (!fullPath.isAbsolute())
1308 if (!
mkDir(fullPath.path()))
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.
List< labelList > labelListList
A List of labelList.
Field< label > labelField
Specialisation of Field<T> for label.
void size(const label n)
Older name for setAddressableSize.
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
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 the UList 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.
Foam::DimensionedField< label, triSurfaceGeoMesh > triSurfaceLabelField
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.
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 processes in communicator.
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()
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
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 INVALID.
An edge is a list of two point labels. The functionality it provides supports the discretisation 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.
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 time name of given scalar time formatted with the given precision.
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.
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
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...
const Time & time() const
Return Time associated with the objectRegistry.
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)
Am I the master rank.
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)
label size() const noexcept
The number of elements in the UList.
List< label > labelList
A List of labels.
IntType size() const noexcept
The size of the range.
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...
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.
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)