ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/microstructure/src/mstruct_ves.cpp
Revision: 919
Committed: Tue Mar 6 17:51:54 2018 UTC (7 years, 2 months ago) by couturad
File size: 46798 byte(s)
Log Message:
Correction des bugs lors de l'execution en mode RELWITHDEBINFO.
Ajouts de fichiers pour la librairie MICROSTRUCTURE

File Contents

# User Rev Content
1 couturad 919 #include "mstruct_ves.h"
2     #include "mg_volume.h"
3     #include "mg_geometrie.h"
4     #include "mg_maillage.h"
5     #include "fem_maillage.h"
6     #include "mg_gestionnaire.h"
7     #include "mstruct_groupe_volume.h"
8     #include "mstruct_parametres.h"
9     #include "mstruct_generateur_rsa.h"
10     #include "mg_cg_modele.h"
11     #include "mg_cg_assemblage.h"
12     #include "mg_sous_geometrie.h"
13     #include "mg_cg_forme_multi_volume.h"
14     #include "mg_file.h"
15     #include "fct_taille_fem_solution_generateur_microstructure.h"
16     #include "mailleur0d.h"
17     #include "mailleur1d.h"
18     #include "mailleur2d.h"
19     #include "mailleur3d.h"
20     #include "mailleur_fem.h"
21     #include "mailleur_analyse.h"
22     #include <fstream>
23     #include "mgaster.h"
24     #include "ot_cpu.h"
25     #include "mstruct_outils.h"
26     #include "mstruct_groupe_forme.h"
27     using namespace MICROSTRUCTURE;
28     VES::VES(void)
29     {
30     m_mg_gestionnaire=new MG_GESTIONNAIRE;
31     m_mg_geometrie=NULL;
32     m_mgcg_modele=NULL;
33     m_mg_maillage=NULL;
34     m_fem_maillage=NULL;
35     m_boite3D_ves = BOITE_3D(0.0,0.0,0.0,1.0,1.0,1.0);
36     m_eps=1.0e-06;
37     m_temps_generation_geometrie=0.0;
38     m_temps_generation_materiau=0.0;
39     m_temps_generation_carte=0.0;
40     m_temps_generation_maillage=0.0;
41     m_temps_generation_fem_maillage=0.0;
42     m_temps_generation_etude=0.0;
43     m_temps_calcul=0.0;
44     }
45    
46     VES::VES(char* fichier)
47     {
48     m_mgcg_modele=NULL;
49     m_mgcg_assemblage=NULL;
50     m_mg_geometrie=NULL;
51     m_mg_maillage=NULL;
52     m_fem_maillage=NULL;
53     m_boite3D_ves = BOITE_3D(0.0,0.0,0.0,1.0,1.0,1.0);
54     m_eps=1.0e-06;
55     m_temps_generation_geometrie=0.0;
56     m_temps_generation_materiau=0.0;
57     m_temps_generation_carte=0.0;
58     m_temps_generation_maillage=0.0;
59     m_temps_generation_fem_maillage=0.0;
60     m_temps_generation_etude=0.0;
61     m_temps_calcul=0.0;
62     importer(fichier);
63     }
64    
65     VES::~VES(void)
66     {
67     std::vector<GROUPE_FORME*>::iterator it;
68     for(GROUPE_FORME* groupe_forme=get_premier_groupe_forme(it);groupe_forme!=NULL;groupe_forme=get_suivant_groupe_forme(it))
69     {
70     delete groupe_forme;
71     }
72     delete m_mg_gestionnaire;
73     }
74    
75     MG_GESTIONNAIRE* VES::get_mg_gestionnaire(void)
76     {
77     return m_mg_gestionnaire;
78     }
79    
80     void VES::change_mg_geometrie(MG_GEOMETRIE* mg_geometrie)
81     {
82     m_mg_geometrie=mg_geometrie;
83     }
84    
85     MG_GEOMETRIE* VES::get_mg_geometrie(void)
86     {
87     return m_mg_geometrie;
88     }
89    
90     void VES::change_mgcg_assemblage(MG_CG_ASSEMBLAGE* mgcg_assemblage)
91     {
92     m_mgcg_assemblage=mgcg_assemblage;
93     }
94    
95     MG_CG_ASSEMBLAGE* VES::get_mgcg_assemblage(void)
96     {
97     return m_mgcg_assemblage;
98     }
99    
100     void VES::change_mgcg_modele(MG_CG_MODELE* mgcg_modele)
101     {
102     m_mgcg_modele=mgcg_modele;
103     }
104    
105     MG_CG_MODELE* VES::get_mgcg_modele(void)
106     {
107     return m_mgcg_modele;
108     }
109    
110     MG_MAILLAGE* VES::get_mg_maillage(void)
111     {
112     return m_mg_maillage;
113     }
114    
115     void VES::change_mg_maillage(MG_MAILLAGE* mg_maillage)
116     {
117     m_mg_maillage=mg_maillage;
118     }
119    
120     FEM_MAILLAGE* VES::get_fem_maillage(void)
121     {
122     return m_fem_maillage;
123     }
124    
125     void VES::change_fem_maillage(FEM_MAILLAGE* fem_maillage)
126     {
127     m_fem_maillage=fem_maillage;
128     }
129    
130     long int VES::get_nb_groupe_forme(void)
131     {
132     return m_vector_groupe_forme.size();
133     }
134    
135     void VES::ajouter_groupe_forme(GROUPE_FORME* groupe_forme)
136     {
137     m_vector_groupe_forme.push_back(groupe_forme);
138     }
139    
140     GROUPE_FORME* VES::get_premier_groupe_forme(std::vector< GROUPE_FORME* >::iterator& it)
141     {
142     it=m_vector_groupe_forme.begin();
143     if(it==m_vector_groupe_forme.end()) return NULL;
144     return *it;
145     }
146    
147     GROUPE_FORME* VES::get_suivant_groupe_forme(std::vector< GROUPE_FORME* >::iterator& it)
148     {
149     it++;
150     if(it==m_vector_groupe_forme.end()) return NULL;
151     return *it;
152     }
153    
154     GROUPE_FORME* VES::get_groupe_forme(string nom)
155     {
156     std::vector< GROUPE_FORME* >::iterator it;
157     for(GROUPE_FORME* groupe_forme=get_premier_groupe_forme(it);groupe_forme!=NULL;groupe_forme=get_suivant_groupe_forme(it))
158     {
159     if(groupe_forme->get_nom()==nom) return groupe_forme;
160     }
161     return NULL;
162     }
163    
164     BOITE_3D VES::get_boite3d_ves(void)
165     {
166     return m_boite3D_ves;
167     }
168    
169    
170     int VES::generer_geometrie(std::vector< OT_PARAMETRES* >& vector_params_geometrie)
171     {
172     OT_CPU ot_cpu;
173     ot_cpu.initialise();
174     GENERATEUR* generateur=NULL;
175     std::vector<OT_PARAMETRES*>::iterator it;
176     for(it=vector_params_geometrie.begin();it!=vector_params_geometrie.end();it++)
177     {
178     OT_PARAMETRES* param = *it;
179     if(((int)param->get_valeur((char*)"Type_generateur"))==GENERATEUR::TYPE_GENERATEUR::RSA)
180     {
181     GENERATEUR_RSA *RSA;
182     std::string Nom_mgcg_modele = param->get_nom((char*)"Nom_mgcg_modele");
183     double Boite3D_distribution_Xmin = param->get_valeur((char*)"Boite3D_distribution_Xmin");
184     double Boite3D_distribution_Ymin = param->get_valeur((char*)"Boite3D_distribution_Ymin");
185     double Boite3D_distribution_Zmin = param->get_valeur((char*)"Boite3D_distribution_Zmin");
186     double Boite3D_distribution_Xmax = param->get_valeur((char*)"Boite3D_distribution_Xmax");
187     double Boite3D_distribution_Ymax = param->get_valeur((char*)"Boite3D_distribution_Ymax");
188     double Boite3D_distribution_Zmax = param->get_valeur((char*)"Boite3D_distribution_Zmax");
189     BOITE_3D Boite3D_distribution(Boite3D_distribution_Xmin,
190     Boite3D_distribution_Ymin,
191     Boite3D_distribution_Zmin,
192     Boite3D_distribution_Xmax,
193     Boite3D_distribution_Ymax,
194     Boite3D_distribution_Zmax);
195     double Nb_pas_X = param->get_valeur((char*)"Nb_pas_X");
196     double Nb_pas_Y = param->get_valeur((char*)"Nb_pas_Y");
197     double Nb_pas_Z = param->get_valeur((char*)"Nb_pas_Z");
198     if(generateur==NULL)
199     {
200     RSA = new GENERATEUR_RSA(m_mg_gestionnaire,(char*)Nom_mgcg_modele.c_str(),m_boite3D_ves,Boite3D_distribution,Nb_pas_X,Nb_pas_Y,Nb_pas_Z);
201     generateur=RSA;
202     }
203     std::string Nom_groupe_inclusion = param->get_nom((char*)"Nom_groupe_inclusion");
204     int Type_inclusion = param->get_valeur((char*)"Type_inclusion");
205     bool Porosite = (bool)param->get_valeur((char*)"Porosite");
206     double Distance_min_inter_volume = param->get_valeur((char*)"Distance_min_inter_volume");
207     double Volume_min = param->get_valeur((char*)"Volume_min");
208     double Aire_min = param->get_valeur((char*)"Aire_min");
209     double Longueur_min = param->get_valeur((char*)"Longueur_min");
210     double Angle_min = param->get_valeur((char*)"Angle_min");
211     double Nb_volume_max = param->get_valeur((char*)"Nb_volume_max");
212     double Nb_iteration_max = param->get_valeur((char*)"Nb_iteration_max");
213     double Fraction_volumique_cible = param->get_valeur((char*)"Fraction_volumique_cible");
214     if(Type_inclusion==GENERATEUR_RSA::TYPE_INCLUSION::SPHERE)
215     {
216     double Mu_rayon = param->get_valeur((char*)"Mu_rayon");
217     double Sigma_rayon = param->get_valeur((char*)"Sigma_rayon");
218     RSA->tirrage_aleatoire_sphere(Nom_groupe_inclusion,
219     Mu_rayon,Sigma_rayon,
220     Fraction_volumique_cible,
221     Distance_min_inter_volume,
222     Volume_min,
223     Aire_min,
224     Longueur_min,
225     Angle_min,
226     Nb_volume_max,
227     Nb_iteration_max,
228     Porosite);
229     }
230     else if(Type_inclusion==GENERATEUR_RSA::TYPE_INCLUSION::CYLINDRE)
231     {
232     double Mu_rayon = param->get_valeur((char*)"Mu_rayon");
233     double Sigma_rayon = param->get_valeur((char*)"Sigma_rayon");
234     double Mu_longueur = param->get_valeur((char*)"Mu_longueur");
235     double Sigma_longueur = param->get_valeur((char*)"Sigma_longueur");
236     double Mu_axe_X = param->get_valeur((char*)"Mu_axe_X");
237     double Sigma_axe_X = param->get_valeur((char*)"Sigma_axe_X");
238     double Type_distribution_axe_X = param->get_valeur((char*)"Type_distribution_axe_X");
239     double Mu_axe_Y = param->get_valeur((char*)"Type_distribution_axe_X");
240     double Sigma_axe_Y = param->get_valeur((char*)"Sigma_axe_Y");
241     double Type_distribution_axe_Y = param->get_valeur((char*)"Type_distribution_axe_Y");
242     double Mu_axe_Z = param->get_valeur((char*)"Mu_axe_Z");
243     double Sigma_axe_Z = param->get_valeur((char*)"Sigma_axe_Z");
244     double Type_distribution_axe_Z = param->get_valeur((char*)"Type_distribution_axe_Z");
245     RSA->tirrage_aleatoire_cylindre(Nom_groupe_inclusion,
246     Mu_rayon,Sigma_rayon,
247     Mu_longueur,Sigma_longueur,
248     Mu_axe_X,Sigma_axe_X,Type_distribution_axe_X,
249     Mu_axe_Y,Sigma_axe_Y,Type_distribution_axe_Y,
250     Mu_axe_Z,Sigma_axe_Z,Type_distribution_axe_Z,Fraction_volumique_cible,
251     Distance_min_inter_volume,
252     Volume_min,
253     Aire_min,
254     Longueur_min,
255     Angle_min,
256     Nb_volume_max,
257     Nb_iteration_max,
258     Porosite);
259     }
260    
261     }
262     }
263     ot_cpu.ajouter_etape((char*)"generation_geometrie");
264     ot_cpu.get_etape((char*)"generation_geometrie",m_temps_generation_geometrie);
265     generateur->construire(this);
266     delete generateur;
267     return OK;
268     }
269    
270     int VES::generer_materiau(std::vector< OT_PARAMETRES* >& vector_params_materiau)
271     {
272     OT_CPU ot_cpu;
273     ot_cpu.initialise();
274     std::vector<OT_PARAMETRES*>::iterator it;
275     for(it=vector_params_materiau.begin();it!=vector_params_materiau.end();it++)
276     {
277     OT_PARAMETRES* param = *it;
278     std::string Nom_groupe_forme = param->get_nom((char*)"Nom_groupe_forme");
279     double Mu_E = param->get_valeur((char*)"Mu_E");
280     double Sigma_E = param->get_valeur((char*)"Sigma_E");
281     double Mu_nu = param->get_valeur((char*)"Mu_nu");
282     double Sigma_nu = param->get_valeur((char*)"Sigma_nu");
283     GROUPE_FORME* groupe_forme = get_groupe_forme(Nom_groupe_forme);
284     TPL_MAP_ENTITE<MG_CG_FORME*> tpl_map_forme = groupe_forme->get_tpl_map_forme();
285     TPL_MAP_ENTITE<MG_CG_FORME*>::ITERATEUR it_forme;
286     for(MG_CG_FORME* forme = tpl_map_forme.get_premier(it_forme);forme!=NULL;forme=tpl_map_forme.get_suivant(it_forme))
287     {
288     if(forme->get_type_forme()==MG_CG_FORME::TYPE_FORME::VOLUME)
289     {
290     MG_CG_FORME_VOLUME* forme_volume = (MG_CG_FORME_VOLUME*)forme;
291     if(Sigma_E==0.0) forme_volume->get_mg_volume()->ajouter_ccf((char*)"Em",Mu_E);
292     else
293     {
294     std::random_device seed;
295     std::mt19937_64 generateur(seed());
296     std::normal_distribution<double> distribution(Mu_E,Sigma_E);
297     double Em = distribution(generateur);
298     forme_volume->get_mg_volume()->ajouter_ccf((char*)"Em",Em);
299     }
300     if(Sigma_nu==0.0) forme_volume->get_mg_volume()->ajouter_ccf((char*)"nu",Mu_nu);
301     else
302     {
303     std::random_device seed;
304     std::mt19937_64 generateur(seed());
305     std::normal_distribution<double> distribution(Mu_nu,Sigma_nu);
306     double nu = distribution(generateur);
307     forme_volume->get_mg_volume()->ajouter_ccf((char*)"nu",nu);
308     }
309     }
310     if(forme->get_type_forme()==MG_CG_FORME::TYPE_FORME::MULTI_VOLUME)
311     {
312     MG_CG_FORME_MULTI_VOLUME* forme_multi_volume = (MG_CG_FORME_MULTI_VOLUME*)forme;
313     std::map<long,MG_VOLUME*>::iterator it_volume;
314     for(MG_VOLUME* volume = forme_multi_volume->get_premier_mg_volume(it_volume);volume!=NULL;volume=forme_multi_volume->get_suivant_mg_volume(it_volume))
315     {
316     if(Sigma_E==0.0) volume->ajouter_ccf((char*)"Em",Mu_E);
317     else
318     {
319     std::random_device seed;
320     std::mt19937_64 generateur(seed());
321     std::normal_distribution<double> distribution(Mu_E,Sigma_E);
322     double Em = distribution(generateur);
323     volume->ajouter_ccf((char*)"Em",Em);
324     }
325     if(Sigma_nu==0.0) volume->ajouter_ccf((char*)"nu",Mu_nu);
326     else
327     {
328     std::random_device seed;
329     std::mt19937_64 generateur(seed());
330     std::normal_distribution<double> distribution(Mu_nu,Sigma_nu);
331     double nu = distribution(generateur);
332     volume->ajouter_ccf((char*)"nu",nu);
333     }
334     }
335     }
336     }
337     }
338     ot_cpu.ajouter_etape((char*)"generation_materiau");
339     ot_cpu.get_etape((char*)"generation_materiau",m_temps_generation_materiau);
340     return OK;
341     }
342    
343     int VES::generer_carte(OT_PARAMETRES *param)
344     {
345     double Ecart_nodal = param->get_valeur((char*)"Ecart_nodal");
346     double Fechantillonnage = param->get_valeur((char*)"Fechantillonnage");
347     double Nb_cellule_direction = param->get_valeur((char*)"Nb_cellule_direction");
348     std::string Nom_fem_solution = param->get_nom((char*)"Nom_fem_solution");
349     std::string Nom_mg_gestionnaire_carte = param->get_nom((char*)"Nom_mg_gestionnaire_carte");
350     std::string Nom_carte = param->get_nom((char*)"Nom_carte");
351     double Nb_couche_min = param->get_valeur((char*)"Nb_couche_min");
352     double Nb_pas = param->get_valeur((char*)"Nb_pas");
353     double Facteur_augmentation = param->get_valeur((char*)"Facteur_augmentation");
354     MG_GESTIONNAIRE *mggest_carte = new MG_GESTIONNAIRE;
355     MICROSTRUCTURE::GROUPE_FORME* groupe_matrice = get_groupe_forme((char*)"Matrice");
356     TPL_MAP_ENTITE<MG_VOLUME*> tpl_map_volume_matrice = groupe_matrice->get_tpl_map_volume();
357     OT_CPU ot_cpu;
358     ot_cpu.initialise();
359     FCT_TAILLE_FEM_SOLUTION_GENERATEUR_MICROSTRUCTURE *carte = new FCT_TAILLE_FEM_SOLUTION_GENERATEUR_MICROSTRUCTURE(mggest_carte,
360     m_mg_geometrie,
361     Ecart_nodal,
362     Fechantillonnage,
363     Nb_cellule_direction,
364     (char*)Nom_fem_solution.c_str(),
365     tpl_map_volume_matrice,
366     Nb_couche_min,
367     Nb_pas,
368     Facteur_augmentation);
369     ot_cpu.ajouter_etape((char*)"generation_carte");
370     ot_cpu.get_etape((char*)"generation_carte",m_temps_generation_carte);
371     mggest_carte->enregistrer(Nom_mg_gestionnaire_carte.c_str());
372     carte->construit();
373     carte->enregistrer((char*)Nom_carte.c_str());
374     return OK;
375     }
376    
377     int VES::generer_maillage(OT_PARAMETRES *param,FCT_TAILLE_FEM_SOLUTION* carte)
378     {
379     OT_CPU ot_cpu;
380     ot_cpu.initialise();
381     int Niveau = (int)param->get_valeur((char*)"Niveau");
382     int Niveau_opt_2d = (int)param->get_valeur((char*)"Niveau_opt_2d");
383     int Niveau_opt_3d = (int)param->get_valeur((char*)"Niveau_opt_3d");
384     double Priorite_metrique = param->get_valeur((char*)"Priorite_metrique");
385     int Analyse = (int)param->get_valeur((char*)"Analyse");
386     affiche((char*)"Maillage du VER :");
387     m_mg_maillage = new MG_MAILLAGE(m_mg_geometrie);
388     m_mg_gestionnaire->ajouter_mg_maillage(m_mg_maillage);
389     MAILLEUR0D m0d(m_mg_maillage,m_mg_geometrie);
390     affiche((char*)" Maillage 0D :");
391     LISTE_MG_SOMMET::iterator it_sommet;
392     for(MG_SOMMET* sommet=m_mg_geometrie->get_premier_sommet(it_sommet);sommet!=NULL;sommet=m_mg_geometrie->get_suivant_sommet(it_sommet))
393     {
394     char message[1000];
395     sprintf(message," -> Maillage du sommet id %li",sommet->get_id());
396     affiche(message);
397     m0d.maille(sommet);
398     }
399    
400     MAILLEUR1D m1d(m_mg_maillage,m_mg_geometrie,carte);
401     affiche((char*)" Maillage 1D :");
402     m1d.active_affichage(fonc_affiche);
403     LISTE_MG_ARETE::iterator it_arete;
404     for(MG_ARETE* arete=m_mg_geometrie->get_premier_arete(it_arete);arete!=NULL;arete=m_mg_geometrie->get_suivant_arete(it_arete))
405     {
406     char message[1000];
407     sprintf(message," -> Maillage de l'arete id %li",arete->get_id());
408     affiche(message);
409     m1d.maille(arete);
410     }
411     MAILLEUR2D m2d(m_mg_maillage,m_mg_geometrie,carte);
412     m2d.change_niveau_optimisation(Niveau_opt_2d);
413     m2d.change_priorite_metrique(Priorite_metrique);
414     affiche((char*)" Maillage 2D :");
415     m2d.active_affichage(fonc_affiche);
416     LISTE_MG_FACE::iterator it_face;
417     for(MG_FACE* face=m_mg_geometrie->get_premier_face(it_face);face!=NULL;face=m_mg_geometrie->get_suivant_face(it_face))
418     {
419     char message[1000];
420     sprintf(message," -> Maillage de la face id %li",face->get_id());
421     affiche(message);
422     m2d.maille(face);
423     }
424     MAILLEUR3D m3d(m_mg_maillage,m_mg_geometrie,carte,false);
425     m3d.change_niveau_optimisation(Niveau_opt_2d);
426     m3d.change_priorite_metrique(Priorite_metrique);
427     affiche((char*)" Maillage 3D :");
428     m3d.active_affichage(fonc_affiche);
429     LISTE_MG_VOLUME::iterator it_volume;
430     for(MG_VOLUME* volume=m_mg_geometrie->get_premier_volume(it_volume);volume!=NULL;volume=m_mg_geometrie->get_suivant_volume(it_volume))
431     {
432     char message[1000];
433     sprintf(message," -> Maillage du volume id %li",volume->get_id());
434     affiche(message);
435     m3d.maille(volume);
436     }
437     ot_cpu.ajouter_etape((char*)"generation_maillage");
438     ot_cpu.get_etape((char*)"generation_maillage",m_temps_generation_maillage);
439     return OK;
440     }
441    
442     int VES::generer_fem_maillage(OT_PARAMETRES *param)
443     {
444     OT_CPU ot_cpu;
445     ot_cpu.initialise();
446     int Degre = (int)param->get_valeur((char*)"Degre");
447     int Analyse = (int)param->get_valeur((char*)"Analyse");
448     int Optimisation_num_noeud = (int)param->get_valeur((char*)"Optimisation_num_noeud");
449     MAILLEUR_FEM mailleurfem;
450     mailleurfem.active_affichage(fonc_affiche);
451     m_fem_maillage=new FEM_MAILLAGE(m_mg_maillage->get_mg_geometrie(),m_mg_maillage,Degre);
452     m_mg_gestionnaire->ajouter_fem_maillage(m_fem_maillage);
453     if(Optimisation_num_noeud) mailleurfem.maille(m_fem_maillage,1);
454     else mailleurfem.maille(m_fem_maillage,0);
455     if(Analyse)
456     {
457     MAILLEUR_ANALYSE m3d(m_fem_maillage);
458     m3d.active_affichage(fonc_affiche);
459     // m3d.analyse();
460     }
461     ot_cpu.ajouter_etape((char*)"generation_fem_maillage");
462     ot_cpu.get_etape((char*)"generation_fem_maillage",m_temps_generation_fem_maillage);
463     return OK;
464     }
465    
466     int VES::generer_etude(OT_PARAMETRES *param)
467     {
468     OT_CPU ot_cpu;
469     ot_cpu.initialise();
470     TPL_MAP_ENTITE<MG_FACE*> plan_xy_z0;
471     TPL_MAP_ENTITE<MG_FACE*> plan_xy_z1;
472     TPL_MAP_ENTITE<MG_FACE*> plan_yz_x0;
473     TPL_MAP_ENTITE<MG_FACE*> plan_yz_x1;
474     TPL_MAP_ENTITE<MG_FACE*> plan_xz_y0;
475     TPL_MAP_ENTITE<MG_FACE*> plan_xz_y1;
476     std::map<unsigned long,MG_FACE*,std::less<unsigned long>>::iterator it_face;
477     for(MG_FACE *face = m_mg_geometrie->get_premier_face(it_face);face!=NULL;face=m_mg_geometrie->get_suivant_face(it_face))
478     {
479     double xyzmin[3];
480     double xyzmax[3];
481     face->get_xyz_min_max(xyzmin,xyzmax,16);
482    
483     if(OPERATEUR::egal(xyzmin[0],m_boite3D_ves.get_xmin(),m_eps) && OPERATEUR::egal(xyzmax[0],m_boite3D_ves.get_xmin(),m_eps)) plan_yz_x0.ajouter(face);
484     else if(OPERATEUR::egal(xyzmin[0],m_boite3D_ves.get_xmax(),m_eps) && OPERATEUR::egal(xyzmax[0],m_boite3D_ves.get_xmax(),m_eps)) plan_yz_x1.ajouter(face);
485     else if(OPERATEUR::egal(xyzmin[1],m_boite3D_ves.get_ymin(),m_eps) && OPERATEUR::egal(xyzmax[1],m_boite3D_ves.get_ymin(),m_eps)) plan_xz_y0.ajouter(face);
486     else if(OPERATEUR::egal(xyzmin[1],m_boite3D_ves.get_ymax(),m_eps) && OPERATEUR::egal(xyzmax[1],m_boite3D_ves.get_ymax(),m_eps)) plan_xz_y1.ajouter(face);
487     else if(OPERATEUR::egal(xyzmin[2],m_boite3D_ves.get_zmin(),m_eps) && OPERATEUR::egal(xyzmax[2],m_boite3D_ves.get_zmin(),m_eps)) plan_xy_z0.ajouter(face);
488     else if(OPERATEUR::egal(xyzmin[2],m_boite3D_ves.get_zmax(),m_eps) && OPERATEUR::egal(xyzmax[2],m_boite3D_ves.get_zmax(),m_eps)) plan_xy_z1.ajouter(face);
489     }
490     MG_SOMMET* sommet_origine;
491     MG_SOMMET* sommet_x1y0z0;
492     MG_SOMMET* sommet_x0y1z0;
493     MG_SOMMET* sommet_x0y0z1;
494     std::map<unsigned long,MG_SOMMET*,std::less<unsigned long>>::iterator it_sommet;
495     for(MG_SOMMET* som=m_mg_geometrie->get_premier_sommet(it_sommet);som!=NULL;som=m_mg_geometrie->get_suivant_sommet(it_sommet))
496     {
497     double xyz[3];
498     som->get_point()->evaluer(xyz);
499     if(OPERATEUR::egal(xyz[0],m_boite3D_ves.get_xmin(),m_eps) && OPERATEUR::egal(xyz[1],m_boite3D_ves.get_ymin(),m_eps) && OPERATEUR::egal(xyz[2],m_boite3D_ves.get_zmin(),m_eps)) sommet_origine=som;
500     else if(OPERATEUR::egal(xyz[0],m_boite3D_ves.get_xmax(),m_eps) && OPERATEUR::egal(xyz[1],m_boite3D_ves.get_ymin(),m_eps) && OPERATEUR::egal(xyz[2],m_boite3D_ves.get_zmin(),m_eps)) sommet_x1y0z0=som;
501     else if(OPERATEUR::egal(xyz[0],m_boite3D_ves.get_xmin(),m_eps) && OPERATEUR::egal(xyz[1],m_boite3D_ves.get_ymax(),m_eps) && OPERATEUR::egal(xyz[2],m_boite3D_ves.get_zmin(),m_eps)) sommet_x0y1z0=som;
502     else if(OPERATEUR::egal(xyz[0],m_boite3D_ves.get_xmin(),m_eps) && OPERATEUR::egal(xyz[1],m_boite3D_ves.get_ymin(),m_eps) && OPERATEUR::egal(xyz[2],m_boite3D_ves.get_zmax(),m_eps)) sommet_x0y0z1=som;
503     }
504     int Type_etude = (int)param->get_valeur((char*)"Type_etude");
505     int Type_Chargement = (int)param->get_valeur((char*)"Type_Chargement");
506     int Type_CL = (int)param->get_valeur((char*)"Type_CL");
507     double Valeur_CL = param->get_valeur((char*)"Valeur_CL");
508     if(Type_etude==TYPE_ETUDE::MECANIQUE)
509     {
510     if(Type_Chargement==TYPE_CHARGEMENT::SPHERIQUE)
511     {
512     if(Type_CL==TYPE_CONDITIONS_LIMITES::DEFORMATION_HOMOGENE)
513     {
514     appliquer_conditions_limites_plan(&plan_xy_z0,(char*)"Dz",0.0,true);
515     appliquer_conditions_limites_plan(&plan_xy_z1,(char*)"Dz",Valeur_CL,true);
516     appliquer_conditions_limites_plan(&plan_yz_x0,(char*)"Dx",0.0,true);
517     appliquer_conditions_limites_plan(&plan_yz_x1,(char*)"Dx",Valeur_CL,true);
518     appliquer_conditions_limites_plan(&plan_xz_y0,(char*)"Dy",0.0,true);
519     appliquer_conditions_limites_plan(&plan_xz_y1,(char*)"Dy",Valeur_CL,true);
520     }
521     else if(Type_CL==TYPE_CONDITIONS_LIMITES::CONTRAINTE_HOMOGENE)
522     {
523     appliquer_conditions_limites_plan(&plan_xy_z0,(char*)"Dz",0.0,true);
524     appliquer_conditions_limites_plan(&plan_xy_z1,(char*)"Pz",Valeur_CL,false);
525     appliquer_conditions_limites_plan(&plan_yz_x0,(char*)"Dx",0.0,true);
526     appliquer_conditions_limites_plan(&plan_yz_x1,(char*)"Px",Valeur_CL,false);
527     appliquer_conditions_limites_plan(&plan_xz_y0,(char*)"Dy",0.0,true);
528     appliquer_conditions_limites_plan(&plan_xz_y1,(char*)"Py",Valeur_CL,false);
529     }
530     }
531     else if(Type_Chargement==TYPE_CHARGEMENT::DEVIATORIQUE)
532     {
533     if(Type_CL==TYPE_CONDITIONS_LIMITES::DEFORMATION_HOMOGENE)
534     {
535     char chr_valeur_cl[1000];
536     sprintf(chr_valeur_cl,"%lf",Valeur_CL);
537     std::string str_valeur_cl = chr_valeur_cl;
538     std::string formule_Dx = str_valeur_cl+ "*Y";
539     std::string formule_Dy = str_valeur_cl+ "*Z";
540     std::string formule_Dz = str_valeur_cl+ "*X";
541     std::vector<std::string> liste_variable_formule_Dx;
542     std::vector<std::string> liste_variable_formule_Dy;
543     std::vector<std::string> liste_variable_formule_Dz;
544     liste_variable_formule_Dx.push_back((std::string)"Y");
545     liste_variable_formule_Dy.push_back((std::string)"Z");
546     liste_variable_formule_Dz.push_back((std::string)"X");
547     appliquer_conditions_limites_plan(&plan_xy_z0,(char*)"Dx",formule_Dx,liste_variable_formule_Dx,true);
548     appliquer_conditions_limites_plan(&plan_xy_z0,(char*)"Dy",formule_Dy,liste_variable_formule_Dy,true);
549     appliquer_conditions_limites_plan(&plan_xy_z0,(char*)"Dz",formule_Dz,liste_variable_formule_Dz,true);
550     appliquer_conditions_limites_plan(&plan_xy_z1,(char*)"Dx",formule_Dx,liste_variable_formule_Dx,true);
551     appliquer_conditions_limites_plan(&plan_xy_z1,(char*)"Dy",formule_Dy,liste_variable_formule_Dy,true);
552     appliquer_conditions_limites_plan(&plan_xy_z1,(char*)"Dz",formule_Dz,liste_variable_formule_Dz,true);
553     appliquer_conditions_limites_plan(&plan_yz_x0,(char*)"Dx",formule_Dx,liste_variable_formule_Dx,true);
554     appliquer_conditions_limites_plan(&plan_yz_x0,(char*)"Dy",formule_Dy,liste_variable_formule_Dy,true);
555     appliquer_conditions_limites_plan(&plan_yz_x0,(char*)"Dz",formule_Dz,liste_variable_formule_Dz,true);
556     appliquer_conditions_limites_plan(&plan_yz_x1,(char*)"Dx",formule_Dx,liste_variable_formule_Dx,true);
557     appliquer_conditions_limites_plan(&plan_yz_x1,(char*)"Dy",formule_Dy,liste_variable_formule_Dy,true);
558     appliquer_conditions_limites_plan(&plan_yz_x1,(char*)"Dz",formule_Dz,liste_variable_formule_Dz,true);
559     appliquer_conditions_limites_plan(&plan_xz_y0,(char*)"Dx",formule_Dx,liste_variable_formule_Dx,true);
560     appliquer_conditions_limites_plan(&plan_xz_y0,(char*)"Dy",formule_Dy,liste_variable_formule_Dy,true);
561     appliquer_conditions_limites_plan(&plan_xz_y0,(char*)"Dz",formule_Dz,liste_variable_formule_Dz,true);
562     appliquer_conditions_limites_plan(&plan_xz_y1,(char*)"Dx",formule_Dx,liste_variable_formule_Dx,true);
563     appliquer_conditions_limites_plan(&plan_xz_y1,(char*)"Dy",formule_Dy,liste_variable_formule_Dy,true);
564     appliquer_conditions_limites_plan(&plan_xz_y1,(char*)"Dz",formule_Dz,liste_variable_formule_Dz,true);
565     }
566     else if(Type_CL==TYPE_CONDITIONS_LIMITES::CONTRAINTE_HOMOGENE)
567     {
568     sommet_origine->ajouter_ccf((char*)"Dt",0.0);
569     sommet_x1y0z0->ajouter_ccf((char*)"Dy",0.0);
570     sommet_x1y0z0->ajouter_ccf((char*)"Dz",0.0);
571     sommet_x0y1z0->ajouter_ccf((char*)"Dz",0.0);
572     appliquer_conditions_limites_plan(&plan_xy_z0,(char*)"Px",-Valeur_CL,true);
573     appliquer_conditions_limites_plan(&plan_xy_z0,(char*)"Py",-Valeur_CL,true);
574     appliquer_conditions_limites_plan(&plan_xy_z1,(char*)"Px",Valeur_CL,true);
575     appliquer_conditions_limites_plan(&plan_xy_z1,(char*)"Py",Valeur_CL,true);
576     appliquer_conditions_limites_plan(&plan_xz_y0,(char*)"Px",-Valeur_CL,true);
577     appliquer_conditions_limites_plan(&plan_xz_y0,(char*)"Pz",-Valeur_CL,true);
578     appliquer_conditions_limites_plan(&plan_xz_y1,(char*)"Px",Valeur_CL,true);
579     appliquer_conditions_limites_plan(&plan_xz_y1,(char*)"Pz",Valeur_CL,true);
580     appliquer_conditions_limites_plan(&plan_yz_x0,(char*)"Py",-Valeur_CL,true);
581     appliquer_conditions_limites_plan(&plan_yz_x0,(char*)"Pz",-Valeur_CL,true);
582     appliquer_conditions_limites_plan(&plan_yz_x1,(char*)"Py",Valeur_CL,true);
583     appliquer_conditions_limites_plan(&plan_yz_x1,(char*)"Pz",Valeur_CL,true);
584     }
585     }
586     }
587     ot_cpu.ajouter_etape((char*)"generation_etude");
588     ot_cpu.get_etape((char*)"generation_etude",m_temps_generation_etude);
589     return OK;
590     }
591    
592     int VES::appliquer_conditions_limites_plan(TPL_MAP_ENTITE< MG_FACE* >* plan, char* condition, double valeur,bool topo_sous_jacente)
593     {
594     TPL_MAP_ENTITE<MG_FACE*>::ITERATEUR it_face_plan;
595     for(MG_FACE *face = plan->get_premier(it_face_plan);face!=NULL;face=plan->get_suivant(it_face_plan))
596     {
597     face->ajouter_ccf(condition,valeur);
598     if(topo_sous_jacente==true)
599     {
600     TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> map_topo;
601     face->get_topologie_sousjacente(&map_topo);
602     TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*>::ITERATEUR it_topo;
603     for(MG_ELEMENT_TOPOLOGIQUE *topo=map_topo.get_premier(it_topo);topo!=NULL;topo=map_topo.get_suivant(it_topo))
604     {
605     topo->ajouter_ccf(condition,valeur);
606     }
607     }
608     }
609     }
610    
611     int 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)
612     {
613     TPL_MAP_ENTITE<MG_FACE*>::ITERATEUR it_face_plan;
614     for(MG_FACE *face = plan->get_premier(it_face_plan);face!=NULL;face=plan->get_suivant(it_face_plan))
615     {
616     face->ajouter_ccf(condition,formule,listvariable);
617     if(topo_sous_jacente==true)
618     {
619     TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> map_topo;
620     face->get_topologie_sousjacente(&map_topo);
621     TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*>::ITERATEUR it_topo;
622     for(MG_ELEMENT_TOPOLOGIQUE *topo=map_topo.get_premier(it_topo);topo!=NULL;topo=map_topo.get_suivant(it_topo))
623     {
624     topo->ajouter_ccf(condition,formule,listvariable);
625     }
626     }
627     }
628     }
629    
630     int VES::calcul(OT_PARAMETRES *param,char* param_aster)
631     {
632     std::string Nom_etude = param->get_nom((char*)"Nom_etude");
633     int Type_etude = (int)param->get_valeur((char*)"Type_etude");
634     int Type_calcul = (int)param->get_valeur((char*)"Type_calcul");
635     std::string Code_resu = param->get_nom((char*)"Code_resu");
636     MGASTER mgaster;
637     mgaster.active_affichage(fonc_affiche);
638     OT_CPU ot_cpu;
639     ot_cpu.initialise();
640     mgaster.calcule(param_aster,m_fem_maillage,(char*)Nom_etude.c_str(),Type_calcul,(char*)Code_resu.c_str());
641     ot_cpu.ajouter_etape((char*)"calcul");
642     ot_cpu.get_etape((char*)"calcul",m_temps_calcul);
643     }
644    
645     int VES::homogeneisation(OT_PARAMETRES *param,char* fichier_resultats)
646     {
647     int Type_etude = (int)param->get_valeur((char*)"Type_etude");
648     int Type_Chargement = (int)param->get_valeur((char*)"Type_Chargement");
649     int Type_CL = (int)param->get_valeur((char*)"Type_CL");
650     double Valeur_CL = param->get_valeur((char*)"Valeur_CL");
651     int nb_forme_total=0;
652     std::ofstream f;
653     f.precision(16);
654     f.open(fichier_resultats,ios::out);
655     std::vector<GROUPE_FORME*>:: iterator it_groupe;
656     double val_min_e[6];
657     double val_max_e[6];
658     FEM_SOLUTION* sol_e=m_mg_gestionnaire->get_fem_solution(1);
659     MICROSTRUCTURE::OUTILS::get_valeur_min_max_champs_elements(sol_e,0,val_min_e[0],val_max_e[0]);
660     MICROSTRUCTURE::OUTILS::get_valeur_min_max_champs_elements(sol_e,1,val_min_e[1],val_max_e[1]);
661     MICROSTRUCTURE::OUTILS::get_valeur_min_max_champs_elements(sol_e,2,val_min_e[2],val_max_e[2]);
662     MICROSTRUCTURE::OUTILS::get_valeur_min_max_champs_elements(sol_e,3,val_min_e[3],val_max_e[3]);
663     MICROSTRUCTURE::OUTILS::get_valeur_min_max_champs_elements(sol_e,4,val_min_e[4],val_max_e[4]);
664     MICROSTRUCTURE::OUTILS::get_valeur_min_max_champs_elements(sol_e,5,val_min_e[5],val_max_e[5]);
665     double val_min_s[6];
666     double val_max_s[6];
667     FEM_SOLUTION* sol_s=m_mg_gestionnaire->get_fem_solution(2);
668     MICROSTRUCTURE::OUTILS::get_valeur_min_max_champs_elements(sol_s,0,val_min_s[0],val_max_s[0]);
669     MICROSTRUCTURE::OUTILS::get_valeur_min_max_champs_elements(sol_s,1,val_min_s[1],val_max_s[1]);
670     MICROSTRUCTURE::OUTILS::get_valeur_min_max_champs_elements(sol_s,2,val_min_s[2],val_max_s[2]);
671     MICROSTRUCTURE::OUTILS::get_valeur_min_max_champs_elements(sol_s,3,val_min_s[3],val_max_s[3]);
672     MICROSTRUCTURE::OUTILS::get_valeur_min_max_champs_elements(sol_s,4,val_min_s[4],val_max_s[4]);
673     MICROSTRUCTURE::OUTILS::get_valeur_min_max_champs_elements(sol_s,5,val_min_s[5],val_max_s[5]);
674     for(GROUPE_FORME* groupe_forme=get_premier_groupe_forme(it_groupe);groupe_forme!=NULL;groupe_forme=get_suivant_groupe_forme(it_groupe))
675     {
676     int nb_forme=groupe_forme->get_tpl_map_forme().get_nb();
677     nb_forme_total+=nb_forme;
678     double volume_cad;
679     double fraction_volumique_cad;
680     MICROSTRUCTURE::OUTILS::fraction_volumique_CAD(this,groupe_forme,volume_cad,fraction_volumique_cad,1.0e-06);
681     double volume_mg_maill;
682     double fraction_volumique_mg_maill;
683     MICROSTRUCTURE::OUTILS::fraction_volumique_mg_maillage(this,groupe_forme,volume_mg_maill,fraction_volumique_mg_maill);
684     double volume_fem_maill;
685     double fraction_volumique_fem_maill;
686     MICROSTRUCTURE::OUTILS::fraction_volumique_fem_maillage(this,groupe_forme,volume_fem_maill,fraction_volumique_fem_maill);
687     double e[6];
688     double s[6];
689     MICROSTRUCTURE::OUTILS::moyenne_volumique_champs_e_s(m_mg_gestionnaire->get_fem_solution(0),e,m_mg_gestionnaire->get_fem_solution(1),s,groupe_forme);
690     double a2[6];
691     bool ok_tenseur_orientation=MICROSTRUCTURE::OUTILS::tenseur_orientation(groupe_forme,a2,1.0e-06);
692     f << groupe_forme->get_nom() << "=" << "NB_FORME(" << nb_forme << ")" << std::endl;
693     f << groupe_forme->get_nom() << "=" << "VOLUME_CAD(" << volume_cad << ")" << std::endl;
694     f << groupe_forme->get_nom() << "=" << "FRAC_VOL_CAD(" << fraction_volumique_cad << ")" << std::endl;
695     f << groupe_forme->get_nom() << "=" << "VOLUME_MG_MAILL(" << volume_mg_maill << ")" << std::endl;
696     f << groupe_forme->get_nom() << "=" << "FRAC_VOL_MG_MAILL(" << fraction_volumique_mg_maill << ")" << std::endl;
697     f << groupe_forme->get_nom() << "=" << "VOLUME_FEM_MAILL(" << volume_fem_maill << ")" << std::endl;
698     f << groupe_forme->get_nom() << "=" << "FRAC_VOL_FEM_MAILL(" << fraction_volumique_fem_maill << ")" << std::endl;
699     f << groupe_forme->get_nom() << "=" << "MOY_VOL_DEFORMATIONS(" << e[0] << "," << e[1] << "," << e[2] << "," << e[3] << "," << e[4] << "," << e[5] << "," << ")" << std::endl;
700     f << groupe_forme->get_nom() << "=" << "MOY_VOL_CONTRAINTES(" << s[0] << "," << s[1] << "," << s[2] << "," << s[3] << "," << s[4] << "," << s[5] << "," << ")" << std::endl;
701     if(ok_tenseur_orientation) f << groupe_forme->get_nom() << "=" << "TENSEUR_ORIENTATION(" << a2[0] << "," << a2[1] << "," << a2[2] << "," << a2[3] << "," << a2[4] << "," << a2[5] << "," << ")" << std::endl;
702     // OT_HISTOGRAMME histo_exx(val_min_e[0],val_max_e[0],10);
703     // MICROSTRUCTURE::OUTILS::histogramme_champs_elements(histo_exx,groupe_forme,sol_e,0);
704     // OT_HISTOGRAMME histo_eyy(val_min_e[1],val_max_e[1],10);
705     // MICROSTRUCTURE::OUTILS::histogramme_champs_elements(histo_eyy,groupe_forme,sol_e,1);
706     // OT_HISTOGRAMME histo_ezz(val_min_e[2],val_max_e[2],10);
707     // MICROSTRUCTURE::OUTILS::histogramme_champs_elements(histo_ezz,groupe_forme,sol_e,2);
708     // OT_HISTOGRAMME histo_exy(val_min_e[3],val_max_e[3],10);
709     // MICROSTRUCTURE::OUTILS::histogramme_champs_elements(histo_exy,groupe_forme,sol_e,3);
710     // OT_HISTOGRAMME histo_exz(val_min_e[4],val_max_e[4],10);
711     // MICROSTRUCTURE::OUTILS::histogramme_champs_elements(histo_exz,groupe_forme,sol_e,4);
712     // OT_HISTOGRAMME histo_eyz(val_min_e[5],val_max_e[5],10);
713     // MICROSTRUCTURE::OUTILS::histogramme_champs_elements(histo_eyz,groupe_forme,sol_e,5);
714     // f << groupe_forme->get_nom() << "=" << "HISTOGRAMME_EXX(" << histo_exx.get_valeur_min() << "," << histo_exx.get_valeur_max() << "," << histo_exx.get_nb_valeurs_intervalle() << "," << histo_exx.get_nb_colonnes() << ",(";
715     // for(int i=0;i<histo_exx.get_nb_colonnes()-1;i++) f << histo_exx.get_frequence(i) << ",";
716     // f << histo_exx.get_frequence(histo_exx.get_nb_colonnes()-1) << "),";
717     // f << histo_exx.get_nb_valeurs_inferieur_intervalle() << "," << histo_exx.get_nb_valeurs_superieur_intervalle() << ")" << std::endl;
718     // f << groupe_forme->get_nom() << "=" << "HISTOGRAMME_EYY(" << histo_eyy.get_valeur_min() << "," << histo_eyy.get_valeur_max() << "," << histo_eyy.get_nb_valeurs_intervalle() << "," << histo_eyy.get_nb_colonnes() << ",(";
719     // for(int i=0;i<histo_eyy.get_nb_colonnes()-1;i++) f << histo_eyy.get_frequence(i) << ",";
720     // f << histo_eyy.get_frequence(histo_eyy.get_nb_colonnes()-1) << "),";
721     // f << histo_eyy.get_nb_valeurs_inferieur_intervalle() << "," << histo_eyy.get_nb_valeurs_superieur_intervalle() << ")" << std::endl;
722     // f << groupe_forme->get_nom() << "=" << "HISTOGRAMME_EZZ(" << histo_ezz.get_valeur_min() << "," << histo_ezz.get_valeur_max() << "," << histo_ezz.get_nb_valeurs_intervalle() << "," << histo_ezz.get_nb_colonnes() << ",(";
723     // for(int i=0;i<histo_ezz.get_nb_colonnes()-1;i++) f << histo_ezz.get_frequence(i) << ",";
724     // f << histo_ezz.get_frequence(histo_ezz.get_nb_colonnes()-1) << "),";
725     // f << histo_ezz.get_nb_valeurs_inferieur_intervalle() << "," << histo_ezz.get_nb_valeurs_superieur_intervalle() << ")" << std::endl;
726     // f << groupe_forme->get_nom() << "=" << "HISTOGRAMME_EXY(" << histo_exy.get_valeur_min() << "," << histo_exy.get_valeur_max() << "," << histo_exy.get_nb_valeurs_intervalle() << "," << histo_exy.get_nb_colonnes() << ",(";
727     // for(int i=0;i<histo_exy.get_nb_colonnes()-1;i++) f << histo_exy.get_frequence(i) << ",";
728     // f << histo_exy.get_frequence(histo_exy.get_nb_colonnes()-1) << "),";
729     // f << histo_exy.get_nb_valeurs_inferieur_intervalle() << "," << histo_exy.get_nb_valeurs_superieur_intervalle() << ")" << std::endl;
730     // f << groupe_forme->get_nom() << "=" << "HISTOGRAMME_EXZ(" << histo_exz.get_valeur_min() << "," << histo_exz.get_valeur_max() << "," << histo_exz.get_nb_valeurs_intervalle() << "," << histo_exz.get_nb_colonnes() << ",(";
731     // for(int i=0;i<histo_exz.get_nb_colonnes()-1;i++) f << histo_exz.get_frequence(i) << ",";
732     // f << histo_exz.get_frequence(histo_exz.get_nb_colonnes()-1) << "),";
733     // f << histo_exz.get_nb_valeurs_inferieur_intervalle() << "," << histo_exz.get_nb_valeurs_superieur_intervalle() << ")" << std::endl;
734     // f << groupe_forme->get_nom() << "=" << "HISTOGRAMME_EYZ(" << histo_eyz.get_valeur_min() << "," << histo_eyz.get_valeur_max() << "," << histo_eyz.get_nb_valeurs_intervalle() << "," << histo_eyz.get_nb_colonnes() << ",(";
735     // for(int i=0;i<histo_eyz.get_nb_colonnes()-1;i++) f << histo_eyz.get_frequence(i) << ",";
736     // f << histo_eyz.get_frequence(histo_eyz.get_nb_colonnes()-1) << "),";
737     // f << histo_eyz.get_nb_valeurs_inferieur_intervalle() << "," << histo_eyz.get_nb_valeurs_superieur_intervalle() << ")" << std::endl;
738     }
739     // double volume_cad;
740     // double fraction_volumique_cad;
741     // MICROSTRUCTURE::OUTILS::fraction_volumique_CAD(this,NULL,volume_cad,fraction_volumique_cad,1.0e-06);
742     // double volume_mg_maill;
743     // double fraction_volumique_mg_maill;
744     // MICROSTRUCTURE::OUTILS::fraction_volumique_mg_maillage(this,NULL,volume_mg_maill,fraction_volumique_mg_maill);
745     // double volume_fem_maill;
746     // double fraction_volumique_fem_maill;
747     // MICROSTRUCTURE::OUTILS::fraction_volumique_fem_maillage(this,NULL,volume_fem_maill,fraction_volumique_fem_maill);
748     // double e[6];
749     // double s[6];
750     // MICROSTRUCTURE::OUTILS::moyenne_volumique_champs_e_s(m_mg_gestionnaire->get_fem_solution(0),e,m_mg_gestionnaire->get_fem_solution(1),s,NULL);
751     // f << "MICROSTRUCTURE=" << "NB_FORME(" << nb_forme_total << ")" << std::endl;
752     // f << "MICROSTRUCTURE=" << "VOLUME_CAD(" << volume_cad << ")" << std::endl;
753     // f << "MICROSTRUCTURE=" << "FRAC_VOL_CAD(" << fraction_volumique_cad << ")" << std::endl;
754     // f << "MICROSTRUCTURE=" << "VOLUME_MG_MAILL(" << volume_mg_maill << ")" << std::endl;
755     // f << "MICROSTRUCTURE=" << "FRAC_VOL_MG_MAILL(" << fraction_volumique_mg_maill << ")" << std::endl;
756     // f << "MICROSTRUCTURE=" << "VOLUME_FEM_MAILL(" << volume_fem_maill << ")" << std::endl;
757     // f << "MICROSTRUCTURE=" << "FRAC_VOL_FEM_MAILL(" << fraction_volumique_fem_maill << ")" << std::endl;
758     // f << "MICROSTRUCTURE=" << "MOY_VOL_DEFORMATIONS(" << e[0] << "," << e[1] << "," << e[2] << "," << e[3] << "," << e[4] << "," << e[5] << "," << ")" << std::endl;
759     // f << "MICROSTRUCTURE=" << "MOY_VOL_CONTRAINTES(" << s[0] << "," << s[1] << "," << s[2] << "," << s[3] << "," << s[4] << "," << s[5] << "," << ")" << std::endl;
760     // OT_HISTOGRAMME histo_exx(val_min_e[0],val_max_e[0],10);
761     // MICROSTRUCTURE::OUTILS::histogramme_champs_volumique_elements(histo_exx,NULL,m_boite3D_ves.get_volume(),sol_e,0);
762     // OT_HISTOGRAMME histo_eyy(val_min_e[1],val_max_e[1],10);
763     // MICROSTRUCTURE::OUTILS::histogramme_champs_volumique_elements(histo_eyy,NULL,m_boite3D_ves.get_volume(),sol_e,1);
764     // OT_HISTOGRAMME histo_ezz(val_min_e[2],val_max_e[2],10);
765     // MICROSTRUCTURE::OUTILS::histogramme_champs_volumique_elements(histo_ezz,NULL,m_boite3D_ves.get_volume(),sol_e,2);
766     // OT_HISTOGRAMME histo_exy(val_min_e[3],val_max_e[3],10);
767     // MICROSTRUCTURE::OUTILS::histogramme_champs_volumique_elements(histo_exy,NULL,m_boite3D_ves.get_volume(),sol_e,3);
768     // OT_HISTOGRAMME histo_exz(val_min_e[4],val_max_e[4],10);
769     // MICROSTRUCTURE::OUTILS::histogramme_champs_volumique_elements(histo_exz,NULL,m_boite3D_ves.get_volume(),sol_e,4);
770     // OT_HISTOGRAMME histo_eyz(val_min_e[5],val_max_e[5],10);
771     // MICROSTRUCTURE::OUTILS::histogramme_champs_volumique_elements(histo_eyz,NULL,m_boite3D_ves.get_volume(),sol_e,5);
772     // f << "MICROSTRUCTURE=" << "HISTOGRAMME_EXX(" << histo_exx.get_x_min() << "," << histo_exx.get_x_max() << "," << histo_exx.get_nb_observations() << "," << histo_exx.get_nb_colonnes() << ",(";
773     // for(int i=0;i<histo_exx.get_nb_colonnes()-1;i++) f << histo_exx.get_y(i) << ",";
774     // f << histo_exx.get_y(histo_exx.get_nb_colonnes()-1) << ")" << std::endl;
775     // f << "MICROSTRUCTURE=" << "HISTOGRAMME_EYY(" << histo_eyy.get_x_min() << "," << histo_eyy.get_x_max() << "," << histo_eyy.get_nb_observations() << "," << histo_eyy.get_nb_colonnes() << ",(";
776     // for(int i=0;i<histo_eyy.get_nb_colonnes()-1;i++) f << histo_eyy.get_y(i) << ",";
777     // f << histo_eyy.get_y(histo_eyy.get_nb_colonnes()-1) << ")" << std::endl;
778     // f << "MICROSTRUCTURE=" << "HISTOGRAMME_EZZ(" << histo_ezz.get_x_min() << "," << histo_ezz.get_x_max() << "," << histo_ezz.get_nb_observations() << "," << histo_ezz.get_nb_colonnes() << ",(";
779     // for(int i=0;i<histo_ezz.get_nb_colonnes()-1;i++) f << histo_ezz.get_y(i) << ",";
780     // f << histo_ezz.get_y(histo_ezz.get_nb_colonnes()-1) << ")" << std::endl;
781     // f << "MICROSTRUCTURE=" << "HISTOGRAMME_EXY(" << histo_exy.get_x_min() << "," << histo_exy.get_x_max() << "," << histo_exy.get_nb_observations() << "," << histo_exy.get_nb_colonnes() << ",(";
782     // for(int i=0;i<histo_exy.get_nb_colonnes()-1;i++) f << histo_exy.get_y(i) << ",";
783     // f << histo_exy.get_y(histo_exy.get_nb_colonnes()-1) << ")" << std::endl;
784     // f << "MICROSTRUCTURE=" << "HISTOGRAMME_EXZ(" << histo_exz.get_x_min() << "," << histo_exz.get_x_max() << "," << histo_exz.get_nb_observations() << "," << histo_exz.get_nb_colonnes() << ",(";
785     // for(int i=0;i<histo_exz.get_nb_colonnes()-1;i++) f << histo_exz.get_y(i) << ",";
786     // f << histo_exz.get_y(histo_exz.get_nb_colonnes()-1) << ")" << std::endl;
787     // f << "MICROSTRUCTURE=" << "HISTOGRAMME_EYZ(" << histo_eyz.get_x_min() << "," << histo_eyz.get_x_max() << "," << histo_eyz.get_nb_observations() << "," << histo_eyz.get_nb_colonnes() << ",(";
788     // for(int i=0;i<histo_eyz.get_nb_colonnes()-1;i++) f << histo_eyz.get_y(i) << ",";
789     // f << histo_eyz.get_y(histo_eyz.get_nb_colonnes()-1) << ")" << std::endl;
790     // f << "MICROSTRUCTURE=" << "TEMPS_GEOMETRIE(" << m_temps_generation_geometrie << ")" << std::endl;
791     // f << "MICROSTRUCTURE=" << "TEMPS_MATERIAU(" << m_temps_generation_materiau << ")" << std::endl;
792     // f << "MICROSTRUCTURE=" << "TEMPS_CARTE(" << m_temps_generation_carte << ")" << std::endl;
793     // f << "MICROSTRUCTURE=" << "TEMPS_MG_MAILLAGE(" << m_temps_generation_maillage << ")" << std::endl;
794     // f << "MICROSTRUCTURE=" << "TEMPS_FEM_MAILLAGE(" << m_temps_generation_fem_maillage << ")" << std::endl;
795     // f << "MICROSTRUCTURE=" << "TEMPS_ETUDE(" << m_temps_generation_etude << ")" << std::endl;
796     // f << "MICROSTRUCTURE=" << "TEMPS_CALCUL(" << m_temps_calcul << ")" << std::endl;
797     f.close();
798     }
799    
800     int VES::enregistrer(char *fichier_ves,char* fichier_magic)
801     {
802     std::ofstream f;
803     f.open(fichier_ves,ios::out);
804     f << "FICHIER_MAGIC " << fichier_magic << std::endl;
805     if(m_mgcg_modele!=NULL) f << "MG_CG_MODELE " << m_mgcg_modele->get_id() << std::endl;
806     else f << "MG_CG_MODELE NULL" << std::endl;
807     if(m_mgcg_assemblage!=NULL) f << "MG_CG_ASSEMBLAGE " << m_mgcg_assemblage->get_id() << std::endl;
808     else f << "MG_CG_ASSEMBLAGE NULL" << std::endl;
809     if(m_mg_geometrie!=NULL) f << "MG_GEOMETRIE " << m_mg_geometrie->get_id() << std::endl;
810     else f << "MG_GEOMETRIE NULL" << std::endl;
811     if(m_mg_maillage!=NULL) f << "MG_MAILLAGE " << m_mg_maillage->get_id() << std::endl;
812     else f << "MG_MAILLAGE NULL" << std::endl;
813     if(m_fem_maillage!=NULL) f << "FEM_MAILLAGE " << m_fem_maillage->get_id() << std::endl;
814     else f << "FEM_MAILLAGE NULL" << std::endl;
815     f << "NB_GROUPE_VOLUME " << get_nb_groupe_forme() << std::endl;
816     std::vector< GROUPE_FORME* >::iterator it;
817     for(GROUPE_FORME* groupe_forme=get_premier_groupe_forme(it);groupe_forme!=NULL;groupe_forme=get_suivant_groupe_forme(it))
818     {
819     groupe_forme->exporter(f);
820     }
821     f << "TEMPS_CPU (sec)" << std::endl;
822     if(m_temps_generation_geometrie>0) f << "TEMPS_GENERATION_GEOMETRIE " << m_temps_generation_geometrie << std::endl;
823     else f << "TEMPS_GENERATION_GEOMETRIE NULL" << std::endl;
824     if(m_temps_generation_materiau>0) f << "TEMPS_GENERATION_MATERIAU " << m_temps_generation_materiau << std::endl;
825     else f << "TEMPS_GENERATION_MATERIAU NULL" << std::endl;
826     if(m_temps_generation_carte>0) f << "TEMPS_GENERATION_CARTE " << m_temps_generation_carte << std::endl;
827     else f << "TEMPS_GENERATION_CARTE NULL" << std::endl;
828     if(m_temps_generation_maillage>0) f << "TEMPS_GENERATION_MAILLAGE " << m_temps_generation_maillage << std::endl;
829     else f << "TEMPS_GENERATION_MAILLAGE NULL" << std::endl;
830     if(m_temps_generation_fem_maillage>0) f << "TEMPS_GENERATION_FEM_MAILLAGE " << m_temps_generation_fem_maillage << std::endl;
831     else f << "TEMPS_GENERATION_FEM_MAILLAGE NULL" << std::endl;
832     if(m_temps_generation_etude>0) f << "TEMPS_GENERATION_ETUDE " << m_temps_generation_etude << std::endl;
833     else f << "TEMPS_GENERATION_ETUDE NULL" << std::endl;
834     if(m_temps_calcul>0) f << "TEMPS_CALCUL " << m_temps_calcul << std::endl;
835     else f << "TEMPS_CALCUL NULL" << std::endl;
836     f.close();
837     m_mg_gestionnaire->enregistrer(fichier_magic);
838     }
839    
840     int VES::importer(char* fichier)
841     {
842     std::ifstream f;
843     f.open(fichier,ios::in);
844     std::string str_fichier=fichier;
845     std::size_t found = str_fichier.rfind((char*)"/");
846    
847     std::string str_fichier_magic;
848     if (found!=std::string::npos)
849     {
850     str_fichier_magic=str_fichier.substr(0,found+1);
851     }
852     else str_fichier_magic ="";
853     char ligne[1000];
854     char fichier_magic[1000];
855     f.getline(ligne,1000);
856     sscanf(ligne,"%*s %s",fichier_magic);
857     str_fichier_magic.append(fichier_magic);
858     m_mg_gestionnaire = new MG_FILE((char*)str_fichier_magic.c_str());
859     char chr_id[500];
860     f.getline(ligne,1000);
861     sscanf(ligne,"%*s %s",chr_id);
862     if(strcmp(chr_id,"NULL")!=0)
863     {
864     long id_mgcg_modele = atol(chr_id);
865     m_mgcg_modele=m_mg_gestionnaire->get_mgcg_modeleid(id_mgcg_modele);
866     }
867     f.getline(ligne,1000);
868     sscanf(ligne,"%*s %s",chr_id);
869     if(strcmp(chr_id,"NULL")!=0)
870     {
871     long id_mgcg_assemblage = atol(chr_id);
872     m_mgcg_assemblage=m_mgcg_modele->get_mgcg_assemblageid(id_mgcg_assemblage);
873     }
874     f.getline(ligne,1000);
875     sscanf(ligne,"%*s %s",chr_id);
876     if(strcmp(chr_id,"NULL")!=0)
877     {
878     long id_geometrie = atol(chr_id);
879     m_mg_geometrie=m_mg_gestionnaire->get_mg_geometrieid(id_geometrie);
880     }
881     f.getline(ligne,1000);
882     sscanf(ligne,"%*s %s",chr_id);
883     if(strcmp(chr_id,"NULL")!=0)
884     {
885     long id_mg_maillage = atol(chr_id);
886     m_mg_maillage=m_mg_gestionnaire->get_mg_maillageid(id_mg_maillage);
887     }
888     f.getline(ligne,1000);
889     sscanf(ligne,"%*s %s",chr_id);
890     if(strcmp(chr_id,"NULL")!=0)
891     {
892     long id_fem_maillage = atol(chr_id);
893     m_fem_maillage=m_mg_gestionnaire->get_fem_maillageid(id_fem_maillage);
894     }
895     long nb_groupe_forme;
896     f.getline(ligne,1000);
897     sscanf(ligne,"%*s %li",&nb_groupe_forme);
898     for(long i=0;i<nb_groupe_forme;i++)
899     {
900     GROUPE_FORME* groupe_forme = new GROUPE_FORME;
901     groupe_forme->importer(f,m_mgcg_modele);
902     ajouter_groupe_forme(groupe_forme);
903     }
904     f.getline(ligne,1000);
905     char chr_temps[500];
906     f.getline(ligne,1000);
907     sscanf(ligne,"%*s %s",chr_temps);
908     if(strcmp(chr_temps,"NULL")!=0)
909     {
910     m_temps_generation_geometrie = atof(chr_temps);
911     }
912     f.getline(ligne,1000);
913     sscanf(ligne,"%*s %s",chr_temps);
914     if(strcmp(chr_temps,"NULL")!=0)
915     {
916     m_temps_generation_materiau = atof(chr_temps);
917     }
918     f.getline(ligne,1000);
919     sscanf(ligne,"%*s %s",chr_temps);
920     if(strcmp(chr_temps,"NULL")!=0)
921     {
922     m_temps_generation_carte = atof(chr_temps);
923     }
924     f.getline(ligne,1000);
925     sscanf(ligne,"%*s %s",chr_temps);
926     if(strcmp(chr_temps,"NULL")!=0)
927     {
928     m_temps_generation_maillage = atof(chr_temps);
929     }
930     f.getline(ligne,1000);
931     sscanf(ligne,"%*s %s",chr_temps);
932     if(strcmp(chr_temps,"NULL")!=0)
933     {
934     m_temps_generation_fem_maillage = atof(chr_temps);
935     }
936     f.getline(ligne,1000);
937     sscanf(ligne,"%*s %s",chr_temps);
938     if(strcmp(chr_temps,"NULL")!=0)
939     {
940     m_temps_generation_etude = atof(chr_temps);
941     }
942     f.getline(ligne,1000);
943     sscanf(ligne,"%*s %s",chr_temps);
944     if(strcmp(chr_temps,"NULL")!=0)
945     {
946     m_temps_calcul = atof(chr_temps);
947     }
948     f.close();
949     }
950    
951     void VES::active_affichage(MICROSTRUCTURE::fonction_affiche* fonc)
952     {
953     fonc_affiche = fonc;
954     affichageactif = 1;
955     }
956    
957     void VES::affiche(char* message)
958     {
959     if(affichageactif==1) fonc_affiche(message);
960     }
961    
962    
963    
964    
965