ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/mtu/src/fem_tetra4.cpp
Revision: 1114
Committed: Wed May 3 18:29:42 2023 UTC (2 years ago) by francois
File size: 11749 byte(s)
Log Message:
Étape 2  : remplacement du nom geometrie par mtu pour corresponde à la publi de mtu

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    
316    
317 francois 635 bool FEM_TETRA4::valide_parametre_EF(double* uvw)
318     {
319     if (uvw[0]>=-1e-10)
320     if (uvw[1]>=-1e-10)
321     if (uvw[2]>=-1e-10)
322     if (uvw[0]+uvw[1]+uvw[2]<=1.+1e-10)
323     return true;
324     return false;
325     }
326 francois 763 void FEM_TETRA4::enregistrer(std::ostream& o,double version)
327 francois 283 {
328 francois 378 if (maillage!=NULL)
329 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;
330     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;
331 francois 378 else
332 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;
333     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;
334 francois 339
335 francois 283 }
336 francois 405
337    
338 francois 406 int FEM_TETRA4::verifie_validite_decoupage_xfem(double *vol)
339 francois 405 {
340     if (get_nb_xfem(3)==0) return 1;
341     FEM_NOEUD* no1=get_fem_noeud(0);
342     FEM_NOEUD* no2=get_fem_noeud(1);
343     FEM_NOEUD* no3=get_fem_noeud(2);
344     FEM_NOEUD* no4=get_fem_noeud(3);
345     OT_VECTEUR_3D vec1(no1->get_coord(),no2->get_coord());
346     OT_VECTEUR_3D vec2(no1->get_coord(),no3->get_coord());
347     OT_VECTEUR_3D vec3(no1->get_coord(),no4->get_coord());
348     double volume=(vec1&vec2)*vec3;
349 francois 407 int volumenul=0;
350 francois 405 for (int i=0;i<get_nb_xfem(3);i++)
351     {
352     XFEM_TETRA4* xtet=(XFEM_TETRA4*)get_xfem(3,i);
353     FEM_NOEUD* xno1=xtet->get_fem_noeud(0);
354     FEM_NOEUD* xno2=xtet->get_fem_noeud(1);
355     FEM_NOEUD* xno3=xtet->get_fem_noeud(2);
356     FEM_NOEUD* xno4=xtet->get_fem_noeud(3);
357     OT_VECTEUR_3D xvec1(xno1->get_coord(),xno2->get_coord());
358     OT_VECTEUR_3D xvec2(xno1->get_coord(),xno3->get_coord());
359     OT_VECTEUR_3D xvec3(xno1->get_coord(),xno4->get_coord());
360     double xvolume=(xvec1&xvec2)*xvec3;
361     volume=volume-xvolume;
362 francois 407 if (xvolume<1e-10*volume) volumenul=1;
363 francois 405 }
364 francois 406 if (vol!=NULL) *vol=volume;
365 francois 407 if (fabs(volume)>1e-12) return 2*volumenul;
366     return 1+2*volumenul;
367 francois 405 }