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 75 fileName foamName(d.caseName() +
".ftr");
83 for (i=ts.size()-1; i>=0; i--)
85 if (ts[i].value() <= d.timeOutputValue())
96 for (label j=i; j>=0; j--)
98 if (
isFile(d.path()/ts[j].name()/typeName/foamName))
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
129 List<labelledTri> triFaces(faces.size());
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;
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);
212 const labelledTri&
f = (*this)[facei];
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)
244 const labelledTri&
n = (*this)[neighbour];
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.back()).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
536 read(
name, fileType);
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 && !
equal(scaleFactor, 1))
644 this->clearTopology();
649 this->storedPoints() *= scaleFactor;
658 stitchTriangles(SMALL, verbose);
663 checkTriangles(verbose);
679 for (
auto&
f : this->storedFaces())
681 for (label& pointi :
f)
683 label compacti = oldToCompact[pointi];
686 compacti = compactPointMap.
size();
687 oldToCompact[pointi] = compacti;
688 compactPointMap.append(pointi);
696 UIndirectList<point>(this->
points(), compactPointMap)
699 this->swapPoints(newPoints);
725 plainFaces.setSize(size());
729 plainFaces[facei] = this->operator[](facei);
740 const label currentZone,
750 DynamicList<label> newChangedFaces(2*changedFaces.size());
752 for (
const label facei : changedFaces)
754 const labelList& fEdges = faceEdges()[facei];
756 for (
const label edgei : fEdges)
758 if (!borderEdge[edgei])
760 const labelList& eFaces = edgeFaces()[edgei];
762 for (
const label nbrFacei : eFaces)
764 if (faceZone[nbrFacei] == -1)
766 faceZone[nbrFacei] = currentZone;
767 newChangedFaces.
append(nbrFacei);
769 else if (faceZone[nbrFacei] != currentZone)
772 <<
"Zones " << faceZone[nbrFacei]
773 <<
" at face " << nbrFacei
774 <<
" connects to zone " << currentZone
775 <<
" at face " << facei
783 if (newChangedFaces.empty())
788 changedFaces.transfer(newChangedFaces);
801 faceZone.setSize(size());
804 if (borderEdge.size() != nEdges())
807 <<
"borderEdge boolList not same size as number of edges" <<
endl 808 <<
"borderEdge:" << borderEdge.size() <<
endl 809 <<
"nEdges :" << nEdges()
815 for (label startFacei = 0;; zoneI++)
818 for (; startFacei < size(); startFacei++)
820 if (faceZone[startFacei] == -1)
826 if (startFacei >= size())
831 faceZone[startFacei] = zoneI;
833 markZone(borderEdge, startFacei, zoneI, faceZone);
847 const List<labelledTri>& locFaces = localFaces();
850 pointField newPoints(UIndirectList<point>(locPoints, pointMap));
853 labelList oldToNew(locPoints.size(), -1);
856 oldToNew[pointMap[pointi]] = pointi;
860 List<labelledTri> newFaces(UIndirectList<labelledTri>(locFaces,
faceMap));
863 for (
auto&
f : newFaces)
865 for (label& vert :
f)
867 vert = oldToNew[vert];
885 this->subsetMeshMap(include, pointMap,
faceMap);
886 return this->subsetMeshImpl(pointMap,
faceMap);
898 this->subsetMeshMap(include, pointMap,
faceMap);
899 return this->subsetMeshImpl(pointMap,
faceMap);
907 return this->subsetMesh(include, pointMap,
faceMap);
915 return this->subsetMesh(include, pointMap,
faceMap);
926 const bitSet selectPatches
937 bitSet include(this->size());
941 const label patchi = (*this)[facei].region();
943 if (selectPatches.test(patchi))
949 return this->subsetMesh(include);
957 this->storedFaces().swap(faceLst);
967 patches_.transfer(surf.
patches());
976 auto patches = ListOps::create<geometricSurfacePatch>
1003 storedFaces() = surf;
1004 storedPoints() = surf.
points();
virtual const fileName & name() const
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
List< triFace > triFaceList
List of triFace.
List< instant > instantList
List of instants.
triSurface subsetMesh(const UList< bool > &include, labelList &pointMap, labelList &faceMap) const
Return a new surface subsetted on the selected faces.
void cleanup(const bool verbose)
Remove non-valid triangles.
void size(const label n)
Older name for setAddressableSize.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type unset(const label i)
Unset the bool entry at specified position, always false for out-of-range access. ...
void set(const bitSet &bitset)
Set specified bits from another bitset.
A class for handling file names.
virtual const fileName & name() const
The name of the stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
bool equal(const T &a, const T &b)
Compare two values for equality.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void compactPoints(labelList &pointMap=const_cast< labelList &>(labelList::null()))
Remove unused points and renumber faces in local visit order.
void append(const T &val)
Append an element at the end of the list.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
A surface zone on a MeshedSurface.
constexpr char nl
The newline '\n' character (0x0a)
virtual void movePoints(const pointField &pts)
Move points.
virtual void clear()
Clear all storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void transfer(triSurface &surf)
Alter contents by transferring (triangles, points) components.
std::vector< Triangle > triangles
static void printTriangle(Ostream &os, const string &pre, const labelledTri &f, const pointField &points)
void clearPatchMeshAddr()
List< labelList > labelListList
List of labelList.
List< labelledTri > & storedFaces()
Non-const access to the faces.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Extract name (as a word) from an object, typically using its name() method.
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
static word defaultName(const label n=-1)
Default patch name: "patch" or "patchN".
Helper to convert identifier types as an operation.
void swapPoints(pointField &points)
Swap the stored points.
List< face > faceList
List of faces.
static fileName triSurfInstance(const Time &)
Name of triSurface directory to use.
const geometricSurfacePatchList & patches() const noexcept
vectorField pointField
pointField is a vectorField.
const labelListList & sortedEdgeFaces() const
Return edge-face addressing sorted (for edges with more than.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
void checkTriangles(const bool verbose)
Check/remove duplicate/degenerate triangles.
label size() const noexcept
The number of entries in the list.
labelList findMatching(const StringListType &input, const wordRes::filter &pred, AccessOp aop=identityOp())
Return ids for items with matching names.
void checkEdges(const bool verbose)
Check triply (or more) connected edges.
A List of wordRe with additional matching capabilities.
void swapFaces(List< labelledTri > &faceLst)
Swap the list of faces being addressed.
A triFace with additional (region) index.
const Field< point_type > & points() const noexcept
Return reference to global points.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
pointField & storedPoints()
Non-const access to global points.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void markZone(const boolList &borderEdge, const label facei, const label currentZone, labelList &faceZone) const
Fill faceZone with currentZone for every face reachable.
int debug
Static debugging option.
void triFaceFaces(List< face > &plainFaceList) const
Create a list of faces from the triFaces.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
static constexpr const char *const emptyType
The name for an 'empty' type.
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text...
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
virtual void swapPoints(pointField &pts)
Swap points. Similar to movePoints, but returns the old points.
triSurface()
Default construct.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
#define WarningInFunction
Report a warning using Foam::Warning.
const polyBoundaryMesh & patches
List< surfZone > surfZoneList
List of surfZone.
List< surfZone > sortedZones(labelList &faceMap) const
Sort faces according to zoneIds.
void swap(triSurface &surf)
void swapFaces(List< Face > &faces)
Swap the stored faces. Use with caution.
virtual void scalePoints(const scalar scaleFactor)
Scale points. A non-positive factor is ignored.
label markZones(const boolList &borderEdge, labelList &faceZone) const
(size and) fills faceZone with zone of face. Zone is area
virtual ~triSurface()
Destructor.
List< label > labelList
A List of labels.
const surfZoneList & surfZones() const
Const access to the surface zones.
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))
void operator=(const triSurface &surf)
Copy assignment.
const labelList & edgeOwner() const
If 2 face neighbours: label of face where ordering of edge.
List< bool > boolList
A List of bools.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
bool notNull(const T *ptr)
True if ptr is not a pointer (of type T) to the nullObject.
List< surfacePatch > surfacePatchList
List of surfacePatch.