ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/fem_tetra4.cpp
Revision: 763
Committed: Wed Dec 2 19:55:53 2015 UTC (9 years, 5 months ago) by francois
File size: 13441 byte(s)
Log Message:
Le fichier MAGiC est maintenant versionné. LA version actuelle est 2.0. L'ancienne version est 1.0.
Tout est transparent pour l'utilisateur. Les vieilles versions sont lisibles mais les nouveaux enregistrements sont dans la version la plus récente.
Changement des conditions aux limites : ajout d'un parametre pour dire si la condition numerique est une valeur ou une formule ou un lien vers une autre entité magic.
Les parametres pour saisir sont maintenant -ccf -ccfi -ccff -ccft -ccfit -ccfft

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 francois 757 int FEM_TETRA4::get_degre_gauss(int num)
187     {
188     return OT_POINTS_GAUSS::get_degre_gauss_tetra(num);
189     }
190 francois 637
191    
192 francois 638 int FEM_TETRA4::get_nb_fonction_interpolation(void)
193 francois 283 {
194     return 4;
195     }
196 francois 638 int FEM_TETRA4::get_degremax_fonction_interpolation(void)
197     {
198     return 1;
199     }
200 francois 283
201     double FEM_TETRA4::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]-uv[2];
208     break;
209     case 2:
210     val=uv[0];
211     break;
212     case 3:
213     val=uv[1];
214     break;
215     case 4:
216     val=uv[2];
217     break;
218     }
219     return val;
220     }
221    
222     double FEM_TETRA4::get_fonction_derive_interpolation(int num,int num_variable,double *uv)
223     {
224     double val;
225    
226     switch (num)
227     {
228     case 1:
229     switch (num_variable)
230     {
231     case 1:
232     val=-1;
233     break;
234     case 2:
235     val=-1;
236     break;
237     case 3:
238     val=-1;
239     break;
240     } break;
241     case 2:
242     switch (num_variable)
243     {
244     case 1:
245     val=1;
246     break;
247     case 2:
248     val=0;
249     break;
250     case 3:
251     val=0;
252     break;
253     }break;
254     case 3:
255     switch (num_variable)
256     {
257     case 1:
258     val=0;
259     break;
260     case 2:
261     val=1;
262     break;
263     case 3:
264     val=0;
265     break;
266     }break;
267     case 4:
268     switch (num_variable)
269     {
270     case 1:
271     val=0;
272     break;
273     case 2:
274     val=0;
275     break;
276     case 3:
277     val=1;
278     break;
279     }break;
280    
281     }
282     return val;
283     }
284    
285     double FEM_TETRA4::get_jacobien(double* jac,double *uv,int& li,int& col,double unite)
286     {
287     li=3;
288     col=3;
289     double *xyz1=tab[0]->get_coord();
290     double *xyz2=tab[1]->get_coord();
291     double *xyz3=tab[2]->get_coord();
292     double *xyz4=tab[3]->get_coord();
293    
294     jac[0]=unite*(xyz2[0] - xyz1[0]) ;
295     jac[1]=unite*(xyz2[1] - xyz1[1]) ;
296     jac[2]=unite*(xyz2[2] - xyz1[2]) ;
297    
298     jac[3]=unite*(xyz3[0] - xyz1[0]) ;
299     jac[4]=unite*(xyz3[1] - xyz1[1]) ;
300     jac[5]=unite*(xyz3[2] - xyz1[2]) ;
301    
302     jac[6]=unite*(xyz4[0] - xyz1[0]) ;
303     jac[7]=unite*(xyz4[1] - xyz1[1]) ;
304     jac[8]=unite*(xyz4[2] - xyz1[2]) ;
305    
306     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]);
307    
308     return SIX_V;
309     }
310    
311     void FEM_TETRA4::get_inverse_jacob(double* j,double *uv,double unite)
312     {
313     double *xyz1=tab[0]->get_coord();
314     double *xyz2=tab[1]->get_coord();
315     double *xyz3=tab[2]->get_coord();
316     double *xyz4=tab[3]->get_coord();
317    
318     double jac[9];
319    
320     jac[0*3+0]= unite*(xyz2[0] - xyz1[0]) ;
321     jac[0*3+1]= unite*(xyz2[1] - xyz1[1]) ;
322     jac[0*3+2]= unite*(xyz2[2] - xyz1[2]) ;
323    
324     jac[1*3+0]= unite*(xyz3[0] - xyz1[0]) ;
325     jac[1*3+1]= unite*(xyz3[1] - xyz1[1]) ;
326     jac[1*3+2]= unite*(xyz3[2] - xyz1[2]) ;
327    
328     jac[2*3+0]= unite*(xyz4[0] - xyz1[0]) ;
329     jac[2*3+1]= unite*(xyz4[1] - xyz1[1]) ;
330     jac[2*3+2]= unite*(xyz4[2] - xyz1[2]) ;
331    
332     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]);
333    
334     j[0*3+0] = (jac[1*3+1]*jac[2*3+2]-jac[1*3+2]*jac[2*3+1])/(detj);
335     j[0*3+1] = -(jac[0*3+1]*jac[2*3+2]-jac[0*3+2]*jac[2*3+1])/(detj);
336     j[0*3+2] =-(-jac[0*3+1]*jac[1*3+2]+jac[0*3+2]*jac[1*3+1])/(detj);
337    
338     j[1*3+0] = -(jac[1*3+0]*jac[2*3+2]-jac[1*3+2]*jac[2*3+0])/(detj);
339     j[1*3+1] = (jac[0*3+0]*jac[2*3+2]-jac[0*3+2]*jac[2*3+0])/(detj);
340     j[1*3+2] = -(jac[0*3+0]*jac[1*3+2]-jac[0*3+2]*jac[1*3+0])/(detj);
341    
342     j[2*3+0] =-(-jac[1*3+0]*jac[2*3+1]+jac[1*3+1]*jac[2*3+0])/(detj);
343     j[2*3+1] = -(jac[0*3+0]*jac[2*3+1]-jac[0*3+1]*jac[2*3+0])/(detj);
344     j[2*3+2] = (jac[0*3+0]*jac[1*3+1]-jac[0*3+1]*jac[1*3+0])/(detj);
345    
346    
347    
348     }
349    
350 francois 635 bool FEM_TETRA4::valide_parametre_EF(double* uvw)
351     {
352     if (uvw[0]>=-1e-10)
353     if (uvw[1]>=-1e-10)
354     if (uvw[2]>=-1e-10)
355     if (uvw[0]+uvw[1]+uvw[2]<=1.+1e-10)
356     return true;
357     return false;
358     }
359 francois 763 void FEM_TETRA4::enregistrer(std::ostream& o,double version)
360 francois 283 {
361 francois 378 if (maillage!=NULL)
362 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;
363     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;
364 francois 378 else
365 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;
366     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;
367 francois 339
368 francois 283 }
369 francois 405
370    
371 francois 406 int FEM_TETRA4::verifie_validite_decoupage_xfem(double *vol)
372 francois 405 {
373     if (get_nb_xfem(3)==0) return 1;
374     FEM_NOEUD* no1=get_fem_noeud(0);
375     FEM_NOEUD* no2=get_fem_noeud(1);
376     FEM_NOEUD* no3=get_fem_noeud(2);
377     FEM_NOEUD* no4=get_fem_noeud(3);
378     OT_VECTEUR_3D vec1(no1->get_coord(),no2->get_coord());
379     OT_VECTEUR_3D vec2(no1->get_coord(),no3->get_coord());
380     OT_VECTEUR_3D vec3(no1->get_coord(),no4->get_coord());
381     double volume=(vec1&vec2)*vec3;
382 francois 407 int volumenul=0;
383 francois 405 for (int i=0;i<get_nb_xfem(3);i++)
384     {
385     XFEM_TETRA4* xtet=(XFEM_TETRA4*)get_xfem(3,i);
386     FEM_NOEUD* xno1=xtet->get_fem_noeud(0);
387     FEM_NOEUD* xno2=xtet->get_fem_noeud(1);
388     FEM_NOEUD* xno3=xtet->get_fem_noeud(2);
389     FEM_NOEUD* xno4=xtet->get_fem_noeud(3);
390     OT_VECTEUR_3D xvec1(xno1->get_coord(),xno2->get_coord());
391     OT_VECTEUR_3D xvec2(xno1->get_coord(),xno3->get_coord());
392     OT_VECTEUR_3D xvec3(xno1->get_coord(),xno4->get_coord());
393     double xvolume=(xvec1&xvec2)*xvec3;
394     volume=volume-xvolume;
395 francois 407 if (xvolume<1e-10*volume) volumenul=1;
396 francois 405 }
397 francois 406 if (vol!=NULL) *vol=volume;
398 francois 407 if (fabs(volume)>1e-12) return 2*volumenul;
399     return 1+2*volumenul;
400 francois 405 }