//+
SetFactory("OpenCASCADE");

Mesh.CharacteristicLengthMin = 0.001;
Mesh.CharacteristicLengthMax = 2.0;

Mesh.CharacteristicLengthExtendFromBoundary = 0;

Mesh.Algorithm = 6;
Mesh.Smoothing = 3;
Mesh.Algorithm3D = 1;

Box(1) = {0, -0.5, -0.5, 1, 1, 1};
Box(2) = {-1, -0.5, -0.5, 1, 1, 1};

Coherence;

surfs_box1() = Unique(Abs(Boundary{ Volume{1}; } ));
lines_box1() = Unique(Abs(Boundary{ Surface{surfs_box1()}; } ));
pts_box1() = Unique(Abs(Boundary{ Line{lines_box1()}; } ));

surfs_box2() = Unique(Abs(Boundary{ Volume{2}; } ));
lines_box2() = Unique(Abs(Boundary{ Surface{surfs_box2()}; } ));
pts_box2() = Unique(Abs(Boundary{ Line{lines_box2()}; } ));

Field[1] = MathEval;
Field[1].F = "0.1";
Field[2] = Restrict;
Field[2].EdgesList = {lines_box1()};
Field[2].FacesList = {surfs_box1()};
Field[2].VerticesList = {pts_box1()};
Field[2].RegionsList = {1};
Field[3] = MathEval;
Field[3].F = "0.5";
Field[4] = Restrict;
Field[4].IField = 3;
Field[4].RegionsList = {2};
Field[4].EdgesList = {lines_box2()};
Field[4].FacesList = {surfs_box2()};
Field[4].VerticesList = {pts_box2()};
Field[5] = Min;
Field[5].FieldsList = {2, 4};

Background Field = 5;

