getvertexelements inline

This commit is contained in:
Joachim Schöberl 2016-03-23 08:17:45 +01:00
parent 7525e2c09b
commit 21199b565a
5 changed files with 88 additions and 67 deletions

View File

@ -116,6 +116,7 @@ namespace netgen
public:
Ng_Elements elements;
Ng_Elements bnd_elements;
};

View File

@ -135,3 +135,82 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<3> (int nr) const
ret.is_curved = el.IsCurved();
return ret;
}
template <> NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetNNodes<1> ()
{
return mesh->GetTopology().GetNEdges();
}
template <> NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetNNodes<2> ()
{
return mesh->GetTopology().GetNFaces();
}
template <> NGX_INLINE DLL_HEADER const Ng_Node<0> Ngx_Mesh :: GetNode<0> (int vnr) const
{
Ng_Node<0> node;
vnr++;
switch (mesh->GetDimension())
{
case 3:
{
FlatArray<ElementIndex> ia = mesh->GetTopology().GetVertexElements(vnr);
node.elements.ne = ia.Size();
node.elements.ptr = (int*)&ia[0];
FlatArray<SurfaceElementIndex> bia = mesh->GetTopology().GetVertexSurfaceElements(vnr);
node.bnd_elements.ne = bia.Size();
node.bnd_elements.ptr = (int*)&bia[0];
break;
}
case 2:
{
FlatArray<SurfaceElementIndex> ia = mesh->GetTopology().GetVertexSurfaceElements(vnr);
node.elements.ne = ia.Size();
node.elements.ptr = (int*)&ia[0];
FlatArray<SegmentIndex> bia = mesh->GetTopology().GetVertexSegments(vnr);
node.bnd_elements.ne = bia.Size();
node.bnd_elements.ptr = (int*)&bia[0];
break;
}
case 1:
{
FlatArray<SegmentIndex> ia = mesh->GetTopology().GetVertexSegments(vnr);
node.elements.ne = ia.Size();
node.elements.ptr = (int*)&ia[0];
node.bnd_elements.ne = 1; // nothing useful ...
node.bnd_elements.ptr = nullptr;
break;
}
default:
;
}
return node;
}
template <> NGX_INLINE DLL_HEADER const Ng_Node<1> Ngx_Mesh :: GetNode<1> (int nr) const
{
Ng_Node<1> node;
node.vertices.ptr = mesh->GetTopology().GetEdgeVerticesPtr(nr);
return node;
}
template <> NGX_INLINE DLL_HEADER const Ng_Node<2> Ngx_Mesh :: GetNode<2> (int nr) const
{
Ng_Node<2> node;
node.vertices.ptr = mesh->GetTopology().GetFaceVerticesPtr(nr);
node.vertices.nv = (node.vertices.ptr[3] == 0) ? 3 : 4;
return node;
}

View File

@ -601,67 +601,6 @@ namespace netgen
template <> DLL_HEADER int Ngx_Mesh :: GetNNodes<1> ()
{
return mesh->GetTopology().GetNEdges();
}
template <> DLL_HEADER int Ngx_Mesh :: GetNNodes<2> ()
{
return mesh->GetTopology().GetNFaces();
}
template <> DLL_HEADER const Ng_Node<0> Ngx_Mesh :: GetNode<0> (int vnr) const
{
Ng_Node<0> node;
vnr++;
switch (mesh->GetDimension())
{
case 3:
{
FlatArray<ElementIndex> ia = mesh->GetTopology().GetVertexElements(vnr);
node.elements.ne = ia.Size();
node.elements.ptr = (int*)&ia[0];
break;
}
case 2:
{
FlatArray<SurfaceElementIndex> ia = mesh->GetTopology().GetVertexSurfaceElements(vnr);
node.elements.ne = ia.Size();
node.elements.ptr = (int*)&ia[0];
break;
}
case 1:
{
FlatArray<SegmentIndex> ia = mesh->GetTopology().GetVertexSegments(vnr);
node.elements.ne = ia.Size();
node.elements.ptr = (int*)&ia[0];
break;
}
default:
;
}
return node;
}
template <> DLL_HEADER const Ng_Node<1> Ngx_Mesh :: GetNode<1> (int nr) const
{
Ng_Node<1> node;
node.vertices.ptr = mesh->GetTopology().GetEdgeVerticesPtr(nr);
return node;
}
template <> DLL_HEADER const Ng_Node<2> Ngx_Mesh :: GetNode<2> (int nr) const
{
Ng_Node<2> node;
node.vertices.ptr = mesh->GetTopology().GetFaceVerticesPtr(nr);
node.vertices.nv = (node.vertices.ptr[3] == 0) ? 3 : 4;
return node;
}
template <>
DLL_HEADER int Ngx_Mesh :: FindElementOfPoint <1>
(double * hp, double * lami,

View File

@ -1664,7 +1664,7 @@ namespace netgen
}
}
/*
FlatArray<ElementIndex> MeshTopology :: GetVertexElements (int vnr) const
{
if (vert2element)
@ -1685,7 +1685,7 @@ namespace netgen
return (*vert2segment)[vnr];
return FlatArray<SegmentIndex> (0,0);
}
*/
void MeshTopology :: GetVertexSurfaceElements( int vnr,
Array<SurfaceElementIndex> & elements ) const

View File

@ -133,13 +133,15 @@ public:
int GetFace2SurfaceElement (int fnr) const { return face2surfel[fnr-1]; }
void GetVertexElements (int vnr, Array<ElementIndex> & elements) const;
FlatArray<ElementIndex> GetVertexElements (int vnr) const;
FlatArray<ElementIndex> GetVertexElements (int vnr) const
{ return (*vert2element)[vnr]; }
void GetVertexSurfaceElements( int vnr, Array<SurfaceElementIndex>& elements ) const;
FlatArray<SurfaceElementIndex> GetVertexSurfaceElements (int vnr) const;
FlatArray<SegmentIndex> GetVertexSegments (int vnr) const;
FlatArray<SurfaceElementIndex> GetVertexSurfaceElements (int vnr) const
{ return (*vert2surfelement)[vnr]; }
FlatArray<SegmentIndex> GetVertexSegments (int vnr) const
{ return (*vert2segment)[vnr]; }
int GetVerticesEdge ( int v1, int v2) const;
void GetSegmentVolumeElements ( int segnr, Array<ElementIndex> & els ) const;