Herezh_dev/herezh_pp/Enumeration/Enum_type_resolution_matri.cc

288 lines
8.7 KiB
C++
Executable file

// FICHIER : Enum_type_resolution_matri.cp
// 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-2021 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 "Enum_type_resolution_matri.h"
# include <iostream>
using namespace std; //introduces namespace std
#include <stdlib.h>
#include "Sortie.h"
//#ifdef SYSTEM_MAC_OS_X
// #include <stringfwd.h> // a priori ce n'est pas portable
//#el
#if defined SYSTEM_MAC_OS_CARBON
#include <stringfwd.h> // a priori ce n'est pas portable
#else
#include <string.h> // pour le flot en memoire centrale
#endif
#include <string>
// ===================================================================
// cas du type de résolution
// ===================================================================
string Nom_resolution (Enum_type_resolution_matri id_resolution)
// Retourne le nom du type de resolution correspondant a l'identificateur
// de type enumere id_resolution
{
string result;
switch (id_resolution)
{
case RIEN_TYPE_RESOLUTION_MATRI : result="RIEN_TYPE_RESOLUTION_MATRI"; break;
case CHOLESKY : result="CHOLESKY"; break;
case SYMETRISATION_PUIS_CHOLESKY : result="SYMETRISATION_PUIS_CHOLESKY"; break;
case GAUSS : result="GAUSS"; break;
case GAUSS_EXPERT : result="GAUSS_EXPERT"; break;
case BI_CONJUG : result="BI_CONJUG"; break;
case BI_CONJUG_STAB : result="BI_CONJUG_STAB"; break;
case CONJUG_GRAD : result="CONJUG_GRAD"; break;
case CONJUG_GRAD_SQUARE : result="CONJUG_GRAD_SQUARE"; break;
case CHEBYSHEV : result="CHEBYSHEV"; break;
case GENE_MINI_RESIDUAL : result="GENE_MINI_RESIDUAL"; break;
case ITERATION_RICHARSON : result="ITERATION_RICHARSON"; break;
case QUASI_MINI_RESIDUAL : result="QUASI_MINI_RESIDUAL"; break;
case DIRECT_DIAGONAL : result="DIRECT_DIAGONAL"; break;
case CRAMER : result="CRAMER"; break;
case LU_EQUILIBRE : result="LU_EQUILIBRE"; break;
default :
cout << "\nErreur : valeur incorrecte du type Enum_type_resolution_matri !\n";
cout << "Nom_resolution(Enum_type_resolution_matri ) \n";
Sortie(1);
};
return result;
};
Enum_type_resolution_matri Id_nom_resolution (string& nom_resolution)
// Retourne la variable de type enumere associe au nom
// de resolution nom_resolution
{
Enum_type_resolution_matri result;
if ( nom_resolution == "RIEN_TYPE_RESOLUTION_MATRI" )
result=RIEN_TYPE_RESOLUTION_MATRI;
else if ( nom_resolution == "SYMETRISATION_PUIS_CHOLESKY" )
result=SYMETRISATION_PUIS_CHOLESKY;
else if ( nom_resolution == "CHOLESKY" )
result=CHOLESKY;
else if ( nom_resolution == "GAUSS" )
result=GAUSS;
else if ( nom_resolution == "GAUSS_EXPERT" )
result=GAUSS_EXPERT;
else if ( nom_resolution == "BI_CONJUG" )
result=BI_CONJUG;
else if ( nom_resolution == "BI_CONJUG_STAB" )
result=BI_CONJUG_STAB;
else if ( nom_resolution == "CONJUG_GRAD" )
result=CONJUG_GRAD;
else if ( nom_resolution == "CONJUG_GRAD_SQUARE" )
result=CONJUG_GRAD_SQUARE;
else if ( nom_resolution == "CHEBYSHEV" )
result=CHEBYSHEV;
else if ( nom_resolution == "GENE_MINI_RESIDUAL" )
result=GENE_MINI_RESIDUAL;
else if ( nom_resolution == "ITERATION_RICHARSON" )
result=ITERATION_RICHARSON;
else if ( nom_resolution == "QUASI_MINI_RESIDUAL" )
result=QUASI_MINI_RESIDUAL;
else if ( nom_resolution == "DIRECT_DIAGONAL" )
result=DIRECT_DIAGONAL;
else if ( nom_resolution == "CRAMER" )
result=CRAMER;
else if ( nom_resolution == "LU_EQUILIBRE" )
result=LU_EQUILIBRE;
else
{ string toto(nom_resolution);
cout << "\nErreur : nom de resolution inconnu != " << toto <<"\n";
cout << "Id_nom_resolution(string ) \n";
Sortie(1);
};
return result;
};
// indique si le type existe ou pas, -> 1 ou 0
int Existe_Enum_type_resolution_matri(string& nom_resolution)
{
int result;
if ( nom_resolution == "RIEN_TYPE_RESOLUTION_MATRI" )
result=1;
else if ( nom_resolution == "SYMETRISATION_PUIS_CHOLESKY" )
result=1;
else if ( nom_resolution == "CHOLESKY" )
result=1;
else if ( nom_resolution == "GAUSS" )
result=1;
else if ( nom_resolution == "GAUSS_EXPERT" )
result=0; // pour l'instant n'est pas utilisé
else if ( nom_resolution == "BI_CONJUG" )
result=1;
else if ( nom_resolution == "BI_CONJUG_STAB" )
result=1;
else if ( nom_resolution == "CONJUG_GRAD" )
result=1;
else if ( nom_resolution == "CONJUG_GRAD_SQUARE" )
result=1;
else if ( nom_resolution == "CHEBYSHEV" )
result=1;
else if ( nom_resolution == "GENE_MINI_RESIDUAL" )
result=1;
else if ( nom_resolution == "ITERATION_RICHARSON" )
result=1;
else if ( nom_resolution == "QUASI_MINI_RESIDUAL" )
result=1;
else if ( nom_resolution == "DIRECT_DIAGONAL" )
result=1;
else if ( nom_resolution == "CRAMER" )
result=1;
else if ( nom_resolution == "LU_EQUILIBRE" )
result=1;
else
{ result = 0;};
return result;
};
// surcharge de la lecture
istream & operator >> (istream & entree, Enum_type_resolution_matri & result)
{ string nom_resolution;
entree >> nom_resolution;
result = Id_nom_resolution ( nom_resolution);
return entree;
};
// surcharge de l'operator d'ecriture
ostream & operator << (ostream & sort, const Enum_type_resolution_matri& a)
{ // on ecrit la forme caractère
sort << Nom_resolution(a) << " ";
return sort;
};
// ===================================================================
// cas du type de préconditionnement
// ===================================================================
string Nom_preconditionnement (Enum_preconditionnement id_preconditionnement)
// Retourne le nom du type de preconditionnement correspondant a l'identificateur
// de type enumere id_preconditionnement
{
string result;
switch (id_preconditionnement)
{
case RIEN_PRECONDITIONNEMENT :
result="RIEN_PRECONDITIONNEMENT";
break;
case DIAGONAL :
result="DIAGONAL";
break;
case ICP :
result="ICP";
break;
case ILU :
result="ILU";
break;
default :
cout << "\nErreur : valeur incorrecte du type Enum_preconditionnement !\n";
cout << "Nom_preconditionnement(Enum_preconditionnement ) \n";
Sortie(1);
};
return result;
};
Enum_preconditionnement Id_nom_preconditionnement (string nom_preconditionnement)
// Retourne la variable de type enumere associe au nom
// de preconditionnement nom_preconditionnement
{
Enum_preconditionnement result;
if ( nom_preconditionnement == "RIEN_PRECONDITIONNEMENT" )
result=RIEN_PRECONDITIONNEMENT;
else if ( nom_preconditionnement == "DIAGONAL" )
result=DIAGONAL;
else if ( nom_preconditionnement == "ICP" )
result=ICP;
else if ( nom_preconditionnement == "ILU" )
result=ILU;
else
{
cout << "\nErreur : nom de preconditionnement inconnu !\n";
cout << "Id_nom_preconditionnement(string ) \n";
Sortie(1);
};
return result;
};
// indique si le type existe ou pas, -> 1 ou 0
int Existe_Enum_preconditionnement(string& nom_preconditionnement)
{
int result;
if ( nom_preconditionnement == "RIEN_PRECONDITIONNEMENT" )
result=1;
else if ( nom_preconditionnement == "DIAGONAL" )
result=1;
else if ( nom_preconditionnement == "ICP" )
result=1;
else if ( nom_preconditionnement == "ILU" )
result=1;
else
{result = 0;};
return result;
};
// surcharge de la lecture
istream & operator >> (istream & entree, Enum_preconditionnement & result)
{ char nom_preconditionnement[45];
entree >> nom_preconditionnement;
result = Id_nom_preconditionnement ( nom_preconditionnement);
return entree;
};
// surcharge de l'operator d'ecriture
ostream & operator << (ostream & sort, const Enum_preconditionnement& a)
{ // on ecrit la forme caractère
sort << Nom_preconditionnement(a) << " ";
return sort;
};