ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/mg_hexa.cpp
Revision: 663
Committed: Fri Apr 10 20:13:11 2015 UTC (10 years, 1 month ago) by francois
File size: 14718 byte(s)
Log Message:
resolution de bug de desallocation + resolution du mailleur bloc avec optimisateur de coin active

File Contents

# User Rev Content
1 francois 308 //------------------------------------------------------------
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_hexa.cpp
16     //
17     //------------------------------------------------------------
18     //------------------------------------------------------------
19     // COPYRIGHT 2000
20     // Version du 02/03/2006 � 11H22
21     //------------------------------------------------------------
22     //------------------------------------------------------------
23    
24    
25     #include "gestionversion.h"
26 francois 311 #include "mg_hexa.h"
27 francois 308 #include "mg_maillage.h"
28    
29     MG_HEXA::MG_HEXA(unsigned long num,MG_ELEMENT_TOPOLOGIQUE* topo,class MG_NOEUD *mgnoeud1,class MG_NOEUD *mgnoeud2,class MG_NOEUD *mgnoeud3,class MG_NOEUD *mgnoeud4,class MG_NOEUD *mgnoeud5,class MG_NOEUD *mgnoeud6,class MG_NOEUD *mgnoeud7,class MG_NOEUD *mgnoeud8,class MG_QUADRANGLE* mgquadrangle1,class MG_QUADRANGLE* mgquadrangle2,class MG_QUADRANGLE* mgquadrangle3,class MG_QUADRANGLE* mgquadrangle4,class MG_QUADRANGLE* mgquadrangle5,class MG_QUADRANGLE* mgquadrangle6,int origine):MG_ELEMENT_MAILLAGE(num,topo,origine),noeud1(mgnoeud1),noeud2(mgnoeud2),noeud3(mgnoeud3),noeud4(mgnoeud4),noeud5(mgnoeud5),noeud6(mgnoeud6),noeud7(mgnoeud7),noeud8(mgnoeud8),quadrangle1(mgquadrangle1),quadrangle2(mgquadrangle2),quadrangle3(mgquadrangle3),quadrangle4(mgquadrangle4),quadrangle5(mgquadrangle5),quadrangle6(mgquadrangle6)
30     {
31     init_hexa();
32     }
33    
34     MG_HEXA::MG_HEXA(MG_ELEMENT_TOPOLOGIQUE* topo,class MG_NOEUD *mgnoeud1,class MG_NOEUD *mgnoeud2,class MG_NOEUD *mgnoeud3,class MG_NOEUD *mgnoeud4,class MG_NOEUD *mgnoeud5,class MG_NOEUD *mgnoeud6,class MG_NOEUD *mgnoeud7,class MG_NOEUD *mgnoeud8,class MG_QUADRANGLE* mgquadrangle1,class MG_QUADRANGLE* mgquadrangle2,class MG_QUADRANGLE* mgquadrangle3,class MG_QUADRANGLE* mgquadrangle4,class MG_QUADRANGLE* mgquadrangle5,class MG_QUADRANGLE* mgquadrangle6,int origine):MG_ELEMENT_MAILLAGE(topo,origine),noeud1(mgnoeud1),noeud2(mgnoeud2),noeud3(mgnoeud3),noeud4(mgnoeud4),noeud5(mgnoeud5),noeud6(mgnoeud6),noeud7(mgnoeud7),noeud8(mgnoeud8),quadrangle1(mgquadrangle1),quadrangle2(mgquadrangle2),quadrangle3(mgquadrangle3),quadrangle4(mgquadrangle4),quadrangle5(mgquadrangle5),quadrangle6(mgquadrangle6)
35     {
36     init_hexa();
37     }
38    
39    
40     MG_HEXA::MG_HEXA(MG_HEXA& mdd):MG_ELEMENT_MAILLAGE(mdd),noeud1(mdd.noeud1),noeud2(mdd.noeud2),noeud3(mdd.noeud3),noeud4(mdd.noeud4),noeud5(mdd.noeud5),noeud6(mdd.noeud6),noeud7(mdd.noeud7),noeud8(mdd.noeud8),quadrangle1(mdd.quadrangle1),quadrangle2(mdd.quadrangle2),quadrangle3(mdd.quadrangle3),quadrangle4(mdd.quadrangle4),quadrangle5(mdd.quadrangle5),quadrangle6(mdd.quadrangle6)
41     {
42     init_hexa();
43     }
44    
45    
46     MG_HEXA* MG_HEXA::dupliquer(MG_MAILLAGE *mgmai,long decalage)
47     {
48     MG_NOEUD* nd1=mgmai->get_mg_noeudid(noeud1->get_id()+decalage);
49     MG_NOEUD* nd2=mgmai->get_mg_noeudid(noeud2->get_id()+decalage);
50     MG_NOEUD* nd3=mgmai->get_mg_noeudid(noeud3->get_id()+decalage);
51     MG_NOEUD* nd4=mgmai->get_mg_noeudid(noeud4->get_id()+decalage);
52     MG_NOEUD* nd5=mgmai->get_mg_noeudid(noeud5->get_id()+decalage);
53     MG_NOEUD* nd6=mgmai->get_mg_noeudid(noeud6->get_id()+decalage);
54     MG_NOEUD* nd7=mgmai->get_mg_noeudid(noeud7->get_id()+decalage);
55     MG_NOEUD* nd8=mgmai->get_mg_noeudid(noeud8->get_id()+decalage);
56     MG_QUADRANGLE* quad1=mgmai->get_mg_quadrangleid(quadrangle1->get_id()+decalage);
57     MG_QUADRANGLE* quad2=mgmai->get_mg_quadrangleid(quadrangle2->get_id()+decalage);
58     MG_QUADRANGLE* quad3=mgmai->get_mg_quadrangleid(quadrangle3->get_id()+decalage);
59     MG_QUADRANGLE* quad4=mgmai->get_mg_quadrangleid(quadrangle4->get_id()+decalage);
60     MG_QUADRANGLE* quad5=mgmai->get_mg_quadrangleid(quadrangle5->get_id()+decalage);
61     MG_QUADRANGLE* quad6=mgmai->get_mg_quadrangleid(quadrangle6->get_id()+decalage);
62     MG_HEXA* hex=new MG_HEXA(this->get_id()+decalage,liaison_topologique,nd1,nd2,nd3,nd4,nd5,nd6,nd7,nd8,quad1,quad2,quad3,quad4,quad5,quad6,DUPLIQUER);
63     mgmai->ajouter_mg_hexa(hex);
64     return hex;
65     }
66    
67     MG_HEXA::~MG_HEXA()
68     {
69     if (noeud1!=NULL) noeud1->get_lien_hexa()->supprimer(this);
70     if (noeud2!=NULL) noeud2->get_lien_hexa()->supprimer(this);
71     if (noeud3!=NULL) noeud3->get_lien_hexa()->supprimer(this);
72     if (noeud4!=NULL) noeud4->get_lien_hexa()->supprimer(this);
73     if (noeud5!=NULL) noeud5->get_lien_hexa()->supprimer(this);
74     if (noeud6!=NULL) noeud6->get_lien_hexa()->supprimer(this);
75     if (noeud7!=NULL) noeud7->get_lien_hexa()->supprimer(this);
76     if (noeud8!=NULL) noeud8->get_lien_hexa()->supprimer(this);
77     unsigned long noeudminid=std::min(noeud1->get_id(),noeud2->get_id());
78     noeudminid=std::min(noeudminid,noeud3->get_id());
79     noeudminid=std::min(noeudminid,noeud4->get_id());
80     noeudminid=std::min(noeudminid,noeud5->get_id());
81     noeudminid=std::min(noeudminid,noeud6->get_id());
82     noeudminid=std::min(noeudminid,noeud7->get_id());
83     noeudminid=std::min(noeudminid,noeud8->get_id());
84     if (noeud1!=NULL)
85     if (noeud1->get_id()==noeudminid) noeud1->get_lien_petit_hexa()->supprimer(this);
86     if (noeud2!=NULL)
87     if (noeud2->get_id()==noeudminid) noeud2->get_lien_petit_hexa()->supprimer(this);
88     if (noeud3!=NULL)
89     if (noeud3->get_id()==noeudminid) noeud3->get_lien_petit_hexa()->supprimer(this);
90     if (noeud4!=NULL)
91     if (noeud4->get_id()==noeudminid) noeud4->get_lien_petit_hexa()->supprimer(this);
92     if (noeud5!=NULL)
93     if (noeud5->get_id()==noeudminid) noeud5->get_lien_petit_hexa()->supprimer(this);
94     if (noeud6!=NULL)
95     if (noeud6->get_id()==noeudminid) noeud6->get_lien_petit_hexa()->supprimer(this);
96     if (noeud7!=NULL)
97     if (noeud7->get_id()==noeudminid) noeud7->get_lien_petit_hexa()->supprimer(this);
98     if (noeud8!=NULL)
99     if (noeud8->get_id()==noeudminid) noeud8->get_lien_petit_hexa()->supprimer(this);
100     if (quadrangle1!=NULL) {
101     quadrangle1->decrementer();
102     quadrangle1->get_lien_hexa()->supprimer(this);
103     }
104     if (quadrangle2!=NULL) {
105     quadrangle2->decrementer();
106     quadrangle2->get_lien_hexa()->supprimer(this);
107     }
108     if (quadrangle3!=NULL) {
109     quadrangle3->decrementer();
110     quadrangle3->get_lien_hexa()->supprimer(this);
111     }
112     if (quadrangle4!=NULL) {
113     quadrangle4->decrementer();
114     quadrangle4->get_lien_hexa()->supprimer(this);
115     }
116     if (quadrangle5!=NULL) {
117     quadrangle5->decrementer();
118     quadrangle5->get_lien_hexa()->supprimer(this);
119     }
120     if (quadrangle6!=NULL) {
121     quadrangle6->decrementer();
122     quadrangle6->get_lien_hexa()->supprimer(this);
123     }
124 francois 663 if (liaison_topologique!=NULL)
125     if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_maillage()->supprimer(this);
126 francois 308 }
127    
128     void MG_HEXA::init_hexa(void)
129     {
130     if (noeud1!=NULL) noeud1->get_lien_hexa()->ajouter(this);
131     if (noeud2!=NULL) noeud2->get_lien_hexa()->ajouter(this);
132     if (noeud3!=NULL) noeud3->get_lien_hexa()->ajouter(this);
133     if (noeud4!=NULL) noeud4->get_lien_hexa()->ajouter(this);
134     if (noeud5!=NULL) noeud5->get_lien_hexa()->ajouter(this);
135     if (noeud6!=NULL) noeud6->get_lien_hexa()->ajouter(this);
136     if (noeud7!=NULL) noeud7->get_lien_hexa()->ajouter(this);
137     if (noeud8!=NULL) noeud8->get_lien_hexa()->ajouter(this);
138     unsigned long noeudminid=std::min(noeud1->get_id(),noeud2->get_id());
139     noeudminid=std::min(noeudminid,noeud3->get_id());
140     noeudminid=std::min(noeudminid,noeud4->get_id());
141     noeudminid=std::min(noeudminid,noeud5->get_id());
142     noeudminid=std::min(noeudminid,noeud6->get_id());
143     noeudminid=std::min(noeudminid,noeud7->get_id());
144     noeudminid=std::min(noeudminid,noeud8->get_id());
145     if (noeud1!=NULL)
146     if (noeud1->get_id()==noeudminid) noeud1->get_lien_petit_hexa()->ajouter(this);
147     if (noeud2!=NULL)
148     if (noeud2->get_id()==noeudminid) noeud2->get_lien_petit_hexa()->ajouter(this);
149     if (noeud3!=NULL)
150     if (noeud3->get_id()==noeudminid) noeud3->get_lien_petit_hexa()->ajouter(this);
151     if (noeud4!=NULL)
152     if (noeud4->get_id()==noeudminid) noeud4->get_lien_petit_hexa()->ajouter(this);
153     if (noeud5!=NULL)
154     if (noeud5->get_id()==noeudminid) noeud5->get_lien_petit_hexa()->ajouter(this);
155     if (noeud6!=NULL)
156     if (noeud6->get_id()==noeudminid) noeud6->get_lien_petit_hexa()->ajouter(this);
157     if (noeud7!=NULL)
158     if (noeud7->get_id()==noeudminid) noeud7->get_lien_petit_hexa()->ajouter(this);
159     if (noeud8!=NULL)
160     if (noeud8->get_id()==noeudminid) noeud8->get_lien_petit_hexa()->ajouter(this);
161     if (quadrangle1!=NULL) {
162     quadrangle1->incrementer();
163     quadrangle1->get_lien_hexa()->ajouter(this);
164     }
165     if (quadrangle2!=NULL) {
166     quadrangle2->incrementer();
167     quadrangle2->get_lien_hexa()->ajouter(this);
168     }
169     if (quadrangle3!=NULL) {
170     quadrangle3->incrementer();
171     quadrangle3->get_lien_hexa()->ajouter(this);
172     }
173     if (quadrangle4!=NULL) {
174     quadrangle4->incrementer();
175     quadrangle4->get_lien_hexa()->ajouter(this);
176     }
177     if (quadrangle5!=NULL) {
178     quadrangle5->incrementer();
179     quadrangle5->get_lien_hexa()->ajouter(this);
180     }
181     if (quadrangle6!=NULL) {
182     quadrangle6->incrementer();
183     quadrangle6->get_lien_hexa()->ajouter(this);
184     }
185    
186     if (liaison_topologique==NULL) return;
187     if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_maillage()->ajouter(this);
188     }
189    
190    
191     int MG_HEXA::get_type_entite(void)
192     {
193     return IDMG_HEXA;
194     }
195    
196    
197    
198    
199    
200     MG_NOEUD* MG_HEXA::get_noeud1(void)
201     {
202     return noeud1;
203     }
204    
205     MG_NOEUD* MG_HEXA::get_noeud2(void)
206     {
207     return noeud2;
208     }
209    
210     MG_NOEUD* MG_HEXA::get_noeud3(void)
211     {
212     return noeud3;
213     }
214    
215     MG_NOEUD* MG_HEXA::get_noeud4(void)
216     {
217     return noeud4;
218     }
219     MG_NOEUD* MG_HEXA::get_noeud5(void)
220     {
221     return noeud5;
222     }
223     MG_NOEUD* MG_HEXA::get_noeud6(void)
224     {
225     return noeud6;
226     }
227     MG_NOEUD* MG_HEXA::get_noeud7(void)
228     {
229     return noeud7;
230     }
231     MG_NOEUD* MG_HEXA::get_noeud8(void)
232     {
233     return noeud8;
234     }
235    
236     MG_QUADRANGLE* MG_HEXA::get_quadrangle1(void)
237     {
238     return quadrangle1;
239     }
240    
241     MG_QUADRANGLE* MG_HEXA::get_quadrangle2(void)
242     {
243     return quadrangle2;
244     }
245    
246     MG_QUADRANGLE* MG_HEXA::get_quadrangle3(void)
247     {
248     return quadrangle3;
249     }
250    
251     MG_QUADRANGLE* MG_HEXA::get_quadrangle4(void)
252     {
253     return quadrangle4;
254     }
255    
256     MG_QUADRANGLE* MG_HEXA::get_quadrangle5(void)
257     {
258     return quadrangle5;
259     }
260    
261     MG_QUADRANGLE* MG_HEXA::get_quadrangle6(void)
262     {
263     return quadrangle6;
264     }
265    
266    
267     int MG_HEXA::get_dimension(void)
268     {
269     return 3;
270     }
271    
272    
273     BOITE_3D MG_HEXA::get_boite_3D(void)
274     {
275     double coo1[3];
276     double coo2[3];
277     double coo3[3];
278     double coo4[3];
279     double coo5[3];
280     double coo6[3];
281     double coo7[3];
282     double coo8[3];
283     coo1[0]=noeud1->get_x();
284     coo1[1]=noeud1->get_y();
285     coo1[2]=noeud1->get_z();
286     coo2[0]=noeud2->get_x();
287     coo2[1]=noeud2->get_y();
288     coo2[2]=noeud2->get_z();
289     coo3[0]=noeud3->get_x();
290     coo3[1]=noeud3->get_y();
291     coo3[2]=noeud3->get_z();
292     coo4[0]=noeud4->get_x();
293     coo4[1]=noeud4->get_y();
294     coo4[2]=noeud4->get_z();
295     coo5[0]=noeud5->get_x();
296     coo5[1]=noeud5->get_y();
297     coo5[2]=noeud5->get_z();
298     coo6[0]=noeud6->get_x();
299     coo6[1]=noeud6->get_y();
300     coo6[2]=noeud6->get_z();
301     coo7[0]=noeud7->get_x();
302     coo7[1]=noeud7->get_y();
303     coo7[2]=noeud7->get_z();
304     coo8[0]=noeud8->get_x();
305     coo8[1]=noeud8->get_y();
306     coo8[2]=noeud8->get_z();
307     double xmin,ymin,zmin,xmax,ymax,zmax;
308     xmin=std::min(coo1[0],coo2[0]);
309     xmin=std::min(xmin,coo3[0]);
310     xmin=std::min(xmin,coo4[0]);
311     xmin=std::min(xmin,coo5[0]);
312     xmin=std::min(xmin,coo6[0]);
313     xmin=std::min(xmin,coo7[0]);
314     xmin=std::min(xmin,coo8[0]);
315     xmax=std::max(coo1[0],coo2[0]);
316     xmax=std::max(xmax,coo3[0]);
317     xmax=std::max(xmax,coo4[0]);
318     xmax=std::max(xmax,coo5[0]);
319     xmax=std::max(xmax,coo6[0]);
320     xmax=std::max(xmax,coo7[0]);
321     xmax=std::max(xmax,coo8[0]);
322     ymin=std::min(coo1[1],coo2[1]);
323     ymin=std::min(ymin,coo3[1]);
324     ymin=std::min(ymin,coo4[1]);
325     ymin=std::min(ymin,coo5[1]);
326     ymin=std::min(ymin,coo6[1]);
327     ymin=std::min(ymin,coo7[1]);
328     ymin=std::min(ymin,coo8[1]);
329     ymax=std::max(coo1[1],coo2[1]);
330     ymax=std::max(ymax,coo3[1]);
331     ymax=std::max(ymax,coo4[1]);
332     ymax=std::max(ymax,coo5[1]);
333     ymax=std::max(ymax,coo6[1]);
334     ymax=std::max(ymax,coo7[1]);
335     ymax=std::max(ymax,coo8[1]);
336     zmin=std::min(coo1[2],coo2[2]);
337     zmin=std::min(zmin,coo3[2]);
338     zmin=std::min(zmin,coo4[2]);
339     zmin=std::min(zmin,coo5[2]);
340     zmin=std::min(zmin,coo6[2]);
341     zmin=std::min(zmin,coo7[2]);
342     zmin=std::min(zmin,coo8[2]);
343     zmax=std::max(coo1[2],coo2[2]);
344     zmax=std::max(zmax,coo3[2]);
345     zmax=std::max(zmax,coo4[2]);
346     zmax=std::max(zmax,coo5[2]);
347     zmax=std::max(zmax,coo6[2]);
348     zmax=std::max(zmax,coo7[2]);
349     zmax=std::max(zmax,coo8[2]);
350     BOITE_3D boite(xmin,ymin,zmin,xmax,ymax,zmax);
351     return boite;
352     }
353     void MG_HEXA::extrapoler_solution_noeud(void)
354     {
355 francois 377 for (int j=0;j<MAX_TYPE_SOLUTION;j++)
356     {
357     noeud1->change_solution(solution[j],j);
358     noeud2->change_solution(solution[j],j);
359     noeud3->change_solution(solution[j],j);
360     noeud4->change_solution(solution[j],j);
361     noeud5->change_solution(solution[j],j);
362     noeud6->change_solution(solution[j],j);
363     noeud7->change_solution(solution[j],j);
364     noeud8->change_solution(solution[j],j);
365     }
366 francois 308 }
367    
368     void MG_HEXA::enregistrer(std::ostream& o)
369     {
370     if ((liaison_topologique==NULL) && (MG_MAILLAGE::DIMENSIONMAILLAGESANSTOPO!=3)) return;
371     if (liaison_topologique==NULL) o << "%" << get_id() << "=HEXAEDRE(NULL,$" << noeud1->get_id() << ",$" << noeud2->get_id() << ",$" << noeud3->get_id() << ",$" << noeud4->get_id() << ",$" << noeud5->get_id() << ",$" << noeud6->get_id() << ",$" << noeud7->get_id() << ",$" << noeud8->get_id() << "," << origine_creation << ");" << std::endl;
372     else if (liaison_topologique->get_dimension()==3) o << "%" << get_id() << "=HEXAEDRE($"<< get_lien_topologie()->get_id() << ",$" << noeud1->get_id() << ",$" << noeud2->get_id() << ",$" << noeud3->get_id() << ",$" << noeud4->get_id() << ",$" <<noeud5->get_id() << ",$" << noeud6->get_id() << ",$" << noeud7->get_id() << ",$" << noeud8->get_id() << "," << origine_creation << ");" << std::endl;
373     }
374    
375    
376    
377    
378    
379