ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/mg_face.cpp
Revision: 375
Committed: Fri Nov 9 15:27:14 2012 UTC (12 years, 6 months ago) by francois
File size: 9890 byte(s)
Log Message:
Solution FEM sont vectorielles et tensorielles + affichage des options de compilations dans les exe

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     // mg_face.cpp
16     //
17     //------------------------------------------------------------
18     //------------------------------------------------------------
19     // COPYRIGHT 2000
20     // Version du 02/03/2006 � 11H22
21     //------------------------------------------------------------
22     //------------------------------------------------------------
23    
24    
25     #include "gestionversion.h"
26     #include <math.h>
27     #include "mg_face.h"
28     #include "vct_face.h"
29 francois 375 #include "mg_definition.h"
30 francois 283 //#include "message.h"
31     //#include "affiche.h"
32     #include "ot_mathematique.h"
33    
34     MG_FACE::MG_FACE(std::string idori,unsigned long num,MG_SURFACE* srf,int sens):MG_ELEMENT_TOPOLOGIQUE(num,idori),surface(srf),orientation(sens),vect(NULL)
35     {
36     }
37    
38     MG_FACE::MG_FACE(std::string idori,MG_SURFACE* srf,int sens):MG_ELEMENT_TOPOLOGIQUE(idori),surface(srf),orientation(sens),vect(NULL)
39     {
40     }
41    
42     MG_FACE::MG_FACE(MG_FACE& mdd):MG_ELEMENT_TOPOLOGIQUE(mdd),lst_boucle(mdd.lst_boucle),surface(mdd.surface),orientation(mdd.orientation),vect(NULL)
43     {
44     }
45    
46     MG_FACE::~MG_FACE()
47     {
48     //if (lst_coface.size()!=0) afficheur << WARCOFACE << this->get_id()<< enderr;
49     if (vect!=NULL) delete vect;
50     }
51    
52     void MG_FACE::ajouter_mg_boucle(class MG_BOUCLE* mgbou)
53     {
54     lst_boucle.insert(lst_boucle.end(),mgbou);
55     }
56    
57     void MG_FACE::supprimer_mg_boucle(class MG_BOUCLE* mgbou)
58     {
59     std::vector<MG_BOUCLE*>::iterator i;
60     for (i=lst_boucle.begin();i!=lst_boucle.end();i++)
61     {
62     if ((*i)==mgbou)
63     {
64     lst_boucle.erase(i);
65     return;
66     }
67     }
68     }
69    
70    
71     int MG_FACE::get_nb_mg_boucle(void)
72     {
73     return lst_boucle.size();
74     }
75    
76     MG_BOUCLE* MG_FACE::get_mg_boucle(int num)
77     {
78     return lst_boucle[num];
79     }
80    
81    
82     void MG_FACE::ajouter_mg_coface(class MG_COFACE* coface)
83     {
84     lst_coface.insert(lst_coface.end(),coface);
85     }
86    
87     int MG_FACE::get_nb_mg_coface(void)
88     {
89     return lst_coface.size();
90     }
91    
92    
93     void MG_FACE::supprimer_mg_coface(class MG_COFACE* coface)
94     {
95     std::vector<MG_COFACE*>::iterator i;
96     for (i=lst_coface.begin();i!=lst_coface.end();i++)
97     {
98     if ((*i)==coface)
99     {
100     lst_coface.erase(i);
101     return;
102     }
103     }
104     }
105    
106    
107    
108     MG_COFACE* MG_FACE::get_mg_coface(int num)
109     {
110     return lst_coface[num];
111     }
112    
113     MG_SURFACE* MG_FACE::get_surface(void)
114     {
115     return surface;
116     }
117    
118     void MG_FACE::get_topologie_sousjacente(TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> *lst)
119     {
120     int nb=lst_boucle.size();
121     for (int i=0;i<nb;i++)
122     {
123     MG_BOUCLE* bou=lst_boucle[i];
124     int nb2=bou->get_nb_mg_coarete();
125     for (int j=0;j<nb2;j++)
126     {
127     MG_ARETE* are=bou->get_mg_coarete(j)->get_arete();
128     lst->ajouter(are);
129     are->get_topologie_sousjacente(lst);
130     }
131     }
132     }
133    
134     int MG_FACE::get_dimension(void)
135     {
136     return 2;
137     }
138    
139     int MG_FACE::get_orientation(void)
140     {
141     return orientation;
142     }
143    
144     int MG_FACE::valide_parametre_u(double& u)
145     {
146     if (surface->est_periodique_u()) return 1;
147     double param=u;
148     if (orientation!=MEME_SENS) param=surface->get_umin()+surface->get_umax()-param;
149     double param_min,param_max;
150     param_min=surface->get_umin();
151     param_max=surface->get_umax();
152     if (param<param_min)
153     {
154     u=param_min;
155     if (orientation!=MEME_SENS) u=surface->get_umin()+surface->get_umax()-u;
156     return 0;
157     }
158     if (param>param_max)
159     {
160     u=param_max;
161     if (orientation!=MEME_SENS) u=surface->get_umin()+surface->get_umax()-u;
162     return 0;
163     }
164     return 1;
165     }
166     int MG_FACE::valide_parametre_v(double& v)
167     {
168     if (surface->est_periodique_v()) return 1;
169     double param=v;
170     double param_min,param_max;
171     param_min=surface->get_vmin();
172     param_max=surface->get_vmax();
173     if (param<param_min)
174     {
175     v=param_min;
176     return 0;
177     }
178     if (param>param_max)
179     {
180     v=param_max;
181     return 0;
182     }
183     return 1;
184     }
185    
186     void MG_FACE::evaluer(double *uv,double *xyz)
187     {
188     double param[2]={uv[0],uv[1]};
189     if (orientation!=MEME_SENS) param[0]=surface->get_umin()+surface->get_umax()-param[0];
190     surface->evaluer(param,xyz);
191     }
192    
193     void MG_FACE::deriver(double *uv,double *xyzdu, double *xyzdv)
194     {
195     double param[2]={uv[0],uv[1]};
196     if (orientation!=MEME_SENS) param[0]=surface->get_umin()+surface->get_umax()-param[0];
197     surface->deriver(param,xyzdu,xyzdv);
198     if (orientation!=MEME_SENS)
199     {
200     xyzdu[0]=-xyzdu[0];
201     xyzdu[1]=-xyzdu[1];
202     xyzdu[2]=-xyzdu[2];
203     }
204     }
205    
206     void MG_FACE::deriver_seconde(double *uv,double* xyzduu,double* xyzduv,double* xyzdvv,double *xyz , double *xyzdu, double *xyzdv)
207     {
208     double param[2]={uv[0],uv[1]};
209     if (orientation!=MEME_SENS) param[0]=surface->get_umin()+surface->get_umax()-param[0];
210     surface->deriver_seconde(param,xyzduu,xyzduv,xyzdvv,xyz,xyzdu,xyzdv);
211     if (orientation!=MEME_SENS)
212     {
213     xyzdu[0]=-xyzdu[0];
214     xyzdu[1]=-xyzdu[1];
215     xyzdu[2]=-xyzdu[2];
216     xyzduv[0]=-xyzduv[0];
217     xyzduv[1]=-xyzduv[1];
218     xyzduv[2]=-xyzduv[2];
219     }
220     }
221    
222     void MG_FACE::inverser(double *uv,double *xyz,double precision)
223     {
224     surface->inverser(uv,xyz,precision);
225     if (orientation!=MEME_SENS) uv[0]=surface->get_umin()+surface->get_umax()-uv[0];
226     }
227    
228     void MG_FACE::calcul_normale(double *uv,double *normale)
229     {
230     double xyzdu[3];
231     double xyzdv[3];
232    
233     deriver(uv,xyzdu,xyzdv);
234     OT_VECTEUR_3D xu(xyzdu);
235     OT_VECTEUR_3D xv(xyzdv);
236     OT_VECTEUR_3D n=xu&xv;
237     normale[0]=n.get_x();
238     normale[1]=n.get_y();
239     normale[2]=n.get_z();
240     }
241    
242     void MG_FACE::calcul_normale_unitaire(double *uv,double *normale)
243     {
244     double xyzdu[3];
245     double xyzdv[3];
246    
247     deriver(uv,xyzdu,xyzdv);
248     OT_VECTEUR_3D xu(xyzdu);
249     OT_VECTEUR_3D xv(xyzdv);
250     OT_VECTEUR_3D n=xu&xv;
251     n.norme();
252     normale[0]=n.get_x();
253     normale[1]=n.get_y();
254     normale[2]=n.get_z();
255     }
256    
257    
258     void MG_FACE::get_EFG(double *uv,double& E,double& F,double& G)
259     {
260     double xyzdu[3];
261     double xyzdv[3];
262     deriver(uv,xyzdu,xyzdv);
263     E=xyzdu[0]*xyzdu[0]+xyzdu[1]*xyzdu[1]+xyzdu[2]*xyzdu[2];
264     F=xyzdu[0]*xyzdv[0]+xyzdu[1]*xyzdv[1]+xyzdu[2]*xyzdv[2];
265     G=xyzdv[0]*xyzdv[0]+xyzdv[1]*xyzdv[1]+xyzdv[2]*xyzdv[2];
266     }
267    
268     void MG_FACE::get_M(double *uv,double& M1,double& M2,double& M3)
269     {
270     double E,F,G;
271     double xyz[3],xyzdu[3],xyzdv[3],xyzduu[3],xyzduv[3],xyzdvv[3];
272    
273     deriver_seconde(uv,xyzduu,xyzduv,xyzdvv,xyz,xyzdu,xyzdv);
274     E=xyzdu[0]*xyzdu[0]+xyzdu[1]*xyzdu[1]+xyzdu[2]*xyzdu[2];
275     //F=xyzdu[0]*xyzdv[0]+xyzdu[1]*xyzdv[1]+xyzdu[2]*xyzdv[2];
276     G=xyzdv[0]*xyzdv[0]+xyzdv[1]*xyzdv[1]+xyzdv[2]*xyzdv[2];
277     double Edu=2.*(xyzdu[0]*xyzduu[0]+xyzdu[1]*xyzduu[1]+xyzdu[2]*xyzduu[2]);
278     double Gdv=2.*(xyzdv[0]*xyzdvv[0]+xyzdv[1]*xyzdvv[1]+xyzdv[2]*xyzdvv[2]);
279     double Edv=2.*(xyzdu[0]*xyzduv[0]+xyzdu[1]*xyzduv[1]+xyzdu[2]*xyzduv[2]);
280     double Gdu=2.*(xyzdv[0]*xyzduv[0]+xyzdv[1]*xyzduv[1]+xyzdv[2]*xyzduv[2]);
281     double m1[3],m2[3],m3[3];
282     m1[0]=xyzduu[0]/E-0.5*Edu*xyzdu[0]/E/E;
283     m1[1]=xyzduu[1]/E-0.5*Edu*xyzdu[1]/E/E;
284     m1[2]=xyzduu[2]/E-0.5*Edu*xyzdu[2]/E/E;
285     m2[0]=xyzduv[0]/sqrt(E*G)-0.5*xyzdu[0]*Edv/E/sqrt(E*G)-0.5*xyzdv[0]*Gdu/G/sqrt(E*G);
286     m2[1]=xyzduv[1]/sqrt(E*G)-0.5*xyzdu[1]*Edv/E/sqrt(E*G)-0.5*xyzdv[1]*Gdu/G/sqrt(E*G);
287     m2[2]=xyzduv[2]/sqrt(E*G)-0.5*xyzdu[2]*Edv/E/sqrt(E*G)-0.5*xyzdv[2]*Gdu/G/sqrt(E*G);
288     m3[0]=xyzdvv[0]/G-0.5*Gdv*xyzdv[0]/G/G;
289     m3[1]=xyzdvv[1]/G-0.5*Gdv*xyzdv[1]/G/G;
290     m3[2]=xyzdvv[2]/G-0.5*Gdv*xyzdv[2]/G/G;
291     M1=sqrt(m1[0]*m1[0]+m1[1]*m1[1]+m1[2]*m1[2]);
292     M2=sqrt(m2[0]*m2[0]+m2[1]*m2[1]+m2[2]*m2[2]);
293     M3=sqrt(m3[0]*m3[0]+m3[1]*m3[1]+m3[2]*m3[2]);
294     }
295    
296     void MG_FACE::get_LMN(double *uv,double& L,double& M,double &N)
297     {
298    
299     double xyz[3],xyzdu[3],xyzdv[3],xyzduu[3],xyzduv[3],xyzdvv[3],normal[3];
300     deriver_seconde(uv,xyzduu,xyzduv,xyzdvv,xyz,xyzdu,xyzdv);
301     calcul_normale_unitaire(uv,normal);
302     L=xyzduu[0]*normal[0]+xyzduu[1]*normal[1]+xyzduu[2]*normal[2];
303     M=xyzduv[0]*normal[0]+xyzduv[1]*normal[1]+xyzduv[2]*normal[2];
304     N=xyzdvv[0]*normal[0]+xyzdvv[1]*normal[1]+xyzdvv[2]*normal[2];
305     }
306    
307    
308     void MG_FACE::get_courbure(double *uv,double& cmax,double& cmin)
309     {
310     double E,F,G,L,M,N;
311     get_EFG(uv,E,F,G);
312     get_LMN(uv,L,M,N);
313     double a=E*G-F*F;
314     double b=-E*N-G*L+2*F*M;
315     double c=L*N-M*M;
316     double delta=b*b-4*a*c;
317     if (delta<0.00000001) delta=0.;
318     double x1=(-b+sqrt(delta))/2./a;
319     double x2=(-b-sqrt(delta))/2./a;
320     if (fabs(x1)>fabs(x2)) {
321     cmax=x1;
322     cmin=x2;
323     } else {
324     cmax=x2;
325     cmin=x1;
326     }
327     }
328    
329     VCT& MG_FACE::get_vectorisation(void)
330     {
331     if (vect==NULL) vect=new VCT_FACE(this);
332     return *vect;
333     }
334    
335     void MG_FACE::enregistrer(std::ostream& o)
336     {
337     o << "%" << get_id() << "=FACE("<< get_idoriginal() << ",$" << surface->get_id() << ",(";
338     for (unsigned int i=0;i<lst_boucle.size();i++)
339     {
340     o << "$" << lst_boucle[i]->get_id();
341     if (i!=lst_boucle.size()-1) o << ",";
342     else o << ")";
343     }
344     int nb=get_nb_ccf();
345     o << "," << orientation << "," << nb;
346     if (nb!=0)
347     {
348     o << ",(";
349     for (int i=0;i<nb;i++)
350     {
351     char nom[3];
352     get_type_ccf(i,nom);
353     o << "(" << nom << "," << get_valeur_ccf(i) << ")";
354     if (i!=nb-1) o << "," ;
355     }
356     o << ")";
357     }
358     o << ");" << std::endl;
359     }
360    
361