ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/fem_hexa8.cpp
Revision: 406
Committed: Wed Jun 5 20:13:26 2013 UTC (12 years, 2 months ago) by francois
File size: 14613 byte(s)
Log Message:
Procedure d'autoevaluation du decoupage xfem

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()==2) 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()==2) 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()==2) 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()==2) 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()==2) 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()==2) 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()==2) 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()==0) 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
167
168
169 int FEM_HEXA8::get_type_entite(void)
170 {
171 return IDFEM_HEXA8;
172 }
173
174 int FEM_HEXA8::get_dimension(void)
175 {
176 return 3;
177 }
178
179
180
181 int FEM_HEXA8::get_nb_fem_noeud(void)
182 {
183 return FEM_TEMPLATE_ELEMENT<8>::get_nb_fem_noeud();
184 }
185
186 FEM_NOEUD* FEM_HEXA8::get_fem_noeud(int num)
187 {
188 return FEM_TEMPLATE_ELEMENT<8>::get_fem_noeud(num);
189 }
190
191 void FEM_HEXA8::change_noeud(int num,FEM_NOEUD* noeud)
192 {
193 FEM_TEMPLATE_ELEMENT<8>::change_noeud(num,noeud);
194 }
195
196 BOITE_3D& FEM_HEXA8::get_boite_3D(void)
197 {
198 return FEM_TEMPLATE_ELEMENT<8>::get_boite_3D();
199 }
200
201
202 void FEM_HEXA8::enregistrer(std::ostream& o)
203 {
204 if (maillage!=NULL)
205 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;
206 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;
207 else
208 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;
209 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;
210
211 }
212 int FEM_HEXA8::nb_fonction_interpolation(void)
213 {
214 return 8;
215 }
216
217
218 double FEM_HEXA8::get_fonction_interpolation(int num,double *uv)
219 {
220 double val;
221 double a1=1.+uv[0],a2=1.-uv[0];
222 double b1=1.+uv[1],b2=1.-uv[1];
223 double c1=1.+uv[2],c2=1.-uv[2];
224 switch (num)
225 {
226 case 1:
227 val=0.125*a2*b2*c2;
228 break;
229 case 2:
230 val=0.125*a1*b2*c2;
231 break;
232 case 3:
233 val=0.125*a1*b1*c2;
234 break;
235 case 4:
236 val=0.125*a2*b1*c2;
237 break;
238 case 5:
239 val=0.125*a2*b2*c1;
240 break;
241 case 6:
242 val=0.125*a1*b2*c1;
243 break;
244 case 7:
245 val=0.125*a1*b1*c1;
246 break;
247 case 8:
248 val=0.125*a2*b1*c1;
249 break;
250 }
251 return val;
252 }
253
254 double FEM_HEXA8::get_fonction_derive_interpolation(int num,int num_variable,double *uv)
255 {
256 double val;
257 double a1=1.+uv[0],a2=1.-uv[0];
258 double b1=1.+uv[1],b2=1.-uv[1];
259 double c1=1.+uv[2],c2=1.-uv[2];
260 switch (num)
261 {
262 case 1:
263 switch (num_variable)
264 {
265 case 1:
266 val=-0.125*b2*c2;
267 break;
268 case 2:
269 val=-0.125*a2*c2;
270 break;
271 case 3:
272 val=-0.125*a2*b2;
273 break;
274 } break;
275 case 2:
276 switch (num_variable)
277 {
278 case 1:
279 val=0.125*b2*c2;
280 break;
281 case 2:
282 val=-0.125*a1*c2;
283 break;
284 case 3:
285 val=-0.125*a1*b2;
286 break;
287 } break;
288 case 3:
289 switch (num_variable)
290 {
291 case 1:
292 val=0.125*b1*c2;
293 break;
294 case 2:
295 val=0.125*a1*c2;
296 break;
297 case 3:
298 val=-0.125*a1*b1;
299 break;
300 } break;
301 case 4:
302 switch (num_variable)
303 {
304 case 1:
305 val=-0.125*b1*c2;
306 break;
307 case 2:
308 val=0.125*a2*c2;
309 break;
310 case 3:
311 val=-0.125*a2*b1;
312 break;
313 } break;
314 case 5:
315 switch (num_variable)
316 {
317 case 1:
318 val=-0.125*b2*c1;
319 break;
320 case 2:
321 val=-0.125*a2*c1;
322 break;
323 case 3:
324 val=0.125*a2*b2;
325 break;
326 } break;
327 case 6:
328 switch (num_variable)
329 {
330 case 1:
331 val=0.125*b2*c1;
332 break;
333 case 2:
334 val=-0.125*a1*c1;
335 break;
336 case 3:
337 val=0.125*a1*b2;
338 break;
339 } break;
340 case 7:
341 switch (num_variable)
342 {
343 case 1:
344 val=0.125*b1*c1;
345 break;
346 case 2:
347 val=0.125*a1*c1;
348 break;
349 case 3:
350 val=0.125*a1*b1;
351 break;
352 } break;
353 case 8:
354 switch (num_variable)
355 {
356 case 1:
357 val=-0.125*b1*c1;
358 break;
359 case 2:
360 val=0.125*a2*c1;
361 break;
362 case 3:
363 val=0.125*a2*b1;
364 break;
365 } break;
366 }
367 return val;
368 }
369
370 double FEM_HEXA8::get_jacobien(double* jac,double *uv,int& li,int& col,double unite)
371 {
372 li=3;col=3;
373 OT_TENSEUR Ni(3,8),Xi(8,3);
374 for (int i=0;i<3;i++)
375 for (int j=0;j<8;j++)
376 Ni(i,j)=get_fonction_derive_interpolation(j+1,i+1,uv);
377 for (int i=0;i<8;i++)
378 {
379 double *xyz=tab[i]->get_coord();
380 Xi(i,0)=xyz[0]*unite;
381 Xi(i,1)=xyz[1]*unite;
382 Xi(i,2)=xyz[2]*unite;
383 }
384 OT_TENSEUR jacobi=Ni*Xi;
385 jac[0]=jacobi(0,0).get_x();
386 jac[1]=jacobi(0,1).get_x();
387 jac[2]=jacobi(0,2).get_x();
388 jac[3]=jacobi(1,0).get_x();
389 jac[4]=jacobi(1,1).get_x();
390 jac[5]=jacobi(1,2).get_x();
391 jac[6]=jacobi(2,0).get_x();
392 jac[7]=jacobi(2,1).get_x();
393 jac[8]=jacobi(2,2).get_x();
394 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];
395 return det;
396
397 }
398
399 void FEM_HEXA8::get_inverse_jacob(double* j,double *uv,double unite)
400 {
401 double jac[9];
402 int li,col;
403 double detj=get_jacobien(jac,uv,li,col,unite);
404 j[0*3+0] = (jac[1*3+1]*jac[2*3+2]-jac[1*3+2]*jac[2*3+1])/(detj);
405 j[0*3+1] = -(jac[0*3+1]*jac[2*3+2]-jac[0*3+2]*jac[2*3+1])/(detj);
406 j[0*3+2] =-(-jac[0*3+1]*jac[1*3+2]+jac[0*3+2]*jac[1*3+1])/(detj);
407
408 j[1*3+0] = -(jac[1*3+0]*jac[2*3+2]-jac[1*3+2]*jac[2*3+0])/(detj);
409 j[1*3+1] = (jac[0*3+0]*jac[2*3+2]-jac[0*3+2]*jac[2*3+0])/(detj);
410 j[1*3+2] = -(jac[0*3+0]*jac[1*3+2]-jac[0*3+2]*jac[1*3+0])/(detj);
411
412 j[2*3+0] =-(-jac[1*3+0]*jac[2*3+1]+jac[1*3+1]*jac[2*3+0])/(detj);
413 j[2*3+1] = -(jac[0*3+0]*jac[2*3+1]-jac[0*3+1]*jac[2*3+0])/(detj);
414 j[2*3+2] = (jac[0*3+0]*jac[1*3+1]-jac[0*3+1]*jac[1*3+0])/(detj);
415
416 }
417
418
419
420 int FEM_HEXA8::verifie_validite_decoupage_xfem(double *vol)
421 {
422
423 }