PointIndex

This commit is contained in:
Joachim Schoeberl 2024-12-27 18:05:04 +01:00
parent 0a7a206223
commit ceddf31f87
18 changed files with 95 additions and 94 deletions

View File

@ -473,8 +473,8 @@ namespace netgen
{ {
PointGeomInfo gi; PointGeomInfo gi;
gi.trignum = k; gi.trignum = k;
meshing.AddBoundaryElement (segments[si][0] + 1 - PointIndex::BASE, meshing.AddBoundaryElement (segments[si][0] + 1 - IndexBASE<PointIndex>(),
segments[si][1] + 1 - PointIndex::BASE, segments[si][1] + 1 - IndexBASE<PointIndex>(),
gi, gi); gi, gi);
} }

View File

@ -564,13 +564,17 @@ namespace netgen
NgArray<PointIndex> pts ( (nex+1) * (ney+1) ); // x ... inner loop NgArray<PointIndex> pts ( (nex+1) * (ney+1) ); // x ... inner loop
pts = -1; pts = -1;
for (PointIndex pi = c1, i = 0; pi != c2; pi = nextpi[pi], i++) int i = 0;
for (PointIndex pi = c1; pi != c2; pi = nextpi[pi], i++)
pts[i] = pi; pts[i] = pi;
for (PointIndex pi = c2, i = 0; pi != c3; pi = nextpi[pi], i++) i = 0;
for (PointIndex pi = c2; pi != c3; pi = nextpi[pi], i++)
pts[(nex+1)*i+nex] = pi; pts[(nex+1)*i+nex] = pi;
for (PointIndex pi = c3, i = 0; pi != c4; pi = nextpi[pi], i++) i = 0;
for (PointIndex pi = c3; pi != c4; pi = nextpi[pi], i++)
pts[(nex+1)*(ney+1)-i-1] = pi; pts[(nex+1)*(ney+1)-i-1] = pi;
for (PointIndex pi = c4, i = 0; pi != c1; pi = nextpi[pi], i++) i = 0;
for (PointIndex pi = c4; pi != c1; pi = nextpi[pi], i++)
pts[(nex+1)*(ney-i)] = pi; pts[(nex+1)*(ney-i)] = pi;

View File

@ -2240,7 +2240,7 @@ int Ng_GetClosureNodes (int nt, int nodenr, int nodeset, int * nodes)
for (int i = 0; i < el.GetNP(); i++) for (int i = 0; i < el.GetNP(); i++)
{ {
nodes[cnt++] = 0; nodes[cnt++] = 0;
nodes[cnt++] = el[i] - PointIndex::BASE; nodes[cnt++] = el[i] - IndexBASE<PointIndex>();
} }
} }
@ -2322,7 +2322,7 @@ int Ng_GetElementClosureNodes (int dim, int elementnr, int nodeset, int * nodes)
for (int i = 0; i < el.GetNP(); i++) for (int i = 0; i < el.GetNP(); i++)
{ {
nodes[cnt++] = 0; nodes[cnt++] = 0;
nodes[cnt++] = el[i] - PointIndex::BASE; nodes[cnt++] = el[i] - IndexBASE<PointIndex>();
} }
} }

View File

@ -60,7 +60,7 @@ static void WritePoints ( const Mesh & mesh, ostream & out )
out << "*Node" << endl; out << "*Node" << endl;
for(auto pi : mesh.Points().Range() ) for(auto pi : mesh.Points().Range() )
{ {
out << pi+1-PointIndex::BASE << ", "; out << pi+1-IndexBASE<PointIndex>() << ", ";
auto p = mesh[pi]; auto p = mesh[pi];
out << p[0] << ", " << p[1] << ", " << p[2] << '\n'; out << p[0] << ", " << p[1] << ", " << p[2] << '\n';
} }
@ -73,7 +73,7 @@ static void WriteElement(ostream & out, const Mesh& mesh, ElIndex ei, const vect
auto el = mesh[ei]; auto el = mesh[ei];
out << el_counter; out << el_counter;
for(auto i : Range(el.PNums())) for(auto i : Range(el.PNums()))
out << ", " << el[permutation[i]]+1-PointIndex::BASE; out << ", " << el[permutation[i]]+1-IndexBASE<PointIndex>();
out << '\n'; out << '\n';
} }

View File

