1 |
|
5 |
#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) {recover=1;para=1;}
|
89 |
|
|
if (strcmp ( argv[i], "-remesh" ) == 0) {remesh=1;}
|
90 |
|
|
if (strcmp ( argv[i], "-batch" ) == 0) remesh=1;
|
91 |
|
|
if (strcmp ( argv[i], "-save" ) == 0) save = 1;
|
92 |
|
|
if (strcmp ( argv[i], "-skin" ) == 0) skin = 1;
|
93 |
|
|
if (strcmp ( argv[i], "-noiter" ) == 0) iter = 0 ;
|
94 |
|
|
if (strcmp ( argv[i], "-noresult" ) == 0) result = FAUX ;
|
95 |
|
|
if (strcmp ( argv[i], "-crit" ) == 0) crit_min = (float)atof(argv[i+1]) ;
|
96 |
|
|
if (strcmp ( argv[i], "-raf" ) == 0) raf = (float)atof(argv[i+1]) ;
|
97 |
|
|
if (strcmp ( argv[i], "-nosmooth" ) == 0) lissage = 0;
|
98 |
|
|
if (strcmp ( argv[i], "-best" ) == 0) is_best = 1;
|
99 |
|
|
if (strcmp ( argv[i], "-dim" ) == 0) dimp = (float)atof(argv[i+1]) ;
|
100 |
|
|
if (strcmp ( argv[i], "-check" ) == 0) check = 1;
|
101 |
|
|
|
102 |
|
|
if (strcmp ( argv[i], "-nb_node" ) == 0)
|
103 |
|
|
{
|
104 |
|
|
nb_max_noe = atoi(argv[i+1]) ;
|
105 |
|
|
nb_max_ele = 5 * nb_max_noe;
|
106 |
|
|
}
|
107 |
|
|
if (!is_ext) is_ext = !strcmp ( argv[i], "-ext" );
|
108 |
|
|
if (!is_format) is_format = !strcmp ( argv[i], "-input" );
|
109 |
|
|
if (!is_output) is_output = !strcmp ( argv[i], "-output" );
|
110 |
|
|
if (!is_fich) is_fich = !strcmp ( argv[i], "-file" );
|
111 |
|
|
i++;
|
112 |
|
|
}
|
113 |
|
|
/* nom du fichier */
|
114 |
|
|
if (is_fich)
|
115 |
|
|
{
|
116 |
|
|
is_fich = FAUX ;
|
117 |
|
|
i = 0 ;
|
118 |
|
|
while ((!is_fich)&&(i<argc))
|
119 |
|
|
{
|
120 |
|
|
is_fich = !strcmp ( argv[i], "-file" );
|
121 |
|
|
if (is_fich)
|
122 |
|
|
{
|
123 |
|
|
filename[0] = 0 ;
|
124 |
|
|
strcpy(filename,argv[i+1]) ;
|
125 |
|
|
}
|
126 |
|
|
i ++ ;
|
127 |
|
|
}
|
128 |
|
|
}
|
129 |
|
|
/* extension du fichier */
|
130 |
|
|
if (is_ext)
|
131 |
|
|
{
|
132 |
|
|
is_ext = FAUX ;
|
133 |
|
|
i = 0 ;
|
134 |
|
|
while ((!is_ext)&&(i<argc))
|
135 |
|
|
{
|
136 |
|
|
is_ext = !strcmp ( argv[i], "-ext" );
|
137 |
|
|
if (is_ext)
|
138 |
|
|
{
|
139 |
|
|
ext_out[0] = 0 ;
|
140 |
|
|
strcpy(ext_out,argv[i+1]) ;
|
141 |
|
|
}
|
142 |
|
|
i ++ ;
|
143 |
|
|
}
|
144 |
|
|
}
|
145 |
|
|
|
146 |
|
|
if (is_format)
|
147 |
|
|
{
|
148 |
|
|
is_format = FAUX ;
|
149 |
|
|
i = 0 ;
|
150 |
|
|
while ((!is_format)&&(i<argc))
|
151 |
|
|
{
|
152 |
|
|
is_format = !strcmp ( argv[i], "-input" ) ;
|
153 |
|
|
if (is_format)
|
154 |
|
|
{
|
155 |
|
|
if (!strcmp ( argv[i+1], "mosaic" )) format = MOSAIC ;
|
156 |
|
|
if (!strcmp ( argv[i+1], "systus" )) format = SYSTUS ;
|
157 |
|
|
if (!strcmp ( argv[i+1], "starcd" )) format = STARCD ;
|
158 |
|
|
if (!strcmp ( argv[i+1], "master" )) format = MASTER_SERIES ;
|
159 |
|
|
if (!strcmp ( argv[i+1], "nastran" )) format = NASTRAN ;
|
160 |
|
|
if (!strcmp ( argv[i+1], "ansys" )) format = ANSYS ;
|
161 |
|
|
if (!strcmp ( argv[i+1], "ideas" )) format = SUPERTAB ;
|
162 |
|
|
if (!strcmp ( argv[i+1], "acsis" )) sortie = ACSIS ;
|
163 |
|
|
|
164 |
|
|
}
|
165 |
|
|
i ++ ;
|
166 |
|
|
}
|
167 |
|
|
}
|
168 |
|
|
if (is_output)
|
169 |
|
|
{
|
170 |
|
|
is_output = FAUX ;
|
171 |
|
|
i = 0 ;
|
172 |
|
|
while ((!is_output)&&(i<argc))
|
173 |
|
|
{
|
174 |
|
|
is_output = !strcmp ( argv[i], "-output" ) ;
|
175 |
|
|
if (is_output)
|
176 |
|
|
{
|
177 |
|
|
if (!strcmp ( argv[i+1], "mosaic" )) sortie = MOSAIC ;
|
178 |
|
|
if (!strcmp ( argv[i+1], "systus" )) sortie = SYSTUS ;
|
179 |
|
|
if (!strcmp ( argv[i+1], "starcd" )) sortie = STARCD ;
|
180 |
|
|
if (!strcmp ( argv[i+1], "master" )) sortie = MASTER_SERIES ;
|
181 |
|
|
if (!strcmp ( argv[i+1], "nastran" )) sortie = NASTRAN ;
|
182 |
|
|
if (!strcmp ( argv[i+1], "ansys" )) sortie = ANSYS ;
|
183 |
|
|
if (!strcmp ( argv[i+1], "ideas" )) sortie = SUPERTAB ;
|
184 |
|
|
if (!strcmp ( argv[i+1], "acsis" )) sortie = ACSIS ;
|
185 |
|
|
|
186 |
|
|
}
|
187 |
|
|
i ++ ;
|
188 |
|
|
}
|
189 |
|
|
}
|
190 |
|
|
else sortie = format ;
|
191 |
|
|
|
192 |
|
|
m3d_message(WELCOME) ;
|
193 |
|
|
|
194 |
|
|
sprintf(mess,"%s %s\n",MESS_FICHIER,filename) ;
|
195 |
|
|
// aff_text(mess);
|
196 |
|
|
// aff_text("\n");
|
197 |
|
|
|
198 |
|
|
/* Prendre en compte la protection */
|
199 |
|
|
|
200 |
|
|
m3d_init() ; /* initialisation des structures de donnees */
|
201 |
|
|
/* lecture des donnees */
|
202 |
|
|
|
203 |
|
|
while (!gest->lecture_donnees)
|
204 |
|
|
{
|
205 |
|
|
m3d_recu(filename) ;
|
206 |
|
|
switch(gest->icode)
|
207 |
|
|
{
|
208 |
|
|
case ERR_OPEN : return(remesh) ;
|
209 |
|
|
case ERR_TYPE_ELE : return(remesh) ;
|
210 |
|
|
case ERR_FORMAT : return(remesh) ;
|
211 |
|
|
case ERR_ALLOC : return(remesh) ;
|
212 |
|
|
case ERR_SYST : return(remesh) ;
|
213 |
|
|
case ERR_QUAL_SKIN : return(remesh) ;
|
214 |
|
|
case ERR_FIN : return(remesh) ;
|
215 |
|
|
case ERR_NB_NOE :
|
216 |
|
|
{
|
217 |
|
|
nb_max_noe = nb_max_noe * 2 ;
|
218 |
|
|
nb_max_ele = 5 * nb_max_noe;
|
219 |
|
|
gest->icode = FAUX ;
|
220 |
|
|
}
|
221 |
|
|
break ;
|
222 |
|
|
case FAUX : break ;
|
223 |
|
|
default : return(remesh) ;
|
224 |
|
|
}
|
225 |
|
|
}
|
226 |
|
|
if (skin) return(remesh) ;
|
227 |
|
|
nb_iter = 0 ;
|
228 |
|
|
|
229 |
|
|
if (iter)
|
230 |
|
|
while ((!gest->maillage_termine) && (nb_iter < 10))
|
231 |
|
|
{
|
232 |
|
|
if (save) m3d_wri(RECOVER) ;
|
233 |
|
|
/*save = FAUX ;*/
|
234 |
|
|
switch(gest->icode)
|
235 |
|
|
{
|
236 |
|
|
case FAUX : m3d_mai() ; break ;
|
237 |
|
|
case ERR_ALLOC : return(remesh) ;
|
238 |
|
|
case ERR_FIN : return(remesh) ;
|
239 |
|
|
case ERR_NB_NOE :
|
240 |
|
|
/* nombre de noeuds insuffisant */
|
241 |
|
|
/* relancer le maillage */
|
242 |
|
|
nb_max_noe = nb_max_noe * 2 ;
|
243 |
|
|
nb_max_ele = 5 * nb_max_noe;
|
244 |
|
|
gest->icode = FAUX ;
|
245 |
|
|
if (gest->premiere_couche)
|
246 |
|
|
{
|
247 |
|
|
//aff_text("nouvel essai - option recover \n") ;
|
248 |
|
|
recover = VRAI ;
|
249 |
|
|
nb_recover++ ;
|
250 |
|
|
m3d_init() ;
|
251 |
|
|
if (!m3d_recu(filename)) return(remesh) ;
|
252 |
|
|
m3d_mai() ;
|
253 |
|
|
}
|
254 |
|
|
else /* la premiere couche n'a pas ete creee */
|
255 |
|
|
{
|
256 |
|
|
save = FAUX ;
|
257 |
|
|
recover = FAUX ;
|
258 |
|
|
m3d_init() ;
|
259 |
|
|
if (!m3d_recu(filename)) return(remesh) ;
|
260 |
|
|
m3d_mai() ;
|
261 |
|
|
}
|
262 |
|
|
break ;
|
263 |
|
|
case ERR_SYST :
|
264 |
|
|
nb_iter ++ ;
|
265 |
|
|
gest->icode = FAUX ;
|
266 |
|
|
/* la premiere couche d'elements a ete construite */
|
267 |
|
|
if (gest->premiere_couche)
|
268 |
|
|
{
|
269 |
|
|
// if (show) aff_text("nouvel essai - option recover \n") ;
|
270 |
|
|
recover = VRAI ;
|
271 |
|
|
is_recover = VRAI ;
|
272 |
|
|
nb_recover++ ;
|
273 |
|
|
save = FAUX ;
|
274 |
|
|
if (nb_recover >3) crit_min = min(crit_min,gest->crit_2d_min*0.45) ;
|
275 |
|
|
if (nb_recover>5) crit_min = crit_min/2. ;
|
276 |
|
|
m3d_init() ;
|
277 |
|
|
if (!m3d_recu(filename)) return(remesh) ;
|
278 |
|
|
m3d_mai() ;
|
279 |
|
|
}
|
280 |
|
|
else /* remaillage sans option recover */
|
281 |
|
|
{
|
282 |
|
|
// if (show) aff_text("nouvel essai - option recover \n") ;
|
283 |
|
|
recover = FAUX ;
|
284 |
|
|
crit_min = crit_min/2. ;
|
285 |
|
|
m3d_init() ;
|
286 |
|
|
if (!m3d_recu(filename)) return(remesh) ;
|
287 |
|
|
m3d_mai() ;
|
288 |
|
|
}
|
289 |
|
|
break ;
|
290 |
|
|
case ERR_QUAL :
|
291 |
|
|
nb_iter ++ ;
|
292 |
|
|
gest->icode = FAUX ;
|
293 |
|
|
if (gest->premiere_couche)
|
294 |
|
|
{
|
295 |
|
|
// if (show) aff_text("nouvel essai qualite diminuee - option recover \n") ;
|
296 |
|
|
recover = VRAI ;
|
297 |
|
|
is_recover = VRAI ;
|
298 |
|
|
nb_recover++ ;
|
299 |
|
|
m3d_init() ;
|
300 |
|
|
if (!m3d_recu(filename)) return(remesh) ;
|
301 |
|
|
crit_min = crit_min/2. ;
|
302 |
|
|
m3d_mai() ;
|
303 |
|
|
}
|
304 |
|
|
else /* remaillage sans option recover */
|
305 |
|
|
{
|
306 |
|
|
// if (debug) aff_text("nouvel essai essai qualite diminuee - sans option recover \n") ;
|
307 |
|
|
recover = FAUX ;
|
308 |
|
|
m3d_init() ;
|
309 |
|
|
crit_min_tmp=crit_min;
|
310 |
|
|
if (!m3d_recu(filename)) return(remesh) ;
|
311 |
|
|
crit_min = crit_min_tmp/2. ;
|
312 |
|
|
m3d_mai() ;
|
313 |
|
|
}
|
314 |
|
|
break ;
|
315 |
|
|
default : return(remesh) ;
|
316 |
|
|
}
|
317 |
|
|
}
|
318 |
|
|
else
|
319 |
|
|
{
|
320 |
|
|
m3d_mai() ;
|
321 |
|
|
if (!gest->maillage_termine)
|
322 |
|
|
{
|
323 |
|
|
// if (show) aff_text("Echec dans la phase de maillage \n") ;
|
324 |
|
|
}
|
325 |
|
|
}
|
326 |
|
|
|
327 |
|
|
m3d_wri(sortie) ;
|
328 |
|
|
return(remesh) ;
|
329 |
|
|
}
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
|
|
|
337 |
|
|
|