replace (most) NgBitArrays

This commit is contained in:
Joachim Schoeberl 2024-12-24 00:10:20 +01:00
parent b5fe5a4fb2
commit 209863d79e
14 changed files with 119 additions and 112 deletions

View File

@ -12,7 +12,6 @@
namespace netgen namespace netgen
{ {
/** /**
data type NgBitArray data type NgBitArray
@ -29,8 +28,12 @@ class NgBitArray
unsigned char * data; unsigned char * data;
public: public:
[[ deprecated ("use BitArray instead")]]
DLL_HEADER NgBitArray (); DLL_HEADER NgBitArray ();
/// ///
[[ deprecated ("use BitArray instead")]]
DLL_HEADER NgBitArray (INDEX asize); DLL_HEADER NgBitArray (INDEX asize);
/// ///
DLL_HEADER ~NgBitArray (); DLL_HEADER ~NgBitArray ();

View File

@ -1,5 +1,5 @@
HPREF_ELEMENT_TYPE ClassifyTet(HPRefElement & el, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom, HPREF_ELEMENT_TYPE ClassifyTet(HPRefElement & el, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom,
NgBitArray & cornerpoint, NgBitArray & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges, TBitArray<PointIndex> & cornerpoint, TBitArray<PointIndex> & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges,
INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint) INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint)
{ {
int ep1(0), ep2(0), ep3(0), ep4(0), cp1(0), cp2(0), cp3(0), cp4(0), fp1, fp2, fp3, fp4; int ep1(0), ep2(0), ep3(0), ep4(0), cp1(0), cp2(0), cp3(0), cp4(0), fp1, fp2, fp3, fp4;
@ -587,7 +587,7 @@ HPREF_ELEMENT_TYPE ClassifyTet(HPRefElement & el, INDEX_2_HASHTABLE<int> & edges
HPREF_ELEMENT_TYPE ClassifyPrism(HPRefElement & el, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom, HPREF_ELEMENT_TYPE ClassifyPrism(HPRefElement & el, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom,
NgBitArray & cornerpoint, NgBitArray & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges, TBitArray<PointIndex> & cornerpoint, TBitArray<PointIndex> & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges,
INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint) INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint)
{ {
@ -824,7 +824,7 @@ HPREF_ELEMENT_TYPE ClassifyPrism(HPRefElement & el, INDEX_2_HASHTABLE<int> & edg
// #ifdef SABINE // #ifdef SABINE
HPREF_ELEMENT_TYPE ClassifyTrig(HPRefElement & el, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom, HPREF_ELEMENT_TYPE ClassifyTrig(HPRefElement & el, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom,
NgBitArray & cornerpoint, NgBitArray & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges, TBitArray<PointIndex> & cornerpoint, TBitArray<PointIndex> & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges,
INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint, int dim, const FaceDescriptor & fd) INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint, int dim, const FaceDescriptor & fd)
{ {
@ -1301,7 +1301,7 @@ HPREF_ELEMENT_TYPE ClassifyTrig(HPRefElement & el, INDEX_2_HASHTABLE<int> & edge
} }
#endif #endif
HPREF_ELEMENT_TYPE ClassifyQuad(HPRefElement & el, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom, HPREF_ELEMENT_TYPE ClassifyQuad(HPRefElement & el, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom,
NgBitArray & cornerpoint, NgBitArray & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges, TBitArray<PointIndex> & cornerpoint, TBitArray<PointIndex> & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges,
INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint, int dim, const FaceDescriptor & fd) INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint, int dim, const FaceDescriptor & fd)
{ {
HPREF_ELEMENT_TYPE type = HP_NONE; HPREF_ELEMENT_TYPE type = HP_NONE;
@ -1651,7 +1651,7 @@ HPREF_ELEMENT_TYPE ClassifyQuad(HPRefElement & el, INDEX_2_HASHTABLE<int> & edge
HPREF_ELEMENT_TYPE ClassifyHex(HPRefElement & el, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom, HPREF_ELEMENT_TYPE ClassifyHex(HPRefElement & el, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom,
NgBitArray & cornerpoint, NgBitArray & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges, TBitArray<PointIndex> & cornerpoint, TBitArray<PointIndex> & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges,
INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint) INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint)
{ {
HPREF_ELEMENT_TYPE type = HP_NONE; HPREF_ELEMENT_TYPE type = HP_NONE;
@ -1756,7 +1756,8 @@ HPREF_ELEMENT_TYPE ClassifyHex(HPRefElement & el, INDEX_2_HASHTABLE<int> & edges
HPREF_ELEMENT_TYPE ClassifyHex7 (HPRefElement & el, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom, HPREF_ELEMENT_TYPE ClassifyHex7 (HPRefElement & el, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom,
NgBitArray & cornerpoint, NgBitArray & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges, TBitArray<PointIndex> & cornerpoint, TBitArray<PointIndex> & edgepoint,
INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges,
INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint) INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint)
{ {
// HPREF_ELEMENT_TYPE type = HP_NONE; // HPREF_ELEMENT_TYPE type = HP_NONE;
@ -1795,7 +1796,8 @@ HPREF_ELEMENT_TYPE ClassifyHex7 (HPRefElement & el, INDEX_2_HASHTABLE<int> & edg
HPREF_ELEMENT_TYPE ClassifySegm(HPRefElement & hpel, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom, HPREF_ELEMENT_TYPE ClassifySegm(HPRefElement & hpel, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom,
NgBitArray & cornerpoint, NgBitArray & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges, TBitArray<PointIndex> & cornerpoint, TBitArray<PointIndex> & edgepoint,
INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges,
INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint) INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint)
{ {
@ -1838,7 +1840,8 @@ HPREF_ELEMENT_TYPE ClassifySegm(HPRefElement & hpel, INDEX_2_HASHTABLE<int> & ed
HPREF_ELEMENT_TYPE ClassifyPyramid(HPRefElement & el, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom, HPREF_ELEMENT_TYPE ClassifyPyramid(HPRefElement & el, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom,
NgBitArray & cornerpoint, NgBitArray & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges, TBitArray<PointIndex> & cornerpoint, TBitArray<PointIndex> & edgepoint,
INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges,
INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint) INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint)
{ {
// *testout << "classify pyramid, pnums = "; // *testout << "classify pyramid, pnums = ";

View File

@ -1281,7 +1281,7 @@ namespace netgen
auto ne = tempels.Size(); auto ne = tempels.Size();
NgBitArray inner(ne), outer(ne); BitArray inner(ne+1), outer(ne+1);
inner.Clear(); inner.Clear();
outer.Clear(); outer.Clear();
NgArray<int> elstack; NgArray<int> elstack;
@ -1346,9 +1346,9 @@ namespace netgen
if (!inner.Test(ei) && !outer.Test(ei)) if (!inner.Test(ei) && !outer.Test(ei))
{ {
if (inside) if (inside)
inner.Set(ei); inner.SetBit(ei);
else else
outer.Set(ei); outer.SetBit(ei);
for (int j = 1; j <= 4; j++) for (int j = 1; j <= 4; j++)
@ -1439,7 +1439,7 @@ namespace netgen
if (adfront->Inside(ci)) if (adfront->Inside(ci))
outer.Clear(i); outer.Clear(i);
else else
outer.Set(i); outer.SetBit(i);
} }
} }

View File

@ -1632,8 +1632,8 @@ namespace netgen
} }
} }
bool CheckSingularities(Mesh & mesh, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom, bool CheckSingularities(Mesh & mesh, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HASHTABLE<int> & edgepoint_dom,
NgBitArray & cornerpoint, NgBitArray & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges, TBitArray<PointIndex> & cornerpoint, TBitArray<PointIndex> & edgepoint, INDEX_3_HASHTABLE<int> & faces, INDEX_2_HASHTABLE<int> & face_edges,
INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint, int & levels, int & act_ref) INDEX_2_HASHTABLE<int> & surf_edges, NgArray<int, PointIndex::BASE> & facepoint, int & levels, int & act_ref)
{ {
bool sing = 0; bool sing = 0;
@ -1670,7 +1670,7 @@ bool CheckSingularities(Mesh & mesh, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HAS
{ {
if (mesh.Point(i).Singularity() * levels >= act_ref) if (mesh.Point(i).Singularity() * levels >= act_ref)
{ {
cornerpoint.Set(i); cornerpoint.SetBit(i);
sing = 1; sing = 1;
} }
} }
@ -1695,8 +1695,8 @@ bool CheckSingularities(Mesh & mesh, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HAS
edges.Set (i2s, 1); edges.Set (i2s, 1);
edgepoint.Set (i2.I1()); edgepoint.SetBit (i2.I1());
edgepoint.Set (i2.I2()); edgepoint.SetBit (i2.I2());
sing = 1; sing = 1;
} }
@ -1718,10 +1718,10 @@ bool CheckSingularities(Mesh & mesh, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HAS
ek.Sort(); ek.Sort();
if (edges.Used(ej) && edges.Used(ek)) if (edges.Used(ej) && edges.Used(ek))
{ {
if (ej.I1() == ek.I1()) cornerpoint.Set (ek.I1()); if (ej.I1() == ek.I1()) cornerpoint.SetBit (ek.I1());
if (ej.I1() == ek.I2()) cornerpoint.Set (ek.I2()); if (ej.I1() == ek.I2()) cornerpoint.SetBit (ek.I2());
if (ej.I2() == ek.I1()) cornerpoint.Set (ek.I1()); if (ej.I2() == ek.I1()) cornerpoint.SetBit (ek.I1());
if (ej.I2() == ek.I2()) cornerpoint.Set (ek.I2()); if (ej.I2() == ek.I2()) cornerpoint.SetBit (ek.I2());
} }
} }
} }
@ -1801,10 +1801,10 @@ bool CheckSingularities(Mesh & mesh, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HAS
if (seg.singedge_left * levels >= act_ref) if (seg.singedge_left * levels >= act_ref)
{ {
INDEX_2 i2 = INDEX_2::Sort(mesh.LineSegment(i)[0], INDEX_2 i2 = INDEX_2::Sort(mesh.LineSegment(i)[0],
mesh.LineSegment(i)[1]); mesh.LineSegment(i)[1]);
edges.Set(i2,1); edges.Set(i2,1);
edgepoint.Set(i2.I1()); edgepoint.SetBit(i2.I1());
edgepoint.Set(i2.I2()); edgepoint.SetBit(i2.I2());
*testout << " singleft " << endl; *testout << " singleft " << endl;
*testout << " mesh.LineSegment(i).domout " << mesh.LineSegment(i).domout << endl; *testout << " mesh.LineSegment(i).domout " << mesh.LineSegment(i).domout << endl;
*testout << " mesh.LineSegment(i).domin " << mesh.LineSegment(i).domin << endl; *testout << " mesh.LineSegment(i).domin " << mesh.LineSegment(i).domin << endl;
@ -1819,8 +1819,8 @@ bool CheckSingularities(Mesh & mesh, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HAS
INDEX_2 i2 = INDEX_2::Sort(mesh.LineSegment(i)[1], INDEX_2 i2 = INDEX_2::Sort(mesh.LineSegment(i)[1],
mesh.LineSegment(i)[0]); mesh.LineSegment(i)[0]);
edges.Set (i2, 1); edges.Set (i2, 1);
edgepoint.Set(i2.I1()); edgepoint.SetBit(i2.I1());
edgepoint.Set(i2.I2()); edgepoint.SetBit(i2.I2());
*testout << " singright " << endl; *testout << " singright " << endl;
*testout << " mesh.LineSegment(i).domout " << mesh.LineSegment(i).domout << endl; *testout << " mesh.LineSegment(i).domout " << mesh.LineSegment(i).domout << endl;
@ -1858,14 +1858,14 @@ bool CheckSingularities(Mesh & mesh, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HAS
if (surfonpoint.Get(i).I1()) if (surfonpoint.Get(i).I1())
{ {
// cornerpoint.Set(i); // disabled by JS, Aug 2009 // cornerpoint.Set(i); // disabled by JS, Aug 2009
edgepoint.Set(i); edgepoint.SetBit(i);
} }
// mark points for refinement that are explicitly specified in input file // mark points for refinement that are explicitly specified in input file
if (mesh.Point(i).Singularity()*levels >= act_ref) if (mesh.Point(i).Singularity()*levels >= act_ref)
{ {
cornerpoint.Set(i); cornerpoint.SetBit(i);
edgepoint.Set(i); edgepoint.SetBit(i);
sing = 1; sing = 1;
} }
} }
@ -1890,11 +1890,11 @@ bool CheckSingularities(Mesh & mesh, INDEX_2_HASHTABLE<int> & edges, INDEX_2_HAS
bool ClassifyHPElements (Mesh & mesh, NgArray<HPRefElement> & elements, SplittingType split, int & act_ref, int & levels) bool ClassifyHPElements (Mesh & mesh, NgArray<HPRefElement> & elements, SplittingType split, int & act_ref, int & levels)
{ {
INDEX_2_HASHTABLE<int> edges(mesh.GetNSeg()+1); INDEX_2_HASHTABLE<int> edges(mesh.GetNSeg()+1);
NgBitArray edgepoint(mesh.GetNP()); TBitArray<PointIndex> edgepoint(mesh.GetNP());
INDEX_2_HASHTABLE<int> edgepoint_dom(mesh.GetNSeg()+1); INDEX_2_HASHTABLE<int> edgepoint_dom(mesh.GetNSeg()+1);
edgepoint.Clear(); edgepoint.Clear();
NgBitArray cornerpoint(mesh.GetNP()); TBitArray<PointIndex> cornerpoint(mesh.GetNP());
cornerpoint.Clear(); cornerpoint.Clear();
// value = nr > 0 ... refine elements in domain nr // value = nr > 0 ... refine elements in domain nr

View File

@ -704,7 +704,7 @@ void MeshOptimize3d :: SplitImprove ()
double MeshOptimize3d :: SwapImproveEdge ( double MeshOptimize3d :: SwapImproveEdge (
const NgBitArray * working_elements, const BitArray * working_elements,
Table<ElementIndex, PointIndex> & elementsonnode, Table<ElementIndex, PointIndex> & elementsonnode,
INDEX_3_HASHTABLE<int> & faces, INDEX_3_HASHTABLE<int> & faces,
PointIndex pi1, PointIndex pi2, bool check_only) PointIndex pi1, PointIndex pi2, bool check_only)
@ -1328,7 +1328,7 @@ double MeshOptimize3d :: SwapImproveEdge (
return d_badness; return d_badness;
} }
void MeshOptimize3d :: SwapImprove (const NgBitArray * working_elements) void MeshOptimize3d :: SwapImprove (const BitArray * working_elements)
{ {
static Timer t("MeshOptimize3d::SwapImprove"); RegionTimer reg(t); static Timer t("MeshOptimize3d::SwapImprove"); RegionTimer reg(t);
static Timer tloop("MeshOptimize3d::SwapImprove loop"); static Timer tloop("MeshOptimize3d::SwapImprove loop");
@ -1466,7 +1466,7 @@ void MeshOptimize3d :: SwapImprove (const NgBitArray * working_elements)
void MeshOptimize3d :: SwapImproveSurface ( void MeshOptimize3d :: SwapImproveSurface (
const NgBitArray * working_elements, const BitArray * working_elements,
const NgArray< idmap_type* > * idmaps) const NgArray< idmap_type* > * idmaps)
{ {
NgArray< idmap_type* > locidmaps; NgArray< idmap_type* > locidmaps;

View File

@ -41,9 +41,9 @@ public:
double SplitImprove2Element (ElementIndex ei, const Table<ElementIndex, PointIndex> & elements_of_point, bool check_only); double SplitImprove2Element (ElementIndex ei, const Table<ElementIndex, PointIndex> & elements_of_point, bool check_only);
double SwapImproveEdge (const NgBitArray * working_elements, Table<ElementIndex,PointIndex> & elementsonnode, INDEX_3_HASHTABLE<int> & faces, PointIndex pi1, PointIndex pi2, bool check_only=false); double SwapImproveEdge (const BitArray * working_elements, Table<ElementIndex,PointIndex> & elementsonnode, INDEX_3_HASHTABLE<int> & faces, PointIndex pi1, PointIndex pi2, bool check_only=false);
void SwapImprove (const NgBitArray * working_elements = NULL); void SwapImprove (const BitArray * working_elements = NULL);
void SwapImproveSurface (const NgBitArray * working_elements = NULL, void SwapImproveSurface (const BitArray * working_elements = NULL,
const NgArray< idmap_type* > * idmaps = NULL); const NgArray< idmap_type* > * idmaps = NULL);
void SwapImprove2 (); void SwapImprove2 ();
double SwapImprove2 (ElementIndex eli1, int face, Table<ElementIndex, PointIndex> & elementsonnode, TABLE<SurfaceElementIndex, PointIndex::BASE> & belementsonnode, bool check_only=false ); double SwapImprove2 (ElementIndex eli1, int face, Table<ElementIndex, PointIndex> & elementsonnode, TABLE<SurfaceElementIndex, PointIndex::BASE> & belementsonnode, bool check_only=false );

View File

@ -2457,7 +2457,7 @@ namespace netgen
} }
// NgBitArray base is PointIndex::BASE ... // NgBitArray base is PointIndex::BASE ...
void Mesh :: FixPoints (const NgBitArray & fixpoints) void Mesh :: FixPoints (const TBitArray<PointIndex> & fixpoints)
{ {
if (fixpoints.Size() != GetNP()) if (fixpoints.Size() != GetNP())
{ {
@ -3219,14 +3219,14 @@ namespace netgen
int np = GetNP(); int np = GetNP();
FindOpenSegments(); FindOpenSegments();
NgBitArray frontpoints(np+1); // for 0- and 1-based TBitArray<PointIndex> frontpoints(np); // for 0- and 1-based
frontpoints.Clear(); frontpoints.Clear();
for (int i = 1; i <= GetNOpenSegments(); i++) for (int i = 1; i <= GetNOpenSegments(); i++)
{ {
const Segment & seg = GetOpenSegment(i); const Segment & seg = GetOpenSegment(i);
frontpoints.Set (seg[0]); frontpoints.SetBit (seg[0]);
frontpoints.Set (seg[1]); frontpoints.SetBit (seg[1]);
} }
for (int i = 1; i <= GetNSE(); i++) for (int i = 1; i <= GetNSE(); i++)
@ -4799,10 +4799,10 @@ namespace netgen
void Mesh :: SurfaceMeshOrientation () void Mesh :: SurfaceMeshOrientation ()
{ {
int i, j; // int i, j;
int nse = GetNSE(); int nse = GetNSE();
NgBitArray used(nse); BitArray used(nse+1);
used.Clear(); used.Clear();
INDEX_2_HASHTABLE<int> edges(nse+1); INDEX_2_HASHTABLE<int> edges(nse+1);
@ -4810,12 +4810,12 @@ namespace netgen
const Element2d & tri = SurfaceElement(1); const Element2d & tri = SurfaceElement(1);
for (j = 1; j <= 3; j++) for (int j = 1; j <= 3; j++)
{ {
INDEX_2 i2(tri.PNumMod(j), tri.PNumMod(j+1)); INDEX_2 i2(tri.PNumMod(j), tri.PNumMod(j+1));
edges.Set (i2, 1); edges.Set (i2, 1);
} }
used.Set(1); used.SetBit(1);
bool unused; bool unused;
do do
@ -4824,12 +4824,12 @@ namespace netgen
do do
{ {
changed = 0; changed = 0;
for (i = 1; i <= nse; i++) for (int i = 1; i <= nse; i++)
if (!used.Test(i)) if (!used.Test(i))
{ {
Element2d & el = surfelements[i-1]; Element2d & el = surfelements[i-1];
int found = 0, foundrev = 0; int found = 0, foundrev = 0;
for (j = 1; j <= 3; j++) for (int j = 1; j <= 3; j++)
{ {
INDEX_2 i2(el.PNumMod(j), el.PNumMod(j+1)); INDEX_2 i2(el.PNumMod(j), el.PNumMod(j+1));
if (edges.Used(i2)) if (edges.Used(i2))
@ -4845,12 +4845,12 @@ namespace netgen
swap (el.PNum(2), el.PNum(3)); swap (el.PNum(2), el.PNum(3));
changed = 1; changed = 1;
for (j = 1; j <= 3; j++) for (int j = 1; j <= 3; j++)
{ {
INDEX_2 i2(el.PNumMod(j), el.PNumMod(j+1)); INDEX_2 i2(el.PNumMod(j), el.PNumMod(j+1));
edges.Set (i2, 1); edges.Set (i2, 1);
} }
used.Set (i); used.SetBit (i);
} }
} }
if (changed) if (changed)
@ -4860,17 +4860,17 @@ namespace netgen
unused = 0; unused = 0;
for (i = 1; i <= nse; i++) for (int i = 1; i <= nse; i++)
if (!used.Test(i)) if (!used.Test(i))
{ {
unused = 1; unused = 1;
const Element2d & tri = SurfaceElement(i); const Element2d & tri = SurfaceElement(i);
for (j = 1; j <= 3; j++) for (int j = 1; j <= 3; j++)
{ {
INDEX_2 i2(tri.PNumMod(j), tri.PNumMod(j+1)); INDEX_2 i2(tri.PNumMod(j), tri.PNumMod(j+1));
edges.Set (i2, 1); edges.Set (i2, 1);
} }
used.Set(i); used.SetBit(i);
break; break;
} }
} }
@ -6105,17 +6105,17 @@ namespace netgen
void Mesh :: SplitIntoParts() void Mesh :: SplitIntoParts()
{ {
int i, j, dom; // int i, j, dom;
int ne = GetNE(); int ne = GetNE();
int np = GetNP(); int np = GetNP();
int nse = GetNSE(); int nse = GetNSE();
NgBitArray surfused(nse); BitArray surfused(nse+1);
NgBitArray pused (np); TBitArray<PointIndex> pused (np);
surfused.Clear(); surfused.Clear();
dom = 0; int dom = 0;
while (1) while (1)
{ {
@ -6126,15 +6126,15 @@ namespace netgen
pused.Clear(); pused.Clear();
int found = 0; int found = 0;
for (i = 1; i <= nse; i++) for (int i = 1; i <= nse; i++)
if (!surfused.Test(i)) if (!surfused.Test(i))
{ {
SurfaceElement(i).SetIndex (dom); SurfaceElement(i).SetIndex (dom);
for (j = 1; j <= 3; j++) for (int j = 1; j <= 3; j++)
pused.Set (SurfaceElement(i).PNum(j)); pused.SetBit (SurfaceElement(i).PNum(j));
found = 1; found = 1;
cntd = 1; cntd = 1;
surfused.Set(i); surfused.SetBit(i);
break; break;
} }
@ -6145,10 +6145,10 @@ namespace netgen
do do
{ {
change = 0; change = 0;
for (i = 1; i <= nse; i++) for (int i = 1; i <= nse; i++)
{ {
int is = 0, isnot = 0; int is = 0, isnot = 0;
for (j = 1; j <= 3; j++) for (int j = 1; j <= 3; j++)
if (pused.Test(SurfaceElement(i).PNum(j))) if (pused.Test(SurfaceElement(i).PNum(j)))
is = 1; is = 1;
else else
@ -6157,15 +6157,15 @@ namespace netgen
if (is && isnot) if (is && isnot)
{ {
change = 1; change = 1;
for (j = 1; j <= 3; j++) for (int j = 1; j <= 3; j++)
pused.Set (SurfaceElement(i).PNum(j)); pused.SetBit (SurfaceElement(i).PNum(j));
} }
if (is) if (is)
{ {
if (!surfused.Test(i)) if (!surfused.Test(i))
{ {
surfused.Set(i); surfused.SetBit(i);
SurfaceElement(i).SetIndex (dom); SurfaceElement(i).SetIndex (dom);
cntd++; cntd++;
} }
@ -6173,10 +6173,10 @@ namespace netgen
} }
for (i = 1; i <= ne; i++) for (int i = 1; i <= ne; i++)
{ {
int is = 0, isnot = 0; int is = 0, isnot = 0;
for (j = 1; j <= 4; j++) for (int j = 1; j <= 4; j++)
if (pused.Test(VolumeElement(i).PNum(j))) if (pused.Test(VolumeElement(i).PNum(j)))
is = 1; is = 1;
else else
@ -6185,8 +6185,8 @@ namespace netgen
if (is && isnot) if (is && isnot)
{ {
change = 1; change = 1;
for (j = 1; j <= 4; j++) for (int j = 1; j <= 4; j++)
pused.Set (VolumeElement(i).PNum(j)); pused.SetBit (VolumeElement(i).PNum(j));
} }
if (is) if (is)
@ -6210,7 +6210,7 @@ namespace netgen
} }
*/ */
ClearFaceDescriptors(); ClearFaceDescriptors();
for (i = 1; i <= dom; i++) for (int i = 1; i <= dom; i++)
AddFaceDescriptor (FaceDescriptor (0, i, 0, 0)); AddFaceDescriptor (FaceDescriptor (0, i, 0, 0));
CalcSurfacesOfNode(); CalcSurfacesOfNode();
timestamp = NextTimeStamp(); timestamp = NextTimeStamp();
@ -6222,7 +6222,7 @@ namespace netgen
int fdi; int fdi;
int np = GetNP(); int np = GetNP();
NgBitArray usedp(np); TBitArray<PointIndex> usedp(np);
Array<SurfaceElementIndex> els_of_face; Array<SurfaceElementIndex> els_of_face;
fdi = 1; fdi = 1;
@ -6240,7 +6240,7 @@ namespace netgen
usedp.Clear(); usedp.Clear();
for (int j = 1; j <= SurfaceElement(firstel).GetNP(); j++) for (int j = 1; j <= SurfaceElement(firstel).GetNP(); j++)
usedp.Set (SurfaceElement(firstel).PNum(j)); usedp.SetBit (SurfaceElement(firstel).PNum(j));
bool changed; bool changed;
do do
@ -6266,7 +6266,7 @@ namespace netgen
if (has) if (has)
for (int j = 0; j < el.GetNP(); j++) for (int j = 0; j < el.GetNP(); j++)
usedp.Set (el[j]); usedp.SetBit (el[j]);
} }
} }
while (changed); while (changed);