@ -502,7 +502,7 @@ namespace netgen
<< mesh[i](0) << " " << mesh[i](0) << " "
<< mesh[i](1) << " " << mesh[i](1) << " "
<< mesh[i](2) << " " << id_type[i] << " "; << mesh[i](2) << " " << id_type[i] << " ";
if(i-PointIndex::BASE < point_ids.Size()) if(i-IndexBASE<PointIndex>() < point_ids.Size())
outfile << point_ids[i]; outfile << point_ids[i];
else else
outfile << "0"; outfile << "0";
@ -1066,13 +1066,13 @@ namespace netgen
// for(PointIndex i = mesh.Points().Begin(); i < mesh.Points().End(); i++) // for(PointIndex i = mesh.Points().Begin(); i < mesh.Points().End(); i++)
for(PointIndex i : mesh.Points().Range()) for(PointIndex i : mesh.Points().Range())
{ {
if(i-PointIndex::BASE < point_ids.Size()) if(i-IndexBASE<PointIndex>() < point_ids.Size())
{ {
if(uid_to_group_0D[point_ids[i]] >= 0) if(uid_to_group_0D[point_ids[i]] >= 0)
groups[uid_to_group_0D[point_ids[i]]]->Append(i+1-PointIndex::BASE); groups[uid_to_group_0D[point_ids[i]]]->Append(i+1-IndexBASE<PointIndex>());
} }
else else
groups[uid_to_group_0D[0]]->Append(i+1-PointIndex::BASE); groups[uid_to_group_0D[0]]->Append(i+1-IndexBASE<PointIndex>());
} }

View File

@ -584,6 +584,7 @@ namespace netgen
Array<PointIndex> vert2meshpt(vertices.Size()); Array<PointIndex> vert2meshpt(vertices.Size());
vert2meshpt = PointIndex::INVALID; vert2meshpt = PointIndex::INVALID;
for(auto & vert : vertices) for(auto & vert : vertices)
{ {
auto pi = mesh.AddPoint(vert->GetPoint(), vert->properties.layer); auto pi = mesh.AddPoint(vert->GetPoint(), vert->properties.layer);
@ -591,9 +592,9 @@ namespace netgen
mesh[pi].Singularity(vert->properties.hpref); mesh[pi].Singularity(vert->properties.hpref);
mesh[pi].SetType(FIXEDPOINT); mesh[pi].SetType(FIXEDPOINT);
Element0d el(pi, pi); Element0d el(pi, pi-IndexBASE<PointIndex>()+1);
el.name = vert->properties.GetName(); el.name = vert->properties.GetName();
mesh.SetCD3Name(pi, el.name); mesh.SetCD3Name(pi-IndexBASE<PointIndex>()+1, el.name);
mesh.pointelements.Append (el); mesh.pointelements.Append (el);
} }

View File

@ -342,7 +342,7 @@ namespace netgen
possible = 1; possible = 1;
for (int k = 0; k < rel.GetNP(); k++) for (int k = 0; k < rel.GetNP(); k++)
if (pmap.Elem(rel[k]) != -1 && if (pmap.Elem(rel[k]).IsValid() &&
pmap.Elem(rel[k]) != el.PNumMod (k+elrot[i]+1)) pmap.Elem(rel[k]) != el.PNumMod (k+elrot[i]+1))
possible = 0; possible = 0;

View File

