Herezh_dev/Elements/Thermique/LesPtIntegThermiInterne.cc
2023-05-03 17:23:49 +02:00

244 lines
8.9 KiB
C++
Executable file

// 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 "LesPtIntegThermiInterne.h"
// contructeur par défaut
LesPtIntegThermiInterne::LesPtIntegThermiInterne():
tabPtInt(),tabfluxH(),tabfluxH_t()
{};
// contructeur fonction du nombre de points d'intégration et de la dimension de tenseurs
LesPtIntegThermiInterne::LesPtIntegThermiInterne(int nbpti, int dimtens):
tabPtInt(nbpti,PtIntegThermiInterne(dimtens)),tabfluxH(nbpti),tabfluxH_t(nbpti)
{ // on relie les tableaux entre eux
for (int i=1; i<= nbpti; i++)
{tabfluxH(i)= &tabPtInt(i).FluxH();
tabfluxH_t(i)= &tabPtInt(i).FluxH_t();
};
};
// contructeur de copie
LesPtIntegThermiInterne::LesPtIntegThermiInterne(const LesPtIntegThermiInterne& lespti):
tabPtInt(lespti.tabPtInt),tabfluxH(lespti.tabfluxH.Taille())
,tabfluxH_t(lespti.tabfluxH_t.Taille())
{ // on relie les tableaux entre eux
int nbpti = tabPtInt.Taille();
for (int i=1; i<= nbpti; i++)
{tabfluxH(i)= &tabPtInt(i).FluxH();
tabfluxH_t(i)= &tabPtInt(i).FluxH_t();
};
};
// DESTRUCTEUR :
// normalement il n'y a rien n'a faire car les pointeurs sont des copies
LesPtIntegThermiInterne::~LesPtIntegThermiInterne()
{ };
// Surcharge de l'operateur =
LesPtIntegThermiInterne& LesPtIntegThermiInterne::operator= ( const LesPtIntegThermiInterne& lespti)
{ int newTaille = lespti.NbPti();
tabPtInt = lespti.tabPtInt;
tabfluxH.Change_taille(newTaille);
tabfluxH_t.Change_taille(newTaille);
// on relie les tableaux entre eux
int nbpti = tabPtInt.Taille();
for (int i=1; i<= nbpti; i++)
{tabfluxH(i)= &tabPtInt(i).FluxH();
tabfluxH_t(i)= &tabPtInt(i).FluxH_t();
};
// retour
return *this;
};
// changement de taille donc de nombre de points d'intégration
// fonction du nombre de points d'intégration et de la dimension de tenseurs
// attention: il s'agit d'un dimentionnement pas défaut (les activations diverses
// sont ensuite à faire: par exemple pour les invariants)
void LesPtIntegThermiInterne::Change_taille_PtIntegThermi(int nbpti, int dimtens)
{ // tout d'abord on adapte la taille
tabPtInt.Change_taille(nbpti,PtIntegThermiInterne(dimtens));
tabfluxH.Change_taille(nbpti);
tabfluxH_t.Change_taille(nbpti);
// on relie les tableaux entre eux
for (int i=1; i<= nbpti; i++)
{tabfluxH(i)= &tabPtInt(i).FluxH();
tabfluxH_t(i)= &tabPtInt(i).FluxH_t();
};
};
// idem, mais les instances ajoutées ou retirer ont la même dimension de tenseur que celles
// qui existent déjà
void LesPtIntegThermiInterne::Change_taille_PtIntegThermi(int nbpti)
{ // tout d'abord on adapte la taille
tabPtInt.Change_taille(nbpti);
tabfluxH.Change_taille(nbpti);
tabfluxH_t.Change_taille(nbpti);
// on relie les tableaux entre eux
for (int i=1; i<= nbpti; i++)
{tabfluxH(i)= &tabPtInt(i).FluxH();
tabfluxH_t(i)= &tabPtInt(i).FluxH_t();
};
};
// retour la dimension des coordonnées gérés
int LesPtIntegThermiInterne::DimCoord() const
{if (tabPtInt.Taille() != 0)
{return tabPtInt(1).GradTB().Dimension();}
else
{return 0;};
};
//============= lecture écriture dans base info ==========
// cas donne le niveau de la récupération
// = 1 : on récupère tout
// = 2 : on récupère uniquement les données variables (supposées comme telles)
void LesPtIntegThermiInterne::Lecture_base_info (ifstream& ent,const int cas)
{switch (cas)
{ case 1 : // ------- on récupère tout -------------------------
{ string nom; ent >> nom; // on ne vérifie pas le nom car on considère que
// ça a été écrit par le prog associé
int taille = 0;
ent >> nom >> taille; // lecture de la taille
tabPtInt.Change_taille(taille);
tabfluxH.Change_taille(taille);
tabfluxH_t.Change_taille(taille);
// lecture
for (int i=1;i<=taille;i++)
tabPtInt(i).Lecture_base_info (ent,cas);
// on relie les tableaux entre eux
for (int i=1; i<= taille; i++)
{tabfluxH(i)= &tabPtInt(i).FluxH();
tabfluxH_t(i)= &tabPtInt(i).FluxH_t();
};
break;
}
case 2 : // ----------- lecture uniquement de se qui varie --------------------
{ string nom; ent >> nom; // on ne vérifie pas le nom car on considère que
// ça a été écrit par le prog associé
// lecture
int taille = tabPtInt.Taille();
for (int i=1;i<=taille;i++)
tabPtInt(i).Lecture_base_info (ent,cas);
break;
}
default :
{ cout << "\nErreur : valeur incorrecte du type de lecture !\n";
cout << "LesPtIntegThermiInterne::Lecture_base_info(ifstream& ent,const "
<< " cas= " << cas << endl;
Sortie(1);
}
}
};
// cas donne le niveau de sauvegarde
// = 1 : on sauvegarde tout
// = 2 : on sauvegarde uniquement les données variables (supposées comme telles)
void LesPtIntegThermiInterne::Ecriture_base_info(ofstream& sort,const int cas)
{switch (cas)
{ case 1 : // ------- on sauvegarde tout -------------------------
{ sort << "\n grandeurs_aux_points_d_integration:" ;
int taille = tabPtInt.Taille();
sort << " taille= " << taille << " " ;
for (int i=1;i<=taille;i++)
tabPtInt(i).Ecriture_base_info(sort,cas);
break;
}
case 2 : // ----------- sauvegarde uniquement de se qui varie --------------------
{ sort << "\n grandeurs_aux_points_d_integration:" ;
int taille = tabPtInt.Taille();
for (int i=1;i<=taille;i++)
tabPtInt(i).Ecriture_base_info(sort,cas);
break;
}
default :
{ cout << "\nErreur : valeur incorrecte du type d'écriture !\n";
cout << "LesPtIntegThermiInterne::Ecriture_base_info(ofstream& sort,const int cas)"
<< " cas= " << cas << endl;
Sortie(1);
}
}
};
// actualisation des grandeurs actives de t+dt vers t, pour celles qui existent
// sous ces deux formes
void LesPtIntegThermiInterne::TdtversT()
{ int taille = tabPtInt.Taille();
for (int i=1;i<=taille;i++)
tabPtInt(i).TdtversT();
};
// actualisation des grandeurs actives de t vers tdt, pour celles qui existent
// sous ces deux formes
void LesPtIntegThermiInterne::TversTdt()
{ int taille = tabPtInt.Taille();
for (int i=1;i<=taille;i++)
tabPtInt(i).TversTdt();
};
// surcharge de l'operateur de lecture
istream & operator >> (istream & entree, LesPtIntegThermiInterne & lespti)
{ // vérification du type
string nom;
entree >> nom;
#ifdef MISE_AU_POINT
if (nom != "LesPtIntegThermiInterne")
{ cout << "\nErreur, en lecture d'une instance LesPtIntegThermiInterne "
<< " on attendait LesPtIntegThermiInterne et on a lue: " << nom ;
cout << "istream & operator >> (istream & entree, LesPtIntegThermiInterne & pti)\n";
Sortie(1);
};
#endif
// puis lecture des différents éléments
lespti.tabPtInt.Entree(entree);
// on s'occupe des pointeurs
int nbpti = lespti.tabPtInt.Taille();
lespti.tabfluxH.Change_taille(nbpti);
lespti.tabfluxH_t.Change_taille(nbpti);
// on relie les tableaux entre eux
for (int i=1; i<= nbpti; i++)
{lespti.tabfluxH(i)= &lespti.tabPtInt(i).FluxH();
lespti.tabfluxH_t(i)= &lespti.tabPtInt(i).FluxH_t();
};
return entree;
};
// surcharge de l'operateur d'ecriture
ostream & operator << ( ostream & sort,const LesPtIntegThermiInterne & lespti)
{ // tout d'abord un indicateur donnant le type
sort << "LesPtIntegThermiInterne " ;
// puis les différents éléments (pas les pointeurs qui n'ont aucun intérêt ici)
lespti.tabPtInt.Sortir(sort);
return sort;
};