Need help on creating an ellipsoid cavity inside a box

Hello, I am struggling with Gmsh, then I found I have coreform, thanks in advance if someone can help me.

I have a 5x5x5 box, and in the middle (2.5,2.5,2.5) of the box, I want to have an ellipsoid that has a = 0.03, b=0.03, and c=0.1. like in the picture

and the mesh is finer near the ellipsoid, and coarser gradually to the boundary. Also, I need to give a physical volume to the box (cavity inside) and a physical surface to the cavity, because later I need to choose them in third-party software to apply boundary conditions.

//this is my gmsh code
SetFactory("OpenCASCADE");
eps = 1e-5;
Block(1) = {0, 0, 0, 5, 5, 5};
Sphere(2) = {2.5, 2.5, 2.5, 1};
Dilate {{2.5, 2.5, 2.5}, {0.03, 0.03, 0.1}} { Volume{2}; }//this one used to scale the radius to a,b,and c

BooleanDifference(3) = { Volume{1}; Delete; }{ Volume{2}; Delete; }; //Box mins the ellipsoid

inner() = Surface In BoundingBox{2.5-0.03-eps,2.5-0.03-eps,2.5-0.1-eps, 2.5+0.03+eps, 2.5+0.03+eps, 2.5+0.1+eps};//This one is to define the surface I want

Physical Volume("my volume") = {2};
Physical Surface("my inner surface") = inner();

Mesh.MeshSizeFromCurvature = 30;
Mesh.MeshSizeMax = 0.2;

Gmsh works fine except cannot give me the physical surface of the cavity.

Hi @miraboreasu1,

Welcome to the Coreform Cubit forum. Here is a solution to your problem in Cubit.

reset
brick x 5
sphere radius 1
Volume 2 scale X .03  Y .03 Z .1 
subtract volume 2 from volume 1 keep_tool 
imprint all
merge all
volume all scheme tetmesh
volume 2 size auto factor 5
mesh vol all

#Graphics commands for the visualization below. These can also be done using the GUI
draw tet all
graphics clip on plane yz
graphics clip manipulation off

The one thing I will note is that scaling a sphere to the ellipsoid causes the surface to be approximated by a NURBS surface. As a result, the surface area is not exact.

One way to get the surface area is to select the ellipsoidal surface and click on the Surface Area property. This will bring up a calculator icon as shown in the image below.
image

The value that Cubit calculates for this spline approximation of the ellipsoidal surface is 0.0306725. This is very close the exact surface area of the ellipsoid.

Thanks,
Karl