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();
954 const_cast<labelList&>(labelList::null())
969 for (
const auto&
f : faceLst)
971 nTri +=
f.nTriangles();
975 if (nTri <= faceLst.size())
990 label
n = faceLst[facei].nTriangles();
1004 template<
class Face>
1007 if (faceTraits<Face>::isTri())
1016 const_cast<labelList&>(labelList::null())
1022 template<
class Face>
1037 if (faceTraits<Face>::isTri())
1046 List<Face>& faceLst = this->storedFaces();
1049 for (
const auto&
f : faceLst)
1051 const label
n =
f.nTriangles();
1060 if (nTri <= faceLst.size())
1066 this->storedFaceIds().clear();
1068 List<Face> newFaces(nTri);
1071 if (this->
points().empty())
1078 const Face&
f = faceLst[facei];
1080 for (label fp = 1; fp <
f.size() - 1; ++fp)
1082 const label fp1 =
f.fcIndex(fp);
1084 newFaces[nTri] = Face{
f[0],
f[fp],
f[fp1]};
1093 List<face> tmpTri(maxTri);
1099 const face&
f = faceLst[facei];
1102 f.triangles(this->
points(), nTmp, tmpTri);
1103 for (label triI = 0; triI < nTmp; triI++)
1105 newFaces[nTri] = Face
1107 static_cast<labelUList&>(tmpTri[triI])
1116 nTri -= faceLst.size();
1118 faceLst.transfer(newFaces);
1122 MeshReference::clearOut();
1128 template<
class Face>
1136 const pointField& locPoints = this->localPoints();
1137 const List<Face>& locFaces = this->localFaces();
1140 pointField newPoints(UIndirectList<point>(locPoints, pointMap));
1143 labelList oldToNew(locPoints.size(), -1);
1146 oldToNew[pointMap[pointi]] = pointi;
1150 List<Face> newFaces(UIndirectList<Face>(locFaces,
faceMap));
1153 for (
auto&
f : newFaces)
1155 for (label& vert :
f)
1157 vert = oldToNew[vert];
1169 for (surfZone& zone : newZones)
1172 origEndi += zone.size();
1175 zone.start() = newFacei;
1177 for (label facei = newFacei; facei <
faceMap.size(); ++facei)
1179 if (
faceMap[facei] < origEndi)
1190 zone.size() = newFacei - zone.start();
1196 if (faceIds_.size())
1202 MeshedSurface<Face> newSurf;
1203 newSurf.storedFaces().transfer(newFaces);
1204 newSurf.storedPoints().transfer(newPoints);
1205 newSurf.storedZones().transfer(newZones);
1206 newSurf.storedFaceIds().transfer(newFaceIds);
1212 template<
class Face>
1221 this->subsetMeshMap(include, pointMap,
faceMap);
1226 template<
class Face>
1235 this->subsetMeshMap(include, pointMap,
faceMap);
1240 template<
class Face>
1248 return this->subsetMesh(include, pointMap,
faceMap);
1252 template<
class Face>
1260 return this->subsetMesh(include, pointMap,
faceMap);
1264 template<
class Face>
1271 bitSet include(this->size());
1276 : fileFormats::surfaceFormatsCore::getSelectedPatches
1284 include.
set(zones_[zonei].
range());
1287 return this->subsetMesh(include);
1291 template<
class Face>
1302 MeshReference::clearOut();
1312 template<
class Face>
1319 MeshReference::clearOut();
1321 this->storedPoints().transfer(pointLst);
1322 this->storedFaces().transfer(faceLst);
1323 this->storedZones().clear();
1324 this->storedFaceIds().clear();
1328 template<
class Face>
1339 MeshReference::clearOut();
1350 template<
class Face>
1364 if (zoneLst.
size() > 1)
1371 sortedFaces[
faceMap[facei]].transfer(faceLst[facei]);
1374 faceLst.
swap(sortedFaces);
1377 MeshedSurface<Face> newSurf
1386 this->swap(newSurf);
1390 template<
class Face>
1398 template<
class Face>
1401 MeshReference::clearOut();
1403 this->storedFaceIds().clear();
1405 this->storedFaces().swap(faces);
1411 template<
class Face>
1417 this->storedPoints().swap(
points);
1421 template<
class Face>
1430 template<
class Face>
1434 const word& fileType
1443 template<
class Face>
1447 const word& surfName
1456 template<
class Face>
1467 this->storedPoints() = surf.
points();
1469 this->storedFaceIds() = surf.
faceIds();
1474 template<
class Face>
1481 template<
class Face>
1484 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.
word ext() const
Return file name extension (part after last .)
void swapPoints(pointField &points)
Swap the stored points.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
vectorField pointField
pointField is a vectorField.
static wordHashSet readTypes()
Known readable file-types, without friends or proxies.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
bool has_ext() const
Various checks for extensions.
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.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
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.
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.