1 |
mejri |
932 |
//------------------------------------------------------------ |
2 |
|
|
//------------------------------------------------------------ |
3 |
|
|
// MAGiC |
4 |
|
|
// Jean Christophe Cuilli�re et Vincent FRANCOIS |
5 |
|
|
// D�partement de G�nie M�canique - UQTR |
6 |
|
|
//------------------------------------------------------------ |
7 |
|
|
// Le projet MAGIC est un projet de recherche du d�partement |
8 |
|
|
// de g�nie m�canique de l'Universit� du Qu�bec � |
9 |
|
|
// Trois Rivi�res |
10 |
|
|
// Les librairies ne peuvent �tre utilis�es sans l'accord |
11 |
|
|
// des auteurs (contact : francois@uqtr.ca) |
12 |
|
|
//------------------------------------------------------------ |
13 |
|
|
//------------------------------------------------------------ |
14 |
|
|
// |
15 |
|
|
// main.cpp |
16 |
|
|
// |
17 |
|
|
//------------------------------------------------------------ |
18 |
|
|
//------------------------------------------------------------ |
19 |
|
|
// COPYRIGHT 2000 |
20 |
|
|
// Version du 02/03/2006 � 11H25 |
21 |
|
|
//------------------------------------------------------------ |
22 |
|
|
//------------------------------------------------------------ |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
#include "gestionversion.h" |
27 |
|
|
#ifdef WINDOWS_VERSION |
28 |
|
|
#include "fenetre.h" |
29 |
|
|
#endif |
30 |
|
|
#include "mg_calcul_fatigue.h" |
31 |
|
|
#include "mg_export.h" |
32 |
|
|
#include "mgaster.h" |
33 |
|
|
#include "mg_definition.h" |
34 |
|
|
#include "mg_gestionnaire.h" |
35 |
|
|
#include "magic_application.h" |
36 |
|
|
#include <string.h> |
37 |
|
|
#include "mg_file.h" |
38 |
couturad |
965 |
#include <math.h> |
39 |
mejri |
932 |
//--------------------------------------------------------------------------- |
40 |
|
|
|
41 |
|
|
|
42 |
|
|
int main(int argc,char **argv) |
43 |
|
|
{ |
44 |
|
|
std::vector<MAGIC_PARAMETRE_APPLICATION> lst; |
45 |
|
|
MAGIC_PARAMETRE_APPLICATION p1(2,(char*)"-fatigue",MAGIC_PARAMETRE_APPLICATION::ACTION,(char*)"modelisation de l endommagement de composite par un essai de fatigue"); |
46 |
|
|
MAGIC_PARAMETRE_APPLICATION p2(3,(char*)"-fichiercalcul",MAGIC_PARAMETRE_APPLICATION::STRING,(char*)"Nom du fichier de parametre de calcul de fatigue"); |
47 |
|
|
MAGIC_PARAMETRE_APPLICATION p3(4,(char*)"-param",MAGIC_PARAMETRE_APPLICATION::STRING,(char*)"Nom du fichier de parametre aster"); |
48 |
|
|
MAGIC_PARAMETRE_APPLICATION p4(5,(char*)"-coderesu",MAGIC_PARAMETRE_APPLICATION::STRING,(char*)"Choix des valeurs à calculer par EF - Defaut 11111111 - |Surface moyenne|Surface inferieure|Surface superieur|Deplacement|Contraintes|Deformations|Contraintes equivalentes|Energie|"); |
49 |
|
|
MAGIC_PARAMETRE_APPLICATION p5(7,(char*)"-gen_fichiercalcul",MAGIC_PARAMETRE_APPLICATION::ACTION,(char*)"Generer un fichier de parametre de calcul de fatigue"); |
50 |
|
|
p1.ajouter_dependance(1);p1.ajouter_dependance(3);p1.ajouter_dependance(4);p1.ajouter_dependance(5); |
51 |
|
|
p5.ajouter_dependance(3); |
52 |
|
|
lst.push_back(p1); |
53 |
|
|
lst.push_back(p2); |
54 |
|
|
lst.push_back(p3); |
55 |
|
|
lst.push_back(p4); |
56 |
|
|
lst.push_back(p5); |
57 |
|
|
MAGIC_APPLICATION app((char*)"Calculs",argc,argv,lst,true,true); |
58 |
|
|
if (app.get_erreur()==true) return 0; |
59 |
|
|
if (app.get_action()==2) |
60 |
|
|
{ |
61 |
|
|
OT_PARAMETRES* params=new OT_PARAMETRES; |
62 |
|
|
char fichier_params[500]; |
63 |
|
|
int Njump,N,nummai; |
64 |
|
|
double penal,max_damage_element; |
65 |
|
|
int numchamps=0; |
66 |
|
|
char coderesu[10]; |
67 |
|
|
FEM_MAILLAGE* mai; |
68 |
|
|
MG_GEOMETRIE *geo; |
69 |
|
|
char nomparam[500]; |
70 |
|
|
char nometude[1000]; |
71 |
|
|
char message[500]; |
72 |
|
|
char message1[500]; |
73 |
|
|
char mess[500]; |
74 |
|
|
char mess1[500]; |
75 |
|
|
char mess2[500]; |
76 |
|
|
char mess3[500]; |
77 |
|
|
char nomfichierout[500]; |
78 |
|
|
char chemin[1000]; |
79 |
|
|
N=1; //initialisation du nombre de cycles |
80 |
|
|
max_damage_element=0.; //initialisation de l'endommagement par element |
81 |
|
|
char fichiermagic[500]; |
82 |
|
|
app.recupere_parametre_string(1,fichiermagic,(char*)"Fichier MAGIC entrant manquant"); |
83 |
|
|
app.recupere_parametre_string(3,fichier_params,(char*)"Fichier parametres calcul de fatigue manquant"); |
84 |
|
|
app.recupere_parametre_string(4,nomparam,(char*)"Fichier parametres aster manquant"); |
85 |
|
|
app.recupere_parametre_string_avec_defaut(5,coderesu,(char*)"11111111"); |
86 |
|
|
app.recupere_parametre_string_avec_defaut(6,nomfichierout,fichiermagic); |
87 |
|
|
if (app.get_erreur()==true) return 0; |
88 |
|
|
app.affiche((char*)"endommagement par fatigue du composite"); |
89 |
|
|
params->lire(fichier_params); |
90 |
|
|
double Nmax = params->get_valeur((char*)"Nmax"); |
91 |
|
|
double nombreclasse = params->get_valeur((char*)"nombreclasse"); |
92 |
|
|
double valx = params->get_valeur((char*)"valx"); |
93 |
|
|
double valy = params->get_valeur((char*)"valy"); |
94 |
|
|
double valz = params->get_valeur((char*)"valz"); |
95 |
|
|
double nbrniveau = params->get_valeur((char*)"nbrniveau"); |
96 |
|
|
int position = (int)params->get_valeur((char*)"position"); |
97 |
|
|
double valeur_position = params->get_valeur((char*)"valeur_position"); |
98 |
|
|
int nomb_noeud = (int)params->get_valeur((char*)"nomb_noeud"); |
99 |
|
|
delete params; |
100 |
|
|
int niveaumax=(int)nbrniveau; |
101 |
|
|
std::vector<FEM_ELEMENT3*> *lst=new std::vector<FEM_ELEMENT3*>[niveaumax+1]; |
102 |
|
|
MG_FILE gest(fichiermagic); |
103 |
|
|
mai=gest.get_fem_maillage(0); |
104 |
|
|
geo=gest.get_mg_geometrie(0); //parametrer le 0 |
105 |
|
|
int nombre_element=mai->get_nb_fem_element3(); |
106 |
|
|
int nombre_element_case=round(nombre_element/niveaumax); |
107 |
|
|
std::vector<double>tableau_D; |
108 |
|
|
int nombre_Gauss_max=15; |
109 |
|
|
int size=nombre_element*nombre_Gauss_max; |
110 |
|
|
tableau_D.reserve(size); |
111 |
|
|
int j=0; |
112 |
|
|
int i=1; |
113 |
|
|
LISTE_FEM_ELEMENT3::iterator it; |
114 |
|
|
for (FEM_ELEMENT3* ele=mai->get_premier_element3(it);ele!=NULL;ele=mai->get_suivant_element3(it)) |
115 |
|
|
{ |
116 |
|
|
if ((j<=nombre_element_case) && (i<=niveaumax)) |
117 |
|
|
{ |
118 |
|
|
lst[i].push_back(ele); |
119 |
|
|
} |
120 |
|
|
if ((j>nombre_element_case) && (i<niveaumax)) |
121 |
|
|
{ |
122 |
|
|
j=0; |
123 |
|
|
i++; |
124 |
|
|
lst[i].push_back(ele); |
125 |
|
|
} |
126 |
|
|
j++; |
127 |
|
|
} |
128 |
|
|
MG_CALCUL_FATIGUE jump; |
129 |
|
|
MGASTER mgaster; |
130 |
|
|
char *p=strchr(nomfichierout,'.'); |
131 |
|
|
strncpy(nometude,nomfichierout,p-nomfichierout); |
132 |
|
|
nometude[p-nomfichierout]=0; |
133 |
|
|
FILE *strength = NULL; |
134 |
|
|
strength = fopen((char*)"resistancenum.txt", "w"); |
135 |
mejri |
935 |
while((N>0) && (N<=Nmax) && (max_damage_element<=0.99999)) |
136 |
mejri |
932 |
{ |
137 |
|
|
sprintf(mess," Calcul ASTER"); |
138 |
|
|
sprintf(mess1,"le cycle actuellement simulé est %d",N); |
139 |
|
|
app.affiche(mess); |
140 |
|
|
app.affiche(mess1); |
141 |
|
|
mgaster.calcule_fatigue(nomparam,mai,nometude,MAGIC::CALCUL_ASTER::ELASTIQUE_NON_LINEAIRE_3D_FATIGUE,lst,niveaumax,coderesu); |
142 |
|
|
jump.cycle_jump(gest,geo,Njump,nomparam,numchamps,N,niveaumax,fichiermagic,lst,tableau_D,nombreclasse,max_damage_element,strength,valx,valy,valz,fichier_params,position,valeur_position,nomb_noeud); |
143 |
|
|
jump.active_affichage(app.affiche); |
144 |
|
|
sprintf(message,"le nombre de cycles à ne pas prendre en consideration est %d cycles",Njump); |
145 |
|
|
sprintf(mess2,"le cycle prochainement simulé est %d",N+Njump); |
146 |
|
|
sprintf(message1,"l'endommagement maximal par element pour le cycle %d est %lf",N+Njump,max_damage_element); |
147 |
|
|
app.affiche(message); |
148 |
|
|
app.affiche(mess2); |
149 |
|
|
app.affiche(message1); |
150 |
|
|
sprintf(mess3,"Modification de la courbe de traction"); |
151 |
|
|
app.affiche(mess3); |
152 |
|
|
N=N+Njump; |
153 |
mejri |
946 |
if((N>Nmax)&& (max_damage_element<=0.99999)) |
154 |
|
|
{ |
155 |
|
|
sprintf(mess," Calcul ASTER"); |
156 |
|
|
sprintf(mess1,"le cycle actuellement simulé est %d",N); |
157 |
|
|
app.affiche(mess); |
158 |
|
|
app.affiche(mess1); |
159 |
|
|
mgaster.calcule_fatigue(nomparam,mai,nometude,MAGIC::CALCUL_ASTER::ELASTIQUE_NON_LINEAIRE_3D_FATIGUE,lst,niveaumax,coderesu); |
160 |
|
|
jump.cycle_jump(gest,geo,Njump,nomparam,numchamps,N,niveaumax,fichiermagic,lst,tableau_D,nombreclasse,max_damage_element,strength,valx,valy,valz,fichier_params,position,valeur_position,nomb_noeud); |
161 |
|
|
jump.active_affichage(app.affiche); |
162 |
|
|
sprintf(message,"le nombre de cycles à ne pas prendre en consideration est %d cycles",Njump); |
163 |
|
|
sprintf(mess2,"le cycle prochainement simulé est %d",N+Njump); |
164 |
|
|
sprintf(message1,"l'endommagement maximal par element pour le cycle %d est %lf",N+Njump,max_damage_element); |
165 |
|
|
app.affiche(message); |
166 |
|
|
app.affiche(mess2); |
167 |
|
|
app.affiche(message1); |
168 |
mejri |
932 |
} |
169 |
mejri |
946 |
} |
170 |
mejri |
932 |
fclose(strength); |
171 |
|
|
jump.modification_courbe_exp_sidolo(strength); |
172 |
|
|
app.affiche((char*)"Fin"); |
173 |
|
|
} |
174 |
|
|
if (app.get_action()==7) |
175 |
|
|
{ |
176 |
|
|
app.affiche((char*)"Generation d'un fichier de parametres"); |
177 |
|
|
char fichier_params[500]; |
178 |
|
|
app.recupere_parametre_string(3,fichier_params,(char*)"Fichier parametres calcul de fatigue manquant"); |
179 |
|
|
if (app.get_erreur()==true) return 0; |
180 |
|
|
OT_PARAMETRES* params=new OT_PARAMETRES; |
181 |
|
|
MG_CALCUL_FATIGUE magic_calcul_fatigue; |
182 |
|
|
magic_calcul_fatigue.parametres_calcul(params,fichier_params); |
183 |
|
|
params->enregistrer(fichier_params); |
184 |
|
|
delete params; |
185 |
|
|
app.affiche((char*)"Fin"); |
186 |
|
|
} |
187 |
|
|
return 0; |
188 |
|
|
} |
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
#pragma package(smart_init) |