# [Gmsh] Sphere in a sphere mesh

Christophe Geuzaine cgeuzaine at uliege.be
Wed Mar 4 10:35:26 CET 2020

```
> On 4 Mar 2020, at 09:25, Silvia Ceccacci (HDR) <silvia.ceccacci at hdr.mq.edu.au> wrote:
>
> Dear all,
>
> I would like to generate a geometry where I have a bigger sphere (radius=3) and a smaller one inside it (radius=1). Then I want to generate a 3D mesh without the sphere inside (so there is a hole in the middle of the bigger sphere).
>
> I am trying two different approaches, but none of them seem to work:
>
> 1) BooleanDifference - I want to take away the smaller sphere from the bigger one. This is the code:
>
> Sphere(1) = {0, 0, 0, 1, -Pi/2, Pi/2, 2*Pi};
> Sphere(2) = {0, 0, 0, 3, -Pi/2, Pi/2, 2*Pi};
> BooleanDifference{ Volume{2}; Delete; }{ Volume{1}; Delete; }
>
> but it does not do it. Could you explain why, please?

>
> 2) Extrude - I generate a half annulus (with the first Extrude), then I want to extrude it in rotation (2*Pi) to generate the same geometry, sphere in a sphere. This is the code:
>
> Point(1) = {1, 0, 0, 1.0};
> Point(2) = {2, 0, 0, 1.0};
> Line(1) = {1, 2};
> //+
> Extrude {{0, 0, 1}, {0, 0, 0}, Pi} {
> Line{1};Layers{8};Recombine;
> }
> //+
> Extrude {{1, 0, 0}, {0, 0, 0}, Pi} {
> Surface{5};Layers{8};Recombine;
> }
>
> but again, the second Extrude does not do it. Could you explain why, please?
>

With the built-in kernel extrusions are limited to angles < Pi. You can do full 2*Pi extrude with OpenCASCADE:

Point(1) = {1, 0, 0, 1.0};
Point(2) = {2, 0, 0, 1.0};
Line(1) = {1, 2};
Extrude {{0, 0, 1}, {0, 0, 0}, Pi} { Line{1}; }
Extrude {{1, 0, 0}, {0, 0, 0}, 2*Pi} { Surface{1}; }

But you cannot use "Layers" in that case (because OpenCASCADE removes the seam surface. With "Layers" you'll need to extrude twice.)

Christophe

> Could you tell me how to do it, please?
>
> Thank you.
>
> Kind regards,
> Silvia
>
>
> _______________________________________________
> 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

```