@ -1170,10 +1170,7 @@ double MeshOptimize3d :: SwapImproveEdge (
for (int k2 = 0; k2 < 4 && !newpi.IsValid(); k2++) for (int k2 = 0; k2 < 4 && !newpi.IsValid(); k2++)
if (nel[k2] == oldpi) if (nel[k2] == oldpi)
{ {
newpi = newpi = nel[0] - pi1 + nel[1] - pi2 + nel[2] - oldpi + nel[3];
nel[0] + nel[1] + nel[2] + nel[3]
- pi1 - pi2 - oldpi;
tetused[k] = true; tetused[k] = true;
suroundpts[l] = newpi; suroundpts[l] = newpi;
} }
@ -1830,7 +1827,7 @@ void MeshOptimize3d :: SwapImproveSurface (
int nsuround = hasbothpoints.Size(); int nsuround = hasbothpoints.Size();
int nsuroundother = hasbothpointsother.Size(); int nsuroundother = hasbothpointsother.Size();
NgArray < int > outerpoints(nsuround+1); NgArray < PointIndex > outerpoints(nsuround+1);
outerpoints[0] = sp1; outerpoints[0] = sp1;
for(int i=0; i<nsuround; i++) for(int i=0; i<nsuround; i++)
@ -1865,7 +1862,7 @@ void MeshOptimize3d :: SwapImproveSurface (
{ {
(*testout) << mesh[hasbothpoints[ii]] << endl; (*testout) << mesh[hasbothpoints[ii]] << endl;
for(int jj=0; jj<mesh[hasbothpoints[ii]].GetNP(); jj++) for(int jj=0; jj<mesh[hasbothpoints[ii]].GetNP(); jj++)
if(mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][0] > 0) if(mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][0].IsValid())
(*testout) << mesh[hasbothpoints[ii]][jj] << " between " (*testout) << mesh[hasbothpoints[ii]][jj] << " between "
<< mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][0] << " and " << mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][0] << " and "
<< mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][1] << endl; << mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][1] << endl;
@ -1875,11 +1872,11 @@ void MeshOptimize3d :: SwapImproveSurface (
<< "sel2 " << mesh[sel2] << endl; << "sel2 " << mesh[sel2] << endl;
for(int ii=0; ii<3; ii++) for(int ii=0; ii<3; ii++)
{ {
if(mesh.mlbetweennodes[mesh[sel1][ii]][0] > 0) if(mesh.mlbetweennodes[mesh[sel1][ii]][0].IsValid())
(*testout) << mesh[sel1][ii] << " between " (*testout) << mesh[sel1][ii] << " between "
<< mesh.mlbetweennodes[mesh[sel1][ii]][0] << " and " << mesh.mlbetweennodes[mesh[sel1][ii]][0] << " and "
<< mesh.mlbetweennodes[mesh[sel1][ii]][1] << endl; << mesh.mlbetweennodes[mesh[sel1][ii]][1] << endl;
if(mesh.mlbetweennodes[mesh[sel2][ii]][0] > 0) if(mesh.mlbetweennodes[mesh[sel2][ii]][0].IsValid())
(*testout) << mesh[sel2][ii] << " between " (*testout) << mesh[sel2][ii] << " between "
<< mesh.mlbetweennodes[mesh[sel2][ii]][0] << " and " << mesh.mlbetweennodes[mesh[sel2][ii]][0] << " and "
<< mesh.mlbetweennodes[mesh[sel2][ii]][1] << endl; << mesh.mlbetweennodes[mesh[sel2][ii]][1] << endl;
@ -1887,7 +1884,7 @@ void MeshOptimize3d :: SwapImproveSurface (
} }
NgArray < int > outerpointsother; NgArray < PointIndex > outerpointsother;
if(nsuroundother > 0) if(nsuroundother > 0)
{ {
@ -1928,7 +1925,7 @@ void MeshOptimize3d :: SwapImproveSurface (
{ {
(*testout) << mesh[hasbothpoints[ii]] << endl; (*testout) << mesh[hasbothpoints[ii]] << endl;
for(int jj=0; jj<mesh[hasbothpoints[ii]].GetNP(); jj++) for(int jj=0; jj<mesh[hasbothpoints[ii]].GetNP(); jj++)
if(mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][0] > 0) if(mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][0].IsValid())
(*testout) << mesh[hasbothpoints[ii]][jj] << " between " (*testout) << mesh[hasbothpoints[ii]][jj] << " between "
<< mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][0] << " and " << mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][0] << " and "
<< mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][1] << endl; << mesh.mlbetweennodes[mesh[hasbothpoints[ii]][jj]][1] << endl;
@ -1938,11 +1935,11 @@ void MeshOptimize3d :: SwapImproveSurface (
<< "sel2 " << mesh[sel2] << endl; << "sel2 " << mesh[sel2] << endl;
for(int ii=0; ii<3; ii++) for(int ii=0; ii<3; ii++)
{ {
if(mesh.mlbetweennodes[mesh[sel1][ii]][0] > 0) if(mesh.mlbetweennodes[mesh[sel1][ii]][0].IsValid())
(*testout) << mesh[sel1][ii] << " between " (*testout) << mesh[sel1][ii] << " between "
<< mesh.mlbetweennodes[mesh[sel1][ii]][0] << " and " << mesh.mlbetweennodes[mesh[sel1][ii]][0] << " and "
<< mesh.mlbetweennodes[mesh[sel1][ii]][1] << endl; << mesh.mlbetweennodes[mesh[sel1][ii]][1] << endl;
if(mesh.mlbetweennodes[mesh[sel2][ii]][0] > 0) if(mesh.mlbetweennodes[mesh[sel2][ii]][0].IsValid())
(*testout) << mesh[sel2][ii] << " between " (*testout) << mesh[sel2][ii] << " between "
<< mesh.mlbetweennodes[mesh[sel2][ii]][0] << " and " << mesh.mlbetweennodes[mesh[sel2][ii]][0] << " and "
<< mesh.mlbetweennodes[mesh[sel2][ii]][1] << endl; << mesh.mlbetweennodes[mesh[sel2][ii]][1] << endl;
@ -1954,7 +1951,7 @@ void MeshOptimize3d :: SwapImproveSurface (
{ {
(*testout) << mesh[hasbothpointsother[ii]] << endl; (*testout) << mesh[hasbothpointsother[ii]] << endl;
for(int jj=0; jj<mesh[hasbothpointsother[ii]].GetNP(); jj++) for(int jj=0; jj<mesh[hasbothpointsother[ii]].GetNP(); jj++)
if(mesh.mlbetweennodes[mesh[hasbothpointsother[ii]][jj]][0] > 0) if(mesh.mlbetweennodes[mesh[hasbothpointsother[ii]][jj]][0].IsValid())
(*testout) << mesh[hasbothpointsother[ii]][jj] << " between " (*testout) << mesh[hasbothpointsother[ii]][jj] << " between "
<< mesh.mlbetweennodes[mesh[hasbothpointsother[ii]][jj]][0] << " and " << mesh.mlbetweennodes[mesh[hasbothpointsother[ii]][jj]][0] << " and "
<< mesh.mlbetweennodes[mesh[hasbothpointsother[ii]][jj]][1] << endl; << mesh.mlbetweennodes[mesh[hasbothpointsother[ii]][jj]][1] << endl;
@ -1964,11 +1961,11 @@ void MeshOptimize3d :: SwapImproveSurface (
<< "sel2other " << mesh[sel2other] << endl; << "sel2other " << mesh[sel2other] << endl;
for(int ii=0; ii<3; ii++) for(int ii=0; ii<3; ii++)
{ {
if(mesh.mlbetweennodes[mesh[sel1other][ii]][0] > 0) if(mesh.mlbetweennodes[mesh[sel1other][ii]][0].IsValid())
(*testout) << mesh[sel1other][ii] << " between " (*testout) << mesh[sel1other][ii] << " between "
<< mesh.mlbetweennodes[mesh[sel1other][ii]][0] << " and " << mesh.mlbetweennodes[mesh[sel1other][ii]][0] << " and "
<< mesh.mlbetweennodes[mesh[sel1other][ii]][1] << endl; << mesh.mlbetweennodes[mesh[sel1other][ii]][1] << endl;
if(mesh.mlbetweennodes[mesh[sel2other][ii]][0] > 0) if(mesh.mlbetweennodes[mesh[sel2other][ii]][0].IsValid())
(*testout) << mesh[sel2other][ii] << " between " (*testout) << mesh[sel2other][ii] << " between "
<< mesh.mlbetweennodes[mesh[sel2other][ii]][0] << " and " << mesh.mlbetweennodes[mesh[sel2other][ii]][0] << " and "
<< mesh.mlbetweennodes[mesh[sel2other][ii]][1] << endl; << mesh.mlbetweennodes[mesh[sel2other][ii]][1] << endl;

View File

@ -2867,7 +2867,7 @@ namespace netgen
tval i2 = faceht.Get(i3); tval i2 = faceht.Get(i3);
if (i2.index == el.GetIndex()) if (i2.index == el.GetIndex())
{ {
i2.index = PointIndex::BASE-1; i2.index = long(PointIndex::BASE)-1;
faceht.Set (i3, i2); faceht.Set (i3, i2);
} }
else else
@ -2911,7 +2911,7 @@ namespace netgen
faceht.GetData (i, i3, i2); faceht.GetData (i, i3, i2);
if (i2.index != PointIndex::BASE-1) if (i2.index != PointIndex::BASE-1)
{ {
Element2d tri ( (i2.p4 == PointIndex::BASE-1) ? TRIG : QUAD); Element2d tri ( (!i2.p4.IsValid()) ? TRIG : QUAD);
for (int l = 0; l < 3; l++) for (int l = 0; l < 3; l++)
tri[l] = i3.I(l+1); tri[l] = i3.I(l+1);
tri.PNum(4) = i2.p4; tri.PNum(4) = i2.p4;
@ -3323,7 +3323,7 @@ namespace netgen
*/ */
for (auto & el : VolumeElements()) for (auto & el : VolumeElements())
{ {
if (el[0] == -1 || el.IsDeleted()) continue; if (!el[0].IsValid() || el.IsDeleted()) continue;
int elmin = large; int elmin = large;
for (int j = 0; j < el.GetNP(); j++) for (int j = 0; j < el.GetNP(); j++)
@ -3346,7 +3346,7 @@ namespace netgen
*/ */
for (auto & el : VolumeElements()) for (auto & el : VolumeElements())
{ {
if (el[0] == -1 || el.IsDeleted()) continue; if (!el[0].IsValid() || el.IsDeleted()) continue;
int elmin = large; int elmin = large;
for (int j = 0; j < el.GetNP(); j++) for (int j = 0; j < el.GetNP(); j++)
@ -3363,8 +3363,8 @@ namespace netgen
PrintMessage (5, "free: ", cntfree, ", fixed: ", GetNE()-cntfree); PrintMessage (5, "free: ", cntfree, ", fixed: ", GetNE()-cntfree);
(*testout) << "free: " << cntfree << ", fixed: " << GetNE()-cntfree << endl; (*testout) << "free: " << cntfree << ", fixed: " << GetNE()-cntfree << endl;
for (PointIndex pi = PointIndex::BASE; for (PointIndex pi = IndexBASE<PointIndex>();
pi < GetNP()+PointIndex::BASE; pi++) pi < GetNP()+IndexBASE<PointIndex>(); pi++)
{ {
if (dist[pi] > layers+1) if (dist[pi] > layers+1)
points[pi].SetType(FIXEDPOINT); points[pi].SetType(FIXEDPOINT);
@ -3664,18 +3664,16 @@ namespace netgen
SetLocalH (pmin, pmax, grading, layer); SetLocalH (pmin, pmax, grading, layer);
} }
PointIndex i,j; // double hl;
double hl;
for (PointIndex i = IndexBASE<PointIndex>();
for (i = PointIndex::BASE; i < GetNP()+IndexBASE<PointIndex>(); i++)
i < GetNP()+PointIndex::BASE; i++)
{ {
for(j=i+1; j<GetNP()+PointIndex::BASE; j++) for(PointIndex j=i+1; j<GetNP()+IndexBASE<PointIndex>(); j++)
{ {
const Point3d & p1 = points[i]; const Point3d & p1 = points[i];
const Point3d & p2 = points[j]; const Point3d & p2 = points[j];
hl = Dist(p1,p2); double hl = Dist(p1,p2);
RestrictLocalH(p1,hl); RestrictLocalH(p1,hl);
RestrictLocalH(p2,hl); RestrictLocalH(p2,hl);
//cout << "restricted h at " << p1 << " and " << p2 << " to " << hl << endl; //cout << "restricted h at " << p1 << " and " << p2 << " to " << hl << endl;
@ -3718,7 +3716,7 @@ namespace netgen
continue; continue;
for (j = 1; j <= 3; j++) for (j = 1; j <= 3; j++)
{ {
INDEX_2 i2(sel.PNumMod(j), sel.PNumMod(j+1)); PointIndices<2> i2(sel.PNumMod(j), sel.PNumMod(j+1));
i2.Sort(); i2.Sort();
if (bedges.Used(i2)) continue; if (bedges.Used(i2)) continue;
@ -3728,22 +3726,22 @@ namespace netgen
const Element2d & elother = SurfaceElement(other); const Element2d & elother = SurfaceElement(other);
int pi3 = 1; int pi3_ = 1;
while ( (sel.PNum(pi3) == i2.I1()) || while ( (sel.PNum(pi3_) == i2[0]) ||
(sel.PNum(pi3) == i2.I2())) (sel.PNum(pi3_) == i2[1]))
pi3++; pi3_++;
pi3 = sel.PNum(pi3); PointIndex pi3 = sel.PNum(pi3_);
int pi4 = 1; int pi4_ = 1;
while ( (elother.PNum(pi4) == i2.I1()) || while ( (elother.PNum(pi4_) == i2[0]) ||
(elother.PNum(pi4) == i2.I2())) (elother.PNum(pi4_) == i2[1]))
pi4++; pi4_++;
pi4 = elother.PNum(pi4); PointIndex pi4 = elother.PNum(pi4_);
double rad = ComputeCylinderRadius (Point (PointIndex(i2.I1())), double rad = ComputeCylinderRadius (Point (i2[0]),
Point (PointIndex(i2.I2())), Point (i2[1]),
Point (PointIndex(pi3)), Point (pi3),
Point (PointIndex(pi4))); Point (pi4));
RestrictLocalHLine (Point(PointIndex(i2.I1())), Point(PointIndex(i2.I2())), rad/elperr); RestrictLocalHLine (Point(PointIndex(i2.I1())), Point(PointIndex(i2.I2())), rad/elperr);
@ -6634,8 +6632,8 @@ namespace netgen
SurfaceElementIndex si = facedecoding[facenr-1].firstelement; SurfaceElementIndex si = facedecoding[facenr-1].firstelement;
while (si != -1) while (si != -1)
{ {
if ( (*this)[si].GetIndex () == facenr && (*this)[si][0] >= PointIndex::BASE && if ( (*this)[si].GetIndex () == facenr && (*this)[si][0].IsValid() &&
!(*this)[si].IsDeleted() ) !(*this)[si].IsDeleted() )
{ {
sei.Append (si); sei.Append (si);
} }

View File

@ -541,8 +541,8 @@ namespace netgen
// problem recognition ! // problem recognition !
if (found && if (found &&
(gpi1 < illegalpoint.Size()+PointIndex::BASE) && (gpi1 < illegalpoint.Size()+IndexBASE<PointIndex>()) &&
(gpi2 < illegalpoint.Size()+PointIndex::BASE) ) (gpi2 < illegalpoint.Size()+IndexBASE<PointIndex>()) )
{ {
if (illegalpoint[gpi1] || illegalpoint[gpi2]) if (illegalpoint[gpi1] || illegalpoint[gpi2])
found = 0; found = 0;

View File

@ -235,7 +235,7 @@ namespace netgen
friend bool operator!= (PointIndex a, PointIndex b); friend bool operator!= (PointIndex a, PointIndex b);
*/ */
public: public:
constexpr PointIndex (t_invalid inv) : i(PointIndex::BASE-1) { ; } constexpr PointIndex (t_invalid inv) : i(long(PointIndex::BASE)-1) { ; }
// PointIndex & operator= (const PointIndex &ai) { i = ai.i; return *this; } // PointIndex & operator= (const PointIndex &ai) { i = ai.i; return *this; }
// private: // private:
constexpr operator const int& () const { return i; } constexpr operator const int& () const { return i; }
@ -246,8 +246,8 @@ namespace netgen
PointIndex & operator++ () { i++; return *this; } PointIndex & operator++ () { i++; return *this; }
PointIndex operator-- () { i--; return *this; } PointIndex operator-- () { i--; return *this; }
PointIndex operator+= (int add) { i += add; return *this; } PointIndex operator+= (int add) { i += add; return *this; }
void Invalidate() { i = PointIndex::BASE-1; } void Invalidate() { i = long(PointIndex::BASE)-1; }
bool IsValid() const { return i != PointIndex::BASE-1; } bool IsValid() const { return i+1 != PointIndex::BASE; }
// operator bool() const { return IsValid(); } // operator bool() const { return IsValid(); }
#ifdef BASE0 #ifdef BASE0
static constexpr size_t BASE = 0; static constexpr size_t BASE = 0;
@ -816,7 +816,7 @@ namespace netgen
void Delete () void Delete ()
{ {
deleted = 1; deleted = true;
// for (PointIndex & p : pnum) p.Invalidate(); // for (PointIndex & p : pnum) p.Invalidate();
} }

View File

@ -438,7 +438,8 @@ namespace netgen
local vertex numbers on distant procs local vertex numbers on distant procs
(I think this was only used for debugging??) (I think this was only used for debugging??)
**/ **/
for (int vert = 1; vert <= GetNP(); vert++ ) // for (int vert = 1; vert <= GetNP(); vert++ )
for (PointIndex vert : Points().Range())
{ {
NgFlatArray<int> procs = procs_of_vert[vert]; NgFlatArray<int> procs = procs_of_vert[vert];
for (int j = 0; j < procs.Size(); j++) for (int j = 0; j < procs.Size(); j++)
@ -1017,7 +1018,7 @@ namespace netgen
for (int vert = 0; vert < numvert; vert++) for (int vert = 0; vert < numvert; vert++)
{ {
int globvert = verts[vert] + IndexBASE<T_POINTS::index_type>(); PointIndex globvert = verts[vert] + IndexBASE<T_POINTS::index_type>();
// paralleltop->SetLoc2Glob_Vert ( vert+1, globvert ); // paralleltop->SetLoc2Glob_Vert ( vert+1, globvert );
paralleltop->L2G (PointIndex(vert+PointIndex::BASE)) = globvert; paralleltop->L2G (PointIndex(vert+PointIndex::BASE)) = globvert;
glob2loc_vert_ht.Set (globvert, vert+1); glob2loc_vert_ht.Set (globvert, vert+1);

View File

@ -93,7 +93,7 @@ namespace netgen
comm.AllGather (num_master_points, first_master_point); comm.AllGather (num_master_points, first_master_point);
auto max_oldv = comm.AllReduce (Max (glob_vert.Range(0, oldnv)), NG_MPI_MAX); auto max_oldv = comm.AllReduce (Max (glob_vert.Range(0, oldnv)), NG_MPI_MAX);
if (comm.AllReduce (oldnv, NG_MPI_SUM) == 0) if (comm.AllReduce (oldnv, NG_MPI_SUM) == 0)
max_oldv = PointIndex::BASE-1; max_oldv = long(PointIndex::BASE)-1;
size_t num_glob_points = max_oldv+1; size_t num_glob_points = max_oldv+1;
for (int i = 0; i < comm.Size(); i++) for (int i = 0; i < comm.Size(); i++)

View File

@ -1561,7 +1561,7 @@ py::arg("point_tolerance") = -1.)
{ {
const auto & seg = segs[i]; const auto & seg = segs[i];
for(auto k : Range(2)) for(auto k : Range(2))
output[2*i+k] = seg[k]-PointIndex::BASE; output[2*i+k] = seg[k]-IndexBASE<PointIndex>();
} }); } });
return output; return output;
}) })
@ -1580,8 +1580,8 @@ py::arg("point_tolerance") = -1.)
// PointIndex p0,p1; // PointIndex p0,p1;
// topo.GetEdgeVertices(i+1, p0, p1); // topo.GetEdgeVertices(i+1, p0, p1);
auto [p0,p1] = topo.GetEdgeVertices(i); auto [p0,p1] = topo.GetEdgeVertices(i);
output[2*i] = p0-PointIndex::BASE; output[2*i] = p0-IndexBASE<PointIndex>();
output[2*i+1] = p1-PointIndex::BASE; output[2*i+1] = p1-IndexBASE<PointIndex>();
} }); } });
return output; return output;
}) })
@ -1599,7 +1599,7 @@ py::arg("point_tolerance") = -1.)
const auto & sel = surfels[i]; const auto & sel = surfels[i];
auto * trig = &trigs[3*i]; auto * trig = &trigs[3*i];
for(auto k : Range(3)) for(auto k : Range(3))
trig[k] = sel[k]-PointIndex::BASE; trig[k] = sel[k]-IndexBASE<PointIndex>();
// todo: quads (store the second trig in thread-local extra array, merge them at the end (mutex) // todo: quads (store the second trig in thread-local extra array, merge them at the end (mutex)
} }); } });
return trigs; return trigs;
@ -1617,7 +1617,7 @@ py::arg("point_tolerance") = -1.)
const auto & el = els[i]; const auto & el = els[i];
auto * trig = &tets[4*i]; auto * trig = &tets[4*i];
for(auto k : Range(4)) for(auto k : Range(4))
trig[k] = el[k]-PointIndex::BASE; trig[k] = el[k]-IndexBASE<PointIndex>();
// todo: prisms etc (store the extra tets in thread-local extra array, merge them at the end (mutex) // todo: prisms etc (store the extra tets in thread-local extra array, merge them at the end (mutex)
} }); } });
return tets; return tets;

