MAGiC  V5.0
Mailleurs Automatiques de Géometries intégrés à la Cao
mstruct_analyse_erosion.cpp
Aller à la documentation de ce fichier.
1 //####//------------------------------------------------------------
2 //####//------------------------------------------------------------
3 //####// MAGiC
4 //####// Jean Christophe Cuilliere et Vincent FRANCOIS
5 //####// Departement de Genie Mecanique - UQTR
6 //####//------------------------------------------------------------
7 //####// MAGIC est un projet de recherche de l equipe ERICCA
8 //####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres
9 //####// http://www.uqtr.ca/ericca
10 //####// http://www.uqtr.ca/
11 //####//------------------------------------------------------------
12 //####//------------------------------------------------------------
13 //####//
14 //####// mstruct_analyse_erosion.cpp
15 //####//
16 //####//------------------------------------------------------------
17 //####//------------------------------------------------------------
18 //####// COPYRIGHT 2000-2024
19 //####// jeu 13 jun 2024 11:58:57 EDT
20 //####//------------------------------------------------------------
21 //####//------------------------------------------------------------
23 #include "mstruct_analyse_champ.h"
25 #include "mstruct_analyse_cao.h"
31 #include "mstruct_definition.h"
32 #include "ot_boite_3d.h"
34 {
36 }
37 
39  double epaisseur_couche,
40  std::string nom_groupe_forme,
41  BOITE_3D* boite_3d):MSTRUCT_ANALYSE(identifiant,nom_groupe_forme,boite_3d)
42 {
43  m_epaisseur_couche=epaisseur_couche;
44 }
45 
46 
48  MSTRUCT_ANALYSE* analyse_initiale,
49  long nb_couche,
50  double epaisseur_couche): MSTRUCT_ANALYSE(identifiant,
51  analyse_initiale->get_nom_groupe_forme(),
52  analyse_initiale->get_boite_analyse()),
53  m_epaisseur_couche(epaisseur_couche)
54 {
55  std::string iden_ini=identifiant+"_0";
56  analyse_initiale->change_identifiant(iden_ini);
57  ajouter_analyse(analyse_initiale);
58  int type_analyse = analyse_initiale->get_type();
59  for(long i=1;i<nb_couche;i++)
60  {
61  MSTRUCT_ANALYSE* nouvelle_analyse;
62  if(type_analyse==MSTRUCT::TYPE_ANALYSE::CHAMP)
63  {
64  MSTRUCT_ANALYSE_CHAMP* analyse_ini_champ = (MSTRUCT_ANALYSE_CHAMP*)analyse_initiale;
65  MSTRUCT_ANALYSE_CHAMP* analyse_champ = new MSTRUCT_ANALYSE_CHAMP(*analyse_ini_champ);
66  nouvelle_analyse=analyse_champ;
67  }
68  else if(type_analyse==MSTRUCT::TYPE_ANALYSE::ORIENTATION)
69  {
70  MSTRUCT_ANALYSE_ORIENTATION* analyse_ini_ori = (MSTRUCT_ANALYSE_ORIENTATION*)analyse_initiale;
71  MSTRUCT_ANALYSE_ORIENTATION* analyse_ori = new MSTRUCT_ANALYSE_ORIENTATION(*analyse_ini_ori);
72  nouvelle_analyse=analyse_ori;
73  }
74  else if(type_analyse==MSTRUCT::TYPE_ANALYSE::CAO)
75  {
76  MSTRUCT_ANALYSE_CAO* analyse_ini_cao = (MSTRUCT_ANALYSE_CAO*)analyse_initiale;
77  MSTRUCT_ANALYSE_CAO* analyse_cao = new MSTRUCT_ANALYSE_CAO(*analyse_ini_cao);
78  nouvelle_analyse=analyse_cao;
79  }
80  else if(type_analyse==MSTRUCT::TYPE_ANALYSE::MAILLAGE_MG)
81  {
82  MSTRUCT_ANALYSE_MG_MAILLAGE* analyse_ini_mg_maill = (MSTRUCT_ANALYSE_MG_MAILLAGE*)analyse_initiale;
83  MSTRUCT_ANALYSE_MG_MAILLAGE* analyse_mg_maill = new MSTRUCT_ANALYSE_MG_MAILLAGE(*analyse_ini_mg_maill);
84  nouvelle_analyse=analyse_mg_maill;
85  }
86  else if(type_analyse==MSTRUCT::TYPE_ANALYSE::MAILLAGE_FEM)
87  {
88  MSTRUCT_ANALYSE_FEM_MAILLAGE* analyse_ini_fem_maill = (MSTRUCT_ANALYSE_FEM_MAILLAGE*)analyse_initiale;
89  MSTRUCT_ANALYSE_FEM_MAILLAGE* analyse_fem_maill = new MSTRUCT_ANALYSE_FEM_MAILLAGE(*analyse_ini_fem_maill);
90  nouvelle_analyse=analyse_fem_maill;
91  }
93  {
94  MSTRUCT_ANALYSE_CONDUCTIVITE_THERMIQUE* analyse_ini_cond_ther = (MSTRUCT_ANALYSE_CONDUCTIVITE_THERMIQUE*)analyse_initiale;
95  MSTRUCT_ANALYSE_CONDUCTIVITE_THERMIQUE* analyse_cond_ther = new MSTRUCT_ANALYSE_CONDUCTIVITE_THERMIQUE(*analyse_ini_cond_ther);
96  nouvelle_analyse=analyse_cond_ther;
97  }
98  else if(type_analyse==MSTRUCT::TYPE_ANALYSE::ENERGIE_HILL)
99  {
100  MSTRUCT_ANALYSE_ENERGIE_HILL* analyse_ini_cond_ther = (MSTRUCT_ANALYSE_ENERGIE_HILL*)analyse_initiale;
101  MSTRUCT_ANALYSE_ENERGIE_HILL* analyse_cond_ther = new MSTRUCT_ANALYSE_ENERGIE_HILL(*analyse_ini_cond_ther);
102  nouvelle_analyse=analyse_cond_ther;
103  }
104  char iden[500];
105  sprintf(iden,"%s_%li",identifiant.c_str(),i);
106  nouvelle_analyse->change_identifiant(iden);
107  if(nouvelle_analyse->get_boite_analyse()==NULL)
108  {
109  nouvelle_analyse->change_boite_analyse(BOITE_3D(0.0,0.0,0.0,1.0,1.0,1.0));
110  }
111  double xmin,ymin,zmin,xmax,ymax,zmax;
112  xmin=nouvelle_analyse->get_boite_analyse()->get_xmin();
113  ymin=nouvelle_analyse->get_boite_analyse()->get_ymin();
114  zmin=nouvelle_analyse->get_boite_analyse()->get_zmin();
115  xmax=nouvelle_analyse->get_boite_analyse()->get_xmax();
116  ymax=nouvelle_analyse->get_boite_analyse()->get_ymax();
117  zmax=nouvelle_analyse->get_boite_analyse()->get_zmax();
118  xmin=xmin+i*m_epaisseur_couche;
119  ymin=ymin+i*m_epaisseur_couche;
120  zmin=zmin+i*m_epaisseur_couche;
121  xmax=xmax-i*m_epaisseur_couche;
122  ymax=ymax-i*m_epaisseur_couche;
123  zmax=zmax-i*m_epaisseur_couche;
124  nouvelle_analyse->get_boite_analyse()->reinit(xmin,ymin,zmin,xmax,ymax,zmax);
125  ajouter_analyse(nouvelle_analyse);
126  }
127 }
128 
129 
131 {
132  std::vector<MSTRUCT_ANALYSE*>::iterator it_analyse;
133  for(MSTRUCT_ANALYSE* analyse=get_premiere_analyse(it_analyse);analyse!=NULL;analyse=get_suivante_analyse(it_analyse)) delete analyse;
134 }
135 
137 {
138  return m_epaisseur_couche;
139 }
140 
142 {
143  return m_vector_analyse.size();
144 }
145 
147 {
148  char iden[500];
149  sprintf(iden,"%s_%li",m_identifiant.c_str(),get_nb_analyse());
150  analyse->change_identifiant(iden);
151  m_vector_analyse.push_back(analyse);
152  return 0;
153 }
154 
155 MSTRUCT_ANALYSE* MSTRUCT_ANALYSE_EROSION::get_premiere_analyse(std::vector<MSTRUCT_ANALYSE*>::iterator& it)
156 {
157  it=m_vector_analyse.begin();
158  if(it!=m_vector_analyse.end()) return *it;
159  else return NULL;
160 }
161 
162 MSTRUCT_ANALYSE* MSTRUCT_ANALYSE_EROSION::get_suivante_analyse(std::vector<MSTRUCT_ANALYSE*>::iterator& it)
163 {
164  it++;
165  if(it!=m_vector_analyse.end()) return *it;
166  else return NULL;
167 }
168 
170 {
171  return m_vector_analyse.at(num);
172 }
173 
175 {
177 }
178 
180 {
181  std::vector<MSTRUCT_ANALYSE*>::iterator it_analyse;
182  for(MSTRUCT_ANALYSE* analyse=get_premiere_analyse(it_analyse);analyse!=NULL;analyse=get_suivante_analyse(it_analyse)) analyse->executer();
183 }
184 
185 void MSTRUCT_ANALYSE_EROSION::exporter(std::ofstream& ofstrm, long i, bool avec_entete, bool avec_graph, char* prefix_graph)
186 {
187  std::vector<MSTRUCT_ANALYSE*>::iterator it_analyse;
188  for(MSTRUCT_ANALYSE* analyse=get_premiere_analyse(it_analyse);analyse!=NULL;analyse=get_suivante_analyse(it_analyse))
189  {
190  ofstrm << analyse->get_identifiant() << std::endl;
191  analyse->exporter(ofstrm,i,avec_entete,avec_graph,prefix_graph);
192  }
193 }
194 
195 void MSTRUCT_ANALYSE_EROSION::enregistrer(std::ofstream& ofstrm)
196 {
197  long type_analyse=get_type();
198  ofstrm.write((char*)&type_analyse,sizeof(long));
200  ofstrm.write((char*)&m_epaisseur_couche,sizeof(double));
201  long nb_analyse=get_nb_analyse();
202  ofstrm.write((char*)&nb_analyse,sizeof(long));
203  std::vector<MSTRUCT_ANALYSE*>::iterator it_analyse;
204  for(MSTRUCT_ANALYSE* analyse=get_premiere_analyse(it_analyse);analyse!=NULL;analyse=get_suivante_analyse(it_analyse)) analyse->enregistrer(ofstrm);
205 }
206 
207 void MSTRUCT_ANALYSE_EROSION::ouvrir(std::ifstream& ifstrm)
208 {
209  MSTRUCT_ANALYSE::ouvrir(ifstrm);
210  ifstrm.read((char*)&m_epaisseur_couche,sizeof(double));
211  long nb_analyse;
212  ifstrm.read((char*)&nb_analyse,sizeof(long));
213  for(long i=0;i<nb_analyse;i++)
214  {
215  long type_analyse;
216  ifstrm.read((char*)&type_analyse,sizeof(long));
217  MSTRUCT_ANALYSE *analyse;
218  if(type_analyse==MSTRUCT::TYPE_ANALYSE::CHAMP)
219  {
220  analyse = new MSTRUCT_ANALYSE_CHAMP;
221  analyse->ouvrir(ifstrm);
222  }
223  else if(type_analyse==MSTRUCT::TYPE_ANALYSE::ORIENTATION)
224  {
225  analyse = new MSTRUCT_ANALYSE_ORIENTATION;
226  analyse->ouvrir(ifstrm);
227  }
228  else if(type_analyse==MSTRUCT::TYPE_ANALYSE::CAO)
229  {
230  analyse = new MSTRUCT_ANALYSE_CAO;
231  analyse->ouvrir(ifstrm);
232  }
233  else if(type_analyse==MSTRUCT::TYPE_ANALYSE::MAILLAGE_MG)
234  {
235  analyse = new MSTRUCT_ANALYSE_MG_MAILLAGE;
236  analyse->ouvrir(ifstrm);
237  }
238  else if(type_analyse==MSTRUCT::TYPE_ANALYSE::MAILLAGE_FEM)
239  {
240  analyse = new MSTRUCT_ANALYSE_FEM_MAILLAGE;
241  analyse->ouvrir(ifstrm);
242  }
243  else if(type_analyse==MSTRUCT::TYPE_ANALYSE::MODULES_ELASTICITE)
244  {
246  analyse->ouvrir(ifstrm);
247  }
248  else if(type_analyse==MSTRUCT::TYPE_ANALYSE::CONDUCTIVITE_THERMIQUE)
249  {
251  analyse->ouvrir(ifstrm);
252  }
253  else if(type_analyse==MSTRUCT::TYPE_ANALYSE::ENERGIE_HILL)
254  {
255  analyse = new MSTRUCT_ANALYSE_ENERGIE_HILL;
256  analyse->ouvrir(ifstrm);
257  }
258  ajouter_analyse(analyse);
259  }
260 }
261 
263 {
265  char ligne[5000];
266  sprintf(ligne,"MSTRUCT_ANALYSE_EROSION");fonc(ligne);
267  sprintf(ligne,"-> Nb analyse : %li",get_nb_analyse());fonc(ligne);
268  sprintf(ligne,"-> Epaisseur couche : %lf",m_epaisseur_couche);fonc(ligne);
269  std::vector<MSTRUCT_ANALYSE*>::iterator it_analyse;
270  for(MSTRUCT_ANALYSE* analyse=get_premiere_analyse(it_analyse);analyse!=NULL;analyse=get_suivante_analyse(it_analyse))
271  {
272  analyse->affiche_contenu(fonc);
273  }
274 }
MSTRUCT_ANALYSE_FEM_MAILLAGE
Definition: mstruct_analyse_fem_maillage.h:26
MSTRUCT_ANALYSE_EROSION::affiche_contenu
virtual void affiche_contenu(fonction_affiche *fonc)
Definition: mstruct_analyse_erosion.cpp:262
MSTRUCT_ANALYSE::get_type
virtual long get_type(void)=0
MSTRUCT::MODULES_ELASTICITE
@ MODULES_ELASTICITE
Definition: mstruct_definition.h:65
mstruct_analyse_modules_elasticite.h
mstruct_analyse_conductivite_thermique.h
BOITE_3D::get_xmin
double get_xmin(void)
Definition: ot_boite_3d.cpp:104
MSTRUCT_ANALYSE::enregistrer
virtual void enregistrer(std::ofstream &ofstrm)
Definition: mstruct_analyse.cpp:100
MSTRUCT_ANALYSE_EROSION::m_vector_analyse
std::vector< MSTRUCT_ANALYSE * > m_vector_analyse
Definition: mstruct_analyse_erosion.h:48
MSTRUCT::CHAMP
@ CHAMP
Definition: mstruct_definition.h:58
MSTRUCT::ENERGIE_HILL
@ ENERGIE_HILL
Definition: mstruct_definition.h:67
MSTRUCT_ANALYSE_CAO
Definition: mstruct_analyse_cao.h:30
MSTRUCT_ANALYSE_EROSION::m_epaisseur_couche
double m_epaisseur_couche
Definition: mstruct_analyse_erosion.h:47
MSTRUCT_ANALYSE_EROSION::get_suivante_analyse
virtual MSTRUCT_ANALYSE * get_suivante_analyse(std::vector< MSTRUCT_ANALYSE * >::iterator &it)
Definition: mstruct_analyse_erosion.cpp:162
MSTRUCT_ANALYSE::get_boite_analyse
virtual BOITE_3D * get_boite_analyse(void)
Definition: mstruct_analyse.cpp:85
MSTRUCT_ANALYSE_EROSION::~MSTRUCT_ANALYSE_EROSION
~MSTRUCT_ANALYSE_EROSION(void)
Definition: mstruct_analyse_erosion.cpp:130
MSTRUCT_ANALYSE_MODULES_ELASTICITE
Definition: mstruct_analyse_modules_elasticite.h:27
MSTRUCT_ANALYSE_EROSION::get_nb_analyse
virtual long get_nb_analyse(void)
Definition: mstruct_analyse_erosion.cpp:141
MSTRUCT::MAILLAGE_FEM
@ MAILLAGE_FEM
Definition: mstruct_definition.h:63
MSTRUCT_ANALYSE_EROSION::get_epaisseur_couche
virtual double get_epaisseur_couche(void)
Definition: mstruct_analyse_erosion.cpp:136
BOITE_3D::get_zmax
double get_zmax(void)
Definition: ot_boite_3d.cpp:129
BOITE_3D::get_ymin
double get_ymin(void)
Definition: ot_boite_3d.cpp:114
MSTRUCT_ANALYSE_EROSION::ajouter_analyse
virtual int ajouter_analyse(MSTRUCT_ANALYSE *analyse)
Definition: mstruct_analyse_erosion.cpp:146
MSTRUCT::MAILLAGE_MG
@ MAILLAGE_MG
Definition: mstruct_definition.h:62
mstruct_analyse_energie_hill.h
MSTRUCT::CAO
@ CAO
Definition: mstruct_definition.h:60
MSTRUCT_ANALYSE_EROSION::get_premiere_analyse
virtual MSTRUCT_ANALYSE * get_premiere_analyse(std::vector< MSTRUCT_ANALYSE * >::iterator &it)
Definition: mstruct_analyse_erosion.cpp:155
MSTRUCT_ANALYSE_ENERGIE_HILL
Definition: mstruct_analyse_energie_hill.h:27
BOITE_3D::get_xmax
double get_xmax(void)
Definition: ot_boite_3d.cpp:109
MSTRUCT_ANALYSE
Definition: mstruct_analyse.h:30
MSTRUCT::CONDUCTIVITE_THERMIQUE
@ CONDUCTIVITE_THERMIQUE
Definition: mstruct_definition.h:66
MSTRUCT_ANALYSE_EROSION::get_type
virtual long get_type(void)
Definition: mstruct_analyse_erosion.cpp:174
MSTRUCT_ANALYSE::change_identifiant
void change_identifiant(std::string identifiant)
Definition: mstruct_analyse.cpp:69
BOITE_3D::reinit
void reinit(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
Definition: ot_boite_3d.cpp:55
mstruct_analyse_fem_maillage.h
MSTRUCT::EROSION
@ EROSION
Definition: mstruct_definition.h:64
mstruct_definition.h
BOITE_3D::get_ymax
double get_ymax(void)
Definition: ot_boite_3d.cpp:119
mstruct_analyse_cao.h
BOITE_3D
Definition: ot_boite_3d.h:27
MSTRUCT_ANALYSE_CHAMP
Definition: mstruct_analyse_champ.h:28
MSTRUCT_ANALYSE_EROSION::ouvrir
virtual void ouvrir(std::ifstream &ifstrm)
Definition: mstruct_analyse_erosion.cpp:207
MSTRUCT_ANALYSE::affiche_contenu
virtual void affiche_contenu(fonction_affiche *fonc)
Definition: mstruct_analyse.cpp:171
ot_boite_3d.h
MSTRUCT_ANALYSE::change_boite_analyse
virtual void change_boite_analyse(BOITE_3D boite_3d)
Definition: mstruct_analyse.cpp:79
MSTRUCT_ANALYSE_CONDUCTIVITE_THERMIQUE
Definition: mstruct_analyse_conductivite_thermique.h:27
MSTRUCT_ANALYSE::m_identifiant
std::string m_identifiant
Definition: mstruct_analyse.h:52
BOITE_3D::get_zmin
double get_zmin(void)
Definition: ot_boite_3d.cpp:124
mstruct_analyse_mg_maillage.h
MSTRUCT_ANALYSE_EROSION::get_analyse
virtual MSTRUCT_ANALYSE * get_analyse(long num)
Definition: mstruct_analyse_erosion.cpp:169
mstruct_analyse_champ.h
MSTRUCT_ANALYSE_EROSION::enregistrer
virtual void enregistrer(std::ofstream &ofstrm)
Definition: mstruct_analyse_erosion.cpp:195
MSTRUCT_ANALYSE_MG_MAILLAGE
Definition: mstruct_analyse_mg_maillage.h:26
fonction_affiche
void fonction_affiche(char *)
Definition: fct_taille.h:28
MSTRUCT_ANALYSE::ouvrir
virtual void ouvrir(std::ifstream &ifstrm)
Definition: mstruct_analyse.cpp:131
MSTRUCT_ANALYSE_EROSION::MSTRUCT_ANALYSE_EROSION
MSTRUCT_ANALYSE_EROSION(void)
Definition: mstruct_analyse_erosion.cpp:33
MSTRUCT::ORIENTATION
@ ORIENTATION
Definition: mstruct_definition.h:59
MSTRUCT_ANALYSE_ORIENTATION
Definition: mstruct_analyse_orientation.h:25
mstruct_analyse_erosion.h
MSTRUCT_ANALYSE_EROSION::executer
virtual void executer(void)
Definition: mstruct_analyse_erosion.cpp:179
mstruct_analyse_orientation.h
MSTRUCT_ANALYSE_EROSION::exporter
virtual void exporter(std::ofstream &ofstrm, long i, bool avec_entete=false, bool avec_graph=false, char *prefix_graph=(char *)"")
Definition: mstruct_analyse_erosion.cpp:185