Function GeomProgrNbNodesDx0
/* INPUT  : length, ratio and desired 1st node characteristic length dx0
   OUTPUT : number of nodes and actual dx0 value */

  Printf("GPNND_length %f ", GPNND_length);
  GPNND_olddx0 = GPNND_dx0;

  If (GPNND_ratio !=1.)
    GPNND_N = Floor(Log((1 + GPNND_length * (GPNND_ratio - 1) / GPNND_dx0)) / Log(GPNND_ratio));
    GPNND_dx0 = (1 - GPNND_ratio) * GPNND_length / (1 - GPNND_ratio^(GPNND_N+1));
  EndIf
  If (GPNND_ratio == 1.)
    Printf("case GPNND_ratio = 1");
    GPNND_N = Floor(GPNND_length / GPNND_dx0);
    GPNND_dx0 = GPNND_length / (GPNND_N+1);
  EndIf
  GPNND_nbnodes = GPNND_N + 2;
  Printf("nbnodes %f ", GPNND_nbnodes);
  Printf("dx0 %f => %f", GPNND_olddx0, GPNND_dx0);
  GPNND_dxN = GPNND_dx0 * GPNND_ratio^GPNND_N;
  Printf("dxN %f", GPNND_dxN);

Return

/*
Point(1) = {0,0,0,0.1};
Point(2) = {1,0,0,0.1};
Line(1) = {1,2};

GPNND_length = 1;
GPNND_dx0 = 0.1;
GPNND_ratio = 1.2;

Call GeomProgrNbNodesDx0;

Transfinite Line{1} = GPNND_nbnodes Using Progression GPNND_ratio; 
*/


Function GeomProgrNbNodesRatio
/* INPUT  : dx0, dxN
   OUTPUT : number of nodes and actual ratio value */

  GPNNR_olddxN = GPNNR_dxN;

  Printf("GPNNR_length %f ", GPNNR_length);
  GPNNR_ratio = (GPNNR_dx0 - GPNNR_length) / (GPNNR_dxN - GPNNR_length);
  GPNNR_N = Floor(Log(GPNNR_dxN/GPNNR_dx0) / Log(GPNNR_ratio));
  GPNNR_dxN = GPNNR_dx0 * GPNNR_ratio^GPNNR_N;

  GPNNR_nbnodes = GPNNR_N + 2;
  Printf("dxN %f => %f", GPNNR_olddxN, GPNNR_dxN);
  Printf("nbnodes %f ", GPNNR_nbnodes);
  Printf("ratio %f", GPNNR_ratio);

Return

/*
Point(1) = {0,0,0,0.1};
Point(2) = {1,0,0,0.1};
Line(1) = {1,2};

GPNNR_length = 1;
GPNNR_dx0 = 0.1;
GPNNR_dxN = 0.3;

Call GeomProgrNbNodesRatio;

Transfinite Line{1} = GPNNR_nbnodes Using Progression GPNNR_ratio; 
*/



Function BumpProgrNbNodesBRatio
/* INPUT  : length, ratio and desired 1st node characteristic length dx0
   OUTPUT : number of nodes and the bump ratio (biggest to smallest cell ratio) */

  Printf("GBPNND_length %f ", GBPNND_length);

  GBPNND_olddx0 = GBPNND_dx0;
  GBPNND_halflength = GBPNND_length / 2;
  If (GBPNND_ratio !=1)
    GBPNND_N = Floor(Log((1 + GBPNND_halflength * (GBPNND_ratio - 1) / GBPNND_dx0)) / Log(GBPNND_ratio));
    GBPNND_dx0 = (1 - GBPNND_ratio) * GBPNND_halflength / (1 - GBPNND_ratio^(GBPNND_N+1));
    GBPNND_bumpratio = 1 / GBPNND_ratio^GBPNND_N ; 
  EndIf
  If (GBPNND_ratio == 1)
    Printf("case GBPNND_ratio = 1");
    GBPNND_N = Floor(GBPNND_halflength / GBPNND_dx0);
    GBPNND_dx0 = GBPNND_halflength / (GBPNND_N+1);
    GBPNND_bumpratio = 1 ;
  EndIf
  GBPNND_nbnodes = 2 * (GBPNND_N + 1) + 1;
  Printf("nbnodes %f ", GBPNND_nbnodes);
  Printf("dx0 %f => %f", GBPNND_olddx0, GBPNND_dx0);
  GBPNND_dxN = GBPNND_dx0 * GBPNND_ratio^GBPNND_N;
  Printf("dxN %f", GBPNND_dxN);
  Printf("bumpratio %f", GBPNND_bumpratio);
  
Return

/*
Point(1) = {0,0,0,0.1};
Point(2) = {1,0,0,0.1};
Line(1) = {1,2};

GBPNND_length = 1;
GBPNND_dx0 = 0.1;
GBPNND_ratio = 1.2;

Call BumpProgrNbNodesBRatio;

Transfinite Line{1} = GBPNND_nbnodes Using Bump GBPNND_bumpratio;
*/