View File

@ -189,8 +189,8 @@ namespace netgen
mesh.Point(pinew) = pnew; mesh.Point(pinew) = pnew;
// between.Set (i2, pinew); // between.Set (i2, pinew);
if (pinew >= epgi.Size()+PointIndex::BASE) if (pinew >= epgi.Size()+IndexBASE<PointIndex>())
epgi.SetSize (pinew+1-PointIndex::BASE); epgi.SetSize (pinew+1-IndexBASE<PointIndex>());
epgi[pinew] = ngi; epgi[pinew] = ngi;
} }
@ -208,7 +208,7 @@ namespace netgen
PrintMessage (5, "have 1d elements"); PrintMessage (5, "have 1d elements");
// refine surface elements // refine surface elements
NgArray<PointGeomInfo,PointIndex::BASE> surfgi (8*mesh.GetNP()); Array<PointGeomInfo,PointIndex> surfgi (8*mesh.GetNP());
for (int i = PointIndex::BASE; for (int i = PointIndex::BASE;
i < surfgi.Size()+PointIndex::BASE; i++) i < surfgi.Size()+PointIndex::BASE; i++)
surfgi[i].trignum = -1; surfgi[i].trignum = -1;
@ -273,9 +273,9 @@ namespace netgen
between.Set (i2, pnums.Get(4+j)); between.Set (i2, pnums.Get(4+j));
} }
*/ */
if (surfgi.Size() < pnums.Elem(4+j)) if (surfgi.Size() < pnums.Elem(4+j)-IndexBASE<PointIndex>()+1)
surfgi.SetSize (pnums.Elem(4+j)); surfgi.SetSize (pnums.Elem(4+j)-IndexBASE<PointIndex>()+1);
surfgi.Elem(pnums.Elem(4+j)) = pgis.Elem(4+j); surfgi[pnums.Elem(4+j)] = pgis.Elem(4+j);
} }
@ -356,9 +356,9 @@ namespace netgen
mesh.Point(pinew) = pb; mesh.Point(pinew) = pb;
} }
if (surfgi.Size() < pnums[4+j]) if (surfgi.Size() < pnums[4+j]-IndexBASE<PointIndex>()+1)
surfgi.SetSize (pnums[4+j]); surfgi.SetSize (pnums[4+j]-IndexBASE<PointIndex>()+1);
surfgi.Elem(pnums[4+j]) = pgis[4+j]; surfgi[pnums[4+j]] = pgis[4+j];
} }
static int reftab[4][4] = static int reftab[4][4] =

