netgen/libsrc/meshing/topology.hpp

986 lines
21 KiB
C++
Raw Normal View History

2009-01-13 04:40:13 +05:00
#ifndef TOPOLOGY
#define TOPOLOGY
/**************************************************************************/
/* File: topology.hh */
/* Author: Joachim Schoeberl */
/* Date: 27. Apr. 01 */
/**************************************************************************/
/*
Mesh topology
(Elements, Faces, Edges, Vertices
*/
2016-01-07 17:37:48 +05:00
namespace netgen
{
typedef int T_EDGE;
typedef int T_FACE;
2014-01-07 16:42:39 +06:00
2009-01-13 04:40:13 +05:00
class MeshTopology
{
const Mesh * mesh;
2021-06-24 10:38:49 +05:00
bool buildvertex2element;
2009-01-13 04:40:13 +05:00
bool buildedges;
bool buildfaces;
2021-02-18 03:32:15 +05:00
bool build_parent_edges = false; // may be changed to default = false
bool build_parent_faces = false; // may be changed to default = false
2021-06-24 10:38:49 +05:00
static bool static_buildedges, static_buildfaces, static_buildvertex2element;
2009-01-13 04:40:13 +05:00
2022-04-23 01:39:06 +05:00
Array<std::array<PointIndex,2>> edge2vert;
Array<std::array<PointIndex,4>> face2vert;
2022-04-21 14:37:30 +05:00
NgArray<std::array<T_EDGE,12>> edges;
NgArray<std::array<T_FACE,6>> faces;
NgArray<std::array<T_EDGE,4>> surfedges;
2019-07-09 13:39:16 +05:00
NgArray<T_EDGE> segedges;
NgArray<T_FACE> surffaces;
NgArray<INDEX_2> surf2volelement;
NgArray<int> face2surfel;
Array<SegmentIndex> edge2segment;
Table<ElementIndex, PointIndex> vert2element;
Table<SurfaceElementIndex, PointIndex> vert2surfelement;
2021-05-11 21:21:40 +05:00
Table<SegmentIndex,PointIndex> vert2segment;
Table<int,PointIndex> vert2pointelement;
2009-01-13 04:40:13 +05:00
int timestamp;
public:
int GetNSurfedges() const {return surfedges.Size();}
MeshTopology () = default;
MeshTopology (MeshTopology && top) = default;
2023-09-18 16:50:33 +05:00
DLL_HEADER MeshTopology (const Mesh & amesh);
DLL_HEADER ~MeshTopology ();
MeshTopology & operator= (MeshTopology && top) = default;
2021-06-08 22:08:07 +05:00
void SetBuildVertex2Element (bool bv2e) { buildvertex2element = bv2e; }
void SetBuildEdges (bool be) { buildedges = be; }
void SetBuildFaces (bool bf) { buildfaces = bf; }
2021-02-18 03:32:15 +05:00
void SetBuildParentEdges (bool bh) { build_parent_edges = bh; }
void SetBuildParentFaces (bool bh) { build_parent_faces = bh; }
2009-01-13 04:40:13 +05:00
2021-02-18 03:32:15 +05:00
void EnableTable (string name, bool set);
static void EnableTableStatic (string name, bool set);
2021-02-18 03:32:15 +05:00
bool HasEdges () const { return buildedges; }
bool HasFaces () const { return buildfaces; }
bool HasParentEdges () const { return build_parent_edges; }
2009-01-13 04:40:13 +05:00
void Update(NgTaskManager tm = &DummyTaskManager, NgTracer tracer = &DummyTracer);
bool NeedsUpdate() const;
2009-01-13 04:40:13 +05:00
2009-11-01 02:03:52 +05:00
int GetNEdges () const { return edge2vert.Size(); }
int GetNFaces () const { return face2vert.Size(); }
2009-01-13 04:40:13 +05:00
2016-01-07 17:37:48 +05:00
static inline short int GetNVertices (ELEMENT_TYPE et);
static inline short int GetNPoints (ELEMENT_TYPE et);
static inline short int GetNEdges (ELEMENT_TYPE et);
static inline short int GetNFaces (ELEMENT_TYPE et);
2009-01-13 04:40:13 +05:00
DLL_HEADER static const Point3d * GetVertices (ELEMENT_TYPE et);
inline static const ELEMENT_EDGE * GetEdges1 (ELEMENT_TYPE et);
inline static const ELEMENT_EDGE * GetEdges0 (ELEMENT_TYPE et);
2022-04-21 14:37:30 +05:00
inline static FlatArray<ELEMENT_EDGE> GetEdges (ELEMENT_TYPE et);
inline static const ELEMENT_FACE * GetFaces1 (ELEMENT_TYPE et);
inline static const ELEMENT_FACE * GetFaces0 (ELEMENT_TYPE et);
2022-04-21 14:37:30 +05:00
[[deprecated("use GetEdge(SegmentIndex) instead")]]
int GetSegmentEdge (int segnr) const { return segedges[segnr-1]+1; }
2022-04-21 14:37:30 +05:00
int GetEdge (SegmentIndex segnr) const { return segedges[segnr]; }
2009-01-13 04:40:13 +05:00
2022-04-21 14:37:30 +05:00
[[deprecated("use GetEdge(SegmentIndex) instead")]]
2022-04-29 10:20:47 +05:00
void GetSegmentEdge (int segnr, int & enr, int & orient) const;
/*
2009-01-13 04:40:13 +05:00
{
enr = segedges.Get(segnr)+1;
// orient = segedges.Get(segnr).orient;
orient = GetSegmentEdgeOrientation(segnr);
2022-04-29 10:20:47 +05:00
}
*/
2009-01-13 04:40:13 +05:00
[[deprecated("use GetEdges (ElementIndex) -> FlatArray")]]
2019-07-09 13:39:16 +05:00
void GetElementEdges (int elnr, NgArray<int> & edges) const;
[[deprecated("use GetFaces (ElementIndex) -> FlatArray")]]
2023-07-31 03:13:56 +05:00
void GetElementFaces (int elnr, NgArray<int> & faces) const;
void GetElementFaces (int elnr, NgArray<int> & faces, bool withorientation) const;
2022-04-21 14:37:30 +05:00
2022-04-23 01:39:06 +05:00
// definition in meshclass.hpp
inline FlatArray<T_EDGE> GetEdges (ElementIndex elnr) const;
inline FlatArray<T_FACE> GetFaces (ElementIndex elnr) const;
2022-10-26 19:45:15 +05:00
// [[deprecated("use GetElementEdge instead")]]
2019-07-09 13:39:16 +05:00
void GetElementEdgeOrientations (int elnr, NgArray<int> & eorient) const;
2022-10-26 19:45:15 +05:00
// [[deprecated("use GetElementEdge instead")]]
2019-07-09 13:39:16 +05:00
void GetElementFaceOrientations (int elnr, NgArray<int> & forient) const;
2009-01-13 04:40:13 +05:00
[[deprecated("use GetEdges (ElementIndex) -> FlatArray")]]
2009-01-13 04:40:13 +05:00
int GetElementEdges (int elnr, int * edges, int * orient) const;
2022-10-26 19:45:15 +05:00
// [[deprecated("use GetFaces (ElementIndex) -> FlatArray")]]
2009-01-13 04:40:13 +05:00
int GetElementFaces (int elnr, int * faces, int * orient) const;
2022-10-26 19:50:19 +05:00
// [[deprecated("use GetElementEdge instead")]]
int GetElementEdgeOrientation (int elnr, int locedgenr) const; // old style
2022-10-26 19:50:19 +05:00
// [[deprecated("use GetElementEdge instead")]]
int GetElementFaceOrientation (int elnr, int locfacenr) const; // old style
2022-10-26 19:50:19 +05:00
// [[deprecated("use GetElementEdge instead")]]
int GetSurfaceElementEdgeOrientation (int elnr, int locedgenr) const; // old style
2022-10-26 19:50:19 +05:00
// [[deprecated("use GetElementEdge instead")]]
int GetSurfaceElementFaceOrientation2 (int elnr) const; // old style
2022-10-26 19:50:19 +05:00
// [[deprecated("use GetElementEdge instead")]]
int GetSegmentEdgeOrientation (int elnr) const; // old style
DLL_HEADER void GetFaceVertices (int fnr, NgArray<int> & vertices) const;
DLL_HEADER void GetFaceVertices (int fnr, int * vertices) const;
2024-12-15 22:00:50 +05:00
auto GetFaceVertices (int fnr) const
{ return FlatArray (face2vert[fnr][3].IsValid() ? 4 : 3, &face2vert[fnr][0]); }
2023-07-31 01:29:54 +05:00
[[deprecated("use GetEdgeVertices -> tupe(v0,v1) instead")]]
DLL_HEADER void GetEdgeVertices (int enr, int & v1, int & v2) const;
2023-07-31 01:29:54 +05:00
[[deprecated("use GetEdgeVertices -> tupe(v0,v1) instead")]]
DLL_HEADER void GetEdgeVertices (int enr, PointIndex & v1, PointIndex & v2) const;
2022-04-21 14:37:30 +05:00
auto GetEdgeVertices (int enr) const { return tuple(edge2vert[enr][0], edge2vert[enr][1]); }
auto GetEdgeVerticesPtr (int enr) const { return &edge2vert[enr][0]; }
auto GetFaceVerticesPtr (int fnr) const { return &face2vert[fnr][0]; }
DLL_HEADER void GetFaceEdges (int fnr, NgArray<int> & edges, bool withorientation = false) const;
2009-01-13 04:40:13 +05:00
2017-02-16 02:30:48 +05:00
ELEMENT_TYPE GetFaceType (int fnr) const
2022-04-23 01:39:06 +05:00
// { return (face2vert.Get(fnr)[3] == 0) ? TRIG : QUAD; }
2024-12-15 00:21:18 +05:00
{ return (!face2vert[fnr-1][3].IsValid()) ? TRIG : QUAD; }
2009-01-13 04:40:13 +05:00
2019-07-09 13:39:16 +05:00
void GetSurfaceElementEdges (int elnr, NgArray<int> & edges) const;
2009-01-13 04:40:13 +05:00
int GetSurfaceElementFace (int elnr) const;
2022-04-21 20:16:26 +05:00
[[deprecated("orientation is outdated")]]
2019-07-09 13:39:16 +05:00
void GetSurfaceElementEdgeOrientations (int elnr, NgArray<int> & eorient) const;
2022-10-26 19:45:15 +05:00
// [[deprecated("orientation is outdated")]]
2009-01-13 04:40:13 +05:00
int GetSurfaceElementFaceOrientation (int elnr) const;
2022-04-21 14:37:30 +05:00
[[deprecated("use GetEdge -> FlatArray instead")]]
2019-07-09 13:39:16 +05:00
void GetEdges (SurfaceElementIndex elnr, NgArray<int> & edges) const;
2022-04-21 14:37:30 +05:00
2022-04-23 01:39:06 +05:00
inline FlatArray<T_EDGE> GetEdges (SurfaceElementIndex elnr) const;
2022-04-21 14:37:30 +05:00
// { return FlatArray<T_EDGE>(GetNEdges ( (*mesh)[elnr].GetType()), &surfedges[elnr][0]); }
2017-02-16 02:30:48 +05:00
int GetFace (SurfaceElementIndex elnr) const
{ return surffaces[elnr]; }
2009-01-13 04:40:13 +05:00
int GetSurfaceElementEdges (int elnr, int * edges, int * orient) const;
2014-01-07 16:42:39 +06:00
const T_EDGE * GetElementEdgesPtr (int elnr) const { return &edges[elnr][0]; }
const T_EDGE * GetSurfaceElementEdgesPtr (int selnr) const { return &surfedges[selnr][0]; }
const T_EDGE * GetSegmentElementEdgesPtr (int selnr) const { return &segedges[selnr]; }
2009-07-13 19:03:01 +06:00
2014-01-07 16:42:39 +06:00
const T_FACE * GetElementFacesPtr (int elnr) const { return &faces[elnr][0]; }
const T_FACE * GetSurfaceElementFacesPtr (int selnr) const { return &surffaces[selnr]; }
2009-07-13 19:03:01 +06:00
2009-01-13 04:40:13 +05:00
void GetSurface2VolumeElement (int selnr, int & elnr1, int & elnr2) const
{
elnr1 = surf2volelement.Get(selnr)[0];
elnr2 = surf2volelement.Get(selnr)[1];
}
int GetFace2SurfaceElement (int fnr) const { return face2surfel[fnr-1]; }
SegmentIndex GetSegmentOfEdge(int edgenr) const { return edge2segment[edgenr-1]; }
2022-04-21 14:37:30 +05:00
[[deprecated("use GetVertexElements -> FlatArray instead")]]
void GetVertexElements (int vnr, Array<ElementIndex> & elements) const;
2022-04-21 14:37:30 +05:00
2022-04-23 01:39:06 +05:00
FlatArray<ElementIndex> GetVertexElements (PointIndex vnr) const
{ return vert2element[vnr]; }
2009-01-13 04:40:13 +05:00
2022-04-21 14:37:30 +05:00
[[deprecated("use GetVertexSurfaceElements -> FlatArray instead")]]
void GetVertexSurfaceElements( int vnr, Array<SurfaceElementIndex>& elements ) const;
const auto & GetVertexSurfaceElements( ) const { return vert2surfelement; }
2022-04-21 14:37:30 +05:00
FlatArray<SurfaceElementIndex> GetVertexSurfaceElements(PointIndex vnr) const
{ return vert2surfelement[vnr]; }
2009-01-13 04:40:13 +05:00
2022-04-23 01:39:06 +05:00
FlatArray<SegmentIndex> GetVertexSegments (PointIndex vnr) const
{ return vert2segment[vnr]; }
2016-08-17 17:51:02 +05:00
2022-04-23 01:39:06 +05:00
FlatArray<int> GetVertexPointElements (PointIndex vnr) const
{ return vert2pointelement[vnr]; }
2009-01-13 04:40:13 +05:00
2023-08-21 00:54:09 +05:00
DLL_HEADER int GetVerticesEdge ( int v1, int v2) const;
2019-07-09 13:39:16 +05:00
void GetSegmentVolumeElements ( int segnr, NgArray<ElementIndex> & els ) const;
void GetSegmentSurfaceElements ( int segnr, NgArray<SurfaceElementIndex> & els ) const;
// Call this before Update() to discard old edges
2022-04-23 01:39:06 +05:00
void ClearEdges() { edge2vert.SetSize0(); }
private:
2021-05-30 21:43:09 +05:00
Array<std::tuple<int, std::array<int,3>>> parent_edges;
void BuildParentEdges ();
2021-05-30 21:43:09 +05:00
Array<std::tuple<int, std::array<int,4>>> parent_faces;
void BuildParentFaces ();
public:
auto GetParentEdges (int enr) const { return parent_edges[enr]; }
auto GetParentFaces (int fnr) const { return parent_faces[fnr]; }
2009-01-13 04:40:13 +05:00
};
2016-01-07 17:37:48 +05:00
inline short int MeshTopology :: GetNVertices (ELEMENT_TYPE et)
2009-07-13 19:03:01 +06:00
{
switch (et)
{
case SEGMENT:
case SEGMENT3:
return 2;
case TRIG:
case TRIG6:
return 3;
case QUAD:
case QUAD6:
case QUAD8:
return 4;
case TET:
case TET10:
return 4;
case PYRAMID:
case PYRAMID13:
2009-07-13 19:03:01 +06:00
return 5;
case PRISM:
case PRISM12:
case PRISM15:
2009-07-13 19:03:01 +06:00
return 6;
2023-09-21 01:21:24 +05:00
case HEX7:
return 7;
2009-07-13 19:03:01 +06:00
case HEX:
2019-01-18 02:08:35 +05:00
case HEX20:
2009-07-13 19:03:01 +06:00
return 8;
2014-01-07 16:42:39 +06:00
// default:
// cerr << "Ng_ME_GetNVertices, illegal element type " << et << endl;
2009-07-13 19:03:01 +06:00
}
return 0;
}
2016-01-07 17:37:48 +05:00
inline short int MeshTopology :: GetNPoints (ELEMENT_TYPE et)
2009-07-13 19:03:01 +06:00
{
switch (et)
{
case SEGMENT:
return 2;
case SEGMENT3:
return 3;
case TRIG:
return 3;
case TRIG6:
return 6;
case QUAD:
case QUAD6:
return 4;
2019-01-18 02:08:35 +05:00
case QUAD8:
return 8;
2009-07-13 19:03:01 +06:00
case TET:
return 4;
case TET10:
return 10;
case PYRAMID:
return 5;
case PYRAMID13:
return 13;
2009-07-13 19:03:01 +06:00
case PRISM:
return 6;
case PRISM12:
return 12;
case PRISM15:
return 15;
2009-07-13 19:03:01 +06:00
2023-09-21 01:21:24 +05:00
case HEX7:
return 7;
2009-07-13 19:03:01 +06:00
case HEX:
return 8;
2019-01-18 02:08:35 +05:00
case HEX20:
return 20;
2014-01-07 16:42:39 +06:00
// default:
// cerr << "Ng_ME_GetNVertices, illegal element type " << et << endl;
2009-07-13 19:03:01 +06:00
}
return -99;
2009-07-13 19:03:01 +06:00
}
2016-01-07 17:37:48 +05:00
inline short int MeshTopology :: GetNEdges (ELEMENT_TYPE et)
2009-07-13 19:03:01 +06:00
{
2023-09-21 01:21:24 +05:00
// __assume(et >= SEGMENT && et <= PYRAMID13);
2009-07-13 19:03:01 +06:00
switch (et)
{
case SEGMENT:
case SEGMENT3:
return 1;
case TRIG:
case TRIG6:
return 3;
case QUAD:
case QUAD6:
case QUAD8:
return 4;
case TET:
case TET10:
return 6;
case PYRAMID:
case PYRAMID13:
2009-07-13 19:03:01 +06:00
return 8;
case PRISM:
case PRISM12:
case PRISM15:
2009-07-13 19:03:01 +06:00
return 9;
2023-09-21 01:21:24 +05:00
case HEX7:
return 11;
2009-07-13 19:03:01 +06:00
case HEX:
2019-01-18 02:08:35 +05:00
case HEX20:
2009-07-13 19:03:01 +06:00
return 12;
2014-01-07 16:42:39 +06:00
// default:
// cerr << "Ng_ME_GetNEdges, illegal element type " << et << endl;
2009-07-13 19:03:01 +06:00
}
return -99;
2009-07-13 19:03:01 +06:00
}
2016-01-07 17:37:48 +05:00
inline short int MeshTopology :: GetNFaces (ELEMENT_TYPE et)
2009-07-13 19:03:01 +06:00
{
2023-09-21 01:21:24 +05:00
// __assume(et >= SEGMENT && et <= PYRAMID13);
2009-07-13 19:03:01 +06:00
switch (et)
{
case SEGMENT:
case SEGMENT3:
return 0;
case TRIG:
case TRIG6:
return 1;
case QUAD:
case QUAD6:
case QUAD8:
return 1;
case TET:
case TET10:
return 4;
case PYRAMID:
case PYRAMID13:
2009-07-13 19:03:01 +06:00
return 5;
case PRISM:
case PRISM12:
case PRISM15:
2009-07-13 19:03:01 +06:00
return 5;
case HEX:
2019-01-18 02:08:35 +05:00
case HEX20:
2023-09-21 01:21:24 +05:00
case HEX7:
2009-07-13 19:03:01 +06:00
return 6;
2016-01-07 17:37:48 +05:00
default:
return -99;
2014-01-07 16:42:39 +06:00
// default:
// cerr << "Ng_ME_GetNVertices, illegal element type " << et << endl;
2009-07-13 19:03:01 +06:00
}
}
2009-01-13 04:40:13 +05:00
const ELEMENT_EDGE * MeshTopology :: GetEdges1 (ELEMENT_TYPE et)
2009-01-13 04:40:13 +05:00
{
static ELEMENT_EDGE segm_edges[1] =
2009-01-13 04:40:13 +05:00
{ { 1, 2 }};
static ELEMENT_EDGE trig_edges[3] =
2009-01-13 04:40:13 +05:00
{ { 3, 1 },
{ 2, 3 },
{ 1, 2 }};
static ELEMENT_EDGE quad_edges[4] =
2009-01-13 04:40:13 +05:00
{ { 1, 2 },
{ 3, 4 },
{ 4, 1 },
{ 2, 3 }};
static ELEMENT_EDGE tet_edges[6] =
2009-01-13 04:40:13 +05:00
{ { 4, 1 },
{ 4, 2 },
{ 4, 3 },
{ 1, 2 },
{ 1, 3 },
{ 2, 3 }};
static ELEMENT_EDGE prism_edges[9] =
2009-01-13 04:40:13 +05:00
{ { 3, 1 },
{ 1, 2 },
{ 3, 2 },
{ 6, 4 },
{ 4, 5 },
{ 6, 5 },
{ 3, 6 },
{ 1, 4 },
{ 2, 5 }};
static ELEMENT_EDGE pyramid_edges[8] =
2009-01-13 04:40:13 +05:00
{ { 1, 2 },
{ 2, 3 },
{ 1, 4 },
{ 4, 3 },
{ 1, 5 },
{ 2, 5 },
{ 3, 5 },
{ 4, 5 }};
2023-09-21 01:21:24 +05:00
static ELEMENT_EDGE hex7_edges[11] =
{
{ 1, 2 },
{ 3, 4 },
{ 4, 1 },
{ 2, 3 },
{ 5, 6 },
{ 7, 5 },
{ 6, 7 },
{ 1, 5 },
{ 2, 6 },
{ 3, 7 },
{ 4, 7 },
};
static ELEMENT_EDGE hex_edges[12] =
2009-01-13 04:40:13 +05:00
{
{ 1, 2 },
{ 3, 4 },
{ 4, 1 },
{ 2, 3 },
{ 5, 6 },
{ 7, 8 },
{ 8, 5 },
{ 6, 7 },
{ 1, 5 },
{ 2, 6 },
{ 3, 7 },
{ 4, 8 },
};
2023-09-21 01:21:24 +05:00
2009-01-13 04:40:13 +05:00
switch (et)
{
case SEGMENT:
case SEGMENT3:
return segm_edges;
case TRIG:
case TRIG6:
return trig_edges;
case QUAD:
case QUAD6:
case QUAD8:
return quad_edges;
case TET:
case TET10:
return tet_edges;
case PYRAMID:
case PYRAMID13:
2009-01-13 04:40:13 +05:00
return pyramid_edges;
case PRISM:
case PRISM12:
case PRISM15:
2009-01-13 04:40:13 +05:00
return prism_edges;
2023-09-21 01:21:24 +05:00
case HEX7:
return hex7_edges;
2009-01-13 04:40:13 +05:00
case HEX:
2019-01-18 02:08:35 +05:00
case HEX20:
2009-01-13 04:40:13 +05:00
return hex_edges;
2014-01-07 16:42:39 +06:00
// default:
// cerr << "Ng_ME_GetEdges, illegal element type " << et << endl;
2009-01-13 04:40:13 +05:00
}
return 0;
}
const ELEMENT_EDGE * MeshTopology :: GetEdges0 (ELEMENT_TYPE et)
{
static ELEMENT_EDGE segm_edges[1] =
{ { 0, 1 }};
static ELEMENT_EDGE trig_edges[3] =
{ { 2, 0 },
{ 1, 2 },
{ 0, 1 }};
static ELEMENT_EDGE quad_edges[4] =
{ { 0, 1 },
{ 2, 3 },
{ 3, 0 },
{ 1, 2 }};
static ELEMENT_EDGE tet_edges[6] =
{ { 3, 0 },
{ 3, 1 },
{ 3, 2 },
{ 0, 1 },
{ 0, 2 },
{ 1, 2 }};
static ELEMENT_EDGE prism_edges[9] =
{ { 2, 0 },
{ 0, 1 },
{ 2, 1 },
{ 5, 3 },
{ 3, 4 },
{ 5, 4 },
{ 2, 5 },
{ 0, 3 },
{ 1, 4 }};
static ELEMENT_EDGE pyramid_edges[8] =
{ { 0, 1 },
{ 1, 2 },
{ 0, 3 },
{ 3, 2 },
{ 0, 4 },
{ 1, 4 },
{ 2, 4 },
{ 3, 4 }};
2023-09-21 01:21:24 +05:00
static ELEMENT_EDGE hex7_edges[11] =
{
{ 0, 1 },
{ 2, 3 },
{ 3, 0 },
{ 1, 2 },
{ 4, 5 },
{ 6, 4 },
{ 5, 6 },
{ 0, 4 },
{ 1, 5 },
{ 2, 6 },
{ 3, 6 },
};
static ELEMENT_EDGE hex_edges[12] =
{
{ 0, 1 },
{ 2, 3 },
{ 3, 0 },
{ 1, 2 },
{ 4, 5 },
{ 6, 7 },
{ 7, 4 },
{ 5, 6 },
{ 0, 4 },
{ 1, 5 },
{ 2, 6 },
{ 3, 7 },
};
2023-09-21 01:21:24 +05:00
2019-01-18 02:08:35 +05:00
switch (et)
{
case SEGMENT:
case SEGMENT3:
return segm_edges;
case TRIG:
case TRIG6:
return trig_edges;
case QUAD:
case QUAD6:
case QUAD8:
return quad_edges;
case TET:
case TET10:
return tet_edges;
case PYRAMID:
case PYRAMID13:
return pyramid_edges;
case PRISM:
case PRISM12:
case PRISM15:
return prism_edges;
2023-09-21 01:21:24 +05:00
case HEX7:
return hex7_edges;
case HEX:
2019-01-18 02:08:35 +05:00
case HEX20:
return hex_edges;
2014-01-07 16:42:39 +06:00
// default:
// cerr << "Ng_ME_GetEdges, illegal element type " << et << endl;
}
return 0;
}
2022-04-21 14:37:30 +05:00
FlatArray<ELEMENT_EDGE> MeshTopology :: GetEdges (ELEMENT_TYPE et)
{
static ELEMENT_EDGE segm_edges[1] =
{ { 0, 1 }};
static ELEMENT_EDGE trig_edges[3] =
{ { 2, 0 },
{ 1, 2 },
{ 0, 1 }};
static ELEMENT_EDGE quad_edges[4] =
{ { 0, 1 },
{ 2, 3 },
{ 3, 0 },
{ 1, 2 }};
static ELEMENT_EDGE tet_edges[6] =
{ { 3, 0 },
{ 3, 1 },
{ 3, 2 },
{ 0, 1 },
{ 0, 2 },
{ 1, 2 }};
static ELEMENT_EDGE prism_edges[9] =
{ { 2, 0 },
{ 0, 1 },
{ 2, 1 },
{ 5, 3 },
{ 3, 4 },
{ 5, 4 },
{ 2, 5 },
{ 0, 3 },
{ 1, 4 }};
static ELEMENT_EDGE pyramid_edges[8] =
{ { 0, 1 },
{ 1, 2 },
{ 0, 3 },
{ 3, 2 },
{ 0, 4 },
{ 1, 4 },
{ 2, 4 },
{ 3, 4 }};
2023-09-21 01:21:24 +05:00
static ELEMENT_EDGE hex7_edges[11] =
{
{ 0, 1 },
{ 2, 3 },
{ 3, 0 },
{ 1, 2 },
{ 4, 5 },
{ 6, 4 },
{ 5, 6 },
{ 0, 4 },
{ 1, 5 },
{ 2, 6 },
{ 3, 6 },
};
2022-04-21 14:37:30 +05:00
static ELEMENT_EDGE hex_edges[12] =
{
{ 0, 1 },
{ 2, 3 },
{ 3, 0 },
{ 1, 2 },
{ 4, 5 },
{ 6, 7 },
{ 7, 4 },
{ 5, 6 },
{ 0, 4 },
{ 1, 5 },
{ 2, 6 },
{ 3, 7 },
};
switch (et)
{
case SEGMENT:
case SEGMENT3:
return { 1, segm_edges };
case TRIG:
case TRIG6:
return { 3, trig_edges };
case QUAD:
case QUAD6:
case QUAD8:
return { 4, quad_edges };
case TET:
case TET10:
return { 6, tet_edges };
case PYRAMID:
case PYRAMID13:
return { 8, pyramid_edges };
case PRISM:
case PRISM12:
case PRISM15:
return { 9, prism_edges };
2023-09-21 01:21:24 +05:00
case HEX7:
return { 11, hex7_edges };
2022-04-21 14:37:30 +05:00
case HEX:
case HEX20:
return { 12, hex_edges };
// default:
// cerr << "Ng_ME_GetEdges, illegal element type " << et << endl;
}
return { 0, nullptr };
}
2014-01-07 16:42:39 +06:00
inline const ELEMENT_FACE * MeshTopology :: GetFaces1 (ELEMENT_TYPE et)
2009-01-13 04:40:13 +05:00
{
static const ELEMENT_FACE trig_faces[1] =
2009-01-13 04:40:13 +05:00
{ { 1, 2, 3, 0 } };
static const ELEMENT_FACE quad_faces[1] =
2009-01-13 04:40:13 +05:00
{ { 1, 2, 3, 4 } };
static const ELEMENT_FACE tet_faces[4] =
2009-01-13 04:40:13 +05:00
{ { 4, 2, 3, 0 },
{ 4, 3, 1, 0 },
{ 4, 1, 2, 0 },
{ 1, 3, 2, 0 } };
static const ELEMENT_FACE prism_faces[5] =
2009-01-13 04:40:13 +05:00
{
{ 1, 3, 2, 0 },
{ 4, 5, 6, 0 },
{ 3, 1, 4, 6 },
{ 1, 2, 5, 4 },
{ 2, 3, 6, 5 }
};
static const ELEMENT_FACE pyramid_faces[5] =
2009-01-13 04:40:13 +05:00
{
{ 1, 2, 5, 0 },
{ 2, 3, 5, 0 },
{ 3, 4, 5, 0 },
{ 4, 1, 5, 0 },
{ 1, 4, 3, 2 }
};
2023-09-21 01:21:24 +05:00
static const ELEMENT_FACE hex7_faces[6] =
{
{ 1, 4, 3, 2 },
{ 5, 6, 7, 0 },
{ 1, 2, 6, 5 },
{ 2, 3, 7, 6 },
{ 3, 4, 7, 0 },
{ 4, 1, 5, 7 }
};
static const ELEMENT_FACE hex_faces[6] =
2009-01-13 04:40:13 +05:00
{
{ 1, 4, 3, 2 },
{ 5, 6, 7, 8 },
{ 1, 2, 6, 5 },
{ 2, 3, 7, 6 },
{ 3, 4, 8, 7 },
{ 4, 1, 5, 8 }
};
switch (et)
{
case TRIG:
case TRIG6:
return trig_faces;
case QUAD:
case QUAD6:
case QUAD8:
return quad_faces;
case TET:
case TET10:
return tet_faces;
case PRISM:
case PRISM12:
case PRISM15:
2009-01-13 04:40:13 +05:00
return prism_faces;
case PYRAMID:
case PYRAMID13:
2009-01-13 04:40:13 +05:00
return pyramid_faces;
case SEGMENT:
case SEGMENT3:
2023-09-21 01:21:24 +05:00
case HEX7:
return hex7_faces;
2009-01-13 04:40:13 +05:00
case HEX:
2019-01-18 02:08:35 +05:00
case HEX20:
2009-01-13 04:40:13 +05:00
return hex_faces;
2014-01-07 16:42:39 +06:00
// default:
// cerr << "Ng_ME_GetVertices, illegal element type " << et << endl;
2009-01-13 04:40:13 +05:00
}
return 0;
}
2014-01-07 16:42:39 +06:00
inline const ELEMENT_FACE * MeshTopology :: GetFaces0 (ELEMENT_TYPE et)
{
static const ELEMENT_FACE trig_faces[1] =
{ { 0, 1, 2, -1 } };
static const ELEMENT_FACE quad_faces[1] =
{ { 0, 1, 2, 3 } };
static const ELEMENT_FACE tet_faces[4] =
{ { 3, 1, 2, -1 },
{ 3, 2, 0, -1 },
{ 3, 0, 1, -1 },
{ 0, 2, 1, -1 } };
static const ELEMENT_FACE prism_faces[5] =
{
{ 0, 2, 1, -1 },
{ 3, 4, 5, -1 },
{ 2, 0, 3, 5 },
{ 0, 1, 4, 3 },
{ 1, 2, 5, 4 }
};
static const ELEMENT_FACE pyramid_faces[5] =
{
{ 0, 1, 4, -1 },
{ 1, 2, 4, -1 },
{ 2, 3, 4, -1 },
{ 3, 0, 4, -1 },
{ 0, 3, 2, 1 }
};
2023-09-21 01:21:24 +05:00
static const ELEMENT_FACE hex7_faces[6] =
{
{ 0, 3, 2, 1 },
{ 4, 5, 6, -1},
{ 0, 1, 5, 4 },
{ 1, 2, 6, 5 },
{ 2, 3, 6, -1},
{ 3, 0, 4, 6 }
};
static const ELEMENT_FACE hex_faces[6] =
{
{ 0, 3, 2, 1 },
{ 4, 5, 6, 7 },
{ 0, 1, 5, 4 },
{ 1, 2, 6, 5 },
{ 2, 3, 7, 6 },
{ 3, 0, 4, 7 }
};
switch (et)
{
case TRIG:
case TRIG6:
return trig_faces;
case QUAD:
case QUAD6:
case QUAD8:
return quad_faces;
case TET:
case TET10:
return tet_faces;
case PRISM:
case PRISM12:
case PRISM15:
return prism_faces;
case PYRAMID:
case PYRAMID13:
return pyramid_faces;
case SEGMENT:
case SEGMENT3:
2023-09-21 01:21:24 +05:00
case HEX7:
return hex7_faces;
case HEX:
2019-01-18 02:08:35 +05:00
case HEX20:
return hex_faces;
2014-01-07 16:42:39 +06:00
// default:
// cerr << "Ng_ME_GetVertices, illegal element type " << et << endl;
}
return 0;
}
2016-01-07 17:37:48 +05:00
}
2009-01-13 04:40:13 +05:00
#endif