// FICHIER : Met_biellette.cc
// CLASSE : Met_biellette

// This file is part of the Herezh++ application.
//
// The finite element software Herezh++ is dedicated to the field
// of mechanics for large transformations of solid structures.
// It is developed by Gérard Rio (APP: IDDN.FR.010.0106078.000.R.P.2006.035.20600)
// INSTITUT DE RECHERCHE DUPUY DE LÔME (IRDL) <https://www.irdl.fr/>.
//
// Herezh++ is distributed under GPL 3 license ou ultérieure.
//
// Copyright (C) 1997-2022 Université Bretagne Sud (France)
// AUTHOR : Gérard Rio
// E-MAIL  : gerardrio56@free.fr
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// For more information, please consult: <https://herezh.irdl.fr/>.



# include <iostream>
using namespace std;  //introduces namespace std
#include <math.h>
#include <stdlib.h>
#include "Sortie.h"


#include "Met_biellette.h"

// -Constructeur par defaut
Met_biellette::Met_biellette () {};
// constructeur permettant de dimensionner unique ment certaine variables
// dim = dimension de l'espace, tab = liste
// des variables a initialiser
Met_biellette::Met_biellette (int dim_base,const  DdlElement& tabddl,
	                   const  Tableau<Enum_variable_metrique>& tab,int nomb_noeud) :
	           Met_abstraite (dim_base,1,tabddl,tab, nomb_noeud) {};
// constructeur de copie
Met_biellette::Met_biellette (const  Met_biellette& a) :
    Met_abstraite (a) {};

// destructeur
Met_biellette::~Met_biellette () {};

// calcul de la base  naturel a t0  1 seul vecteur
void Met_biellette::Calcul_giB_0
 (const  Tableau<Noeud *>& tab_noeud,const   Mat_pleine& dphi, int nombre_noeud,const Vecteur&)
   { 
    for (int a=1;a<= dim_base;a++)
      { giB_0->CoordoB(1)(a)= 0.;
        for (int r=1;r<=nombre_noeud;r++)
          { giB_0->CoordoB(1)(a)=(*(giB_0))(1)(a) + tab_noeud(r)->Coord0()(a) * dphi(1,r);
          };
		    };
   };
// calcul de la base  naturel a t  -- calcul classique
void Met_biellette::Calcul_giB_t
 (const   Tableau<Noeud *>& tab_noeud,const   Mat_pleine& dphi, int nombre_noeud,const Vecteur& )
 {
   for (int a=1;a<= dim_base;a++)
     { giB_t->CoordoB(1)(a)= 0.;
       for (int r=1;r<=nombre_noeud;r++)
         { giB_t->CoordoB(1)(a)=(*(giB_t))(1)(a) + tab_noeud(r)->Coord1()(a) * dphi(1,r);
         };
     };
////--- debug
//cout << "\n debug Met_biellette::Calcul_giB_t ";
//for (int r=1;r<=nombre_noeud;r++)
//   tab_noeud(r)->Affiche(0);
//cout << endl;
////--- fin debug

 };
// calcul de la base  naturel a tdt  -- calcul classique
void Met_biellette::Calcul_giB_tdt
 ( const  Tableau<Noeud *>& tab_noeud,const   Mat_pleine& dphi, int nombre_noeud,const Vecteur& )
   {
    for (int a=1;a<= dim_base;a++)
      { giB_tdt->CoordoB(1)(a)= 0.;
        for (int r=1;r<=nombre_noeud;r++)
         { giB_tdt->CoordoB(1)(a)=(*(giB_tdt))(1)(a) + tab_noeud(r)->Coord2()(a) * dphi(1,r);
         };
       };
   };

//==  calcul de la variation des jacobiens
// pas valable dans le cas à une dimension
void Met_biellette::Djacobien_t()
   { // on alloue en fonction des parametres
	 int nbddl = tab_ddl.NbDdl_famille(X1); // nombre de ddl en position
     // un seul vecteur de base
     for ( int indice = 1; indice <= nbddl; indice ++)
              d_jacobien_t(indice)  = 
                 (((*d_giB_t)(indice)(1)(1)) * ((*giB_t)(1)(1)))/jacobien_t;
   };
void Met_biellette::Djacobien_tdt()   
   { int nbddl = tab_ddl.NbDdl_famille(X1); // nombre de ddl en position
     // un seul vecteur de base
     for ( int indice = 1; indice <= nbddl; indice ++)
         d_jacobien_tdt(indice)  = 
              (((*d_giB_tdt)(indice)(1)(1)) * ((*giB_tdt)(1)(1)))
                  /jacobien_tdt;
   };