CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Mesh Generation & Pre-Processing (https://www.cfd-online.com/Forums/mesh-generation/)
-   -   Gmsh get all Surfaces of a Volume (https://www.cfd-online.com/Forums/mesh-generation/214645-gmsh-get-all-surfaces-volume.html)

 mkoeh February 8, 2019 08:27

Gmsh get all Surfaces of a Volume

1 Attachment(s)
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 SetFactory("OpenCASCADE"); 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

 mkoeh February 8, 2019 14:13

Solution with API

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,entity) == 'Sphere' and entity == 2:         noslipboundary.append(entity)     elif gmsh.model.getType(entity,entity) != 'Sphere' and entity == 2:         boundary.append(entity)     elif entity == 3:         domain.append(entity)     elif entity == 1:         dstuff.append(entity)     elif entity == 0:         points.append(entity) 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()```

 All times are GMT -4. The time now is 08:39.