1 |
francois |
283 |
//#include "gestionversion.h" |
2 |
|
|
#include <stdio.h> |
3 |
|
|
#include <string.h> |
4 |
|
|
#include <stdlib.h> |
5 |
|
|
#include "m3d_const.h" |
6 |
|
|
#include "m3d_struct.h" |
7 |
|
|
#include "m3d_hotes.h" |
8 |
|
|
#include "m3d_erreur.h" |
9 |
|
|
#include "m3d_message.h" |
10 |
|
|
#include "prototype.h" |
11 |
|
|
#include "diamesh.h" |
12 |
|
|
/*protection */ |
13 |
|
|
char application[8],mess[255]; |
14 |
|
|
int compteur = 0 ; |
15 |
|
|
int nb_lettres; |
16 |
|
|
char *SYSMESH_DIR ; |
17 |
|
|
char *num_version ; |
18 |
|
|
GEST_MEM *gest ; /* parametres a passer entre routines */ |
19 |
|
|
int nb_tetra_cree= 0 ; /* nombre de tetraedres crees lors du maillage */ |
20 |
|
|
|
21 |
|
|
/* prise en compte des parametres de lancement */ |
22 |
|
|
int istop = 0 ; |
23 |
|
|
int lissage = 1 ; |
24 |
|
|
int recover = 0 ; |
25 |
|
|
int remesh = 0 ; |
26 |
|
|
int save = 0 ; |
27 |
|
|
int debug = 0 ; /* le passer a 1 pour debugger */ |
28 |
|
|
int is_best = 0 ; /* 1 : lissage plus couteux */ |
29 |
|
|
int format = ACSIS ; /* type de fichier charge en memoire */ |
30 |
|
|
int sortie = ACSIS ; |
31 |
|
|
int adap = DMOYEN;/* maillage adaptatif moyen */ |
32 |
|
|
float biais = 0. ; /* critere de biais */ |
33 |
|
|
float crit_min = 0.1 ; /* critere minimum */ |
34 |
|
|
float raf = 2. ; /* critere raf */ |
35 |
|
|
float elan = 10. ; /* critere elan */ |
36 |
|
|
int nb_max_noe = 10000 ; /* nombre arbitraire de noeuds traitables */ |
37 |
|
|
int nb_max_ele = 50000 ; /* nombre arbitraire d'elements */ |
38 |
|
|
float dimp = 10000.;/* dim de l'espace de maillage */ |
39 |
|
|
int result = 1 ; |
40 |
|
|
/* statistiques sur le maillage */ |
41 |
|
|
long cpu_avant = 0. ; /* initialisation du temps cpu */ |
42 |
|
|
float crit_min_calc ; /* critere mini calcule sur les mailles */ |
43 |
|
|
float crit_moy_calc ; /* critere moyen calcule sur les mailles */ |
44 |
|
|
float crit_max_calc ; /* critere maxi calcule sur les mailles */ |
45 |
|
|
float crit_e_mini = 0. ; /* ecart autour du critere mini */ |
46 |
|
|
float crit_e_moyen= 0. ; /* ecart autour du critere moyen */ |
47 |
|
|
float crit_e_maxi = 0. ; /* ecart autour du critere maxi */ |
48 |
|
|
int check = 0 ; |
49 |
|
|
int nb_inter = 0 ; |
50 |
|
|
int nb_no_inter = 0 ; |
51 |
|
|
float tab_vn[5][3] ; |
52 |
|
|
int tab_plan[4] ; |
53 |
|
|
int iter = 1 ; |
54 |
|
|
int skin = 0 ; |
55 |
|
|
int is_recover = 0 ; |
56 |
|
|
int nb_recover = 0 ; |
57 |
|
|
int show = 0 ; |
58 |
|
|
int is_ext = 0 ; |
59 |
|
|
int para=0; |
60 |
|
|
float eps, eps2, eps3, eps4 ; |
61 |
|
|
char ext_out[MAX_LINE] ; |
62 |
|
|
|
63 |
|
|
int diamesh(int argc,char argv[][100]) |
64 |
|
|
{ |
65 |
|
|
//voir(); |
66 |
|
|
/*------------------ |
67 |
|
|
* variables privees |
68 |
|
|
*------------------*/ |
69 |
|
|
|
70 |
|
|
int i = 0; |
71 |
|
|
int is_fich = 0 ; |
72 |
|
|
int is_format = 0 ; |
73 |
|
|
int is_output = 0 ; |
74 |
|
|
int nb_iter = 0 ; |
75 |
|
|
float crit_min_tmp; |
76 |
|
|
char filename[256], choice[256] ; |
77 |
|
|
|
78 |
|
|
num_version = (char*) malloc(10); |
79 |
|
|
sprintf( num_version, "%d.%d", VERSION, SOUSVERSION); |
80 |
|
|
|
81 |
|
|
ext_out[0] = 0 ; |
82 |
|
|
/* Recuperation des parametres de lancements */ |
83 |
|
|
while (i < argc) |
84 |
|
|
{ |
85 |
|
|
if (strcmp ( argv[i], "-rax" ) == 0) debug = 1; |
86 |
|
|
if (strcmp ( argv[i], "-show" ) == 0) show = 1; |
87 |
|
|
if (strcmp ( argv[i], "-recover" ) == 0) recover = 1; |
88 |
|
|
if (strcmp ( argv[i], "-para" ) == 0) { |
89 |
|
|
recover=1; |
90 |
|
|
para=1; |
91 |
|
|
} |
92 |
|
|
if (strcmp ( argv[i], "-remesh" ) == 0) { |
93 |
|
|
remesh=1; |
94 |
|
|
} |
95 |
|
|
if (strcmp ( argv[i], "-batch" ) == 0) remesh=1; |
96 |
|
|
if (strcmp ( argv[i], "-save" ) == 0) save = 1; |
97 |
|
|
if (strcmp ( argv[i], "-skin" ) == 0) skin = 1; |
98 |
|
|
if (strcmp ( argv[i], "-noiter" ) == 0) iter = 0 ; |
99 |
|
|
if (strcmp ( argv[i], "-noresult" ) == 0) result = FAUX ; |
100 |
|
|
if (strcmp ( argv[i], "-crit" ) == 0) crit_min = (float)atof(argv[i+1]) ; |
101 |
|
|
if (strcmp ( argv[i], "-raf" ) == 0) raf = (float)atof(argv[i+1]) ; |
102 |
|
|
if (strcmp ( argv[i], "-nosmooth" ) == 0) lissage = 0; |
103 |
|
|
if (strcmp ( argv[i], "-best" ) == 0) is_best = 1; |
104 |
|
|
if (strcmp ( argv[i], "-dim" ) == 0) dimp = (float)atof(argv[i+1]) ; |
105 |
|
|
if (strcmp ( argv[i], "-check" ) == 0) check = 1; |
106 |
|
|
|
107 |
|
|
if (strcmp ( argv[i], "-nb_node" ) == 0) |
108 |
|
|
{ |
109 |
|
|
nb_max_noe = atoi(argv[i+1]) ; |
110 |
|
|
nb_max_ele = 5 * nb_max_noe; |
111 |
|
|
} |
112 |
|
|
if (!is_ext) is_ext = !strcmp ( argv[i], "-ext" ); |
113 |
|
|
if (!is_format) is_format = !strcmp ( argv[i], "-input" ); |
114 |
|
|
if (!is_output) is_output = !strcmp ( argv[i], "-output" ); |
115 |
|
|
if (!is_fich) is_fich = !strcmp ( argv[i], "-file" ); |
116 |
|
|
i++; |
117 |
|
|
} |
118 |
|
|
/* nom du fichier */ |
119 |
|
|
if (is_fich) |
120 |
|
|
{ |
121 |
|
|
is_fich = FAUX ; |
122 |
|
|
i = 0 ; |
123 |
|
|
while ((!is_fich)&&(i<argc)) |
124 |
|
|
{ |
125 |
|
|
is_fich = !strcmp ( argv[i], "-file" ); |
126 |
|
|
if (is_fich) |
127 |
|
|
{ |
128 |
|
|
filename[0] = 0 ; |
129 |
|
|
strcpy(filename,argv[i+1]) ; |
130 |
|
|
} |
131 |
|
|
i ++ ; |
132 |
|
|
} |
133 |
|
|
} |
134 |
|
|
/* extension du fichier */ |
135 |
|
|
if (is_ext) |
136 |
|
|
{ |
137 |
|
|
is_ext = FAUX ; |
138 |
|
|
i = 0 ; |
139 |
|
|
while ((!is_ext)&&(i<argc)) |
140 |
|
|
{ |
141 |
|
|
is_ext = !strcmp ( argv[i], "-ext" ); |
142 |
|
|
if (is_ext) |
143 |
|
|
{ |
144 |
|
|
ext_out[0] = 0 ; |
145 |
|
|
strcpy(ext_out,argv[i+1]) ; |
146 |
|
|
} |
147 |
|
|
i ++ ; |
148 |
|
|
} |
149 |
|
|
} |
150 |
|
|
|
151 |
|
|
if (is_format) |
152 |
|
|
{ |
153 |
|
|
is_format = FAUX ; |
154 |
|
|
i = 0 ; |
155 |
|
|
while ((!is_format)&&(i<argc)) |
156 |
|
|
{ |
157 |
|
|
is_format = !strcmp ( argv[i], "-input" ) ; |
158 |
|
|
if (is_format) |
159 |
|
|
{ |
160 |
|
|
if (!strcmp ( argv[i+1], "mosaic" )) format = MOSAIC ; |
161 |
|
|
if (!strcmp ( argv[i+1], "systus" )) format = SYSTUS ; |
162 |
|
|
if (!strcmp ( argv[i+1], "starcd" )) format = STARCD ; |
163 |
|
|
if (!strcmp ( argv[i+1], "master" )) format = MASTER_SERIES ; |
164 |
|
|
if (!strcmp ( argv[i+1], "nastran" )) format = NASTRAN ; |
165 |
|
|
if (!strcmp ( argv[i+1], "ansys" )) format = ANSYS ; |
166 |
|
|
if (!strcmp ( argv[i+1], "ideas" )) format = SUPERTAB ; |
167 |
|
|
if (!strcmp ( argv[i+1], "acsis" )) sortie = ACSIS ; |
168 |
|
|
|
169 |
|
|
} |
170 |
|
|
i ++ ; |
171 |
|
|
} |
172 |
|
|
} |
173 |
|
|
if (is_output) |
174 |
|
|
{ |
175 |
|
|
is_output = FAUX ; |
176 |
|
|
i = 0 ; |
177 |
|
|
while ((!is_output)&&(i<argc)) |
178 |
|
|
{ |
179 |
|
|
is_output = !strcmp ( argv[i], "-output" ) ; |
180 |
|
|
if (is_output) |
181 |
|
|
{ |
182 |
|
|
if (!strcmp ( argv[i+1], "mosaic" )) sortie = MOSAIC ; |
183 |
|
|
if (!strcmp ( argv[i+1], "systus" )) sortie = SYSTUS ; |
184 |
|
|
if (!strcmp ( argv[i+1], "starcd" )) sortie = STARCD ; |
185 |
|
|
if (!strcmp ( argv[i+1], "master" )) sortie = MASTER_SERIES ; |
186 |
|
|
if (!strcmp ( argv[i+1], "nastran" )) sortie = NASTRAN ; |
187 |
|
|
if (!strcmp ( argv[i+1], "ansys" )) sortie = ANSYS ; |
188 |
|
|
if (!strcmp ( argv[i+1], "ideas" )) sortie = SUPERTAB ; |
189 |
|
|
if (!strcmp ( argv[i+1], "acsis" )) sortie = ACSIS ; |
190 |
|
|
|
191 |
|
|
} |
192 |
|
|
i ++ ; |
193 |
|
|
} |
194 |
|
|
} |
195 |
|
|
else sortie = format ; |
196 |
|
|
|
197 |
|
|
m3d_message(WELCOME) ; |
198 |
|
|
|
199 |
|
|
sprintf(mess,"%s %s\n",MESS_FICHIER,filename) ; |
200 |
|
|
// aff_text(mess); |
201 |
|
|
// aff_text("\n"); |
202 |
|
|
|
203 |
|
|
/* Prendre en compte la protection */ |
204 |
|
|
|
205 |
|
|
m3d_init() ; /* initialisation des structures de donnees */ |
206 |
|
|
/* lecture des donnees */ |
207 |
|
|
|
208 |
|
|
while (!gest->lecture_donnees) |
209 |
|
|
{ |
210 |
|
|
m3d_recu(filename) ; |
211 |
|
|
switch (gest->icode) |
212 |
|
|
{ |
213 |
|
|
case ERR_OPEN : |
214 |
|
|
return(remesh) ; |
215 |
|
|
case ERR_TYPE_ELE : |
216 |
|
|
return(remesh) ; |
217 |
|
|
case ERR_FORMAT : |
218 |
|
|
return(remesh) ; |
219 |
|
|
case ERR_ALLOC : |
220 |
|
|
return(remesh) ; |
221 |
|
|
case ERR_SYST : |
222 |
|
|
return(remesh) ; |
223 |
|
|
case ERR_QUAL_SKIN : |
224 |
|
|
return(remesh) ; |
225 |
|
|
case ERR_FIN : |
226 |
|
|
return(remesh) ; |
227 |
|
|
case ERR_NB_NOE : |
228 |
|
|
{ |
229 |
|
|
nb_max_noe = nb_max_noe * 2 ; |
230 |
|
|
nb_max_ele = 5 * nb_max_noe; |
231 |
|
|
gest->icode = FAUX ; |
232 |
|
|
} |
233 |
|
|
break ; |
234 |
|
|
case FAUX : |
235 |
|
|
break ; |
236 |
|
|
default : |
237 |
|
|
return(remesh) ; |
238 |
|
|
} |
239 |
|
|
} |
240 |
|
|
if (skin) return(remesh) ; |
241 |
|
|
nb_iter = 0 ; |
242 |
|
|
|
243 |
|
|
if (iter) |
244 |
|
|
while ((!gest->maillage_termine) && (nb_iter < 10)) |
245 |
|
|
{ |
246 |
|
|
if (save) m3d_wri(RECOVER) ; |
247 |
|
|
/*save = FAUX ;*/ |
248 |
|
|
switch (gest->icode) |
249 |
|
|
{ |
250 |
|
|
case FAUX : |
251 |
|
|
m3d_mai() ; |
252 |
|
|
break ; |
253 |
|
|
case ERR_ALLOC : |
254 |
|
|
return(remesh) ; |
255 |
|
|
case ERR_FIN : |
256 |
|
|
return(remesh) ; |
257 |
|
|
case ERR_NB_NOE : |
258 |
|
|
/* nombre de noeuds insuffisant */ |
259 |
|
|
/* relancer le maillage */ |
260 |
|
|
nb_max_noe = nb_max_noe * 2 ; |
261 |
|
|
nb_max_ele = 5 * nb_max_noe; |
262 |
|
|
gest->icode = FAUX ; |
263 |
|
|
if (gest->premiere_couche) |
264 |
|
|
{ |
265 |
|
|
//aff_text("nouvel essai - option recover \n") ; |
266 |
|
|
recover = VRAI ; |
267 |
|
|
nb_recover++ ; |
268 |
|
|
m3d_init() ; |
269 |
|
|
if (!m3d_recu(filename)) return(remesh) ; |
270 |
|
|
m3d_mai() ; |
271 |
|
|
} |
272 |
|
|
else /* la premiere couche n'a pas ete creee */ |
273 |
|
|
{ |
274 |
|
|
save = FAUX ; |
275 |
|
|
recover = FAUX ; |
276 |
|
|
m3d_init() ; |
277 |
|
|
if (!m3d_recu(filename)) return(remesh) ; |
278 |
|
|
m3d_mai() ; |
279 |
|
|
} |
280 |
|
|
break ; |
281 |
|
|
case ERR_SYST : |
282 |
|
|
nb_iter ++ ; |
283 |
|
|
gest->icode = FAUX ; |
284 |
|
|
/* la premiere couche d'elements a ete construite */ |
285 |
|
|
if (gest->premiere_couche) |
286 |
|
|
{ |
287 |
|
|
// if (show) aff_text("nouvel essai - option recover \n") ; |
288 |
|
|
recover = VRAI ; |
289 |
|
|
is_recover = VRAI ; |
290 |
|
|
nb_recover++ ; |
291 |
|
|
save = FAUX ; |
292 |
|
|
if (nb_recover >3) crit_min = min(crit_min,gest->crit_2d_min*0.45) ; |
293 |
|
|
if (nb_recover>5) crit_min = crit_min/2. ; |
294 |
|
|
m3d_init() ; |
295 |
|
|
if (!m3d_recu(filename)) return(remesh) ; |
296 |
|
|
m3d_mai() ; |
297 |
|
|
} |
298 |
|
|
else /* remaillage sans option recover */ |
299 |
|
|
{ |
300 |
|
|
// if (show) aff_text("nouvel essai - option recover \n") ; |
301 |
|
|
recover = FAUX ; |
302 |
|
|
crit_min = crit_min/2. ; |
303 |
|
|
m3d_init() ; |
304 |
|
|
if (!m3d_recu(filename)) return(remesh) ; |
305 |
|
|
m3d_mai() ; |
306 |
|
|
} |
307 |
|
|
break ; |
308 |
|
|
case ERR_QUAL : |
309 |
|
|
nb_iter ++ ; |
310 |
|
|
gest->icode = FAUX ; |
311 |
|
|
if (gest->premiere_couche) |
312 |
|
|
{ |
313 |
|
|
// if (show) aff_text("nouvel essai qualite diminuee - option recover \n") ; |
314 |
|
|
recover = VRAI ; |
315 |
|
|
is_recover = VRAI ; |
316 |
|
|
nb_recover++ ; |
317 |
|
|
m3d_init() ; |
318 |
|
|
if (!m3d_recu(filename)) return(remesh) ; |
319 |
|
|
crit_min = crit_min/2. ; |
320 |
|
|
m3d_mai() ; |
321 |
|
|
} |
322 |
|
|
else /* remaillage sans option recover */ |
323 |
|
|
{ |
324 |
|
|
// if (debug) aff_text("nouvel essai essai qualite diminuee - sans option recover \n") ; |
325 |
|
|
recover = FAUX ; |
326 |
|
|
m3d_init() ; |
327 |
|
|
crit_min_tmp=crit_min; |
328 |
|
|
if (!m3d_recu(filename)) return(remesh) ; |
329 |
|
|
crit_min = crit_min_tmp/2. ; |
330 |
|
|
m3d_mai() ; |
331 |
|
|
} |
332 |
|
|
break ; |
333 |
|
|
default : |
334 |
|
|
return(remesh) ; |
335 |
|
|
} |
336 |
|
|
} |
337 |
|
|
else |
338 |
|
|
{ |
339 |
|
|
m3d_mai() ; |
340 |
|
|
if (!gest->maillage_termine) |
341 |
|
|
{ |
342 |
|
|
// if (show) aff_text("Echec dans la phase de maillage \n") ; |
343 |
|
|
} |
344 |
|
|
} |
345 |
|
|
|
346 |
|
|
m3d_wri(sortie) ; |
347 |
|
|
return(remesh) ; |
348 |
|
|
} |
349 |
|
|
|
350 |
|
|
|
351 |
|
|
|
352 |
|
|
|
353 |
|
|
|
354 |
|
|
|
355 |
|
|
|
356 |
|
|
|