diff --git a/libsrc/meshing/boundarylayer.cpp b/libsrc/meshing/boundarylayer.cpp index 8fe6f31e..bc005da4 100644 --- a/libsrc/meshing/boundarylayer.cpp +++ b/libsrc/meshing/boundarylayer.cpp @@ -1145,6 +1145,11 @@ struct GrowthVectorLimiter { moved_surfaces.SetBit(i); mesh.SetBCName(new_si-1, "mapped_" + name); } + // curving of surfaces with boundary layers will often + // result in pushed through elements, since we do not (yet) + // curvature through layers. + // Therefore we disable curving for these surfaces. + mesh.GetFaceDescriptor(i).SetSurfNr(-1); } } @@ -1782,6 +1787,9 @@ struct GrowthVectorLimiter { if(surfacefacs[sel.GetIndex()] > 0) Swap(points[0], points[2]); for(auto i : Range(points)) el[sel.PNums().Size() + i] = points[i]; + auto new_index = new_mat_nrs[sel.GetIndex()]; + if(new_index == -1) + throw Exception("Boundary " + ToString(sel.GetIndex()) + " with name " + mesh.GetBCName(sel.GetIndex()-1) + " extruded, but no new material specified for it!"); el.SetIndex(new_mat_nrs[sel.GetIndex()]); if(add_volume_element) mesh.AddVolumeElement(el); diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index bd265ca7..6908fe5f 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -633,8 +633,12 @@ public: { TopoDS_Wire wire = wires.back(); wires.pop_back(); - BRepOffsetAPI_MakeOffset builder; - builder.AddWire(wire); + + // handle wires containing a single edge correctly, see + // https://dev.opencascade.org/content/brepoffsetapimakeoffset-open-topodswire + BRepBuilderAPI_MakeFace makeFace{gp_Pln{axes}}; + makeFace.Add(wire); + BRepOffsetAPI_MakeOffset builder(makeFace.Face()); builder.Perform(d); auto shape = builder.Shape(); wires.push_back (TopoDS::Wire(shape.Reversed())); diff --git a/libsrc/visualization/vssolution.cpp b/libsrc/visualization/vssolution.cpp index ac70842e..84cd31ee 100644 --- a/libsrc/visualization/vssolution.cpp +++ b/libsrc/visualization/vssolution.cpp @@ -2308,6 +2308,8 @@ namespace netgen for (sei = 0; sei < nse; sei++) { const Element2d & el = (*mesh)[sei]; + if(!SurfaceElementActive(vsol, *mesh, el)) + continue; if (el.GetType() == TRIG || el.GetType() == TRIG6) { diff --git a/python/read_gmsh.py b/python/read_gmsh.py index 23a7ec52..1b57144e 100644 --- a/python/read_gmsh.py +++ b/python/read_gmsh.py @@ -22,7 +22,10 @@ def ReadGmsh(filename): pointmap = {} facedescriptormap = {} - namemap = { 0 : "default" } + namemap = { 0 : { 0 : "default" }, + 1: { 0 : "default" }, + 2: { 0 : "default" }, + 3: { 0 : "default" } } materialmap = {} bbcmap = {} @@ -80,7 +83,7 @@ def ReadGmsh(filename): for i in range(numnames): f.readline line = f.readline() - namemap[int(line.split()[1])] = line.split()[2][1:-1] + namemap[int(line.split()[0])][int(line.split()[1])] = line.split()[2][1:-1] if line.split()[0] == "$Nodes": num = int(f.readline().split()[0]) @@ -115,7 +118,7 @@ def ReadGmsh(filename): else: index = len(bbcmap) + 1 if len(namemap): - mesh.SetCD2Name(index, namemap[tags[0]]) + mesh.SetCD2Name(index, namemap[1][tags[0]]) else: mesh.SetCD2Name(index, "line" + str(tags[1])) bbcmap[tags[1]] = index @@ -127,7 +130,7 @@ def ReadGmsh(filename): index = len(facedescriptormap) + 1 fd = FaceDescriptor(bc=index) if len(namemap): - fd.bcname = namemap[tags[0]] + fd.bcname = namemap[1][tags[0]] else: fd.bcname = 'line' + str(tags[1]) mesh.SetBCName(index - 1, fd.bcname) @@ -139,7 +142,7 @@ def ReadGmsh(filename): else: index = len(materialmap) + 1 if len(namemap): - mesh.SetMaterial(index, namemap[tags[0]]) + mesh.SetMaterial(index, namemap[1][tags[0]]) else: mesh.SetMaterial(index, "line" + str(tags[1])) materialmap[tags[1]] = index @@ -154,7 +157,7 @@ def ReadGmsh(filename): index = len(facedescriptormap) + 1 fd = FaceDescriptor(bc=index) if len(namemap): - fd.bcname = namemap[tags[0]] + fd.bcname = namemap[2][tags[0]] else: fd.bcname = "surf" + str(tags[1]) mesh.SetBCName(index - 1, fd.bcname) @@ -166,7 +169,7 @@ def ReadGmsh(filename): else: index = len(materialmap) + 1 if len(namemap): - mesh.SetMaterial(index, namemap[tags[0]]) + mesh.SetMaterial(index, namemap[2][tags[0]]) else: mesh.SetMaterial(index, "surf" + str(tags[1])) materialmap[tags[1]] = index @@ -187,7 +190,7 @@ def ReadGmsh(filename): else: index = len(materialmap) + 1 if len(namemap): - mesh.SetMaterial(index, namemap[tags[0]]) + mesh.SetMaterial(index, namemap[3][tags[0]]) else: mesh.SetMaterial(index, "vol" + str(tags[1])) materialmap[tags[1]] = index diff --git a/python/webgui.py b/python/webgui.py index 4886c320..494c545b 100644 --- a/python/webgui.py +++ b/python/webgui.py @@ -189,7 +189,7 @@ def GetData(mesh, args, kwargs): for i, el in enumerate(mesh.Elements2D()): pnts[i, :, 3] = el.index - 1 fds = mesh.FaceDescriptors() - d["colors"] = [fd.color for fd in fds] + d["colors"] = [fd.color +(fd.transparency,) for fd in fds] d["mesh_regions_2d"] = len(fds) d["names"] = [fd.bcname for fd in fds] @@ -222,6 +222,17 @@ class WebGLScene(base): self.kwargs = kwargs self.encoding = "b64" + def Redraw(self, *args, **kwargs): + if args or kwargs: + if 'show' not in kwargs: + kwargs['show'] = False + + new_scene = Draw(*args, **kwargs) + self.obj = new_scene.obj + self.args = new_scene.args + self.kwargs = new_scene.kwargs + super().Redraw() + def GetData(self, set_minmax=True): self.kwargs["encoding"] = self.encoding typ = type(self.obj) @@ -361,12 +372,12 @@ def _get_draw_default_args(): ) -def Draw(obj, *args, **kwargs): +def Draw(obj, *args, show=True, **kwargs): kwargs_with_defaults = _get_draw_default_args() kwargs_with_defaults.update(kwargs) scene = WebGLScene(obj, args, kwargs_with_defaults) - if wg is not None and wg._IN_IPYTHON: + if show and wg is not None and wg._IN_IPYTHON: if wg._IN_GOOGLE_COLAB: from IPython.display import display, HTML