preparations to switch T_POINTS to ngcore::Array

This commit is contained in:
Joachim Schöberl 2019-08-09 15:30:58 +02:00
parent c900e0380b
commit 9118ddc63a
17 changed files with 143 additions and 73 deletions

View File

@ -201,16 +201,21 @@ namespace ngcore
NETGEN_INLINE operator T* () const { return data; } NETGEN_INLINE operator T* () const { return data; }
}; };
template <class T> class FlatArray;
template <typename T>
constexpr size_t IndexBASE () { return 0; }
template <typename TELEM, typename TSIZE> template <class T, class IndexType = size_t> class FlatArray;
template <typename TELEM, typename IndexType>
class ArrayIterator class ArrayIterator
{ {
FlatArray<TELEM> ar; FlatArray<TELEM, IndexType> ar;
TSIZE ind; IndexType ind;
public: public:
NETGEN_INLINE ArrayIterator (FlatArray<TELEM> aar, TSIZE ai) NETGEN_INLINE ArrayIterator (FlatArray<TELEM, IndexType> aar, IndexType ai)
: ar(aar), ind(ai) { ; } : ar(aar), ind(ai) { ; }
NETGEN_INLINE ArrayIterator operator++ (int) NETGEN_INLINE ArrayIterator operator++ (int)
{ return ArrayIterator(ar, ind++); } { return ArrayIterator(ar, ind++); }
@ -381,23 +386,24 @@ namespace ngcore
Helper functions for printing. Helper functions for printing.
Optional range check by macro NETGEN_CHECK_RANGE Optional range check by macro NETGEN_CHECK_RANGE
*/ */
template <class T> template <class T, class IndexType>
class FlatArray : public BaseArrayObject<FlatArray<T> > class FlatArray : public BaseArrayObject<FlatArray<T,IndexType> >
{ {
protected: protected:
static constexpr size_t BASE = IndexBASE<IndexType>();
/// the size /// the size
size_t size; size_t size;
/// the data /// the data
T * __restrict data; T * __restrict data;
public: public:
using BaseArrayObject<FlatArray<T> >::ILLEGAL_POSITION; using BaseArrayObject<FlatArray>::ILLEGAL_POSITION;
/// initialize array /// initialize array
NETGEN_INLINE FlatArray () = default; NETGEN_INLINE FlatArray () = default;
// { ; } // size = 0; data = 0; } // { ; } // size = 0; data = 0; }
/// copy constructor allows size-type conversion /// copy constructor allows size-type conversion
NETGEN_INLINE FlatArray (const FlatArray<T> & a2) = default; NETGEN_INLINE FlatArray (const FlatArray & a2) = default;
// : size(a2.Size()), data(a2.data) { ; } // : size(a2.Size()), data(a2.data) { ; }
/// provide size and memory /// provide size and memory
@ -473,10 +479,10 @@ namespace ngcore
} }
/// Access array. range check by macro NETGEN_CHECK_RANGE /// Access array. range check by macro NETGEN_CHECK_RANGE
NETGEN_INLINE T & operator[] (size_t i) const NETGEN_INLINE T & operator[] (IndexType i) const
{ {
NETGEN_CHECK_RANGE(i,0,size); NETGEN_CHECK_RANGE(i,0,size);
return data[i]; return data[i-BASE];
} }
NETGEN_INLINE T_Range<size_t> Range () const NETGEN_INLINE T_Range<size_t> Range () const
@ -552,10 +558,8 @@ namespace ngcore
return Pos(elem) != ILLEGAL_POSITION; return Pos(elem) != ILLEGAL_POSITION;
} }
ArrayIterator<T, size_t> begin() const auto begin() const { return ArrayIterator<T,IndexType> (*this, BASE); }
{ return ArrayIterator<T,size_t> (*this, 0); } auto end() const { return ArrayIterator<T,IndexType> (*this, size+BASE); }
ArrayIterator<T, size_t> end() const
{ return ArrayIterator<T,size_t> (*this, size); }
}; };
template <typename T> template <typename T>
@ -591,8 +595,8 @@ namespace ngcore
Either the container takes care of memory allocation and deallocation, Either the container takes care of memory allocation and deallocation,
or the user provides one block of data. or the user provides one block of data.
*/ */
template <class T> template <class T, class IndexType = size_t>
class Array : public FlatArray<T> class Array : public FlatArray<T, IndexType>
{ {
protected: protected:
/// physical size of array /// physical size of array
@ -600,20 +604,20 @@ namespace ngcore
/// that's the data we have to delete, nullptr for not owning the memory /// that's the data we have to delete, nullptr for not owning the memory
T * mem_to_delete; T * mem_to_delete;
using FlatArray<T>::size; using FlatArray<T,IndexType>::size;
using FlatArray<T>::data; using FlatArray<T,IndexType>::data;
public: public:
/// Generate array of logical and physical size asize /// Generate array of logical and physical size asize
NETGEN_INLINE explicit Array() NETGEN_INLINE explicit Array()
: FlatArray<T> (0, nullptr) : FlatArray<T,IndexType> (0, nullptr)
{ {
allocsize = 0; allocsize = 0;
mem_to_delete = nullptr; mem_to_delete = nullptr;
} }
NETGEN_INLINE explicit Array(size_t asize) NETGEN_INLINE explicit Array(size_t asize)
: FlatArray<T> (asize, new T[asize]) : FlatArray<T,IndexType> (asize, new T[asize])
{ {
allocsize = asize; allocsize = asize;
mem_to_delete = data; mem_to_delete = data;
@ -654,18 +658,18 @@ namespace ngcore
/// array copy /// array copy
NETGEN_INLINE explicit Array (const Array & a2) NETGEN_INLINE explicit Array (const Array & a2)
: FlatArray<T> (a2.Size(), a2.Size() ? new T[a2.Size()] : nullptr) : FlatArray<T,IndexType> (a2.Size(), a2.Size() ? new T[a2.Size()] : nullptr)
{ {
allocsize = size; allocsize = size;
mem_to_delete = data; mem_to_delete = data;
for (size_t i = 0; i < size; i++) for (size_t i = 0; i < size; i++)
data[i] = a2[i]; data[i] = a2.data[i];
} }
template <typename TA> template <typename TA>
explicit Array (const BaseArrayObject<TA> & a2) explicit Array (const BaseArrayObject<TA> & a2)
: FlatArray<T> (a2.Size(), : FlatArray<T,IndexType> (a2.Size(),
a2.Size() ? new T[a2.Size()] : nullptr) a2.Size() ? new T[a2.Size()] : nullptr)
{ {
allocsize = size; allocsize = size;
@ -976,8 +980,8 @@ namespace ngcore
/// resize array, at least to size minsize. copy contents /// resize array, at least to size minsize. copy contents
template <class T> template <class T, class IndexType>
NETGEN_INLINE void Array<T> :: ReSize (size_t minsize) NETGEN_INLINE void Array<T, IndexType> :: ReSize (size_t minsize)
{ {
size_t nsize = 2 * allocsize; size_t nsize = 2 * allocsize;
if (nsize < minsize) nsize = minsize; if (nsize < minsize) nsize = minsize;

View File

@ -96,10 +96,15 @@ namespace netgen
ArrayIterator<T,BASE,TIND> end() const ArrayIterator<T,BASE,TIND> end() const
{ return ArrayIterator<T,BASE,TIND> (*this, BASE+size); } { return ArrayIterator<T,BASE,TIND> (*this, BASE+size); }
TIND Begin() const { return TIND(BASE); } // TIND Begin() const { return TIND(BASE); }
TIND End() const { return TIND(size+BASE); } // TIND End() const { return TIND(size+BASE); }
T_Range<TIND> Range() const { return T_Range<TIND>(BASE, size+BASE); } T_Range<TIND> Range() const { return T_Range<TIND>(BASE, size+BASE); }
[[deprecated("Use *Range().begin() instead")]]
auto Begin() const { return *Range().begin(); }
[[deprecated("Use *Range().end() instead")]]
auto End() const { return *Range().end(); }
/// Access array. BASE-based /// Access array. BASE-based
T & operator[] (TIND i) const T & operator[] (TIND i) const
{ {
@ -205,13 +210,13 @@ namespace netgen
template <typename T, int BASE, typename TIND> template <typename T, int BASE, typename TIND>
inline ostream & operator<< (ostream & s, const NgFlatArray<T,BASE,TIND> & a) inline ostream & operator<< (ostream & s, const NgFlatArray<T,BASE,TIND> & a)
{ {
for (TIND i = a.Begin(); i < a.End(); i++) // for (TIND i = a.Begin(); i < a.End(); i++)
for (auto i : a.Range())
s << i << ": " << a[i] << endl; s << i << ": " << a[i] << endl;
return s; return s;
} }
/** /**
Dynamic array container. Dynamic array container.
@ -530,6 +535,9 @@ namespace netgen
int End() const { return ia.End(); } int End() const { return ia.End(); }
const typename TA1::TELEM & operator[] (int i) const { return array[ia[i]]; } const typename TA1::TELEM & operator[] (int i) const { return array[ia[i]]; }
auto Range() const { return ia.Range(); }
auto begin() const { return ia.begin(); }
auto end() const { return ia.end(); }
}; };

View File

@ -38,7 +38,8 @@ template <class T>
inline void BubbleSort (NgArray<T> & data) inline void BubbleSort (NgArray<T> & data)
{ {
if(data.Size() > 0) if(data.Size() > 0)
BubbleSort (data.Size(), &data[data.Begin()]); // BubbleSort (data.Size(), &data[data.Begin()]);
BubbleSort (data.Size(), &data[*data.Range().begin()]);
} }
} }

View File

@ -286,7 +286,8 @@ namespace netgen
template <typename T1, typename T2> template <typename T1, typename T2>
void Add (const IndirectArray<T1, T2> & points) void Add (const IndirectArray<T1, T2> & points)
{ {
for (int i = points.Begin(); i < points.End(); i++) // for (int i = points.Begin(); i < points.End(); i++)
for (int i : points.Range())
Add (points[i]); Add (points[i]);
} }

View File

@ -494,7 +494,8 @@ 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())
{ {
if(nodenum[i] == -1) if(nodenum[i] == -1)
continue; continue;
@ -1063,7 +1064,8 @@ namespace netgen
for(int i=0; i<groups.Size(); i++) for(int i=0; i<groups.Size(); i++)
groups[i]->SetSize(0); groups[i]->SetSize(0);
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())
{ {
if(i-PointIndex::BASE < point_ids.Size()) if(i-PointIndex::BASE < point_ids.Size())
{ {

View File

@ -39,7 +39,8 @@ namespace netgen
allflines = 0; allflines = 0;
minval = 0; minval = 0;
starti = lines.Begin(); // starti = lines.Begin();
starti = *lines.Range().begin();
} }
AdFront2 :: ~AdFront2 () AdFront2 :: ~AdFront2 ()
@ -53,7 +54,8 @@ namespace netgen
if (nfl > 0) if (nfl > 0)
{ {
ost << nfl << " open front segments left:" << endl; ost << nfl << " open front segments left:" << endl;
for (int i = lines.Begin(); i < lines.End(); i++) // for (int i = lines.Begin(); i < lines.End(); i++)
for (int i : lines.Range())
if (lines[i].Valid()) if (lines[i].Valid())
ost << i << ": " ost << i << ": "
<< GetGlobalIndex (lines[i].L().I1()) << "-" << GetGlobalIndex (lines[i].L().I1()) << "-"
@ -220,7 +222,8 @@ namespace netgen
{ {
int baselineindex = -1; int baselineindex = -1;
for (int i = starti; i < lines.End(); i++) // for (int i = starti; i < lines.End(); i++)
for (int i = starti; i < *lines.Range().end(); i++)
{ {
if (lines[i].Valid()) if (lines[i].Valid())
{ {
@ -240,7 +243,8 @@ namespace netgen
if (baselineindex == -1) if (baselineindex == -1)
{ {
minval = INT_MAX; minval = INT_MAX;
for (int i = lines.Begin(); i < lines.End(); i++) // for (int i = lines.Begin(); i < lines.End(); i++)
for (int i : lines.Range())
if (lines[i].Valid()) if (lines[i].Valid())
{ {
int hi = lines[i].LineClass() + int hi = lines[i].LineClass() +
@ -432,7 +436,8 @@ namespace netgen
void AdFront2 :: SetStartFront () void AdFront2 :: SetStartFront ()
{ {
for (int i = lines.Begin(); i < lines.End(); i++) // for (int i = lines.Begin(); i < lines.End(); i++)
for (int i : lines.Range())
if (lines[i].Valid()) if (lines[i].Valid())
for (int j = 1; j <= 2; j++) for (int j = 1; j <= 2; j++)
points[lines[i].L().I(j)].DecFrontNr(0); points[lines[i].L().I(j)].DecFrontNr(0);
@ -442,12 +447,14 @@ namespace netgen
void AdFront2 :: Print (ostream & ost) const void AdFront2 :: Print (ostream & ost) const
{ {
ost << points.Size() << " Points: " << endl; ost << points.Size() << " Points: " << endl;
for (int i = points.Begin(); i < points.End(); i++) // for (int i = points.Begin(); i < points.End(); i++)
for (int i : points.Range())
if (points[i].Valid()) if (points[i].Valid())
ost << i << " " << points[i].P() << endl; ost << i << " " << points[i].P() << endl;
ost << nfl << " Lines: " << endl; ost << nfl << " Lines: " << endl;
for (int i = lines.Begin(); i < lines.End(); i++) // for (int i = lines.Begin(); i < lines.End(); i++)
for (int i : lines.Range())
if (lines[i].Valid()) if (lines[i].Valid())
ost << lines[i].L().I1() << " - " << lines[i].L().I2() << endl; ost << lines[i].L().I1() << " - " << lines[i].L().I2() << endl;

View File

@ -86,9 +86,13 @@ AdFront3 :: ~AdFront3 ()
void AdFront3 :: GetPoints (NgArray<Point<3> > & apoints) const void AdFront3 :: GetPoints (NgArray<Point<3> > & apoints) const
{ {
/*
for (PointIndex pi = points.Begin(); pi < points.End(); pi++) for (PointIndex pi = points.Begin(); pi < points.End(); pi++)
apoints.Append (points[pi].P()); apoints.Append (points[pi].P());
*/
for (auto & p : points)
apoints.Append(p.P());
} }
@ -105,7 +109,8 @@ PointIndex AdFront3 :: AddPoint (const Point<3> & p, PointIndex globind)
else else
{ {
points.Append (FrontPoint3 (p, globind)); points.Append (FrontPoint3 (p, globind));
return --points.End(); // return --points.End();
return *points.Range().end()-1;
// return points.Size()-1+PointIndex::BASE; // return points.Size()-1+PointIndex::BASE;
} }
} }
@ -302,7 +307,8 @@ void AdFront3 :: RebuildInternalTables ()
int np = points.Size(); int np = points.Size();
for (PointIndex pi = points.Begin(); pi < points.End(); pi++) // for (PointIndex pi = points.Begin(); pi < points.End(); pi++)
for (PointIndex pi : points.Range())
points[pi].cluster = pi; points[pi].cluster = pi;
NgProfiler::StopTimer (timer_a); NgProfiler::StopTimer (timer_a);
@ -400,7 +406,8 @@ void AdFront3 :: RebuildInternalTables ()
{ {
for (int i = 1; i <= faces.Size(); i++) for (int i = 1; i <= faces.Size(); i++)
faces.Elem(i).cluster = 1; faces.Elem(i).cluster = 1;
for (PointIndex pi = points.Begin(); pi < points.End(); pi++) // for (PointIndex pi = points.Begin(); pi < points.End(); pi++)
for (PointIndex pi : points.Range())
points[pi].cluster = 1; points[pi].cluster = 1;
} }

View File

@ -572,7 +572,8 @@ namespace netgen
// Lock all the prism points so that the rest of the mesh can be // Lock all the prism points so that the rest of the mesh can be
// optimised without invalidating the entire mesh // optimised without invalidating the entire mesh
for (PointIndex pi = mesh.Points().Begin(); pi < mesh.Points().End(); pi++) // for (PointIndex pi = mesh.Points().Begin(); pi < mesh.Points().End(); pi++)
for (PointIndex pi : mesh.Points().Range())
{ {
if(bndnodes.Test(pi)) mesh.AddLockedPoint(pi); if(bndnodes.Test(pi)) mesh.AddLockedPoint(pi);
} }

View File

@ -188,7 +188,8 @@ namespace netgen
timestamp = NextTimeStamp(); timestamp = NextTimeStamp();
PointIndex pi = points.End(); // PointIndex pi = points.End();
PointIndex pi = *points.Range().end();
points.Append ( MeshPoint (p, layer, type) ); points.Append ( MeshPoint (p, layer, type) );
lock.UnLock(); lock.UnLock();
@ -259,7 +260,8 @@ namespace netgen
points[el[i]].SetType(SURFACEPOINT); points[el[i]].SetType(SURFACEPOINT);
} }
*/ */
if (maxn < points.End()) // if (maxn < points.End())
if (maxn < *points.Range().end())
for (PointIndex pi : el.PNums()) for (PointIndex pi : el.PNums())
if (points[pi].Type() > SURFACEPOINT) if (points[pi].Type() > SURFACEPOINT)
points[pi].SetType(SURFACEPOINT); points[pi].SetType(SURFACEPOINT);
@ -719,7 +721,8 @@ namespace netgen
if (cnt_sing) if (cnt_sing)
{ {
outfile << "singular_points" << endl << cnt_sing << endl; outfile << "singular_points" << endl << cnt_sing << endl;
for (PointIndex pi = points.Begin(); pi < points.End(); pi++) // for (PointIndex pi = points.Begin(); pi < points.End(); pi++)
for (PointIndex pi : points.Range())
if ((*this)[pi].Singularity()>=1.) if ((*this)[pi].Singularity()>=1.)
outfile << int(pi) << "\t" << (*this)[pi].Singularity() << endl; outfile << int(pi) << "\t" << (*this)[pi].Singularity() << endl;
} }
@ -1969,7 +1972,8 @@ namespace netgen
INDEX_3_CLOSED_HASHTABLE<tval> faceht(100); INDEX_3_CLOSED_HASHTABLE<tval> faceht(100);
openelements.SetSize(0); openelements.SetSize(0);
for (PointIndex pi = points.Begin(); pi < points.End(); pi++) // for (PointIndex pi = points.Begin(); pi < points.End(); pi++)
for (PointIndex pi : points.Range())
if (selsonpoint[pi].Size()+elsonpoint[pi].Size()) if (selsonpoint[pi].Size()+elsonpoint[pi].Size())
{ {
faceht.SetSize (2 * selsonpoint[pi].Size() + 4 * elsonpoint[pi].Size()); faceht.SetSize (2 * selsonpoint[pi].Size() + 4 * elsonpoint[pi].Size());
@ -2149,7 +2153,8 @@ namespace netgen
for (int j = 1; j <= 3; j++) for (int j = 1; j <= 3; j++)
{ {
PointIndex pi = sel.PNum(j); PointIndex pi = sel.PNum(j);
if (pi < points.End()) // if (pi < points.End())
if (pi < *points.Range().end())
points[pi].SetType (FIXEDPOINT); points[pi].SetType (FIXEDPOINT);
} }
} }
@ -3159,7 +3164,8 @@ namespace netgen
pmin = Point3d (1e10, 1e10, 1e10); pmin = Point3d (1e10, 1e10, 1e10);
pmax = Point3d (-1e10, -1e10, -1e10); pmax = Point3d (-1e10, -1e10, -1e10);
for (PointIndex pi = points.Begin(); pi < points.End(); pi++) // for (PointIndex pi = points.Begin(); pi < points.End(); pi++)
for (PointIndex pi : points.Range())
{ {
pmin.SetToMin ( (*this) [pi] ); pmin.SetToMin ( (*this) [pi] );
pmax.SetToMax ( (*this) [pi] ); pmax.SetToMax ( (*this) [pi] );
@ -3208,7 +3214,8 @@ namespace netgen
pmin = Point3d (1e10, 1e10, 1e10); pmin = Point3d (1e10, 1e10, 1e10);
pmax = Point3d (-1e10, -1e10, -1e10); pmax = Point3d (-1e10, -1e10, -1e10);
for (PointIndex pi = points.Begin(); pi < points.End(); pi++) // for (PointIndex pi = points.Begin(); pi < points.End(); pi++)
for (PointIndex pi : points.Range())
if (points[pi].Type() <= ptyp) if (points[pi].Type() <= ptyp)
{ {
pmin.SetToMin ( (*this) [pi] ); pmin.SetToMin ( (*this) [pi] );
@ -3334,7 +3341,8 @@ namespace netgen
int npi = PointIndex::BASE-1; int npi = PointIndex::BASE-1;
for (PointIndex pi = points.Begin(); pi < points.End(); pi++) // for (PointIndex pi = points.Begin(); pi < points.End(); pi++)
for (PointIndex pi : points.Range())
if (pused.Test(pi)) if (pused.Test(pi))
{ {
npi++; npi++;

View File

@ -227,10 +227,18 @@ namespace netgen
auto GetNP () const { return points.Size(); } auto GetNP () const { return points.Size(); }
// [[deprecated("Use Point(PointIndex) instead of int !")]] // [[deprecated("Use Point(PointIndex) instead of int !")]]
MeshPoint & Point(int i) { return points.Elem(i); } MeshPoint & Point(int i)
{
// return points.Elem(i);
return Point (PointIndex(i+PointIndex::BASE-1));
}
MeshPoint & Point(PointIndex pi) { return points[pi]; } MeshPoint & Point(PointIndex pi) { return points[pi]; }
// [[deprecated("Use Point(PointIndex) instead of int !")]] // [[deprecated("Use Point(PointIndex) instead of int !")]]
const MeshPoint & Point(int i) const { return points.Get(i); } const MeshPoint & Point(int i) const
{
// return points.Get(i);
return Point (PointIndex(i+PointIndex::BASE-1));
}
const MeshPoint & Point(PointIndex pi) const { return points[pi]; } const MeshPoint & Point(PointIndex pi) const { return points[pi]; }
const MeshPoint & operator[] (PointIndex pi) const { return points[pi]; } const MeshPoint & operator[] (PointIndex pi) const { return points[pi]; }

View File

@ -145,7 +145,8 @@ namespace netgen
mpquad.check_impossible = qstep == 1; // for prisms only (air domain in trafo) mpquad.check_impossible = qstep == 1; // for prisms only (air domain in trafo)
for (PointIndex pi = mesh3d.Points().Begin(); pi < mesh3d.Points().End(); pi++) // for (PointIndex pi = mesh3d.Points().Begin(); pi < mesh3d.Points().End(); pi++)
for (PointIndex pi : mesh3d.Points().Range())
meshing.AddPoint (mesh3d[pi], pi); meshing.AddPoint (mesh3d[pi], pi);
/* /*
@ -241,7 +242,8 @@ namespace netgen
NgArray<int, PointIndex::BASE> glob2loc(mesh3d.GetNP()); NgArray<int, PointIndex::BASE> glob2loc(mesh3d.GetNP());
glob2loc = -1; glob2loc = -1;
for (PointIndex pi = mesh3d.Points().Begin(); pi < mesh3d.Points().End(); pi++) // for (PointIndex pi = mesh3d.Points().Begin(); pi < mesh3d.Points().End(); pi++)
for (PointIndex pi : mesh3d.Points().Range())
if (domain_bbox.IsIn (mesh3d[pi])) if (domain_bbox.IsIn (mesh3d[pi]))
glob2loc[pi] = glob2loc[pi] =
meshing.AddPoint (mesh3d[pi], pi); meshing.AddPoint (mesh3d[pi], pi);

View File

@ -188,6 +188,18 @@ namespace netgen
void DoArchive (Archive & ar) { ar & i; } void DoArchive (Archive & ar) { ar & i; }
}; };
}
namespace ngcore
{
template<>
constexpr size_t IndexBASE<netgen::PointIndex> () { return netgen::PointIndex::BASE; }
}
namespace netgen
{
inline istream & operator>> (istream & ist, PointIndex & pi) inline istream & operator>> (istream & ist, PointIndex & pi)
{ {
int i; ist >> i; pi = PointIndex(i); return ist; int i; ist >> i; pi = PointIndex(i); return ist;
@ -358,6 +370,7 @@ namespace netgen
typedef NgArray<MeshPoint, PointIndex::BASE, PointIndex> T_POINTS; typedef NgArray<MeshPoint, PointIndex::BASE, PointIndex> T_POINTS;
// typedef Array<MeshPoint, PointIndex> T_POINTS;

View File

@ -142,7 +142,8 @@ namespace netgen
NgArray<SurfaceElementIndex> locelements(0); NgArray<SurfaceElementIndex> locelements(0);
NgArray<int> locrots(0); NgArray<int> locrots(0);
for (PointIndex pi = mesh.Points().Begin(); pi < mesh.Points().End(); pi++) // for (PointIndex pi = mesh.Points().Begin(); pi < mesh.Points().End(); pi++)
for (PointIndex pi : mesh.Points().Range())
{ {
if (mesh[pi].Type() != SURFACEPOINT) if (mesh[pi].Type() != SURFACEPOINT)
continue; continue;

View File

@ -1533,7 +1533,8 @@ void Mesh :: ImproveMeshJacobian (const MeshingParameters & mp,
const char * savetask = multithread.task; const char * savetask = multithread.task;
multithread.task = "Smooth Mesh Jacobian"; multithread.task = "Smooth Mesh Jacobian";
for (PointIndex pi = points.Begin(); i < points.End(); pi++) // for (PointIndex pi = points.Begin(); i < points.End(); pi++)
for (PointIndex pi : points.Range())
{ {
if ((*this)[pi].Type() != INNERPOINT) if ((*this)[pi].Type() != INNERPOINT)
continue; continue;
@ -1687,7 +1688,8 @@ void Mesh :: ImproveMeshJacobianOnSurface (const MeshingParameters & mp,
const char * savetask = multithread.task; const char * savetask = multithread.task;
multithread.task = "Smooth Mesh Jacobian"; multithread.task = "Smooth Mesh Jacobian";
for (PointIndex pi = points.Begin(); pi <= points.End(); pi++) // for (PointIndex pi = points.Begin(); pi <= points.End(); pi++)
for (PointIndex pi : points.Range())
if ( usepoint.Test(i) ) if ( usepoint.Test(i) )
{ {
//(*testout) << "improvejac, p = " << i << endl; //(*testout) << "improvejac, p = " << i << endl;

View File

@ -521,13 +521,15 @@ namespace netgen
// ensure all coarse grid and intermediate level edges // ensure all coarse grid and intermediate level edges
cnt = 0; cnt = 0;
for (int i = mesh->mlbetweennodes.Begin(); i < mesh->mlbetweennodes.End(); i++) // for (int i = mesh->mlbetweennodes.Begin(); i < mesh->mlbetweennodes.End(); i++)
for (int i : mesh->mlbetweennodes.Range())
{ {
INDEX_2 parents = Sort (mesh->mlbetweennodes[i]); INDEX_2 parents = Sort (mesh->mlbetweennodes[i]);
if (parents[0] >= PointIndex::BASE) cnt[parents[0]]++; if (parents[0] >= PointIndex::BASE) cnt[parents[0]]++;
} }
TABLE<int,PointIndex::BASE> vert2vertcoarse (cnt); TABLE<int,PointIndex::BASE> vert2vertcoarse (cnt);
for (int i = mesh->mlbetweennodes.Begin(); i < mesh->mlbetweennodes.End(); i++) // for (int i = mesh->mlbetweennodes.Begin(); i < mesh->mlbetweennodes.End(); i++)
for (int i : mesh->mlbetweennodes.Range())
{ {
INDEX_2 parents = Sort (mesh->mlbetweennodes[i]); INDEX_2 parents = Sort (mesh->mlbetweennodes[i]);
if (parents[0] >= PointIndex::BASE) vert2vertcoarse.AddSave (parents[0], parents[1]); if (parents[0] >= PointIndex::BASE) vert2vertcoarse.AddSave (parents[0], parents[1]);

View File

@ -346,7 +346,8 @@ namespace netgen
(*testout) << "different vertices = " << mesh.GetNP() << endl; (*testout) << "different vertices = " << mesh.GetNP() << endl;
// int first_ep = mesh.GetNP()+1; // int first_ep = mesh.GetNP()+1;
PointIndex first_ep = mesh.Points().End(); // PointIndex first_ep = mesh.Points().End();
PointIndex first_ep = *mesh.Points().Range().end();
auto vertexrange = mesh.Points().Range(); auto vertexrange = mesh.Points().Range();
NgArray<int> face2solid[2]; NgArray<int> face2solid[2];
@ -500,7 +501,8 @@ namespace netgen
bool exists = 0; bool exists = 0;
tsearch.Start(); tsearch.Start();
for (PointIndex j = first_ep; j < mesh.Points().End(); j++) // for (PointIndex j = first_ep; j < mesh.Points().End(); j++)
for (PointIndex j = first_ep; j < *mesh.Points().Range().end(); j++)
if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps) if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps)
{ {
exists = true; exists = true;

View File

@ -4008,7 +4008,8 @@ namespace netgen
// NgProfiler::StartTimer (timer_vals); // NgProfiler::StartTimer (timer_vals);
NgArray<double,PointIndex::BASE> vertval(mesh->GetNP()); NgArray<double,PointIndex::BASE> vertval(mesh->GetNP());
NgArray<bool,PointIndex::BASE> posval(mesh->GetNP()); NgArray<bool,PointIndex::BASE> posval(mesh->GetNP());
for (PointIndex pi = vertval.Begin(); pi < vertval.End(); pi++) // for (PointIndex pi = vertval.Begin(); pi < vertval.End(); pi++)
for (PointIndex pi : vertval.Range())
{ {
Point<3> vert = (*mesh)[pi]; Point<3> vert = (*mesh)[pi];
vertval[pi] = vertval[pi] =