diff --git a/libsrc/interface/nginterface.cpp b/libsrc/interface/nginterface.cpp index cf3c580e..6ceeed96 100644 --- a/libsrc/interface/nginterface.cpp +++ b/libsrc/interface/nginterface.cpp @@ -1749,12 +1749,12 @@ int Ng_GetParentElement (int ei) if (mesh->GetDimension() == 3) { if (ei <= mesh->mlparentelement.Size()) - return mesh->mlparentelement.Get(ei); + return mesh->mlparentelement[ei-1]+1; } else { if (ei <= mesh->mlparentsurfaceelement.Size()) - return mesh->mlparentsurfaceelement.Get(ei); + return mesh->mlparentsurfaceelement[ei-1]+1; } return 0; } @@ -1765,7 +1765,7 @@ int Ng_GetParentSElement (int ei) if (mesh->GetDimension() == 3) { if (ei <= mesh->mlparentsurfaceelement.Size()) - return mesh->mlparentsurfaceelement.Get(ei); + return mesh->mlparentsurfaceelement[ei-1]+1; } else { diff --git a/libsrc/interface/nginterface_v2.cpp b/libsrc/interface/nginterface_v2.cpp index 1e3e7af8..782a3381 100644 --- a/libsrc/interface/nginterface_v2.cpp +++ b/libsrc/interface/nginterface_v2.cpp @@ -725,34 +725,32 @@ namespace netgen int Ngx_Mesh :: GetParentElement (int ei) const { - ei++; - if (mesh->GetDimension() == 3) + if (mesh->GetDimension() == 3) { - if (ei <= mesh->mlparentelement.Size()) - return mesh->mlparentelement.Get(ei)-1; + if (ei < mesh->mlparentelement.Size()) + return mesh->mlparentelement[ei]; } - else + else { - if (ei <= mesh->mlparentsurfaceelement.Size()) - return mesh->mlparentsurfaceelement.Get(ei)-1; + if (ei < mesh->mlparentsurfaceelement.Size()) + return mesh->mlparentsurfaceelement[ei]; } - return -1; + return -1; } int Ngx_Mesh :: GetParentSElement (int ei) const { - ei++; - if (mesh->GetDimension() == 3) + if (mesh->GetDimension() == 3) { - if (ei <= mesh->mlparentsurfaceelement.Size()) - return mesh->mlparentsurfaceelement.Get(ei)-1; + if (ei < mesh->mlparentsurfaceelement.Size()) + return mesh->mlparentsurfaceelement[ei]; } - else + else { - return -1; + return -1; } - return -1; + return -1; } int Ngx_Mesh :: GetNIdentifications () const diff --git a/libsrc/meshing/bisect.cpp b/libsrc/meshing/bisect.cpp index d8016b6e..b33787e5 100644 --- a/libsrc/meshing/bisect.cpp +++ b/libsrc/meshing/bisect.cpp @@ -2203,11 +2203,14 @@ namespace netgen mesh.mlparentelement.SetSize(ne); - for (int i = 1; i <= ne; i++) - mesh.mlparentelement.Elem(i) = 0; + // for (int i = 1; i <= ne; i++) + // mesh.mlparentelement.Elem(i) = 0; + mesh.mlparentelement = ElementIndex::INVALID; + mesh.mlparentsurfaceelement.SetSize(nse); - for (int i = 1; i <= nse; i++) - mesh.mlparentsurfaceelement.Elem(i) = 0; + // for (int i = 1; i <= nse; i++) + // mesh.mlparentsurfaceelement.Elem(i) = 0; + mesh.mlparentsurfaceelement = SurfaceElementIndex::INVALID; if (printmessage_importance>0) { @@ -3361,7 +3364,7 @@ namespace netgen mtets[ei] = newtet1; mtets.Append (newtet2); - mesh.mlparentelement.Append (ei-IndexBASE()+1); + mesh.mlparentelement.Append (ei); } NgProfiler::StopTimer (timer_bisecttet); (*opt.tracer)("bisecttet", true); @@ -3508,7 +3511,7 @@ namespace netgen mtris[i] = newtri1; mtris.Append (newtri2); - mesh.mlparentsurfaceelement.Append (i+1); + mesh.mlparentsurfaceelement.Append (i); } NgProfiler::StopTimer (timer_bisecttrig); diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index 4e05dbf2..60fb764f 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -224,9 +224,9 @@ namespace netgen /// refinement hierarchy Array,PointIndex> mlbetweennodes; /// parent element of volume element - NgArray mlparentelement; + Array mlparentelement; /// parent element of surface element - NgArray mlparentsurfaceelement; + Array mlparentsurfaceelement; diff --git a/libsrc/meshing/parallelmesh.cpp b/libsrc/meshing/parallelmesh.cpp index 7745f33a..29b76dbe 100644 --- a/libsrc/meshing/parallelmesh.cpp +++ b/libsrc/meshing/parallelmesh.cpp @@ -959,8 +959,8 @@ namespace netgen self.opensegments = NgArray(0); self.numvertices = 0; self.mlbetweennodes = Array,PointIndex> (0); - self.mlparentelement = NgArray(0); - self.mlparentsurfaceelement = NgArray(0); + self.mlparentelement = Array(0); + self.mlparentsurfaceelement = Array(0); self.curvedelems = make_unique (self); self.clusters = make_unique (self); self.ident = make_unique (self); diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index c9c95002..102d8b55 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -961,11 +961,13 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) ); }) .def_property_readonly("parentelements", [](Mesh & self) { - return FlatArray(self.mlparentelement.Size(), &self.mlparentelement[0]); + // return FlatArray(self.mlparentelement.Size(), &self.mlparentelement[0]); + return FlatArray(self.mlparentelement); }, py::keep_alive<0,1>()) .def_property_readonly("parentsurfaceelements", [](Mesh & self) { - return FlatArray(self.mlparentsurfaceelement.Size(), - &self.mlparentsurfaceelement[0]); + // return FlatArray(self.mlparentsurfaceelement.Size(), + // &self.mlparentsurfaceelement[0]); + return FlatArray(self.mlparentsurfaceelement); }, py::keep_alive<0,1>()) .def_property_readonly("macromesh", [](Mesh & self) { auto coarsemesh = make_shared();