From 4a1fe78ff6a7d192ba6843576714664982f6dddb Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Tue, 8 Oct 2024 17:35:53 +0200 Subject: [PATCH] Rename blp.keep_surfaceindex to disable_curving When disabling curving at faces, also disable it for adjacent edges --- libsrc/meshing/boundarylayer.cpp | 23 ++++++++++++++++++-- libsrc/meshing/boundarylayer.hpp | 1 + libsrc/meshing/boundarylayer_interpolate.cpp | 7 ++++++ libsrc/meshing/meshtype.cpp | 2 +- libsrc/meshing/meshtype.hpp | 2 +- libsrc/meshing/python_mesh.cpp | 14 ++++++------ 6 files changed, 38 insertions(+), 11 deletions(-) diff --git a/libsrc/meshing/boundarylayer.cpp b/libsrc/meshing/boundarylayer.cpp index e19e7f2a..fe7a31ad 100644 --- a/libsrc/meshing/boundarylayer.cpp +++ b/libsrc/meshing/boundarylayer.cpp @@ -339,7 +339,7 @@ void BoundaryLayerTool ::CreateNewFaceDescriptors() // result in pushed through elements, since we do not (yet) // curvature through layers. // Therefore we disable curving for these surfaces. - if (!params.keep_surfaceindex) + if (params.disable_curving) mesh.GetFaceDescriptor(i).SetSurfNr(-1); } } @@ -1079,7 +1079,23 @@ void BoundaryLayerTool ::AddSegments() { auto& new_segs = insert_only_volume_elements ? new_segments_on_moved_bnd : new_segments; - // cout << "add new segs " << endl << new_segs << endl; + + if (params.disable_curving) + { + for (auto& seg : segments) + if (is_edge_moved[seg.si]) + { + seg.epgeominfo[0].edgenr = -1; + seg.epgeominfo[0].edgenr = -1; + } + + for (auto& seg : new_segs) + { + seg.epgeominfo[0].edgenr = -1; + seg.epgeominfo[0].edgenr = -1; + } + } + if (have_single_segments) MergeAndAddSegments(mesh, segments, new_segs); else @@ -1264,6 +1280,8 @@ void BoundaryLayerTool ::ProcessParameters() void BoundaryLayerTool ::Perform() { + if (domains.NumSet() == 0) + return; CreateNewFaceDescriptors(); CalculateGrowthVectors(); CreateFaceDescriptorsSides(); @@ -1288,6 +1306,7 @@ void BoundaryLayerTool ::Perform() if (params.limit_growth_vectors) LimitGrowthVectorLengths(); + FixEdges(); FixSurfaceElements(); for (auto [pi, data] : growth_vector_map) diff --git a/libsrc/meshing/boundarylayer.hpp b/libsrc/meshing/boundarylayer.hpp index 679dc0ba..e01d14e7 100644 --- a/libsrc/meshing/boundarylayer.hpp +++ b/libsrc/meshing/boundarylayer.hpp @@ -90,6 +90,7 @@ public: void InterpolateSurfaceGrowthVectors (); void InterpolateGrowthVectors (); void LimitGrowthVectorLengths (); + void FixEdges (); void FixSurfaceElements (); void InsertNewElements (FlatArray>, SegmentIndex> segmap, const BitArray& in_surface_direction); diff --git a/libsrc/meshing/boundarylayer_interpolate.cpp b/libsrc/meshing/boundarylayer_interpolate.cpp index 20e2cfdf..229fb0c9 100644 --- a/libsrc/meshing/boundarylayer_interpolate.cpp +++ b/libsrc/meshing/boundarylayer_interpolate.cpp @@ -365,6 +365,13 @@ void BoundaryLayerTool ::InterpolateSurfaceGrowthVectors() addGW(pi, corrections[pi]); } +void BoundaryLayerTool ::FixEdges() +{ + for (auto& seg : mesh.LineSegments()) + if (seg.epgeominfo[0].edgenr == -1 && seg.epgeominfo[1].edgenr == -1) + seg.edgenr = -1; +} + void BoundaryLayerTool ::FixSurfaceElements() { static Timer tall("FixSurfaceElements"); diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index 728ac06a..cb613a8d 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -2961,7 +2961,7 @@ namespace netgen ost << "\n grow_edges: " << mp.grow_edges; ost << "\n limit_growth_vectors: " << mp.limit_growth_vectors; ost << "\n sides_keep_surfaceindex: " << (mp.sides_keep_surfaceindex ? ToString(*mp.sides_keep_surfaceindex) : "nullopt"); - ost << "\n keep_surfaceindex: " << mp.keep_surfaceindex; + ost << "\n disable_curving: " << mp.disable_curving; ost << endl; return ost; } diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index 926c1411..c1972c62 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -1285,7 +1285,7 @@ namespace netgen bool grow_edges = true; bool limit_growth_vectors = true; std::optional sides_keep_surfaceindex = nullopt; // !outside by default - bool keep_surfaceindex = false; + bool disable_curving = true; // disable curving affected boundaries/edges (could lead to self-intersecting volume elements) }; diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index 4df733db..c5e1a61d 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -1477,7 +1477,7 @@ py::arg("point_tolerance") = -1.) optional>> project_boundaries, bool grow_edges, bool limit_growth_vectors, bool sides_keep_surfaceindex, - bool keep_surfaceindex) + bool disable_curving) { BoundaryLayerParameters blp; blp.boundary = boundary; @@ -1489,13 +1489,13 @@ py::arg("point_tolerance") = -1.) blp.grow_edges = grow_edges; blp.limit_growth_vectors = limit_growth_vectors; blp.sides_keep_surfaceindex = sides_keep_surfaceindex; - blp.keep_surfaceindex = keep_surfaceindex; + blp.disable_curving = disable_curving; GenerateBoundaryLayer (self, blp); self.UpdateTopology(); }, py::arg("boundary"), py::arg("thickness"), py::arg("material")=nullopt, 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("keep_surfaceindex")=false, "Add boundary layer to mesh. see help(BoundaryLayerParameters) for details.") + py::arg("disable_curving")=true, "Add boundary layer to mesh. see help(BoundaryLayerParameters) for details.") .def_static ("EnableTableClass", [] (string name, bool set) { @@ -1732,7 +1732,7 @@ py::arg("point_tolerance") = -1.) bool grow_edges, bool limit_growth_vectors, std::optional sides_keep_surfaceindex, - bool keep_surfaceindex) + bool disable_curving) { BoundaryLayerParameters blp; blp.boundary = boundary; @@ -1744,14 +1744,14 @@ py::arg("point_tolerance") = -1.) blp.grow_edges = grow_edges; blp.limit_growth_vectors = limit_growth_vectors; blp.sides_keep_surfaceindex = sides_keep_surfaceindex; - blp.keep_surfaceindex = keep_surfaceindex; + blp.disable_curving = disable_curving; return blp; }), py::arg("boundary"), py::arg("thickness"), py::arg("new_material")=nullopt, py::arg("domain") = ".*", 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")=nullopt, - py::arg("keep_surfaceindex")=false, + py::arg("disable_curving")=true, R"delimiter( Add boundary layer to mesh. @@ -1803,7 +1803,7 @@ project_boundaries : Optional[str] = None .def_readwrite("grow_edges", &BoundaryLayerParameters::grow_edges) .def_readwrite("limit_growth_vectors", &BoundaryLayerParameters::limit_growth_vectors) .def_readwrite("sides_keep_surfaceindex", &BoundaryLayerParameters::sides_keep_surfaceindex) - .def_readwrite("keep_surfaceindex", &BoundaryLayerParameters::keep_surfaceindex) + .def_readwrite("disable_curving", &BoundaryLayerParameters::disable_curving) ; py::implicitly_convertible();