ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/fem_hexa8.cpp
Revision: 638
Committed: Mon Jan 26 21:56:20 2015 UTC (10 years, 7 months ago) by francois
File size: 16939 byte(s)
Log Message:
ajout d'une méthode qui renvoit le degre max des fonctions d'interpolation et changement de nom de la fonction qui renvoie le nombre de fonction d'interpolation (ajout d'un get pour uniformiser)

File Contents

# Content
1 //------------------------------------------------------------
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 // fem_triangle3.cpp
16 //
17 //------------------------------------------------------------
18 //------------------------------------------------------------
19 // COPYRIGHT 2000
20 // Version du 02/03/2006 � 11H22
21 //------------------------------------------------------------
22 //------------------------------------------------------------
23
24
25 #include "gestionversion.h"
26 #include "fem_hexa8.h"
27 #include "fem_maillage.h"
28 #include "fem_noeud.h"
29 #include "mg_element_maillage.h"
30 #include "ot_tenseur.h"
31
32
33 FEM_HEXA8::FEM_HEXA8(unsigned long num,class MG_ELEMENT_MAILLAGE* mai,class FEM_NOEUD** tabnoeud):FEM_ELEMENT3(num,mai),FEM_TEMPLATE_ELEMENT<8>(tabnoeud)
34 {
35 if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
36 tab[0]->get_lien_element3()->ajouter(this);
37 tab[1]->get_lien_element3()->ajouter(this);
38 tab[2]->get_lien_element3()->ajouter(this);
39 tab[3]->get_lien_element3()->ajouter(this);
40 tab[4]->get_lien_element3()->ajouter(this);
41 tab[5]->get_lien_element3()->ajouter(this);
42 tab[6]->get_lien_element3()->ajouter(this);
43 tab[7]->get_lien_element3()->ajouter(this);
44 get_fem_noeudpetitid()->get_lien_petit_element3()->ajouter(this);
45 }
46
47 FEM_HEXA8::FEM_HEXA8(class MG_ELEMENT_MAILLAGE* mai,FEM_NOEUD** tabnoeud):FEM_ELEMENT3(mai),FEM_TEMPLATE_ELEMENT<8>(tabnoeud)
48 {
49 if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
50 tab[0]->get_lien_element3()->ajouter(this);
51 tab[1]->get_lien_element3()->ajouter(this);
52 tab[2]->get_lien_element3()->ajouter(this);
53 tab[3]->get_lien_element3()->ajouter(this);
54 tab[4]->get_lien_element3()->ajouter(this);
55 tab[5]->get_lien_element3()->ajouter(this);
56 tab[6]->get_lien_element3()->ajouter(this);
57 tab[7]->get_lien_element3()->ajouter(this);
58 get_fem_noeudpetitid()->get_lien_petit_element3()->ajouter(this);
59 }
60
61 FEM_HEXA8::FEM_HEXA8(unsigned long num,class MG_ELEMENT_TOPOLOGIQUE* topo,class FEM_NOEUD** tabnoeud):FEM_ELEMENT3(num,topo),FEM_TEMPLATE_ELEMENT<8>(tabnoeud)
62 {
63 if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
64 tab[0]->get_lien_element3()->ajouter(this);
65 tab[1]->get_lien_element3()->ajouter(this);
66 tab[2]->get_lien_element3()->ajouter(this);
67 tab[3]->get_lien_element3()->ajouter(this);
68 tab[4]->get_lien_element3()->ajouter(this);
69 tab[5]->get_lien_element3()->ajouter(this);
70 tab[6]->get_lien_element3()->ajouter(this);
71 tab[7]->get_lien_element3()->ajouter(this);
72 get_fem_noeudpetitid()->get_lien_petit_element3()->ajouter(this);
73 }
74
75 FEM_HEXA8::FEM_HEXA8(class MG_ELEMENT_TOPOLOGIQUE* topo,FEM_NOEUD** tabnoeud):FEM_ELEMENT3(topo),FEM_TEMPLATE_ELEMENT<8>(tabnoeud)
76 {
77 if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
78 tab[0]->get_lien_element3()->ajouter(this);
79 tab[1]->get_lien_element3()->ajouter(this);
80 tab[2]->get_lien_element3()->ajouter(this);
81 tab[3]->get_lien_element3()->ajouter(this);
82 tab[4]->get_lien_element3()->ajouter(this);
83 tab[5]->get_lien_element3()->ajouter(this);
84 tab[6]->get_lien_element3()->ajouter(this);
85 tab[7]->get_lien_element3()->ajouter(this);
86 get_fem_noeudpetitid()->get_lien_petit_element3()->ajouter(this);
87 }
88
89 FEM_HEXA8::FEM_HEXA8(unsigned long num,class MG_ELEMENT_TOPOLOGIQUE* topo,class MG_ELEMENT_MAILLAGE* mai,class FEM_NOEUD** tabnoeud):FEM_ELEMENT3(num,topo,mai),FEM_TEMPLATE_ELEMENT<8>(tabnoeud)
90 {
91 if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
92 tab[0]->get_lien_element3()->ajouter(this);
93 tab[1]->get_lien_element3()->ajouter(this);
94 tab[2]->get_lien_element3()->ajouter(this);
95 tab[3]->get_lien_element3()->ajouter(this);
96 tab[4]->get_lien_element3()->ajouter(this);
97 tab[5]->get_lien_element3()->ajouter(this);
98 tab[6]->get_lien_element3()->ajouter(this);
99 tab[7]->get_lien_element3()->ajouter(this);
100 get_fem_noeudpetitid()->get_lien_petit_element3()->ajouter(this);
101 }
102
103 FEM_HEXA8::FEM_HEXA8(class MG_ELEMENT_TOPOLOGIQUE* topo,class MG_ELEMENT_MAILLAGE* mai,FEM_NOEUD** tabnoeud):FEM_ELEMENT3(topo,mai),FEM_TEMPLATE_ELEMENT<8>(tabnoeud)
104 {
105 if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
106 tab[0]->get_lien_element3()->ajouter(this);
107 tab[1]->get_lien_element3()->ajouter(this);
108 tab[2]->get_lien_element3()->ajouter(this);
109 tab[3]->get_lien_element3()->ajouter(this);
110 tab[4]->get_lien_element3()->ajouter(this);
111 tab[5]->get_lien_element3()->ajouter(this);
112 tab[6]->get_lien_element3()->ajouter(this);
113 tab[7]->get_lien_element3()->ajouter(this);
114 get_fem_noeudpetitid()->get_lien_petit_element3()->ajouter(this);
115 }
116
117
118
119
120 FEM_HEXA8::FEM_HEXA8(FEM_HEXA8& mdd):FEM_ELEMENT3(mdd),FEM_TEMPLATE_ELEMENT<8>(mdd)
121 {
122 if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
123 tab[0]->get_lien_element3()->ajouter(this);
124 tab[1]->get_lien_element3()->ajouter(this);
125 tab[2]->get_lien_element3()->ajouter(this);
126 tab[3]->get_lien_element3()->ajouter(this);
127 tab[4]->get_lien_element3()->ajouter(this);
128 tab[5]->get_lien_element3()->ajouter(this);
129 tab[6]->get_lien_element3()->ajouter(this);
130 tab[7]->get_lien_element3()->ajouter(this);
131 get_fem_noeudpetitid()->get_lien_petit_element3()->ajouter(this);
132 }
133 FEM_HEXA8::~FEM_HEXA8()
134 {
135 if (liaison_topologique==NULL) return;
136 if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_fem_maillage()->supprimer(this);
137 tab[0]->get_lien_element3()->supprimer(this);
138 tab[1]->get_lien_element3()->supprimer(this);
139 tab[2]->get_lien_element3()->supprimer(this);
140 tab[3]->get_lien_element3()->supprimer(this);
141 tab[4]->get_lien_element3()->supprimer(this);
142 tab[5]->get_lien_element3()->supprimer(this);
143 tab[6]->get_lien_element3()->supprimer(this);
144 tab[7]->get_lien_element3()->supprimer(this);
145 get_fem_noeudpetitid()->get_lien_petit_element3()->supprimer(this);
146 }
147
148
149 FEM_ELEMENT_MAILLAGE* FEM_HEXA8::dupliquer(FEM_MAILLAGE *femmai,long decalage)
150 {
151 FEM_NOEUD* tabnoeud[8];
152 tabnoeud[0]=femmai->get_fem_noeudid(tab[0]->get_id()+decalage);
153 tabnoeud[1]=femmai->get_fem_noeudid(tab[1]->get_id()+decalage);
154 tabnoeud[2]=femmai->get_fem_noeudid(tab[2]->get_id()+decalage);
155 tabnoeud[3]=femmai->get_fem_noeudid(tab[3]->get_id()+decalage);
156 tabnoeud[4]=femmai->get_fem_noeudid(tab[4]->get_id()+decalage);
157 tabnoeud[5]=femmai->get_fem_noeudid(tab[5]->get_id()+decalage);
158 tabnoeud[6]=femmai->get_fem_noeudid(tab[6]->get_id()+decalage);
159 tabnoeud[7]=femmai->get_fem_noeudid(tab[7]->get_id()+decalage);
160 FEM_HEXA8* quad=new FEM_HEXA8(get_id()+decalage,maillage,tabnoeud);
161 femmai->ajouter_fem_element3(quad);
162 return quad;
163 }
164
165
166 bool FEM_HEXA8::valide_parametre_EF(double* uvw)
167 {
168 if (uvw[0]>=-1e-10)
169 if (uvw[1]>=-1e-10)
170 if (uvw[2]>=-1e-10)
171 if (uvw[0]<=1.+1e-10)
172 if (uvw[1]<=1.+1e-10)
173 if (uvw[2]<=1.+1e-10)
174 return true;
175 return false;
176 }
177
178
179
180 int FEM_HEXA8::get_type_entite(void)
181 {
182 return IDFEM_HEXA8;
183 }
184
185 int FEM_HEXA8::get_dimension(void)
186 {
187 return 3;
188 }
189
190
191
192 int FEM_HEXA8::get_nb_fem_noeud(void)
193 {
194 return FEM_TEMPLATE_ELEMENT<8>::get_nb_fem_noeud();
195 }
196
197 FEM_NOEUD* FEM_HEXA8::get_fem_noeud(int num)
198 {
199 return FEM_TEMPLATE_ELEMENT<8>::get_fem_noeud(num);
200 }
201
202 void FEM_HEXA8::change_noeud(int num,FEM_NOEUD* noeud)
203 {
204 FEM_TEMPLATE_ELEMENT<8>::change_noeud(num,noeud);
205 }
206
207 BOITE_3D& FEM_HEXA8::get_boite_3D(void)
208 {
209 return FEM_TEMPLATE_ELEMENT<8>::get_boite_3D();
210 }
211
212
213 void FEM_HEXA8::enregistrer(std::ostream& o)
214 {
215 if (maillage!=NULL)
216 if (get_lien_topologie()!=NULL) o << "%" << get_id() << "=FEM_HEXA8($"<< get_lien_topologie()->get_id() << ",$" << maillage->get_id() << ",$" << tab[0]->get_id() << ",$" << tab[1]->get_id() << ",$" << tab[2]->get_id()<< ",$" << tab[3]->get_id() << ",$" << tab[4]->get_id() << ",$" << tab[5]->get_id() << ",$" << tab[6]->get_id()<< ",$" << tab[7]->get_id()<< ");" << std::endl;
217 else o << "%" << get_id() << "=FEM_HEXA8(NULL,$" << maillage->get_id() << ",$" << tab[0]->get_id() << ",$" << tab[1]->get_id() << ",$" << tab[2]->get_id()<< ",$" << tab[3]->get_id() << ",$" << tab[4]->get_id() << ",$" << tab[5]->get_id() << ",$" << tab[6]->get_id()<< ",$" << tab[7]->get_id()<<");" << std::endl;
218 else
219 if (get_lien_topologie()!=NULL) o << "%" << get_id() << "=FEM_HEXA8($"<< get_lien_topologie()->get_id() << ",NULL,$" << tab[0]->get_id() << ",$" << tab[1]->get_id() << ",$" << tab[2]->get_id()<< ",$" << tab[3]->get_id() << ",$" << tab[4]->get_id() << ",$" << tab[5]->get_id() << ",$" << tab[6]->get_id()<< ",$" << tab[7]->get_id()<< ");" << std::endl;
220 else o << "%" << get_id() << "=FEM_HEXA8(NULL,NULL,$" << tab[0]->get_id() << ",$" << tab[1]->get_id() << ",$" << tab[2]->get_id()<< ",$" << tab[3]->get_id() << ",$" << tab[4]->get_id() << ",$" << tab[5]->get_id() << ",$" << tab[6]->get_id()<< ",$" << tab[7]->get_id()<<");" << std::endl;
221
222 }
223
224
225 int FEM_HEXA8::get_nb_pt_gauss(int degre)
226 {
227 if (degre<3) return 4;
228 if (degre<4) return 6;
229 if (degre<6) return 14;
230 return 0;
231 }
232
233 void FEM_HEXA8::get_pt_gauss(int degre,int num,double &w,double *uvw)
234 {
235 if (degre<3)
236 {
237 if (num==0) {w=2.;uvw[0]=0.;uvw[1]=0.816496580927726;uvw[2]=-0,577350269189626;}
238 if (num==1) {w=2.;uvw[0]=0.;uvw[1]=-0.816496580927726;uvw[2]=-0,577350269189626;}
239 if (num==2) {w=2.;uvw[0]=-0.816496580927726;uvw[1]=0.;uvw[2]=0,577350269189626;}
240 if (num==2) {w=2.;uvw[0]=0.816496580927726;uvw[1]=0.;uvw[2]=0,577350269189626;}
241 return;
242 }
243 if (degre<4)
244 {
245 if (num==0) {w=1.333333333333333;uvw[0]=1.;uvw[1]=0.;uvw[2]=0.;}
246 if (num==1) {w=1.333333333333333;uvw[0]=-1.;uvw[1]=0.;uvw[2]=0.;}
247 if (num==2) {w=1.333333333333333;uvw[0]=0.;uvw[1]=1.;uvw[2]=0.;}
248 if (num==3) {w=1.333333333333333;uvw[0]=0.;uvw[1]=-1.;uvw[2]=0.;}
249 if (num==4) {w=1.333333333333333;uvw[0]=0.;uvw[1]=0.;uvw[2]=1.;}
250 if (num==5) {w=1.333333333333333;uvw[0]=0.;uvw[1]=0.;uvw[2]=-1.;}
251 return;
252 }
253 if (degre<6)
254 {
255 double a=0.795822425754221;
256 double b=0.758786910639328;
257 double w1=0.886426592797784;
258 double w2=0.335180055401662;
259 if (num==0) {w=w1;uvw[0]=a;uvw[1]=0.;uvw[2]=0.;}
260 if (num==1) {w=w1;uvw[0]=-a;uvw[1]=0.;uvw[2]=0.;}
261 if (num==2) {w=w1;uvw[0]=0.;uvw[1]=a;uvw[2]=0.;}
262 if (num==3) {w=w1;uvw[0]=0.;uvw[1]=-a;uvw[2]=0.;}
263 if (num==4) {w=w1;uvw[0]=0.;uvw[1]=0.;uvw[2]=a;}
264 if (num==5) {w=w1;uvw[0]=0.;uvw[1]=0.;uvw[2]=-a;}
265 if (num==6) {w=w2;uvw[0]=b;uvw[1]=b;uvw[2]=b;}
266 if (num==7) {w=w2;uvw[0]=b;uvw[1]=-b;uvw[2]=-b;}
267 if (num==8) {w=w2;uvw[0]=b;uvw[1]=b;uvw[2]=-b;}
268 if (num==9) {w=w2;uvw[0]=b;uvw[1]=-b;uvw[2]=b;}
269 if (num==10) {w=w2;uvw[0]=-b;uvw[1]=b;uvw[2]=b;}
270 if (num==11) {w=w2;uvw[0]=-b;uvw[1]=-b;uvw[2]=-b;}
271 if (num==12) {w=w2;uvw[0]=-b;uvw[1]=b;uvw[2]=-b;}
272 if (num==13) {w=w2;uvw[0]=-b;uvw[1]=-b;uvw[2]=b;}
273 return;
274 }
275
276 }
277 int FEM_HEXA8::get_nb_fonction_interpolation(void)
278 {
279 return 8;
280 }
281
282 int FEM_HEXA8::get_degremax_fonction_interpolation(void)
283 {
284 return 3;
285 }
286 double FEM_HEXA8::get_fonction_interpolation(int num,double *uv)
287 {
288 double val;
289 double a1=1.+uv[0],a2=1.-uv[0];
290 double b1=1.+uv[1],b2=1.-uv[1];
291 double c1=1.+uv[2],c2=1.-uv[2];
292 switch (num)
293 {
294 case 1:
295 val=0.125*a2*b2*c2;
296 break;
297 case 2:
298 val=0.125*a1*b2*c2;
299 break;
300 case 3:
301 val=0.125*a1*b1*c2;
302 break;
303 case 4:
304 val=0.125*a2*b1*c2;
305 break;
306 case 5:
307 val=0.125*a2*b2*c1;
308 break;
309 case 6:
310 val=0.125*a1*b2*c1;
311 break;
312 case 7:
313 val=0.125*a1*b1*c1;
314 break;
315 case 8:
316 val=0.125*a2*b1*c1;
317 break;
318 }
319 return val;
320 }
321
322 double FEM_HEXA8::get_fonction_derive_interpolation(int num,int num_variable,double *uv)
323 {
324 double val;
325 double a1=1.+uv[0],a2=1.-uv[0];
326 double b1=1.+uv[1],b2=1.-uv[1];
327 double c1=1.+uv[2],c2=1.-uv[2];
328 switch (num)
329 {
330 case 1:
331 switch (num_variable)
332 {
333 case 1:
334 val=-0.125*b2*c2;
335 break;
336 case 2:
337 val=-0.125*a2*c2;
338 break;
339 case 3:
340 val=-0.125*a2*b2;
341 break;
342 } break;
343 case 2:
344 switch (num_variable)
345 {
346 case 1:
347 val=0.125*b2*c2;
348 break;
349 case 2:
350 val=-0.125*a1*c2;
351 break;
352 case 3:
353 val=-0.125*a1*b2;
354 break;
355 } break;
356 case 3:
357 switch (num_variable)
358 {
359 case 1:
360 val=0.125*b1*c2;
361 break;
362 case 2:
363 val=0.125*a1*c2;
364 break;
365 case 3:
366 val=-0.125*a1*b1;
367 break;
368 } break;
369 case 4:
370 switch (num_variable)
371 {
372 case 1:
373 val=-0.125*b1*c2;
374 break;
375 case 2:
376 val=0.125*a2*c2;
377 break;
378 case 3:
379 val=-0.125*a2*b1;
380 break;
381 } break;
382 case 5:
383 switch (num_variable)
384 {
385 case 1:
386 val=-0.125*b2*c1;
387 break;
388 case 2:
389 val=-0.125*a2*c1;
390 break;
391 case 3:
392 val=0.125*a2*b2;
393 break;
394 } break;
395 case 6:
396 switch (num_variable)
397 {
398 case 1:
399 val=0.125*b2*c1;
400 break;
401 case 2:
402 val=-0.125*a1*c1;
403 break;
404 case 3:
405 val=0.125*a1*b2;
406 break;
407 } break;
408 case 7:
409 switch (num_variable)
410 {
411 case 1:
412 val=0.125*b1*c1;
413 break;
414 case 2:
415 val=0.125*a1*c1;
416 break;
417 case 3:
418 val=0.125*a1*b1;
419 break;
420 } break;
421 case 8:
422 switch (num_variable)
423 {
424 case 1:
425 val=-0.125*b1*c1;
426 break;
427 case 2:
428 val=0.125*a2*c1;
429 break;
430 case 3:
431 val=0.125*a2*b1;
432 break;
433 } break;
434 }
435 return val;
436 }
437
438 double FEM_HEXA8::get_jacobien(double* jac,double *uv,int& li,int& col,double unite)
439 {
440 li=3;col=3;
441 OT_TENSEUR Ni(3,8),Xi(8,3);
442 for (int i=0;i<3;i++)
443 for (int j=0;j<8;j++)
444 Ni(i,j)=get_fonction_derive_interpolation(j+1,i+1,uv);
445 for (int i=0;i<8;i++)
446 {
447 double *xyz=tab[i]->get_coord();
448 Xi(i,0)=xyz[0]*unite;
449 Xi(i,1)=xyz[1]*unite;
450 Xi(i,2)=xyz[2]*unite;
451 }
452 OT_TENSEUR jacobi=Ni*Xi;
453 jac[0]=jacobi(0,0).get_x();
454 jac[1]=jacobi(0,1).get_x();
455 jac[2]=jacobi(0,2).get_x();
456 jac[3]=jacobi(1,0).get_x();
457 jac[4]=jacobi(1,1).get_x();
458 jac[5]=jacobi(1,2).get_x();
459 jac[6]=jacobi(2,0).get_x();
460 jac[7]=jacobi(2,1).get_x();
461 jac[8]=jacobi(2,2).get_x();
462 double det=jac[0]*jac[4]*jac[8]+jac[3]*jac[7]*jac[2]+jac[6]*jac[1]*jac[5]-jac[2]*jac[4]*jac[6]-jac[5]*jac[7]*jac[0]-jac[8]*jac[1]*jac[3];
463 return det;
464
465 }
466
467 void FEM_HEXA8::get_inverse_jacob(double* j,double *uv,double unite)
468 {
469 double jac[9];
470 int li,col;
471 double detj=get_jacobien(jac,uv,li,col,unite);
472 j[0*3+0] = (jac[1*3+1]*jac[2*3+2]-jac[1*3+2]*jac[2*3+1])/(detj);
473 j[0*3+1] = -(jac[0*3+1]*jac[2*3+2]-jac[0*3+2]*jac[2*3+1])/(detj);
474 j[0*3+2] =-(-jac[0*3+1]*jac[1*3+2]+jac[0*3+2]*jac[1*3+1])/(detj);
475
476 j[1*3+0] = -(jac[1*3+0]*jac[2*3+2]-jac[1*3+2]*jac[2*3+0])/(detj);
477 j[1*3+1] = (jac[0*3+0]*jac[2*3+2]-jac[0*3+2]*jac[2*3+0])/(detj);
478 j[1*3+2] = -(jac[0*3+0]*jac[1*3+2]-jac[0*3+2]*jac[1*3+0])/(detj);
479
480 j[2*3+0] =-(-jac[1*3+0]*jac[2*3+1]+jac[1*3+1]*jac[2*3+0])/(detj);
481 j[2*3+1] = -(jac[0*3+0]*jac[2*3+1]-jac[0*3+1]*jac[2*3+0])/(detj);
482 j[2*3+2] = (jac[0*3+0]*jac[1*3+1]-jac[0*3+1]*jac[1*3+0])/(detj);
483
484 }
485
486
487
488 int FEM_HEXA8::verifie_validite_decoupage_xfem(double *vol)
489 {
490
491 }