47 return wordHashSet(*fileExtensionConstructorTablePtr_);
54 return wordHashSet(*writefileExtensionMemberFunctionTablePtr_);
67 readTypes() | FriendType::readTypes(),
84 writeTypes() | ProxyType::writeTypes(),
111void Foam::MeshedSurface<Face>::write
124void Foam::MeshedSurface<Face>::write
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);
200 faceIds_(surf.faceIds_),
225 newFaces[
faceMap[facei]] = origFaces[facei];
234 if (origIds.size() == origFaces.
size())
240 newFaceIds[
faceMap[facei]] = origIds[facei];
251 MeshedSurface<Face>&& surf
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
379 const bool useGlobalPoints
389 label startFacei = 0;
404 startFacei +=
p.size();
408 newZones.setSize(nZone);
426 allBoundary.localPoints(),
427 allBoundary.localFaces(),
439 const fileName&
name,
503 std::move(*(
mesh.releaseGeom()))
548 if (faceMapNewToOld.
empty())
555 if (zones.size() == 1)
558 zones[0].size() = faceMapNewToOld.
size();
569 zone.start() = newFacei;
572 for (label facei = newFacei; facei < faceMapNewToOld.
size(); ++facei)
574 if (faceMapNewToOld[facei] < origEndi)
595 MeshReference::clearOut();
597 storedPoints().clear();
607 MeshReference::clearGeom();
610 MeshReference::movePoints(newPoints);
621 if (scaleFactor > SMALL && !
equal(scaleFactor, 1))
659 for (label& pointi :
f)
661 label compacti = oldToCompact[pointi];
664 compacti = compactPointMap.size();
665 oldToCompact[pointi] = compacti;
666 compactPointMap.append(pointi);
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);
949 return MeshReference::size();
969 for (
const auto&
f : faceLst)
971 nTri +=
f.nTriangles();
975 if (nTri <= faceLst.
size())
990 label
n = faceLst[facei].nTriangles();
1049 for (
const auto&
f : faceLst)
1051 const label
n =
f.nTriangles();
1060 if (nTri <= faceLst.size())
1066 this->storedFaceIds().clear();
1071 if (this->
points().empty())
1078 const Face&
f = faceLst[facei];
1080 for (label fp = 1; fp <
f.
size() - 1; ++fp)
1084 newFaces[nTri] = Face{
f[0],
f[fp],
f[fp1]};
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
1116 nTri -= faceLst.size();
1118 faceLst.transfer(newFaces);
1122 MeshReference::clearOut();
1129Foam::MeshedSurface<Face>
1130Foam::MeshedSurface<Face>::subsetMeshImpl
1136 const pointField& locPoints = this->localPoints();
1137 const List<Face>& locFaces = this->localFaces();
1143 labelList oldToNew(locPoints.size(), -1);
1146 oldToNew[pointMap[pointi]] = pointi;
1153 for (
auto&
f : newFaces)
1155 for (label& vert :
f)
1157 vert = oldToNew[vert];
1175 zone.start() = newFacei;
1177 for (label facei = newFacei; facei <
faceMap.size(); ++facei)
1179 if (
faceMap[facei] < origEndi)
1196 if (faceIds_.size())
1204 newSurf.storedPoints().transfer(newPoints);
1205 newSurf.storedZones().transfer(newZones);
1206 newSurf.storedFaceIds().transfer(newFaceIds);
1222 return this->subsetMeshImpl(pointMap,
faceMap);
1236 return this->subsetMeshImpl(pointMap,
faceMap);
1271 bitSet include(this->size());
1284 include.set(zones_[zonei].
range());
1287 return this->subsetMesh(include);
1294 MeshedSurface<Face>& surf
1302 MeshReference::clearOut();
1305 this->storedPoints().swap(surf.storedPoints());
1319 MeshReference::clearOut();
1321 this->storedPoints().transfer(pointLst);
1339 MeshReference::clearOut();
1364 if (zoneLst.
size() > 1)
1374 faceLst.
swap(sortedFaces);
1377 MeshedSurface<Face> newSurf
1386 this->
swap(newSurf);
1401 MeshReference::clearOut();
1403 this->storedFaceIds().clear();
1422bool Foam::MeshedSurface<Face>::read(
const fileName&
name)
1431bool Foam::MeshedSurface<Face>::read
1434 const word& fileType
1444void Foam::MeshedSurface<Face>::write
1447 const word& surfName
1467 this->storedPoints() = surf.
points();
1484 return MeshedSurfaceProxy<Face>
Various functions to operate on Lists.
Macros for easy insertion into run-time selection tables.
const polyBoundaryMesh & pbm
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
bool found(const Key &key) const
Same as contains().
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A simple container for options an IOstream can normally have.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
void setSize(label n)
Alias for resize().
void resize(const label len)
Adjust allocated size of list.
void clear()
Clear the list, i.e. set size to zero.
static const List< T > & null() noexcept
Return a null List (reference to a nullObject). Behaves like an empty List.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
static wordHashSet writeTypes()
The file format types that can be written via MeshedSurfaceProxy.
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.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
MeshedSurface subsetMesh(const UList< bool > &include, labelList &pointMap, labelList &faceMap) const
Return a new surface subsetted on the selected faces.
virtual void movePoints(const pointField &newPoints)
Move points.
surfZoneList & storedZones()
Non-const access to the zones.
static bool canWriteType(const word &fileType, bool verbose=false)
Can we write this file format? Also checks proxy types.
labelList & storedFaceIds()
Non-const access to face ids.
const surfZoneList & surfZones() const
Const access to the surface zones.
pointField & storedPoints()
Non-const access to global points.
static wordHashSet writeTypes()
Known writable file-types, without friends or proxies.
virtual void remapFaces(const labelUList &faceMapNewToOld)
Set new zones from faceMap.
void transfer(pointField &pointLst, List< Face > &faceLst)
Transfer the components.
static bool canReadType(const word &fileType, bool verbose=false)
Can we read this file format? Also checks friend types.
virtual void cleanup(const bool verbose)
Remove invalid faces.
virtual ~MeshedSurface()
Destructor.
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
void swapPoints(pointField &points)
virtual void compactPoints(labelList &pointMap=const_cast< labelList & >(labelList::null()))
Remove unused points and renumber faces in local visit order.
static bool canRead(const fileName &name, bool verbose=false)
Can we read this file format?
void checkZones(const bool verbose=true)
Sanity check/resizing on zones.
const labelList & faceIds() const
Return const access to faces ids.
const List< face > & surfFaces() const
MeshedSurface(const MeshedSurface< Foam::face > &surf)
void subsetMeshMap(const BoolListType &include, labelList &pointMap, labelList &faceMap) const
Create mappings for a sub-surface.
autoPtr< MeshedSurface< Face > > releaseGeom()
Release (clear) geometry and return for reuse.
virtual label nTriangles() const
Count number of triangles.
List< Face > & storedFaces()
Non-const access to the faces.
void transcribe(MeshedSurface< face > &surf)
Transfer points/zones from 'face' to other other shapes.
void swap(MeshedSurface< Face > &surf)
Swap contents.
virtual void clear()
Clear all storage.
virtual bool stitchFaces(const scalar tol=SMALL, const bool verbose=false)
virtual void scalePoints(const scalar scaleFactor)
Scale points. A non-positive factor is ignored.
friend class UnsortedMeshedSurface
friend class MeshedSurface
virtual bool checkFaces(const bool verbose=false)
void operator=(const MeshedSurface< Face > &surf)
Copy assignment.
void swapFaces(List< Face > &faces)
Swap the stored faces. Use with caution.
static wordHashSet readTypes()
Known readable file-types, without friends or proxies.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
const Field< point_type > & points() const noexcept
virtual void movePoints(const Field< point_type > &)
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A List with indirect addressing. Like IndirectList but does not store addressing.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void swap(UList< T > &list) noexcept
Swap content with another UList of the same type in constant time.
static const UList< label > & null() noexcept
void size(const label n)
Older name for setAddressableSize.
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
surfZoneList sortedZones(labelList &faceMap) const
Sort faces according to zoneIds.
void transfer(UnsortedMeshedSurface< Face > &surf)
Transfer the contents of the argument and annul the argument.
virtual void clear()
Clear all storage.
static wordHashSet readTypes()
Known readable file-types, without friends or proxies.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void set(const bitSet &bitset)
Set specified bits from another bitset.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
static bool isTri()
Face-type only handles triangles. Not true in general.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
A patch is a list of labels that address the faces in the global face list.
A surface mesh consisting of general polygon faces that has IO capabilities and a registry for storin...
A surface zone on a MeshedSurface.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
static const word null
An empty word.
Base class for mesh zones.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Geometric merging of points. See below.
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugInFunction
Report an information message using Foam::Info.
#define InfoInFunction
Report an information message using Foam::Info.
List< label > sortedToc(const UList< bool > &bools)
Return the (sorted) values corresponding to 'true' entries.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
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.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
List< labelList > labelListList
List of labelList.
bool read(const char *buf, int32_t &val)
Same as readInt32.
List< label > labelList
A List of labels.
label checkTopology(const polyMesh &mesh, const bool allTopology, const bool allGeometry, autoPtr< surfaceWriter > &surfWriter, autoPtr< coordSetWriter > &setWriter, const bool writeBadEdges=false)
UIndirectList< label > labelUIndList
UIndirectList of labels.
List< surfZone > surfZoneList
List of surfZone.
bool equal(const T &a, const T &b)
Compare two values for equality.
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
label checkZones(const polyMesh &mesh, const ZoneMesh< Zone, polyMesh > &zones, topoSet &set)
Ostream & endl(Ostream &os)
Add newline and flush stream.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
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...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
bool notNull(const T *ptr) noexcept
True if ptr is not a pointer (of type T) to the nullObject.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.