Go to the documentation of this file.
58 << pre.c_str() <<
"vertex numbers:"
59 <<
f[0] <<
' ' <<
f[1] <<
' ' <<
f[2] <<
nl
61 << pre.c_str() <<
"vertex coords :"
64 << pre.c_str() <<
"region :" <<
f.region() <<
nl
83 for (i=ts.size()-1; i>=0; i--)
96 for (label j=i; j>=0; j--)
102 Pout<<
" triSurface::triSurfInstance(const Time& d)"
103 <<
"reading " << foamName
104 <<
" from " << ts[j].
name()/typeName
115 Pout<<
" triSurface::triSurfInstance(const Time& d)"
116 <<
"reading " << foamName
117 <<
" from constant/" <<
endl;
126 const label defaultRegion
133 const face&
f = faces[facei];
138 <<
"Face at position " << facei
139 <<
" does not have three vertices:" <<
f
143 labelledTri& tri = triFaces[facei];
148 tri.region() = defaultRegion;
158 const label defaultRegion
161 List<labelledTri> triFaces(faces.size());
167 labelledTri& tri = triFaces[facei];
172 tri.region() = defaultRegion;
185 const label maxPointi =
points().size() - 1;
187 for (
const auto&
f : *
this)
189 for (
const label verti :
f)
191 if (verti < 0 || verti > maxPointi)
195 <<
" uses point indices outside point range 0.."
208 bitSet valid(size(),
true);
214 if ((
f[0] ==
f[1]) || (
f[0] ==
f[2]) || (
f[1] ==
f[2]))
222 <<
"triangle " << facei
223 <<
" does not have three unique vertices:\n";
230 const labelList& fEdges = faceEdges()[facei];
235 for (
const label edgei : fEdges)
237 const labelList& eFaces = edgeFaces()[edgei];
239 for (
const label neighbour : eFaces)
241 if (neighbour > facei)
248 ((
f[0] ==
n[0]) || (
f[0] ==
n[1]) || (
f[0] ==
n[2]))
249 && ((
f[1] ==
n[0]) || (
f[1] ==
n[1]) || (
f[1] ==
n[2]))
250 && ((
f[2] ==
n[0]) || (
f[2] ==
n[1]) || (
f[2] ==
n[2]))
258 <<
"triangles share the same vertices:\n"
259 <<
" face 1 :" << facei <<
endl;
265 << neighbour <<
endl;
281 for (
const label facei : valid)
283 (*this)[newFacei++] = (*this)[facei];
289 <<
"Removing " << size() - newFacei
290 <<
" illegal faces." <<
endl;
292 (*this).setSize(newFacei);
307 const labelList& myFaces = eFaces[edgei];
312 <<
"Edge " << edgei <<
" with vertices " << edges()[edgei]
313 <<
" has no edgeFaces"
316 else if (myFaces.size() > 2 && verbose)
319 <<
"Edge " << edgei <<
" with vertices " << edges()[edgei]
320 <<
" has more than 2 faces connected to it : " << myFaces
338 regions[facei] = operator[](facei).region();
344 label maxRegion = patches_.size()-1;
351 operator[](
faceMap.last()).region()
361 label region = operator[](facei).region();
363 newPatches[region].size()++;
369 label startFacei = 0;
370 forAll(newPatches, newPatchi)
372 surfacePatch& newPatch = newPatches[newPatchi];
374 newPatch.index() = newPatchi;
375 newPatch.start() = startFacei;
380 newPatchi < patches_.size()
381 && !patches_[newPatchi].name().empty()
384 newPatch.name() = patches_[newPatchi].name();
393 newPatchi < patches_.size()
394 && !patches_[newPatchi].geometricType().empty()
397 newPatch.geometricType() = patches_[newPatchi].geometricType();
404 startFacei += newPatch.size();
411 void Foam::triSurface::setDefaultPatches()
419 patches_.setSize(newPatches.size());
421 forAll(newPatches, patchi)
423 patches_[patchi].index() = patchi;
424 patches_[patchi].name() = newPatches[patchi].name();
425 patches_[patchi].geometricType() = newPatches[patchi].geometricType();
436 sortedEdgeFacesPtr_(nullptr),
437 edgeOwnerPtr_(nullptr)
445 sortedEdgeFacesPtr_(nullptr),
446 edgeOwnerPtr_(nullptr)
467 sortedEdgeFacesPtr_(
nullptr),
468 edgeOwnerPtr_(
nullptr)
482 sortedEdgeFacesPtr_(
nullptr),
483 edgeOwnerPtr_(
nullptr)
495 sortedEdgeFacesPtr_(
nullptr),
496 edgeOwnerPtr_(
nullptr)
510 sortedEdgeFacesPtr_(
nullptr),
511 edgeOwnerPtr_(
nullptr)
520 const scalar scaleFactor
530 const word& fileType,
531 const scalar scaleFactor
537 scalePoints(scaleFactor);
554 MeshReference::clearTopology();
555 sortedEdgeFacesPtr_.reset(
nullptr);
556 edgeOwnerPtr_.reset(
nullptr);
562 MeshReference::clearPatchMeshAddr();
568 MeshReference::clearOut();
570 clearPatchMeshAddr();
592 if (!sortedEdgeFacesPtr_)
594 calcSortedEdgeFaces();
597 return *sortedEdgeFacesPtr_;
608 return *edgeOwnerPtr_;
615 sortedEdgeFacesPtr_.reset(
nullptr);
618 MeshReference::movePoints(pts);
621 storedPoints() = pts;
628 sortedEdgeFacesPtr_.reset(
nullptr);
631 MeshReference::movePoints(pts);
634 storedPoints().swap(pts);
641 if (scaleFactor > SMALL && scaleFactor != 1.0)
649 storedPoints() *= scaleFactor;
658 stitchTriangles(SMALL, verbose);
663 checkTriangles(verbose);
690 plainFaces[facei] = this->operator[](facei);
701 const label currentZone,
713 for (
const label facei : changedFaces)
715 const labelList& fEdges = faceEdges()[facei];
717 for (
const label edgei : fEdges)
719 if (!borderEdge[edgei])
721 const labelList& eFaces = edgeFaces()[edgei];
723 for (
const label nbrFacei : eFaces)
728 newChangedFaces.
append(nbrFacei);
730 else if (
faceZone[nbrFacei] != currentZone)
734 <<
" at face " << nbrFacei
735 <<
" connects to zone " << currentZone
736 <<
" at face " << facei
744 if (newChangedFaces.empty())
749 changedFaces.transfer(newChangedFaces);
765 if (borderEdge.size() != nEdges())
768 <<
"borderEdge boolList not same size as number of edges" <<
endl
769 <<
"borderEdge:" << borderEdge.size() <<
endl
770 <<
"nEdges :" << nEdges()
776 for (label startFacei = 0;; zoneI++)
779 for (; startFacei < size(); startFacei++)
787 if (startFacei >= size())
794 markZone(borderEdge, startFacei, zoneI,
faceZone);
814 labelList oldToNew(locPoints.size(), -1);
817 oldToNew[pointMap[pointi]] = pointi;
821 List<labelledTri> newFaces(UIndirectList<labelledTri>(locFaces,
faceMap));
824 for (
auto&
f : newFaces)
826 for (label& vert :
f)
828 vert = oldToNew[vert];
834 return triSurface(newFaces,
patches(), newPoints,
true);
846 this->subsetMeshMap(include, pointMap,
faceMap);
847 return this->subsetMeshImpl(pointMap,
faceMap);
859 this->subsetMeshMap(include, pointMap,
faceMap);
860 return this->subsetMeshImpl(pointMap,
faceMap);
868 return this->subsetMesh(include, pointMap,
faceMap);
876 return this->subsetMesh(include, pointMap,
faceMap);
887 const bitSet selectPatches
898 bitSet include(this->size());
902 const label patchi = (*this)[facei].region();
904 if (selectPatches.
test(patchi))
910 return this->subsetMesh(include);
918 this->storedFaces().swap(faceLst);
928 patches_.transfer(surf.
patches());
937 auto patches = ListOps::create<geometricSurfacePatch>
964 storedFaces() = surf;
965 storedPoints() = surf.
points();
int debug
Static debugging option.
List< label > labelList
A List of labels.
static void printTriangle(Ostream &os, const string &pre, const labelledTri &f, const pointField &points)
triSurface subsetMesh(const UList< bool > &include, labelList &pointMap, labelList &faceMap) const
Return a new surface subsetted on the selected faces.
vectorField pointField
pointField is a vectorField.
scalar timeOutputValue() const
Return current time value.
const surfZoneList & surfZones() const
Const access to the surface zones.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
A class for handling words, derived from Foam::string.
A class for handling file names.
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))
bool all() const
True if all bits in this bitset are set or if the set is empty.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void markZone(const boolList &borderEdge, const label facei, const label currentZone, labelList &faceZone) const
Fill faceZone with currentZone for every face reachable.
void triFaceFaces(List< face > &plainFaceList) const
Create a list of faces from the triFaces.
bitSet & unset(const bitSet &other)
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
bool read(const char *buf, int32_t &val)
Same as readInt32.
List< surfacePatch > surfacePatchList
A List of surfacePatch.
static word defaultName(const label n=-1)
Default patch name: "patch" or "patchN".
void set(const bitSet &bitset)
Set specified bits from another bitset.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
void append(const T &val)
Append an element at the end of the list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word ext() const
Return file name extension (part after last .)
virtual void clear()
Clear all storage.
void clearPatchMeshAddr()
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
bool test(const label pos) const
Test value at specified position, never auto-vivify entries.
const geometricSurfacePatchList & patches() const
virtual ~triSurface()
Destructor.
#define forAll(list, i)
Loop across all elements in list.
void swapFaces(List< labelledTri > &faceLst)
Swap the list of faces being addressed.
virtual void scalePoints(const scalar scaleFactor)
Scale points. A non-positive factor is ignored.
void checkTriangles(const bool verbose)
Check/remove duplicate/degenerate triangles.
virtual void movePoints(const pointField &pts)
Move points.
Triangulated surface description with patch information.
virtual void swapPoints(pointField &pts)
Swap points. Similar to movePoints, but returns the old points.
A subset of mesh faces organised as a primitive patch.
word name(const complex &c)
Return string representation of complex.
virtual const fileName & name() const
Return the name of the stream.
instantList times() const
Search the case for valid time directories.
void transfer(triSurface &surf)
Alter contents by transferring (triangles, points) components.
Extract name (as a word) from an object, typically using its name() method.
virtual const fileName & name() const
Return the name of the stream.
labelList findMatching(const StringListType &input, const wordRes &whitelist, const wordRes &blacklist=wordRes(), AccessOp aop=noOp())
Return ids for items with matching names.
triSurface()
Default construct.
pointField & storedPoints()
Non-const access to global points.
List< surfZone > sortedZones(labelList &faceMap) const
Sort faces according to zoneIds.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
void swapPoints(pointField &points)
Swap the stored points.
const Field< point_type > & points() const
Return reference to global points.
List< triFace > triFaceList
list of triFaces
errorManip< error > abort(error &err)
const labelList & edgeOwner() const
If 2 face neighbours: label of face where ordering of edge.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void cleanup(const bool verbose)
Remove non-valid triangles.
label markZones(const boolList &borderEdge, labelList &faceZone) const
(size and) fills faceZone with zone of face. Zone is area
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fileName & caseName() const
Return case name.
Helper to convert identifier types as an operation.
void swap(triSurface &surf)
fileName path() const
Return path.
A surface zone on a MeshedSurface.
List< labelledTri > & storedFaces()
Non-const access to the faces.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A List of wordRe with additional matching capabilities.
static constexpr const char *const emptyType
The name for an 'empty' type.
const polyBoundaryMesh & patches
Triangle with additional region number.
A List with indirect addressing.
A face is a list of labels corresponding to mesh vertices.
Various functions to operate on Lists.
const labelListList & sortedEdgeFaces() const
Return edge-face addressing sorted (for edges with more than.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
void operator=(const triSurface &surf)
Copy assignment.
void swapFaces(List< Face > &faces)
Swap the stored faces. Use with caution.
void setSize(const label newSize)
Alias for resize(const label)
const word & constant() const
Return constant name.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
static fileName triSurfInstance(const Time &)
Name of triSurface directory to use.
void checkEdges(const bool verbose)
Check triply (or more) connected edges.