# [Gmsh] Problem with meshing making a volume in a volume

Christophe Geuzaine cgeuzaine at ulg.ac.be
Mon Sep 25 22:30:12 CEST 2017

> On 20 Sep 2017, at 13:07, Richard Veazey <richvea at hotmail.com> wrote:
>
> Good Afternoon,
>
> I am having issues with meshing a certain model. The model is a cube within a cube, however the smaller cube is not fully contained within the larger cube. Instead, only one of the surfaces of the smaller cube can be seen (see image attached, this shows a clip of the model). Each cube is then defined as a separate volume, so 2 volumes - Large cube minus the small cube (blue in image), and small cube (red in image).
>
> The problem I am having is when both volumes are present, the meshing isn’t working for me. The surface mesh looks fine, but the volume mesh is too coarse. I can mesh both volumes independently ok. However when both volumes are present the meshing isn’t working. Below is the script I have used. I first define all the planes that make up the small cube. Then I define the planes to make the larger volume (large cube - small cube). Note that Plane Surface(41) is where the top surface of the small cube is subtracted. The large volume is then made, and then the small cube.
>

Why not simply:

Lc1 = 0.05;
Lc2 = 0.5;
Point(1)={0.5,0.5,0, Lc1};
Point(2)={0.5,1.5,0, Lc1};
Point(3)={1.5,1.5,0, Lc1};
Point(4)={1.5,0.5,0, Lc1};
Line(1)={1,2};
Line(2)={2,3};
Line(3)={3,4};
Line(4)={4,1};
Line Loop(1)={1,2,3,4};
Plane Surface(1)={1};
Point(5)={0.5,0.5,1, Lc1};
Point(6)={0.5,1.5,1, Lc1};
Point(7)={1.5,1.5,1, Lc1};
Point(8)={1.5,0.5,1, Lc1};
Line(5)={5,6};
Line(6)={6,7};
Line(7)={7,8};
Line(8)={8,5};
Line Loop(2)={5,6,7,8};
Plane Surface(2)={2};
Line(9)={1,5};
Line(10)={6,2};
Line(11)={2,1};
Line Loop(3)={9,5,10,11};
Plane Surface(3)={3};
Line(12)={3,7};
Line(13)={7,6};
Line Loop(4)={2,12,13,10};
Plane Surface(4)={4};
Line(14)={8,4};
Line(15)={4,3};
Line Loop(5)={12,7,14,15};
Plane Surface(5)={5};
Line(16)={5,8};
Line Loop(6)={14,4,9,16};
Plane Surface(6)={6};

Point(41)={0.1,0.1,0, Lc2};
Point(42)={0.1,1.9,0, Lc2};
Point(43)={1.9,1.9,0, Lc2};
Point(44)={1.9,0.1,0, Lc2};
Line(41)={41,42};
Line(42)={42,43};
Line(43)={43,44};
Line(44)={44,41};
Line Loop(41)={41,42,43,44};
Plane Surface(41)={41,-1};
Point(45)={0.1,0.1,1.1, Lc2};
Point(46)={0.1,1.9,1.1, Lc2};
Point(47)={1.9,1.9,1.1, Lc2};
Point(48)={1.9,0.1,1.1, Lc2};
Line(45)={45,46};
Line(46)={46,47};
Line(47)={47,48};
Line(48)={48,45};
Line Loop(42)={45,46,47,48};
Plane Surface(42)={42};
Line(49)={41,45};
Line(50)={46,42};
Line(51)={42,41};
Line Loop(43)={49,45,50,51};
Plane Surface(43)={43};
Line(52)={43,47};
Line(53)={47,46};
Line Loop(44)={42,52,53,50};
Plane Surface(44)={44};
Line(54)={48,44};
Line(55)={44,43};
Line Loop(45)={52,47,54,55};
Plane Surface(45)={45};
Line(56)={45,48};
Line Loop(46)={54,44,49,56};
Plane Surface(46)={46};
Surface Loop(1)={41,42,43,44,45,46,2,3,4,5,6};
Volume(1)={1};
Physical Volume(1)={1};

Surface Loop(2)={1,2,3,4,5,6};
Volume(2)={2};
Physical Volume(2)={2};
Coherence;

?

