ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/fem_segment2.cpp
Revision: 638
Committed: Mon Jan 26 21:56:20 2015 UTC (10 years, 3 months ago) by francois
File size: 9211 byte(s)
Log Message:
ajout d'une méthode qui renvoit le degre max des fonctions d'interpolation et changement de nom de la fonction qui renvoie le nombre de fonction d'interpolation (ajout d'un get pour uniformiser)

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_element12.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_segment2.h"
27     #include "fem_noeud.h"
28     #include "fem_maillage.h"
29     #include "mg_element_maillage.h"
30    
31 francois 309 FEM_SEGMENT2::FEM_SEGMENT2(unsigned long num,class MG_ELEMENT_MAILLAGE* mai,class FEM_NOEUD** tabnoeud):FEM_ELEMENT1(num,mai),FEM_TEMPLATE_ELEMENT<2>(tabnoeud)
32 francois 283 {
33 francois 378 tab[0]->get_lien_element1()->ajouter(this);
34     tab[1]->get_lien_element1()->ajouter(this);
35     get_fem_noeudpetitid()->get_lien_petit_element1()->ajouter(this);
36 francois 283 if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==1) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
37 francois 378
38     }
39     FEM_SEGMENT2::FEM_SEGMENT2(unsigned long num,class MG_ELEMENT_TOPOLOGIQUE* topo,class MG_ELEMENT_MAILLAGE* mai,class FEM_NOEUD** tabnoeud):FEM_ELEMENT1(num,topo,mai),FEM_TEMPLATE_ELEMENT<2>(tabnoeud)
40     {
41 francois 309 tab[0]->get_lien_element1()->ajouter(this);
42     tab[1]->get_lien_element1()->ajouter(this);
43     get_fem_noeudpetitid()->get_lien_petit_element1()->ajouter(this);
44 francois 378 if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==1) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
45    
46 francois 283 }
47    
48 francois 378 FEM_SEGMENT2::FEM_SEGMENT2(class MG_ELEMENT_TOPOLOGIQUE* topo,class FEM_NOEUD** tabnoeud):FEM_ELEMENT1(topo),FEM_TEMPLATE_ELEMENT<2>(tabnoeud)
49     {
50     tab[0]->get_lien_element1()->ajouter(this);
51     tab[1]->get_lien_element1()->ajouter(this);
52     get_fem_noeudpetitid()->get_lien_petit_element1()->ajouter(this);
53     if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==1) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
54    
55     }
56 francois 309 FEM_SEGMENT2::FEM_SEGMENT2(class MG_ELEMENT_MAILLAGE* mai,FEM_NOEUD** tabnoeud):FEM_ELEMENT1(mai),FEM_TEMPLATE_ELEMENT<2>(tabnoeud)
57 francois 283 {
58 francois 309 tab[0]->get_lien_element1()->ajouter(this);
59     tab[1]->get_lien_element1()->ajouter(this);
60     get_fem_noeudpetitid()->get_lien_petit_element1()->ajouter(this);
61 francois 378 if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==1) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
62    
63 francois 283 }
64    
65 francois 309 FEM_SEGMENT2::FEM_SEGMENT2(FEM_SEGMENT2& mdd):FEM_ELEMENT1(mdd),FEM_TEMPLATE_ELEMENT<2>(mdd)
66 francois 283 {
67 francois 309 tab[0]->get_lien_element1()->ajouter(this);
68     tab[1]->get_lien_element1()->ajouter(this);
69     get_fem_noeudpetitid()->get_lien_petit_element1()->ajouter(this);
70 francois 378 if (liaison_topologique!=NULL) if (liaison_topologique->get_dimension()==1) liaison_topologique->get_lien_fem_maillage()->ajouter(this);
71    
72 francois 283 }
73    
74     FEM_SEGMENT2::~FEM_SEGMENT2()
75     {
76     if (liaison_topologique==NULL) return;
77     if (liaison_topologique->get_dimension()==0) liaison_topologique->get_lien_fem_maillage()->supprimer(this);
78 francois 309 tab[0]->get_lien_element1()->supprimer(this);
79     tab[1]->get_lien_element1()->supprimer(this);
80     get_fem_noeudpetitid()->get_lien_petit_element1()->supprimer(this);
81 francois 283 }
82    
83     FEM_ELEMENT_MAILLAGE* FEM_SEGMENT2::dupliquer(FEM_MAILLAGE *femmai,long decalage)
84     {
85     FEM_NOEUD* tabnoeud[2];
86     tabnoeud[0]=femmai->get_fem_noeudid(tab[0]->get_id()+decalage);
87     tabnoeud[1]=femmai->get_fem_noeudid(tab[1]->get_id()+decalage);
88     FEM_SEGMENT2* seg=new FEM_SEGMENT2(get_id()+decalage,maillage,tabnoeud);
89 francois 309 femmai->ajouter_fem_element1(seg);
90 francois 283 return seg;
91     }
92    
93 francois 635 bool FEM_SEGMENT2::valide_parametre_EF(double* uvw)
94     {
95     if (uvw[0]>=-1e-10)
96     if (uvw[0]<=1.+1e-10)
97     return true;
98     return false;
99     }
100 francois 283
101    
102    
103     int FEM_SEGMENT2::get_type_entite(void)
104     {
105     return IDFEM_SEGMENT2;
106     }
107    
108     int FEM_SEGMENT2::get_dimension(void)
109     {
110     return 1;
111     }
112    
113    
114    
115     int FEM_SEGMENT2::get_nb_fem_noeud(void)
116     {
117     return FEM_TEMPLATE_ELEMENT<2>::get_nb_fem_noeud();
118     }
119    
120     FEM_NOEUD* FEM_SEGMENT2::get_fem_noeud(int num)
121     {
122     return FEM_TEMPLATE_ELEMENT<2>::get_fem_noeud(num);
123     }
124    
125     void FEM_SEGMENT2::change_noeud(int num,FEM_NOEUD* noeud)
126     {
127     FEM_TEMPLATE_ELEMENT<2>::change_noeud(num,noeud);
128     }
129    
130     BOITE_3D& FEM_SEGMENT2::get_boite_3D(void)
131     {
132     return FEM_TEMPLATE_ELEMENT<2>::get_boite_3D();
133     }
134    
135    
136     void FEM_SEGMENT2::enregistrer(std::ostream& o)
137     {
138 francois 378 if (maillage!=NULL)
139     if (get_lien_topologie()!=NULL) o << "%" << get_id() << "=FEM_SEGMENT2($"<< get_lien_topologie()->get_id() << ",$"<< maillage->get_id() << ",$" << tab[0]->get_id() << ",$" << tab[1]->get_id() << ");" << std::endl;
140 francois 283 else o << "%" << get_id() << "=FEM_SEGMENT2(NULL,$" << maillage->get_id() <<",$" << tab[0]->get_id() << ",$" << tab[1]->get_id() << ");" << std::endl;
141 francois 378 if (maillage==NULL)
142     if (get_lien_topologie()!=NULL) o << "%" << get_id() << "=FEM_SEGMENT2($"<< get_lien_topologie()->get_id() << ",NULL,$" << tab[0]->get_id() << ",$" << tab[1]->get_id() << ");" << std::endl;
143     else o << "%" << get_id() << "=FEM_SEGMENT2(NULL,NULL,$" << tab[0]->get_id() << ",$" << tab[1]->get_id() << ");" << std::endl;
144 francois 283 }
145 francois 310
146    
147 francois 637 int FEM_SEGMENT2::get_nb_pt_gauss(int degre)
148     {
149     if (degre<2) return 1;
150     if (degre<4) return 2;
151     if (degre<6) return 3;
152     if (degre<8) return 4;
153     if (degre<10) return 5;
154     if (degre<12) return 6;
155     if (degre<14) return 7;
156     return 0;
157     }
158    
159     void FEM_SEGMENT2::get_pt_gauss(int degre,int num,double &w,double *u)
160     {
161     if (degre<2)
162     {
163     if (num==0) {w=2;u[0]=0;}
164     return;
165     }
166     if (degre<4)
167     {
168     if (num==0) {w=1;u[0]=-0.577350269189626;}
169     if (num==1) {w=1;u[0]=0.577350269189626;}
170     return;
171     }
172     if (degre<6)
173     {
174     if (num==0) {w=0.888888888888889;u[0]=0.;}
175     if (num==1) {w=0.555555555555556;u[0]=-0.774596669241483;}
176     if (num==2) {w=0.555555555555556;u[0]=0.774596669241483;}
177     return;
178     }
179     if (degre<8)
180     {
181     if (num==0) {w=0.652145154862546;u[0]=-0.339981043584856;}
182     if (num==1) {w=0.652145154862546;u[0]=0.339981043584856;}
183     if (num==2) {w=0.347854845137454;u[0]=-0.861136311594053;}
184     if (num==3) {w=0.347854845137454;u[0]=0.861136311594053;}
185     return;
186     }
187     if (degre<10)
188     {
189     if (num==0) {w=0.568888888888889;u[0]=0.;}
190     if (num==1) {w=0.478628670499366;u[0]=-0.538469310105683;}
191     if (num==2) {w=0.478628670499366;u[0]=0.538469310105683;}
192     if (num==3) {w=0.236926885056189;u[0]=-0.906179845938664;}
193     if (num==4) {w=0.236926885056189;u[0]=0.906179845938664;}
194     return;
195     }
196     if (degre<12)
197     {
198     if (num==0) {w=0.467913934572691;u[0]=-0.238619186083197;}
199     if (num==1) {w=0.467913934572691;u[0]=0.238619186083197;}
200     if (num==2) {w=0.360761573048139;u[0]=-0.661209386466265;}
201     if (num==3) {w=0.360761573048139;u[0]=0.661209386466265;}
202     if (num==4) {w=0.171324492379170;u[0]=-0.932469514203152;}
203     if (num==5) {w=0.171324492379170;u[0]=0.932469514203152;}
204     return;
205     }
206     if (degre<14)
207     {
208     if (num==0) {w=0.417959183673469;u[0]=0;}
209     if (num==1) {w=0.381830050505119;u[0]=-0.405845151377397;}
210     if (num==2) {w=0.381830050505119;u[0]=0.405845151377397;}
211     if (num==3) {w=0.279705391489277;u[0]=-0.741531185599394;}
212     if (num==4) {w=0.279705391489277;u[0]=0.741531185599394;}
213     if (num==5) {w=0.129484966168870;u[0]=-0.949107912342759;}
214     if (num==6) {w=0.129484966168870;u[0]=0.949107912342759;}
215     return;
216     }
217     }
218    
219    
220 francois 638 int FEM_SEGMENT2::get_nb_fonction_interpolation(void)
221 francois 310 {
222     return 2;
223     }
224 francois 638 int FEM_SEGMENT2::get_degremax_fonction_interpolation(void)
225     {
226     return 1;
227     }
228 francois 310 double FEM_SEGMENT2::get_fonction_interpolation(int num,double *uv)
229     {
230     double val;
231     switch (num)
232     {
233     case 1:
234     val=0.5*(1.-uv[0]);
235     break;
236     case 2:
237     val=0.5*(1.+uv[0]);
238     break;
239     }
240     return val;
241     }
242    
243     double FEM_SEGMENT2::get_fonction_derive_interpolation(int num,int num_variable,double *uv)
244     {
245     double val;
246    
247     switch (num)
248     {
249     case 1:
250     switch (num_variable)
251     {
252     case 1:
253     val=-0.5;
254     break;
255     case 2:
256     val=-0.5;
257     break;
258     }
259     break;
260    
261     }
262     return val;
263     }
264    
265     double FEM_SEGMENT2::get_jacobien(double* jac,double *uv,int& li,int& col,double unite)
266     {
267     /*li=1;
268     col=1;
269     double *xyz1=tab[0]->get_coord();
270     double *xyz2=tab[1]->get_coord();
271    
272     jac[0]=0.5*unite*(xyz2[0] - xyz1[0]) ;
273    
274    
275    
276     return jac[0];*/
277     }
278    
279     void FEM_SEGMENT2::get_inverse_jacob(double* j,double *uv,double unite)
280     {
281     /*double *xyz1=tab[0]->get_coord();
282     double *xyz2=tab[1]->get_coord();
283    
284     j[0]=1./(0.5*unite*(xyz2[0] - xyz1[0])) ;*/
285     }