mesh.parentelement with correct types

This commit is contained in:
Joachim Schoeberl 2025-01-04 12:41:04 +01:00
parent 9bc0273784
commit 63cb566b8d
6 changed files with 34 additions and 31 deletions

View File

@ -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
{

View File

@ -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

View File

@ -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<ElementIndex>()+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);

View File

@ -224,9 +224,9 @@ namespace netgen
/// refinement hierarchy
Array<PointIndices<2>,PointIndex> mlbetweennodes;
/// parent element of volume element
NgArray<int> mlparentelement;
Array<ElementIndex, ElementIndex> mlparentelement;
/// parent element of surface element
NgArray<int> mlparentsurfaceelement;
Array<SurfaceElementIndex, SurfaceElementIndex> mlparentsurfaceelement;

View File

@ -959,8 +959,8 @@ namespace netgen
self.opensegments = NgArray<Segment>(0);
self.numvertices = 0;
self.mlbetweennodes = Array<PointIndices<2>,PointIndex> (0);
self.mlparentelement = NgArray<int>(0);
self.mlparentsurfaceelement = NgArray<int>(0);
self.mlparentelement = Array<ElementIndex, ElementIndex>(0);
self.mlparentsurfaceelement = Array<SurfaceElementIndex, SurfaceElementIndex>(0);
self.curvedelems = make_unique<CurvedElements> (self);
self.clusters = make_unique<AnisotropicClusters> (self);
self.ident = make_unique<Identifications> (self);

View File

@ -961,11 +961,13 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
);
})
.def_property_readonly("parentelements", [](Mesh & self) {
return FlatArray<int>(self.mlparentelement.Size(), &self.mlparentelement[0]);
// return FlatArray<int>(self.mlparentelement.Size(), &self.mlparentelement[0]);
return FlatArray(self.mlparentelement);
}, py::keep_alive<0,1>())
.def_property_readonly("parentsurfaceelements", [](Mesh & self) {
return FlatArray<int>(self.mlparentsurfaceelement.Size(),
&self.mlparentsurfaceelement[0]);
// return FlatArray<int>(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<Mesh>();