mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
__assume for switch (element_type)
This commit is contained in:
parent
b3451ed2e4
commit
1d6c7b283a
@ -35,6 +35,22 @@
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef __assume
|
||||
#ifdef __GNUC__
|
||||
#define __assume(cond) if (!(cond)) __builtin_unreachable(); else;
|
||||
#else
|
||||
#define __assume(cond)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define noDEMOVERSION
|
||||
#define noDEVELOP
|
||||
#define noSTEP
|
||||
|
@ -251,7 +251,11 @@ namespace netgen
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
#define NGX_INLINE __attribute__ ((__always_inline__)) inline
|
||||
#else
|
||||
#define NGX_INLINE inline
|
||||
#endif
|
||||
#include <nginterface_v2_impl.hpp>
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,7 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<3> (int nr) const
|
||||
Ng_Element ret;
|
||||
ret.type = NG_ELEMENT_TYPE(el.GetType());
|
||||
ret.index = el.GetIndex();
|
||||
|
||||
ret.points.num = el.GetNP();
|
||||
ret.points.ptr = (int*)&el[0];
|
||||
|
||||
@ -126,8 +127,6 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<3> (int nr) const
|
||||
ret.faces.num = MeshTopology::GetNFaces (el.GetType());
|
||||
ret.faces.ptr = (T_FACE2*)mesh->GetTopology().GetElementFacesPtr (nr);
|
||||
|
||||
// ret.is_curved = mesh->GetCurvedElements().IsElementCurved(nr);
|
||||
ret.is_curved = el.IsCurved();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ namespace netgen
|
||||
mutable int elementsearchtreets;
|
||||
|
||||
/// element -> face, element -> edge etc ...
|
||||
class MeshTopology * topology;
|
||||
MeshTopology * topology;
|
||||
/// methods for high order elements
|
||||
class CurvedElements * curvedelems;
|
||||
|
||||
@ -655,19 +655,19 @@ namespace netgen
|
||||
|
||||
|
||||
|
||||
DLL_HEADER bool PureTrigMesh (int faceindex = 0) const;
|
||||
DLL_HEADER bool PureTetMesh () const;
|
||||
DLL_HEADER bool PureTrigMesh (int faceindex = 0) const;
|
||||
DLL_HEADER bool PureTetMesh () const;
|
||||
|
||||
|
||||
const class MeshTopology & GetTopology () const
|
||||
const MeshTopology & GetTopology () const
|
||||
{ return *topology; }
|
||||
|
||||
DLL_HEADER void UpdateTopology();
|
||||
DLL_HEADER void UpdateTopology();
|
||||
|
||||
class CurvedElements & GetCurvedElements () const
|
||||
{ return *curvedelems; }
|
||||
|
||||
DLL_HEADER void BuildCurvedElements (const class Refinement * ref, int aorder, bool arational = false);
|
||||
DLL_HEADER void BuildCurvedElements (const class Refinement * ref, int aorder, bool arational = false);
|
||||
|
||||
const class AnisotropicClusters & GetClusters () const
|
||||
{ return *clusters; }
|
||||
|
@ -22,6 +22,7 @@ namespace netgen
|
||||
#include "msghandler.hpp"
|
||||
#include "meshtype.hpp"
|
||||
#include "localh.hpp"
|
||||
#include "topology.hpp"
|
||||
#include "meshclass.hpp"
|
||||
#include "global.hpp"
|
||||
|
||||
@ -48,7 +49,6 @@ namespace netgen
|
||||
#include "findip.hpp"
|
||||
#include "findip2.hpp"
|
||||
|
||||
#include "topology.hpp"
|
||||
#include "curvedelems.hpp"
|
||||
#include "clusters.hpp"
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace netgen
|
||||
|
||||
|
||||
|
||||
enum ELEMENT_TYPE {
|
||||
enum ELEMENT_TYPE : unsigned char {
|
||||
SEGMENT = 1, SEGMENT3 = 2,
|
||||
TRIG = 10, QUAD=11, TRIG6 = 12, QUAD6 = 13, QUAD8 = 14,
|
||||
TET = 20, TET10 = 21,
|
||||
@ -292,7 +292,7 @@ namespace netgen
|
||||
/// surface nr
|
||||
int index:16;
|
||||
///
|
||||
ELEMENT_TYPE typ:6;
|
||||
ELEMENT_TYPE typ;
|
||||
/// number of points
|
||||
unsigned int np:4;
|
||||
bool badel:1;
|
||||
@ -545,7 +545,7 @@ namespace netgen
|
||||
/// point numbers
|
||||
PointIndex pnum[ELEMENT_MAXPOINTS];
|
||||
///
|
||||
ELEMENT_TYPE typ:6;
|
||||
ELEMENT_TYPE typ;
|
||||
/// number of points (4..tet, 5..pyramid, 6..prism, 8..hex, 10..quad tet, 12..quad prism)
|
||||
int np:5;
|
||||
///
|
||||
@ -601,27 +601,27 @@ namespace netgen
|
||||
///
|
||||
int GetNP () const { return np; }
|
||||
///
|
||||
int GetNV() const
|
||||
short int GetNV() const
|
||||
{
|
||||
__assume(typ >= TET && typ <= HEX);
|
||||
switch (typ)
|
||||
{
|
||||
case TET:
|
||||
case TET10:
|
||||
return 4;
|
||||
case PRISM12:
|
||||
case PRISM:
|
||||
case TET:
|
||||
case TET10:
|
||||
return 4;
|
||||
case PRISM12:
|
||||
case PRISM:
|
||||
return 6;
|
||||
case PYRAMID:
|
||||
return 5;
|
||||
case HEX:
|
||||
return 8;
|
||||
default:
|
||||
default: // not a 3D element
|
||||
#ifdef DEBUG
|
||||
PrintSysError ("Element3d::GetNV not implemented for typ ", typ)
|
||||
PrintSysError ("Element3d::GetNV not implemented for typ ", typ)
|
||||
#endif
|
||||
;
|
||||
}
|
||||
return np;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const Element & el2) const;
|
||||
|
@ -12,6 +12,8 @@
|
||||
(Elements, Faces, Edges, Vertices
|
||||
*/
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
|
||||
struct T_EDGE
|
||||
{
|
||||
@ -67,10 +69,10 @@ public:
|
||||
int GetNEdges () const { return edge2vert.Size(); }
|
||||
int GetNFaces () const { return face2vert.Size(); }
|
||||
|
||||
static inline int GetNVertices (ELEMENT_TYPE et);
|
||||
static inline int GetNPoints (ELEMENT_TYPE et);
|
||||
static inline int GetNEdges (ELEMENT_TYPE et);
|
||||
static inline int GetNFaces (ELEMENT_TYPE et);
|
||||
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);
|
||||
|
||||
static const Point3d * GetVertices (ELEMENT_TYPE et);
|
||||
inline static const ELEMENT_EDGE * GetEdges1 (ELEMENT_TYPE et);
|
||||
@ -78,19 +80,11 @@ public:
|
||||
inline static const ELEMENT_FACE * GetFaces1 (ELEMENT_TYPE et);
|
||||
inline static const ELEMENT_FACE * GetFaces0 (ELEMENT_TYPE et);
|
||||
|
||||
|
||||
// int GetSegmentEdge (int segnr) const { return abs(segedges[segnr-1]); }
|
||||
// int GetSegmentEdgeOrientation (int segnr) const { return sgn(segedges[segnr-1]); }
|
||||
// int GetEdge (SegmentIndex segnr) const { return abs(segedges[segnr])-1; }
|
||||
int GetSegmentEdge (int segnr) const { return segedges[segnr-1].nr+1; }
|
||||
int GetEdge (SegmentIndex segnr) const { return segedges[segnr].nr; }
|
||||
|
||||
void GetSegmentEdge (int segnr, int & enr, int & orient) const
|
||||
{
|
||||
/*
|
||||
enr = abs(segedges.Get(segnr));
|
||||
orient = segedges.Get(segnr) > 0 ? 1 : -1;
|
||||
*/
|
||||
enr = segedges.Get(segnr).nr+1;
|
||||
orient = segedges.Get(segnr).orient;
|
||||
}
|
||||
@ -160,7 +154,7 @@ public:
|
||||
|
||||
|
||||
|
||||
inline int MeshTopology :: GetNVertices (ELEMENT_TYPE et)
|
||||
inline short int MeshTopology :: GetNVertices (ELEMENT_TYPE et)
|
||||
{
|
||||
switch (et)
|
||||
{
|
||||
@ -198,7 +192,7 @@ inline int MeshTopology :: GetNVertices (ELEMENT_TYPE et)
|
||||
}
|
||||
|
||||
|
||||
inline int MeshTopology :: GetNPoints (ELEMENT_TYPE et)
|
||||
inline short int MeshTopology :: GetNPoints (ELEMENT_TYPE et)
|
||||
{
|
||||
switch (et)
|
||||
{
|
||||
@ -240,8 +234,9 @@ inline int MeshTopology :: GetNPoints (ELEMENT_TYPE et)
|
||||
|
||||
|
||||
|
||||
inline int MeshTopology :: GetNEdges (ELEMENT_TYPE et)
|
||||
inline short int MeshTopology :: GetNEdges (ELEMENT_TYPE et)
|
||||
{
|
||||
__assume(et >= SEGMENT && et <= HEX);
|
||||
switch (et)
|
||||
{
|
||||
case SEGMENT:
|
||||
@ -270,16 +265,18 @@ inline int MeshTopology :: GetNEdges (ELEMENT_TYPE et)
|
||||
|
||||
case HEX:
|
||||
return 12;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
// default:
|
||||
// cerr << "Ng_ME_GetNEdges, illegal element type " << et << endl;
|
||||
}
|
||||
return 0;
|
||||
// return 0;
|
||||
}
|
||||
|
||||
|
||||
inline int MeshTopology :: GetNFaces (ELEMENT_TYPE et)
|
||||
inline short int MeshTopology :: GetNFaces (ELEMENT_TYPE et)
|
||||
{
|
||||
__assume(et >= SEGMENT && et <= HEX);
|
||||
switch (et)
|
||||
{
|
||||
case SEGMENT:
|
||||
@ -309,10 +306,11 @@ inline int MeshTopology :: GetNFaces (ELEMENT_TYPE et)
|
||||
case HEX:
|
||||
return 6;
|
||||
|
||||
default:
|
||||
return -99;
|
||||
// default:
|
||||
// cerr << "Ng_ME_GetNVertices, illegal element type " << et << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -683,24 +681,6 @@ inline const ELEMENT_FACE * MeshTopology :: GetFaces0 (ELEMENT_TYPE et)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user