47 return wordHashSet(*fileExtensionConstructorTablePtr_);
54 return wordHashSet(*writefileExtensionMemberFunctionTablePtr_);
65 return fileFormats::surfaceFormatsCore::checkSupport
67 readTypes() | FriendType::readTypes(),
82 return fileFormats::surfaceFormatsCore::checkSupport
84 writeTypes() | ProxyType::writeTypes(),
106 return canReadType(ext, verbose);
127 const word& fileType,
133 if (fileType.empty())
142 <<
"Cannot determine format from filename" <<
nl 147 write(
name, ext, surf, streamOpt, options);
154 auto* mfuncPtr = writefileExtensionMemberFunctionTable(fileType);
159 const wordHashSet delegate(ProxyType::writeTypes());
161 if (!delegate.found(fileType))
164 <<
"Unknown write format " << fileType <<
nl <<
nl 165 <<
"Valid types:" <<
nl 170 MeshedSurfaceProxy<Face>(surf).
write 172 name, fileType, streamOpt, options
177 mfuncPtr(
name, surf, streamOpt, options);
199 MeshReference(surf.surfFaces(), surf.
points()),
200 faceIds_(surf.faceIds_),
225 newFaces[
faceMap[facei]] = origFaces[facei];
228 this->storedFaces().
transfer(newFaces);
234 if (origIds.size() == origFaces.
size())
240 newFaceIds[
faceMap[facei]] = origIds[facei];
243 this->storedFaceIds().transfer(newFaceIds);
251 MeshedSurface<Face>&& surf
254 MeshedSurface<Face>()
280 MeshReference(
List<Face>(faceLst), pointLst),
296 MeshReference(faceLst, pointLst, true),
313 MeshReference(
List<Face>(faceLst), pointLst),
317 if (zoneSizes.
size())
319 if (zoneNames.
size())
321 addZones(zoneSizes, zoneNames);
335 List<Face>&& faceLst,
337 const UList<word>& zoneNames
340 MeshReference(faceLst, pointLst, true),
344 if (zoneSizes.size())
346 if (zoneNames.size())
348 addZones(zoneSizes, zoneNames);
361 MeshedSurface<Face>()
364 MeshedSurface<face> surf
371 this->transcribe(surf);
379 const bool useGlobalPoints
389 label startFacei = 0;
404 startFacei +=
p.size();
408 newZones.setSize(nZone);
414 MeshedSurface<face> surf;
419 surf = MeshedSurface<face>(
mesh.points(), allBoundary, newZones);
424 surf = MeshedSurface<face>
426 allBoundary.localPoints(),
427 allBoundary.localFaces(),
432 this->transcribe(surf);
493 IOobjectOption::MUST_READ,
494 IOobjectOption::NO_WRITE,
495 IOobjectOption::NO_REGISTER
503 std::move(*(
mesh.releaseGeom()))
506 this->transcribe(surf);
522 fileFormats::surfaceFormatsCore::checkFile(
io,
dict, isGlobal)
525 this->
read(fName,
dict.getOrDefault<
word>(
"fileType", word::null));
527 this->scalePoints(
dict.getOrDefault<scalar>(
"scale", 0));
548 if (faceMapNewToOld.
empty())
555 if (zones.size() == 1)
558 zones[0].size() = faceMapNewToOld.
size();
566 for (surfZone& zone : zones)
569 zone.start() = newFacei;
570 origEndi += zone.size();
572 for (label facei = newFacei; facei < faceMapNewToOld.
size(); ++facei)
574 if (faceMapNewToOld[facei] < origEndi)
585 zone.size() = newFacei - zone.start();
595 MeshReference::clearOut();
597 storedPoints().clear();
598 storedFaces().clear();
599 storedFaceIds().clear();
600 storedZones().clear();
607 MeshReference::clearGeom();
610 MeshReference::movePoints(newPoints);
613 storedPoints() = newPoints;
621 if (scaleFactor > SMALL && !
equal(scaleFactor, 1))
624 this->clearTopology();
629 this->storedPoints() *= scaleFactor;
639 stitchFaces(SMALL, verbose);
657 for (
auto&
f : this->storedFaces())
659 for (label& pointi :
f)
661 label compacti = oldToCompact[pointi];
664 compacti = compactPointMap.
size();
665 oldToCompact[pointi] = compacti;
666 compactPointMap.append(pointi);
674 UIndirectList<point>(this->
points(), compactPointMap)
677 this->swapPoints(newPoints);
709 List<Face>& faceLst = this->storedFaces();
717 Face&
f = faceLst[facei];
718 for (label& vert :
f)
720 vert = pointMap[vert];
724 if (
f.collapse() >= 3)
726 if (newFacei != facei)
728 faceLst[newFacei] =
f;
735 Pout<<
"MeshedSurface::stitchFaces : " 736 <<
"Removing collapsed face " << facei <<
endl 737 <<
" vertices :" <<
f <<
endl;
742 if (newFacei != faceLst.size())
746 Pout<<
"MeshedSurface::stitchFaces : " 747 <<
"Removed " << faceLst.size() - newFacei
751 faceLst.resize(newFacei);
758 faceIds_[facei] = faceIds_[
faceMap[facei]];
761 faceIds_.resize(newFacei);
769 MeshReference::clearOut();
782 bool changed =
false;
788 const label maxPointi = this->
points().size();
793 Face&
f = faceLst[facei];
796 if (
f.collapse() >= 3)
798 for (
const label vert :
f)
800 if (vert < 0 || vert >= maxPointi)
804 <<
" uses point indices outside point range 0.." 822 <<
"face[" << facei <<
"] = " <<
f 823 <<
" does not have three unique vertices" <<
endl;
840 const Face&
f = faceLst[facei];
844 const labelList& neighbours = fFaces[facei];
848 for (
const label neiFacei : neighbours)
850 if (neiFacei <= facei ||
faceMap[neiFacei] < 0)
857 const Face& nei = faceLst[neiFacei];
866 <<
"faces share the same vertices:" <<
nl 867 <<
" face[" << facei <<
"] : " <<
f <<
nl 868 <<
" face[" << neiFacei <<
"] : " << nei <<
endl;
894 if (changed || newFacei < faceLst.
size())
901 <<
"Removed " << faceLst.
size() - newFacei
902 <<
" illegal faces." <<
endl;
911 if (newFacei != facei)
913 faceLst[newFacei] = std::move(faceLst[facei]);
928 faceIds_[facei] = faceIds_[
faceMap[facei]];
931 faceIds_.resize(newFacei);
939 MeshReference::clearOut();
949 return MeshReference::size();
955 const_cast<labelList&>(labelList::null())
968 const List<Face>& faceLst = surfFaces();
971 for (
const auto&
f : faceLst)
973 nTri +=
f.nTriangles();
977 if (nTri <= faceLst.size())
992 label
n = faceLst[facei].nTriangles();
1006 template<
class Face>
1009 if constexpr (faceTraits<Face>::isTri())
1018 const_cast<labelList&>(labelList::null())
1024 template<
class Face>
1039 if (faceTraits<Face>::isTri())
1048 List<Face>& faceLst = this->storedFaces();
1051 for (
const auto&
f : faceLst)
1053 const label
n =
f.nTriangles();
1062 if (nTri <= faceLst.size())
1068 this->storedFaceIds().clear();
1070 List<Face> newFaces(nTri);
1073 if (this->
points().empty())
1080 const Face&
f = faceLst[facei];
1082 for (label fp = 1; fp <
f.size() - 1; ++fp)
1084 const label fp1 =
f.fcIndex(fp);
1086 newFaces[nTri] = Face{
f[0],
f[fp],
f[fp1]};
1095 List<face> tmpTri(maxTri);
1101 const face&
f = faceLst[facei];
1104 f.triangles(this->
points(), nTmp, tmpTri);
1105 for (label triI = 0; triI < nTmp; triI++)
1107 newFaces[nTri] = Face
1109 static_cast<labelUList&>(tmpTri[triI])
1118 nTri -= faceLst.size();
1120 faceLst.transfer(newFaces);
1124 MeshReference::clearOut();
1130 template<
class Face>
1138 const pointField& locPoints = this->localPoints();
1139 const List<Face>& locFaces = this->localFaces();
1142 pointField newPoints(UIndirectList<point>(locPoints, pointMap));
1145 labelList oldToNew(locPoints.size(), -1);
1148 oldToNew[pointMap[pointi]] = pointi;
1152 List<Face> newFaces(UIndirectList<Face>(locFaces,
faceMap));
1155 for (
auto&
f : newFaces)
1157 for (label& vert :
f)
1159 vert = oldToNew[vert];
1171 for (surfZone& zone : newZones)
1174 origEndi += zone.size();
1177 zone.start() = newFacei;
1179 for (label facei = newFacei; facei <
faceMap.size(); ++facei)
1181 if (
faceMap[facei] < origEndi)
1192 zone.size() = newFacei - zone.start();
1198 if (faceIds_.size())
1204 MeshedSurface<Face> newSurf;
1205 newSurf.storedFaces().transfer(newFaces);
1206 newSurf.storedPoints().transfer(newPoints);
1207 newSurf.storedZones().transfer(newZones);
1208 newSurf.storedFaceIds().transfer(newFaceIds);
1214 template<
class Face>
1223 this->subsetMeshMap(include, pointMap,
faceMap);
1228 template<
class Face>
1237 this->subsetMeshMap(include, pointMap,
faceMap);
1242 template<
class Face>
1250 return this->subsetMesh(include, pointMap,
faceMap);
1254 template<
class Face>
1262 return this->subsetMesh(include, pointMap,
faceMap);
1266 template<
class Face>
1273 bitSet include(this->size());
1278 : fileFormats::surfaceFormatsCore::getSelectedPatches
1286 include.
set(zones_[zonei].
range());
1289 return this->subsetMesh(include);
1293 template<
class Face>
1304 MeshReference::clearOut();
1314 template<
class Face>
1321 MeshReference::clearOut();
1323 this->storedPoints().transfer(pointLst);
1324 this->storedFaces().transfer(faceLst);
1325 this->storedZones().clear();
1326 this->storedFaceIds().clear();
1330 template<
class Face>
1341 MeshReference::clearOut();
1352 template<
class Face>
1366 if (zoneLst.
size() > 1)
1373 sortedFaces[
faceMap[facei]].transfer(faceLst[facei]);
1376 faceLst.
swap(sortedFaces);
1379 MeshedSurface<Face> newSurf
1388 this->swap(newSurf);
1392 template<
class Face>
1400 template<
class Face>
1403 MeshReference::clearOut();
1405 this->storedFaceIds().clear();
1407 this->storedFaces().swap(faces);
1413 template<
class Face>
1419 this->storedPoints().swap(
points);
1423 template<
class Face>
1432 template<
class Face>
1436 const word& fileType
1445 template<
class Face>
1449 const word& surfName
1458 template<
class Face>
1469 this->storedPoints() = surf.
points();
1471 this->storedFaceIds() = surf.
faceIds();
1476 template<
class Face>
1483 template<
class Face>
1486 return MeshedSurfaceProxy<Face>
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
virtual void clear()
Clear all storage.
void swap(UList< T > &list) noexcept
Swap content with another UList of the same type in constant time.
const polyBoundaryMesh & pbm
void size(const label n)
Older name for setAddressableSize.
virtual void compactPoints(labelList &pointMap=const_cast< labelList &>(labelList::null()))
Remove unused points and renumber faces in local visit order.
virtual void scalePoints(const scalar scaleFactor)
Scale points. A non-positive factor is ignored.
void set(const bitSet &bitset)
Set specified bits from another bitset.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual ~MeshedSurface()
Destructor.
autoPtr< MeshedSurface< Face > > releaseGeom()
Release (clear) geometry and return for reuse.
void resize(const label len)
Adjust allocated size of list.
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...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
static bool canRead(const fileName &name, bool verbose=false)
Can we read this file format?
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
A surface zone on a MeshedSurface.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
label checkTopology(const polyMesh &mesh, const bool allTopology, const bool allGeometry, autoPtr< surfaceWriter > &surfWriter, autoPtr< coordSetWriter > &setWriter, const bool writeBadEdges=false)
static wordHashSet writeTypes()
Known writable file-types, without friends or proxies.
UIndirectList< label > labelUIndList
UIndirectList of labels.
virtual void clear()
Clear all storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
A simple container for options an IOstream can normally have.
label checkZones(const polyMesh &mesh, const ZoneMesh< Zone, polyMesh > &zones, topoSet &set)
List< labelList > labelListList
List of labelList.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
surfZoneList & storedZones()
Non-const access to the zones.
Macros for easy insertion into run-time selection tables.
UList< label > labelUList
A UList of labels.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
static void write(const fileName &name, const MeshedSurfaceProxy &surf, IOstreamOption streamOpt=IOstreamOption(), const dictionary &options=dictionary::null)
Write to file, select based on its extension.
void swapPoints(pointField &points)
Swap the stored points.
vectorField pointField
pointField is a vectorField.
static wordHashSet readTypes()
Known readable file-types, without friends or proxies.
List< Face > & storedFaces()
Non-const access to the faces.
A class for handling words, derived from Foam::string.
#define DebugInFunction
Report an information message using Foam::Info.
void swap(MeshedSurface< Face > &surf)
Swap contents.
pointField & storedPoints()
Non-const access to global points.
virtual void cleanup(const bool verbose)
Remove invalid faces.
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
virtual void movePoints(const pointField &newPoints)
Move points.
A List of wordRe with additional matching capabilities.
MeshedSurface subsetMesh(const UList< bool > &include, labelList &pointMap, labelList &faceMap) const
Return a new surface subsetted on the selected faces.
void operator=(const MeshedSurface< Face > &surf)
Copy assignment.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
const Field< point_type > & points() const noexcept
Return reference to global points.
labelList & storedFaceIds()
Non-const access to face ids.
label inplaceMergePoints(PointList &points, const scalar mergeTol, const bool verbose, labelList &pointToUnique)
Inplace merge points, preserving the original point order. All points closer/equal mergeTol are to be...
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh...
const labelList & faceIds() const
Return const access to faces ids.
A surface mesh consisting of general polygon faces that has IO capabilities and a registry for storin...
const List< Face > & surfFaces() const
Return const access to the faces.
static bool canWriteType(const word &fileType, bool verbose=false)
Can we write this file format? Also checks proxy types.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats...
Geometric merging of points. See below.
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field...
surfZoneList sortedZones(labelList &faceMap) const
Sort faces according to zoneIds.
virtual label nTriangles() const
Count number of triangles.
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.
static bool canReadType(const word &fileType, bool verbose=false)
Can we read this file format? Also checks friend types.
virtual bool checkFaces(const bool verbose=false)
bool notNull(const T *ptr) noexcept
True if ptr is not a pointer (of type T) to the nullObject.
List< surfZone > surfZoneList
List of surfZone.
void transfer(pointField &pointLst, List< Face > &faceLst)
Transfer the components.
virtual void remapFaces(const labelUList &faceMapNewToOld)
Set new zones from faceMap.
List< label > sortedToc(const UList< bool > &bools)
Return the (sorted) values corresponding to 'true' entries.
void swapFaces(List< Face > &faces)
Swap the stored faces. Use with caution.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
const surfZoneList & surfZones() const
Const access to the surface zones.
A patch is a list of labels that address the faces in the global face list.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Defines the attributes of an object for which implicit objectRegistry management is supported...
bool equal(const UList< Type1 > &a, const UList< Type2 > &b)
Test for list equality with different but compatible data types. Eg, int32 and int64.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
MeshedSurface()
Default construct, an empty surface.
virtual bool stitchFaces(const scalar tol=SMALL, const bool verbose=false)
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
#define InfoInFunction
Report an information message using Foam::Info.