CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Special Topics > Mesh Generation & Pre-Processing

Gmsh get all Surfaces of a Volume

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 8, 2019, 07:27
Default Gmsh get all Surfaces of a Volume
  #1
New Member
 
Maximilian Köhler
Join Date: Feb 2019
Posts: 2
Rep Power: 0
mkoeh is on a distinguished road
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
Attached Images
File Type: png domain.png (113.1 KB, 3 views)
mkoeh is offline   Reply With Quote

Old   February 8, 2019, 13:13
Default Solution with API
  #2
New Member
 
Maximilian Köhler
Join Date: Feb 2019
Posts: 2
Rep Power: 0
mkoeh is on a distinguished road
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()
mkoeh is offline   Reply With Quote

Reply

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set periodic boundary conditions Ganesh FLUENT 14 November 26, 2018 11:26
alphaEqn.H in twoPhaseEulerFoam cheng1988sjtu OpenFOAM Bugs 15 May 1, 2016 16:12
[blockMesh] non-orthogonal faces and incorrect orientation? nennbs OpenFOAM Meshing & Mesh Conversion 7 April 17, 2013 05:42
[Gmsh] Import problem ARC OpenFOAM Meshing & Mesh Conversion 0 February 27, 2010 10:56
GMSH: Volume of two intersecting cubes shangzung Main CFD Forum 1 October 10, 2009 09:34


All times are GMT -4. The time now is 16:02.