54#ifndef Foam_PrimitivePatch_H
55#define Foam_PrimitivePatch_H
74template<
class T>
class Map;
82template<
class FaceList,
class Po
intField>
94 std::remove_reference<FaceList>::type::value_type
face_type;
98 std::remove_reference<PointField>::type::value_type
point_type;
135 mutable std::unique_ptr<edgeList> edgesPtr_;
138 mutable label nInternalEdges_;
141 mutable std::unique_ptr<labelList> boundaryPointsPtr_;
144 mutable std::unique_ptr<labelListList> faceFacesPtr_;
147 mutable std::unique_ptr<labelListList> edgeFacesPtr_;
150 mutable std::unique_ptr<labelListList> faceEdgesPtr_;
153 mutable std::unique_ptr<labelListList> pointEdgesPtr_;
156 mutable std::unique_ptr<labelListList> pointFacesPtr_;
159 mutable std::unique_ptr<List<face_type>> localFacesPtr_;
162 mutable std::unique_ptr<labelList> meshPointsPtr_;
166 mutable std::unique_ptr<Map<label>> meshPointMapPtr_;
169 mutable std::unique_ptr<labelListList> edgeLoopsPtr_;
172 mutable std::unique_ptr<Field<point_type>> localPointsPtr_;
175 mutable std::unique_ptr<labelList> localPointOrderPtr_;
178 mutable std::unique_ptr<Field<point_type>> faceCentresPtr_;
181 mutable std::unique_ptr<Field<point_type>> faceAreasPtr_;
184 mutable std::unique_ptr<Field<scalar>> magFaceAreasPtr_;
187 mutable std::unique_ptr<Field<point_type>> faceNormalsPtr_;
190 mutable std::unique_ptr<Field<point_type>> pointNormalsPtr_;
196 void calcInternPoints()
const;
199 void calcBdryPoints()
const;
202 void calcAddressing()
const;
205 void calcPointEdges()
const;
208 void calcPointFaces()
const;
211 void calcMeshData()
const;
214 void calcMeshPointMap()
const;
217 void calcEdgeLoops()
const;
220 void calcLocalPoints()
const;
223 void calcLocalPointOrder()
const;
226 void calcFaceCentres()
const;
229 void calcFaceAreas()
const;
232 void calcMagFaceAreas()
const;
235 void calcFaceNormals()
const;
238 void calcPointNormals()
const;
243 void visitPointRegion
247 const label startFacei,
248 const label startEdgei,
260 const FaceList& faces,
312 return FaceList::size();
472 scalar
sphere(
const label facei)
const;
477 bool hasFaceAreas()
const {
return bool(faceAreasPtr_); }
487 bool hasEdges()
const {
return bool(edgesPtr_); }
488 bool hasFaceFaces()
const {
return bool(faceFacesPtr_); }
490 bool hasFaceEdges()
const {
return bool(faceEdgesPtr_); }
502 template<
class ToPatch>
505 const ToPatch& targetPatch,
512 template<
class ToPatch>
515 const ToPatch& targetPatch,
543 const bool report =
false,
555 const bool report =
false,
labelHashSet * pointSetPtr
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
labelHashSet * badEdgesPtr
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
A HashTable to objects of type <T> with a label key.
An ordered pair of two objects of type <T> with first() and second() elements.
PrimitivePatchBase()=default
Default construct.
A list of faces which address into the list of points.
label nEdges() const
Number of edges in patch.
bool hasPointFaces() const
label nPoints() const
Number of points supporting patch faces.
label nFaces() const noexcept
Number of faces in the patch.
label nBoundaryEdges() const
Number of boundary edges == (nEdges() - nInternalEdges()).
List< face > FaceListType
const labelListList & pointEdges() const
Return point-edge addressing.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
label nInternalEdges() const
Number of internal edges.
bool checkTopology(const bool report=false, labelHashSet *pointSetPtr=nullptr) const
Check surface formed by patch for manifoldness (see above).
bool hasBoundaryPoints() const
edge meshEdge(const edge &e) const
From patch edge to global edge using meshPoints.
PrimitivePatch(const PrimitivePatch< FaceList, PointField > &pp)
Copy construct.
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Return labels of patch edges in the global edge list using cell addressing.
bool hasFaceNormals() const
const Map< label > & meshPointMap() const
Mesh point map.
const edgeList::subList internalEdges() const
Return sub-list of internal edges, address into LOCAL point list.
List< objectHit > projectFaceCentres(const ToPatch &targetPatch, const Field< point_type > &projectionDirection, const intersection::algorithm=intersection::FULL_RAY, const intersection::direction=intersection::VECTOR) const
Project vertices of patch onto another patch.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
bool hasFaceAreas() const
edge meshEdge(const label edgei) const
From patch edge to global edge using meshPoints.
void operator=(const PrimitivePatch< FaceList, PointField > &rhs)
Copy assign faces. Leave points alone (could be a reference).
bool hasFaceCentres() const
const Field< point_type > & localPoints() const
Return pointField of points in patch.
label meshEdge(const label edgei, const edgeList &allEdges, const labelListList &pointEdges) const
Return label of the local patch edge into the global edge list using basic edge addressing.
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
const labelList & localPointOrder() const
Return orders the local points for most efficient search.
PrimitivePatch(FaceList &faces, PointField &points, const bool reuse)
Construct from components, reuse storage.
PrimitivePatch(const FaceList &faces, const PointField &points)
Construct from components.
const Field< point_type > & pointNormals() const
Return point normals for patch.
const edgeList::subList boundaryEdges() const
Return sub-list of boundary edges, address into LOCAL point list.
std::remove_reference< const pointField >::type::value_type point_type
bool hasMeshPointMap() const
labelList meshEdges(const edgeList &allEdges, const labelListList &pointEdges) const
Return labels of patch edges into the global edge list using basic edge addressing.
labelList boundaryFaces() const
Extract list of local faces corresponding to the boundary edges.
const Field< point_type > & points() const noexcept
bool checkPointManifold(const bool report=false, labelHashSet *pointSetPtr=nullptr) const
Checks primitivePatch for faces sharing point but not edge.
Pair< point_type > box() const
The enclosing (bounding) box for the patch points.
const Field< point_type > & faceAreas() const
Return face area vectors for patch.
const pointField PointFieldType
label whichPoint(const label gp) const
Given a global point index, return the local point index.
const labelListList & edgeLoops() const
Return list of closed loops of boundary vertices.
scalar sphere(const label facei) const
The enclosing (bounding) sphere radius^2 for specified face.
virtual void movePoints(const Field< point_type > &)
Correct patch after moving points.
bool isInternalEdge(const label edgei) const
Is internal edge?
const labelList & boundaryPoints() const
Return list of boundary points, address into LOCAL point list.
const Field< point_type > & faceCentres() const
Return face centres for patch.
const labelListList & faceFaces() const
Return face-face addressing.
virtual ~PrimitivePatch()
Destructor.
bool hasPointNormals() const
void swap(PrimitivePatch &)=delete
Suppress direct swapping, since storage containers may be const.
const labelListList & pointFaces() const
Return point-face addressing.
void operator=(PrimitivePatch< FaceList, PointField > &&rhs)
Move assign faces. Leave points alone (could be a reference).
surfaceTopo surfaceType(labelHashSet *badEdgesPtr=nullptr) const
Calculate surface type formed by patch, optionally recording the indices of illegal edges.
std::remove_reference< List< face > >::type::value_type face_type
bool hasFaceEdges() const
const labelListList & edgeFaces() const
Return edge-face addressing.
const labelListList & faceEdges() const
Return face-edge addressing.
void clearPatchMeshAddr()
const Field< scalar > & magFaceAreas() const
Return face area magnitudes for patch.
List< objectHit > projectPoints(const ToPatch &targetPatch, const Field< point_type > &projectionDirection, const intersection::algorithm=intersection::FULL_RAY, const intersection::direction=intersection::VECTOR) const
Project vertices of patch onto another patch.
label whichEdge(const edge &e) const
Identical to findEdge.
labelList meshEdges(const labelUList &edgeLabels, const edgeList &allEdges, const labelListList &pointEdges) const
Return labels of specified patch edges into the global edge list using basic edge addressing.
bool hasEdgeFaces() const
label findEdge(const edge &e) const
Search for edge (local point labels) and return its index in the edge list or -1 if not found.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
bool hasMeshPoints() const
bool hasPointEdges() const
PrimitivePatch(FaceList &&faces, const PointField &points)
Construct from components, transferring faces.
surfaceTopo
Enumeration defining the surface type. Used in check routines.
bool hasFaceFaces() const
labelList uniqBoundaryFaces() const
Extract sorted list of unique local faces associated with the boundary edges.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Smooth ATC in cells next to a set of patches supplied by type.
List< edge > edgeList
List of edge.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
GeometricField< Type, pointPatchField, pointMesh > PointField
A point field for a given type.
UList< label > labelUList
A UList of labels.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::HEX);labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells].reset(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} pointMap[start]=pointMap[end]=Foam::min(start, end);} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};constexpr label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< DynamicList< face > > pFaces[nBCs]