Initializing OCCGeometry with different materials

More
2 years 8 months ago #4209 by sindresb
Dear community,

In continuation of my earlier post, I am still working on meshing 3D geometries with subdomains made from different materials. As a first test, I aim to mesh a stack of two cubes -- one made form steel and one made from foam. I have identified two approaches which I expected to work: 1) gluing the two boxes and initializing the OCCGeometry with the glued shape, and 2) initializing the OCCGeometry with a list containing the two boxes. However, only the first approach produces the expected output where the bottom cube has value 1 and the top cube has value 2 (see code below). Why does the second approach not work?

Best regards,
Sindre
Code:
from netgen import occ import ngsolve as ng from ngsolve.webgui import Draw from ngsolve.comp import BoundaryFromVolumeCF box1 = occ.Box(occ.Pnt(0,0,0), occ.Pnt(1,1,1)).mat("steel") box2 = occ.Box(occ.Pnt(0,0,1), occ.Pnt(1,1,2)).mat("foam") boxes = occ.Glue([box1, box2]) geo_init_glued_boxes  = occ.OCCGeometry(boxes) mesh_init_glued_boxes = ng.Mesh(geo_init_glued_boxes.GenerateMesh(maxh=0.2)) cf_init_glued_boxes   = mesh_init_glued_boxes.RegionCF(ng.VOL, {"steel":1, "foam":2}) Draw(BoundaryFromVolumeCF(cf_init_glued_boxes), mesh_init_glued_boxes) # Output visualization: bottom cube shown with value 1 and top cube shown with value 2 geo_init_list  = occ.OCCGeometry([box1, box2]) mesh_init_list = ng.Mesh(geo_init_list.GenerateMesh(maxh=0.2)) cf_init_list   = mesh_init_list.RegionCF(ng.VOL, {"steel":1, "foam":2}) Draw(BoundaryFromVolumeCF(cf_init_list), mesh_init_list) # Output visualization: both cubes shown with value 0.
Time to create page: 0.084 seconds