mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
consistent vertex->elements (1D/2D/3D) tables
This commit is contained in:
parent
24324c1ab9
commit
bee6c6bf90
@ -100,6 +100,27 @@ namespace netgen
|
|||||||
|
|
||||||
template <int DIM> class Ng_Node;
|
template <int DIM> class Ng_Node;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class Ng_Node<0>
|
||||||
|
{
|
||||||
|
class Ng_Elements
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int ne;
|
||||||
|
const int * ptr;
|
||||||
|
|
||||||
|
int Size() const { return ne; }
|
||||||
|
int operator[] (int i) const { return ptr[i]; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
Ng_Elements elements;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class Ng_Node<1>
|
class Ng_Node<1>
|
||||||
{
|
{
|
||||||
|
@ -1573,12 +1573,15 @@ int Ng_GetNVertexElements (int vnr)
|
|||||||
case 2:
|
case 2:
|
||||||
return mesh->GetTopology().GetVertexSurfaceElements(vnr).Size();
|
return mesh->GetTopology().GetVertexSurfaceElements(vnr).Size();
|
||||||
case 1:
|
case 1:
|
||||||
|
return mesh->GetTopology().GetVertexSegments(vnr).Size();
|
||||||
|
/*
|
||||||
{
|
{
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
for (SegmentIndex i = 0; i < mesh->GetNSeg(); i++)
|
for (SegmentIndex i = 0; i < mesh->GetNSeg(); i++)
|
||||||
if ( ((*mesh)[i][0] == vnr) || ((*mesh)[i][1] == vnr) ) cnt++;
|
if ( ((*mesh)[i][0] == vnr) || ((*mesh)[i][1] == vnr) ) cnt++;
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
default:
|
default:
|
||||||
cerr << "error: mesh->GetDimension() gives "
|
cerr << "error: mesh->GetDimension() gives "
|
||||||
<< mesh->GetDimension() << endl;
|
<< mesh->GetDimension() << endl;
|
||||||
@ -1598,17 +1601,22 @@ void Ng_GetVertexElements (int vnr, int * els)
|
|||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
FlatArray<int> ia = mesh->GetTopology().GetVertexSurfaceElements(vnr);
|
FlatArray<SurfaceElementIndex> ia = mesh->GetTopology().GetVertexSurfaceElements(vnr);
|
||||||
for (int i = 0; i < ia.Size(); i++) els[i] = ia[i];
|
for (int i = 0; i < ia.Size(); i++) els[i] = ia[i]+1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
|
FlatArray<SegmentIndex> ia = mesh->GetTopology().GetVertexSegments(vnr);
|
||||||
|
for (int i = 0; i < ia.Size(); i++) els[i] = ia[i]+1;
|
||||||
|
break;
|
||||||
|
/*
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
for (SegmentIndex i = 0; i < mesh->GetNSeg(); i++)
|
for (SegmentIndex i = 0; i < mesh->GetNSeg(); i++)
|
||||||
if ( ((*mesh)[i][0] == vnr) || ((*mesh)[i][1] == vnr) )
|
if ( ((*mesh)[i][0] == vnr) || ((*mesh)[i][1] == vnr) )
|
||||||
els[cnt++] = i+1;
|
els[cnt++] = i+1;
|
||||||
break;
|
break;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1894,11 +1902,11 @@ int Ng_GetVertex_SurfaceElements( int vnr, int* elems )
|
|||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
const MeshTopology& topology = mesh->GetTopology();
|
const MeshTopology& topology = mesh->GetTopology();
|
||||||
ArrayMem<int,4> indexArray;
|
ArrayMem<SurfaceElementIndex,4> indexArray;
|
||||||
topology.GetVertexSurfaceElements( vnr, indexArray );
|
topology.GetVertexSurfaceElements( vnr, indexArray );
|
||||||
|
|
||||||
for( int i=0; i<indexArray.Size(); i++ )
|
for( int i=0; i<indexArray.Size(); i++ )
|
||||||
elems[i] = indexArray[i];
|
elems[i] = indexArray[i]+1;
|
||||||
|
|
||||||
return indexArray.Size();
|
return indexArray.Size();
|
||||||
}
|
}
|
||||||
@ -1932,7 +1940,7 @@ int Ng_GetVertex_NSurfaceElements( int vnr )
|
|||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
const MeshTopology& topology = mesh->GetTopology();
|
const MeshTopology& topology = mesh->GetTopology();
|
||||||
ArrayMem<int,4> indexArray;
|
ArrayMem<SurfaceElementIndex,4> indexArray;
|
||||||
topology.GetVertexSurfaceElements( vnr, indexArray );
|
topology.GetVertexSurfaceElements( vnr, indexArray );
|
||||||
return indexArray.Size();
|
return indexArray.Size();
|
||||||
}
|
}
|
||||||
|
@ -612,6 +612,40 @@ namespace netgen
|
|||||||
return mesh->GetTopology().GetNFaces();
|
return mesh->GetTopology().GetNFaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <> DLL_HEADER 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 Ng_Node<1> Ngx_Mesh :: GetNode<1> (int nr) const
|
template <> DLL_HEADER Ng_Node<1> Ngx_Mesh :: GetNode<1> (int nr) const
|
||||||
{
|
{
|
||||||
Ng_Node<1> node;
|
Ng_Node<1> node;
|
||||||
|
@ -323,9 +323,9 @@ namespace netgen
|
|||||||
// boundary layer list
|
// boundary layer list
|
||||||
if(!surfid.Contains(mesh[sej].si))
|
if(!surfid.Contains(mesh[sej].si))
|
||||||
{
|
{
|
||||||
int pnt_commelem = 0;
|
SurfaceElementIndex pnt_commelem = 0;
|
||||||
Array<int> pnt1_elems;
|
Array<SurfaceElementIndex> pnt1_elems;
|
||||||
Array<int> pnt2_elems;
|
Array<SurfaceElementIndex> pnt2_elems;
|
||||||
|
|
||||||
|
|
||||||
meshtopo.GetVertexSurfaceElements(segpair_p1,pnt1_elems);
|
meshtopo.GetVertexSurfaceElements(segpair_p1,pnt1_elems);
|
||||||
|
@ -126,28 +126,28 @@ namespace netgen
|
|||||||
cnt[el[j]]++;
|
cnt[el[j]]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
vert2surfelement = new TABLE<int,PointIndex::BASE> (cnt);
|
vert2surfelement = new TABLE<SurfaceElementIndex,PointIndex::BASE> (cnt);
|
||||||
for (SurfaceElementIndex sei = 0; sei < nse; sei++)
|
for (SurfaceElementIndex sei = 0; sei < nse; sei++)
|
||||||
{
|
{
|
||||||
const Element2d & el = mesh[sei];
|
const Element2d & el = mesh[sei];
|
||||||
for (int j = 0; j < el.GetNV(); j++)
|
for (int j = 0; j < el.GetNV(); j++)
|
||||||
vert2surfelement->AddSave (el[j], sei+1);
|
vert2surfelement->AddSave (el[j], sei);
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
for (int i = 1; i <= nseg; i++)
|
for (SegmentIndex si = 0; si < nseg; si++)
|
||||||
{
|
{
|
||||||
const Segment & seg = mesh.LineSegment(i);
|
const Segment & seg = mesh.LineSegment(si);
|
||||||
cnt[seg[0]]++;
|
cnt[seg[0]]++;
|
||||||
cnt[seg[1]]++;
|
cnt[seg[1]]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
vert2segment = new TABLE<int,PointIndex::BASE> (cnt);
|
vert2segment = new TABLE<SegmentIndex,PointIndex::BASE> (cnt);
|
||||||
for (int i = 1; i <= nseg; i++)
|
for (SegmentIndex si = 0; si < nseg; si++)
|
||||||
{
|
{
|
||||||
const Segment & seg = mesh.LineSegment(i);
|
const Segment & seg = mesh.LineSegment(si);
|
||||||
vert2segment->AddSave (seg[0], i);
|
vert2segment->AddSave (seg[0], si);
|
||||||
vert2segment->AddSave (seg[1], i);
|
vert2segment->AddSave (seg[1], si);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buildedges)
|
if (buildedges)
|
||||||
@ -243,7 +243,7 @@ namespace netgen
|
|||||||
|
|
||||||
for (int j = 0; j < (*vert2surfelement)[i].Size(); j++)
|
for (int j = 0; j < (*vert2surfelement)[i].Size(); j++)
|
||||||
{
|
{
|
||||||
int elnr = (*vert2surfelement)[i][j];
|
SurfaceElementIndex elnr = (*vert2surfelement)[i][j];
|
||||||
const Element2d & el = mesh.SurfaceElement (elnr);
|
const Element2d & el = mesh.SurfaceElement (elnr);
|
||||||
|
|
||||||
int neledges = GetNEdges (el.GetType());
|
int neledges = GetNEdges (el.GetType());
|
||||||
@ -265,7 +265,7 @@ namespace netgen
|
|||||||
|
|
||||||
for (int j = 0; j < (*vert2segment)[i].Size(); j++)
|
for (int j = 0; j < (*vert2segment)[i].Size(); j++)
|
||||||
{
|
{
|
||||||
int elnr = (*vert2segment)[i][j];
|
SegmentIndex elnr = (*vert2segment)[i][j];
|
||||||
const Segment & el = mesh.LineSegment (elnr);
|
const Segment & el = mesh.LineSegment (elnr);
|
||||||
|
|
||||||
INDEX_2 edge(el[0], el[1]);
|
INDEX_2 edge(el[0], el[1]);
|
||||||
@ -316,7 +316,7 @@ namespace netgen
|
|||||||
|
|
||||||
for (int j = 0; j < (*vert2surfelement)[i].Size(); j++)
|
for (int j = 0; j < (*vert2surfelement)[i].Size(); j++)
|
||||||
{
|
{
|
||||||
int elnr = (*vert2surfelement)[i][j];
|
SurfaceElementIndex elnr = (*vert2surfelement)[i][j];
|
||||||
const Element2d & el = mesh.SurfaceElement (elnr);
|
const Element2d & el = mesh.SurfaceElement (elnr);
|
||||||
|
|
||||||
int neledges = GetNEdges (el.GetType());
|
int neledges = GetNEdges (el.GetType());
|
||||||
@ -334,15 +334,14 @@ namespace netgen
|
|||||||
int edgenum = edgenr[edge.I2()];
|
int edgenum = edgenr[edge.I2()];
|
||||||
// if (edgedir) edgenum *= -1;
|
// if (edgedir) edgenum *= -1;
|
||||||
// surfedges.Elem(elnr)[k] = edgenum;
|
// surfedges.Elem(elnr)[k] = edgenum;
|
||||||
surfedges.Elem(elnr)[k].nr = edgenum-1;
|
surfedges[elnr][k].nr = edgenum-1;
|
||||||
surfedges.Elem(elnr)[k].orient = edgedir;
|
surfedges[elnr][k].orient = edgedir;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < (*vert2segment)[i].Size(); j++)
|
for (int j = 0; j < (*vert2segment)[i].Size(); j++)
|
||||||
{
|
{
|
||||||
int elnr = (*vert2segment)[i][j];
|
SegmentIndex elnr = (*vert2segment)[i][j];
|
||||||
const Segment & el = mesh.LineSegment (elnr);
|
const Segment & el = mesh.LineSegment (elnr);
|
||||||
|
|
||||||
INDEX_2 edge(el[0], el[1]);
|
INDEX_2 edge(el[0], el[1]);
|
||||||
@ -357,8 +356,8 @@ namespace netgen
|
|||||||
if (edgedir) edgenum *= -1;
|
if (edgedir) edgenum *= -1;
|
||||||
segedges.Elem(elnr) = edgenum;
|
segedges.Elem(elnr) = edgenum;
|
||||||
*/
|
*/
|
||||||
segedges.Elem(elnr).nr = edgenum-1;
|
segedges[elnr].nr = edgenum-1;
|
||||||
segedges.Elem(elnr).orient = edgedir;
|
segedges[elnr].orient = edgedir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -875,7 +874,7 @@ namespace netgen
|
|||||||
|
|
||||||
for (int j = 0; j < (*vert2surfelement)[v].Size(); j++)
|
for (int j = 0; j < (*vert2surfelement)[v].Size(); j++)
|
||||||
{
|
{
|
||||||
int elnr = (*vert2surfelement)[v][j];
|
SurfaceElementIndex elnr = (*vert2surfelement)[v][j];
|
||||||
// cout << "surfelnr = " << elnr << endl;
|
// cout << "surfelnr = " << elnr << endl;
|
||||||
const Element2d & el = mesh.SurfaceElement (elnr);
|
const Element2d & el = mesh.SurfaceElement (elnr);
|
||||||
|
|
||||||
@ -926,8 +925,8 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
// surffaces.Elem(elnr) = 8*(facenum-1)+facedir+1;
|
// surffaces.Elem(elnr) = 8*(facenum-1)+facedir+1;
|
||||||
surffaces.Elem(elnr).fnr = facenum-1;
|
surffaces[elnr].fnr = facenum-1;
|
||||||
surffaces.Elem(elnr).forient = facedir;
|
surffaces[elnr].forient = facedir;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -979,8 +978,8 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
// surffaces.Elem(elnr) = 8*(facenum-1)+facedir+1;
|
// surffaces.Elem(elnr) = 8*(facenum-1)+facedir+1;
|
||||||
surffaces.Elem(elnr).fnr = facenum-1;
|
surffaces[elnr].fnr = facenum-1;
|
||||||
surffaces.Elem(elnr).forient = facedir;
|
surffaces[elnr].forient = facedir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1673,16 +1672,23 @@ namespace netgen
|
|||||||
return FlatArray<ElementIndex> (0,0);
|
return FlatArray<ElementIndex> (0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
FlatArray<int> MeshTopology :: GetVertexSurfaceElements (int vnr) const
|
FlatArray<SurfaceElementIndex> MeshTopology :: GetVertexSurfaceElements (int vnr) const
|
||||||
{
|
{
|
||||||
if (vert2surfelement)
|
if (vert2surfelement)
|
||||||
return (*vert2surfelement)[vnr];
|
return (*vert2surfelement)[vnr];
|
||||||
return FlatArray<int> (0,0);
|
return FlatArray<SurfaceElementIndex> (0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
FlatArray<SegmentIndex> MeshTopology :: GetVertexSegments (int vnr) const
|
||||||
|
{
|
||||||
|
if (vert2segment)
|
||||||
|
return (*vert2segment)[vnr];
|
||||||
|
return FlatArray<SegmentIndex> (0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MeshTopology :: GetVertexSurfaceElements( int vnr,
|
void MeshTopology :: GetVertexSurfaceElements( int vnr,
|
||||||
Array<int>& elements ) const
|
Array<SurfaceElementIndex> & elements ) const
|
||||||
{
|
{
|
||||||
if (vert2surfelement)
|
if (vert2surfelement)
|
||||||
{
|
{
|
||||||
@ -1719,7 +1725,7 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
void MeshTopology ::
|
void MeshTopology ::
|
||||||
GetSegmentVolumeElements ( int segnr, Array<int> & volels ) const
|
GetSegmentVolumeElements ( int segnr, Array<ElementIndex> & volels ) const
|
||||||
{
|
{
|
||||||
int v1, v2;
|
int v1, v2;
|
||||||
GetEdgeVertices ( GetSegmentEdge (segnr), v1, v2 );
|
GetEdgeVertices ( GetSegmentEdge (segnr), v1, v2 );
|
||||||
@ -1730,15 +1736,15 @@ namespace netgen
|
|||||||
|
|
||||||
for ( int eli1=1; eli1 <= volels1.Size(); eli1++)
|
for ( int eli1=1; eli1 <= volels1.Size(); eli1++)
|
||||||
if ( volels2.Contains( volels1.Elem(eli1) ) )
|
if ( volels2.Contains( volels1.Elem(eli1) ) )
|
||||||
volels.Append ( volels1.Elem(eli1)+1 );
|
volels.Append ( volels1.Elem(eli1) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshTopology ::
|
void MeshTopology ::
|
||||||
GetSegmentSurfaceElements (int segnr, Array<int> & els) const
|
GetSegmentSurfaceElements (int segnr, Array<SurfaceElementIndex> & els) const
|
||||||
{
|
{
|
||||||
int v1, v2;
|
int v1, v2;
|
||||||
GetEdgeVertices ( GetSegmentEdge (segnr), v1, v2 );
|
GetEdgeVertices ( GetSegmentEdge (segnr), v1, v2 );
|
||||||
Array<int> els1, els2;
|
Array<SurfaceElementIndex> els1, els2;
|
||||||
GetVertexSurfaceElements ( v1, els1 );
|
GetVertexSurfaceElements ( v1, els1 );
|
||||||
GetVertexSurfaceElements ( v2, els2 );
|
GetVertexSurfaceElements ( v2, els2 );
|
||||||
els.SetSize(0);
|
els.SetSize(0);
|
||||||
|
@ -44,8 +44,8 @@ class MeshTopology
|
|||||||
Array<INDEX_2> surf2volelement;
|
Array<INDEX_2> surf2volelement;
|
||||||
Array<int> face2surfel;
|
Array<int> face2surfel;
|
||||||
TABLE<ElementIndex,PointIndex::BASE> *vert2element;
|
TABLE<ElementIndex,PointIndex::BASE> *vert2element;
|
||||||
TABLE<int,PointIndex::BASE> *vert2surfelement;
|
TABLE<SurfaceElementIndex,PointIndex::BASE> *vert2surfelement;
|
||||||
TABLE<int,PointIndex::BASE> *vert2segment;
|
TABLE<SegmentIndex,PointIndex::BASE> *vert2segment;
|
||||||
int timestamp;
|
int timestamp;
|
||||||
public:
|
public:
|
||||||
int GetNSurfedges() const {return surfedges.Size();}
|
int GetNSurfedges() const {return surfedges.Size();}
|
||||||
@ -135,14 +135,15 @@ public:
|
|||||||
void GetVertexElements (int vnr, Array<ElementIndex> & elements) const;
|
void GetVertexElements (int vnr, Array<ElementIndex> & elements) const;
|
||||||
FlatArray<ElementIndex> GetVertexElements (int vnr) const;
|
FlatArray<ElementIndex> GetVertexElements (int vnr) const;
|
||||||
|
|
||||||
void GetVertexSurfaceElements( int vnr, Array<int>& elements ) const;
|
void GetVertexSurfaceElements( int vnr, Array<SurfaceElementIndex>& elements ) const;
|
||||||
FlatArray<int> GetVertexSurfaceElements (int vnr) const;
|
FlatArray<SurfaceElementIndex> GetVertexSurfaceElements (int vnr) const;
|
||||||
|
|
||||||
|
FlatArray<SegmentIndex> GetVertexSegments (int vnr) const;
|
||||||
|
|
||||||
|
|
||||||
int GetVerticesEdge ( int v1, int v2) const;
|
int GetVerticesEdge ( int v1, int v2) const;
|
||||||
void GetSegmentVolumeElements ( int segnr, Array<int> & els ) const;
|
void GetSegmentVolumeElements ( int segnr, Array<ElementIndex> & els ) const;
|
||||||
void GetSegmentSurfaceElements ( int segnr, Array<int> & els ) const;
|
void GetSegmentSurfaceElements ( int segnr, Array<SurfaceElementIndex> & els ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user