ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/fem_tetra4.cpp
Revision: 786
Committed: Wed Mar 9 21:10:49 2016 UTC (9 years, 2 months ago) by francois
File size: 14042 byte(s)
Log Message:
Possibilité d'obtenir la matrice de rigidite de code aster sous form de matrice bande.
Pour cela ajouter -opt dans l'operation -fem à la création du maillage FEM et dans -calculaster utiliser les nouveaux types d'étude rigidite.
Attention pour cela il faut une version de code aster modifiée
De manière automatique elle peut etre optenu en faisant ./instal_aster 12.5mod
Uniquement implantée avec la version 12.5 de code aster. 

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 francois 309 // fem_element34.cpp
16 francois 283 //
17     //------------------------------------------------------------
18     //------------------------------------------------------------
19     // COPYRIGHT 2000
20     // Version du 02/03/2006 � 11H22
21     //------------------------------------------------------------
22     //------------------------------------------------------------
23    
24    
25     #include "gestionversion.h"
26     #include "fem_tetra4.h"
27     #include "fem_noeud.h"
28     #include "mg_element_maillage.h"
29     #include "fem_maillage.h"
30 francois 405 #include "ot_mathematique.h"
31     #include "xfem_tetra4.h"
32 francois 754 #include "ot_quadrature_gauss.h"
33 francois 405 #include <math.h>
34 francois 283
35 francois 309 FEM_TETRA4::FEM_TETRA4(unsigned long num,class MG_ELEMENT_MAILLAGE* mai,class FEM_NOEUD** tabnoeud):FEM_ELEMENT3(num,mai),FEM_TEMPLATE_ELEMENT<4>(tabnoeud)
36 francois 283 {
37     if (liaison_topologique!=NULL)
38     if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
39 francois 309 tab[0]->get_lien_element3()->ajouter(this);
40     tab[1]->get_lien_element3()->ajouter(this);
41     tab[2]->get_lien_element3()->ajouter(this);
42     tab[3]->get_lien_element3()->ajouter(this);
43     get_fem_noeudpetitid()->get_lien_petit_element3()->ajouter(this);
44 francois 283 }
45    
46 francois 309 FEM_TETRA4::FEM_TETRA4(class MG_ELEMENT_MAILLAGE* mai,FEM_NOEUD** tabnoeud):FEM_ELEMENT3(mai),FEM_TEMPLATE_ELEMENT<4>(tabnoeud)
47 francois 283 {
48     if (liaison_topologique!=NULL)
49     if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
50 francois 309 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     get_fem_noeudpetitid()->get_lien_petit_element3()->ajouter(this);
55 francois 283 }
56 francois 378 FEM_TETRA4::FEM_TETRA4(unsigned long num,class MG_ELEMENT_TOPOLOGIQUE* topo,class FEM_NOEUD** tabnoeud):FEM_ELEMENT3(num,topo),FEM_TEMPLATE_ELEMENT<4>(tabnoeud)
57     {
58     if (liaison_topologique!=NULL)
59     if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
60     tab[0]->get_lien_element3()->ajouter(this);
61     tab[1]->get_lien_element3()->ajouter(this);
62     tab[2]->get_lien_element3()->ajouter(this);
63     tab[3]->get_lien_element3()->ajouter(this);
64     get_fem_noeudpetitid()->get_lien_petit_element3()->ajouter(this);
65     }
66 francois 283
67 francois 378 FEM_TETRA4::FEM_TETRA4(class MG_ELEMENT_TOPOLOGIQUE* topo,FEM_NOEUD** tabnoeud):FEM_ELEMENT3(topo),FEM_TEMPLATE_ELEMENT<4>(tabnoeud)
68     {
69     if (liaison_topologique!=NULL)
70     if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
71     tab[0]->get_lien_element3()->ajouter(this);
72     tab[1]->get_lien_element3()->ajouter(this);
73     tab[2]->get_lien_element3()->ajouter(this);
74     tab[3]->get_lien_element3()->ajouter(this);
75     get_fem_noeudpetitid()->get_lien_petit_element3()->ajouter(this);
76     }
77     FEM_TETRA4::FEM_TETRA4(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<4>(tabnoeud)
78     {
79     if (liaison_topologique!=NULL)
80     if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
81     tab[0]->get_lien_element3()->ajouter(this);
82     tab[1]->get_lien_element3()->ajouter(this);
83     tab[2]->get_lien_element3()->ajouter(this);
84     tab[3]->get_lien_element3()->ajouter(this);
85     get_fem_noeudpetitid()->get_lien_petit_element3()->ajouter(this);
86     }
87    
88     FEM_TETRA4::FEM_TETRA4(class MG_ELEMENT_TOPOLOGIQUE* topo,class MG_ELEMENT_MAILLAGE* mai,FEM_NOEUD** tabnoeud):FEM_ELEMENT3(topo,mai),FEM_TEMPLATE_ELEMENT<4>(tabnoeud)
89     {
90     if (liaison_topologique!=NULL)
91     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     get_fem_noeudpetitid()->get_lien_petit_element3()->ajouter(this);
97     }
98    
99    
100    
101 francois 684 void FEM_TETRA4::reinit_boite_3D(void)
102     {
103     FEM_TEMPLATE_ELEMENT<4>::reinit_boite_3D();
104     }
105 francois 378
106    
107    
108 francois 309 FEM_TETRA4::FEM_TETRA4(FEM_TETRA4& mdd):FEM_ELEMENT3(mdd),FEM_TEMPLATE_ELEMENT<4>(mdd)
109 francois 283 {
110     if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
111 francois 309 tab[0]->get_lien_element3()->ajouter(this);
112     tab[1]->get_lien_element3()->ajouter(this);
113     tab[2]->get_lien_element3()->ajouter(this);
114     tab[3]->get_lien_element3()->ajouter(this);
115     get_fem_noeudpetitid()->get_lien_petit_element3()->ajouter(this);
116 francois 283 }
117    
118     FEM_TETRA4::~FEM_TETRA4()
119     {
120 francois 663 if (liaison_topologique!=NULL)
121     if (liaison_topologique->get_dimension()==0) liaison_topologique->get_lien_fem_maillage()->supprimer(this);
122 francois 309 tab[0]->get_lien_element3()->supprimer(this);
123     tab[1]->get_lien_element3()->supprimer(this);
124     tab[2]->get_lien_element3()->supprimer(this);
125     tab[3]->get_lien_element3()->supprimer(this);
126     get_fem_noeudpetitid()->get_lien_petit_element3()->supprimer(this);
127 francois 283 }
128    
129    
130 francois 786 void FEM_TETRA4::get_voisin_noeud(class FEM_NOEUD* no,TPL_LISTE_ENTITE<FEM_NOEUD*> &voisin)
131     {
132     voisin.vide();
133     if (no==tab[0])
134     {
135     voisin.ajouter(tab[1]);
136     voisin.ajouter(tab[2]);
137     voisin.ajouter(tab[3]);
138     }
139     if (no==tab[1])
140     {
141     voisin.ajouter(tab[0]);
142     voisin.ajouter(tab[2]);
143     voisin.ajouter(tab[3]);
144     }
145     if (no==tab[2])
146     {
147     voisin.ajouter(tab[0]);
148     voisin.ajouter(tab[1]);
149     voisin.ajouter(tab[3]);
150     }
151     if (no==tab[3])
152     {
153     voisin.ajouter(tab[0]);
154     voisin.ajouter(tab[1]);
155     voisin.ajouter(tab[2]);
156     }
157     }
158    
159    
160 francois 283 FEM_ELEMENT_MAILLAGE* FEM_TETRA4::dupliquer(FEM_MAILLAGE *femmai,long decalage)
161     {
162     FEM_NOEUD* tabnoeud[4];
163     tabnoeud[0]=femmai->get_fem_noeudid(tab[0]->get_id()+decalage);
164     tabnoeud[1]=femmai->get_fem_noeudid(tab[1]->get_id()+decalage);
165     tabnoeud[2]=femmai->get_fem_noeudid(tab[2]->get_id()+decalage);
166     tabnoeud[3]=femmai->get_fem_noeudid(tab[3]->get_id()+decalage);
167     FEM_TETRA4* tet=new FEM_TETRA4(get_id()+decalage,maillage,tabnoeud);
168 francois 309 femmai->ajouter_fem_element3(tet);
169 francois 283 return tet;
170     }
171    
172    
173     int FEM_TETRA4::get_type_entite(void)
174     {
175     return IDFEM_TETRA4;
176     }
177    
178     int FEM_TETRA4::get_dimension(void)
179     {
180     return 3;
181     }
182    
183    
184     int FEM_TETRA4::get_nb_fem_noeud(void)
185     {
186     return FEM_TEMPLATE_ELEMENT<4>::get_nb_fem_noeud();
187     }
188    
189     FEM_NOEUD* FEM_TETRA4::get_fem_noeud(int num)
190     {
191     return FEM_TEMPLATE_ELEMENT<4>::get_fem_noeud(num);
192     }
193    
194     void FEM_TETRA4::change_noeud(int num,FEM_NOEUD* noeud)
195     {
196     FEM_TEMPLATE_ELEMENT<4>::change_noeud(num,noeud);
197     }
198    
199    
200     BOITE_3D& FEM_TETRA4::get_boite_3D(void)
201     {
202     return FEM_TEMPLATE_ELEMENT<4>::get_boite_3D();
203     }
204 francois 637
205    
206     int FEM_TETRA4::get_nb_pt_gauss(int degre)
207     {
208 francois 754 return OT_POINTS_GAUSS::get_nb_point_tetra(degre);
209 francois 637 }
210    
211     void FEM_TETRA4::get_pt_gauss(int degre,int num,double &w,double *uvw)
212     {
213 francois 754 return OT_POINTS_GAUSS::get_pt_gauss_tet(degre,num,w,uvw);
214 francois 637 }
215    
216 francois 757 int FEM_TETRA4::get_degre_gauss(int num)
217     {
218     return OT_POINTS_GAUSS::get_degre_gauss_tetra(num);
219     }
220 francois 637
221    
222 francois 638 int FEM_TETRA4::get_nb_fonction_interpolation(void)
223 francois 283 {
224     return 4;
225     }
226 francois 638 int FEM_TETRA4::get_degremax_fonction_interpolation(void)
227     {
228     return 1;
229     }
230 francois 283
231     double FEM_TETRA4::get_fonction_interpolation(int num,double *uv)
232     {
233     double val;
234     switch (num)
235     {
236     case 1:
237     val=1-uv[0]-uv[1]-uv[2];
238     break;
239     case 2:
240     val=uv[0];
241     break;
242     case 3:
243     val=uv[1];
244     break;
245     case 4:
246     val=uv[2];
247     break;
248     }
249     return val;
250     }
251    
252     double FEM_TETRA4::get_fonction_derive_interpolation(int num,int num_variable,double *uv)
253     {
254     double val;
255    
256     switch (num)
257     {
258     case 1:
259     switch (num_variable)
260     {
261     case 1:
262     val=-1;
263     break;
264     case 2:
265     val=-1;
266     break;
267     case 3:
268     val=-1;
269     break;
270     } break;
271     case 2:
272     switch (num_variable)
273     {
274     case 1:
275     val=1;
276     break;
277     case 2:
278     val=0;
279     break;
280     case 3:
281     val=0;
282     break;
283     }break;
284     case 3:
285     switch (num_variable)
286     {
287     case 1:
288     val=0;
289     break;
290     case 2:
291     val=1;
292     break;
293     case 3:
294     val=0;
295     break;
296     }break;
297     case 4:
298     switch (num_variable)
299     {
300     case 1:
301     val=0;
302     break;
303     case 2:
304     val=0;
305     break;
306     case 3:
307     val=1;
308     break;
309     }break;
310    
311     }
312     return val;
313     }
314    
315     double FEM_TETRA4::get_jacobien(double* jac,double *uv,int& li,int& col,double unite)
316     {
317     li=3;
318     col=3;
319     double *xyz1=tab[0]->get_coord();
320     double *xyz2=tab[1]->get_coord();
321     double *xyz3=tab[2]->get_coord();
322     double *xyz4=tab[3]->get_coord();
323    
324     jac[0]=unite*(xyz2[0] - xyz1[0]) ;
325     jac[1]=unite*(xyz2[1] - xyz1[1]) ;
326     jac[2]=unite*(xyz2[2] - xyz1[2]) ;
327    
328     jac[3]=unite*(xyz3[0] - xyz1[0]) ;
329     jac[4]=unite*(xyz3[1] - xyz1[1]) ;
330     jac[5]=unite*(xyz3[2] - xyz1[2]) ;
331    
332     jac[6]=unite*(xyz4[0] - xyz1[0]) ;
333     jac[7]=unite*(xyz4[1] - xyz1[1]) ;
334     jac[8]=unite*(xyz4[2] - xyz1[2]) ;
335    
336     double SIX_V= jac[0]*(jac[4]*jac[8]-jac[7]*jac[5])+jac[1]*(jac[5]*jac[6]-jac[8]*jac[3])+jac[2]*(jac[3]*jac[7]-jac[6]*jac[4]);
337    
338     return SIX_V;
339     }
340    
341     void FEM_TETRA4::get_inverse_jacob(double* j,double *uv,double unite)
342     {
343     double *xyz1=tab[0]->get_coord();
344     double *xyz2=tab[1]->get_coord();
345     double *xyz3=tab[2]->get_coord();
346     double *xyz4=tab[3]->get_coord();
347    
348     double jac[9];
349    
350     jac[0*3+0]= unite*(xyz2[0] - xyz1[0]) ;
351     jac[0*3+1]= unite*(xyz2[1] - xyz1[1]) ;
352     jac[0*3+2]= unite*(xyz2[2] - xyz1[2]) ;
353    
354     jac[1*3+0]= unite*(xyz3[0] - xyz1[0]) ;
355     jac[1*3+1]= unite*(xyz3[1] - xyz1[1]) ;
356     jac[1*3+2]= unite*(xyz3[2] - xyz1[2]) ;
357    
358     jac[2*3+0]= unite*(xyz4[0] - xyz1[0]) ;
359     jac[2*3+1]= unite*(xyz4[1] - xyz1[1]) ;
360     jac[2*3+2]= unite*(xyz4[2] - xyz1[2]) ;
361    
362     double detj=(jac[0*3+0]*jac[1*3+1]*jac[2*3+2]-jac[0*3+0]*jac[1*3+2]*jac[2*3+1]-jac[1*3+0]*jac[0*3+1]*jac[2*3+2]+jac[1*3+0]*jac[0*3+2]*jac[2*3+1]+jac[2*3+0]*jac[0*3+1]*jac[1*3+2]-jac[2*3+0]*jac[0*3+2]*jac[1*3+1]);
363    
364     j[0*3+0] = (jac[1*3+1]*jac[2*3+2]-jac[1*3+2]*jac[2*3+1])/(detj);
365     j[0*3+1] = -(jac[0*3+1]*jac[2*3+2]-jac[0*3+2]*jac[2*3+1])/(detj);
366     j[0*3+2] =-(-jac[0*3+1]*jac[1*3+2]+jac[0*3+2]*jac[1*3+1])/(detj);
367    
368     j[1*3+0] = -(jac[1*3+0]*jac[2*3+2]-jac[1*3+2]*jac[2*3+0])/(detj);
369     j[1*3+1] = (jac[0*3+0]*jac[2*3+2]-jac[0*3+2]*jac[2*3+0])/(detj);
370     j[1*3+2] = -(jac[0*3+0]*jac[1*3+2]-jac[0*3+2]*jac[1*3+0])/(detj);
371    
372     j[2*3+0] =-(-jac[1*3+0]*jac[2*3+1]+jac[1*3+1]*jac[2*3+0])/(detj);
373     j[2*3+1] = -(jac[0*3+0]*jac[2*3+1]-jac[0*3+1]*jac[2*3+0])/(detj);
374     j[2*3+2] = (jac[0*3+0]*jac[1*3+1]-jac[0*3+1]*jac[1*3+0])/(detj);
375    
376    
377    
378     }
379    
380 francois 635 bool FEM_TETRA4::valide_parametre_EF(double* uvw)
381     {
382     if (uvw[0]>=-1e-10)
383     if (uvw[1]>=-1e-10)
384     if (uvw[2]>=-1e-10)
385     if (uvw[0]+uvw[1]+uvw[2]<=1.+1e-10)
386     return true;
387     return false;
388     }
389 francois 763 void FEM_TETRA4::enregistrer(std::ostream& o,double version)
390 francois 283 {
391 francois 378 if (maillage!=NULL)
392 francois 410 if (get_lien_topologie()!=NULL) o << "%" << get_id() << "=FEM_TETRA4($"<< get_lien_topologie()->get_id() << ",$" << maillage->get_id() << ",$" << tab[0]->get_id() << ",$" << tab[1]->get_id() << ",$" << tab[2]->get_id() << ",$" << tab[3]->get_id() << ","<< get_etat(0) << ");" << std::endl;
393     else o << "%" << get_id() << "=FEM_TETRA4(NULL,$"<< maillage->get_id() << ",$" << tab[0]->get_id() << ",$" << tab[1]->get_id() << ",$" << tab[2]->get_id() << ",$" << tab[3]->get_id() << ","<< get_etat(0) << ");" << std::endl;
394 francois 378 else
395 francois 410 if (get_lien_topologie()!=NULL) o << "%" << get_id() << "=FEM_TETRA4($"<< get_lien_topologie()->get_id() << ",NULL,$" << tab[0]->get_id() << ",$" << tab[1]->get_id() << ",$" << tab[2]->get_id() << ",$" << tab[3]->get_id() << ","<< get_etat(0) << ");" << std::endl;
396     else o << "%" << get_id() << "=FEM_TETRA4(NULL,NULL,$" << tab[0]->get_id() << ",$" << tab[1]->get_id() << ",$" << tab[2]->get_id() << ",$" << tab[3]->get_id() << ","<< get_etat(0) << ");" << std::endl;
397 francois 339
398 francois 283 }
399 francois 405
400    
401 francois 406 int FEM_TETRA4::verifie_validite_decoupage_xfem(double *vol)
402 francois 405 {
403     if (get_nb_xfem(3)==0) return 1;
404     FEM_NOEUD* no1=get_fem_noeud(0);
405     FEM_NOEUD* no2=get_fem_noeud(1);
406     FEM_NOEUD* no3=get_fem_noeud(2);
407     FEM_NOEUD* no4=get_fem_noeud(3);
408     OT_VECTEUR_3D vec1(no1->get_coord(),no2->get_coord());
409     OT_VECTEUR_3D vec2(no1->get_coord(),no3->get_coord());
410     OT_VECTEUR_3D vec3(no1->get_coord(),no4->get_coord());
411     double volume=(vec1&vec2)*vec3;
412 francois 407 int volumenul=0;
413 francois 405 for (int i=0;i<get_nb_xfem(3);i++)
414     {
415     XFEM_TETRA4* xtet=(XFEM_TETRA4*)get_xfem(3,i);
416     FEM_NOEUD* xno1=xtet->get_fem_noeud(0);
417     FEM_NOEUD* xno2=xtet->get_fem_noeud(1);
418     FEM_NOEUD* xno3=xtet->get_fem_noeud(2);
419     FEM_NOEUD* xno4=xtet->get_fem_noeud(3);
420     OT_VECTEUR_3D xvec1(xno1->get_coord(),xno2->get_coord());
421     OT_VECTEUR_3D xvec2(xno1->get_coord(),xno3->get_coord());
422     OT_VECTEUR_3D xvec3(xno1->get_coord(),xno4->get_coord());
423     double xvolume=(xvec1&xvec2)*xvec3;
424     volume=volume-xvolume;
425 francois 407 if (xvolume<1e-10*volume) volumenul=1;
426 francois 405 }
427 francois 406 if (vol!=NULL) *vol=volume;
428 francois 407 if (fabs(volume)>1e-12) return 2*volumenul;
429     return 1+2*volumenul;
430 francois 405 }