[Gmsh] Gmsh curved surface

Christophe Geuzaine cgeuzaine at uliege.be
Fri Jun 8 02:22:25 CEST 2018



> On 7 Jun 2018, at 23:08, Caoimhe Rooney <rooney at maths.ox.ac.uk> wrote:
> 
> Hi there,
> 
> I am having some difficulty meshing up a truncated sphere geometry. Google is telling me a lot about an old feature “ruled surface” that worked in the past, and I believe that “surface filling” might be the replacement

The "Surface" command in recent versions does behave in the same way as the old "Ruled Surface" command with the "Built-in" geometry kernel: it will create a (part of a) sphere if all the control points are co-spherical. My guess is that you are using the new "OpenCASCADE" kernel, in which "Surface" does a more general, but generic b-spline filling - so you won't get a sphere patch.

With the OpenCASCADE kernel you should really use the constructive solid geometry features. For example, you could create your geometry as follows in a .geo file:

*** test.geo ***
SetFactory("OpenCASCADE");
R = 1;
R1 = 0.95;
Sphere(1) = {0,0,0, R, 0, Pi/2, Pi/2};
Box(2) = {R1,0,0, R,R,R};
Box(3) = {0,R1,0, R,R,R};
Box(4) = {0,0,R1, R,R,R};
BooleanDifference{ Volume{1}; Delete; }{ Volume{2:4}; Delete; }
Delete{ Volume{1}; }
Recursive Delete{ Surface{2,4,6}; }
***

If you want to generate your geometry in Python, I really recommend using the new Gmsh Python API. Download the binary software development kit (SDK) from the website; then you can do this in a Python script:

*** test.py ***
import gmsh
import sys
import math
gmsh.initialize(sys.argv)
gmsh.model.add("sphere_cut")
R = 1
R1 = 0.95
sph = gmsh.model.occ.addSphere(0,0,0, R, -1, 0, math.pi/2, math.pi/2)
b1 = gmsh.model.occ.addBox(R1,0,0, R,R,R)
b2 = gmsh.model.occ.addBox(0,R1,0, R,R,R)
b3 = gmsh.model.occ.addBox(0,0,R1, R,R,R)
gmsh.model.occ.cut([(3,sph)], [(3,b1), (3,b2), (3,b3)])
gmsh.model.occ.synchronize()
gmsh.model.removeEntities([(3,sph)])
gmsh.model.removeEntities([(2,2), (2,4), (2,6)], True)
gmsh.fltk.run()
gmsh.finalize()
***

And you could do the same in Julia :

*** test.jl ***
import gmsh
gmsh.initialize(ARGS)
gmsh.model.add("sphere_cut")
R = 1
R1 = 0.95
sph = gmsh.model.occ.addSphere(0,0,0, R, -1, 0, pi/2, pi/2)
b1 = gmsh.model.occ.addBox(R1,0,0, R,R,R)
b2 = gmsh.model.occ.addBox(0,R1,0, R,R,R)
b3 = gmsh.model.occ.addBox(0,0,R1, R,R,R)
gmsh.model.occ.cut([(3,sph)], [(3,b1), (3,b2), (3,b3)])
gmsh.model.occ.synchronize()
gmsh.model.removeEntities([(3,sph)])
gmsh.model.removeEntities([(2,2), (2,4), (2,6)], true)
gmsh.fltk.run()
gmsh.finalize()
***

Christophe


> , but I’m really struggling to get a sensible result. I have attached some pictures of my geometry frame, and I would like to have a 3D mesh of this shape. I am generating this through pygmsh, but do not know how to proceed with defining the surfaces, in particular the curved surfaces, and hence the volume. 
> 
> I would be so grateful if someone could advise me how to do this.
> 
> Many thanks,
> Caoimhe 
> 
> <PastedGraphic-1.png>	<PastedGraphic-2.png><PastedGraphic-3.png>
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh

— 
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science 
http://www.montefiore.ulg.ac.be/~geuzaine

Free software: http://gmsh.info | http://getdp.info | http://onelab.info




More information about the gmsh mailing list