View File

@ -1736,7 +1736,7 @@ void Mesh :: ImproveMeshJacobianOnSurface (const MeshingParameters & mp,
{ {
for(int j=0; brother == -1 && j<used_idmaps->Size(); j++) for(int j=0; brother == -1 && j<used_idmaps->Size(); j++)
{ {
if(pi < (*used_idmaps)[j]->Size() + PointIndex::BASE) if(pi < (*used_idmaps)[j]->Size() + IndexBASE<PointIndex>())
{ {
brother = (*(*used_idmaps)[j])[pi]; brother = (*(*used_idmaps)[j])[pi];
if(brother == pi || brother == 0) if(brother == pi || brother == 0)

View File

@ -969,7 +969,7 @@ namespace netgen
{ {
PointIndex v0 = pa[k]; // also in face PointIndex v0 = pa[k]; // also in face
PointIndex v1 = pa[1-k]; PointIndex v1 = pa[1-k];
PointIndex v2 = f3[0]+f3[1]+f3[2] - v - v0; PointIndex v2 = f3[0]-v+f3[1]-v0+f3[2];
// if there is an edge connecting v1 and v2, accept // if there is an edge connecting v1 and v2, accept
// the new face // the new face
IVec<2> parentedge(v1, v2); IVec<2> parentedge(v1, v2);
@ -1000,7 +1000,7 @@ namespace netgen
{ {
PointIndex v0 = pa[k]; // also in face PointIndex v0 = pa[k]; // also in face
PointIndex v1 = pa[1-k]; PointIndex v1 = pa[1-k];
PointIndex v2 = f3[0]+f3[1]+f3[2] - v - v0; PointIndex v2 = f3[0]-v+f3[1]-v0+f3[2];
// if there is an edge connecting v1 and v2, accept // if there is an edge connecting v1 and v2, accept
// the new face // the new face
IVec<2> parentedge(v1, v2); IVec<2> parentedge(v1, v2);
@ -1428,7 +1428,7 @@ namespace netgen
PointIndex v1 = parents[1-j]; PointIndex v1 = parents[1-j];
// the third one, on the tip // the third one, on the tip
PointIndex v2 = f3[0]+f3[1]+f3[2] - v0 - vb; PointIndex v2 = f3[0]-v0+f3[1]-vb+f3[2];
// if there is an edge connecting v1 and v2, accept // if there is an edge connecting v1 and v2, accept
// the new face // the new face

View File

@ -209,7 +209,7 @@ namespace netgen
if(!isedgepoint.Test(sel.PNum(j))) if(!isedgepoint.Test(sel.PNum(j)))
{ {
isboundarypoint.SetBit(sel.PNum(j)); isboundarypoint.SetBit(sel.PNum(j));
surfaceindex[sel.PNum(j) - PointIndex::BASE] = surfaceindex[sel.PNum(j) - IndexBASE<PointIndex>()] =
mesh.GetFaceDescriptor(sel.GetIndex()).SurfNr(); mesh.GetFaceDescriptor(sel.GetIndex()).SurfNr();
} }
@ -259,8 +259,8 @@ namespace netgen
if(isnewpoint.Test(i+PointIndex::BASE) && if(isnewpoint.Test(i+PointIndex::BASE) &&
//working_points.Test(i+PointIndex::BASE) && //working_points.Test(i+PointIndex::BASE) &&
mesh.mlbetweennodes[i+PointIndex::BASE][0] > 0) mesh.mlbetweennodes[i+PointIndex::BASE][0] > 0)
*can[i] = Center(*can[mesh.mlbetweennodes[i+PointIndex::BASE][0]-PointIndex::BASE], *can[i] = Center(*can[mesh.mlbetweennodes[i+PointIndex::BASE][0]-IndexBASE<PointIndex>()],
*can[mesh.mlbetweennodes[i+PointIndex::BASE][1]-PointIndex::BASE]); *can[mesh.mlbetweennodes[i+PointIndex::BASE][1]-IndexBASE<PointIndex>()]);
else else
*can[i] = mesh.Point(i+1); *can[i] = mesh.Point(i+1);
} }
@ -320,7 +320,7 @@ namespace netgen
auxvec.Normalize(); auxvec.Normalize();
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)))
*nv[sel.PNum(j) - PointIndex::BASE] += auxvec; *nv[sel.PNum(j) - IndexBASE<PointIndex>()] += auxvec;
} }
for(int i=0; i<nv.Size(); i++) for(int i=0; i<nv.Size(); i++)
nv[i]->Normalize(); nv[i]->Normalize();