Merge "File_1.vtk";
Merge "File_2.vtk";
Merge "File_3.vtk";
Merge "File_4.vtk";
Merge "File_5.vtk";
Merge "File_6.vtk";
Merge "File_7.vtk";


Mesh.CharacteristicLengthMax = .900;
Mesh.CharacteristicLengthMin = .900;

// Trouble shoot : Mesh.CharacteristicLengthFactor

CharacteristicLengthFromCurvature = 1;
Mesh.Algorithm    = 6; // (1=MeshAdapt, 2=Automatic, 5=Delaunay, 6=Frontal, 7=bamg, 8=delquad) (Default=2)
Mesh.RecombineAll = 0; // Apply recombination algorithm to all surfaces, ignoring per-surface spec (Default 0)

//Default Values
Mesh.Optimize = 1; // Optimize quality of tetrahedral elements
Mesh.OptimizeNetgen = 1; //Optimize the mesh using Netgen to improve the quality of tetrahedral elements , Default value: 0

// refine by subdivision to improve the reparametrization
RefineMesh;
RefineMesh;
//RefineMesh;
//RefineMesh;
//RefineMesh;

Mesh.SurfaceFaces = 1; // Only for mesh display in the GUI
CreateTopology;

ll[] = Line "*";
ss[] = Surface "*";

// DEBUG - print length of lines and surfaces arrays
Nl = #ll[];
Printf("length L= %f",Nl); //No Lines ?
Ns = #ss[];
Printf("length S= %f",Ns); // 7 surfaces

// DEBUG - print length of lines and surfaces arrays
Nl = #ll[];
Printf("length L= %f",Nl); //No Lines ?
Ns = #ss[];
Printf("length S= %f",Ns); // 7 surfaces

// Defining compound Lines
//Compound Line{ll[0]};
//Compound Line{ll[1]};
//Compound Line{ll[2]};
//Physical Line("EPI_BASE") ={ll[0], ll[1], ll[2]};

// New way of defining Compound surfaces (version 4.5.4)
Compound Surface{ss[0]}; //File 1
Compound Surface{ss[1]}; //File 2
Compound Surface{ss[2]}; //File 3
// Give names to these
Physical Surface("A") = {ss[0]};
Physical Surface("B") = {ss[1]};
Physical Surface("C") = {ss[2]};

//Create the Base
Compound Surface{ss[3]}; //File 4
Compound Surface{ss[4]}; //File 5
Compound Surface{ss[5]}; //File 6
Compound Surface{ss[6]}; //File 7
// Give names to these
Physical Surface("D") = {ss[3]};
Physical Surface("E") = {ss[4]};
Physical Surface("F") = {ss[5]};
Physical Surface("G") = {ss[6]};
// Create a union of several surfaces 
Physical Surface("Union") = {ss[3], ss[4], ss[5], ss[6]};


// Create the volume consisting of the firt three files
Surface Loop(1) = {ss[0]}; //A
Surface Loop(2) = {ss[1]}; //B
Surface Loop(3) = {ss[2]}; //C

// Surfaces associated to the union surface (composites)
Surface Loop(4) = {ss[3]}; //D
Surface Loop(5) = {ss[4]}; //E
Surface Loop(6) = {ss[5]}; //F
Surface Loop(7) = {ss[6]}; //G

//Volume(1) = {1, 2, 3}; // Decide what you want to be part of the volume
Volume(1) = {1, 2, 3, 4, 5, 6,7};

Physical Volume("WALL") = {1};

// Adjust geo tolerance for correct merge result (avoid facet intersections)
Geometry.Tolerance = 1e-10;
//Difference Chorence mesh and coherence?
// remove duplicate vertices (will make surface mesh watertight)
Coherence; // in older versions: //Coherence Mesh;
// Change the Mesh File Version
Mesh.MshFileVersion = 2.2;
