make number of vertices per level available

This commit is contained in:
Joachim Schöberl 2019-07-29 17:46:09 +02:00
parent ed135fc61e
commit 20abe6ec37
7 changed files with 36 additions and 17 deletions

View File

@ -284,6 +284,7 @@ namespace netgen
int GetDimension() const; int GetDimension() const;
int GetNLevels() const; int GetNLevels() const;
size_t GetNVLevel (int level) const;
int GetNElements (int dim) const; int GetNElements (int dim) const;
int GetNNodes (int nt) const; int GetNNodes (int nt) const;

View File

@ -1724,7 +1724,9 @@ void Ng_SetSurfaceElementOrders (int enr, int ox, int oy)
int Ng_GetNLevels () 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;
} }

View File

@ -130,7 +130,15 @@ namespace netgen
int Ngx_Mesh :: GetNLevels() const 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 int Ngx_Mesh :: GetNElements (int dim) const

View File

@ -2755,14 +2755,15 @@ namespace netgen
inf.close(); inf.close();
} }
if (mesh.mglevels == 1 || idmaps.Size() > 0)
BisectTetsCopyMesh(mesh, NULL, opt, idmaps, refelementinfofileread);
mesh.ComputeNVertices(); 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(); int np = mesh.GetNV();
mesh.SetNP(np); mesh.SetNP(np);
@ -2773,7 +2774,7 @@ namespace netgen
// int initnp = np; // int initnp = np;
// int maxsteps = 3; // int maxsteps = 3;
mesh.mglevels++; // mesh.mglevels++;
/* /*
if (opt.refinementfilename || opt.usemarkedelements) if (opt.refinementfilename || opt.usemarkedelements)
@ -3807,7 +3808,8 @@ namespace netgen
// write multilevel hierarchy to mesh: // write multilevel hierarchy to mesh:
np = mesh.GetNP(); np = mesh.GetNP();
mesh.mlbetweennodes.SetSize(np); mesh.mlbetweennodes.SetSize(np);
if (mesh.mglevels <= 2) // if (mesh.mglevels <= 2)
if (mesh.level_nv.Size() <= 1)
{ {
PrintMessage(4,"RESETTING mlbetweennodes"); PrintMessage(4,"RESETTING mlbetweennodes");
for (int i = 1; i <= np; i++) 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 (i = 1; i <= cutedges.GetNBags(); i++)
for (j = 1; j <= cutedges.GetBagSize(i); j++) for (j = 1; j <= cutedges.GetBagSize(i); j++)
@ -3986,7 +3991,8 @@ namespace netgen
// Check/Repair // Check/Repair
static bool repaired_once; static bool repaired_once;
if(mesh.mglevels == 1) // if(mesh.mglevels == 1)
if(mesh.level_nv.Size() == 1)
repaired_once = false; repaired_once = false;
//mesh.Save("before.vol"); //mesh.Save("before.vol");

View File

@ -20,7 +20,7 @@ namespace netgen
segmentht = NULL; segmentht = NULL;
lochfunc = NULL; lochfunc = NULL;
mglevels = 1; // mglevels = 1;
elementsearchtree = NULL; elementsearchtree = NULL;
elementsearchtreets = NextTimeStamp(); elementsearchtreets = NextTimeStamp();
majortimestamp = timestamp = NextTimeStamp(); majortimestamp = timestamp = NextTimeStamp();

View File

@ -175,7 +175,9 @@ namespace netgen
/// number of refinement levels /// number of refinement levels
int mglevels; // int mglevels;
// number of vertices on each refinement level:
NgArray<size_t> level_nv;
/// refinement hierarchy /// refinement hierarchy
NgArray<PointIndices<2>,PointIndex::BASE> mlbetweennodes; NgArray<PointIndices<2>,PointIndex::BASE> mlbetweennodes;
/// parent element of volume element /// parent element of volume element

View File

@ -690,7 +690,7 @@ namespace netgen
case 'j': mesh3d.ImproveMeshJacobian(mp); break; case 'j': mesh3d.ImproveMeshJacobian(mp); break;
} }
} }
mesh3d.mglevels = 1; // mesh3d.mglevels = 1;
MeshQuality3d (mesh3d); MeshQuality3d (mesh3d);
} }