59 << pre.c_str() <<
"vertex numbers:"
60 <<
f[0] <<
' ' <<
f[1] <<
' ' <<
f[2] <<
nl
62 << pre.c_str() <<
"vertex coords :"
65 << pre.c_str() <<
"region :" <<
f.region() <<
nl
76 fileName foamName(d.caseName() +
".ftr");
84 for (i=ts.size()-1; i>=0; i--)
86 if (ts[i] <= d.timeOutputValue())
97 for (label j=i; j>=0; j--)
103 Pout<<
" triSurface::triSurfInstance(const Time& d)"
104 <<
"reading " << foamName
116 Pout<<
" triSurface::triSurfInstance(const Time& d)"
117 <<
"reading " << foamName
118 <<
" from constant/" <<
endl;
124Foam::List<Foam::labelledTri> Foam::triSurface::convertToTri
127 const label defaultRegion
134 const face&
f = faces[facei];
139 <<
"Face at position " << facei
140 <<
" does not have three vertices:" <<
f
149 tri.region() = defaultRegion;
156Foam::List<Foam::labelledTri> Foam::triSurface::convertToTri
159 const label defaultRegion
173 tri.region() = defaultRegion;
188 for (
const auto&
f : *
this)
190 for (
const label verti :
f)
192 if (verti < 0 || verti > maxPointi)
196 <<
" uses point indices outside point range 0.."
209 bitSet valid(size(),
true);
213 const labelledTri&
f = (*this)[facei];
223 <<
"triangle " << facei
224 <<
" does not have three unique vertices:\n";
231 const labelList& fEdges = faceEdges()[facei];
236 for (
const label edgei : fEdges)
238 const labelList& eFaces = edgeFaces()[edgei];
240 for (
const label neighbour : eFaces)
242 if (neighbour > facei)
249 ((
f[0] ==
n[0]) || (
f[0] ==
n[1]) || (
f[0] ==
n[2]))
250 && ((
f[1] ==
n[0]) || (
f[1] ==
n[1]) || (
f[1] ==
n[2]))
251 && ((
f[2] ==
n[0]) || (
f[2] ==
n[1]) || (
f[2] ==
n[2]))
259 <<
"triangles share the same vertices:\n"
260 <<
" face 1 :" << facei <<
endl;
266 << neighbour <<
endl;
282 for (
const label facei : valid)
284 (*this)[newFacei++] = (*this)[facei];
290 <<
"Removing " << size() - newFacei
291 <<
" illegal faces." <<
endl;
293 (*this).setSize(newFacei);
308 const labelList& myFaces = eFaces[edgei];
313 <<
"Edge " << edgei <<
" with vertices " << edges()[edgei]
314 <<
" has no edgeFaces"
317 else if (myFaces.size() > 2 && verbose)
320 <<
"Edge " << edgei <<
" with vertices " << edges()[edgei]
321 <<
" has more than 2 faces connected to it : " << myFaces
339 regions[facei] = operator[](facei).region();
345 label maxRegion = patches_.size()-1;
352 operator[](
faceMap.back()).region()
362 label region = operator[](facei).region();
364 newPatches[region].size()++;
370 label startFacei = 0;
371 forAll(newPatches, newPatchi)
375 newPatch.
index() = newPatchi;
376 newPatch.start() = startFacei;
381 newPatchi < patches_.size()
382 && !patches_[newPatchi].name().empty()
385 newPatch.name() = patches_[newPatchi].name();
394 newPatchi < patches_.size()
395 && !patches_[newPatchi].geometricType().empty()
398 newPatch.geometricType() = patches_[newPatchi].geometricType();
405 startFacei += newPatch.size();
412void Foam::triSurface::setDefaultPatches()
420 patches_.setSize(newPatches.size());
422 forAll(newPatches, patchi)
424 patches_[patchi].index() = patchi;
425 patches_[patchi].name() = newPatches[patchi].name();
426 patches_[patchi].geometricType() = newPatches[patchi].geometricType();
437 sortedEdgeFacesPtr_(nullptr),
438 edgeOwnerPtr_(nullptr)
446 sortedEdgeFacesPtr_(nullptr),
447 edgeOwnerPtr_(nullptr)
468 sortedEdgeFacesPtr_(nullptr),
469 edgeOwnerPtr_(nullptr)
483 sortedEdgeFacesPtr_(nullptr),
484 edgeOwnerPtr_(nullptr)
496 sortedEdgeFacesPtr_(nullptr),
497 edgeOwnerPtr_(nullptr)
511 sortedEdgeFacesPtr_(nullptr),
512 edgeOwnerPtr_(nullptr)
521 const scalar scaleFactor
531 const word& fileType,
532 const scalar scaleFactor
556 sortedEdgeFacesPtr_.reset(
nullptr);
557 edgeOwnerPtr_.reset(
nullptr);
593 if (!sortedEdgeFacesPtr_)
595 calcSortedEdgeFaces();
598 return *sortedEdgeFacesPtr_;
609 return *edgeOwnerPtr_;
616 sortedEdgeFacesPtr_.reset(
nullptr);
629 sortedEdgeFacesPtr_.reset(
nullptr);
642 if (scaleFactor > SMALL && !
equal(scaleFactor, 1))
645 this->clearTopology();
659 stitchTriangles(SMALL, verbose);
680 for (
auto&
f : this->storedFaces())
682 for (label& pointi :
f)
684 label compacti = oldToCompact[pointi];
687 compacti = compactPointMap.size();
688 oldToCompact[pointi] = compacti;
689 compactPointMap.append(pointi);
700 this->swapPoints(newPoints);
726 plainFaces.setSize(size());
741 const label currentZone,
751 DynamicList<label> newChangedFaces(2*changedFaces.size());
753 for (
const label facei : changedFaces)
755 const labelList& fEdges = faceEdges()[facei];
757 for (
const label edgei : fEdges)
759 if (!borderEdge[edgei])
761 const labelList& eFaces = edgeFaces()[edgei];
763 for (
const label nbrFacei : eFaces)
765 if (faceZone[nbrFacei] == -1)
767 faceZone[nbrFacei] = currentZone;
768 newChangedFaces.append(nbrFacei);
770 else if (
faceZone[nbrFacei] != currentZone)
774 <<
" at face " << nbrFacei
775 <<
" connects to zone " << currentZone
776 <<
" at face " << facei
784 if (newChangedFaces.empty())
789 changedFaces.transfer(newChangedFaces);
802 faceZone.setSize(size());
805 if (borderEdge.size() != nEdges())
808 <<
"borderEdge boolList not same size as number of edges" <<
endl
809 <<
"borderEdge:" << borderEdge.size() <<
endl
810 <<
"nEdges :" << nEdges()
816 for (label startFacei = 0;; zoneI++)
819 for (; startFacei < size(); startFacei++)
827 if (startFacei >= size())
834 markZone(borderEdge, startFacei, zoneI,
faceZone);
841Foam::triSurface Foam::triSurface::subsetMeshImpl
854 labelList oldToNew(locPoints.size(), -1);
857 oldToNew[pointMap[pointi]] = pointi;
864 for (
auto&
f : newFaces)
866 for (label& vert :
f)
868 vert = oldToNew[vert];
887 return this->subsetMeshImpl(pointMap,
faceMap);
900 return this->subsetMeshImpl(pointMap,
faceMap);
927 const bitSet selectPatches
938 bitSet include(this->size());
942 const label patchi = (*this)[facei].region();
944 if (selectPatches.test(patchi))
950 return this->subsetMesh(include);
968 patches_.transfer(surf.
patches());
Various functions to operate on Lists.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
void setSize(label n)
Alias for resize().
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
const surfZoneList & surfZones() const
Const access to the surface zones.
void swapPoints(pointField &points)
Swap the stored points.
virtual void clear()
Clear all storage.
void swapFaces(List< Face > &faces)
Swap the stored faces. Use with caution.
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name).
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const edgeList & edges() const
const Field< point_type > & points() const noexcept
virtual void movePoints(const Field< point_type > &)
const labelListList & edgeFaces() const
const labelListList & faceEdges() const
void clearPatchMeshAddr()
instantList times() const
Search the case for valid time directories.
const word & constant() const noexcept
Return constant name.
scalar timeOutputValue() const
Return the current user-time value. (ie, after applying any timeToUserTime() conversion).
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
fileName path() const
The path for the case = rootPath/caseName.
const fileName & caseName() const noexcept
The case name.
A List with indirect addressing. Like IndirectList but does not store addressing.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void size(const label n)
Older name for setAddressableSize.
T & operator[](const label i)
Return element of UList.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void set(const bitSet &bitset)
Set specified bits from another bitset.
bool test(const label pos) const
Test for True value at specified position, never auto-vivify entries.
bool all() const
True if all bits in this bitset are set or if the set is empty.
bitSet & unset(const bitSet &other)
Unset (subtract) the bits specified in the other bitset, which is a set difference corresponds to the...
A subset of mesh faces organised as a primitive patch.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
static constexpr const char *const emptyType
The name for an 'empty' type.
label index() const noexcept
The index of this patch/zone in the surface mesh.
static word defaultName(const label n=-1)
Default patch name: "patch" or "patchN".
A triFace with additional (region) index.
A surface zone on a MeshedSurface.
A 'patch' on surface as subset of triSurface.
A triangular face using a FixedList of labels corresponding to mesh vertices.
Triangulated surface description with patch information.
static fileName triSurfInstance(const Time &)
Name of triSurface directory to use.
triSurface()
Default construct.
List< surfZone > sortedZones(labelList &faceMap) const
Sort faces according to zoneIds.
pointField & storedPoints()
Non-const access to global points.
void transfer(triSurface &surf)
Alter contents by transferring (triangles, points) components.
label markZones(const boolList &borderEdge, labelList &faceZone) const
(size and) fills faceZone with zone of face. Zone is area
void swap(triSurface &surf)
void triFaceFaces(List< face > &plainFaceList) const
Create a list of faces from the triFaces.
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.
const geometricSurfacePatchList & patches() const noexcept
void checkTriangles(const bool verbose)
Check/remove duplicate/degenerate triangles.
virtual void swapPoints(pointField &pts)
Swap points. Similar to movePoints, but returns the old points.
void checkEdges(const bool verbose)
Check triply (or more) connected edges.
List< labelledTri > & storedFaces()
Non-const access to the faces.
void compactPoints(labelList &pointMap=const_cast< labelList & >(labelList::null()))
Remove unused points and renumber faces in local visit order.
void markZone(const boolList &borderEdge, const label facei, const label currentZone, labelList &faceZone) const
Fill faceZone with currentZone for every face reachable.
const labelList & edgeOwner() const
If 2 face neighbours: label of face where ordering of edge.
void subsetMeshMap(const BoolListType &include, labelList &pointMap, labelList &faceMap) const
Create mappings for a sub-surface.
virtual void movePoints(const pointField &pts)
Move points.
void clearPatchMeshAddr()
virtual void scalePoints(const scalar scaleFactor)
Scale points. A non-positive factor is ignored.
const labelListList & sortedEdgeFaces() const
Return edge-face addressing sorted (for edges with more than.
void swapFaces(List< labelledTri > &faceLst)
Swap the list of faces being addressed.
void operator=(const triSurface &surf)
Copy assignment.
virtual ~triSurface()
Destructor.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
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))
#define WarningInFunction
Report a warning using Foam::Warning.
List< T > create(const UList< T2 > &input, const UnaryOperation &op)
Create a List from a List of a dissimilar type, using the entire list.
Namespace for handling debugging switches.
labelList findMatching(const StringListType &input, const wordRes::filter &pred, AccessOp aop=identityOp())
Return ids for items with matching names.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< surfacePatch > surfacePatchList
List of surfacePatch.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< labelList > labelListList
List of labelList.
bool read(const char *buf, int32_t &val)
Same as readInt32.
List< label > labelList
A List of labels.
List< surfZone > surfZoneList
List of surfZone.
bool equal(const T &a, const T &b)
Compare two values for equality.
List< face > faceList
List of faces.
List< instant > instantList
List of instants.
static void printTriangle(Ostream &os, const string &pre, const labelledTri &f, const pointField &points)
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
errorManip< error > abort(error &err)
List< geometricSurfacePatch > geometricSurfacePatchList
List of geometricSurfacePatch.
List< bool > boolList
A List of bools.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
List< triFace > triFaceList
List of triFace.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
bool notNull(const T *ptr) noexcept
True if ptr is not a pointer (of type T) to the nullObject.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text.
constexpr char nl
The newline '\n' character (0x0a).
std::vector< Triangle > triangles
#define forAll(list, i)
Loop across all elements in list.
Operations on lists of strings.
Helper to convert identifier types as an operation.
Extract name (as a word) from an object, typically using its name() method.