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(faceLst, pointLst),
296 MeshReference(faceLst, pointLst, true),
313 MeshReference(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
393 mesh.nBoundaryFaces(),
394 mesh.nInternalFaces()
402 useGlobalPoints ?
mesh.points() : allBoundary.localPoints()
408 useGlobalPoints ? allBoundary : allBoundary.localFaces()
415 label startFacei = 0;
430 startFacei +=
p.size();
434 newZones.setSize(nZone);
437 MeshedSurface<face> surf(bPoints, bFaces, newZones);
439 this->transcribe(surf);
500 IOobject::MUST_READ_IF_MODIFIED,
502 IOobject::NO_REGISTER
510 std::move(*(
mesh.releaseGeom()))
513 this->transcribe(surf);
529 fileFormats::surfaceFormatsCore::checkFile(
io,
dict, isGlobal)
532 this->
read(fName,
dict.getOrDefault<
word>(
"fileType", word::null));
534 this->scalePoints(
dict.getOrDefault<scalar>(
"scale", 0));
555 if (faceMapNewToOld.
empty())
562 if (zones.size() == 1)
565 zones[0].size() = faceMapNewToOld.
size();
573 for (surfZone& zone : zones)
576 zone.start() = newFacei;
577 origEndi += zone.size();
579 for (label facei = newFacei; facei < faceMapNewToOld.
size(); ++facei)
581 if (faceMapNewToOld[facei] < origEndi)
592 zone.size() = newFacei - zone.start();
602 MeshReference::clearOut();
604 storedPoints().clear();
605 storedFaces().clear();
606 storedFaceIds().clear();
607 storedZones().clear();
614 MeshReference::clearGeom();
617 MeshReference::movePoints(newPoints);
620 storedPoints() = newPoints;
628 if (scaleFactor > SMALL && !
equal(scaleFactor, 1))
631 this->clearTopology();
636 this->storedPoints() *= scaleFactor;
646 stitchFaces(SMALL, verbose);
664 for (
auto&
f : this->storedFaces())
666 for (label& pointi :
f)
668 label compacti = oldToCompact[pointi];
671 compacti = compactPointMap.
size();
672 oldToCompact[pointi] = compacti;
673 compactPointMap.append(pointi);
681 UIndirectList<point>(this->
points(), compactPointMap)
684 this->swapPoints(newPoints);
716 List<Face>& faceLst = this->storedFaces();
724 Face&
f = faceLst[facei];
725 for (label& vert :
f)
727 vert = pointMap[vert];
731 if (
f.collapse() >= 3)
733 if (newFacei != facei)
735 faceLst[newFacei] =
f;
742 Pout<<
"MeshedSurface::stitchFaces : " 743 <<
"Removing collapsed face " << facei <<
endl 744 <<
" vertices :" <<
f <<
endl;
749 if (newFacei != faceLst.size())
753 Pout<<
"MeshedSurface::stitchFaces : " 754 <<
"Removed " << faceLst.size() - newFacei
758 faceLst.resize(newFacei);
765 faceIds_[facei] = faceIds_[
faceMap[facei]];
768 faceIds_.resize(newFacei);
776 MeshReference::clearOut();
789 bool changed =
false;
795 const label maxPointi = this->
points().size();
800 Face&
f = faceLst[facei];
803 if (
f.collapse() >= 3)
805 for (
const label vert :
f)
807 if (vert < 0 || vert >= maxPointi)
811 <<
" uses point indices outside point range 0.." 829 <<
"face[" << facei <<
"] = " <<
f 830 <<
" does not have three unique vertices" <<
endl;
847 const Face&
f = faceLst[facei];
851 const labelList& neighbours = fFaces[facei];
855 for (
const label neiFacei : neighbours)
857 if (neiFacei <= facei ||
faceMap[neiFacei] < 0)
864 const Face& nei = faceLst[neiFacei];
873 <<
"faces share the same vertices:" <<
nl 874 <<
" face[" << facei <<
"] : " <<
f <<
nl 875 <<
" face[" << neiFacei <<
"] : " << nei <<
endl;
901 if (changed || newFacei < faceLst.
size())
908 <<
"Removed " << faceLst.
size() - newFacei
909 <<
" illegal faces." <<
endl;
918 if (newFacei != facei)
920 faceLst[newFacei] = std::move(faceLst[facei]);
935 faceIds_[facei] = faceIds_[
faceMap[facei]];
938 faceIds_.resize(newFacei);
946 MeshReference::clearOut();
956 return MeshReference::size();
961 const_cast<labelList&>(labelList::null())
976 for (
const auto&
f : faceLst)
978 nTri +=
f.nTriangles();
982 if (nTri <= faceLst.size())
997 label
n = faceLst[facei].nTriangles();
1011 template<
class Face>
1014 if (faceTraits<Face>::isTri())
1023 const_cast<labelList&>(labelList::null())
1029 template<
class Face>
1044 if (faceTraits<Face>::isTri())
1053 List<Face>& faceLst = this->storedFaces();
1056 for (
const auto&
f : faceLst)
1058 const label
n =
f.nTriangles();
1067 if (nTri <= faceLst.size())
1073 this->storedFaceIds().clear();
1075 List<Face> newFaces(nTri);
1078 if (this->
points().empty())
1085 const Face&
f = faceLst[facei];
1087 for (label fp = 1; fp <
f.size() - 1; ++fp)
1089 const label fp1 =
f.fcIndex(fp);
1091 newFaces[nTri] = Face{
f[0],
f[fp],
f[fp1]};
1100 List<face> tmpTri(maxTri);
1106 const face&
f = faceLst[facei];
1109 f.triangles(this->
points(), nTmp, tmpTri);
1110 for (label triI = 0; triI < nTmp; triI++)
1112 newFaces[nTri] = Face
1114 static_cast<labelUList&>(tmpTri[triI])
1123 nTri -= faceLst.size();
1125 faceLst.transfer(newFaces);
1129 MeshReference::clearOut();
1135 template<
class Face>
1143 const pointField& locPoints = this->localPoints();
1144 const List<Face>& locFaces = this->localFaces();
1147 pointField newPoints(UIndirectList<point>(locPoints, pointMap));
1150 labelList oldToNew(locPoints.size(), -1);
1153 oldToNew[pointMap[pointi]] = pointi;
1157 List<Face> newFaces(UIndirectList<Face>(locFaces,
faceMap));
1160 for (
auto&
f : newFaces)
1162 for (label& vert :
f)
1164 vert = oldToNew[vert];
1176 for (surfZone& zone : newZones)
1179 origEndi += zone.size();
1182 zone.start() = newFacei;
1184 for (label facei = newFacei; facei <
faceMap.size(); ++facei)
1186 if (
faceMap[facei] < origEndi)
1197 zone.size() = newFacei - zone.start();
1203 if (faceIds_.size())
1209 MeshedSurface<Face> newSurf;
1210 newSurf.storedFaces().transfer(newFaces);
1211 newSurf.storedPoints().transfer(newPoints);
1212 newSurf.storedZones().transfer(newZones);
1213 newSurf.storedFaceIds().transfer(newFaceIds);
1219 template<
class Face>
1228 this->subsetMeshMap(include, pointMap,
faceMap);
1233 template<
class Face>
1242 this->subsetMeshMap(include, pointMap,
faceMap);
1247 template<
class Face>
1255 return this->subsetMesh(include, pointMap,
faceMap);
1259 template<
class Face>
1267 return this->subsetMesh(include, pointMap,
faceMap);
1271 template<
class Face>
1278 bitSet include(this->size());
1283 : fileFormats::surfaceFormatsCore::getSelectedPatches
1291 include.
set(zones_[zonei].
range());
1294 return this->subsetMesh(include);
1298 template<
class Face>
1309 MeshReference::clearOut();
1319 template<
class Face>
1326 MeshReference::clearOut();
1328 this->storedPoints().transfer(pointLst);
1329 this->storedFaces().transfer(faceLst);
1330 this->storedZones().clear();
1331 this->storedFaceIds().clear();
1335 template<
class Face>
1346 MeshReference::clearOut();
1357 template<
class Face>
1371 if (zoneLst.
size() > 1)
1378 sortedFaces[
faceMap[facei]].transfer(faceLst[facei]);
1381 faceLst.
swap(sortedFaces);
1384 MeshedSurface<Face> newSurf
1393 this->swap(newSurf);
1397 template<
class Face>
1405 template<
class Face>
1408 MeshReference::clearOut();
1410 this->storedFaceIds().clear();
1412 this->storedFaces().swap(faces);
1418 template<
class Face>
1424 this->storedPoints().swap(
points);
1428 template<
class Face>
1437 template<
class Face>
1441 const word& fileType
1450 template<
class Face>
1454 const word& surfName
1463 template<
class Face>
1474 this->storedPoints() = surf.
points();
1476 this->storedFaceIds() = surf.
faceIds();
1481 template<
class Face>
1488 template<
class Face>
1491 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 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)
void swap(UList< T > &list)
Swap content with another UList of the same type in constant time.
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)
A list of faces which address into the list of points.
A List obtained as a section of another List.
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 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.
label size() const noexcept
The number of entries in the list.
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 additional search methods and registered IO...
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.
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)
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
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...
PrimitivePatch< List< face >, const pointField > bMesh
Holder of faceList and points. (v.s. e.g. primitivePatch which references points) ...
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.
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.