Go to the documentation of this file.
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(),
104 return canReadType(ext, verbose);
125 const word& fileType,
131 if (fileType.empty())
140 <<
"Cannot determine format from filename" <<
nl
145 write(
name, ext, surf, streamOpt, options);
152 auto mfIter = writefileExtensionMemberFunctionTablePtr_->cfind(fileType);
157 const wordHashSet delegate(ProxyType::writeTypes());
159 if (!delegate.
found(fileType))
162 <<
"Unknown write format " << fileType <<
nl <<
nl
163 <<
"Valid types:" <<
nl
164 <<
flatOutput((delegate | writeTypes()).sortedToc()) <<
nl
170 name, fileType, streamOpt, options
175 mfIter()(
name, surf, streamOpt, options);
198 faceIds_(surf.faceIds_),
223 newFaces[
faceMap[facei]] = origFaces[facei];
226 this->storedFaces().
transfer(newFaces);
230 const labelList& origIds = surf.faceIds();
232 if (origIds.size() == origFaces.size())
238 newFaceIds[
faceMap[facei]] = origIds[facei];
241 this->storedFaceIds().
transfer(newFaceIds);
311 if (zoneSizes.
size())
313 if (zoneNames.
size())
315 addZones(zoneSizes, zoneNames);
338 if (zoneSizes.
size())
340 if (zoneNames.
size())
342 addZones(zoneSizes, zoneNames);
365 this->transcribe(surf);
373 const bool useGlobalPoints
387 mesh.nBoundaryFaces(),
388 mesh.nInternalFaces()
396 useGlobalPoints ?
mesh.points() : allBoundary.localPoints()
402 useGlobalPoints ? allBoundary : allBoundary.localFaces()
409 label startFacei = 0;
424 startFacei +=
p.size();
428 newZones.setSize(nZone);
433 this->transcribe(surf);
494 IOobject::MUST_READ_IF_MODIFIED,
504 std::move(*(
mesh.releaseGeom()))
507 this->transcribe(surf);
523 fileFormats::surfaceFormatsCore::checkFile(io,
dict, isGlobal)
526 this->
read(fName,
dict.getOrDefault<
word>(
"fileType", word::null));
528 this->scalePoints(
dict.getOrDefault<scalar>(
"scale", 0));
549 if (faceMapNewToOld.
empty())
556 if (zones.size() == 1)
559 zones[0].size() = faceMapNewToOld.
size();
570 zone.start() = newFacei;
571 origEndi +=
zone.size();
573 for (label facei = newFacei; facei < faceMapNewToOld.
size(); ++facei)
575 if (faceMapNewToOld[facei] < origEndi)
586 zone.size() = newFacei -
zone.start();
596 MeshReference::clearOut();
598 storedPoints().clear();
599 storedFaces().clear();
600 storedFaceIds().clear();
601 storedZones().clear();
608 MeshReference::clearGeom();
611 MeshReference::movePoints(newPoints);
614 storedPoints() = newPoints;
622 if (scaleFactor > 0 && scaleFactor != 1.0)
624 MeshReference::clearGeom();
629 MeshReference::movePoints(newPoints);
631 storedPoints() = std::move(newPoints);
641 stitchFaces(SMALL, verbose);
661 bool hasMerged =
mergePoints(pointLst, tol, verbose, pointMap, newPoints);
674 pointLst.transfer(newPoints);
684 Face&
f = faceLst[facei];
685 for (label& vert :
f)
687 vert = pointMap[vert];
691 if (
f.collapse() >= 3)
693 if (newFacei != facei)
695 faceLst[newFacei] =
f;
702 Pout<<
"MeshedSurface::stitchFaces : "
703 <<
"Removing collapsed face " << facei <<
endl
704 <<
" vertices :" <<
f <<
endl;
709 if (newFacei != faceLst.size())
713 Pout<<
"MeshedSurface::stitchFaces : "
714 <<
"Removed " << faceLst.size() - newFacei
725 faceIds_[facei] = faceIds_[
faceMap[facei]];
728 faceIds_.resize(newFacei);
736 MeshReference::clearOut();
749 bool changed =
false;
755 const label maxPointi = this->
points().size();
760 Face&
f = faceLst[facei];
763 if (
f.collapse() >= 3)
765 for (
const label vert :
f)
767 if (vert < 0 || vert >= maxPointi)
771 <<
" uses point indices outside point range 0.."
789 <<
"face[" << facei <<
"] = " <<
f
790 <<
" does not have three unique vertices" <<
endl;
807 const Face&
f = faceLst[facei];
811 const labelList& neighbours = fFaces[facei];
815 for (
const label neiFacei : neighbours)
817 if (neiFacei <= facei ||
faceMap[neiFacei] < 0)
824 const Face& nei = faceLst[neiFacei];
833 <<
"faces share the same vertices:" <<
nl
834 <<
" face[" << facei <<
"] : " <<
f <<
nl
835 <<
" face[" << neiFacei <<
"] : " << nei <<
endl;
861 if (changed || newFacei < faceLst.size())
868 <<
"Removed " << faceLst.size() - newFacei
869 <<
" illegal faces." <<
endl;
878 if (newFacei != facei)
880 faceLst[newFacei] = std::move(faceLst[facei]);
895 faceIds_[facei] = faceIds_[
faceMap[facei]];
898 faceIds_.resize(newFacei);
906 MeshReference::clearOut();
916 return MeshReference::size();
921 const_cast<labelList&
>(labelList::null())
936 for (
const auto&
f : faceLst)
938 nTri +=
f.nTriangles();
942 if (nTri <= faceLst.size())
957 label
n = faceLst[facei].nTriangles();
983 const_cast<labelList&
>(labelList::null())
1016 for (
const auto&
f : faceLst)
1018 const label
n =
f.nTriangles();
1027 if (nTri <= faceLst.size())
1033 this->storedFaceIds().clear();
1038 if (this->
points().empty())
1045 const Face&
f = faceLst[facei];
1047 for (label fp = 1; fp <
f.size() - 1; ++fp)
1049 const label fp1 =
f.fcIndex(fp);
1051 newFaces[nTri] = Face{
f[0],
f[fp],
f[fp1]};
1066 const face&
f = faceLst[facei];
1069 f.triangles(this->
points(), nTmp, tmpTri);
1070 for (label triI = 0; triI < nTmp; triI++)
1072 newFaces[nTri] = Face
1083 nTri -= faceLst.size();
1085 faceLst.transfer(newFaces);
1089 MeshReference::clearOut();
1095 template<
class Face>
1103 const pointField& locPoints = this->localPoints();
1104 const List<Face>& locFaces = this->localFaces();
1110 labelList oldToNew(locPoints.size(), -1);
1113 oldToNew[pointMap[pointi]] = pointi;
1117 List<Face> newFaces(UIndirectList<Face>(locFaces,
faceMap));
1120 for (
auto&
f : newFaces)
1122 for (label& vert :
f)
1124 vert = oldToNew[vert];
1136 for (surfZone& zone : newZones)
1139 origEndi += zone.size();
1142 zone.start() = newFacei;
1144 for (label facei = newFacei; facei <
faceMap.size(); ++facei)
1146 if (
faceMap[facei] < origEndi)
1157 zone.size() = newFacei - zone.start();
1163 if (faceIds_.size())
1169 MeshedSurface<Face> newSurf;
1170 newSurf.storedFaces().transfer(newFaces);
1171 newSurf.storedPoints().transfer(newPoints);
1172 newSurf.storedZones().transfer(newZones);
1173 newSurf.storedFaceIds().transfer(newFaceIds);
1179 template<
class Face>
1188 this->subsetMeshMap(include, pointMap,
faceMap);
1189 return this->subsetMeshImpl(pointMap,
faceMap);
1193 template<
class Face>
1202 this->subsetMeshMap(include, pointMap,
faceMap);
1203 return this->subsetMeshImpl(pointMap,
faceMap);
1207 template<
class Face>
1215 return this->subsetMesh(include, pointMap,
faceMap);
1219 template<
class Face>
1227 return this->subsetMesh(include, pointMap,
faceMap);
1231 template<
class Face>
1238 bitSet include(this->size());
1243 : fileFormats::surfaceFormatsCore::getSelectedPatches
1251 include.
set(zones_[zonei].
range());
1254 return this->subsetMesh(include);
1258 template<
class Face>
1269 MeshReference::clearOut();
1279 template<
class Face>
1286 MeshReference::clearOut();
1288 this->storedPoints().transfer(pointLst);
1289 this->storedFaces().transfer(faceLst);
1290 this->storedZones().clear();
1291 this->storedFaceIds().clear();
1295 template<
class Face>
1306 MeshReference::clearOut();
1317 template<
class Face>
1331 if (zoneLst.size() > 1)
1338 sortedFaces[
faceMap[facei]].transfer(faceLst[facei]);
1341 faceLst.swap(sortedFaces);
1346 std::move(surf.storedPoints()),
1353 this->swap(newSurf);
1357 template<
class Face>
1365 template<
class Face>
1368 MeshReference::clearOut();
1370 this->storedFaceIds().clear();
1372 this->storedFaces().swap(faces);
1376 template<
class Face>
1379 MeshReference::clearOut();
1381 this->storedPoints().swap(
points);
1385 template<
class Face>
1394 template<
class Face>
1398 const word& fileType
1402 transfer(*
New(
name, fileType));
1407 template<
class Face>
1411 const word& surfName
1420 template<
class Face>
1431 this->storedPoints() = surf.points();
1433 this->storedFaceIds() = surf.
faceIds();
1438 template<
class Face>
1445 template<
class Face>
const labelList & faceIds() const
Return const access to faces ids.
word lessExt() const
Return word without extension (part before last .)
List< label > labelList
A List of labels.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
#define InfoInFunction
Report an information message using Foam::Info.
const surfZoneList & surfZones() const
Const access to the surface zones.
virtual ~MeshedSurface()
Destructor.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
A class for handling words, derived from Foam::string.
List< Face > & storedFaces()
Non-const access to the faces.
A class for handling file names.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
labelList & storedFaceIds()
Non-const access to face ids.
static bool canReadType(const word &fileType, bool verbose=false)
Can we read this file format? Also checks friend types.
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
void swap(MeshedSurface< Face > &surf)
Swap contents.
pointField & storedPoints()
Non-const access to global points.
virtual bool stitchFaces(const scalar tol=SMALL, const bool verbose=false)
A List obtained as a section of another List.
void operator=(const MeshedSurface< Face > &surf)
Copy assignment.
Base class for mesh zones.
const List< Face > & surfFaces() const
Return const access to the faces.
void set(const bitSet &bitset)
Set specified bits from another bitset.
virtual void scalePoints(const scalar scaleFactor)
Scale points. A non-positive factor is ignored.
A surface mesh consisting of general polygon faces that has IO capabilities and a registry for storin...
Ostream & endl(Ostream &os)
Add newline and flush stream.
word ext() const
Return file name extension (part after last .)
virtual void clear()
Clear all storage.
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.
label checkTopology(const polyMesh &mesh, const bool allTopology, const bool allGeometry, autoPtr< surfaceWriter > &surfWriter, const autoPtr< writer< scalar >> &setWriter)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
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.
Mesh consisting of general polyhedral cells.
virtual bool checkFaces(const bool verbose=false)
#define forAll(list, i)
Loop across all elements in list.
static bool canRead(const fileName &name, bool verbose=false)
Can we read this file format?
surfZoneList & storedZones()
Non-const access to the zones.
void transfer(pointField &pointLst, List< Face > &faceLst)
Transfer the components.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
#define DebugInFunction
Report an information message using Foam::Info.
A patch is a list of labels that address the faces in the global face list.
word name(const complex &c)
Return string representation of complex.
PrimitivePatch< List< face >, const pointField > bMesh
Holder of faceList and points. (v.s. e.g. primitivePatch which references points)
void transfer(List< T > &list)
The IOstreamOption is a simple container for options an IOstream can normally have.
virtual label nTriangles() const
Count number of triangles.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
void resize(const label newSize)
Adjust allocated size of list.
void swapPoints(pointField &points)
Swap the stored points.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
bool notNull(const T *ptr)
True if ptr is not a pointer (of type T) to the nullObject.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Macros for easy insertion into run-time selection tables.
static wordHashSet readTypes()
Known readable file-types, without friends or proxies.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
label mergePoints(const PointList &points, const scalar mergeTol, const bool verbose, labelList &pointMap, typename PointList::const_reference origin=PointList::value_type::zero)
Sorts and merges points. All points closer than/equal mergeTol get merged.
errorManipArg< error, int > exit(error &err, const int errNo=1)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
virtual void movePoints(const pointField &newPoints)
Move points.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual void clear()
Clear all storage.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A surface zone on a MeshedSurface.
A List of wordRe with additional matching capabilities.
void clear()
Clear the list, i.e. set size to zero.
MeshedSurface()
Default construct, an empty surface.
List< surfZone > surfZoneList
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
HashSet< word > wordHashSet
A HashSet with word keys.
static wordHashSet writeTypes()
Known writable file-types, without friends or proxies.
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
A List with indirect addressing.
A face is a list of labels corresponding to mesh vertices.
Various functions to operate on Lists.
bool found(const Key &key) const
Return true if hashed entry is found in table.
void swapFaces(List< Face > &faces)
Swap the stored faces. Use with caution.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
#define WarningInFunction
Report a warning using Foam::Warning.
MeshedSurface subsetMesh(const UList< bool > &include, labelList &pointMap, labelList &faceMap) const
Return a new surface subsetted on the selected faces.
virtual void remapFaces(const labelUList &faceMapNewToOld)
Set new zones from faceMap.
surfZoneList sortedZones(labelList &faceMap) const
Sort faces according to zoneIds.
autoPtr< MeshedSurface< Face > > releaseGeom()
Release (clear) geometry and return for reuse.
virtual void cleanup(const bool verbose)
Remove invalid faces.
A list of faces which address into the list of points.
UIndirectList< label > labelUIndList
UIndirectList of labels.