From 20abe6ec37f8a5ff9fcafbaaabcb3e26ec72637c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Mon, 29 Jul 2019 17:46:09 +0200 Subject: [PATCH] make number of vertices per level available --- libsrc/include/nginterface_v2.hpp | 3 ++- libsrc/interface/nginterface.cpp | 4 +++- libsrc/interface/nginterface_v2.cpp | 10 +++++++++- libsrc/meshing/bisect.cpp | 28 +++++++++++++++++----------- libsrc/meshing/meshclass.cpp | 2 +- libsrc/meshing/meshclass.hpp | 4 +++- libsrc/meshing/meshfunc.cpp | 2 +- 7 files changed, 36 insertions(+), 17 deletions(-) diff --git a/libsrc/include/nginterface_v2.hpp b/libsrc/include/nginterface_v2.hpp index 6e06fc82..081422d3 100644 --- a/libsrc/include/nginterface_v2.hpp +++ b/libsrc/include/nginterface_v2.hpp @@ -284,7 +284,8 @@ namespace netgen int GetDimension() const; int GetNLevels() const; - + size_t GetNVLevel (int level) const; + int GetNElements (int dim) const; int GetNNodes (int nt) const; diff --git a/libsrc/interface/nginterface.cpp b/libsrc/interface/nginterface.cpp index 1896583a..7c647119 100644 --- a/libsrc/interface/nginterface.cpp +++ b/libsrc/interface/nginterface.cpp @@ -1724,7 +1724,9 @@ void Ng_SetSurfaceElementOrders (int enr, int ox, int oy) int Ng_GetNLevels () { - return (mesh) ? mesh->mglevels : 0; + if (!mesh) return 0; + return max(size_t(1), mesh -> level_nv.Size()); + // return (mesh) ? mesh->mglevels : 0; } diff --git a/libsrc/interface/nginterface_v2.cpp b/libsrc/interface/nginterface_v2.cpp index 1d8f9366..2fb395cf 100644 --- a/libsrc/interface/nginterface_v2.cpp +++ b/libsrc/interface/nginterface_v2.cpp @@ -130,7 +130,15 @@ namespace netgen int Ngx_Mesh :: GetNLevels() const { - return mesh -> mglevels; + return max(size_t(1), mesh -> level_nv.Size()); + } + + size_t Ngx_Mesh :: GetNVLevel(int level) const + { + if (level >= mesh->level_nv.Size()) + return mesh->GetNV(); + else + return mesh->level_nv[level]; } int Ngx_Mesh :: GetNElements (int dim) const diff --git a/libsrc/meshing/bisect.cpp b/libsrc/meshing/bisect.cpp index 8cb57bcd..6390fff0 100644 --- a/libsrc/meshing/bisect.cpp +++ b/libsrc/meshing/bisect.cpp @@ -2755,14 +2755,15 @@ namespace netgen inf.close(); } - - - if (mesh.mglevels == 1 || idmaps.Size() > 0) - BisectTetsCopyMesh(mesh, NULL, opt, idmaps, refelementinfofileread); - - mesh.ComputeNVertices(); - + + // if (mesh.mglevels == 1 || idmaps.Size() > 0) + if (mesh.level_nv.Size() == 0) // || idmaps.Size() ???? + { + BisectTetsCopyMesh(mesh, NULL, opt, idmaps, refelementinfofileread); + mesh.level_nv.Append (mesh.GetNV()); + } + int np = mesh.GetNV(); mesh.SetNP(np); @@ -2773,7 +2774,7 @@ namespace netgen // int initnp = np; // int maxsteps = 3; - mesh.mglevels++; + // mesh.mglevels++; /* if (opt.refinementfilename || opt.usemarkedelements) @@ -3807,7 +3808,8 @@ namespace netgen // write multilevel hierarchy to mesh: np = mesh.GetNP(); mesh.mlbetweennodes.SetSize(np); - if (mesh.mglevels <= 2) + // if (mesh.mglevels <= 2) + if (mesh.level_nv.Size() <= 1) { PrintMessage(4,"RESETTING mlbetweennodes"); for (int i = 1; i <= np; i++) @@ -3817,6 +3819,9 @@ namespace netgen } } + mesh.level_nv.Append (np); + + /* for (i = 1; i <= cutedges.GetNBags(); i++) for (j = 1; j <= cutedges.GetBagSize(i); j++) @@ -3982,11 +3987,12 @@ namespace netgen } } - + // Check/Repair static bool repaired_once; - if(mesh.mglevels == 1) + // if(mesh.mglevels == 1) + if(mesh.level_nv.Size() == 1) repaired_once = false; //mesh.Save("before.vol"); diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 695ea807..8d95f222 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -20,7 +20,7 @@ namespace netgen segmentht = NULL; lochfunc = NULL; - mglevels = 1; + // mglevels = 1; elementsearchtree = NULL; elementsearchtreets = NextTimeStamp(); majortimestamp = timestamp = NextTimeStamp(); diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index 78ea8035..7e378ede 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -175,7 +175,9 @@ namespace netgen /// number of refinement levels - int mglevels; + // int mglevels; + // number of vertices on each refinement level: + NgArray level_nv; /// refinement hierarchy NgArray,PointIndex::BASE> mlbetweennodes; /// parent element of volume element diff --git a/libsrc/meshing/meshfunc.cpp b/libsrc/meshing/meshfunc.cpp index b3630df6..b7d91a14 100644 --- a/libsrc/meshing/meshfunc.cpp +++ b/libsrc/meshing/meshfunc.cpp @@ -690,7 +690,7 @@ namespace netgen case 'j': mesh3d.ImproveMeshJacobian(mp); break; } } - mesh3d.mglevels = 1; + // mesh3d.mglevels = 1; MeshQuality3d (mesh3d); }