View File

@ -425,7 +425,7 @@ namespace netgen
DLL_HEADER void CalcSurfacesOfNode (); DLL_HEADER void CalcSurfacesOfNode ();
/// additional (temporarily) fix points /// additional (temporarily) fix points
void FixPoints (const NgBitArray & fixpoints); void FixPoints (const TBitArray<PointIndex> & fixpoints);
/** /**
finds elements without neighbour and finds elements without neighbour and
@ -606,10 +606,11 @@ namespace netgen
DLL_HEADER void ImproveMesh (const MeshingParameters & mp, OPTIMIZEGOAL goal = OPT_QUALITY); DLL_HEADER void ImproveMesh (const MeshingParameters & mp, OPTIMIZEGOAL goal = OPT_QUALITY);
/// ///
void ImproveMeshJacobian (const MeshingParameters & mp, OPTIMIZEGOAL goal = OPT_QUALITY, const NgBitArray * usepoint = NULL); void ImproveMeshJacobian (const MeshingParameters & mp, OPTIMIZEGOAL goal = OPT_QUALITY,
const TBitArray<PointIndex> * usepoint = NULL);
/// ///
void ImproveMeshJacobianOnSurface (const MeshingParameters & mp, void ImproveMeshJacobianOnSurface (const MeshingParameters & mp,
const NgBitArray & usepoint, const TBitArray<PointIndex> & usepoint,
const NgArray< Vec<3>* > & nv, const NgArray< Vec<3>* > & nv,
OPTIMIZEGOAL goal = OPT_QUALITY, OPTIMIZEGOAL goal = OPT_QUALITY,
const NgArray< idmap_type* > * idmaps = NULL); const NgArray< idmap_type* > * idmaps = NULL);

View File

@ -820,11 +820,11 @@ namespace netgen
can.Elem(parent.I2())); can.Elem(parent.I2()));
} }
NgBitArray boundp(np); TBitArray<PointIndex> boundp(np);
boundp.Clear(); boundp.Clear();
for (auto & sel : mesh.SurfaceElements()) for (auto & sel : mesh.SurfaceElements())
for (auto pi : sel.PNums()) for (auto pi : sel.PNums())
boundp.Set(pi); boundp.SetBit(pi);
double lam = 0.5; double lam = 0.5;
@ -851,14 +851,14 @@ namespace netgen
mesh.Point(i) = can.Get(i); mesh.Point(i) = can.Get(i);
NgBitArray free (mesh.GetNP()), fhelp(mesh.GetNP()); TBitArray<PointIndex> free (mesh.GetNP()), fhelp(mesh.GetNP());
free.Clear(); free.Clear();
for (int i = 1; i <= mesh.GetNE(); i++) for (int i = 1; i <= mesh.GetNE(); i++)
{ {
const Element & el = mesh.VolumeElement(i); const Element & el = mesh.VolumeElement(i);
if (el.Volume(mesh.Points()) < 0) if (el.Volume(mesh.Points()) < 0)
for (int j = 1; j <= el.GetNP(); j++) for (int j = 1; j <= el.GetNP(); j++)
free.Set (el.PNum(j)); free.SetBit (el.PNum(j));
} }
for (int k = 1; k <= 3; k++) for (int k = 1; k <= 3; k++)
{ {
@ -872,7 +872,7 @@ namespace netgen
freeel = 1; freeel = 1;
if (freeel) if (freeel)
for (int j = 1; j <= el.GetNP(); j++) for (int j = 1; j <= el.GetNP(); j++)
fhelp.Set (el.PNum(j)); fhelp.SetBit (el.PNum(j));
} }
free.Or (fhelp); free.Or (fhelp);
} }

View File

@ -481,7 +481,7 @@ namespace netgen
double facok = 0; double facok = 0;
double factry; double factry;
NgBitArray illegalels(ne); BitArray illegalels(ne+1);
illegalels.Clear(); illegalels.Clear();
@ -505,13 +505,13 @@ namespace netgen
can.Elem(parents.Get(i).I2())); can.Elem(parents.Get(i).I2()));
} }
NgBitArray boundp(np); TBitArray<PointIndex> boundp(np);
boundp.Clear(); boundp.Clear();
for (int i = 1; i <= mesh.GetNSE(); i++) for (int i = 1; i <= mesh.GetNSE(); i++)
{ {
const Element2d & sel = mesh.SurfaceElement(i); const Element2d & sel = mesh.SurfaceElement(i);
for (int j = 1; j <= sel.GetNP(); j++) for (int j = 1; j <= sel.GetNP(); j++)
boundp.Set(sel.PNum(j)); boundp.SetBit(sel.PNum(j));
} }
@ -563,7 +563,7 @@ namespace netgen
if (lam < 1e-4) if (lam < 1e-4)
illegalels.Set(i); illegalels.SetBit(i);
/* /*

View File

@ -110,7 +110,7 @@ namespace netgen
int np = mesh.GetNP(); int np = mesh.GetNP();
int ne = mesh.GetNE(); int ne = mesh.GetNE();
NgBitArray badnodes(np); TBitArray<PointIndex> badnodes(np);
badnodes.Clear(); badnodes.Clear();
for (i = 1; i <= ne; i++) for (i = 1; i <= ne; i++)
@ -119,7 +119,7 @@ namespace netgen
double bad = el.CalcJacobianBadness (mesh.Points()); double bad = el.CalcJacobianBadness (mesh.Points());
if (bad > 1) if (bad > 1)
for (j = 1; j <= el.GetNP(); j++) for (j = 1; j <= el.GetNP(); j++)
badnodes.Set (el.PNum(j)); badnodes.SetBit (el.PNum(j));
} }

View File

@ -1485,7 +1485,7 @@ void Mesh :: ImproveMesh (const MeshingParameters & mp, OPTIMIZEGOAL goal)
// Improve Condition number of Jacobian, any elements // Improve Condition number of Jacobian, any elements
void Mesh :: ImproveMeshJacobian (const MeshingParameters & mp, void Mesh :: ImproveMeshJacobian (const MeshingParameters & mp,
OPTIMIZEGOAL goal, const NgBitArray * usepoint) OPTIMIZEGOAL goal, const TBitArray<PointIndex> * usepoint)
{ {
// int i, j; // int i, j;
@ -1507,7 +1507,7 @@ void Mesh :: ImproveMeshJacobian (const MeshingParameters & mp,
par.maxit_linsearch = 20; par.maxit_linsearch = 20;
par.maxit_bfgs = 20; par.maxit_bfgs = 20;
NgBitArray badnodes(np); TBitArray<PointIndex> badnodes(np);
badnodes.Clear(); badnodes.Clear();
for (int i = 1; i <= ne; i++) for (int i = 1; i <= ne; i++)
@ -1516,7 +1516,7 @@ void Mesh :: ImproveMeshJacobian (const MeshingParameters & mp,
double bad = el.CalcJacobianBadness (Points()); double bad = el.CalcJacobianBadness (Points());
if (bad > 1) if (bad > 1)
for (int j = 1; j <= el.GetNP(); j++) for (int j = 1; j <= el.GetNP(); j++)
badnodes.Set (el.PNum(j)); badnodes.SetBit (el.PNum(j));
} }
NgArray<double, PointIndex::BASE, PointIndex> pointh (points.Size()); NgArray<double, PointIndex::BASE, PointIndex> pointh (points.Size());
@ -1608,7 +1608,7 @@ void Mesh :: ImproveMeshJacobian (const MeshingParameters & mp,
// Improve Condition number of Jacobian, any elements // Improve Condition number of Jacobian, any elements
void Mesh :: ImproveMeshJacobianOnSurface (const MeshingParameters & mp, void Mesh :: ImproveMeshJacobianOnSurface (const MeshingParameters & mp,
const NgBitArray & usepoint, const TBitArray<PointIndex> & usepoint,
const NgArray< Vec<3>* > & nv, const NgArray< Vec<3>* > & nv,
OPTIMIZEGOAL goal, OPTIMIZEGOAL goal,
const NgArray< idmap_type* > * idmaps) const NgArray< idmap_type* > * idmaps)
@ -1664,7 +1664,7 @@ void Mesh :: ImproveMeshJacobianOnSurface (const MeshingParameters & mp,
par.maxit_linsearch = 20; par.maxit_linsearch = 20;
par.maxit_bfgs = 20; par.maxit_bfgs = 20;
NgBitArray badnodes(np); TBitArray<PointIndex> badnodes(np);
badnodes.Clear(); badnodes.Clear();
for (int i = 1; i <= ne; i++) for (int i = 1; i <= ne; i++)
@ -1673,7 +1673,7 @@ void Mesh :: ImproveMeshJacobianOnSurface (const MeshingParameters & mp,
double bad = el.CalcJacobianBadness (Points()); double bad = el.CalcJacobianBadness (Points());
if (bad > 1) if (bad > 1)
for (int j = 1; j <= el.GetNP(); j++) for (int j = 1; j <= el.GetNP(); j++)
badnodes.Set (el.PNum(j)); badnodes.SetBit (el.PNum(j));
} }
NgArray<double, PointIndex::BASE> pointh (points.Size()); NgArray<double, PointIndex::BASE> pointh (points.Size());

View File

@ -62,13 +62,13 @@ void CutOffAndCombine (Mesh & mesh, const Mesh & othermesh)
} }
cout << endl; cout << endl;
NgBitArray connected(mesh.GetNP()); TBitArray<PointIndex> connected(mesh.GetNP());
connected.Clear(); connected.Clear();
for (i = 1; i <= mesh.GetNSE(); i++) for (i = 1; i <= mesh.GetNSE(); i++)
{ {
const Element2d & el = mesh.SurfaceElement(i); const Element2d & el = mesh.SurfaceElement(i);
for (j = 1; j <= 3; j++) for (j = 1; j <= 3; j++)
connected.Set(el.PNum(j)); connected.SetBit(el.PNum(j));
} }
bool changed; bool changed;
@ -92,7 +92,7 @@ void CutOffAndCombine (Mesh & mesh, const Mesh & othermesh)
{ {
changed = 1; changed = 1;
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
connected.Set (el[j]); connected.SetBit (el[j]);
} }
} }
} }
@ -120,7 +120,7 @@ void CutOffAndCombine (Mesh & mesh, const Mesh & othermesh)
mesh.Compress(); mesh.Compress();
mesh.FindOpenElements(); mesh.FindOpenElements();
NgBitArray locked(mesh.GetNP()); TBitArray<PointIndex> locked(mesh.GetNP());
locked.Set(); locked.Set();
for (i = 1; i <= mesh.GetNOpenElements(); i++) for (i = 1; i <= mesh.GetNOpenElements(); i++)
for (j = 1; j <= 3; j++) for (j = 1; j <= 3; j++)

View File

@ -104,7 +104,7 @@ namespace netgen
} }
void GetWorkingArea(NgBitArray & working_elements, NgBitArray & working_points, void GetWorkingArea(BitArray & working_elements, TBitArray<PointIndex> & working_points,
const Mesh & mesh, const NgArray<ElementIndex> & bad_elements, const Mesh & mesh, const NgArray<ElementIndex> & bad_elements,
const int width) const int width)
{ {
@ -113,10 +113,10 @@ namespace netgen
for(int i=0; i<bad_elements.Size(); i++) for(int i=0; i<bad_elements.Size(); i++)
{ {
working_elements.Set(bad_elements[i]); working_elements.SetBit(bad_elements[i]);
const Element & el = mesh[bad_elements[i]]; const Element & el = mesh[bad_elements[i]];
for(int j=1; j<=el.GetNP(); j++) for(int j=1; j<=el.GetNP(); j++)
working_points.Set(el.PNum(j)); working_points.SetBit(el.PNum(j));
} }
@ -133,7 +133,7 @@ namespace netgen
set_active = working_points.Test(el.PNum(k)); set_active = working_points.Test(el.PNum(k));
if(set_active) if(set_active)
working_elements.Set(j); working_elements.SetBit(j);
} }
} }
@ -143,7 +143,7 @@ namespace netgen
{ {
const Element & el = mesh[j]; const Element & el = mesh[j];
for(int k=1; k<=el.GetNP(); k++) for(int k=1; k<=el.GetNP(); k++)
working_points.Set(el.PNum(k)); working_points.SetBit(el.PNum(k));
} }
} }
} }
@ -185,15 +185,15 @@ namespace netgen
can[i] = new Point<3>; can[i] = new Point<3>;
} }
NgBitArray isboundarypoint(np),isedgepoint(np); TBitArray<PointIndex> isboundarypoint(np),isedgepoint(np);
isboundarypoint.Clear(); isboundarypoint.Clear();
isedgepoint.Clear(); isedgepoint.Clear();
for(int i = 1; i <= mesh.GetNSeg(); i++) for(int i = 1; i <= mesh.GetNSeg(); i++)
{ {
const Segment & seg = mesh.LineSegment(i); const Segment & seg = mesh.LineSegment(i);
isedgepoint.Set(seg[0]); isedgepoint.SetBit(seg[0]);
isedgepoint.Set(seg[1]); isedgepoint.SetBit(seg[1]);
} }
NgArray<int> surfaceindex(np); NgArray<int> surfaceindex(np);
@ -205,7 +205,7 @@ namespace netgen
for (int j = 1; j <= sel.GetNP(); j++) for (int j = 1; j <= sel.GetNP(); j++)
if(!isedgepoint.Test(sel.PNum(j))) if(!isedgepoint.Test(sel.PNum(j)))
{ {
isboundarypoint.Set(sel.PNum(j)); isboundarypoint.SetBit(sel.PNum(j));
surfaceindex[sel.PNum(j) - PointIndex::BASE] = surfaceindex[sel.PNum(j) - PointIndex::BASE] =
mesh.GetFaceDescriptor(sel.GetIndex()).SurfNr(); mesh.GetFaceDescriptor(sel.GetIndex()).SurfNr();
} }
@ -216,8 +216,8 @@ namespace netgen
Validate(mesh,bad_elements,pure_badness, Validate(mesh,bad_elements,pure_badness,
((uselocalworsening) ? (0.8*(max_worsening-1.) + 1.) : (0.1*(max_worsening-1.) + 1.)), ((uselocalworsening) ? (0.8*(max_worsening-1.) + 1.) : (0.1*(max_worsening-1.) + 1.)),
uselocalworsening); // -> larger working area uselocalworsening); // -> larger working area
NgBitArray working_elements(ne); BitArray working_elements(ne+1);
NgBitArray working_points(np); TBitArray<PointIndex> working_points(np);
GetWorkingArea(working_elements,working_points,mesh,bad_elements,numbadneighbours); GetWorkingArea(working_elements,working_points,mesh,bad_elements,numbadneighbours);
//working_elements.Set(); //working_elements.Set();
@ -240,10 +240,10 @@ namespace netgen
PrintMessage(5,ostrstr.str()); PrintMessage(5,ostrstr.str());
NgBitArray isworkingboundary(np); TBitArray<PointIndex> isworkingboundary(np);
for(int i=1; i<=np; i++) for(int i=1; i<=np; i++)
if(working_points.Test(i) && isboundarypoint.Test(i)) if(working_points.Test(i) && isboundarypoint.Test(i))
isworkingboundary.Set(i); isworkingboundary.SetBit(i);
else else
isworkingboundary.Clear(i); isworkingboundary.Clear(i);
@ -497,7 +497,7 @@ namespace netgen
GetWorkingArea(working_elements,working_points,mesh,bad_elements,numbadneighbours); GetWorkingArea(working_elements,working_points,mesh,bad_elements,numbadneighbours);
for(int i=1; i<=np; i++) for(int i=1; i<=np; i++)
if(working_points.Test(i) && isboundarypoint.Test(i)) if(working_points.Test(i) && isboundarypoint.Test(i))
isworkingboundary.Set(i); isworkingboundary.SetBit(i);
else else
isworkingboundary.Clear(i); isworkingboundary.Clear(i);
auxnum=0; auxnum=0;