ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/fem_tetra4.cpp
Revision: 754
Committed: Thu Oct 29 21:49:15 2015 UTC (9 years, 6 months ago) by francois
File size: 13327 byte(s)
Log Message:
Centralisation et unification de la définition des points de gauss des elements finis et arrangement dans le meme ordre que 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     FEM_ELEMENT_MAILLAGE* FEM_TETRA4::dupliquer(FEM_MAILLAGE *femmai,long decalage)
131     {
132     FEM_NOEUD* tabnoeud[4];
133     tabnoeud[0]=femmai->get_fem_noeudid(tab[0]->get_id()+decalage);
134     tabnoeud[1]=femmai->get_fem_noeudid(tab[1]->get_id()+decalage);
135     tabnoeud[2]=femmai->get_fem_noeudid(tab[2]->get_id()+decalage);
136     tabnoeud[3]=femmai->get_fem_noeudid(tab[3]->get_id()+decalage);
137     FEM_TETRA4* tet=new FEM_TETRA4(get_id()+decalage,maillage,tabnoeud);
138 francois 309 femmai->ajouter_fem_element3(tet);
139 francois 283 return tet;
140     }
141    
142    
143     int FEM_TETRA4::get_type_entite(void)
144     {
145     return IDFEM_TETRA4;
146     }
147    
148     int FEM_TETRA4::get_dimension(void)
149     {
150     return 3;
151     }
152    
153    
154     int FEM_TETRA4::get_nb_fem_noeud(void)
155     {
156     return FEM_TEMPLATE_ELEMENT<4>::get_nb_fem_noeud();
157     }
158    
159     FEM_NOEUD* FEM_TETRA4::get_fem_noeud(int num)
160     {
161     return FEM_TEMPLATE_ELEMENT<4>::get_fem_noeud(num);
162     }
163    
164     void FEM_TETRA4::change_noeud(int num,FEM_NOEUD* noeud)
165     {
166     FEM_TEMPLATE_ELEMENT<4>::change_noeud(num,noeud);
167     }
168    
169    
170     BOITE_3D& FEM_TETRA4::get_boite_3D(void)
171     {
172     return FEM_TEMPLATE_ELEMENT<4>::get_boite_3D();
173     }
174 francois 637
175    
176     int FEM_TETRA4::get_nb_pt_gauss(int degre)
177     {
178 francois 754 return OT_POINTS_GAUSS::get_nb_point_tetra(degre);
179 francois 637 }
180    
181     void FEM_TETRA4::get_pt_gauss(int degre,int num,double &w,double *uvw)
182     {
183 francois 754 return OT_POINTS_GAUSS::get_pt_gauss_tet(degre,num,w,uvw);
184 francois 637 }
185    
186    
187    
188 francois 638 int FEM_TETRA4::get_nb_fonction_interpolation(void)
189 francois 283 {
190     return 4;
191     }
192 francois 638 int FEM_TETRA4::get_degremax_fonction_interpolation(void)
193     {
194     return 1;
195     }
196 francois 283
197     double FEM_TETRA4::get_fonction_interpolation(int num,double *uv)
198     {
199     double val;
200     switch (num)
201     {
202     case 1:
203     val=1-uv[0]-uv[1]-uv[2];
204     break;
205     case 2:
206     val=uv[0];
207     break;
208     case 3:
209     val=uv[1];
210     break;
211     case 4:
212     val=uv[2];
213     break;
214     }
215     return val;
216     }
217    
218     double FEM_TETRA4::get_fonction_derive_interpolation(int num,int num_variable,double *uv)
219     {
220     double val;
221    
222     switch (num)
223     {
224     case 1:
225     switch (num_variable)
226     {
227     case 1:
228     val=-1;
229     break;
230     case 2:
231     val=-1;
232     break;
233     case 3:
234     val=-1;
235     break;
236     } break;
237     case 2:
238     switch (num_variable)
239     {
240     case 1:
241     val=1;
242     break;
243     case 2:
244     val=0;
245     break;
246     case 3:
247     val=0;
248     break;
249     }break;
250     case 3:
251     switch (num_variable)
252     {
253     case 1:
254     val=0;
255     break;
256     case 2:
257     val=1;
258     break;
259     case 3:
260     val=0;
261     break;
262     }break;
263     case 4:
264     switch (num_variable)
265     {
266     case 1:
267     val=0;
268     break;
269     case 2:
270     val=0;
271     break;
272     case 3:
273     val=1;
274     break;
275     }break;
276    
277     }
278     return val;
279     }
280    
281     double FEM_TETRA4::get_jacobien(double* jac,double *uv,int& li,int& col,double unite)
282     {
283     li=3;
284     col=3;
285     double *xyz1=tab[0]->get_coord();
286     double *xyz2=tab[1]->get_coord();
287     double *xyz3=tab[2]->get_coord();
288     double *xyz4=tab[3]->get_coord();
289    
290     jac[0]=unite*(xyz2[0] - xyz1[0]) ;
291     jac[1]=unite*(xyz2[1] - xyz1[1]) ;
292     jac[2]=unite*(xyz2[2] - xyz1[2]) ;
293    
294     jac[3]=unite*(xyz3[0] - xyz1[0]) ;
295     jac[4]=unite*(xyz3[1] - xyz1[1]) ;
296     jac[5]=unite*(xyz3[2] - xyz1[2]) ;
297    
298     jac[6]=unite*(xyz4[0] - xyz1[0]) ;
299     jac[7]=unite*(xyz4[1] - xyz1[1]) ;
300     jac[8]=unite*(xyz4[2] - xyz1[2]) ;
301    
302     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]);
303    
304     return SIX_V;
305     }
306    
307     void FEM_TETRA4::get_inverse_jacob(double* j,double *uv,double unite)
308     {
309     double *xyz1=tab[0]->get_coord();
310     double *xyz2=tab[1]->get_coord();
311     double *xyz3=tab[2]->get_coord();
312     double *xyz4=tab[3]->get_coord();
313    
314     double jac[9];
315    
316     jac[0*3+0]= unite*(xyz2[0] - xyz1[0]) ;
317     jac[0*3+1]= unite*(xyz2[1] - xyz1[1]) ;
318     jac[0*3+2]= unite*(xyz2[2] - xyz1[2]) ;
319    
320     jac[1*3+0]= unite*(xyz3[0] - xyz1[0]) ;
321     jac[1*3+1]= unite*(xyz3[1] - xyz1[1]) ;
322     jac[1*3+2]= unite*(xyz3[2] - xyz1[2]) ;
323    
324     jac[2*3+0]= unite*(xyz4[0] - xyz1[0]) ;
325     jac[2*3+1]= unite*(xyz4[1] - xyz1[1]) ;
326     jac[2*3+2]= unite*(xyz4[2] - xyz1[2]) ;
327    
328     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]);
329    
330     j[0*3+0] = (jac[1*3+1]*jac[2*3+2]-jac[1*3+2]*jac[2*3+1])/(detj);
331     j[0*3+1] = -(jac[0*3+1]*jac[2*3+2]-jac[0*3+2]*jac[2*3+1])/(detj);
332     j[0*3+2] =-(-jac[0*3+1]*jac[1*3+2]+jac[0*3+2]*jac[1*3+1])/(detj);
333    
334     j[1*3+0] = -(jac[1*3+0]*jac[2*3+2]-jac[1*3+2]*jac[2*3+0])/(detj);
335     j[1*3+1] = (jac[0*3+0]*jac[2*3+2]-jac[0*3+2]*jac[2*3+0])/(detj);
336     j[1*3+2] = -(jac[0*3+0]*jac[1*3+2]-jac[0*3+2]*jac[1*3+0])/(detj);
337    
338     j[2*3+0] =-(-jac[1*3+0]*jac[2*3+1]+jac[1*3+1]*jac[2*3+0])/(detj);
339     j[2*3+1] = -(jac[0*3+0]*jac[2*3+1]-jac[0*3+1]*jac[2*3+0])/(detj);
340     j[2*3+2] = (jac[0*3+0]*jac[1*3+1]-jac[0*3+1]*jac[1*3+0])/(detj);
341    
342    
343    
344     }
345    
346 francois 635 bool FEM_TETRA4::valide_parametre_EF(double* uvw)
347     {
348     if (uvw[0]>=-1e-10)
349     if (uvw[1]>=-1e-10)
350     if (uvw[2]>=-1e-10)
351     if (uvw[0]+uvw[1]+uvw[2]<=1.+1e-10)
352     return true;
353     return false;
354     }
355 francois 283 void FEM_TETRA4::enregistrer(std::ostream& o)
356     {
357 francois 378 if (maillage!=NULL)
358 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;
359     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;
360 francois 378 else
361 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;
362     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;
363 francois 339
364 francois 283 }
365 francois 405
366    
367 francois 406 int FEM_TETRA4::verifie_validite_decoupage_xfem(double *vol)
368 francois 405 {
369     if (get_nb_xfem(3)==0) return 1;
370     FEM_NOEUD* no1=get_fem_noeud(0);
371     FEM_NOEUD* no2=get_fem_noeud(1);
372     FEM_NOEUD* no3=get_fem_noeud(2);
373     FEM_NOEUD* no4=get_fem_noeud(3);
374     OT_VECTEUR_3D vec1(no1->get_coord(),no2->get_coord());
375     OT_VECTEUR_3D vec2(no1->get_coord(),no3->get_coord());
376     OT_VECTEUR_3D vec3(no1->get_coord(),no4->get_coord());
377     double volume=(vec1&vec2)*vec3;
378 francois 407 int volumenul=0;
379 francois 405 for (int i=0;i<get_nb_xfem(3);i++)
380     {
381     XFEM_TETRA4* xtet=(XFEM_TETRA4*)get_xfem(3,i);
382     FEM_NOEUD* xno1=xtet->get_fem_noeud(0);
383     FEM_NOEUD* xno2=xtet->get_fem_noeud(1);
384     FEM_NOEUD* xno3=xtet->get_fem_noeud(2);
385     FEM_NOEUD* xno4=xtet->get_fem_noeud(3);
386     OT_VECTEUR_3D xvec1(xno1->get_coord(),xno2->get_coord());
387     OT_VECTEUR_3D xvec2(xno1->get_coord(),xno3->get_coord());
388     OT_VECTEUR_3D xvec3(xno1->get_coord(),xno4->get_coord());
389     double xvolume=(xvec1&xvec2)*xvec3;
390     volume=volume-xvolume;
391 francois 407 if (xvolume<1e-10*volume) volumenul=1;
392 francois 405 }
393 francois 406 if (vol!=NULL) *vol=volume;
394 francois 407 if (fabs(volume)>1e-12) return 2*volumenul;
395     return 1+2*volumenul;
396 francois 405 }