From 00e3a3490b2cb16a3f76e1fd3fa75d408f3015df Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Sat, 28 Dec 2024 19:46:29 +0100 Subject: [PATCH] some index fixes --- libsrc/core/bitarray.hpp | 6 ++++++ libsrc/meshing/delaunay.cpp | 4 ++-- libsrc/meshing/meshclass.cpp | 2 +- libsrc/meshing/meshclass.hpp | 2 +- libsrc/meshing/meshfunc.cpp | 12 ++++++------ libsrc/meshing/parser2.cpp | 8 ++++---- libsrc/meshing/parser3.cpp | 32 ++++++++++++++++---------------- libsrc/meshing/refine.cpp | 2 +- libsrc/meshing/ruler3.cpp | 2 +- libsrc/meshing/smoothing2.cpp | 16 ++++++++-------- 10 files changed, 46 insertions(+), 40 deletions(-) diff --git a/libsrc/core/bitarray.hpp b/libsrc/core/bitarray.hpp index a354952b..0587595b 100644 --- a/libsrc/core/bitarray.hpp +++ b/libsrc/core/bitarray.hpp @@ -225,6 +225,12 @@ private: bool Test (IndexType i) const { return BitArray::Test(i-IndexBASE()); } bool operator[] (IndexType i) const { return Test(i); } + NGCORE_API TBitArray & Or (const TBitArray & ba2) + { + BitArray::Or(ba2); + return *this; + } + }; } // namespace ngcore diff --git a/libsrc/meshing/delaunay.cpp b/libsrc/meshing/delaunay.cpp index 3595f8f6..05541632 100644 --- a/libsrc/meshing/delaunay.cpp +++ b/libsrc/meshing/delaunay.cpp @@ -809,7 +809,7 @@ namespace netgen static Timer topenel("Delaunay - find openel"); RegionTimer rt(topenel); // find surface triangles which are no face of any tet - TBitArray bnd_points( mesh.GetNP() + PointIndex::BASE ); + TBitArray bnd_points( mesh.GetNP() ); bnd_points.Clear(); for (int i = 1; i <= mesh.GetNOpenElements(); i++) @@ -891,7 +891,7 @@ namespace netgen table.Add(tri[2], openel_i); }, mesh.GetNP()); - TBitArray badnode(mesh.GetNP()+PointIndex::BASE); + TBitArray badnode(mesh.GetNP()); badnode.Clear(); ngcore::ParallelForRange(openels.Size(), [&] (auto myrange) { diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 0ecaf4fa..afc00fd8 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -7018,7 +7018,7 @@ namespace netgen } - Table Mesh :: CreatePoint2ElementTable(std::optional points, int domain) const + Table Mesh :: CreatePoint2ElementTable(std::optional> points, int domain) const { static Timer timer("Mesh::CreatePoint2VolumeElementTable"); RegionTimer rt(timer); diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index f8b407ab..287c8c0b 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -844,7 +844,7 @@ namespace netgen - DLL_HEADER Table CreatePoint2ElementTable(std::optional points = std::nullopt, int domain = 0) const; + DLL_HEADER Table CreatePoint2ElementTable(std::optional> points = std::nullopt, int domain = 0) const; // DLL_HEADER Table CreatePoint2SurfaceElementTable( int faceindex=0 ) const; DLL_HEADER Table CreatePoint2SurfaceElementTable( int faceindex=0 ) const; DLL_HEADER CompressedTable CreateCompressedPoint2SurfaceElementTable( int faceindex=0 ) const; diff --git a/libsrc/meshing/meshfunc.cpp b/libsrc/meshing/meshfunc.cpp index 15d71354..1170a7aa 100644 --- a/libsrc/meshing/meshfunc.cpp +++ b/libsrc/meshing/meshfunc.cpp @@ -457,14 +457,14 @@ namespace netgen for (PointIndex pi : mesh.Points().Range()) if (domain_bbox.IsIn (mesh[pi])) - glob2loc[pi] = meshing.AddPoint (mesh[pi], pi); + glob2loc[pi] = meshing.AddPoint (mesh[pi], pi); - for (auto sel : mesh.OpenElements() ) - { - for(auto & pi : sel.PNums()) + for (auto sel : mesh.OpenElements()) + { + for(auto & pi : sel.PNums()) pi = glob2loc[pi]; - meshing.AddBoundaryElement (sel); - } + meshing.AddBoundaryElement (sel); + } int oldne = mesh.GetNE(); diff --git a/libsrc/meshing/parser2.cpp b/libsrc/meshing/parser2.cpp index 03a4b87e..d1190ea4 100644 --- a/libsrc/meshing/parser2.cpp +++ b/libsrc/meshing/parser2.cpp @@ -334,23 +334,23 @@ void netrule :: LoadRule (istream & ist) { elements.Append (Element2d(TRIG)); - ist >> elements.Last().PNum(1); + ist >> (int&)elements.Last().PNum(1); ist >> ch; // ',' if (ch == COMMASIGN) { - ist >> elements.Last().PNum(2); + ist >> (int&)elements.Last().PNum(2); ist >> ch; // ',' } if (ch == COMMASIGN) { - ist >> elements.Last().PNum(3); + ist >> (int&)elements.Last().PNum(3); ist >> ch; // ',' } if (ch == COMMASIGN) { elements.Last().SetType (QUAD); - ist >> elements.Last().PNum(4); + ist >> (int&)elements.Last().PNum(4); ist >> ch; // ',' // const Element2d & el = elements.Last(); diff --git a/libsrc/meshing/parser3.cpp b/libsrc/meshing/parser3.cpp index 5f5a6365..6c2ce74a 100644 --- a/libsrc/meshing/parser3.cpp +++ b/libsrc/meshing/parser3.cpp @@ -177,16 +177,16 @@ void vnetrule :: LoadRule (istream & ist) while (ch == '(') { face.SetType(TRIG); - ist >> face.PNum(1); + ist >> (int&)face.PNum(1); ist >> ch; // ',' - ist >> face.PNum(2); + ist >> (int&)face.PNum(2); ist >> ch; // ',' - ist >> face.PNum(3); + ist >> (int&)face.PNum(3); ist >> ch; // ')' or ',' if (ch == COMMASIGN) { face.SetType(QUAD); - ist >> face.PNum(4); + ist >> (int&)face.PNum(4); ist >> ch; // ')' } faces.Append (face); @@ -285,16 +285,16 @@ void vnetrule :: LoadRule (istream & ist) while (ch == '(') { face.SetType(TRIG); - ist >> face.PNum(1); + ist >> (int&)face.PNum(1); ist >> ch; // ',' - ist >> face.PNum(2); + ist >> (int&)face.PNum(2); ist >> ch; // ',' - ist >> face.PNum(3); + ist >> (int&)face.PNum(3); ist >> ch; // ')' or ',' if (ch == COMMASIGN) { face.SetType(QUAD); - ist >> face.PNum(4); + ist >> (int&)face.PNum(4); ist >> ch; // ')' } faces.Append (face); @@ -494,40 +494,40 @@ void vnetrule :: LoadRule (istream & ist) elements.Append (Element(TET)); // elements.Last().SetNP(1); - ist >> elements.Last().PNum(1); + ist >> (int&)elements.Last().PNum(1); ist >> ch; // ',' if (ch == COMMASIGN) { // elements.Last().SetNP(2); - ist >> elements.Last().PNum(2); + ist >> (int&)elements.Last().PNum(2); ist >> ch; // ',' } if (ch == COMMASIGN) { // elements.Last().SetNP(3); - ist >> elements.Last().PNum(3); + ist >> (int&)elements.Last().PNum(3); ist >> ch; // ',' } if (ch == COMMASIGN) { // elements.Last().SetNP(4); elements.Last().SetType(TET); - ist >> elements.Last().PNum(4); + ist >> (int&)elements.Last().PNum(4); ist >> ch; // ',' } if (ch == COMMASIGN) { // elements.Last().SetNP(5); elements.Last().SetType(PYRAMID); - ist >> elements.Last().PNum(5); + ist >> (int&)elements.Last().PNum(5); ist >> ch; // ',' } if (ch == COMMASIGN) { // elements.Last().SetNP(6); elements.Last().SetType(PRISM); - ist >> elements.Last().PNum(6); + ist >> (int&)elements.Last().PNum(6); ist >> ch; // ',' } @@ -535,14 +535,14 @@ void vnetrule :: LoadRule (istream & ist) { // elements.Last().SetNP(6); elements.Last().SetType(HEX); - ist >> elements.Last().PNum(7); + ist >> (int&)elements.Last().PNum(7); ist >> ch; // ',' } if (ch == COMMASIGN) { // elements.Last().SetNP(6); elements.Last().SetType(HEX); - ist >> elements.Last().PNum(8); + ist >> (int&)elements.Last().PNum(8); ist >> ch; // ',' } diff --git a/libsrc/meshing/refine.cpp b/libsrc/meshing/refine.cpp index 8bbbb5ef..8770e07c 100644 --- a/libsrc/meshing/refine.cpp +++ b/libsrc/meshing/refine.cpp @@ -31,7 +31,7 @@ namespace netgen if (mesh.mlbetweennodes.Size() < mesh.GetNV()) { mesh.mlbetweennodes.SetSize(mesh.GetNV()); - mesh.mlbetweennodes = INDEX_2(PointIndex::BASE-1,PointIndex::BASE-1); + mesh.mlbetweennodes = PointIndices<2>(PointIndex::INVALID, PointIndex::INVALID); } if (mesh.level_nv.Size() == 0) diff --git a/libsrc/meshing/ruler3.cpp b/libsrc/meshing/ruler3.cpp index 20a58f17..54d5b315 100644 --- a/libsrc/meshing/ruler3.cpp +++ b/libsrc/meshing/ruler3.cpp @@ -662,7 +662,7 @@ int Meshing3 :: ApplyRules // for (int i = 1; i <= lpoints.Size(); i++) for (auto i : lpoints.Range()) { - if ( !pused.Get(i) ) + if ( !pused[i] ) { const Point3d & lp = lpoints[i]; diff --git a/libsrc/meshing/smoothing2.cpp b/libsrc/meshing/smoothing2.cpp index b5413f6e..b5d001c8 100644 --- a/libsrc/meshing/smoothing2.cpp +++ b/libsrc/meshing/smoothing2.cpp @@ -214,7 +214,7 @@ namespace netgen { } ; - virtual double Func (const Vector & x) const + virtual double Func (const Vector & x) const override { double badness = 0; @@ -243,7 +243,7 @@ namespace netgen } - virtual double FuncGrad (const Vector & x, Vector & g) const + virtual double FuncGrad (const Vector & x, Vector & g) const override { Vec<3> vgrad; Point<3> pp1; @@ -278,7 +278,7 @@ namespace netgen return badness; } - virtual double FuncDeriv (const Vector & x, const Vector & dir, double & deriv) const + virtual double FuncDeriv (const Vector & x, const Vector & dir, double & deriv) const override { deriv = 0; double badness = 0; @@ -479,8 +479,8 @@ namespace netgen Opti2dLocalData & ald) : mesh(amesh), ld(ald), geo(*amesh.GetGeometry()) { } ; - virtual double FuncGrad (const Vector & x, Vector & g) const; - virtual double Func (const Vector & x) const; + virtual double FuncGrad (const Vector & x, Vector & g) const override; + virtual double Func (const Vector & x) const override; }; double Opti2EdgeMinFunction :: Func (const Vector & x) const @@ -550,9 +550,9 @@ namespace netgen Opti2dLocalData & ald) : mesh(amesh), ld(ald), geo(*amesh.GetGeometry()) { } ; - virtual double FuncGrad (const Vector & x, Vector & g) const; - virtual double FuncDeriv (const Vector & x, const Vector & dir, double & deriv) const; - virtual double Func (const Vector & x) const; + virtual double FuncGrad (const Vector & x, Vector & g) const override; + virtual double FuncDeriv (const Vector & x, const Vector & dir, double & deriv) const override; + virtual double Func (const Vector & x) const override; }; double Opti2SurfaceMinFunctionJacobian ::