Gmsh get all Surfaces of a Volume

 Register Blogs Members List Search Today's Posts Mark Forums Read

February 8, 2019, 07:27
Gmsh get all Surfaces of a Volume
#1
New Member

Maximilian Köhler
Join Date: Feb 2019
Posts: 2
Rep Power: 0
Hey there,

I'm a new forum member and I would like to ask you, if you could help me out with the following problem:

I have a bcc lattice domain for the stokes equation and I'm trying to set up the domain with gmsh. For all spherical cavitys of the bcc lattice I would like to assign a physical surface to it, such that the FE-solver can handle those surfaces as a noslip cond.

Code:
```// Gmsh project created on Thu Feb  7 09:15:11 2019

half_length = 0.5774;
//+
Box(1) = {0, 0, 0, half_length, half_length, half_length};
//+
Sphere(2) = {half_length, half_length, half_length, 0.25, -Pi/2, Pi/2, 2*Pi};
//+
Sphere(3) = {half_length, half_length, 0, 0.25, -Pi/2, Pi/2, 2*Pi};
//+
Sphere(4) = {half_length, 0, 0, 0.25, -Pi/2, Pi/2, 2*Pi};
//+
Sphere(5) = {half_length, 0, half_length, 0.25, -Pi/2, Pi/2, 2*Pi};
//+
Sphere(6) = {0, 0, half_length, 0.25, -Pi/2, Pi/2, 2*Pi};
//+
Sphere(7) = {0, half_length, half_length, 0.25, -Pi/2, Pi/2, 2*Pi};
//+
Sphere(8) = {0, half_length, 0, 0.25, -Pi/2, Pi/2, 2*Pi};
//+
Sphere(9) = {0, 0, 0, 0.25, -Pi/2, Pi/2, 2*Pi};
//+
Sphere(10) = {half_length/2, half_length/2, half_length/2, 0.25, -Pi/2, Pi/2, 2*Pi};
//+
BooleanDifference{ Volume{1}; Delete; }{ Volume{10}; Volume{8}; Volume{9}; Volume{3}; Volume{4}; Volume{2}; Volume{5}; Volume{7}; Volume{6}; Delete; }
//+

//+
Translate {0, 0, half_length} {
Duplicata { Volume{1}; }
}
//+
Translate {half_length, 0, 0} {
Duplicata { Volume{2}; Volume{1}; }
}
//+
Translate {0, half_length, 0} {
Duplicata { Volume{4}; Volume{3}; Volume{2}; Volume{1}; }
}```
Is there a way to get the boundary surface of Spheres 1-10 without using the GUI?

Thanks in advance and kind regards
Attached Images
 domain.png (113.1 KB, 10 views)

 February 8, 2019, 13:13 Solution with API #2 New Member   Maximilian Köhler Join Date: Feb 2019 Posts: 2 Rep Power: 0 So, since I got frustrated with the Interface of Gmsh, I approached the API, which has a nice and clear documentation. My code to obtain everything marked and seperated. Maybe it is useful for others Code: ```import gmsh gmsh.initialize() gmsh.open("Mesh/symmetry_structure_gmsh.geo") gmsh.model.mesh.generate(3) gmsh.model.mesh.refine() gmsh.model.mesh.refine() gmsh.model.mesh.refine() entities = gmsh.model.getEntities() noslipboundary = [] boundary = [] dstuff = [] domain = [] points = [] for entity in entities: if gmsh.model.getType(entity[0],entity[1]) == 'Sphere' and entity[0] == 2: noslipboundary.append(entity[1]) elif gmsh.model.getType(entity[0],entity[1]) != 'Sphere' and entity[0] == 2: boundary.append(entity[1]) elif entity[0] == 3: domain.append(entity[1]) elif entity[0] == 1: dstuff.append(entity[1]) elif entity[0] == 0: points.append(entity[0]) gmsh.model.addPhysicalGroup(2,noslipboundary,3) gmsh.model.addPhysicalGroup(3,domain,2) gmsh.model.addPhysicalGroup(2,boundary,4) gmsh.model.addPhysicalGroup(1,dstuff,5) gmsh.model.addPhysicalGroup(0,dstuff,6) gmsh.model.setPhysicalName(3,1,"Domain") gmsh.model.setPhysicalName(2,2,"Boundary") gmsh.model.setPhysicalName(1,4,"1Dstuff") gmsh.model.setPhysicalName(2,3,"NoSlipBoundary") gmsh.model.setPhysicalName(0,5,"Points") gmsh.write("gmsh_api_symmetry_structure_gmsh.msh") gmsh.finalize()```

 Tags boundary, gmsh, mesh 3d, meshing, surface