// 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 "Def_Umat.h"


// ---------- constructeur----------------------------------------
Def_Umat::Def_Umat ()   // constructeur ne devant pas etre utilise
   {
     #ifdef MISE_AU_POINT	 	 
		{ cout << "\nErreur : le constructeur par defaut ne doit pa etre utilise !\n";
			  cout << "Def_Umat::Def_Umat () \n";
			  Sortie(1);
			};
     #endif
   };
// constructeur normal dans le cas d'un ou de plusieurs pt d'integration             	  
Def_Umat::Def_Umat (Met_abstraite & a,Tableau<Noeud *>&  b,     
           Tableau <Mat_pleine> const  & tabdphi,Tableau <Vecteur> const & tabphi 
           ,Enum_type_deformation type_de_deformation) :
       Deformation (a,b,tabdphi,tabphi,type_de_deformation)    
   {     };
   
// constructeur de copie
Def_Umat::Def_Umat (const  Def_Umat& a) :
  Deformation(a)
   {     };
     
// METHODES PUBLIQUES :
    
// ------------------------- cas d'une procédure Umat ------------------------
 //   - calcul des déformations équivalentes
 void Def_Umat::CalDefEqui(const Tableau <double>& def_equi_t,TenseurBB & epsBB_tdt
                     ,Tableau <double>& def_equi,TenseurBB& DepsBB,TenseurBB& delta_epsBB
                     ,const Met_abstraite::Umat_cont& ex,bool premier_calcul)
 {
 
  // --- on calcul la déformation cumulée
	 {TenseurBH * delta_epsBH = NevezTenseurBH(epsBB_tdt.Dimension(), 0.);
	  *delta_epsBH = delta_epsBB * (*ex.gijHH_tdt);
	  double delta_eps_equi = sqrt(2./3. * ( ((*delta_epsBH) && (*delta_epsBH)) - Sqr(delta_epsBH->Trace()) /3. ));
	  def_equi(1) = def_equi_t(1) + delta_eps_equi;
	  def_equi(4) = delta_eps_equi;
	  delete delta_epsBH;
	  };

	 {TenseurBH * epsBH = NevezTenseurBH(epsBB_tdt.Dimension(), 0.);
	  *epsBH = epsBB_tdt * (*ex.gijHH_tdt);
	  def_equi(2) = sqrt(2./3. * ( ((*epsBH) && (*epsBH)) - Sqr(epsBH->Trace()) /3. ));
	  delete epsBH;
	  if (def_equi(2) > def_equi_t(3))
	     def_equi(3) = def_equi(2);
	  };
	 
  // sauvegarde des infos à 0 éventuellement
  if (premier_calcul) saveDefResul->MiseAJourGrandeurs_a_0(metrique);
  // sauvegarde des infos à tdt à chaque passage
  saveDefResul->MiseAJourGrandeurs_a_tdt(metrique,DepsBB);
 
 };
/*const Met_ElemPoint::Umat_cont& Def_Umat::Cal_defUmat(const ParaAlgoControle & pa
                        ,TenseurBB & epsBB_tdt,TenseurBB& DepsBB,TenseurBB& delta_epsBB_tdt)
	{ // calcul des éléments de la métrique
	  const Met_ElemPoint::Umat_cont& ex =((Met_ElemPoint*) metrique)->Calcul_grandeurs_Umat(pa);   
	  // calcul des variables de passage
	  
	  // retour
	   return  ex;
	   };
   
*/