ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/microstructure/src/ve_ves.cpp
Revision: 801
Committed: Tue Jun 7 19:54:41 2016 UTC (8 years, 11 months ago) by couturad
File size: 24471 byte(s)
Log Message:
cas test microstructure plus bug d'inversion VER VES

File Contents

# User Rev Content
1 francois 756 //------------------------------------------------------------
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     // mg_ves.cpp
16     //
17     //------------------------------------------------------------
18     //------------------------------------------------------------
19     // COPYRIGHT 2000
20     // Version du 02/03/2006 � 11H23
21     //------------------------------------------------------------
22     //------------------------------------------------------------
23    
24 couturad 801 #include "ve_ves.h"
25     #include "ve_definition.h"
26 francois 756 #include "gestionversion.h"
27 couturad 801 #include "mg_gestionnaire.h"
28     #include "mg_arbre.h"
29     #include "mg_assemblage.h"
30     #include "mg_primitive.h"
31     #include "mg_primitive_boite.h"
32     #include "mg_primitive_sphere.h"
33     #include "mg_primitive_cylindre.h"
34     #include "mg_primitive_cone.h"
35     #include "mg_primitive_tore.h"
36     #include "mg_primitive_complexe.h"
37     #include "mg_operateur_boolean.h"
38     #include "mg_operateur_boolean_difference.h"
39     #include "mg_operateur_boolean_intersection.h"
40     #include "mg_operateur_boolean_union.h"
41     #include "mg_sommet_noeud.h"
42     #include "fct_taille.h"
43     #include "fct_generateur_frontiere.h"
44     #include "fct_generateur_constante.h"
45     #include "fct_generateur_fichier.h"
46     #include "fct_taille_fem_solution_generateur_constant.h"
47     #include "fct_taille_fem_solution_generateur_echantillon_frontiere.h"
48     #include "fct_taille_fem_solution_generateur_fichier.h"
49     #include "mailleur.h"
50     #include "mailleur0d.h"
51     #include "mailleur1d.h"
52     #include "mailleur2d.h"
53     #include "mailleur3d.h"
54     #include "tpl_map_entite.h"
55     #include "ot_mathematique.h"
56     #include "fem_maillage.h"
57     #include "mgaster.h"
58     #include "mg_export.h"
59     #include "sphere_grille.h"
60     #include <string.h>
61     #include <map>
62     #include <random>
63     #include <stdio.h>
64     #include <iostream>
65     #include <chrono>
66 francois 756
67 couturad 801 VE_VES::VE_VES()
68     {
69     gest = new MG_GESTIONNAIRE;
70     arbre = new MG_ARBRE("Arbre");
71     assemblage = new MG_ASSEMBLAGE("Assemblage");
72     param_ver = new OT_PARAMETRES();
73     gest->ajouter_mg_arbre(arbre);
74     arbre->ajouter_mg_assemblage(assemblage);
75     ini_param_VER(param_ver);
76     dim_VES[0] = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_VER_Dim_longueur_x]);
77     dim_VES[1] = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_VER_Dim_longueur_y]);
78     dim_VES[2] = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_VER_Dim_longueur_z]);
79     }
80 francois 756
81 couturad 801 VE_VES::VE_VES(VE_VES& mdd)
82     {
83 francois 756
84 couturad 801 }
85    
86     VE_VES::~VE_VES()
87 francois 756 {
88 couturad 801 delete assemblage;
89     delete param_ver;
90     delete gest;
91     }
92 francois 756
93 couturad 801 int VE_VES::construire(void)
94     {
95     int type_ver = (int)param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_VER_Type]);
96     switch(type_ver)
97     {
98     case VE_TYPE_VER::HOMOGENE:
99     {
100     generer_VES_homogene();
101     break;
102     }
103     case VE_TYPE_VER::UNE_INCLUSION:
104     {
105     generer_VES_une_inclusion();
106     break;
107     }
108     case VE_TYPE_VER::ALEATOIRE:
109     {
110     generer_VES_aleatoire();
111     break;
112     }
113     }
114     evaluer_geometrie();
115     creer_carte();
116     creer_mg_maillage();
117     appliquer_conditions_limites(param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_VER_CL_CHARGEMENT_type]));
118     appliquer_materiaux();
119     creer_fem_maillage();
120     calcul_aster();
121     homogeneisation();
122     char nom_fichier_magic[1000];
123     sprintf(nom_fichier_magic,"%s",param_ver->get_nom(VE_PARAM_CHAR[VE_PARAM::VE_IO_nom_fichier_MAGiC]).c_str());
124     gest->enregistrer(nom_fichier_magic);
125     return 0;
126 francois 756 }
127    
128 couturad 801 MG_GESTIONNAIRE* VE_VES::get_gestionnaire(void)
129     {
130     return gest;
131     }
132 francois 756
133 couturad 801 MG_ARBRE* VE_VES::get_arbre(void)
134     {
135     return arbre;
136     }
137 francois 756
138 couturad 801 MG_ASSEMBLAGE* VE_VES::get_assemblage(void)
139 francois 756 {
140 couturad 801 return assemblage;
141     }
142 francois 756
143 couturad 801 void VE_VES::active_affichage(fonction_affiche* fonc)
144     {
145     fonc_affiche = fonc;
146     affichageactif = 1;
147 francois 756 }
148    
149 couturad 801 void VE_VES::affiche(char* message)
150     {
151     if(affichageactif==1) fonc_affiche(message);
152     }
153 francois 756
154 couturad 801 void VE_VES::lire_param_VES(char* fichier)
155     {
156     param_ver->lire(fichier);
157     dim_VES[0] = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_VER_Dim_longueur_x]);
158     dim_VES[1] = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_VER_Dim_longueur_y]);
159     dim_VES[2] = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_VER_Dim_longueur_z]);
160     }
161 francois 756
162 couturad 801 void VE_VES::ecrire_param_VES(char* fichier)
163 francois 756 {
164 couturad 801 param_ver->enregistrer(fichier);
165     }
166 francois 756
167 couturad 801 int VE_VES::generer_VES_homogene(void)
168     {
169     affiche((char*)"Generation VER Homogene :\n");
170     MG_PRIMITIVE_BOITE *cube = new MG_PRIMITIVE_BOITE(0,0,0,dim_VES[0],dim_VES[1],dim_VES[2]);
171     arbre->ajouter_mg_primitive(cube);
172     cube->construit();
173     assemblage->ajouter_mg_primitive(cube);
174     return 0;
175 francois 756 }
176 couturad 801
177     int VE_VES::generer_VES_une_inclusion(void)
178     {
179     affiche((char*)"Generation VER Une Inclusion :\n");
180     MG_PRIMITIVE_BOITE *cube = new MG_PRIMITIVE_BOITE(0,0,0,dim_VES[0],dim_VES[1],dim_VES[2]);
181     arbre->ajouter_mg_primitive(cube);
182     cube->construit();
183    
184     MG_PRIMITIVE *matrice;
185     MG_PRIMITIVE *inclusion;
186     MG_PRIMITIVE *inclusion_outil;
187    
188    
189     int type_inclusion = (int)param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_INCLU_Type_INCLUSION]);
190     switch(type_inclusion)
191     {
192     case VE_TYPE_INCLUSION::BOITE:
193     {
194     double xmin,ymin,zmin,xmax,ymax,zmax;
195     double longueur_x,longueur_y,longueur_z;
196     longueur_x = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_INCLU_Dim_mu_longueur_x]);
197     longueur_y = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_INCLU_Dim_mu_longueur_y]);
198     longueur_z = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_INCLU_Dim_mu_longueur_z]);
199     xmin = dim_VES[0]/2.-(longueur_x/2.);
200     ymin = dim_VES[1]/2.-(longueur_y/2.);
201     zmin = dim_VES[2]/2.-(longueur_z/2.);
202     xmax = dim_VES[0]/2.+(longueur_x/2.);
203     ymax = dim_VES[1]/2.+(longueur_y/2.);
204     zmax = dim_VES[2]/2.+(longueur_z/2.);
205     inclusion = new MG_PRIMITIVE_BOITE(xmin,ymin,zmin,xmax,ymax,zmax);
206     inclusion_outil = new MG_PRIMITIVE_BOITE(xmin,ymin,zmin,xmax,ymax,zmax);
207     break;
208     }
209     case VE_TYPE_INCLUSION::SPHERE:
210     {
211     double rayon;
212     rayon = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_INCLU_Dim_mu_rayon]);
213     inclusion = new MG_PRIMITIVE_SPHERE(dim_VES[0]/2.,dim_VES[1]/2.,dim_VES[2]/2.,rayon);
214     inclusion_outil = new MG_PRIMITIVE_SPHERE(dim_VES[0]/2.,dim_VES[1]/2.,dim_VES[2]/2.,rayon);
215     break;
216     }
217     case VE_TYPE_INCLUSION::CYLINDRE:
218     {
219     break;
220     }
221     }
222     arbre->ajouter_mg_primitive(inclusion_outil);
223     arbre->ajouter_mg_primitive(inclusion);
224     inclusion_outil->construit();
225     inclusion->construit();
226     MG_OPERATEUR_BOOLEAN_DIFFERENCE *op_difference=new MG_OPERATEUR_BOOLEAN_DIFFERENCE(MAGIC::SEMANTIQUECSG::SOUSTRACTION,cube,inclusion_outil);
227     matrice=op_difference->construit();
228     arbre->ajouter_mg_operateur_boolean(op_difference);
229     arbre->ajouter_mg_primitive(matrice);
230     assemblage->ajouter_mg_primitive(inclusion);
231     assemblage->ajouter_mg_primitive(matrice);
232     return 0;
233     }
234    
235     int VE_VES::generer_VES_aleatoire(void)
236     {
237    
238     return 0;
239     }
240    
241     int VE_VES::evaluer_geometrie(void)
242     {
243     char nom_fichier[1000];
244     sprintf(nom_fichier,"%s",param_ver->get_nom(VE_PARAM_CHAR[VE_PARAM::VE_IO_nom_fichier_STEP_BREP]).c_str());
245     bool export_STEP, avec_fusion,import_STL;
246     export_STEP = (int)param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_IO_Bool_export_STEP]);
247     avec_fusion = (int)param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_IO_Bool_fusion]);
248     import_STL = (int)param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_IO_Bool_import_STL]);
249     double precision,eps;
250     precision = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_Dim_precision]);
251     eps = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_IO_STL_eps]);
252     arbre->evaluer_geometrie(assemblage,nom_fichier,avec_fusion,export_STEP,import_STL,precision,eps);
253     return 0;
254     }
255    
256     int VE_VES::creer_mg_maillage(void)
257     {
258     affiche((char*)"Maillage du VER :");
259     MG_GEOMETRIE *geo = gest->get_mg_geometrie(0);
260     MG_MAILLAGE *maillage = new MG_MAILLAGE(geo);
261     gest->ajouter_mg_maillage(maillage);
262     MAILLEUR0D m0d(maillage,geo);
263     affiche((char*)" Maillage 0D :");
264     m0d.maille();
265     MAILLEUR1D m1d(maillage,geo,metrique);
266     affiche((char*)" Maillage 1D :");
267     //m1d.active_affichage(fonc_affiche);
268     m1d.maille();
269     MAILLEUR2D m2d(maillage,geo,metrique);
270     affiche((char*)" Maillage 2D :");
271     //m2d.active_affichage(fonc_affiche);
272     m2d.maille();
273     MAILLEUR3D m3d(maillage,geo,metrique,false);
274     affiche((char*)" Maillage 3D :");
275     m3d.active_affichage(fonc_affiche);
276     m3d.maille();
277     return 0;
278     }
279    
280     int VE_VES::creer_carte(void)
281     {
282     int type_carte = (int)param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_CARTE_Type]);
283     switch(type_carte)
284     {
285     case VE_TYPE_CARTE::CONSTANTE:
286     {
287     affiche((char*)"Generation de carte de taille constante V1");
288     double ecart_nodal = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_CARTE_Dim_ecart_nodal]);
289     double fechantillonnage = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_CARTE_Dim_fechantillonnage]);
290     double festimation = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_CARTE_Dim_festimation]);
291     FCT_GENERATEUR_CONSTANTE *carte = new FCT_GENERATEUR_CONSTANTE(*gest,ecart_nodal);
292     affiche((char*)"Construction de la carte");
293     carte->construit(fechantillonnage,festimation);
294     affiche((char*)"Enregistrement de la carte");
295     char nom_fichier[1000];
296     sprintf(nom_fichier,"%s",param_ver->get_nom(VE_PARAM_CHAR[VE_PARAM::VE_IO_nom_fichier_CARTE]).c_str());
297     carte->enregistrer(nom_fichier);
298     metrique = carte;
299     affiche((char*)"Fin");
300     break;
301     }
302     }
303     return 0;
304     }
305    
306     int VE_VES::appliquer_conditions_limites_plan(TPL_MAP_ENTITE< MG_FACE* >* plan, char* condition, double valeur,bool topo_sous_jacente)
307     {
308     TPL_MAP_ENTITE<MG_FACE*>::ITERATEUR it_face_plan;
309     for(MG_FACE *face = plan->get_premier(it_face_plan);face!=NULL;face=plan->get_suivant(it_face_plan))
310     {
311     face->ajouter_ccf(condition,valeur);
312     if(topo_sous_jacente==true)
313     {
314     TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> map_topo;
315     face->get_topologie_sousjacente(&map_topo);
316     TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*>::ITERATEUR it_topo;
317     for(MG_ELEMENT_TOPOLOGIQUE *topo=map_topo.get_premier(it_topo);topo!=NULL;topo=map_topo.get_suivant(it_topo))
318     {
319     topo->ajouter_ccf(condition,valeur);
320     }
321     }
322     }
323     }
324    
325     int VE_VES::appliquer_conditions_limites_plan(TPL_MAP_ENTITE< MG_FACE* >* plan, char* condition, std::string formule,std::vector<std::string> &listvariable,bool topo_sous_jacente)
326     {
327     TPL_MAP_ENTITE<MG_FACE*>::ITERATEUR it_face_plan;
328     for(MG_FACE *face = plan->get_premier(it_face_plan);face!=NULL;face=plan->get_suivant(it_face_plan))
329     {
330     face->ajouter_ccf(condition,formule,listvariable);
331     if(topo_sous_jacente==true)
332     {
333     TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> map_topo;
334     face->get_topologie_sousjacente(&map_topo);
335     TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*>::ITERATEUR it_topo;
336     for(MG_ELEMENT_TOPOLOGIQUE *topo=map_topo.get_premier(it_topo);topo!=NULL;topo=map_topo.get_suivant(it_topo))
337     {
338     topo->ajouter_ccf(condition,formule,listvariable);
339     }
340     }
341     }
342     }
343    
344     int VE_VES::appliquer_conditions_limites(int type_chargement)
345     {
346     TPL_MAP_ENTITE<MG_FACE*> plan_xy_z0;
347     TPL_MAP_ENTITE<MG_FACE*> plan_xy_z1;
348     TPL_MAP_ENTITE<MG_FACE*> plan_yz_x0;
349     TPL_MAP_ENTITE<MG_FACE*> plan_yz_x1;
350     TPL_MAP_ENTITE<MG_FACE*> plan_xz_y0;
351     TPL_MAP_ENTITE<MG_FACE*> plan_xz_y1;
352     MG_SOMMET* sommet_origine;
353     MG_SOMMET* sommet_x1y0z0;
354     MG_SOMMET* sommet_x0y1z0;
355     MG_SOMMET* sommet_x0y0z1;
356     double eps = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_Dim_precision]);
357    
358     MG_GEOMETRIE *geo = gest->get_mg_geometrie(0);
359     std::map<unsigned long,MG_FACE*,std::less<unsigned long>>::iterator it_face;
360     for(MG_FACE *face = geo->get_premier_face(it_face);face!=NULL;face=geo->get_suivant_face(it_face))
361     {
362     TPL_SET<MG_ELEMENT_MAILLAGE*> *liste_element_maillage = face->get_lien_maillage();
363     MG_TRIANGLE *tri = (MG_TRIANGLE*)liste_element_maillage->get(0);
364     MG_NOEUD *nd[3];
365     nd[0] = tri->get_noeud1();
366     nd[1] = tri->get_noeud2();
367     nd[2] = tri->get_noeud3();
368    
369     if(OPERATEUR::egal(nd[0]->get_z(),0,eps) && OPERATEUR::egal(nd[1]->get_z(),0,eps) && OPERATEUR::egal(nd[2]->get_z(),0,eps))
370     {
371     plan_xy_z0.ajouter(face);
372     }
373     else if(OPERATEUR::egal(nd[0]->get_z(),dim_VES[2],eps) && OPERATEUR::egal(nd[1]->get_z(),dim_VES[2],eps) && OPERATEUR::egal(nd[2]->get_z(),dim_VES[2],eps))
374     {
375     plan_xy_z1.ajouter(face);
376     }
377     else if(OPERATEUR::egal(nd[0]->get_x(),0,eps) && OPERATEUR::egal(nd[1]->get_x(),0,eps) && OPERATEUR::egal(nd[2]->get_x(),0,eps))
378     {
379     plan_yz_x0.ajouter(face);
380     }
381     else if(OPERATEUR::egal(nd[0]->get_x(),dim_VES[0],eps) && OPERATEUR::egal(nd[1]->get_x(),dim_VES[0],eps) && OPERATEUR::egal(nd[2]->get_x(),dim_VES[0],eps))
382     {
383     plan_yz_x1.ajouter(face);
384     }
385     else if(OPERATEUR::egal(nd[0]->get_y(),0,eps) && OPERATEUR::egal(nd[1]->get_y(),0,eps) && OPERATEUR::egal(nd[2]->get_y(),0,eps))
386     {
387     plan_xz_y0.ajouter(face);
388     }
389     else if(OPERATEUR::egal(nd[0]->get_y(),dim_VES[1],eps) && OPERATEUR::egal(nd[1]->get_y(),dim_VES[1],eps) && OPERATEUR::egal(nd[2]->get_y(),dim_VES[1],eps))
390     {
391     plan_xz_y1.ajouter(face);
392     }
393     }
394    
395     std::map<unsigned long,MG_SOMMET*,std::less<unsigned long>>::iterator it_sommet;
396     for(MG_SOMMET* som=geo->get_premier_sommet(it_sommet);som!=NULL;som=geo->get_suivant_sommet(it_sommet))
397     {
398     TPL_SET<MG_ELEMENT_MAILLAGE*> *liste_element_maillage = som->get_lien_maillage();
399     MG_NOEUD* nd = (MG_NOEUD*)liste_element_maillage->get(0);
400     if(OPERATEUR::egal(nd->get_x(),0,eps) && OPERATEUR::egal(nd->get_y(),0,eps) && OPERATEUR::egal(nd->get_z(),0,eps))
401     {
402     sommet_origine=som;
403     }
404     else if(OPERATEUR::egal(nd->get_x(),dim_VES[0],eps) && OPERATEUR::egal(nd->get_y(),0,eps) && OPERATEUR::egal(nd->get_z(),0,eps))
405     {
406     sommet_x1y0z0=som;
407     }
408     else if(OPERATEUR::egal(nd->get_x(),0,eps) && OPERATEUR::egal(nd->get_y(),dim_VES[1],eps) && OPERATEUR::egal(nd->get_z(),0,eps))
409     {
410     sommet_x0y1z0=som;
411     }
412     else if(OPERATEUR::egal(nd->get_x(),0,eps) && OPERATEUR::egal(nd->get_y(),0,eps) && OPERATEUR::egal(nd->get_z(),dim_VES[2],eps))
413     {
414     sommet_x0y0z1=som;
415     }
416     }
417    
418     int type_cl = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_VER_CL_Type]);
419     double valeur_cl = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_VER_CL_Dim_valeur]);
420    
421     switch(type_chargement)
422     {
423     case VE_TYPE_CHARGEMENT::SPHERIQUE:
424     {
425     switch(type_cl)
426     {
427     case VE_TYPE_CL::DEFORMATION_HOMOGENE:
428     {
429     appliquer_conditions_limites_plan(&plan_xy_z0,(char*)"Dz",0.0,true);
430     appliquer_conditions_limites_plan(&plan_xy_z1,(char*)"Dz",valeur_cl,true);
431     appliquer_conditions_limites_plan(&plan_yz_x0,(char*)"Dx",0.0,true);
432     appliquer_conditions_limites_plan(&plan_yz_x1,(char*)"Dx",valeur_cl,true);
433     appliquer_conditions_limites_plan(&plan_xz_y0,(char*)"Dy",0.0,true);
434     appliquer_conditions_limites_plan(&plan_xz_y1,(char*)"Dy",valeur_cl,true);
435     break;
436     }
437     case VE_TYPE_CL::CONTRAINTE_HOMOGENE:
438     {
439     appliquer_conditions_limites_plan(&plan_xy_z0,(char*)"Dz",0.0,true);
440     appliquer_conditions_limites_plan(&plan_xy_z1,(char*)"Pz",valeur_cl,false);
441     appliquer_conditions_limites_plan(&plan_yz_x0,(char*)"Dx",0.0,true);
442     appliquer_conditions_limites_plan(&plan_yz_x1,(char*)"Px",valeur_cl,false);
443     appliquer_conditions_limites_plan(&plan_xz_y0,(char*)"Dy",0.0,true);
444     appliquer_conditions_limites_plan(&plan_xz_y1,(char*)"Py",valeur_cl,false);
445     break;
446     }
447     case VE_TYPE_CL::FLUX_CHALEUR_HOMOGENE:
448     {
449     break;
450     }
451     case VE_TYPE_CL::GRADIENT_TEMPERATURE_HOMOGENE:
452     {
453     break;
454     }
455     }
456     break;
457     }
458    
459     case VE_TYPE_CHARGEMENT::DEVIATORIQUE:
460     {
461     switch(type_cl)
462     {
463     case VE_TYPE_CL::DEFORMATION_HOMOGENE:
464     {
465     char chr_valeur_cl[1000];
466     sprintf(chr_valeur_cl,"%lf",valeur_cl);
467     std::string str_valeur_cl = chr_valeur_cl;
468     std::string formule_Dx = str_valeur_cl+ "*Y";
469     std::string formule_Dy = str_valeur_cl+ "*Z";
470     std::string formule_Dz = str_valeur_cl+ "*X";
471     std::vector<std::string> liste_variable_formule_Dx;
472     std::vector<std::string> liste_variable_formule_Dy;
473     std::vector<std::string> liste_variable_formule_Dz;
474     liste_variable_formule_Dx.push_back((std::string)"Y");
475     liste_variable_formule_Dy.push_back((std::string)"Z");
476     liste_variable_formule_Dz.push_back((std::string)"X");
477     appliquer_conditions_limites_plan(&plan_xy_z0,(char*)"Dx",formule_Dx,liste_variable_formule_Dx,true);
478     appliquer_conditions_limites_plan(&plan_xy_z0,(char*)"Dy",formule_Dy,liste_variable_formule_Dy,true);
479     appliquer_conditions_limites_plan(&plan_xy_z0,(char*)"Dz",formule_Dz,liste_variable_formule_Dz,true);
480     appliquer_conditions_limites_plan(&plan_xy_z1,(char*)"Dx",formule_Dx,liste_variable_formule_Dx,true);
481     appliquer_conditions_limites_plan(&plan_xy_z1,(char*)"Dy",formule_Dy,liste_variable_formule_Dy,true);
482     appliquer_conditions_limites_plan(&plan_xy_z1,(char*)"Dz",formule_Dz,liste_variable_formule_Dz,true);
483     appliquer_conditions_limites_plan(&plan_yz_x0,(char*)"Dx",formule_Dx,liste_variable_formule_Dx,true);
484     appliquer_conditions_limites_plan(&plan_yz_x0,(char*)"Dy",formule_Dy,liste_variable_formule_Dy,true);
485     appliquer_conditions_limites_plan(&plan_yz_x0,(char*)"Dz",formule_Dz,liste_variable_formule_Dz,true);
486     appliquer_conditions_limites_plan(&plan_yz_x1,(char*)"Dx",formule_Dx,liste_variable_formule_Dx,true);
487     appliquer_conditions_limites_plan(&plan_yz_x1,(char*)"Dy",formule_Dy,liste_variable_formule_Dy,true);
488     appliquer_conditions_limites_plan(&plan_yz_x1,(char*)"Dz",formule_Dz,liste_variable_formule_Dz,true);
489     appliquer_conditions_limites_plan(&plan_xz_y0,(char*)"Dx",formule_Dx,liste_variable_formule_Dx,true);
490     appliquer_conditions_limites_plan(&plan_xz_y0,(char*)"Dy",formule_Dy,liste_variable_formule_Dy,true);
491     appliquer_conditions_limites_plan(&plan_xz_y0,(char*)"Dz",formule_Dz,liste_variable_formule_Dz,true);
492     appliquer_conditions_limites_plan(&plan_xz_y1,(char*)"Dx",formule_Dx,liste_variable_formule_Dx,true);
493     appliquer_conditions_limites_plan(&plan_xz_y1,(char*)"Dy",formule_Dy,liste_variable_formule_Dy,true);
494     appliquer_conditions_limites_plan(&plan_xz_y1,(char*)"Dz",formule_Dz,liste_variable_formule_Dz,true);
495     break;
496     }
497    
498     case VE_TYPE_CL::CONTRAINTE_HOMOGENE:
499     {
500     sommet_origine->ajouter_ccf((char*)"Dt",0.0);
501     sommet_x1y0z0->ajouter_ccf((char*)"Dy",0.0);
502     sommet_x1y0z0->ajouter_ccf((char*)"Dz",0.0);
503     sommet_x0y1z0->ajouter_ccf((char*)"Dz",0.0);
504     appliquer_conditions_limites_plan(&plan_xy_z0,(char*)"Px",-valeur_cl,true);
505     appliquer_conditions_limites_plan(&plan_xy_z0,(char*)"Py",-valeur_cl,true);
506     appliquer_conditions_limites_plan(&plan_xy_z1,(char*)"Px",valeur_cl,true);
507     appliquer_conditions_limites_plan(&plan_xy_z1,(char*)"Py",valeur_cl,true);
508     appliquer_conditions_limites_plan(&plan_xz_y0,(char*)"Px",-valeur_cl,true);
509     appliquer_conditions_limites_plan(&plan_xz_y0,(char*)"Pz",-valeur_cl,true);
510     appliquer_conditions_limites_plan(&plan_xz_y1,(char*)"Px",valeur_cl,true);
511     appliquer_conditions_limites_plan(&plan_xz_y1,(char*)"Pz",valeur_cl,true);
512     appliquer_conditions_limites_plan(&plan_yz_x0,(char*)"Py",-valeur_cl,true);
513     appliquer_conditions_limites_plan(&plan_yz_x0,(char*)"Pz",-valeur_cl,true);
514     appliquer_conditions_limites_plan(&plan_yz_x1,(char*)"Py",valeur_cl,true);
515     appliquer_conditions_limites_plan(&plan_yz_x1,(char*)"Pz",valeur_cl,true);
516     break;
517     }
518     case VE_TYPE_CL::FLUX_CHALEUR_HOMOGENE:
519     {
520     break;
521     }
522     case VE_TYPE_CL::GRADIENT_TEMPERATURE_HOMOGENE:
523     {
524     break;
525     }
526     }
527     break;
528     }
529     }
530     return 0;
531     }
532    
533     int VE_VES::appliquer_materiaux(void)
534     {
535     double nu_inclu = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_INCLU_Dim_mu_nu]);
536     double nu_matrice = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_MATRICE_Dim_mu_nu]);
537     double Em_inclu = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_INCLU_Dim_mu_Em]);
538     double Em_matrice = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_MATRICE_Dim_mu_Em]);
539     MG_GEOMETRIE *geo = gest->get_mg_geometrie(0);
540     MG_VOLUME *matrice = geo->get_mg_volume(geo->get_nb_mg_volume()-1);
541     std::map<unsigned long,MG_VOLUME*,std::less<unsigned long>>::iterator it_volume;
542     for(MG_VOLUME *volume = geo->get_premier_volume(it_volume);volume!=matrice;volume=geo->get_suivant_volume(it_volume))
543     {
544     volume->ajouter_ccf((char*)"nu",nu_inclu);
545     volume->ajouter_ccf((char*)"Em",Em_inclu);
546     }
547     matrice->ajouter_ccf((char*)"nu",nu_matrice);
548     matrice->ajouter_ccf((char*)"Em",Em_matrice);
549     return 0;
550     }
551    
552     int VE_VES::creer_fem_maillage(void)
553     {
554     MG_GEOMETRIE *geo = gest->get_mg_geometrie(0);
555     MG_MAILLAGE *mai = gest->get_mg_maillage(gest->get_nb_mg_maillage()-1);
556     int degre_mail = (int)param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_MAIL_Dim_degre_maillage]);
557     FEM_MAILLAGE *fem = new FEM_MAILLAGE(geo,mai,degre_mail);
558     gest->ajouter_fem_maillage(fem);
559     fem->construire();
560     return 0;
561     }
562    
563     int VE_VES::calcul_aster(void)
564     {
565     char coderesu[500];
566     char nomparam[500];
567     char nometude[500];
568     sprintf(nometude,"%s",param_ver->get_nom(VE_PARAM_CHAR[VE_PARAM::VE_IO_nom_fichier_ETUDE]).c_str());
569     sprintf(nomparam,"%s",param_ver->get_nom(VE_PARAM_CHAR[VE_PARAM::VE_IO_nom_fichier_param_ASTER]).c_str());
570     sprintf(coderesu,"%s",param_ver->get_nom(VE_PARAM_CHAR[VE_PARAM::VE_IO_code_resu]).c_str());
571     MGASTER mgaster;
572     mgaster.active_affichage(fonc_affiche);
573     mgaster.calcule(nomparam,gest->get_fem_maillage(0),nometude,MAGIC::CALCUL_ASTER::ELASTIQUE,coderesu);
574     }
575    
576     int VE_VES::homogeneisation(void)
577     {
578     FEM_SOLUTION* sol=gest->get_fem_solution(1);
579     FEM_SOLUTION* sol2=gest->get_fem_solution(2);
580     double exx=sol->get_moyenne_volumique_champs(NULL,0);
581     double eyy=sol->get_moyenne_volumique_champs(NULL,1);
582     double ezz=sol->get_moyenne_volumique_champs(NULL,2);
583     double exy=sol->get_moyenne_volumique_champs(NULL,3);
584     double exz=sol->get_moyenne_volumique_champs(NULL,4);
585     double eyz=sol->get_moyenne_volumique_champs(NULL,5);
586     double sxx=sol2->get_moyenne_volumique_champs(NULL,0);
587     double syy=sol2->get_moyenne_volumique_champs(NULL,1);
588     double szz=sol2->get_moyenne_volumique_champs(NULL,2);
589     double sxy=sol2->get_moyenne_volumique_champs(NULL,3);
590     double sxz=sol2->get_moyenne_volumique_champs(NULL,4);
591     double syz=sol2->get_moyenne_volumique_champs(NULL,5);
592     double traces=sxx+syy+szz;
593     double tracee=exx+eyy+ezz;
594     char message[1000];
595     affiche((char*)"");
596     sprintf(message, "Tenseur des deformations :"); affiche(message);
597     sprintf(message, " | exx=% 3.2le exy=% 3.2le exz=% 3.2le |",exx,exy,exz); affiche(message);
598     sprintf(message, " | exy=% 3.2le eyy=% 3.2le eyz=% 3.2le |",exy,eyy,eyz); affiche(message);
599     sprintf(message, " | exz=% 3.2le eyz=% 3.2le ezz=% 3.2le |",exz,eyz,ezz); affiche(message);
600     affiche((char*)"");
601     sprintf(message, " Trace e = % 3.2le",tracee); affiche(message);
602     affiche((char*)"");
603     sprintf(message, "Tenseur des contraintes :"); affiche(message);
604     sprintf(message, " | sxx=% 3.2le sxy=% 3.2le sxz=% 3.2le |",sxx,sxy,sxz); affiche(message);
605     sprintf(message, " | sxy=% 3.2le syy=% 3.2le syz=% 3.2le |",sxy,syy,syz); affiche(message);
606     sprintf(message, " | sxz=% 3.2le syz=% 3.2le szz=% 3.2le |",sxz,syz,szz); affiche(message);
607     affiche((char*)"");
608     sprintf(message, " Trace s = % 3.2le",traces); affiche(message);
609     affiche((char*)"");
610     int type_chargement = param_ver->get_valeur(VE_PARAM_CHAR[VE_PARAM::VE_VER_CL_CHARGEMENT_type]);
611     if(type_chargement==VE_TYPE_CHARGEMENT::SPHERIQUE)
612     {
613     double K = traces/3./tracee;
614     sprintf(message, "Module de compressibilite apparent :"); affiche(message);
615     sprintf(message, " Kapp = % 3.5le",K); affiche(message);
616     }
617     else if(type_chargement==VE_TYPE_CHARGEMENT::DEVIATORIQUE)
618     {
619     double G = (1./3.)*((syz/(2.*eyz))+(sxz/(2.*exz))+(sxy/(2.*exy)));
620     sprintf(message, "Module de cisaillement apparent :"); affiche(message);
621     sprintf(message, " Gapp = % 3.5le",G); affiche(message);
622     }
623     }