GenerateVolumeMesh() error after merging two meshes.

More
5 years 3 months ago #1766 by OCCUser
Hello,
May be you have experience with merging multiple meshes. After merging two meshes when I do GenerateVolumeMesh I have an error "netgen.libngpy._meshing.NgException: Stop meshing since boundary mesh is overlapping".
Could you please tell me what I am doing wrong?
When one cube is inside another it works, but when they intersect by edge or surface i have this error.
Thanks,
Code:
from netgen.occ import * from netgen import meshing from netgen.meshing import Mesh, FaceDescriptor, Element3D,Element2D, Element1D geo1 = OCCGeometry("merge_cube1.step") m1 = geo1.GenerateMesh (maxh=1, minh=0.5, perfstepsend= meshing.MeshingStep.MESHSURFACE) geo2 = OCCGeometry("merge_cube2.step") m2 = geo2.GenerateMesh (maxh=1, minh=0.5, perfstepsend= meshing.MeshingStep.MESHSURFACE) print ("***************************") print ("** merging suface meshes **") print ("***************************") # create an empty mesh mesh = Mesh() # a face-descriptor stores properties associated with a set of surface elements # bc .. boundary condition marker, # domin/domout .. domain-number in front/back of surface elements (0 = void), # surfnr .. number of the surface described by the face-descriptor fd_outside = mesh.Add (FaceDescriptor(bc=1,domin=1,surfnr=1)) fd_inside = mesh.Add (FaceDescriptor(bc=2,domin=2,domout=1,surfnr=2)) # copy all boundary points from first mesh to new mesh. # pmap1 maps point-numbers from old to new mesh pmap1 = { } for e in m1.Elements2D(): for v in e.vertices: if (v not in pmap1): pmap1[v] = mesh.Add (m1[v]) # copy surface elements from first mesh to new mesh # we have to map point-numbers: for e in m1.Elements2D(): mesh.Add(Element2D (fd_outside, [pmap1[v] for v in e.vertices])) # same for the second mesh: pmap2 = { } for e in m2.Elements2D(): for v in e.vertices: if (v not in pmap2): pmap2[v] = mesh.Add (m2[v]) for e in m2.Elements2D(): mesh.Add (Element2D (fd_inside, [pmap2[v] for v in e.vertices])) print ("******************") print ("** merging done **") print ("******************") mesh.GenerateVolumeMesh()
More
5 years 3 months ago #1767 by christopher
Merging of intersecting meshes is not supported in Netgen. But you could use Netgen in Salome for this. Afaik they have some tools to glue intersecting surface meshes. You could glue the geometry there as well and use their Netgen integration to mesh it.

Salome is licensed under the same (LGPL) license as Netgen and free to download here: www.salome-platform.org/downloads/current-version
More
5 years 3 months ago #1768 by OCCUser
Thanks a lot for your answer.
Can I mesh geometry with multiple materials in it with Netgen? If yes, could you please show me an example.
Thanks
More
5 years 3 months ago - 5 years 3 months ago #1769 by christopher
Yes you can. You can specify volume groups and export the mesh then for example as a unv file. There are lots of tutorials for Salome available. You should then be able to load the mesh with the material definitions into NGSolve. Same for boundary groups.
Best
Christopher
Last edit: 5 years 3 months ago by christopher.
More
5 years 3 months ago #1770 by joachim
Hi OCCUser,

you can fuse your two solids within your cad tool (e.g. using py-occ), and load it as one geometry into Netgen. Then Netgen will generate one conforming mesh for the two materials.

Just thinking whether we should also provide a fuse operation in our Netgen-OCC python interface.

Joachim
More
5 years 3 months ago #1771 by OCCUser
Actually i do fuse operation for my geometry, but i do not know how to create volume group, to know which element belongs to which material.
Thanks
Time to create page: 0.102 seconds