allow internal edges on boundarylayer (for sphere, ellipsoid)

This commit is contained in:
Christopher Lackner 2024-02-13 09:35:44 +01:00
parent cee5d55b7d
commit 803eb73d2d
3 changed files with 16 additions and 7 deletions

View File

@ -679,7 +679,8 @@ namespace netgen
// result in pushed through elements, since we do not (yet) // result in pushed through elements, since we do not (yet)
// curvature through layers. // curvature through layers.
// Therefore we disable curving for these surfaces. // Therefore we disable curving for these surfaces.
mesh.GetFaceDescriptor(i).SetSurfNr(-1); if(!params.keep_surfaceindex)
mesh.GetFaceDescriptor(i).SetSurfNr(-1);
} }
} }
@ -984,7 +985,7 @@ namespace netgen
Array<PointIndex> points; Array<PointIndex> points;
// find first vertex on edge // find first vertex on edge
double edge_len = 0.; double edge_len = 0.;
auto is_end_point = [&] (PointIndex pi) auto is_end_point = [&] (PointIndex pi, const Segment& testseg)
{ {
// if(mesh[pi].Type() == FIXEDPOINT) // if(mesh[pi].Type() == FIXEDPOINT)
// return true; // return true;
@ -992,13 +993,14 @@ namespace netgen
auto segs = topo.GetVertexSegments(pi); auto segs = topo.GetVertexSegments(pi);
auto first_edgenr = mesh[segs[0]].edgenr; auto first_edgenr = mesh[segs[0]].edgenr;
for(auto segi : segs) for(auto segi : segs)
if(mesh[segi].edgenr != first_edgenr) if(auto& seg = mesh[segi]; seg.edgenr != first_edgenr || (testseg[0] == seg[1] && testseg[1] == seg[0]))
return true; return true;
return false; return false;
}; };
bool any_grows = false; bool any_grows = false;
const Segment* last_seg = nullptr;
for(const auto& seg : segments) for(const auto& seg : segments)
{ {
if(seg.edgenr-1 == edgenr) if(seg.edgenr-1 == edgenr)
@ -1006,8 +1008,9 @@ namespace netgen
if(growthvectors[seg[0]].Length2() != 0 || if(growthvectors[seg[0]].Length2() != 0 ||
growthvectors[seg[1]].Length2() != 0) growthvectors[seg[1]].Length2() != 0)
any_grows = true; any_grows = true;
if(points.Size() == 0 && is_end_point(seg[0])) if(points.Size() == 0 && is_end_point(seg[0], seg))
{ {
last_seg = &seg;
points.Append(seg[0]); points.Append(seg[0]);
points.Append(seg[1]); points.Append(seg[1]);
edge_len += (mesh[seg[1]] - mesh[seg[0]]).Length(); edge_len += (mesh[seg[1]] - mesh[seg[0]]).Length();
@ -1034,6 +1037,7 @@ namespace netgen
edge_len += (mesh[points.Last()] - mesh[seg[1]]).Length(); edge_len += (mesh[points.Last()] - mesh[seg[1]]).Length();
points.Append(seg[1]); points.Append(seg[1]);
point_found = true; point_found = true;
last_seg = &seg;
break; break;
} }
else if(seg[1] == points.Last() && else if(seg[1] == points.Last() &&
@ -1042,10 +1046,11 @@ namespace netgen
edge_len += (mesh[points.Last()] - mesh[seg[0]]).Length(); edge_len += (mesh[points.Last()] - mesh[seg[0]]).Length();
points.Append(seg[0]); points.Append(seg[0]);
point_found = true; point_found = true;
last_seg = &seg;
break; break;
} }
} }
if(is_end_point(points.Last())) if(last_seg && is_end_point(points.Last(), *last_seg))
break; break;
if(!point_found) if(!point_found)
{ {

View File

@ -23,6 +23,7 @@ public:
bool limit_growth_vectors = true; bool limit_growth_vectors = true;
double limit_safety = 0.3; // alloow only 30% of the growth vector length double limit_safety = 0.3; // alloow only 30% of the growth vector length
bool sides_keep_surfaceindex = false; bool sides_keep_surfaceindex = false;
bool keep_surfaceindex = false;
Array<size_t> project_boundaries; Array<size_t> project_boundaries;
}; };

View File

@ -1463,7 +1463,8 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
variant<string, int> domain, bool outside, variant<string, int> domain, bool outside,
optional<string> project_boundaries, optional<string> project_boundaries,
bool grow_edges, bool limit_growth_vectors, bool grow_edges, bool limit_growth_vectors,
bool sides_keep_surfaceindex) bool sides_keep_surfaceindex,
bool keep_surfaceindex)
{ {
BoundaryLayerParameters blp; BoundaryLayerParameters blp;
BitArray boundaries(self.GetNFD()+1); BitArray boundaries(self.GetNFD()+1);
@ -1549,12 +1550,14 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
blp.grow_edges = grow_edges; blp.grow_edges = grow_edges;
blp.limit_growth_vectors = limit_growth_vectors; blp.limit_growth_vectors = limit_growth_vectors;
blp.sides_keep_surfaceindex = sides_keep_surfaceindex; blp.sides_keep_surfaceindex = sides_keep_surfaceindex;
blp.keep_surfaceindex = keep_surfaceindex;
GenerateBoundaryLayer (self, blp); GenerateBoundaryLayer (self, blp);
self.UpdateTopology(); self.UpdateTopology();
}, py::arg("boundary"), py::arg("thickness"), py::arg("material"), }, py::arg("boundary"), py::arg("thickness"), py::arg("material"),
py::arg("domains") = ".*", py::arg("outside") = false, py::arg("domains") = ".*", py::arg("outside") = false,
py::arg("project_boundaries")=nullopt, py::arg("grow_edges")=true, py::arg("limit_growth_vectors") = true, py::arg("sides_keep_surfaceindex")=false, py::arg("project_boundaries")=nullopt, py::arg("grow_edges")=true, py::arg("limit_growth_vectors") = true, py::arg("sides_keep_surfaceindex")=false,
py::arg("keep_surfaceindex")=false,
R"delimiter( R"delimiter(
Add boundary layer to mesh. Add boundary layer to mesh.