ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/mg_volume.cpp
Revision: 906
Committed: Mon Nov 13 22:30:18 2017 UTC (7 years, 6 months ago) by couturad
File size: 9208 byte(s)
Log Message:
Nouveau opencascade commit 1

File Contents

# User Rev Content
1 francois 283 //------------------------------------------------------------
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_volume.cpp
16     //
17     //------------------------------------------------------------
18     //------------------------------------------------------------
19     // COPYRIGHT 2000
20     // Version du 02/03/2006 ? 11H22
21     //------------------------------------------------------------
22     //------------------------------------------------------------
23    
24    
25     #include "gestionversion.h"
26     #include "mg_volume.h"
27     #include "ot_mathematique.h"
28     #include "mg_maillage.h"
29     #include "vct_volume.h"
30     //#include "message.h"
31    
32 francois 881 MG_VOLUME::MG_VOLUME(std::string idori,unsigned long num):MG_ELEMENT_TOPOLOGIQUE(num,idori),num_materiau(-1),vect(NULL),mince(false)
33 francois 283 {
34     }
35    
36 francois 881 MG_VOLUME::MG_VOLUME(std::string idori):MG_ELEMENT_TOPOLOGIQUE(idori),num_materiau(-1),vect(NULL),mince(false)
37 francois 283 {
38     }
39    
40 francois 881 MG_VOLUME::MG_VOLUME(MG_VOLUME& mdd):MG_ELEMENT_TOPOLOGIQUE(mdd),lst_coquille(mdd.lst_coquille),vect(mdd.vect),mince(mdd.mince)
41 francois 283 {
42     }
43    
44     MG_VOLUME::~MG_VOLUME()
45     {
46     }
47    
48     void MG_VOLUME::ajouter_mg_coquille(class MG_COQUILLE* mgcoq)
49     {
50     lst_coquille.insert(lst_coquille.end(),mgcoq);
51     }
52    
53     void MG_VOLUME::supprimer_mg_coquille(class MG_COQUILLE* mgcoq)
54     {
55     std::vector<MG_COQUILLE*>::iterator i;
56     for (i=lst_coquille.begin();i!=lst_coquille.end();i++)
57     {
58     if ((*i)==mgcoq)
59     {
60     lst_coquille.erase(i);
61     return;
62     }
63     }
64     }
65    
66    
67     int MG_VOLUME::get_nb_mg_coquille(void)
68     {
69     return lst_coquille.size();
70     }
71    
72     MG_COQUILLE* MG_VOLUME::get_mg_coquille(int num)
73     {
74     return lst_coquille[num];
75     }
76    
77     int MG_VOLUME::get_dimension(void)
78     {
79     return 3;
80     }
81 couturad 906
82     int MG_VOLUME::get_type(void)
83     {
84     return TYPE_ELEMENT_TOPOLOGIQUE::VOLUME;
85     }
86    
87 francois 283 VCT& MG_VOLUME::get_vectorisation(void)
88     {
89     //VCT* p=NULL;
90     //return *p;
91     if (vect==NULL) vect=new VCT_VOLUME(this);
92     return *vect;
93     }
94     void MG_VOLUME::get_topologie_sousjacente(TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> *lst)
95     {
96     int nbcoq=lst_coquille.size();
97     for (int i=0;i<nbcoq;i++)
98     {
99     MG_COQUILLE* coq=lst_coquille[i];
100     int nbface=coq->get_nb_mg_coface();
101     for (int j=0;j<nbface;j++)
102     {
103     MG_FACE* face=coq->get_mg_coface(j)->get_face();
104     lst->ajouter(face);
105     face->get_topologie_sousjacente(lst);
106     }
107     }
108     }
109    
110    
111 francois 632
112    
113     BOITE_3D MG_VOLUME::get_boite_3D(int pas_echantillon)
114     {
115     BOITE_3D boitevol;
116     int nb_coquille=get_nb_mg_coquille();
117     for (int i=0;i<nb_coquille;i++)
118     {
119     MG_COQUILLE* coq=get_mg_coquille(i);
120     int nb_face=coq->get_nb_mg_coface();
121     for (int j=0;j<nb_face;j++)
122     {
123     MG_FACE* face=coq->get_mg_coface(j)->get_face();
124     BOITE_3D tmp=face->get_boite_3D(pas_echantillon);
125     if ((i==0) && (j==0)) boitevol=tmp;
126     else boitevol=tmp+boitevol;
127     }
128     }
129     return boitevol;
130     }
131    
132 francois 763 void MG_VOLUME::enregistrer(std::ostream& o,double version)
133 francois 283 {
134     o << "%" << get_id() << "=VOLUME(" << get_idoriginal() << ",(";
135     for (unsigned int i=0;i<lst_coquille.size();i++)
136     {
137     o << "$" << lst_coquille[i]->get_id();
138     if (i!=lst_coquille.size()-1) o << ",";
139     else o << ")";
140     }
141     int nb=get_nb_ccf();
142 francois 763 if (version<2)
143     {
144 francois 283 o << "," << num_materiau << "," << nb;
145     if (nb!=0)
146     {
147     o << ",(";
148     for (int i=0;i<nb;i++)
149     {
150     char nom[3];
151     get_type_ccf(i,nom);
152     o << "(" << nom << "," << get_valeur_ccf(i) << ")";
153     if (i!=nb-1) o << "," ;
154     }
155     o << ")";
156     }
157     o << ");" << std::endl;
158 francois 763 }
159     else
160     {
161 francois 881 if (version>2.2)
162     {
163     if (mince) o << ",1" ;
164     else o << ",0" ;
165     if (mince)
166     {
167     o << ",(" ;
168     for (int i=0;i<get_nb_face_correspondante()-1;i++)
169     o << "$" << lst_base[i]->get_id() << "," << "$" << lst_extrude[i]->get_id() << "," ;
170     o << "$" << lst_base[get_nb_face_correspondante()-1]->get_id() << "," << "$" << lst_extrude[get_nb_face_correspondante()-1]->get_id();
171     o << ")" ;
172     }
173     }
174 francois 763 o << "," ;
175     enregistrer_ccf(o,version);
176     o << ");" << std::endl;
177     }
178 francois 283 }
179    
180     void MG_VOLUME::change_num_materiau(int num)
181     {
182     num_materiau=num;
183     }
184    
185     int MG_VOLUME::get_num_materiau(void)
186     {
187     return num_materiau;
188     }
189    
190 francois 576
191     bool MG_VOLUME::est_un_volume_element(void)
192     {
193     return false;
194     }
195 francois 881
196    
197    
198    
199     void MG_VOLUME::ajouter_face_correspondante(MG_FACE* face1,MG_FACE* face2)
200     {
201     lst_base.push_back(face1);
202     lst_extrude.push_back(face2);
203     mince=true;
204     }
205    
206     void MG_VOLUME::get_face_correspondante(int num,MG_FACE** face1,MG_FACE** face2)
207     {
208     (*face1)=lst_base[num];
209     (*face2)=lst_extrude[num];
210     }
211    
212     int MG_VOLUME::get_nb_face_correspondante(void)
213     {
214     return lst_base.size();
215     }
216    
217     bool MG_VOLUME::est_mince(void)
218     {
219     return mince;
220     }
221    
222    
223    
224 francois 283 void MG_VOLUME::get_propriete_massique(class MG_MAILLAGE* mai,double& volume,class OT_VECTEUR_3D& cdm,class OT_MATRICE_3D& inertieglobale,class OT_MATRICE_3D& inertiecdm,double dens)
225     {
226     double vol=0.;
227     double xg=0.;
228     double yg=0.;
229     double zg=0.;
230     double a=0.;
231     double b=0.;
232     double c=0.;
233     double d=0.;
234     double e=0.;
235     double f=0.;
236     int nbcoquille=get_nb_mg_coquille();
237     for (int i=0;i<nbcoquille;i++)
238     {
239     MG_COQUILLE* coq=get_mg_coquille(i);
240     int nbface=coq->get_nb_mg_coface();
241     for (int j=0;j<nbface;j++)
242     {
243     MG_COFACE* coface=coq->get_mg_coface(j);
244     MG_FACE* face=coface->get_face();
245     TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR it;
246     for (MG_TRIANGLE* tri=(MG_TRIANGLE*)face->get_lien_maillage()->get_premier(it);tri!=NULL;tri=(MG_TRIANGLE*)face->get_lien_maillage()->get_suivant(it))
247     {
248     if (mai->get_mg_triangleid(tri->get_id())==NULL) continue;
249     MG_NOEUD* noeud1=tri->get_noeud1();
250     MG_NOEUD* noeud2=tri->get_noeud2();
251     MG_NOEUD* noeud3=tri->get_noeud3();
252     double *xyz1=noeud1->get_coord();
253     double *xyz2=noeud2->get_coord();
254     double *xyz3=noeud3->get_coord();
255     OT_VECTEUR_3D vec1(xyz1,xyz2);
256     OT_VECTEUR_3D vec2(xyz1,xyz3);
257     OT_VECTEUR_3D n=vec1&vec2;
258     double detj=n.get_longueur();
259     n.norme();
260     n=-1.*coface->get_orientation()*n;
261     for (int k=0;k<3;k++)
262     {
263     double xsi=1./6.;
264     double eta=1./6.;
265     double wi=1./6.;
266     if (k==1) xsi=2./3.;
267     if (k==2) eta=2./3.;
268     double x=(1-xsi-eta)*xyz1[0]+xsi*xyz2[0]+eta*xyz3[0];
269     double y=(1-xsi-eta)*xyz1[1]+xsi*xyz2[1]+eta*xyz3[1];
270     double z=(1-xsi-eta)*xyz1[2]+xsi*xyz2[2]+eta*xyz3[2];
271     OT_VECTEUR_3D psi1(x,0,0);
272     OT_VECTEUR_3D psi2(0.5*x*x,0,0);
273     OT_VECTEUR_3D psi3(0,0.5*y*y,0);
274     OT_VECTEUR_3D psi4(0,0,0.5*z*z);
275     OT_VECTEUR_3D psi5(0,y*y*y/3.,z*z*z/3.);
276     OT_VECTEUR_3D psi6(x*x*x/3.,0,z*z*z/3.);
277     OT_VECTEUR_3D psi7(x*x*x/3.,y*y*y/3.,0);
278     OT_VECTEUR_3D psi8(0.,y*y*z/2.,0);
279     OT_VECTEUR_3D psi9(x*x*z/2.,0.,0);
280     OT_VECTEUR_3D psi10(x*x*y/2.,0,0);
281     vol=vol+detj*wi*(psi1*n);
282     xg=xg+wi*detj*(psi2*n);
283     yg=yg+wi*detj*(psi3*n);
284     zg=zg+wi*detj*(psi4*n);
285     a=a+wi*detj*(psi5*n);
286     b=b+wi*detj*(psi6*n);
287     c=c+wi*detj*(psi7*n);
288     d=d+wi*detj*(psi8*n);
289     e=e+wi*detj*(psi9*n);
290     f=f+wi*detj*(psi10*n);
291     }
292     }
293     }
294     }
295     volume=vol;
296     cdm.change_x(xg/volume);
297     cdm.change_y(yg/volume);
298     cdm.change_z(zg/volume);
299     inertieglobale(0,0)=a*dens;
300     inertieglobale(1,1)=b*dens;
301     inertieglobale(2,2)=c*dens;
302     inertieglobale(1,0)=f*dens;
303     inertieglobale(0,1)=f*dens;
304     inertieglobale(2,0)=e*dens;
305     inertieglobale(0,2)=e*dens;
306     inertieglobale(2,1)=d*dens;
307     inertieglobale(1,2)=d*dens;
308     OT_VECTEUR_3D m1(volume*(cdm.get_y()*cdm.get_y()+cdm.get_z()*cdm.get_z()),volume*cdm.get_x()*cdm.get_y(),volume*cdm.get_x()*cdm.get_z());
309     OT_VECTEUR_3D m2(volume*cdm.get_x()*cdm.get_y(),volume*(cdm.get_x()*cdm.get_x()+cdm.get_z()*cdm.get_z()),volume*cdm.get_y()*cdm.get_z());
310     OT_VECTEUR_3D m3(volume*cdm.get_x()*cdm.get_z(),volume*cdm.get_y()*cdm.get_z(),volume*(cdm.get_x()*cdm.get_x()+cdm.get_y()*cdm.get_y()));
311     m1=(-1.)*m1;
312     m2=(-1.)*m2;
313     m3=(-1.)*m3;
314     OT_MATRICE_3D change(m1,m2,m3);
315     inertiecdm=inertieglobale+change;
316     }
317