//-*- C++ -*-

//!@file

//!This file generates a pipe with fluid and structure part. The mesh is almost
//!structured. It is useful when doing weak scalability tests, playing with the 
//!parameters one can easily double the number of dofs.
//!
//!After this file creates the geometry the fluid and structure meshes can be 
//!xported  in LifeV format using files like FSI_pipe_fluid.geo and FSI_pipe_solid.geo 
//!and the converter from gmsh to mesh.

//Mesh.CharacteristicLengthMin=0.1; useless in this case
//Mesh.CharacteristicLengthFromPoints=1; useless in this case

lc = 0.1;
h = 0.1;
R= 0.50;
L = 2.0;

// ############# POINTS ##############
//Base
Point(0) = {0, 0, 0, lc};
Point(1) = {R, 0, 0, lc};
Point(2) = {0, R, 0, lc};
Point(5) = {R+h, 0, 0, lc};
Point(6) = {0, R+h, 0, lc};

//############### LINES ##############
//Base`
Circle(1) = {1,0,2};
Circle(5) = {5,0,6};

Line (9) = {1,5};
Line (10) = {2,6};


// ############# LINE LOOPS ############
Line Loop(1) = {-1,9,5,-10}; //on lines

// ############ SURFACES ############

Plane Surface(1) = {1}; //on line loops

// ############ TRANSFINITE LINES ############
Transfinite Line{1,5}=45; //Number of points on a 1/4 of circle
Transfinite Line{9,10}=11;       //Number of structure layers

// ############ TRANSFINITE SURFACES ############

Transfinite Surface { 1 } = { 1,5,6,2} ; //on points
Physical Surface(20)={1};
Recombine Surface{1, 20};   //======================================================this line is added

//############# EXTRUSION TO 3D ###############

nb_layers = 60;   // To be computed as = L / ( 2*R*pi/(4*points on circle) )
nb_extrusions = 4; //four layers extrusion for the structure (fixed)

///This loop automatically generates 4 volumes whose indexes should be 1,2,3,4
///These volumes will create physical volume 'PipeWall'
out[] = Extrude{0, 0, L}{Surface{1}; Layers{nb_layers};   Recombine;}; //=================the last command
IndexOutlet = out[0];

Physical Volume (1)={1,out[0],out[1]};
Physical Surface(40)={out[0]};
Physical Surface(50)={out[3]};
Physical Surface(30)={out[5]};
Physical Surface(60)={out[2]};
Physical Surface(70)={out[4]};
