Mesh a cube with a sphere on the side

Maybe you could use Gmsh instead.

SetFactory('OpenCASCADE');
Box(1) = {-1.0,-1.0,-1.0, 2, 2, 2};
Sphere(2) = {0.9999,1,1, 0.5};
BooleanFragments{ Volume{1,2}; Delete; }{}
Characteristic Length{ PointsOf{ Volume{1}; } } = 0.1;
Characteristic Length{ PointsOf{ Volume{3}; } } = 0.1;
Characteristic Length{ PointsOf{ Volume{2}; } } = 0.1;

Then, to do the actual meshing.

gmsh -3 cube-sphere.geo -format mesh

Finally, the .edp.

// gmsh -3 cube-sphere.geo -format mesh

load "msh3"
load "medit"

mesh3 Th = readmesh3("cube-sphere.mesh");
fespace Vh(Th, P1);
Vh u = x + y + z;

medit("Th", Th, u);

1 Like