netgen/libsrc/include/nginterface_v2.hpp

224 lines
4.1 KiB
C++
Raw Permalink Normal View History

2009-07-20 14:36:36 +06:00
#ifndef NGINTERFACE_V2
#define NGINTERFACE_V2
/**************************************************************************/
/* File: nginterface_v2.hpp */
/* Author: Joachim Schoeberl */
/* Date: May 09 */
/**************************************************************************/
2009-04-03 20:39:52 +06:00
2009-07-20 14:36:36 +06:00
/*
C++ interface to Netgen
*/
namespace netgen
{
2013-04-03 02:27:12 +06:00
2009-07-20 14:36:36 +06:00
class Ng_Element
2009-07-13 19:03:01 +06:00
{
2009-07-20 14:36:36 +06:00
class Ng_Points
{
public:
int num;
const int * ptr;
2009-07-13 19:03:01 +06:00
2009-07-20 14:36:36 +06:00
int Size() const { return num; }
int operator[] (int i) const { return ptr[i]-1; }
};
2009-07-13 19:03:01 +06:00
2009-07-20 14:36:36 +06:00
class Ng_Vertices
{
public:
int num;
const int * ptr;
2009-07-13 19:03:01 +06:00
2009-07-20 14:36:36 +06:00
int Size() const { return num; }
int operator[] (int i) const { return ptr[i]-1; }
};
2009-04-03 20:39:52 +06:00
2009-07-20 14:36:36 +06:00
class Ng_Edges
{
public:
int num;
const int * ptr;
2009-07-13 19:03:01 +06:00
2009-07-20 14:36:36 +06:00
int Size() const { return num; }
int operator[] (int i) const { return abs (ptr[i])-1; }
};
class Ng_Faces
{
public:
int num;
const int * ptr;
int Size() const { return num; }
int operator[] (int i) const { return (ptr[i]-1) / 8; }
};
public:
NG_ELEMENT_TYPE type;
NG_ELEMENT_TYPE GetType() const { return type; }
2011-01-11 01:18:01 +05:00
2009-07-20 14:36:36 +06:00
Ng_Points points; // all points
Ng_Vertices vertices;
Ng_Edges edges;
Ng_Faces faces;
2009-07-13 19:03:01 +06:00
};
2009-04-03 20:39:52 +06:00
2009-09-07 17:50:13 +06:00
class Ng_Point
{
public:
double * pt;
double operator[] (int i)
{ return pt[i]; }
};
2009-07-20 14:36:36 +06:00
template <int DIM> class Ng_Node;
template <>
class Ng_Node<1>
2009-04-03 20:39:52 +06:00
{
2009-07-20 14:36:36 +06:00
class Ng_Vertices
{
public:
const int * ptr;
2009-07-13 19:03:01 +06:00
2009-07-20 14:36:36 +06:00
int Size() const { return 2; }
int operator[] (int i) const { return ptr[i]-1; }
};
2009-07-13 19:03:01 +06:00
2009-07-20 14:36:36 +06:00
public:
Ng_Vertices vertices;
};
2010-05-17 15:00:30 +06:00
template <>
class Ng_Node<2>
{
class Ng_Vertices
{
public:
int nv;
const int * ptr;
int Size() const { return nv; }
int operator[] (int i) const { return ptr[i]-1; }
};
class Ng_Edges
{
public:
int ned;
const int * ptr;
int Size() const { return ned; }
int operator[] (int i) const { return ptr[i]-1; }
};
public:
Ng_Vertices vertices;
Ng_Edges edges;
};
2009-07-20 14:36:36 +06:00
2009-04-03 20:39:52 +06:00
2009-07-19 23:33:25 +06:00
2013-04-05 16:06:06 +06:00
class DLL_HEADER Ngx_Mesh
2013-04-03 02:27:12 +06:00
{
private:
class Mesh * mesh;
public:
Ngx_Mesh(class Mesh * amesh);
virtual ~Ngx_Mesh();
int GetDimension() const;
int GetNLevels() const;
int GetNElements (int dim) const;
int GetNNodes (int nt) const;
Ng_Point GetPoint (int nr) const;
template <int DIM>
2013-04-04 20:35:21 +06:00
Ng_Element GetElement (int nr) const;
2013-04-03 02:27:12 +06:00
template <int DIM>
2013-04-04 20:35:21 +06:00
int GetElementIndex (int nr) const;
2013-04-03 02:27:12 +06:00
/// Curved Elements:
/// elnr .. element nr
/// xi..... DIM_EL local coordinates
/// x ..... DIM_SPACE global coordinates
/// dxdxi...DIM_SPACE x DIM_EL Jacobian matrix (row major storage)
template <int DIM_EL, int DIM_SPACE>
2013-04-04 20:35:21 +06:00
void ElementTransformation (int elnr,
const double * xi,
double * x,
double * dxdxi) const;
2013-04-03 02:27:12 +06:00
/// Curved Elements:
/// elnr .. element nr
/// npts .. number of points
/// xi..... DIM_EL local coordinates
/// sxi ... step xi
/// x ..... DIM_SPACE global coordinates
/// dxdxi...DIM_SPACE x DIM_EL Jacobian matrix (row major storage)
template <int DIM_EL, int DIM_SPACE>
2013-04-04 20:35:21 +06:00
void MultiElementTransformation (int elnr, int npts,
const double * xi, size_t sxi,
double * x, size_t sx,
double * dxdxi, size_t sdxdxi) const;
2013-04-03 02:27:12 +06:00
template <int DIM>
2013-04-04 20:35:21 +06:00
Ng_Node<DIM> GetNode (int nr);
2013-04-03 02:27:12 +06:00
template <int DIM>
2013-04-04 20:35:21 +06:00
int GetNNodes ();
2013-04-03 02:27:12 +06:00
// Find element of point, returns local coordinates
template <int DIM>
2013-04-04 20:35:21 +06:00
int FindElementOfPoint
2013-04-03 02:27:12 +06:00
(double * p, double * lami,
bool build_searchtrees = false,
int * const indices = NULL, int numind = 0);
};
DLL_HEADER Ngx_Mesh * LoadMesh (const string & filename);
2009-07-20 14:36:36 +06:00
}
#endif