ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/fem_triangle6.cpp
Revision: 612
Committed: Thu Nov 27 17:14:50 2014 UTC (10 years, 5 months ago) by francois
File size: 14253 byte(s)
Log Message:
maillage et calcul quadratique pour une coque en triangle

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     // fem_triangle6.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_triangle6.h"
27     #include "fem_noeud.h"
28     #include "mg_element_maillage.h"
29     #include "fem_maillage.h"
30 francois 612 #include "math.h"
31     #include "ot_quadrature_gauss.h"
32 francois 283
33 francois 309 FEM_TRIANGLE6::FEM_TRIANGLE6(unsigned long num,class MG_ELEMENT_MAILLAGE* mai,class FEM_NOEUD** tabnoeud):FEM_ELEMENT2(num,mai),FEM_TEMPLATE_ELEMENT<6>(tabnoeud)
34 francois 283 {
35     if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==2) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
36 francois 309 tab[0]->get_lien_element2()->ajouter(this);
37     tab[1]->get_lien_element2()->ajouter(this);
38     tab[2]->get_lien_element2()->ajouter(this);
39     tab[3]->get_lien_element2()->ajouter(this);
40     tab[4]->get_lien_element2()->ajouter(this);
41     tab[5]->get_lien_element2()->ajouter(this);
42     get_fem_noeudpetitid()->get_lien_petit_element2()->ajouter(this);
43 francois 283 }
44    
45 francois 309 FEM_TRIANGLE6::FEM_TRIANGLE6(class MG_ELEMENT_MAILLAGE* mai,FEM_NOEUD** tabnoeud):FEM_ELEMENT2(mai),FEM_TEMPLATE_ELEMENT<6>(tabnoeud)
46 francois 283 {
47     if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==2) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
48 francois 309 tab[0]->get_lien_element2()->ajouter(this);
49     tab[1]->get_lien_element2()->ajouter(this);
50     tab[2]->get_lien_element2()->ajouter(this);
51     tab[3]->get_lien_element2()->ajouter(this);
52     tab[4]->get_lien_element2()->ajouter(this);
53     tab[5]->get_lien_element2()->ajouter(this);
54     get_fem_noeudpetitid()->get_lien_petit_element2()->ajouter(this);
55 francois 283 }
56    
57 francois 378 FEM_TRIANGLE6::FEM_TRIANGLE6(unsigned long num,class MG_ELEMENT_TOPOLOGIQUE* topo,class FEM_NOEUD** tabnoeud):FEM_ELEMENT2(num,topo),FEM_TEMPLATE_ELEMENT<6>(tabnoeud)
58     {
59     if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==2) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
60     tab[0]->get_lien_element2()->ajouter(this);
61     tab[1]->get_lien_element2()->ajouter(this);
62     tab[2]->get_lien_element2()->ajouter(this);
63     tab[3]->get_lien_element2()->ajouter(this);
64     tab[4]->get_lien_element2()->ajouter(this);
65     tab[5]->get_lien_element2()->ajouter(this);
66     get_fem_noeudpetitid()->get_lien_petit_element2()->ajouter(this);
67     }
68    
69     FEM_TRIANGLE6::FEM_TRIANGLE6(class MG_ELEMENT_TOPOLOGIQUE* topo,FEM_NOEUD** tabnoeud):FEM_ELEMENT2(topo),FEM_TEMPLATE_ELEMENT<6>(tabnoeud)
70     {
71     if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==2) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
72     tab[0]->get_lien_element2()->ajouter(this);
73     tab[1]->get_lien_element2()->ajouter(this);
74     tab[2]->get_lien_element2()->ajouter(this);
75     tab[3]->get_lien_element2()->ajouter(this);
76     tab[4]->get_lien_element2()->ajouter(this);
77     tab[5]->get_lien_element2()->ajouter(this);
78     get_fem_noeudpetitid()->get_lien_petit_element2()->ajouter(this);
79     }
80     FEM_TRIANGLE6::FEM_TRIANGLE6(unsigned long num,class MG_ELEMENT_TOPOLOGIQUE* topo,class MG_ELEMENT_MAILLAGE* mai,class FEM_NOEUD** tabnoeud):FEM_ELEMENT2(num,topo,mai),FEM_TEMPLATE_ELEMENT<6>(tabnoeud)
81     {
82     if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==2) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
83     tab[0]->get_lien_element2()->ajouter(this);
84     tab[1]->get_lien_element2()->ajouter(this);
85     tab[2]->get_lien_element2()->ajouter(this);
86     tab[3]->get_lien_element2()->ajouter(this);
87     tab[4]->get_lien_element2()->ajouter(this);
88     tab[5]->get_lien_element2()->ajouter(this);
89     get_fem_noeudpetitid()->get_lien_petit_element2()->ajouter(this);
90     }
91    
92     FEM_TRIANGLE6::FEM_TRIANGLE6(class MG_ELEMENT_TOPOLOGIQUE* topo,class MG_ELEMENT_MAILLAGE* mai,FEM_NOEUD** tabnoeud):FEM_ELEMENT2(topo,mai),FEM_TEMPLATE_ELEMENT<6>(tabnoeud)
93     {
94     if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==2) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
95     tab[0]->get_lien_element2()->ajouter(this);
96     tab[1]->get_lien_element2()->ajouter(this);
97     tab[2]->get_lien_element2()->ajouter(this);
98     tab[3]->get_lien_element2()->ajouter(this);
99     tab[4]->get_lien_element2()->ajouter(this);
100     tab[5]->get_lien_element2()->ajouter(this);
101     get_fem_noeudpetitid()->get_lien_petit_element2()->ajouter(this);
102     }
103    
104    
105    
106    
107    
108    
109    
110    
111 francois 309 FEM_TRIANGLE6::FEM_TRIANGLE6(FEM_TRIANGLE6& mdd):FEM_ELEMENT2(mdd),FEM_TEMPLATE_ELEMENT<6>(mdd)
112 francois 283 {
113     if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==2) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
114 francois 309 tab[0]->get_lien_element2()->ajouter(this);
115     tab[1]->get_lien_element2()->ajouter(this);
116     tab[2]->get_lien_element2()->ajouter(this);
117     tab[3]->get_lien_element2()->ajouter(this);
118     tab[4]->get_lien_element2()->ajouter(this);
119     tab[5]->get_lien_element2()->ajouter(this);
120     get_fem_noeudpetitid()->get_lien_petit_element2()->ajouter(this);
121 francois 283 }
122     FEM_TRIANGLE6::~FEM_TRIANGLE6()
123     {
124     if (liaison_topologique==NULL) return;
125     if (liaison_topologique->get_dimension()==0) liaison_topologique->get_lien_fem_maillage()->supprimer(this);
126 francois 309 tab[0]->get_lien_element2()->supprimer(this);
127     tab[1]->get_lien_element2()->supprimer(this);
128     tab[2]->get_lien_element2()->supprimer(this);
129     tab[3]->get_lien_element2()->supprimer(this);
130     tab[4]->get_lien_element2()->supprimer(this);
131     tab[5]->get_lien_element2()->supprimer(this);
132     get_fem_noeudpetitid()->get_lien_petit_element2()->supprimer(this);
133 francois 283 }
134    
135     FEM_ELEMENT_MAILLAGE* FEM_TRIANGLE6::dupliquer(FEM_MAILLAGE *femmai,long decalage)
136     {
137     FEM_NOEUD* tabnoeud[6];
138     tabnoeud[0]=femmai->get_fem_noeudid(tab[0]->get_id()+decalage);
139     tabnoeud[1]=femmai->get_fem_noeudid(tab[1]->get_id()+decalage);
140     tabnoeud[2]=femmai->get_fem_noeudid(tab[2]->get_id()+decalage);
141     tabnoeud[3]=femmai->get_fem_noeudid(tab[3]->get_id()+decalage);
142     tabnoeud[4]=femmai->get_fem_noeudid(tab[4]->get_id()+decalage);
143     tabnoeud[5]=femmai->get_fem_noeudid(tab[5]->get_id()+decalage);
144     FEM_TRIANGLE6* tri=new FEM_TRIANGLE6(get_id()+decalage,maillage,tabnoeud);
145 francois 309 femmai->ajouter_fem_element2(tri);
146 francois 283 return tri;
147     }
148    
149    
150    
151    
152     int FEM_TRIANGLE6::get_type_entite(void)
153     {
154     return IDFEM_TRIANGLE6;
155     }
156    
157     int FEM_TRIANGLE6::get_dimension(void)
158     {
159     return 2;
160     }
161    
162    
163     int FEM_TRIANGLE6::get_nb_fem_noeud(void)
164     {
165     return FEM_TEMPLATE_ELEMENT<6>::get_nb_fem_noeud();
166     }
167    
168     FEM_NOEUD* FEM_TRIANGLE6::get_fem_noeud(int num)
169     {
170     return FEM_TEMPLATE_ELEMENT<6>::get_fem_noeud(num);
171     }
172    
173     void FEM_TRIANGLE6::change_noeud(int num,FEM_NOEUD* noeud)
174     {
175     FEM_TEMPLATE_ELEMENT<6>::change_noeud(num,noeud);
176     }
177    
178     BOITE_3D& FEM_TRIANGLE6::get_boite_3D(void)
179     {
180     return FEM_TEMPLATE_ELEMENT<6>::get_boite_3D();
181     }
182    
183    
184     void FEM_TRIANGLE6::enregistrer(std::ostream& o)
185     {
186 francois 378 if (maillage!=NULL)
187     if (get_lien_topologie()!=NULL) o << "%" << get_id() << "=FEM_TRIANGLE6($"<< 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() << ");" << std::endl;
188     else o << "%" << get_id() << "=FEM_TRIANGLE6(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() << ");" << std::endl;
189     else
190     if (get_lien_topologie()!=NULL) o << "%" << get_id() << "=FEM_TRIANGLE6($"<< 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() << ");" << std::endl;
191     else o << "%" << get_id() << "=FEM_TRIANGLE6(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() << ");" << std::endl;
192    
193 francois 283 }
194 francois 310
195    
196     int FEM_TRIANGLE6::nb_fonction_interpolation(void)
197     {
198     return 6;
199     }
200    
201     double FEM_TRIANGLE6::get_fonction_interpolation(int num,double *uv)
202     {
203     double val;
204     switch (num)
205     {
206     case 1:
207     val=(-1+uv[0]+uv[1])*(-1+2*uv[0]+2*uv[1]);
208     break;
209     case 2:
210     val=4.*uv[0]*(1-uv[0]-uv[1]);
211     break;
212     case 3:
213     val=-uv[0]*(1.-2.*uv[0]);
214     break;
215     case 4:
216     val=4.*uv[0]*uv[1];
217     break;
218     case 5:
219     val=-uv[1]*(1-2*uv[1]);
220     break;
221     case 6:
222     val=4.*uv[1]*(1-uv[0]-uv[1]);
223     break;
224    
225     }
226     return val;
227     }
228    
229     double FEM_TRIANGLE6::get_fonction_derive_interpolation(int num,int num_variable,double *uv)
230     {
231     double val;
232    
233     switch (num)
234     {
235     case 1:
236     switch (num_variable)
237     {
238     case 1:
239 francois 612 val=-3.+4*uv[0]+4*uv[1];
240 francois 310 break;
241     case 2:
242     val=-3.+4*uv[0]+4*uv[1];
243     break;
244     } break;
245     case 2:
246     switch (num_variable)
247     {
248     case 1:
249     val=4.-8*uv[0]-4*uv[1];
250     break;
251     case 2:
252     val=-4.*uv[0];
253     break;
254     }break;
255     case 3:
256     switch (num_variable)
257     {
258     case 1:
259 francois 612 val=-1.+4*uv[0];
260 francois 310 break;
261     case 2:
262     val=0.;
263     break;
264     }break;
265     case 4:
266     switch (num_variable)
267     {
268     case 1:
269     val=4*uv[1];
270     break;
271     case 2:
272     val=4*uv[0];
273     break;
274     }break;
275     case 5:
276     switch (num_variable)
277     {
278     case 1:
279     val=0.;
280     break;
281     case 2:
282     val=-1+4.*uv[1];
283     break;
284     }break;
285     case 6:
286     switch (num_variable)
287     {
288     case 1:
289     val=-4*uv[1];
290     break;
291     case 2:
292     val=4-4*uv[0]-8*uv[1];
293     break;
294     }break;
295    
296     }
297     return val;
298     }
299    
300 francois 612
301 francois 310 double FEM_TRIANGLE6::get_jacobien(double* jac,double *uv,int& li,int& col,double unite)
302     {
303 francois 612 FEM_NOEUD* n1=get_fem_noeud(0);
304     FEM_NOEUD* n2=get_fem_noeud(1);
305     FEM_NOEUD* n3=get_fem_noeud(2);
306     FEM_NOEUD* n4=get_fem_noeud(3);
307     FEM_NOEUD* n5=get_fem_noeud(4);
308     FEM_NOEUD* n6=get_fem_noeud(5);
309    
310     double xyzn1[3],xyzn2[3],xyzn3[3],xyzn4[3],xyzn5[3],xyzn6[3];
311    
312     xyzn1[0]=n1->get_x();
313     xyzn1[1]=n1->get_y();
314     xyzn1[2]=n1->get_z();
315    
316     xyzn2[0]=n2->get_x();
317     xyzn2[1]=n2->get_y();
318     xyzn2[2]=n2->get_z();
319    
320     xyzn3[0]=n3->get_x();
321     xyzn3[1]=n3->get_y();
322     xyzn3[2]=n3->get_z();
323    
324     xyzn4[0]=n4->get_x();
325     xyzn4[1]=n4->get_y();
326     xyzn4[2]=n4->get_z();
327    
328     xyzn5[0]=n5->get_x();
329     xyzn5[1]=n5->get_y();
330     xyzn5[2]=n5->get_z();
331    
332     xyzn6[0]=n6->get_x();
333     xyzn6[1]=n6->get_y();
334     xyzn6[2]=n6->get_z();
335    
336     OT_VECTEUR_3D vec1(xyzn1,xyzn3);
337     OT_VECTEUR_3D vec3(xyzn1,xyzn5);
338     OT_VECTEUR_3D n=vec1&vec3;
339     n.norme();
340 francois 310
341 francois 612 jac[0]=get_fonction_derive_interpolation(1,1,uv)*xyzn1[0]+get_fonction_derive_interpolation(2,1,uv)*xyzn2[0]+get_fonction_derive_interpolation(3,1,uv)*xyzn3[0]+get_fonction_derive_interpolation(4,1,uv)*xyzn4[0]+get_fonction_derive_interpolation(6,1,uv)*xyzn6[0];
342     jac[1]=get_fonction_derive_interpolation(1,1,uv)*xyzn1[1]+get_fonction_derive_interpolation(2,1,uv)*xyzn2[1]+get_fonction_derive_interpolation(3,1,uv)*xyzn3[1]+get_fonction_derive_interpolation(4,1,uv)*xyzn4[1]+get_fonction_derive_interpolation(6,1,uv)*xyzn6[1];
343     jac[2]=get_fonction_derive_interpolation(1,1,uv)*xyzn1[2]+get_fonction_derive_interpolation(2,1,uv)*xyzn2[2]+get_fonction_derive_interpolation(3,1,uv)*xyzn3[2]+get_fonction_derive_interpolation(4,1,uv)*xyzn4[2]+get_fonction_derive_interpolation(6,1,uv)*xyzn6[2];
344    
345     jac[3]=get_fonction_derive_interpolation(1,2,uv)*xyzn1[0]+get_fonction_derive_interpolation(2,2,uv)*xyzn2[0]+get_fonction_derive_interpolation(4,2,uv)*xyzn4[0]+get_fonction_derive_interpolation(5,2,uv)*xyzn5[0]+get_fonction_derive_interpolation(6,2,uv)*xyzn6[0];
346     jac[4]=get_fonction_derive_interpolation(1,2,uv)*xyzn1[1]+get_fonction_derive_interpolation(2,2,uv)*xyzn2[1]+get_fonction_derive_interpolation(4,2,uv)*xyzn4[1]+get_fonction_derive_interpolation(5,2,uv)*xyzn5[1]+get_fonction_derive_interpolation(6,2,uv)*xyzn6[1];
347     jac[5]=get_fonction_derive_interpolation(1,2,uv)*xyzn1[2]+get_fonction_derive_interpolation(2,2,uv)*xyzn2[2]+get_fonction_derive_interpolation(4,2,uv)*xyzn4[2]+get_fonction_derive_interpolation(5,2,uv)*xyzn5[2]+get_fonction_derive_interpolation(6,2,uv)*xyzn6[2];
348    
349     jac[6]=n[0];
350     jac[7]=n[1];
351     jac[8]=n[2];
352    
353     double DET= 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]);
354    
355     return DET;
356    
357 francois 310 }
358    
359     void FEM_TRIANGLE6::get_inverse_jacob(double* j,double *uv,double unite)
360     {
361 francois 612 double jac[9];
362     int lig,col;
363     double detj=this->get_jacobien(jac,uv,lig,col,unite);
364    
365     j[0] = (jac[4]*jac[8]-jac[5]*jac[7])/(detj);
366     j[1] = -(jac[1]*jac[8]-jac[2]*jac[7])/(detj);
367     j[2] =-(-jac[1]*jac[5]+jac[2]*jac[4])/(detj);
368    
369     j[3] = -(jac[1]*jac[8]-jac[5]*jac[6])/(detj);
370     j[4] = (jac[0]*jac[8]-jac[2]*jac[6])/(detj);
371     j[5] = -(jac[0]*jac[5]-jac[2]*jac[3])/(detj);
372    
373     j[6] =-(-jac[3]*jac[7]+jac[4]*jac[6])/(detj);
374     j[7] = -(jac[0]*jac[7]-jac[1]*jac[6])/(detj);
375     j[8] = (jac[0]*jac[4]-jac[1]*jac[4])/(detj);
376    
377     }
378