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* mfuncPtr = writefileExtensionMemberFunctionTable(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 mfuncPtr(
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);
282 this->checkZones(
false);
298 this->checkZones(
false);
315 if (zoneSizes.
size())
317 if (zoneNames.
size())
319 addZones(zoneSizes, zoneNames);
342 if (zoneSizes.
size())
344 if (zoneNames.
size())
346 addZones(zoneSizes, zoneNames);
369 this->transcribe(surf);
377 const bool useGlobalPoints
391 mesh.nBoundaryFaces(),
392 mesh.nInternalFaces()
400 useGlobalPoints ?
mesh.points() : allBoundary.localPoints()
406 useGlobalPoints ? allBoundary : allBoundary.localFaces()
413 label startFacei = 0;
428 startFacei +=
p.size();
432 newZones.setSize(nZone);
437 this->transcribe(surf);
498 IOobject::MUST_READ_IF_MODIFIED,
508 std::move(*(
mesh.releaseGeom()))
511 this->transcribe(surf);
527 fileFormats::surfaceFormatsCore::checkFile(io,
dict, isGlobal)
530 this->
read(fName,
dict.getOrDefault<
word>(
"fileType", word::null));
532 this->scalePoints(
dict.getOrDefault<scalar>(
"scale", 0));
553 if (faceMapNewToOld.
empty())
560 if (zones.size() == 1)
563 zones[0].size() = faceMapNewToOld.
size();
574 zone.start() = newFacei;
575 origEndi +=
zone.size();
577 for (label facei = newFacei; facei < faceMapNewToOld.
size(); ++facei)
579 if (faceMapNewToOld[facei] < origEndi)
590 zone.size() = newFacei -
zone.start();
600 MeshReference::clearOut();
602 storedPoints().clear();
603 storedFaces().clear();
604 storedFaceIds().clear();
605 storedZones().clear();
612 MeshReference::clearGeom();
615 MeshReference::movePoints(newPoints);
618 storedPoints() = newPoints;
626 if (scaleFactor > SMALL && !
equal(scaleFactor, 1))
629 this->clearTopology();
634 this->storedPoints() *= scaleFactor;
644 stitchFaces(SMALL, verbose);
662 for (
auto&
f : this->storedFaces())
664 for (label& pointi :
f)
666 label compacti = oldToCompact[pointi];
669 compacti = compactPointMap.size();
670 oldToCompact[pointi] = compacti;
671 compactPointMap.
append(pointi);
682 this->swapPoints(newPoints);
704 bool hasMerged =
mergePoints(pointLst, tol, verbose, pointMap, newPoints);
717 pointLst.transfer(newPoints);
727 Face&
f = faceLst[facei];
728 for (label& vert :
f)
730 vert = pointMap[vert];
734 if (
f.collapse() >= 3)
736 if (newFacei != facei)
738 faceLst[newFacei] =
f;
745 Pout<<
"MeshedSurface::stitchFaces : "
746 <<
"Removing collapsed face " << facei <<
endl
747 <<
" vertices :" <<
f <<
endl;
752 if (newFacei != faceLst.size())
756 Pout<<
"MeshedSurface::stitchFaces : "
757 <<
"Removed " << faceLst.size() - newFacei
768 faceIds_[facei] = faceIds_[
faceMap[facei]];
771 faceIds_.resize(newFacei);
779 MeshReference::clearOut();
792 bool changed =
false;
798 const label maxPointi = this->
points().size();
803 Face&
f = faceLst[facei];
806 if (
f.collapse() >= 3)
808 for (
const label vert :
f)
810 if (vert < 0 || vert >= maxPointi)
814 <<
" uses point indices outside point range 0.."
832 <<
"face[" << facei <<
"] = " <<
f
833 <<
" does not have three unique vertices" <<
endl;
850 const Face&
f = faceLst[facei];
854 const labelList& neighbours = fFaces[facei];
858 for (
const label neiFacei : neighbours)
860 if (neiFacei <= facei ||
faceMap[neiFacei] < 0)
867 const Face& nei = faceLst[neiFacei];
876 <<
"faces share the same vertices:" <<
nl
877 <<
" face[" << facei <<
"] : " <<
f <<
nl
878 <<
" face[" << neiFacei <<
"] : " << nei <<
endl;
904 if (changed || newFacei < faceLst.size())
911 <<
"Removed " << faceLst.size() - newFacei
912 <<
" illegal faces." <<
endl;
921 if (newFacei != facei)
923 faceLst[newFacei] = std::move(faceLst[facei]);
938 faceIds_[facei] = faceIds_[
faceMap[facei]];
941 faceIds_.resize(newFacei);
949 MeshReference::clearOut();
959 return MeshReference::size();
964 const_cast<labelList&
>(labelList::null())
979 for (
const auto&
f : faceLst)
981 nTri +=
f.nTriangles();
985 if (nTri <= faceLst.size())
1000 label
n = faceLst[facei].nTriangles();
1014 template<
class Face>
1026 const_cast<labelList&
>(labelList::null())
1032 template<
class Face>
1059 for (
const auto&
f : faceLst)
1061 const label
n =
f.nTriangles();
1070 if (nTri <= faceLst.size())
1076 this->storedFaceIds().clear();
1081 if (this->
points().empty())
1088 const Face&
f = faceLst[facei];
1090 for (label fp = 1; fp <
f.size() - 1; ++fp)
1092 const label fp1 =
f.fcIndex(fp);
1094 newFaces[nTri] = Face{
f[0],
f[fp],
f[fp1]};
1109 const face&
f = faceLst[facei];
1112 f.triangles(this->
points(), nTmp, tmpTri);
1113 for (label triI = 0; triI < nTmp; triI++)
1115 newFaces[nTri] = Face
1126 nTri -= faceLst.size();
1128 faceLst.transfer(newFaces);
1132 MeshReference::clearOut();
1138 template<
class Face>
1146 const pointField& locPoints = this->localPoints();
1147 const List<Face>& locFaces = this->localFaces();
1153 labelList oldToNew(locPoints.size(), -1);
1156 oldToNew[pointMap[pointi]] = pointi;
1160 List<Face> newFaces(UIndirectList<Face>(locFaces,
faceMap));
1163 for (
auto&
f : newFaces)
1165 for (label& vert :
f)
1167 vert = oldToNew[vert];
1179 for (surfZone& zone : newZones)
1182 origEndi += zone.size();
1185 zone.start() = newFacei;
1187 for (label facei = newFacei; facei <
faceMap.size(); ++facei)
1189 if (
faceMap[facei] < origEndi)
1200 zone.size() = newFacei - zone.start();
1206 if (faceIds_.size())
1212 MeshedSurface<Face> newSurf;
1213 newSurf.storedFaces().transfer(newFaces);
1214 newSurf.storedPoints().transfer(newPoints);
1215 newSurf.storedZones().transfer(newZones);
1216 newSurf.storedFaceIds().transfer(newFaceIds);
1222 template<
class Face>
1231 this->subsetMeshMap(include, pointMap,
faceMap);
1232 return this->subsetMeshImpl(pointMap,
faceMap);
1236 template<
class Face>
1245 this->subsetMeshMap(include, pointMap,
faceMap);
1246 return this->subsetMeshImpl(pointMap,
faceMap);
1250 template<
class Face>
1258 return this->subsetMesh(include, pointMap,
faceMap);
1262 template<
class Face>
1270 return this->subsetMesh(include, pointMap,
faceMap);
1274 template<
class Face>
1281 bitSet include(this->size());
1286 : fileFormats::surfaceFormatsCore::getSelectedPatches
1294 include.
set(zones_[zonei].
range());
1297 return this->subsetMesh(include);
1301 template<
class Face>
1312 MeshReference::clearOut();
1322 template<
class Face>
1329 MeshReference::clearOut();
1331 this->storedPoints().transfer(pointLst);
1332 this->storedFaces().transfer(faceLst);
1333 this->storedZones().clear();
1334 this->storedFaceIds().clear();
1338 template<
class Face>
1349 MeshReference::clearOut();
1360 template<
class Face>
1374 if (zoneLst.size() > 1)
1381 sortedFaces[
faceMap[facei]].transfer(faceLst[facei]);
1384 faceLst.swap(sortedFaces);
1389 std::move(surf.storedPoints()),
1396 this->swap(newSurf);
1400 template<
class Face>
1408 template<
class Face>
1411 MeshReference::clearOut();
1413 this->storedFaceIds().clear();
1415 this->storedFaces().swap(faces);
1417 this->checkZones(
false);
1421 template<
class Face>
1425 MeshReference::movePoints(
points);
1427 this->storedPoints().swap(
points);
1431 template<
class Face>
1440 template<
class Face>
1444 const word& fileType
1448 transfer(*
New(
name, fileType));
1453 template<
class Face>
1457 const word& surfName
1466 template<
class Face>
1477 this->storedPoints() = surf.points();
1479 this->storedFaceIds() = surf.
faceIds();
1484 template<
class Face>
1491 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.
vectorField pointField
pointField is a vectorField.
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...
void resize(const label len)
Adjust allocated size of list.
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...
void append(const T &val)
Append an element at the end of the list.
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.
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 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, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
static wordHashSet writeTypes()
Known writable file-types, without friends or proxies.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A List with indirect addressing.
A face is a list of labels corresponding to mesh vertices.
Various functions to operate on Lists.
void size(const label n)
Older name for setAddressableSize.
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 compactPoints(labelList &pointMap=const_cast< labelList & >(labelList::null()))
Remove unused points and renumber faces in local visit order.
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.