> Geometry.AutoCoherence=0;
> Lc1 = 0.05;
> Lc2 = 0.5;
> Point(1)={0.5,0.5,0, Lc1};
> Point(2)={0.5,1.5,0, Lc1};
> Point(3)={1.5,1.5,0, Lc1};
> Point(4)={1.5,0.5,0, Lc1};
> Line(1)={1,2};
> Line(2)={2,3};
> Line(3)={3,4};
> Line(4)={4,1};
> Line Loop(1)={1,2,3,4};
> Plane Surface(1)={1};
> Point(5)={0.5,0.5,1, Lc1};
> Point(6)={0.5,1.5,1, Lc1};
> Point(7)={1.5,1.5,1, Lc1};
> Point(8)={1.5,0.5,1, Lc1};
> Line(5)={5,6};
> Line(6)={6,7};
> Line(7)={7,8};
> Line(8)={8,5};
> Line Loop(2)={5,6,7,8};
> Plane Surface(2)={2};
> Line(9)={1,5};
> Line(10)={6,2};
> Line(11)={2,1};
> Line Loop(3)={9,5,10,11};
> Plane Surface(3)={3};
> Line(12)={3,7};
> Line(13)={7,6};
> Line Loop(4)={2,12,13,10};
> Plane Surface(4)={4};
> Line(14)={8,4};
> Line(15)={4,3};
> Line Loop(5)={12,7,14,15};
> Plane Surface(5)={5};
> Line(16)={5,8};
> Line Loop(6)={14,4,9,16};
> Plane Surface(6)={6};
>
> Point(41)={0.1,0.1,0, Lc2};
> Point(42)={0.1,1.9,0, Lc2};
> Point(43)={1.9,1.9,0, Lc2};
> Point(44)={1.9,0.1,0, Lc2};
> Line(41)={41,42};
> Line(42)={42,43};
> Line(43)={43,44};
> Line(44)={44,41};
> Line Loop(41)={41,42,43,44};
> Plane Surface(41)={41,-1};
> Point(45)={0.1,0.1,1.1, Lc2};
> Point(46)={0.1,1.9,1.1, Lc2};
> Point(47)={1.9,1.9,1.1, Lc2};
> Point(48)={1.9,0.1,1.1, Lc2};
> Line(45)={45,46};
> Line(46)={46,47};
> Line(47)={47,48};
> Line(48)={48,45};
> Line Loop(42)={45,46,47,48};
> Plane Surface(42)={42};
> Line(49)={41,45};
> Line(50)={46,42};
> Line(51)={42,41};
> Line Loop(43)={49,45,50,51};
> Plane Surface(43)={43};
> Line(52)={43,47};
> Line(53)={47,46};
> Line Loop(44)={42,52,53,50};
> Plane Surface(44)={44};
> Line(54)={48,44};
> Line(55)={44,43};
> Line Loop(45)={52,47,54,55};
> Plane Surface(45)={45};
> Line(56)={45,48};
> Line Loop(46)={54,44,49,56};
> Plane Surface(46)={46};
> Surface Loop(1)={41,42,43,44,45,46,2,3,4,5,6};
> Volume(1)={1};
> Physical Volume(1)={1};
>
> Surface Loop(2)={1,2,3,4,5,6};
> Volume(2)={2};
> Physical Volume(2)={2};
>
> Field[1] = MathEval;
> Field[1].F = "0.5";
> Field[2] = Restrict;
> Field[2].IField = 1;
> Field[2].RegionsList = {1};
> Field[3] = MathEval;
> Field[3].F = "0.5";
> Field[4] = Restrict;
> Field[4].IField = 3;
> Field[4].EdgesList = {41:56};
> Field[4].FacesList = {41:46};
>
> Field[5] = MathEval;
> Field[5].F = "0.05";
> Field[6] = Restrict;
> Field[6].IField = 5;
> Field[6].RegionsList = {2};
> Field[7] = MathEval;
> Field[7].F = "0.05";
> Field[8] = Restrict;
> Field[8].IField = 7;
> Field[8].EdgesList = {1:16};
> Field[8].FacesList = {1:6};
>
> Field[9] = Min;
> Field[9].FieldsList = {2,4,6,8};
> Background Field = 9;
> Mesh.CharacteristicLengthExtendFromBoundary = 0.;
> Coherence;
>
>
> Any help you may be able to give me would be greatly appreciated.
>
> Kind Regards,
>
> Richard
>
> <Volume_in_a_volume.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