mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 04:50:34 +05:00
replace NgArray and TABLE with Array and Table
This commit is contained in:
parent
4b53c63fba
commit
c8406d3b10
@ -256,18 +256,18 @@ template <> NGX_INLINE DLL_HEADER const Ng_Node<0> Ngx_Mesh :: GetNode<0> (int v
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
NgFlatArray<ElementIndex> ia = mesh->GetTopology().GetVertexElements(vnr);
|
||||
auto ia = mesh->GetTopology().GetVertexElements(vnr);
|
||||
node.elements.ne = ia.Size();
|
||||
node.elements.ptr = (int*)&ia[0];
|
||||
|
||||
NgFlatArray<SurfaceElementIndex> bia = mesh->GetTopology().GetVertexSurfaceElements(vnr);
|
||||
auto bia = mesh->GetTopology().GetVertexSurfaceElements(vnr);
|
||||
node.bnd_elements.ne = bia.Size();
|
||||
node.bnd_elements.ptr = (int*)&bia[0];
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
NgFlatArray<SurfaceElementIndex> ia = mesh->GetTopology().GetVertexSurfaceElements(vnr);
|
||||
auto ia = mesh->GetTopology().GetVertexSurfaceElements(vnr);
|
||||
node.elements.ne = ia.Size();
|
||||
node.elements.ptr = (int*)&ia[0];
|
||||
|
||||
|
@ -1641,13 +1641,13 @@ void Ng_GetVertexElements (int vnr, int * els)
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
NgFlatArray<ElementIndex> ia = mesh->GetTopology().GetVertexElements(vnr);
|
||||
auto ia = mesh->GetTopology().GetVertexElements(vnr);
|
||||
for (int i = 0; i < ia.Size(); i++) els[i] = ia[i]+1;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
NgFlatArray<SurfaceElementIndex> ia = mesh->GetTopology().GetVertexSurfaceElements(vnr);
|
||||
auto ia = mesh->GetTopology().GetVertexSurfaceElements(vnr);
|
||||
for (int i = 0; i < ia.Size(); i++) els[i] = ia[i]+1;
|
||||
break;
|
||||
}
|
||||
@ -1933,7 +1933,7 @@ int Ng_IsRunning()
|
||||
int Ng_GetVertex_Elements( int vnr, int* elems )
|
||||
{
|
||||
const MeshTopology& topology = mesh->GetTopology();
|
||||
NgArrayMem<ElementIndex,4> indexArray;
|
||||
ArrayMem<ElementIndex,4> indexArray;
|
||||
topology.GetVertexElements( vnr, indexArray );
|
||||
|
||||
for( int i=0; i<indexArray.Size(); i++ )
|
||||
@ -1950,7 +1950,7 @@ int Ng_GetVertex_SurfaceElements( int vnr, int* elems )
|
||||
case 3:
|
||||
{
|
||||
const MeshTopology& topology = mesh->GetTopology();
|
||||
NgArrayMem<SurfaceElementIndex,4> indexArray;
|
||||
ArrayMem<SurfaceElementIndex,4> indexArray;
|
||||
topology.GetVertexSurfaceElements( vnr, indexArray );
|
||||
|
||||
for( int i=0; i<indexArray.Size(); i++ )
|
||||
@ -1982,7 +1982,7 @@ int Ng_GetVertex_SurfaceElements( int vnr, int* elems )
|
||||
int Ng_GetVertex_NElements( int vnr )
|
||||
{
|
||||
const MeshTopology& topology = mesh->GetTopology();
|
||||
NgArrayMem<ElementIndex,4> indexArray;
|
||||
ArrayMem<ElementIndex,4> indexArray;
|
||||
topology.GetVertexElements( vnr, indexArray );
|
||||
|
||||
return indexArray.Size();
|
||||
@ -1996,7 +1996,7 @@ int Ng_GetVertex_NSurfaceElements( int vnr )
|
||||
case 3:
|
||||
{
|
||||
const MeshTopology& topology = mesh->GetTopology();
|
||||
NgArrayMem<SurfaceElementIndex,4> indexArray;
|
||||
ArrayMem<SurfaceElementIndex,4> indexArray;
|
||||
topology.GetVertexSurfaceElements( vnr, indexArray );
|
||||
return indexArray.Size();
|
||||
}
|
||||
|
@ -1289,9 +1289,7 @@ namespace netgen
|
||||
if(mapto[pi].Size() == 0)
|
||||
continue;
|
||||
auto pnew = mapto[pi].Last();
|
||||
NgArray<SurfaceElementIndex> old_els;
|
||||
meshtopo.GetVertexSurfaceElements( pi, old_els);
|
||||
for(auto old_sei : old_els)
|
||||
for(auto old_sei : meshtopo.GetVertexSurfaceElements( pi ))
|
||||
{
|
||||
if(mesh[old_sei].GetIndex() == domain)
|
||||
{
|
||||
|
@ -628,7 +628,7 @@ namespace netgen
|
||||
bool has_ided_sels = false;
|
||||
if(GetNE() && has_periodic) //we can only have identified surf-els if we have vol-els (right?)
|
||||
{
|
||||
NgArray<SurfaceElementIndex, 0> os1, os2;
|
||||
Array<SurfaceElementIndex> os1, os2;
|
||||
for(SurfaceElementIndex sei = 0; sei < GetNSE(); sei++)
|
||||
{
|
||||
if(ided_sel[sei]!=-1) continue;
|
||||
@ -647,7 +647,7 @@ namespace netgen
|
||||
os2.Append(GetTopology().GetVertexSurfaceElements(ided2[l]));
|
||||
for (int m = 0; m<os1.Size(); m++) {
|
||||
if(!os2.Contains(os1[m])) {
|
||||
os1.Delete(m);
|
||||
os1.DeleteElement(m);
|
||||
m--;
|
||||
}
|
||||
}
|
||||
|
@ -404,94 +404,9 @@ namespace netgen
|
||||
vertex to surface element
|
||||
vertex to segment
|
||||
*/
|
||||
cnt = 0;
|
||||
/*
|
||||
for (ElementIndex ei = 0; ei < ne; ei++)
|
||||
{
|
||||
const Element & el = (*mesh)[ei];
|
||||
for (int j = 0; j < el.GetNV(); j++)
|
||||
cnt[el[j]]++;
|
||||
}
|
||||
*/
|
||||
ParallelForRange
|
||||
(ne, [&] (IntRange r)
|
||||
{
|
||||
for (ElementIndex ei : r)
|
||||
{
|
||||
const Element & el = (*mesh)[ei];
|
||||
for (int j = 0; j < el.GetNV(); j++)
|
||||
AsAtomic(cnt[el[j]])++;
|
||||
}
|
||||
});
|
||||
|
||||
vert2element = TABLE<ElementIndex,PointIndex::BASE> (cnt);
|
||||
for (ElementIndex ei = 0; ei < ne; ei++)
|
||||
{
|
||||
const Element & el = (*mesh)[ei];
|
||||
for (int j = 0; j < el.GetNV(); j++)
|
||||
vert2element.AddSave (el[j], ei);
|
||||
}
|
||||
|
||||
/*
|
||||
ParallelForRange
|
||||
(tm, ne,
|
||||
[&] (size_t begin, size_t end)
|
||||
{
|
||||
for (ElementIndex ei = begin; ei < end; ei++)
|
||||
{
|
||||
const Element & el = (*mesh)[ei];
|
||||
for (int j = 0; j < el.GetNV(); j++)
|
||||
vert2element.ParallelAdd (el[j], ei);
|
||||
}
|
||||
});
|
||||
requires sorting !!!!
|
||||
*/
|
||||
|
||||
cnt = 0;
|
||||
/*
|
||||
for (SurfaceElementIndex sei = 0; sei < nse; sei++)
|
||||
{
|
||||
const Element2d & el = (*mesh)[sei];
|
||||
for (int j = 0; j < el.GetNV(); j++)
|
||||
cnt[el[j]]++;
|
||||
}
|
||||
*/
|
||||
ParallelForRange
|
||||
(nse,
|
||||
[&] (IntRange r)
|
||||
{
|
||||
for (SurfaceElementIndex ei : r)
|
||||
{
|
||||
const Element2d & el = (*mesh)[ei];
|
||||
for (int j = 0; j < el.GetNV(); j++)
|
||||
AsAtomic(cnt[el[j]])++;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
vert2surfelement = TABLE<SurfaceElementIndex,PointIndex::BASE> (cnt);
|
||||
|
||||
for (SurfaceElementIndex sei = 0; sei < nse; sei++)
|
||||
{
|
||||
const Element2d & el = (*mesh)[sei];
|
||||
for (int j = 0; j < el.GetNV(); j++)
|
||||
vert2surfelement.AddSave (el[j], sei);
|
||||
}
|
||||
/*
|
||||
ParallelForRange
|
||||
(tm, nse,
|
||||
[&] (size_t begin, size_t end)
|
||||
{
|
||||
for (SurfaceElementIndex sei = begin; sei < end; sei++)
|
||||
{
|
||||
const Element2d & el = (*mesh)[sei];
|
||||
for (int j = 0; j < el.GetNV(); j++)
|
||||
vert2surfelement.ParallelAdd (el[j], sei);
|
||||
}
|
||||
});
|
||||
requires sorting !!!
|
||||
*/
|
||||
vert2element = mesh->CreatePoint2ElementTable();
|
||||
vert2surfelement = mesh->CreatePoint2SurfaceElementTable(0);
|
||||
|
||||
cnt = 0;
|
||||
for (SegmentIndex si = 0; si < nseg; si++)
|
||||
@ -1606,7 +1521,7 @@ namespace netgen
|
||||
(*testout) << (*mesh)[(PointIndex)face2vert[i].I(j+1)] << " ";
|
||||
(*testout) << endl;
|
||||
|
||||
NgFlatArray<ElementIndex> vertels = GetVertexElements (face2vert[i].I(1));
|
||||
FlatArray<ElementIndex> vertels = GetVertexElements (face2vert[i].I(1));
|
||||
for (int k = 0; k < vertels.Size(); k++)
|
||||
{
|
||||
int elfaces[10], orient[10];
|
||||
@ -2522,7 +2437,7 @@ namespace netgen
|
||||
|
||||
|
||||
// GetVertexElements (pi[0], els);
|
||||
NgFlatArray<ElementIndex> els = GetVertexElements (pi[0]);
|
||||
FlatArray<ElementIndex> els = GetVertexElements (pi[0]);
|
||||
|
||||
// find one element having all vertices of the face
|
||||
for (int i = 0; i < els.Size(); i++)
|
||||
@ -2614,15 +2529,10 @@ namespace netgen
|
||||
*/
|
||||
|
||||
|
||||
void MeshTopology :: GetVertexElements (int vnr, NgArray<ElementIndex> & elements) const
|
||||
void MeshTopology :: GetVertexElements (int vnr, Array<ElementIndex> & elements) const
|
||||
{
|
||||
if (vert2element.Size())
|
||||
{
|
||||
int ne = vert2element.EntrySize(vnr);
|
||||
elements.SetSize(ne);
|
||||
for (int i = 1; i <= ne; i++)
|
||||
elements.Elem(i) = vert2element.Get(vnr, i);
|
||||
}
|
||||
elements = vert2element[vnr];
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2649,22 +2559,16 @@ namespace netgen
|
||||
*/
|
||||
|
||||
void MeshTopology :: GetVertexSurfaceElements( int vnr,
|
||||
NgArray<SurfaceElementIndex> & elements ) const
|
||||
Array<SurfaceElementIndex> & elements ) const
|
||||
{
|
||||
if (vert2surfelement.Size())
|
||||
{
|
||||
int i;
|
||||
int ne = vert2surfelement.EntrySize(vnr);
|
||||
elements.SetSize(ne);
|
||||
for (i = 1; i <= ne; i++)
|
||||
elements.Elem(i) = vert2surfelement.Get(vnr, i);
|
||||
}
|
||||
elements = vert2surfelement[vnr];
|
||||
}
|
||||
|
||||
|
||||
int MeshTopology :: GetVerticesEdge ( int v1, int v2 ) const
|
||||
{
|
||||
NgArray<ElementIndex> elements_v1;
|
||||
Array<ElementIndex> elements_v1;
|
||||
NgArray<int> elementedges;
|
||||
GetVertexElements ( v1, elements_v1);
|
||||
int edv1, edv2;
|
||||
@ -2690,14 +2594,13 @@ namespace netgen
|
||||
{
|
||||
int v1, v2;
|
||||
GetEdgeVertices ( GetSegmentEdge (segnr), v1, v2 );
|
||||
NgArray<ElementIndex> volels1, volels2;
|
||||
GetVertexElements ( v1, volels1 );
|
||||
GetVertexElements ( v2, volels2 );
|
||||
auto volels1 = GetVertexElements ( v1 );
|
||||
auto volels2 = GetVertexElements ( v2 );
|
||||
volels.SetSize(0);
|
||||
|
||||
for ( int eli1=1; eli1 <= volels1.Size(); eli1++)
|
||||
if ( volels2.Contains( volels1.Elem(eli1) ) )
|
||||
volels.Append ( volels1.Elem(eli1) );
|
||||
for ( auto volel1 : volels1 )
|
||||
if ( volels2.Contains( volel1 ) )
|
||||
volels.Append ( volel1 );
|
||||
}
|
||||
|
||||
void MeshTopology ::
|
||||
@ -2705,14 +2608,13 @@ namespace netgen
|
||||
{
|
||||
int v1, v2;
|
||||
GetEdgeVertices ( GetSegmentEdge (segnr), v1, v2 );
|
||||
NgArray<SurfaceElementIndex> els1, els2;
|
||||
GetVertexSurfaceElements ( v1, els1 );
|
||||
GetVertexSurfaceElements ( v2, els2 );
|
||||
auto els1 = GetVertexSurfaceElements ( v1 );
|
||||
auto els2 = GetVertexSurfaceElements ( v2 );
|
||||
els.SetSize(0);
|
||||
|
||||
for ( int eli1=1; eli1 <= els1.Size(); eli1++)
|
||||
if ( els2.Contains( els1.Elem(eli1) ) )
|
||||
els.Append ( els1.Elem(eli1) );
|
||||
for ( auto el1 : els1 )
|
||||
if ( els2.Contains( el1 ) )
|
||||
els.Append ( el1 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,8 +65,8 @@ class MeshTopology
|
||||
NgArray<INDEX_2> surf2volelement;
|
||||
NgArray<int> face2surfel;
|
||||
Array<SegmentIndex> edge2segment;
|
||||
TABLE<ElementIndex,PointIndex::BASE> vert2element;
|
||||
TABLE<SurfaceElementIndex,PointIndex::BASE> vert2surfelement;
|
||||
Table<ElementIndex, PointIndex> vert2element;
|
||||
Table<SurfaceElementIndex, PointIndex> vert2surfelement;
|
||||
TABLE<SegmentIndex,PointIndex::BASE> vert2segment;
|
||||
TABLE<int,PointIndex::BASE> vert2pointelement;
|
||||
int timestamp;
|
||||
@ -175,12 +175,12 @@ public:
|
||||
|
||||
SegmentIndex GetSegmentOfEdge(int edgenr) const { return edge2segment[edgenr-1]; }
|
||||
|
||||
void GetVertexElements (int vnr, NgArray<ElementIndex> & elements) const;
|
||||
NgFlatArray<ElementIndex> GetVertexElements (int vnr) const
|
||||
void GetVertexElements (int vnr, Array<ElementIndex> & elements) const;
|
||||
FlatArray<ElementIndex> GetVertexElements (int vnr) const
|
||||
{ return vert2element[vnr]; }
|
||||
|
||||
void GetVertexSurfaceElements( int vnr, NgArray<SurfaceElementIndex>& elements ) const;
|
||||
NgFlatArray<SurfaceElementIndex> GetVertexSurfaceElements(PointIndex vnr) const
|
||||
void GetVertexSurfaceElements( int vnr, Array<SurfaceElementIndex>& elements ) const;
|
||||
FlatArray<SurfaceElementIndex> GetVertexSurfaceElements(PointIndex vnr) const
|
||||
{ return vert2surfelement[vnr]; }
|
||||
|
||||
NgFlatArray<SegmentIndex> GetVertexSegments (int vnr) const
|
||||
|
Loading…
Reference in New Issue
Block a user