00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #ifndef MESGERR
00062 #define MESGERR 1
00063 #endif
00064
00065 #ifdef __cplusplus
00066 extern "C" {
00067 #endif
00068
00069 #include <med.h>
00070 #include <med_config.h>
00071 #include <med_utils.h>
00072 #include <med_misc.h>
00073 #include <stdio.h>
00074 #include <string.h>
00075 #include <stdlib.h>
00076
00077 #ifdef __cplusplus
00078 }
00079 #endif
00080
00081 #ifdef PPRO_NT
00082 #define F_OK 0
00083 #define snprintf _snprintf
00084 #else
00085 #include <unistd.h>
00086 #endif
00087
00088
00089 extern med_entity_type MED23MESH_GET_ENTITY_TYPE[MED_N_ENTITY_TYPES+2];
00090 extern const char * const MED23MESH_GET_ENTITY_TYPENAME[MED_N_ENTITY_TYPES+2];
00091 extern med_geometry_type MED23MESH_GET_CELL_GEOMETRY_TYPE[MED_N_CELL_FIXED_GEO+2];
00092 extern const char * const MED23MESH_GET_CELL_GEOMETRY_TYPENAME[MED_N_CELL_FIXED_GEO+2];
00093 extern med_geometry_type MED23MESH_GET_FACE_GEOMETRY_TYPE[MED_N_FACE_FIXED_GEO+2];
00094 extern const char * const MED23MESH_GET_FACE_GEOMETRY_TYPENAME[MED_N_FACE_FIXED_GEO+2];
00095 extern med_geometry_type MED23MESH_GET_EDGE_GEOMETRY_TYPE[MED_N_EDGE_FIXED_GEO+2];
00096 extern const char * MED23MESH_GET_EDGE_GEOMETRY_TYPENAME[MED_N_EDGE_FIXED_GEO+2];
00097 extern med_geometry_type MED23MESH_GET_NODE_GEOMETRY_TYPE[MED_N_NODE_FIXED_GEO+2];
00098 extern const char * MED23MESH_GET_NODE_GEOMETRY_TYPENAME[MED_N_NODE_FIXED_GEO+2];
00099
00100 extern med_entity_type MED23FIELD_GET_ENTITY_TYPE[MED_N_ENTITY_TYPES+2];
00101 extern const char * const MED23FIELD_GET_ENTITY_TYPENAME[MED_N_ENTITY_TYPES+2];
00102 extern med_geometry_type MED23FIELD_GET_CELL_GEOMETRY_TYPE[MED_N_CELL_FIXED_GEO+2];
00103 extern const char * const MED23FIELD_GET_CELL_GEOMETRY_TYPENAME[MED_N_CELL_FIXED_GEO+2];
00104 extern med_geometry_type MED23FIELD_GET_FACE_GEOMETRY_TYPE[MED_N_FACE_FIXED_GEO+2];
00105 extern const char * const MED23FIELD_GET_FACE_GEOMETRY_TYPENAME[MED_N_FACE_FIXED_GEO+2];
00106 extern med_geometry_type MED23FIELD_GET_EDGE_GEOMETRY_TYPE[MED_N_EDGE_FIXED_GEO+2];
00107 extern const char * MED23FIELD_GET_EDGE_GEOMETRY_TYPENAME[MED_N_EDGE_FIXED_GEO+2];
00108 extern med_geometry_type MED23FIELD_GET_NODE_GEOMETRY_TYPE[MED_N_NODE_FIXED_GEO+2];
00109 extern const char * MED23FIELD_GET_NODE_GEOMETRY_TYPENAME[MED_N_NODE_FIXED_GEO+2];
00110
00111
00112
00113
00114
00115 int structure = 0;
00116
00117
00118 const med_geometry_type * const typmai = MED23MESH_GET_CELL_GEOMETRY_TYPE+1;
00119 const med_geometry_type * const typfac = MED23MESH_GET_FACE_GEOMETRY_TYPE+1;
00120 const med_geometry_type * const typare = MED23MESH_GET_EDGE_GEOMETRY_TYPE+1;
00121
00122 const char * const *nommai = MED23MESH_GET_CELL_GEOMETRY_TYPENAME+1;
00123 const char * const *nomfac = MED23MESH_GET_FACE_GEOMETRY_TYPENAME+1;
00124 const char * const *nomare = MED23MESH_GET_EDGE_GEOMETRY_TYPENAME+1;
00125
00126 #define MED_LECTURE_MAILLAGE_SUPPORT_UNIQUEMENT 2
00127 #define MED_LECTURE_ENTETE_SEULEMENT 1
00128
00129 #define USER_MODE MED_COMPACT_STMODE
00130
00131 #define xstr(s) str(s)
00132 #define str(s) #s
00133
00134 #define MIN(a,b) ((a) < (b) ? (a) : (b))
00135 #define MAX(a,b) ((a) > (b) ? (a) : (b))
00136
00137 #define MAXBANNERLEN 255
00138
00139 void affd(const void *pva)
00140 {
00141 const double *pa = pva;
00142 printf(" %f ",*pa);
00143 }
00144
00145 void affi(const void *pva)
00146 {
00147 const med_int *pa = pva;
00148
00149
00150 printf(" "IFORMAT" " ,*pa);
00151 }
00152
00153 void affs(const void *pva)
00154 {
00155 const char *pa = pva;
00156 printf(" %.*s ",MED_NAME_SIZE,pa);
00157 }
00158
00159 typedef void (*_myfuncptr)(const void*);
00160
00161 _myfuncptr MEDstructPrintFunction(med_attribute_type atttype) {
00162 switch (atttype) {
00163 case MED_ATT_INT :
00164 return affi;
00165 break;
00166 case MED_ATT_FLOAT64:
00167 return affd;
00168 break;
00169 case MED_ATT_NAME:
00170 return affs;
00171 break;
00172 default:
00173 EXIT_IF(-1,"lors de la lecture du type d'attribut à afficher.",NULL);
00174 return NULL;
00175
00176 }
00177 return NULL;
00178
00179 }
00180
00181 med_int lecture_nombre_famille(med_idt fid,const char * const nommaa)
00182 {
00183 med_int nfam = MEDnFamily(fid,nommaa);
00184 EXIT_IF(nfam < 0,"lors de la lecture du nombre de familles",NULL);
00185 fprintf(stdout,"- Nombre de familles : "IFORMAT" \n",nfam);
00186
00187 return nfam;
00188 }
00189
00190 void lecture_famille_maillage(med_idt fid,const char * const nommaa,med_int nfam)
00191 {
00192 med_int i,j;
00193 med_int natt,ngro;
00194 char *attdes=NULL,*gro=NULL;
00195 med_int *attval=NULL,*attide=NULL;
00196 char nomfam[MED_NAME_SIZE+1];
00197 med_int numfam;
00198 char str1[MED_COMMENT_SIZE+1];
00199 char str2[MED_LNAME_SIZE+1];
00200 med_err ret = 0;
00201 int famille_0 = 0;
00202
00203 if (nfam) {
00204 fprintf(stdout,"\n(**************************)\n");
00205 fprintf(stdout,"(* FAMILLES DU MAILLAGE : *)\n");
00206 fprintf(stdout,"(**************************)\n");
00207 }
00208
00209 for (i=0;i<nfam;i++) {
00210
00211
00212 ngro = MEDnFamilyGroup(fid,nommaa,i+1);
00213 EXIT_IF(ngro < 0,"lors de la lecture du nombre de groupe d'une famille",
00214 NULL);
00215
00216
00217 natt = MEDnFamily23Attribute(fid,nommaa,i+1);
00218 EXIT_IF(natt < 0,"lors de la lecture du nombre d'attributs d'une famille",
00219 NULL);
00220
00221 fprintf(stdout,"- Famille "IFORMAT" a "IFORMAT" attributs et "IFORMAT" groupes \n",i+1,natt,
00222 ngro);
00223
00224
00225
00226
00227 attide = (med_int*) malloc(sizeof(med_int)*natt);
00228 EXIT_IF(attide == NULL,NULL,NULL);
00229 attval = (med_int*) malloc(sizeof(med_int)*natt);
00230 EXIT_IF(attval == NULL,NULL,NULL);
00231 attdes = (char *) malloc(MED_COMMENT_SIZE*natt+1);
00232 EXIT_IF(attdes == NULL,NULL,NULL);
00233 gro = (char*) malloc(MED_LNAME_SIZE*ngro+1);
00234 EXIT_IF(gro == NULL,NULL,NULL);
00235 ret = MEDfamily23Info(fid,nommaa,i+1,nomfam,attide,attval,
00236 attdes,&numfam,gro);
00237 EXIT_IF(ret < 0,"lors de la lecture des informations d'une famille",
00238 NULL);
00239 if (numfam == 0)
00240 famille_0 = 1;
00241
00242 if (!structure) {
00243
00244 fprintf(stdout," - Famille de nom %s et de numero "IFORMAT" : \n",nomfam,numfam);
00245 fprintf(stdout," - Attributs : \n");
00246 for (j=0;j<natt;j++) {
00247 strncpy(str1,attdes+j*MED_COMMENT_SIZE,MED_COMMENT_SIZE);
00248 str1[MED_COMMENT_SIZE] = '\0';
00249 fprintf(stdout," ide = "IFORMAT" - val = "IFORMAT" - des = %s\n",*(attide+j),
00250 *(attval+j),str1);
00251 }
00252 }
00253
00254
00255 if (attide) {free(attide);attide=NULL;}
00256 if (attval) {free(attval);attval=NULL;}
00257 if (attdes) {free(attdes);attdes=NULL;}
00258
00259 if (!structure) {
00260 fprintf(stdout," - Groupes :\n");
00261 for (j=0;j<ngro;j++) {
00262 strncpy(str2,gro+j*MED_LNAME_SIZE,MED_LNAME_SIZE);
00263 str2[MED_LNAME_SIZE] = '\0';
00264 fprintf(stdout," gro = %s\n",str2);
00265 }
00266 }
00267
00268
00269 if (gro) {free(gro);gro=NULL;}
00270 }
00271
00272 if (famille_0 != 1) {
00273 MESSAGE("Erreur : La famille FAMILLE_ZERO n'a pas été trouvée, elle est obligatoire. ");
00274 }
00275
00276 return;
00277 }
00278
00279 med_int lecture_nombre_equivalence(med_idt fid,const char * const nommaa)
00280 {
00281 med_int nequ = MEDnEquivalence(fid,nommaa);
00282 EXIT_IF(nequ < 0,"lors de la lecture du nombre d'equivalences",NULL);
00283 fprintf(stdout,"- Nombre d'equivalences : "IFORMAT" \n",nequ);
00284
00285 return nequ;
00286 }
00287
00288
00289 void lecture_equivalence_maillage(med_idt fid,const char * const nommaa,med_int nequ)
00290 {
00291 med_int i,j,k;
00292 med_int ncor;
00293 med_int *cor;
00294 char equ[MED_NAME_SIZE+1];
00295 char des[MED_COMMENT_SIZE+1];
00296 med_err ret = 0;
00297 med_int nstep=0,nocstpncor=0;
00298 int _cstpit=0;
00299 med_int _numdt,_numit;
00300
00301
00302 if ( (nequ != 0) ) {
00303 fprintf(stdout,"\n(******************************)\n");
00304 fprintf(stdout,"(* EQUIVALENCES DU MAILLAGE : *)\n");
00305 fprintf(stdout,"(******************************)\n");
00306 }
00307
00308
00309 for (i = 0;i<nequ;i++) {
00310
00311
00312 ret = MEDequivalenceInfo(fid,nommaa,i+1,equ,des,&nstep,&nocstpncor);
00313 EXIT_IF(ret < 0,"lors de la lecture des informations sur une equivalence",
00314 NULL);
00315
00316
00317 fprintf(stdout,"- Equivalence numero : "IFORMAT" ",i+1);
00318 fprintf(stdout,"\n - Nom de l'equivalence: %s \n",equ);
00319 fprintf(stdout,"\n - Description de l'equivalence : %s \n",des);
00320 if (nstep > 1)
00321 fprintf(stdout,"\n - L'equivalence est définie sur "IFORMAT" étapes de calcul\n",nstep);
00322
00323
00324 for (_cstpit=1; _cstpit <= nstep; ++_cstpit) {
00325
00326 ret = MEDequivalenceComputingStepInfo (fid, nommaa, equ, _cstpit,
00327 & _numdt, &_numit,&nocstpncor);
00328 EXIT_IF(ret < 0,
00329 "lors de la lecture des valeurs de séquence de calcul d'une equivalence",
00330 NULL);
00331
00332 if ( (_numdt != MED_NO_DT) || (_numit != MED_NO_IT) )
00333 fprintf(stdout,"\n - Séquence de calcul définie sur (numdt,numit) ("IFORMAT","IFORMAT") :\n",_numdt,_numit);
00334
00335
00336
00337
00338 ret = MEDequivalenceCorrespondenceSize(fid,nommaa,equ,_numdt,_numit,MED_NODE,MED_NONE,&ncor);
00339 EXIT_IF(ret < 0,
00340 "lors de la lecture du nombre de correspondances d'une equivalence",
00341 NULL);
00342 fprintf(stdout,"\n - Il y a "IFORMAT" correspondances sur les noeuds \n",ncor);
00343
00344 if (ncor > 0) {
00345
00346
00347 cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00348 EXIT_IF(cor == NULL,NULL,NULL);
00349 ret= MEDequivalenceCorrespondenceRd(fid,nommaa,equ,_numdt,_numit,
00350 MED_NODE,MED_NONE,cor);
00351 EXIT_IF(ret < 0,"lors de la lecture du tableau des correspondances",
00352 NULL);
00353 if (!structure) {
00354 for (j=0;j<ncor;j++)
00355 fprintf(stdout,"\n - Correspondance "IFORMAT" : "IFORMAT" et "IFORMAT" \n",j+1,*(cor+2*j),
00356 *(cor+2*j+1));
00357 }
00358 free(cor);
00359 }
00360
00361
00362 for (j=0;j<MED_N_CELL_FIXED_GEO;j++) {
00363
00364 ret = MEDequivalenceCorrespondenceSize(fid,nommaa,equ,_numdt,_numit,MED_CELL,typmai[j],&ncor);
00365 EXIT_IF(ret < 0,
00366 "lors de la lecture du nombre de correspondances dans une equivalence",
00367 NULL);
00368 fprintf(stdout,"\n - Il y a "IFORMAT" correspondances sur les mailles %s \n",ncor,
00369 nommai[j]);
00370
00371 if (ncor > 0) {
00372
00373
00374 cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00375 EXIT_IF(cor == NULL,NULL,NULL);
00376 ret = MEDequivalenceCorrespondenceRd(fid,nommaa,equ,_numdt,_numit,
00377 MED_CELL,typmai[j],cor);
00378 EXIT_IF(ret < 0,"lors de la lecture du tableau des equivalences",
00379 NULL);
00380
00381 if (!structure) {
00382 for (k=0;k<ncor;k++)
00383 fprintf(stdout,"\n - Correspondance "IFORMAT" : "IFORMAT" et "IFORMAT" \n",k+1,
00384 *(cor+2*k),*(cor+2*k+1));
00385 }
00386 free(cor);
00387 }
00388 }
00389
00390
00391
00392 for (j=0;j<MED_N_FACE_FIXED_GEO;j++) {
00393
00394 ret = MEDequivalenceCorrespondenceSize(fid,nommaa,equ,_numdt,_numit,
00395 MED_DESCENDING_FACE,typfac[j],&ncor);
00396
00397 EXIT_IF(ret < 0,
00398 "lors de la lecture du nombre de correspondances dans une equivalence",
00399 NULL);
00400 fprintf(stdout,"\n - Il y a "IFORMAT" correspondances sur les faces %s\n",ncor,
00401 nomfac[j]);
00402
00403 if (ncor > 0) {
00404
00405
00406 cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00407 EXIT_IF(cor == NULL,NULL,NULL);
00408 ret = MEDequivalenceCorrespondenceRd(fid,nommaa,equ,_numdt,_numit,
00409 MED_DESCENDING_FACE,typfac[j],cor);
00410 EXIT_IF(ret < 0,"lors de la lecture du tableau des equivalences",
00411 NULL);
00412
00413 if (!structure) {
00414 for (k=0;k<ncor;k++)
00415 fprintf(stdout,"\n - Correspondance "IFORMAT" : "IFORMAT" et "IFORMAT" \n",k+1,*(cor+2*k),
00416 *(cor+2*k+1));
00417 }
00418 free(cor);
00419 }
00420 }
00421
00422
00423
00424 for (j=0;j<MED_N_NODE_FIXED_GEO;j++) {
00425
00426 ret = MEDequivalenceCorrespondenceSize(fid,nommaa,equ,_numdt,_numit,
00427 MED_DESCENDING_EDGE,typare[j],&ncor);
00428 EXIT_IF(ret < 0,"lors de la lecture du nombre de correspondances",
00429 NULL);
00430 fprintf(stdout,"\n - Il y a "IFORMAT" correspondances sur les aretes %s \n",
00431 ncor,nomare[j]);
00432
00433 if (ncor > 0) {
00434
00435
00436 cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00437 EXIT_IF(cor == NULL,NULL,NULL);
00438 ret =MEDequivalenceCorrespondenceRd(fid,nommaa,equ,_numdt,_numit,
00439 MED_DESCENDING_EDGE,typare[j],cor);
00440 EXIT_IF(ret < 0,"lors de la lecture du tableau des equivalences",
00441 NULL);
00442
00443 if (!structure) {
00444 for (k=0;k<ncor;k++)
00445 fprintf(stdout,"\n Correspondance "IFORMAT" : "IFORMAT" et "IFORMAT" \n",k+1,*(cor+2*k),
00446 *(cor+2*k+1));
00447 }
00448
00449 free(cor);
00450 }
00451 }
00452 }
00453 }
00454
00455 return;
00456 }
00457
00458
00459 med_int lecture_nombre_joint(med_idt fid,const char * const nommaa)
00460 {
00461 med_int njnt = MEDnSubdomainJoint(fid,nommaa);
00462 EXIT_IF(njnt < 0,"lors de la lecture du nombre de joints",NULL);
00463 fprintf(stdout,"- Nombre de joints : "IFORMAT" \n",njnt);
00464
00465 return njnt;
00466 }
00467
00468
00469 void lecture_joint_maillage(med_idt fid,const char * const nommaa,med_int njnt)
00470 {
00471 med_int i,k;
00472 char des[MED_COMMENT_SIZE+1];
00473 med_int ndom,nent;
00474 med_int typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant;
00475
00476
00477 char jn [MED_NAME_SIZE+1]="";
00478 char maa_dist [MED_NAME_SIZE+1]="";
00479 char nom_geo_ent_local [MED_NAME_SIZE+1]="";
00480 char nom_geo_ent_distant [MED_NAME_SIZE+1]="";
00481 med_int *cortab;
00482
00483 med_err ret = 0;
00484 med_int njstep=0,ncor=0,nodtitncor=0;
00485 int corit=0,csit=0;
00486 med_int _numdt,_numit;
00487
00488 if ( (njnt != 0) ) {
00489 fprintf(stdout,"\n(******************************)\n");
00490 fprintf(stdout,"(* JOINTS DU MAILLAGE : *)\n");
00491 fprintf(stdout,"(******************************)\n");
00492 }
00493
00494
00495 for (i = 0;i<njnt;i++) {
00496 fprintf(stdout,"- Joint numero : "IFORMAT" ",i+1);
00497
00498
00499 ret = MEDsubdomainJointInfo(fid,nommaa,i+1,jn,des,&ndom,maa_dist,&njstep,&nodtitncor);
00500 EXIT_IF(ret < 0,"lors de la lecture des informations sur un joint",
00501 NULL);
00502
00503 fprintf(stdout,"\n - Nom du joint: %s \n",jn);
00504 fprintf(stdout,"\n - Description du joint : %s ",des);
00505 fprintf(stdout,"\n - Domaine en regard : "IFORMAT" ",ndom);
00506 fprintf(stdout,"\n - Maillage distant : %s ",maa_dist);
00507 if (njstep > 1 ) {
00508 printf("Nombre d'étapes de calcul : "IFORMAT" \n",njstep);
00509 printf("Nombre de correspondance pour (NO_DT,NO_IT) : "IFORMAT" \n",nodtitncor);
00510 }
00511
00512 for (csit=1; csit <= njstep; ++csit) {
00513
00514 ret = MEDsubdomainComputingStepInfo( fid, nommaa, jn, csit, &_numdt, &_numit, &ncor);
00515 EXIT_IF(ret < 0,"Erreur a la lecture des valeurs (numdt,numit) dans les joints",
00516 NULL);
00517 if ( (_numdt != MED_NO_DT) || (_numit != MED_NO_IT) ) {
00518 printf("Séquence de calcul (numdt,numit) : ("IFORMAT","IFORMAT")\n",_numdt,_numit);
00519 }
00520 corit=1;
00521 while ( corit <= ncor ) {
00522
00523 ret = MEDsubdomainCorrespondenceSizeInfo(fid,nommaa,jn,_numdt,_numit,corit,
00524 (med_entity_type *) &typ_ent_local, (med_geometry_type *) &typ_geo_local,
00525 (med_entity_type *) &typ_ent_distant,(med_geometry_type *)&typ_geo_distant,
00526 &nent);
00527 EXIT_IF(ret < 0,"Erreur a la lecture des infos sur le nombre d'entite en regard",
00528 NULL);
00529 if (nent > 0) {
00530 if (typ_ent_local == MED_NODE) strcpy(nom_geo_ent_local,"MED_NOEUD");
00531 else ret = _MEDgetInternalGeometryTypeName(nom_geo_ent_local,typ_geo_local);
00532 EXIT_IF(ret < 0,"Erreur à l'appel de _MEDgetInternalGeometryTypeName", NULL);
00533 if (typ_ent_distant == MED_NODE) strcpy(nom_geo_ent_distant,"MED_NOEUD");
00534 else ret = _MEDgetInternalGeometryTypeName(nom_geo_ent_distant,typ_geo_distant);
00535 EXIT_IF(ret < 0,"Erreur à l'appel de _MEDgetInternalGeometryTypeName", NULL);
00536 fprintf(stdout,"\n\t\t- nb de couples d'entites en regard (local,distant)=(%s,%s) : "IFORMAT" \n",
00537 nom_geo_ent_local,nom_geo_ent_distant, nent);
00538
00539
00540 cortab = (med_int*) malloc(sizeof(med_int)*nent*2);
00541 if ( (ret=MEDsubdomainCorrespondenceRd(fid,nommaa,jn,_numdt,_numit,
00542 typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant,
00543 cortab)) < 0) {
00544 fprintf(stdout,"\n\t\t- Erreur a la lecture des correspondances sur (%s,%s,%s,%s)",
00545 MED23MESH_GET_ENTITY_TYPENAME[typ_ent_local+1],nom_geo_ent_local,
00546 MED23MESH_GET_ENTITY_TYPENAME[typ_ent_distant+1],nom_geo_ent_distant);
00547 } else {
00548 if (!structure) {
00549 for (k=0;k<nent;k++)
00550 fprintf(stdout,"\n\t\t- Correspondance "IFORMAT" : "IFORMAT" et "IFORMAT" ",k+1,
00551 *(cortab+2*k),*(cortab+2*k+1));
00552 }
00553 }
00554 free(cortab);
00555 }
00556
00557 corit++;
00558 }
00559 }
00560 }
00561
00562 return;
00563 }
00564
00565
00566 med_int lecture_nombre_noeuds_maillage_non_structure(const med_idt fid,
00567 const char * nommaa,
00568 const med_int numdt,
00569 const med_int numit)
00570 {
00571
00572
00573 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
00574
00575 med_int nnoe = MEDmeshnEntity(fid,nommaa,numdt,numit,
00576 MED_NODE,MED_NO_GEOTYPE,
00577 MED_COORDINATE,MED_NODAL,&chgt,&trsf);
00578 EXIT_IF(nnoe < 0,"lors de la lecture du nombre de noeuds",NULL);
00579 fprintf(stdout,"- Nombre de noeuds : "IFORMAT" \n",nnoe);
00580
00581 return nnoe;
00582 }
00583
00584
00585 void lecture_noeuds_maillage_non_structure(const med_idt fid,
00586 const char * const nommaa,
00587 const med_int numdt,
00588 const med_int numit,
00589 const med_int mdim,
00590 const med_int edim,
00591 const med_int nnoe,
00592 const med_switch_mode mode_coo,
00593 const char * const nomcoo,
00594 const char * const unicoo,
00595 const med_axis_type *const rep)
00596 {
00597 med_float *coo;
00598 char *nomnoe;
00599 med_int *numnoe;
00600 med_int *nufano;
00601 med_bool inonoe,inunoe,ifano;
00602 med_err ret = 0;
00603 med_int i;
00604 char str[MED_SNAME_SIZE+1];
00605
00606
00607
00608
00609
00610 coo = (med_float*) malloc(sizeof(med_float)*nnoe*edim);
00611 EXIT_IF(coo == NULL,NULL,NULL);
00612
00613
00614 numnoe = (med_int*) malloc(sizeof(med_int)*nnoe);
00615 EXIT_IF(numnoe == NULL,NULL,NULL);
00616 nufano = (med_int*) malloc(sizeof(med_int)*nnoe);
00617 EXIT_IF(nufano == NULL,NULL,NULL);
00618
00619
00620 nomnoe = (char*) malloc(MED_SNAME_SIZE*nnoe+1);
00621 EXIT_IF(nomnoe == NULL,NULL,NULL);
00622
00623
00624
00625
00626
00627
00628 ret = MEDmeshNodeRd(fid,nommaa,numdt,numit, mode_coo, coo,
00629 &inonoe,nomnoe,&inunoe,numnoe,&ifano,nufano);
00630
00631
00632 EXIT_IF(ret < 0,"lors de la lecture des noeuds du maillage \n",NULL);
00633
00634
00635 if (nnoe) {
00636 fprintf(stdout,"\n(************************)\n");
00637 fprintf(stdout,"(* NOEUDS DU MAILLAGE : *)\n");
00638 fprintf(stdout,"(************************)\n\n");
00639 }
00640 if (!structure) {
00641 fprintf(stdout,"- Type de repere des coordonnees : %d \n",*rep);
00642 fprintf(stdout,"- Nom des coordonnees : \n");
00643 for (i=0;i<edim;i++) {
00644 strncpy(str,nomcoo+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
00645 str[MED_SNAME_SIZE] = '\0';
00646 fprintf(stdout," %s ",str);
00647 }
00648 fprintf(stdout,"\n- Unites des coordonnees : \n");
00649 for (i=0;i<edim;i++) {
00650 strncpy(str,unicoo+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
00651 str[MED_SNAME_SIZE] = '\0';
00652 fprintf(stdout," %s ",str);
00653 }
00654 fprintf(stdout,"\n- Coordonnees des noeuds : ");
00655 for (i=0;i<nnoe*edim;i++) {
00656 if (mode_coo == MED_FULL_INTERLACE && !(i % edim))
00657 fprintf(stdout,"\n [ %5"MED_IFORMAT" ] : ", (i/edim + 1) );
00658 if (mode_coo == MED_NO_INTERLACE && ! (i % nnoe))
00659 fprintf(stdout,"\n\n ");
00660 fprintf(stdout," %-+9.6f ",*(coo+i));
00661 }
00662
00663 if (inonoe) {
00664 fprintf(stdout,"\n- Noms des noeuds : \n");
00665 for (i=0;i<nnoe;i++) {
00666 strncpy(str,nomnoe+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
00667 str[MED_SNAME_SIZE] = '\0';
00668 fprintf(stdout," %s ",str);
00669 }
00670 }
00671 if (inunoe) {
00672 fprintf(stdout,"\n- Numeros des noeuds : \n");
00673 for (i=0;i<nnoe;i++)
00674 fprintf(stdout," "IFORMAT" ",*(numnoe+i));
00675 }
00676
00677 fprintf(stdout,"\n- Numeros des familles des noeuds : \n");
00678 for (i=0;i<nnoe;i++) {
00679 if (ifano)
00680 fprintf(stdout," "IFORMAT" ",*(nufano+i));
00681 else
00682 fprintf(stdout," %d ",0);
00683 }
00684 fprintf(stdout,"\n");
00685 }
00686
00687
00688
00689 free(coo);
00690 free(nomnoe);
00691 free(numnoe);
00692 free(nufano);
00693
00694 return;
00695 }
00696
00697
00698 med_int lecture_nombre_mailles_standards(const med_idt fid,
00699 const char * const nommaa,
00700 const med_int numdt,
00701 const med_int numit,
00702 const med_geometry_type typ_geo,
00703 const med_connectivity_mode typ_con,
00704 const int indice)
00705 {
00706
00707 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
00708
00709 med_int nmailles = MEDmeshnEntity(fid,nommaa,numdt,numit,
00710 MED_CELL,typ_geo,
00711 MED_CONNECTIVITY,typ_con,&chgt,&trsf);
00712 EXIT_IF(nmailles < 0," lors de la lecture du nombre de mailles",NULL);
00713
00714 if ( (indice < (MED_N_CELL_GEO_FIXED_CON-5) ) ||
00715 (indice >= (MED_N_CELL_GEO_FIXED_CON-5) && (nmailles > 0) ) )
00716 if (nmailles)
00717 fprintf (stdout,"- Nombre de mailles de type %s : "IFORMAT" \n",nommai[indice],
00718 nmailles);
00719
00720 return nmailles;
00721 }
00722
00723 med_int lecture_nombre_et_type_mailles_elstruct(const med_idt fid,
00724 const char * const nommaa,
00725 const med_int numdt,
00726 const med_int numit,
00727 const int indice,
00728 med_geometry_type* geotype,
00729 char* geotypename
00730 )
00731 {
00732 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
00733 med_err _ret=-1;
00734 med_int _nmailles=0;
00735
00736 _ret = MEDmeshEntityInfo(fid,nommaa,numdt,numit, MED_STRUCT_ELEMENT,
00737 indice+1,geotypename,geotype );
00738 EXIT_IF(_ret<0,
00739 "Erreur à la demande d'informations pour le type d'entités MED_STRUCT_ELEMENT",NULL);
00740
00741 _nmailles = MEDmeshnEntity(fid,nommaa,numdt,numit,
00742 MED_STRUCT_ELEMENT,*geotype,
00743 MED_CONNECTIVITY,MED_NODAL,&chgt,&trsf);
00744
00745 EXIT_IF(_nmailles < 0," lors de la lecture du nombre de mailles",NULL);
00746
00747 if (_nmailles)
00748 fprintf (stdout,"- Nombre de mailles de type %s : "IFORMAT" \n",geotypename, _nmailles);
00749
00750 return _nmailles;
00751 }
00752
00753 void lecture_mailles_elstruct(const med_idt fid,
00754 const char * const nommaa,
00755 const med_int numdt,
00756 const med_int numit,
00757 const med_int nmodels,
00758 const med_geometry_type* const geotype,
00759 const char* const geotypename,
00760 const med_int * const nmailles,
00761 const med_switch_mode mode_coo)
00762 {
00763 med_err _ret=-1;
00764 med_int taille=0;
00765 char str[MED_SNAME_SIZE+1];
00766
00767 med_int *connectivite;
00768 char *nomele;
00769 med_int *numele;
00770 med_int *nufael;
00771 med_bool inoele=MED_FALSE, inuele=MED_FALSE, inufael=MED_FALSE;
00772
00773 med_geometry_type _geotype=MED_NONE;
00774 med_int _elementdim=0;
00775 char _supportmeshname[MED_NAME_SIZE+1]="";
00776 med_entity_type _entitytype=MED_UNDEF_ENTITY_TYPE;
00777 med_int _nnode=0;
00778 med_int _ncell=0;
00779 med_entity_type _geocelltype=MED_NONE;
00780 med_int _nconstantatribute=0;
00781 med_bool _anyprofile=0;
00782 med_int _nvariableattribute=0;
00783
00784 char _attname[MED_NAME_SIZE+1]="";
00785 med_attribute_type _atttype;
00786 med_int _atttypesize=0;
00787 med_int _attvaluesize=0;
00788 med_int _nattcomp=0;
00789 void *_attvalue=NULL;
00790 void (*_printf)(const void*);
00791 int i=0,j=0,k=0;
00792 med_int dispbanner=MED_FALSE;
00793
00794 for (i=0; i<nmodels; i++ ) {
00795
00796 _ret = MEDstructElementInfoByName(fid, &geotypename[i*(MED_NAME_SIZE+1)],
00797 &_geotype,&_elementdim,
00798 _supportmeshname,&_entitytype,&_nnode,&_ncell,
00799 &_geocelltype,&_nconstantatribute,&_anyprofile,&_nvariableattribute);
00800
00801 if (_ncell > 0 )
00802 taille=_ncell*_geocelltype%100;
00803 else
00804 taille = _nnode;
00805
00806
00807
00808
00809
00810
00811
00812 connectivite = (med_int*) calloc(taille*nmailles[i],sizeof(med_int));
00813 EXIT_IF(connectivite == NULL,NULL,NULL);
00814 nomele = (char*) malloc(sizeof(char)*MED_SNAME_SIZE*nmailles[i]+1);
00815 EXIT_IF(nomele == NULL,NULL,NULL);
00816 numele = (med_int*) malloc(sizeof(med_int)*nmailles[i]);
00817 EXIT_IF(numele == NULL,NULL,NULL);
00818 nufael = (med_int*) malloc(sizeof(med_int)*nmailles[i]);
00819 EXIT_IF(nufael == NULL,NULL,NULL);
00820
00821
00822 _ret = MEDmeshElementRd( fid,nommaa,numdt,numit,MED_STRUCT_ELEMENT,geotype[i],
00823 MED_NODAL, mode_coo, connectivite,
00824 &inoele,nomele,&inuele,numele,&inufael,nufael );
00825
00826 EXIT_IF(_ret < 0,"lors de la lecture des mailles",NULL);
00827
00828
00829 if ( !dispbanner) {
00830 fprintf(stdout,"\n(***************************************)\n");
00831 fprintf(stdout, "(* ELEMENTS DE STRUCTURE DU MAILLAGE : *)\n");
00832 fprintf(stdout, "(***************************************)\n");
00833 dispbanner=MED_TRUE;
00834 }
00835 if (!structure) {
00836
00837 fprintf(stdout,"\n- Mailles de type %s : ", &geotypename[i*(MED_NAME_SIZE+1)]);
00838 if (strcmp(&geotypename[i*(MED_NAME_SIZE+1)],"MED_PARTICLE") ) {
00839 fprintf(stdout,"\n - Connectivité : ");
00840 for (j=0;j<nmailles[i]*taille;j++) {
00841 if (mode_coo == MED_FULL_INTERLACE && !(j % taille))
00842 fprintf(stdout,"\n [ %5"MED_IFORMAT" ] : ", (j/taille +1) );
00843 if (mode_coo == MED_NO_INTERLACE && !(j % nmailles[i]))
00844 fprintf(stdout,"\n");
00845 fprintf(stdout," %9"MED_IFORMAT" ",*(connectivite+j));
00846 }
00847 }
00848
00849 if (inoele) {
00850 fprintf(stdout,"\n - Noms : \n");
00851 for (j=0;j<nmailles[i];j++) {
00852 strncpy(str,nomele+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
00853 str[MED_SNAME_SIZE] = '\0';
00854 fprintf(stdout," %s ",str);
00855 }
00856 }
00857 if (inuele) {
00858 fprintf(stdout,"\n - Numeros :\n");
00859 for (j=0;j<nmailles[i];j++)
00860 fprintf(stdout," "IFORMAT" ",*(numele+j));
00861 }
00862 fprintf(stdout,"\n - Numéros de familles : \n");
00863 for (j=0;j<nmailles[i];j++)
00864 if (inufael)
00865 fprintf(stdout," "IFORMAT" ",*(nufael+j));
00866 else
00867 fprintf(stdout," %d ",0);
00868 fprintf(stdout,"\n");
00869 }
00870
00871
00872
00873 for (k=0; k<_nvariableattribute; k++) {
00874
00875
00876 _ret = MEDstructElementVarAttInfo(fid, &geotypename[i*(MED_NAME_SIZE+1)], k+1,
00877 _attname, &_atttype, &_nattcomp);
00878 EXIT_IF(_ret < 0,"lors de la lecture des caractéristiques de attributs variables",NULL);
00879
00880
00881
00882 EXIT_IF(_atttype == MED_ATT_UNDEF,"à la lecture du type (valeur : MED_ATT_UNDEF) de l'attribut variable ",_attname);
00883 _atttypesize = MEDstructElementAttSizeof(_atttype);
00884
00885 _attvaluesize = nmailles[i]*_nattcomp*_atttypesize;
00886 if ( _atttype == MED_ATT_NAME) ++_attvaluesize;
00887 _attvalue = (void *) malloc( _attvaluesize*sizeof(char));
00888 --_attvaluesize;
00889
00890
00891 _ret =MEDmeshStructElementVarAttRd(fid, nommaa, numdt, numit,
00892 *(geotype+i), _attname, _attvalue );
00893 if (_ret < 0 ) free(_attvalue);
00894 EXIT_IF(_ret < 0,"lors de la lecture des attributs variables",NULL);
00895
00896 _printf=MEDstructPrintFunction(_atttype);
00897
00898 if (!structure) {
00899 fprintf(stdout,"\n - Valeurs de l'attribut |%s| pour le type géométrique |%s| : \n",_attname,
00900 &geotypename[i*(MED_NAME_SIZE+1)]);
00901 for (j=0;j<nmailles[i]*_nattcomp;j++) {
00902 if ( ( _nattcomp > 1 ) && !(j % _nattcomp) )
00903 fprintf(stdout,"\n [ %5"MED_IFORMAT" ] : ", (j/_nattcomp +1) );
00904 _printf( (void *)( (char *)(_attvalue) + j*_atttypesize) );
00905 }
00906 }
00907
00908 free(_attvalue);
00909
00910 }
00911
00912
00913 free(connectivite);
00914 free(nomele);
00915 free(numele);
00916 free(nufael);
00917 }
00918
00919 return;
00920 }
00921
00922 void lecture_mailles_standards(const med_idt fid,
00923 const char *nommaa,
00924 const med_int numdt,
00925 const med_int numit,
00926 const med_int mdim,
00927 const med_int * const nmailles,
00928 const med_switch_mode mode_coo,
00929 const med_connectivity_mode typ_con)
00930 {
00931 med_int taille;
00932 med_int *connectivite;
00933 char *nomele;
00934 med_int *numele;
00935 med_int *nufael;
00936 med_bool inoele=MED_FALSE, inuele=MED_FALSE, inufael=MED_FALSE;
00937 med_int entdim;
00938 med_int nnodes;
00939 med_int nndes;
00940 med_int i,j;
00941 med_err ret = 0;
00942 char str[MED_SNAME_SIZE+1];
00943 med_int dispbanner=MED_FALSE;
00944
00945
00946 for (i=0;i<MED_N_CELL_GEO_FIXED_CON;i++)
00947 if (nmailles[i] > 0) {
00948
00949 ret=_MEDgetGeometricParameter(MED_CELL, typmai[i],&entdim,&nnodes,&nndes);
00950 EXIT_IF(ret < 0,"lors de la lecture des caractéristiques des mailles",NULL);
00951
00952 switch(typ_con) {
00953 case MED_NODAL :
00954 taille = nnodes;
00955 break;
00956
00957 case MED_DESCENDING :
00958 taille = nndes;
00959 break;
00960
00961 default :
00962 ret = -1;
00963 }
00964
00965
00966 connectivite = (med_int*) malloc(sizeof(med_int)*taille*nmailles[i]);
00967 EXIT_IF(connectivite == NULL,NULL,NULL);
00968 nomele = (char*) malloc(sizeof(char)*MED_SNAME_SIZE*nmailles[i]+1);
00969 EXIT_IF(nomele == NULL,NULL,NULL);
00970 numele = (med_int*) malloc(sizeof(med_int)*nmailles[i]);
00971 EXIT_IF(numele == NULL,NULL,NULL);
00972 nufael = (med_int*) malloc(sizeof(med_int)*nmailles[i]);
00973 EXIT_IF(nufael == NULL,NULL,NULL);
00974
00975
00976 ret = MEDmeshElementRd( fid,nommaa,numdt,numit,MED_CELL,typmai[i],
00977 typ_con, mode_coo, connectivite,
00978 &inoele,nomele,&inuele,numele,&inufael,nufael );
00979
00980 EXIT_IF(ret < 0,"lors de la lecture des mailles",NULL);
00981
00982 if ( !dispbanner) {
00983 fprintf(stdout,"\n(**************************)\n");
00984 fprintf(stdout,"(* ELEMENTS DU MAILLAGE : *)\n");
00985 fprintf(stdout,"(**************************)\n");
00986 dispbanner=MED_TRUE;
00987 }
00988 if (!structure) {
00989
00990 fprintf(stdout,"\n- Mailles de type %s : ", nommai[i]);
00991 fprintf(stdout,"\n - Connectivité : ");
00992 for (j=0;j<nmailles[i]*taille;j++) {
00993 if (mode_coo == MED_FULL_INTERLACE && !(j % taille))
00994 fprintf(stdout,"\n [ %5"MED_IFORMAT" ] : ", (j/taille +1) );
00995 if (mode_coo == MED_NO_INTERLACE && !(j % nmailles[i]))
00996 fprintf(stdout,"\n");
00997 fprintf(stdout," %9"MED_IFORMAT" ",*(connectivite+j));
00998 }
00999
01000 if (inoele) {
01001 fprintf(stdout,"\n - Noms : \n");
01002 for (j=0;j<nmailles[i];j++) {
01003 strncpy(str,nomele+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
01004 str[MED_SNAME_SIZE] = '\0';
01005 fprintf(stdout," %s ",str);
01006 }
01007 }
01008 if (inuele) {
01009 fprintf(stdout,"\n - Numeros :\n");
01010 for (j=0;j<nmailles[i];j++)
01011 fprintf(stdout," "IFORMAT" ",*(numele+j));
01012 }
01013 fprintf(stdout,"\n - Numéros de familles : \n");
01014 for (j=0;j<nmailles[i];j++)
01015 if (inufael)
01016 fprintf(stdout," "IFORMAT" ",*(nufael+j));
01017 else
01018 fprintf(stdout," %d ",0);
01019 fprintf(stdout,"\n");
01020 }
01021
01022
01023 free(connectivite);
01024 free(nomele);
01025 free(numele);
01026 free(nufael);
01027 }
01028
01029 return;
01030 }
01031
01032
01033 med_int lecture_nombre_mailles_polygones(const med_idt fid,
01034 const char * const nommaa,
01035 const med_int numdt,
01036 const med_int numit,
01037 const med_geometry_type polytype,
01038 const med_connectivity_mode typ_con)
01039 {
01040
01041 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01042 char polytypename[MED_NAME_SIZE+1]="Undefined GeoType";
01043 med_int nmpolygones;
01044
01045 EXIT_IF( (( polytype != MED_POLYGON) &&
01046 ( polytype != MED_POLYGON2) ),
01047 MED_ERR_RANGE_MSG, MED_ERR_GEOMETRIC_MSG);
01048
01049
01050 nmpolygones = MEDmeshnEntity(fid,nommaa,numdt,numit,
01051 MED_CELL,polytype,
01052 MED_INDEX_NODE,typ_con,&chgt,&trsf);
01053
01054 EXIT_IF(nmpolygones < 0,"lors de la lecture du nombre de mailles polygone\n",
01055 NULL);
01056 if (nmpolygones > 0 ) nmpolygones--; else nmpolygones=0;
01057 if (nmpolygones) {
01058 MEDmeshGeotypeName(fid,polytype,polytypename);
01059 fprintf(stdout,"- Nombre de mailles de type %s : "IFORMAT" \n",
01060 polytypename,nmpolygones);
01061 }
01062 polytypename[0]='\0';
01063 return nmpolygones;
01064 }
01065
01066 void lecture_mailles_polygones(const med_idt fid,
01067 const char * const nommaa,
01068 const med_int numdt,
01069 const med_int numit,
01070 const med_geometry_type polytype,
01071 const med_int nmpolygones,
01072 const med_switch_mode mode_coo,
01073 const med_connectivity_mode typ_con)
01074 {
01075 med_int i,j;
01076 med_err ret = 0;
01077 med_int taille;
01078 med_int *connectivite;
01079 char *nomele;
01080 med_int *numele;
01081 med_int *nufael;
01082 med_int *indexp;
01083 int ind1,ind2;
01084 char tmp[MED_NAME_SIZE+1];
01085 med_err ret1,ret2,ret3;
01086 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01087 char polytypename[MED_NAME_SIZE+1]="Undefined GeoType";
01088
01089 EXIT_IF( (( polytype != MED_POLYGON) &&
01090 ( polytype != MED_POLYGON2) ),
01091 MED_ERR_RANGE_MSG, MED_ERR_GEOMETRIC_MSG);
01092
01093
01094
01095
01096 taille=MEDmeshnEntity(fid,nommaa,numdt,numit,
01097 MED_CELL,polytype,MED_CONNECTIVITY,typ_con,
01098 &chgt,&trsf);
01099 EXIT_IF(taille < 0,"lors de la lecture des parametres des mailles polygones",
01100 NULL);
01101
01102
01103 indexp = (med_int *) malloc(sizeof(med_int)*(nmpolygones+1));
01104 EXIT_IF(indexp == NULL,NULL,NULL);
01105 connectivite = (med_int *) malloc(sizeof(med_int)*taille);
01106 EXIT_IF(connectivite == NULL,NULL,NULL);
01107 numele = (med_int *) malloc(sizeof(med_int)*nmpolygones);
01108 EXIT_IF(numele == NULL,NULL,NULL);
01109 nufael = (med_int *) malloc(sizeof(med_int)*nmpolygones);
01110 EXIT_IF(nufael == NULL,NULL,NULL);
01111 nomele = (char *) malloc(sizeof(char)*MED_SNAME_SIZE*nmpolygones+1);
01112 EXIT_IF(nomele == NULL,NULL,NULL);
01113
01114
01115 ret = MEDmeshPolygon2Rd(fid,nommaa,numdt,numit,MED_CELL,polytype,typ_con,
01116 indexp,connectivite);
01117
01118 EXIT_IF(ret < 0,"lors de la lecture des connectivites des mailles polygones",
01119 NULL);
01120
01121
01122 ret1 = MEDmeshEntityNameRd(fid,nommaa,numdt,numit,
01123 MED_CELL,polytype, nomele);
01124
01125
01126 ret2 = (med_int) MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,
01127 MED_CELL, polytype, numele);
01128
01129
01130 ret3 = MEDmeshEntityFamilyNumberRd(fid, nommaa, MED_NO_DT, MED_NO_IT,
01131 MED_CELL, polytype, nufael);
01132
01133 if (!structure) {
01134
01135 MEDmeshGeotypeName(fid,polytype,polytypename);
01136 fprintf(stdout,"\n\n- Mailles de type %s : ",polytypename);
01137 for (i=0;i<nmpolygones;i++) {
01138 fprintf(stdout,"\n >> Maille MED_POLYGONE "IFORMAT" : \n",i+1);
01139 fprintf(stdout,"\n - Connectivité : ");
01140 ind1 = *(indexp+i)-1;
01141 ind2 = *(indexp+i+1)-1;
01142 for (j=ind1;j<ind2;j++)
01143 printf(" "IFORMAT" ",*(connectivite+j));
01144 if (ret1 == 0) {
01145 strncpy(tmp,nomele+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
01146 tmp[MED_SNAME_SIZE] = '\0';
01147 fprintf(stdout,"\n - Nom : %s \n",tmp);
01148 }
01149 if (ret2 == 0)
01150 fprintf(stdout,"\n - Numero : "IFORMAT" \n",*(numele+i));
01151
01152 if ( ret3 >= 0 )
01153 fprintf(stdout,"\n - Numéro de famille : "IFORMAT" \n",*(nufael+i));
01154 else
01155 fprintf(stdout,"\n - Numéro de famille : %d \n",0);
01156 }
01157 polytypename[0]='\0';
01158 }
01159
01160
01161 free(indexp);
01162 free(connectivite);
01163 free(numele);
01164 free(nufael);
01165 free(nomele);
01166
01167 return;
01168 }
01169
01170
01171 med_int lecture_nombre_mailles_polyedres(const med_idt fid,
01172 const char * const nommaa,
01173 const med_int numdt,
01174 const med_int numit,
01175 const med_connectivity_mode typ_con)
01176 {
01177 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01178
01179 med_int npolyedres = MEDmeshnEntity(fid,nommaa,numdt,numit,
01180 MED_CELL,MED_POLYHEDRON,
01181 MED_INDEX_FACE,typ_con,&chgt,&trsf);
01182
01183 EXIT_IF(npolyedres < 0,"lors de la lecture du nombre de mailles polyedre \n",
01184 NULL);
01185 if ( npolyedres > 0 ) npolyedres--; else npolyedres=0;
01186 if (npolyedres)
01187 fprintf(stdout,"- Nombre de mailles de type MED_POLYEDRE : "IFORMAT" \n",
01188 npolyedres);
01189
01190 return npolyedres;
01191 }
01192
01193
01194 void lecture_mailles_polyedres(const med_idt fid,
01195 const char * const nommaa,
01196 const med_int numdt,
01197 const med_int numit,
01198 const med_int npolyedres,
01199 const med_switch_mode mode_coo,
01200 const med_connectivity_mode typ_con)
01201 {
01202 med_int i,j,k;
01203 med_err ret = 0;
01204 med_int taille;
01205 med_int *connectivite;
01206 char *nomele;
01207 med_int *numele;
01208 med_int *nufael;
01209 med_int *indexf, *indexn;
01210 int ind1,ind2;
01211 char tmp[MED_SNAME_SIZE+1];
01212 med_err ret1,ret2,ret3;
01213 med_int nfa;
01214 med_int nnoe;
01215 med_int nindn;
01216 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01217
01218
01219
01220 taille = MEDmeshnEntity(fid,nommaa,numdt,numit,
01221 MED_CELL,MED_POLYHEDRON,MED_CONNECTIVITY,typ_con,
01222 &chgt,&trsf);
01223 EXIT_IF(taille < 0,"lors de la lecture des parametres des mailles polyedres",
01224 NULL);
01225
01226 nindn = MEDmeshnEntity(fid,nommaa,numdt,numit,
01227 MED_CELL,MED_POLYHEDRON,MED_INDEX_NODE,typ_con,
01228 &chgt,&trsf);
01229 EXIT_IF(nindn < 0,"lors de la lecture des parametres des mailles polyedres",
01230 NULL);
01231
01232
01233
01234 indexf = (med_int *) malloc(sizeof(med_int)*(npolyedres+1));
01235 EXIT_IF(indexf == NULL,NULL,NULL);
01236 indexn = (med_int *) malloc(sizeof(med_int)*nindn);
01237 EXIT_IF(indexn == NULL,NULL,NULL);
01238 connectivite = (med_int *) malloc(sizeof(med_int)*taille);
01239 EXIT_IF(connectivite == NULL,NULL,NULL);
01240 numele = (med_int *) malloc(sizeof(med_int)*npolyedres);
01241 EXIT_IF(numele == NULL,NULL,NULL);
01242 nufael = (med_int *) malloc(sizeof(med_int)*npolyedres);
01243 EXIT_IF(nufael == NULL,NULL,NULL);
01244 nomele = (char *) malloc(sizeof(char)*MED_SNAME_SIZE*npolyedres+1);
01245 EXIT_IF(nomele == NULL,NULL,NULL);
01246
01247 ret = MEDmeshPolyhedronRd(fid,nommaa,numdt,numit,MED_CELL,typ_con,
01248 indexf,indexn,connectivite);
01249 EXIT_IF(ret < 0,
01250 "lors de la lecture de la connectivite des mailles polyedres",
01251 NULL);
01252
01253
01254 ret1 = MEDmeshEntityNameRd(fid,nommaa,numdt,numit,MED_CELL,MED_POLYHEDRON,nomele);
01255
01256
01257 ret2 = MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,MED_CELL,MED_POLYHEDRON,numele);
01258
01259
01260 ret3 = MEDmeshEntityFamilyNumberRd(fid,nommaa,numdt,numit,MED_CELL,MED_POLYHEDRON,nufael);
01261
01262 if (!structure) {
01263
01264 fprintf(stdout,"\n\n- Mailles de type MED_POLYEDRE : ");
01265 for (i=0;i<npolyedres;i++) {
01266 fprintf(stdout,"\n >> Maille MED_POLYEDRE "IFORMAT" : \n",i+1);
01267 fprintf(stdout,"\n - Connectivité : \n");
01268 nfa = *(indexf+i+1) - *(indexf+i);
01269
01270 ind1 = *(indexf+i) - 1;
01271 for (j=0;j<nfa;j++) {
01272 if (typ_con == MED_NODAL) {
01273
01274
01275 ind2 = *(indexn+ind1+j) - 1;
01276 nnoe = *(indexn+ind1+j+1) - *(indexn+ind1+j);
01277 fprintf(stdout," - Face "IFORMAT" : [ ", j+1);
01278 for (k=0;k<nnoe;k++)
01279 printf(" "IFORMAT" ",*(connectivite+ind2+k));
01280 printf(" ] \n");
01281 }
01282 else {
01283 nfa = *(indexf+i+1) - *(indexf+i);
01284
01285
01286 ind1 = *(indexf+i) - 1;
01287 for (j=0;j<nfa;j++)
01288 fprintf(stdout," - Face "IFORMAT" de numero : "IFORMAT" et de type "IFORMAT" \n", j+1,
01289 *(connectivite+ind1+j),*(indexn+ind1+j));
01290 }
01291 }
01292 if (ret1 == 0) {
01293 strncpy(tmp,nomele+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
01294 tmp[MED_SNAME_SIZE] = '\0';
01295 fprintf(stdout,"\n - Nom : %s \n",tmp);
01296 }
01297 if (ret2 == 0)
01298 fprintf(stdout,"\n - Numero : "IFORMAT" \n",*(numele+i));
01299 if (ret3 >= 0)
01300 fprintf(stdout,"\n - Numéro de famille : "IFORMAT" \n",*(nufael+i));
01301 else
01302 fprintf(stdout,"\n - Numéro de famille : %d \n",0);
01303
01304 }
01305 }
01306
01307
01308 free(indexf);
01309 free(indexn);
01310 free(connectivite);
01311 free(numele);
01312 free(nufael);
01313 free(nomele);
01314
01315 return;
01316 }
01317
01318 med_int lecture_nombre_faces_standards(const med_idt fid,
01319 const char * const nommaa,
01320 const med_int numdt,
01321 const med_int numit,
01322 const med_geometry_type typ_geo,
01323 const med_int indice
01324 )
01325 {
01326
01327 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01328
01329 med_int nfaces = MEDmeshnEntity(fid,nommaa,numdt,numit,
01330 MED_DESCENDING_FACE,typ_geo,
01331 MED_CONNECTIVITY,MED_DESCENDING,&chgt,&trsf);
01332 EXIT_IF(nfaces < 0,"lors de la lecture du nombre de faces",NULL);
01333
01334 if ( (indice < (MED_N_FACE_GEO_FIXED_CON-2) ) ||
01335 (indice >= (MED_N_FACE_GEO_FIXED_CON-2) && (nfaces > 0) ) )
01336 if (nfaces)
01337 fprintf (stdout,"- Nombre de faces de type %s : "IFORMAT" \n",
01338 nomfac[indice],nfaces);
01339
01340 return nfaces;
01341 }
01342
01343 void lecture_faces_standard(const med_idt fid,
01344 const char * const nommaa,
01345 const med_int numdt,
01346 const med_int numit,
01347 const med_int mdim,
01348 const med_int *const nfaces,
01349 const med_switch_mode mode_coo)
01350 {
01351 med_int taille;
01352 med_int *connectivite;
01353 char *nomele;
01354 med_int *numele;
01355 med_int *nufael;
01356 med_bool inoele,inuele,inufael;
01357 med_int i,j;
01358 med_err ret = 0;
01359 char str[MED_SNAME_SIZE+1];
01360 med_int entdim;
01361 med_int nnodes;
01362
01363 for (i=0;i<MED_N_FACE_GEO_FIXED_CON;i++)
01364 if (nfaces[i] > 0 ) {
01365
01366
01367 ret=_MEDgetGeometricParameter(MED_DESCENDING_FACE, typfac[i],&entdim,&nnodes,&taille);
01368 EXIT_IF(ret < 0,"lors de la lecture des caractéristiques des mailles",NULL);
01369
01370
01371 connectivite = (med_int*)malloc(sizeof(med_int)*taille*nfaces[i]);
01372 EXIT_IF(connectivite == NULL,NULL,NULL);
01373 nomele = (char*)malloc(sizeof(char)*MED_SNAME_SIZE*nfaces[i]+1);
01374 EXIT_IF(nomele == NULL,NULL,NULL);
01375 numele = (med_int*)malloc(sizeof(med_int)*nfaces[i]);
01376 EXIT_IF(numele == NULL,NULL,NULL);
01377 nufael = (med_int*)malloc(sizeof(med_int)*nfaces[i]);
01378 EXIT_IF(nufael == NULL,NULL,NULL);
01379
01380
01381 ret = MEDmeshElementRd( fid,nommaa,numdt,numit,MED_DESCENDING_FACE,typmai[i],
01382 MED_DESCENDING, mode_coo, connectivite,
01383 &inoele,nomele,&inuele,numele,&inufael,nufael );
01384 EXIT_IF(ret < 0,"lors de la lecture des faces",NULL);
01385
01386 if (!structure) {
01387
01388 fprintf(stdout,"\n- Faces de type %s : ", nomfac[i]);
01389 fprintf(stdout,"\n - Connectivité : ");
01390 for (j=0;j<nfaces[i]*taille;j++) {
01391 if (mode_coo == MED_FULL_INTERLACE && !(j % taille))
01392 fprintf(stdout,"\n [ %5"MED_IFORMAT" ] : ", (j/taille+1) );
01393 if (mode_coo == MED_NO_INTERLACE && !(j % nfaces[i]))
01394 fprintf(stdout,"\n");
01395 fprintf(stdout," %9"MED_IFORMAT" ",*(connectivite+j));
01396 }
01397
01398 if (inoele) {
01399 fprintf(stdout,"\n - Noms : \n");
01400 for (j=0;j<nfaces[i];j++) {
01401 strncpy(str,nomele+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
01402 str[MED_SNAME_SIZE] = '\0';
01403 fprintf(stdout," %s ",str);
01404 }
01405 }
01406 if (inuele) {
01407 fprintf(stdout,"\n - Numeros :\n");
01408 for (j=0;j<nfaces[i];j++)
01409 fprintf(stdout," "IFORMAT" ",*(numele+j));
01410 }
01411 fprintf(stdout,"\n - Numéros de familles : \n");
01412 for (j=0;j<nfaces[i];j++)
01413 if ( inufael )
01414 fprintf(stdout," "IFORMAT" ",*(nufael+j));
01415 else
01416 fprintf(stdout," %d ",0);
01417 }
01418
01419
01420 free(connectivite);
01421 free(nomele);
01422 free(numele);
01423 free(nufael);
01424 }
01425
01426 return;
01427 }
01428
01429 med_int lecture_nombre_faces_polygones(const med_idt fid,
01430 const char * const nommaa,
01431 const med_int numdt,
01432 const med_int numit)
01433 {
01434
01435 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01436
01437 med_int nfpolygones = MEDmeshnEntity(fid,nommaa,numdt,numit,
01438 MED_CELL,MED_POLYGON,
01439 MED_INDEX_NODE,MED_DESCENDING,&chgt,&trsf);
01440
01441 EXIT_IF(nfpolygones < 0,"lors de la lecture du nombre de faces polygone \n",
01442 NULL);
01443 if (nfpolygones > 0 ) nfpolygones--; else nfpolygones=0;
01444 if (nfpolygones)
01445 fprintf(stdout,"- Nombre de faces de type MED_POLYGONE : "IFORMAT" \n",
01446 nfpolygones);
01447
01448 return nfpolygones;
01449 }
01450
01451 void lecture_faces_polygones(const med_idt fid,
01452 const char * const nommaa,
01453 const med_int numdt,
01454 const med_int numit,
01455 const med_int nfpolygones,
01456 const med_switch_mode mode_coo)
01457 {
01458 med_int i,j;
01459 med_err ret = 0;
01460 char *nomele;
01461 med_int *numele;
01462 med_int *nufael;
01463 med_int *connectivite;
01464 med_int taille;
01465 med_int *indexp;
01466 int ind1,ind2;
01467 char tmp[MED_NAME_SIZE+1];
01468 med_err ret1,ret2,ret3;
01469 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01470
01471
01472 taille=MEDmeshnEntity(fid,nommaa,numdt,numit,
01473 MED_DESCENDING_FACE,MED_POLYGON,MED_CONNECTIVITY,MED_DESCENDING,
01474 &chgt,&trsf);
01475 EXIT_IF(taille < 0,"lors de la lecture des parametres des faces polygones",
01476 NULL);
01477
01478
01479 indexp = (med_int *) malloc(sizeof(med_int)*(nfpolygones+1));
01480 EXIT_IF(indexp == NULL,NULL,NULL);
01481 connectivite = (med_int *) malloc(sizeof(med_int)*taille);
01482 EXIT_IF(connectivite == NULL,NULL,NULL);
01483 numele = (med_int *) malloc(sizeof(med_int)*nfpolygones);
01484 EXIT_IF(numele == NULL,NULL,NULL);
01485 nufael = (med_int *) malloc(sizeof(med_int)*nfpolygones);
01486 EXIT_IF(nufael == NULL,NULL,NULL);
01487 nomele = (char *) malloc(sizeof(char)*MED_SNAME_SIZE*nfpolygones+1);
01488 EXIT_IF(nomele == NULL,NULL,NULL);
01489
01490
01491 ret = MEDmeshPolygonRd(fid,nommaa,numdt,numit,MED_DESCENDING_FACE,MED_DESCENDING,
01492 indexp,connectivite);
01493 EXIT_IF(ret < 0,"lors de la lecture des connectivites des faces polygones", NULL);
01494
01495
01496 ret1 = MEDmeshEntityNameRd(fid,nommaa,numdt,numit,
01497 MED_DESCENDING_FACE,MED_POLYGON, nomele);
01498
01499
01500 ret2 = (med_int) MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,
01501 MED_DESCENDING_FACE, MED_POLYGON, numele);
01502
01503
01504 ret3 = MEDmeshEntityFamilyNumberRd(fid, nommaa, MED_NO_DT, MED_NO_IT,
01505 MED_DESCENDING_FACE, MED_POLYGON, nufael);
01506
01507 if (!structure) {
01508
01509 fprintf(stdout,"\n\n- Faces de type MED_POLYGONE : ");
01510 for (i=0;i<nfpolygones;i++) {
01511 fprintf(stdout,"\n >> Face MED_POLYGONE "IFORMAT" : \n",i+1);
01512 fprintf(stdout,"\n - Connectivité : ");
01513 ind1 = *(indexp+i)-1;
01514 ind2 = *(indexp+i+1)-1;
01515 for (j=ind1;j<ind2;j++)
01516 fprintf(stdout," "IFORMAT" ",*(connectivite+j));
01517 if (ret1 == 0) {
01518 strncpy(tmp,nomele+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
01519 tmp[MED_SNAME_SIZE] = '\0';
01520 fprintf(stdout,"\n - Nom : %s \n",tmp);
01521 }
01522 if (ret2 == 0)
01523 fprintf(stdout,"\n - Numero : "IFORMAT" \n",*(numele+j));
01524 if ( ret3 > 0 )
01525 fprintf(stdout,"\n - Numéro de famille : "IFORMAT" \n",*(nufael+i));
01526 else
01527 fprintf(stdout,"\n - Numéro de famille : %d \n",0);
01528 }
01529 }
01530
01531
01532 free(indexp);
01533 free(connectivite);
01534 free(numele);
01535 free(nufael);
01536 free(nomele);
01537
01538 return;
01539 }
01540
01541
01542 med_int lecture_nombre_aretes_standards(const med_idt fid,
01543 const char *const nommaa,
01544 const med_int numdt,
01545 const med_int numit,
01546 const med_geometry_type typ_geo,
01547 const med_int indice)
01548 {
01549
01550 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01551
01552 med_int naretes = MEDmeshnEntity(fid,nommaa,numdt,numit,
01553 MED_DESCENDING_EDGE, typ_geo,
01554 MED_CONNECTIVITY,MED_DESCENDING,&chgt,&trsf);
01555 EXIT_IF(naretes < 0,"lors de la lecture du nombre d'aretes",NULL);
01556 if ( (indice < (MED_N_EDGE_GEO_FIXED_CON-1) ) ||
01557 (indice >= (MED_N_EDGE_GEO_FIXED_CON-1) && (naretes > 0) ) )
01558 if (naretes)
01559 fprintf (stdout,
01560 "- Nombre d'aretes de type %s : "IFORMAT" \n",nomare[indice],naretes);
01561
01562 return naretes;
01563 }
01564
01565 void lecture_aretes_standards(const med_idt fid,
01566 const char * const nommaa,
01567 const med_int numdt,
01568 const med_int numit,
01569 const med_int mdim,
01570 const med_int * const naretes,
01571 const med_switch_mode mode_coo)
01572 {
01573 med_int taille;
01574 med_int *connectivite;
01575 char *nomele;
01576 med_int *numele;
01577 med_int *nufael;
01578 med_bool inoele,inuele,inufael;
01579 med_int i,j;
01580 med_err ret = 0;
01581 char str[MED_SNAME_SIZE+1];
01582 med_int entdim;
01583 med_int nnodes;
01584
01585 for (i=0;i<MED_N_EDGE_GEO_FIXED_CON;i++)
01586 if (naretes[i] > 0) {
01587
01588 ret=_MEDgetGeometricParameter(MED_DESCENDING_EDGE, typare[i],&entdim,&nnodes,&taille);
01589 EXIT_IF(ret < 0,"lors de la lecture des caractéristiques des mailles",NULL);
01590
01591
01592 connectivite = (med_int*)malloc(sizeof(med_int)*taille*naretes[i]);
01593 EXIT_IF(connectivite == NULL,NULL,NULL);
01594 nomele = (char*)malloc(sizeof(char)*MED_SNAME_SIZE*naretes[i]+1);
01595 EXIT_IF(nomele == NULL,NULL,NULL);
01596 numele = (med_int*)malloc(sizeof(med_int)*naretes[i]);
01597 EXIT_IF(numele == NULL,NULL,NULL);
01598 nufael = (med_int*)malloc(sizeof(med_int)*naretes[i]);
01599 EXIT_IF(nufael == NULL,NULL,NULL);
01600
01601
01602 ret = MEDmeshElementRd( fid,nommaa,numdt,numit,MED_DESCENDING_EDGE,typare[i],
01603 MED_DESCENDING, mode_coo, connectivite,
01604 &inoele,nomele,&inuele,numele,&inufael,nufael );
01605 EXIT_IF(ret < 0,"lors de la lecture des aretes",
01606 NULL);
01607
01608 if (!structure) {
01609
01610 fprintf(stdout,"\n- Aretes de type %s : ", nomare[i]);
01611 fprintf(stdout,"\n - Connectivité : ");
01612 for (j=0;j<naretes[i]*taille;j++) {
01613 if (mode_coo == MED_FULL_INTERLACE && !(j % taille))
01614 fprintf(stdout,"\n [ %5"MED_IFORMAT" ] : ", (j/taille+1) );
01615 if (mode_coo == MED_NO_INTERLACE && !(j % naretes[i]))
01616 fprintf(stdout,"\n");
01617 fprintf(stdout," %9"MED_IFORMAT" ",*(connectivite+j));
01618 }
01619
01620 if (inoele) {
01621 fprintf(stdout,"\n - Noms : \n");
01622 for (j=0;j<naretes[i];j++) {
01623 strncpy(str,nomele+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
01624 str[MED_SNAME_SIZE] = '\0';
01625 fprintf(stdout," %s ",str);
01626 }
01627 }
01628 if (inuele) {
01629 fprintf(stdout,"\n - Numeros :\n");
01630 for (j=0;j<naretes[i];j++)
01631 fprintf(stdout," "IFORMAT" ",*(numele+j));
01632 }
01633 fprintf(stdout,"\n - Numéros de familles : \n");
01634 for (j=0;j<naretes[i];j++)
01635 if ( inufael )
01636 fprintf(stdout," "IFORMAT" ",*(nufael+j));
01637 else
01638 fprintf(stdout," %d ",0);
01639 }
01640
01641
01642 free(connectivite);
01643 free(nomele);
01644 free(numele);
01645 free(nufael);
01646 }
01647
01648 return;
01649 }
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668 void lecture_maillage_non_structure(med_idt fid,
01669 const char *nommaa,
01670 const med_int numdt,
01671 const med_int numit,
01672 const med_int mdim,
01673 const med_int edim,
01674 const med_switch_mode mode_coo,
01675 const med_connectivity_mode typ_con,
01676 const char * const nomcoo,
01677 const char * const unicoo,
01678 const med_axis_type *const rep,
01679 med_int* nmodels,
01680 med_geometry_type** geotype_elst,
01681 char** geotypename_elst,
01682 const int lecture_en_tete_seulement)
01683 {
01684 med_int i;
01685
01686 med_int nnoe;
01687 med_int nmailles[MED_N_CELL_GEO_FIXED_CON];
01688 med_int nfaces[MED_N_FACE_GEO_FIXED_CON];
01689 med_int naretes[MED_N_EDGE_GEO_FIXED_CON];
01690
01691 med_int nmpolygones,nmpolygones2, npolyedres, nfpolygones;
01692
01693 med_int nfam;
01694
01695 med_int nequ;
01696
01697 med_int njnt;
01698
01699 med_int _nmodels=0,*_nmailles_elst = NULL;
01700 med_geometry_type *_geotype_elst = NULL;
01701 char *_geotypename_elst = NULL;
01702 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01703
01704
01705 nnoe = lecture_nombre_noeuds_maillage_non_structure(fid,nommaa,numdt,numit);
01706
01707
01708 _nmodels = MEDmeshnEntity(fid,nommaa,numdt,numit,
01709 MED_STRUCT_ELEMENT,MED_GEO_ALL,MED_CONNECTIVITY,MED_GLOBAL_PFLMODE,
01710 &chgt,&trsf);
01711 EXIT_IF(_nmodels<0,
01712 "Erreur à la lecture du nombre de type géométrique pour le type d'entités MED_STRUCT_ELEMENT",NULL);
01713
01714 _nmailles_elst = (med_int *) malloc(_nmodels*sizeof(med_int));
01715 _geotype_elst = (med_geometry_type *) malloc(_nmodels*sizeof(med_geometry_type));
01716 _geotypename_elst = (char *) malloc(_nmodels*sizeof(char)*(MED_NAME_SIZE+1));
01717
01718 for (i=0; i < _nmodels; i++) {
01719 _nmailles_elst[i]=lecture_nombre_et_type_mailles_elstruct(fid,nommaa,numdt,numit,i,
01720 &_geotype_elst[i],&_geotypename_elst[i*(MED_NAME_SIZE+1)]);
01721 }
01722 if (_nmodels) {
01723 *nmodels = _nmodels;
01724 *geotype_elst = _geotype_elst;
01725 *geotypename_elst = _geotypename_elst;
01726 } else *nmodels=0;
01727
01728
01729
01730 for (i=0;i<MED_N_CELL_GEO_FIXED_CON;i++)
01731 nmailles[i] = lecture_nombre_mailles_standards(fid,nommaa,numdt,numit,typmai[i],
01732 typ_con,i);
01733
01734
01735 nmpolygones = lecture_nombre_mailles_polygones(fid,nommaa,numdt,numit,MED_POLYGON,typ_con);
01736
01737
01738 nmpolygones2 = lecture_nombre_mailles_polygones(fid,nommaa,numdt,numit,MED_POLYGON2,typ_con);
01739
01740
01741 npolyedres = lecture_nombre_mailles_polyedres(fid,nommaa,numdt,numit,typ_con);
01742
01743
01744 if (typ_con == MED_DESCENDING) {
01745
01746
01747 for (i=0;i<MED_N_FACE_GEO_FIXED_CON;i++)
01748 nfaces[i] = lecture_nombre_faces_standards(fid,nommaa,numdt,numit,typfac[i],i);
01749
01750
01751 nfpolygones = lecture_nombre_faces_polygones(fid,nommaa,numdt,numit);
01752
01753
01754 for (i=0;i<MED_N_EDGE_GEO_FIXED_CON;i++)
01755 naretes[i] = lecture_nombre_aretes_standards(fid,nommaa,numdt,numit,typare[i],i);
01756 }
01757
01758 if (lecture_en_tete_seulement != MED_LECTURE_MAILLAGE_SUPPORT_UNIQUEMENT) {
01759
01760 nfam = lecture_nombre_famille(fid,nommaa);
01761
01762
01763 nequ = lecture_nombre_equivalence(fid,nommaa);
01764
01765
01766 njnt = lecture_nombre_joint(fid,nommaa);
01767 }
01768
01769
01770 if (lecture_en_tete_seulement == MED_LECTURE_ENTETE_SEULEMENT) {
01771
01772
01773
01774
01775
01776 return;
01777 }
01778
01779
01780
01781 lecture_noeuds_maillage_non_structure(fid,nommaa,numdt,numit,mdim,edim,nnoe,mode_coo,nomcoo,unicoo,rep);
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798 lecture_mailles_standards(fid,nommaa,numdt,numit,mdim,nmailles,mode_coo,typ_con);
01799
01800
01801 if (lecture_en_tete_seulement == MED_LECTURE_MAILLAGE_SUPPORT_UNIQUEMENT) return;
01802
01803 if (_nmodels>0) {
01804 lecture_mailles_elstruct(fid,nommaa,numdt,numit,_nmodels,
01805 _geotype_elst,_geotypename_elst,_nmailles_elst,mode_coo);
01806
01807
01808
01809
01810
01811 }
01812
01813
01814 if (nmpolygones > 0)
01815 lecture_mailles_polygones(fid,nommaa,numdt,numit,MED_POLYGON,nmpolygones,mode_coo,typ_con);
01816
01817
01818 if (nmpolygones2 > 0)
01819 lecture_mailles_polygones(fid,nommaa,numdt,numit,MED_POLYGON2,nmpolygones2,mode_coo,typ_con);
01820
01821
01822 if (npolyedres > 0)
01823 lecture_mailles_polyedres(fid,nommaa,numdt,numit,npolyedres,mode_coo,typ_con);
01824
01825
01826
01827 if (typ_con == MED_DESCENDING) {
01828 lecture_faces_standard(fid,nommaa,numdt,numit,mdim,nfaces,mode_coo);
01829 if (nfpolygones > 0)
01830 lecture_faces_polygones(fid,nommaa,numdt,numit,nfpolygones,mode_coo);
01831 }
01832
01833
01834
01835 if (typ_con == MED_DESCENDING)
01836 lecture_aretes_standards(fid,nommaa,numdt,numit,mdim,naretes,mode_coo);
01837
01838
01839
01840
01841
01842 lecture_famille_maillage(fid,nommaa,nfam);
01843
01844
01845
01846
01847
01848
01849 lecture_equivalence_maillage(fid,nommaa,nequ);
01850
01851
01852
01853
01854
01855
01856 lecture_joint_maillage(fid,nommaa,njnt);
01857
01858
01859 return;
01860 }
01861
01862
01863 void lecture_caracteristiques_grille(const med_idt fid,
01864 const char * const nommaa,
01865 const med_int numdt,
01866 const med_int numit,
01867 const med_int mdim,
01868 med_int *nind,
01869 med_int *nnoe,
01870 med_int *nmai,
01871 med_grid_type *type)
01872 {
01873 med_err ret = 0;
01874 med_int axe;
01875 med_int *structure_grille;
01876 med_data_type quoi;
01877 med_int j;
01878 med_bool chgt=MED_FALSE,trsf=MED_FALSE;
01879
01880
01881 ret = MEDmeshGridTypeRd(fid,nommaa,type);
01882 EXIT_IF(ret < 0,"a la lecture du type d'une grille ",NULL);
01883
01884 switch(*type) {
01885
01886 case MED_CARTESIAN_GRID :
01887 case MED_POLAR_GRID :
01888 if (*type == MED_CARTESIAN_GRID)
01889 fprintf(stdout,"- Type de grille : MED_GRILLE_CARTESIENNE \n");
01890 else
01891 fprintf(stdout,"- Type de grille : MED_GRILLE_POLAIRE \n");
01892 for (axe=1;axe<=mdim;axe++) {
01893 switch(axe) {
01894
01895 case 1:
01896 quoi = MED_COORDINATE_AXIS1;
01897 break;
01898
01899 case 2:
01900 quoi = MED_COORDINATE_AXIS2;
01901 break;
01902
01903 case 3:
01904 quoi = MED_COORDINATE_AXIS3;
01905 break;
01906 }
01907 nind[axe - 1] = MEDmeshnEntity(fid,nommaa, numdt, numit,
01908 MED_NODE, MED_NONE, quoi, MED_NO_CMODE, &chgt, &trsf);
01909
01910 EXIT_IF(nind[axe - 1] < 0,
01911 "lors de la lecture de la taille d'un indice d'une grille",
01912 NULL);
01913 *nnoe = nind[axe - 1] * (*nnoe);
01914 *nmai = (nind[axe - 1] - 1) * (*nmai);
01915 fprintf(stdout,
01916 "- Taille de l'indice de l'axe "IFORMAT" des coordonnees : "IFORMAT" \n",
01917 axe,nind[axe - 1]);
01918 }
01919 break;
01920
01921 case MED_CURVILINEAR_GRID:
01922 fprintf(stdout,"- Type de grille : MED_GRILLE_DESTRUCTUREE \n");
01923 *nnoe = MEDmeshnEntity(fid, nommaa, numdt, numit,
01924 MED_NODE, MED_NONE, MED_COORDINATE, MED_NO_CMODE, &chgt, &trsf);
01925 EXIT_IF(*nnoe < 0,"lors de la lecture du nombre de noeuds du maillage "
01926 ,nommaa);
01927
01928
01929 structure_grille = (med_int *) malloc(sizeof(med_int)*mdim);
01930 EXIT_IF(structure_grille == NULL,NULL,NULL);
01931
01932
01933 ret = MEDmeshGridStructRd(fid,nommaa,numdt, numit, structure_grille);
01934 EXIT_IF(ret < 0,"lors de la lecture de la structure de la grille",
01935 NULL);
01936 fprintf(stdout,"- Structure de la grille : [ ");
01937 for (j=0;j<mdim;j++) {
01938 *nmai = (*(structure_grille+j) - 1) * (*nmai);
01939 fprintf(stdout," "IFORMAT" ",*(structure_grille+j));
01940 }
01941 fprintf(stdout," ] \n");
01942
01943 free(structure_grille);
01944 break;
01945
01946 case MED_UNDEF_GRID_TYPE:
01947 default:
01948 EXIT_IF(-1,"Type de grille non reconnu.",nommaa);
01949
01950 }
01951
01952 fprintf(stdout,"- Nombre de noeuds : "IFORMAT" \n",*nnoe);
01953 fprintf(stdout,"- Nombre de mailles : "IFORMAT" \n",*nmai);
01954
01955 return;
01956 }
01957
01958
01959 void lecture_noeuds_maillage_structure(const med_idt fid,
01960 const char * const nommaa,
01961 const med_int numdt,
01962 const med_int numit,
01963 const med_int mdim,
01964 const med_int edim,
01965 const med_int * const nind,
01966 const med_int nnoe,
01967 const char * const comp,
01968 const char * const unit,
01969 const med_grid_type type,
01970 const med_switch_mode mode_coo)
01971 {
01972 med_err ret = 0;
01973 med_int axe,i,j;
01974 char str[MED_SNAME_SIZE+1];
01975 med_float *coo = NULL;
01976 med_float *indices = NULL;
01977 med_int *nufano = NULL;
01978 med_int *numnoe = NULL;
01979 char *nomnoe = NULL;
01980 med_bool inufael=MED_FALSE;
01981
01982 fprintf(stdout,"\n(*************************)\n");
01983 fprintf(stdout,"(* NOEUDS DE LA GRILLE : *)\n");
01984 fprintf(stdout,"(*************************)\n");
01985
01986 switch(type) {
01987
01988 case MED_CARTESIAN_GRID :
01989 case MED_POLAR_GRID :
01990
01991 for (axe = 1; axe<=mdim; axe++) {
01992
01993 indices = (med_float *) malloc(sizeof(med_float)*nind[axe - 1]);
01994 EXIT_IF(indices == NULL,NULL,NULL);
01995
01996
01997 ret = MEDmeshGridIndexCoordinateRd(fid,nommaa,numdt,numit, axe,indices);
01998 EXIT_IF(ret < 0,"lors de la lecture d'un tableau d'indice",
01999 NULL);
02000 fprintf(stdout,"\n - Axe %." xstr(MED_SNAME_SIZE) "s [%." xstr(MED_SNAME_SIZE) "s] : [ ",
02001 &comp[MED_SNAME_SIZE*(axe-1)],&unit[MED_SNAME_SIZE*(axe-1)]);
02002 for (j=0;j<nind[axe - 1];j++)
02003 fprintf(stdout," %f ",*(indices+j));
02004 printf(" ] \n");
02005
02006 free(indices);
02007 }
02008 break;
02009
02010 case MED_CURVILINEAR_GRID:
02011
02012 coo = (med_float *) malloc(sizeof(med_float)*nnoe*edim);
02013 EXIT_IF(coo == NULL,NULL,NULL);
02014
02015 ret = MEDmeshNodeCoordinateRd(fid,nommaa,numdt,numit, MED_FULL_INTERLACE,coo);
02016
02017 EXIT_IF(ret < 0,"lors de la lecture des noeuds du maillage",NULL);
02018
02019 fprintf(stdout,"- Nom des coordonnees : \n");
02020 for (i=0;i<edim;i++) {
02021 strncpy(str,comp+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
02022 str[MED_SNAME_SIZE] = '\0';
02023 fprintf(stdout," %s ",str);
02024 }
02025 fprintf(stdout,"\n- Unites des coordonnees : \n");
02026 for (i=0;i<edim;i++) {
02027 strncpy(str,unit+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
02028 str[MED_SNAME_SIZE] = '\0';
02029 fprintf(stdout," %s ",str);
02030 }
02031 if (!structure) {
02032 fprintf(stdout,"\n - Coordonnees des noeuds : [ ");
02033 for (j=0;j<nnoe*edim;j++)
02034 fprintf(stdout," %f ",*(coo+j));
02035 fprintf(stdout," ] \n");
02036 }
02037
02038
02039 free(coo);
02040 break;
02041
02042 case MED_UNDEF_GRID_TYPE:
02043 default:
02044 EXIT_IF(-1,"Type de grille non reconnu.",nommaa);
02045
02046 }
02047
02048
02049
02050
02051
02052
02053
02054 numnoe = (med_int *) malloc(sizeof(med_int)*nnoe);
02055 EXIT_IF(numnoe == NULL,NULL,NULL);
02056 nomnoe = (char*) malloc(MED_SNAME_SIZE*nnoe+1);
02057 EXIT_IF(nomnoe == NULL,NULL,NULL);
02058 nufano = (med_int *) malloc(sizeof(med_int)*nnoe);
02059 EXIT_IF(nufano == NULL,NULL,NULL);
02060
02061
02062 ret = MEDmeshEntityFamilyNumberRd(fid,nommaa,numdt,numit,MED_NODE,MED_NO_GEOTYPE,nufano);
02063 if (ret < 0) ret=0; else inufael=MED_TRUE;
02064
02065 EXIT_IF(ret < 0,"lors de la lecture des numeros de familles des noeuds",
02066 NULL);
02067 if (!structure) {
02068
02069 fprintf(stdout,"\n- Numeros des familles des noeuds : \n");
02070 for (i=0;i<nnoe;i++)
02071 if (inufael)
02072 fprintf(stdout," "IFORMAT" ",*(nufano+i));
02073 else
02074 fprintf(stdout," %d ",0);
02075 fprintf(stdout,"\n");
02076 }
02077
02078
02079 if (MEDmeshEntityNameRd(fid,nommaa,numdt,numit,MED_NODE,MED_NO_GEOTYPE,nomnoe) == 0) {
02080 if (!structure) {
02081 fprintf(stdout,"\n- Noms des noeuds : \n");
02082 for (i=0;i<nnoe;i++) {
02083 strncpy(str,nomnoe+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
02084 str[MED_SNAME_SIZE] = '\0';
02085 fprintf(stdout," %s ",str);
02086 }
02087 }
02088 }
02089
02090
02091 if (MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,MED_NODE,MED_NO_GEOTYPE,numnoe) == 0) {
02092 if (!structure) {
02093 fprintf(stdout,"\n- Numeros des noeuds : \n");
02094 for (i=0;i<nnoe;i++)
02095 fprintf(stdout," "IFORMAT" ",*(numnoe+i));
02096 }
02097 }
02098
02099
02100 free(nufano);
02101 free(numnoe);
02102 free(nomnoe);
02103
02104 return;
02105 }
02106
02107
02108 void lecture_mailles_maillage_structure(const med_idt fid,
02109 const char * const nommaa,
02110 const med_int numdt,
02111 const med_int numit,
02112 const med_int mdim,
02113 const med_int nmai)
02114
02115 {
02116 med_err ret = 0;
02117 med_int i;
02118 med_int *nufael = NULL;
02119 char *nomele = NULL;
02120 med_int *numele = NULL;
02121 char str[MED_SNAME_SIZE+1];
02122
02123 med_geometry_type typgeo;
02124
02125 fprintf(stdout,"\n(***************************)\n");
02126 fprintf(stdout,"(* ELEMENTS DE LA GRILLE : *)\n");
02127 fprintf(stdout,"(***************************)\n");
02128
02129
02130 switch(mdim) {
02131 case 0 :
02132 typgeo = MED_POINT1;
02133 break;
02134 case 1 :
02135 typgeo = MED_SEG2;
02136 break;
02137 case 2 :
02138 typgeo = MED_QUAD4;
02139 break;
02140 default :
02141 typgeo = MED_HEXA8;
02142 }
02143
02144
02145
02146
02147
02148
02149
02150
02151 numele = (med_int *) malloc(sizeof(med_int)*nmai);
02152 EXIT_IF(numele == NULL,NULL,NULL);
02153 nomele = (char *) malloc(sizeof(char)*MED_SNAME_SIZE*nmai+1);
02154 EXIT_IF(nomele == NULL,NULL,NULL);
02155 nufael = (med_int *) malloc(sizeof(med_int)*nmai);
02156 EXIT_IF(nufael == NULL,NULL,NULL);
02157
02158
02159 ret = MEDmeshEntityFamilyNumberRd(fid,nommaa,numdt,numit,MED_CELL,typgeo,nufael);
02160 if (ret < 0)
02161 for (i=0;i<nmai;i++)
02162 *(nufael+i) = 0;
02163
02164 if (!structure) {
02165
02166 fprintf(stdout,"\n- Numeros des familles des mailles : \n");
02167 for (i=0;i<nmai;i++)
02168 fprintf(stdout," "IFORMAT" ",*(nufael+i));
02169 fprintf(stdout,"\n");
02170 }
02171
02172
02173 if (MEDmeshEntityNameRd(fid,nommaa,numdt,numit,MED_CELL,typgeo,nomele) == 0) {
02174 if (!structure) {
02175 fprintf(stdout,"\n - Noms : \n");
02176 for (i=0;i<nmai;i++) {
02177 strncpy(str,nomele+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
02178 str[MED_SNAME_SIZE] = '\0';
02179 fprintf(stdout," %s ",str);
02180 }
02181 }
02182 }
02183
02184
02185 if (MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,MED_CELL,typgeo,numele) == 0) {
02186 if (!structure) {
02187 fprintf(stdout,"\n - Numeros :\n");
02188 for (i=0;i<nmai;i++)
02189 fprintf(stdout," "IFORMAT" ",*(numele+i));
02190 }
02191 }
02192
02193
02194 free(nufael);
02195 free(nomele);
02196 free(numele);
02197
02198 return;
02199 }
02200
02201 void lecture_maillage_structure(const med_idt fid,
02202 const char * const nommaa,
02203 const med_int numdt,
02204 const med_int numit,
02205 const med_int mdim,
02206 const med_int edim,
02207 const med_switch_mode mode_coo,
02208 const char * const comp,
02209 const char * const unit,
02210 const int lecture_en_tete_seulement)
02211 {
02212
02213 med_int nind[3];
02214 med_int nnoe = 1;
02215 med_int nmai = 1;
02216
02217 med_grid_type type;
02218
02219 med_int nfam;
02220
02221 med_int nequ;
02222
02223 med_int njnt;
02224
02225
02226
02227
02228
02229
02230 lecture_caracteristiques_grille(fid,nommaa,numdt,numit,mdim,nind,&nnoe,&nmai,&type);
02231
02232
02233 nfam = lecture_nombre_famille(fid,nommaa);
02234
02235
02236 nequ = lecture_nombre_equivalence(fid,nommaa);
02237
02238
02239 njnt = lecture_nombre_joint(fid,nommaa);
02240
02241 if (lecture_en_tete_seulement)
02242 return ;
02243
02244
02245
02246
02247 lecture_noeuds_maillage_structure(fid,nommaa,numdt,numit,mdim,edim,nind,nnoe,comp,unit,type,mode_coo);
02248
02249
02250
02251
02252 lecture_mailles_maillage_structure(fid,nommaa,numdt,numit,mdim,nmai);
02253
02254
02255
02256
02257 lecture_famille_maillage(fid,nommaa,nfam);
02258
02259
02260
02261
02262 lecture_equivalence_maillage(fid,nommaa,nequ);
02263
02264
02265
02266
02267 lecture_joint_maillage(fid,nommaa,njnt);
02268
02269 return ;
02270 }
02271
02272 med_err getFieldsOn(const med_idt fid,
02273 const char * const maillage,
02274 const med_int mnumdt,
02275 const med_int mnumit,
02276 const med_int nmodels,
02277 const med_geometry_type* const geotype_elst,
02278 const char* const geotypename_elst,
02279 const char * const nomcha,
02280 const char * const dtunit,
02281 const med_field_type typcha,
02282 const med_int ncomp,
02283 const char * const comp,
02284 const char * const unit,
02285 const med_entity_type entite,
02286 const med_switch_mode stockage,
02287 const med_int ncstp) {
02288
02289 int i,j,k,l,m,n,nb_geo=0;
02290 med_int nbpdtnor=0,pflsize,*pflval,ngauss=0,ngroup,*vale=NULL,nval;
02291 med_int numdt=0,numo=0,_nprofile;
02292 med_int meshnumdt=0,meshnumit=0;
02293 med_float *valr=NULL,dt=0.0;
02294 med_err ret=0;
02295 char pflname [MED_NAME_SIZE+1]="";
02296 char locname [MED_NAME_SIZE+1]="";
02297 char meshname [MED_NAME_SIZE+1]="";
02298 char maa_ass [MED_NAME_SIZE+1]="";
02299 char * lien = NULL;
02300 med_bool localmesh;
02301 med_int nmesh=0;
02302 med_int lnsize=0;
02303 med_geometry_type * type_geo;
02304
02305 size_t _bannerlen=255;
02306 size_t _bannerlen1=0,_bannershift1=0;
02307 char _temp1[MAXBANNERLEN+1]="";
02308 char * _bannerstr1=NULL;
02309 size_t _bannerlen2=0,_bannershift2=0;
02310 char _temp2[MAXBANNERLEN+1]="";
02311 char * _bannerstr2=NULL;
02312
02313 const char * const * AFF;
02314 const char * const * AFF_ENT=MED23FIELD_GET_ENTITY_TYPENAME+1;
02315 const char * * AFF_STRUCT = NULL;
02316
02317 switch (entite) {
02318 case MED_NODE :
02319 type_geo = MED23FIELD_GET_NODE_GEOMETRY_TYPE;
02320 nb_geo = MED_N_NODE_FIXED_GEO;
02321 AFF = MED23FIELD_GET_NODE_GEOMETRY_TYPENAME;
02322 break;
02323 case MED_CELL :
02324 case MED_NODE_ELEMENT :
02325 type_geo = MED23FIELD_GET_CELL_GEOMETRY_TYPE;
02326 nb_geo = MED_N_CELL_FIXED_GEO;
02327 AFF = MED23FIELD_GET_CELL_GEOMETRY_TYPENAME;
02328 break;
02329 case MED_DESCENDING_FACE :
02330 type_geo = MED23FIELD_GET_FACE_GEOMETRY_TYPE;
02331 nb_geo = MED_N_FACE_FIXED_GEO;
02332 AFF = MED23FIELD_GET_FACE_GEOMETRY_TYPENAME;
02333 break;
02334 case MED_DESCENDING_EDGE :
02335 type_geo = MED23FIELD_GET_EDGE_GEOMETRY_TYPE;
02336 nb_geo = MED_N_EDGE_FIXED_GEO;
02337 AFF = MED23FIELD_GET_EDGE_GEOMETRY_TYPENAME;
02338 break;
02339 case MED_STRUCT_ELEMENT :
02340 AFF_STRUCT = (const char * *) calloc(sizeof(const char * ),nmodels+1);
02341 for(i=0;i<nmodels;++i) AFF_STRUCT[i+1]= &geotypename_elst[(MED_NAME_SIZE+1)*i];
02342 type_geo = (med_geometry_type*)(geotype_elst)-1;
02343 nb_geo = nmodels;
02344 AFF = AFF_STRUCT;
02345 break;
02346 }
02347
02348 for (k=1;k<=nb_geo;k++) {
02349
02350
02351 nbpdtnor = ncstp;
02352 if (nbpdtnor < 1 ) continue;
02353
02354 for (j=0;j<nbpdtnor;j++) {
02355
02356 if ( MEDfield23ComputingStepMeshInfo(fid, nomcha,j+1, &numdt, &numo, &dt,
02357 &nmesh, maa_ass, &localmesh, &meshnumdt, &meshnumit ) <0) {
02358 MESSAGE("Erreur a la demande d'information sur (pdt,nor) : ");
02359 ISCRUTE(numdt); ISCRUTE(numo);ISCRUTE(nmesh);SSCRUTE(meshname);ISCRUTE_int(localmesh);
02360 ISCRUTE(meshnumdt);ISCRUTE(meshnumit);
02361 ret = -1; continue;
02362 }
02363
02364 for (i=0;i< nmesh;++i) {
02365
02366 if ( (_nprofile = MEDfield23nProfile(fid,nomcha,numdt,numo,entite,type_geo[k],i+1,
02367 meshname,pflname,locname ) ) < 0 ) {
02368 MESSAGE("Erreur a la demande du nombre de profils referencés par le champ : ");
02369 SSCRUTE(nomcha); ISCRUTE(numdt); ISCRUTE(numo);SSCRUTE(meshname);
02370 ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);SSCRUTE(pflname);SSCRUTE(locname);
02371 SSCRUTE(AFF_ENT[(int)entite]);SSCRUTE(AFF[k]);
02372 ret = -1; continue;
02373 };
02374
02375 for (l=0;l<_nprofile;l++) {
02376
02377 if ( (nval = MEDfield23nValueWithProfile(fid, nomcha, numdt, numo, entite, type_geo[k],meshname,
02378 l+1, USER_MODE, pflname,&pflsize,
02379 locname, &ngauss) ) < 0 ) {
02380 MESSAGE("Erreur a la lecture du nombre de valeurs du champ : ");
02381 SSCRUTE(nomcha);ISCRUTE(numdt);ISCRUTE(numo);SSCRUTE(meshname);
02382 ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);
02383 ISCRUTE_int(USER_MODE);
02384 ret = -1; continue;
02385 };
02386
02387 if ( (!strcmp(meshname,maillage)) && (meshnumdt == mnumdt) && (meshnumit == mnumit) ) {
02388
02389
02390 _bannerstr1 = "(* CHAMP |%s| A L'ÉTAPE DE CALCUL (n°dt,n°it)="
02391 "(% 2.2"MED_IFORMAT",% 2.2"MED_IFORMAT") , %.*s*)\n";
02392
02393 _bannerstr2 = "(* SUR LE MAILLAGE |%s| A L'ÉTAPE DE CALCUL (n°dt,n°it)="
02394 "(% 2.2"MED_IFORMAT",% 2.2"MED_IFORMAT") : %.*s*)\n";
02395 snprintf(_temp1,MAXBANNERLEN+1,_bannerstr1,nomcha,numdt,numo,0,"");
02396 snprintf(_temp2,MAXBANNERLEN+1,_bannerstr2,meshname,meshnumdt,meshnumit,0,"");
02397 _bannerlen1 = strlen(_temp1);
02398 _bannerlen2 = strlen(_temp2);
02399 _bannerlen=MAX(_bannerlen1,_bannerlen2);
02400 if (_bannerlen1>_bannerlen2) {
02401 _bannershift1 = 0; _bannershift2 = _bannerlen1-_bannerlen2;
02402 } else {
02403 _bannershift2 = 0; _bannershift1 = _bannerlen2-_bannerlen1;
02404 }
02405 fprintf(stdout,"\n(");
02406 for (i=0;i< _bannerlen-6; i++) fprintf(stdout,"*");
02407 fprintf(stdout,")\n");
02408 fprintf(stdout,_bannerstr1,nomcha,numdt,numo,_bannershift1,MED_NAME_BLANK);
02409 fprintf(stdout,_bannerstr2,meshname,meshnumdt,meshnumit,_bannershift2,MED_NAME_BLANK);
02410 fprintf(stdout,"(");
02411 for (i=0;i< _bannerlen-6; i++) fprintf(stdout,"*");
02412 fprintf(stdout,")\n");
02413
02414
02415
02416
02417
02418
02419
02420
02421
02422
02423
02424 fprintf(stdout,"- Valeur de la date du champ %f [%s] : \n",dt,dtunit);
02425 fprintf(stdout,"- Type des composantes du champ : %d\n",typcha);
02426 fprintf(stdout,"- Nombre de composantes par valeur : "IFORMAT"\n",ncomp);
02427 fprintf(stdout,"- Unité des composantes : |%s|\n",unit);
02428 fprintf(stdout,"- Nom des composantes : |%s|\n",comp);
02429
02430 printf("\t- Il y a "IFORMAT" entités qui portent des valeurs en mode %i."
02431 "\n\t Chaque entite %s de type geometrique %s associes au profil |%s| a "IFORMAT" point(s) d'intégration \n",
02432 nval,USER_MODE,AFF_ENT[(int)entite],AFF[k],pflname,ngauss);
02433
02434
02435 if ( !localmesh ) {
02436
02437 if ( (lnsize=MEDlinkInfoByName(fid,maa_ass) ) < 0 ) {
02438 MESSAGE("Erreur a la lecture de la taille du lien : ");
02439 SSCRUTE(maa_ass);
02440 ret = -1;
02441 } else {
02442 lien = (char *)malloc(lnsize*sizeof(char) + 1);
02443 EXIT_IF(lien == NULL,NULL,NULL);
02444
02445 if ( MEDlinkRd(fid, maa_ass, lien) < 0 ) {
02446 MESSAGE("Erreur a la lecture du lien : ");
02447 SSCRUTE(maa_ass);SSCRUTE(lien);
02448 ret = -1;
02449 } else {
02450 lien[lnsize] = '\0';
02451 printf("\tLe maillage |%s| est porte par un fichier distant |%s|\n",maa_ass,lien);
02452 }
02453 free(lien);
02454 }
02455 }
02456
02457
02458 if (typcha == MED_FLOAT64) {
02459
02460 valr = (med_float*) calloc(ncomp*nval*ngauss,sizeof(med_float));
02461 EXIT_IF(valr == NULL,NULL,NULL);
02462
02463 if (MEDfield23ValueWithProfileRd(fid, nomcha, numdt,numo, entite,type_geo[k],meshname,
02464 USER_MODE, pflname, stockage,MED_ALL_CONSTITUENT,
02465 (unsigned char*) valr) < 0 ) {
02466 MESSAGE("Erreur a la lecture des valeurs du champ : ");
02467 SSCRUTE(nomcha);ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);
02468 ISCRUTE(numdt);ISCRUTE(numo);
02469 ret = -1;
02470 }
02471 } else {
02472
02473 vale = (med_int*) calloc(ncomp*nval*ngauss,sizeof(med_int));
02474 EXIT_IF(vale == NULL,NULL,NULL);
02475
02476 if (MEDfield23ValueWithProfileRd(fid, nomcha, numdt,numo, entite,type_geo[k],meshname,
02477 USER_MODE, pflname, stockage,MED_ALL_CONSTITUENT,
02478 (unsigned char*) vale) < 0 ) {
02479 MESSAGE("Erreur a la lecture des valeurs du champ : ");
02480 SSCRUTE(nomcha);ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);
02481 ISCRUTE(numdt);ISCRUTE(numo);
02482 ret = -1;
02483 }
02484 }
02485
02486 if ( strlen(locname) && (_nprofile > 1) )
02487 printf("\t- Modèle de localisation des points de Gauss de nom |%s|\n",locname);
02488
02489 if (entite == MED_NODE_ELEMENT)
02490 ngroup = (type_geo[k] % 100);
02491 else
02492 ngroup = ngauss;
02493
02494 switch (stockage) {
02495
02496 case MED_FULL_INTERLACE :
02497 if (!structure) {
02498 printf("\t- Valeurs :\n\t");
02499 for (m=0;m<(nval*ngauss)/ngroup;m++) {
02500 printf("|");
02501 for (n=0;n<ngroup*ncomp;n++)
02502 if (typcha == MED_FLOAT64)
02503 printf(" %f ",*(valr+(m*ngroup*ncomp)+n));
02504 else
02505 printf(" "IFORMAT" ",*(vale+(m*ngroup*ncomp)+n));
02506 }
02507 }
02508 break;
02509
02510
02511 case MED_NO_INTERLACE :
02512 if (!structure) {
02513 printf("\t- Valeurs :\n\t");
02514 for (m=0;m<ncomp;m++) {
02515 printf("|");
02516 for (n=0;n<(nval*ngauss);n++)
02517 if (typcha == MED_FLOAT64)
02518 printf(" %f ",*(valr+(m*nval)+n));
02519 else
02520 printf(" "IFORMAT" ",*(vale+(m*nval)+n));
02521 }
02522 }
02523 break;
02524 }
02525
02526 if (!structure) {
02527 printf("|\n");
02528 }
02529
02530 if (typcha == MED_FLOAT64) {
02531 if ( valr ) {free(valr);valr = NULL;}}
02532 else
02533 if (vale) { free(vale);vale = NULL; }
02534
02535
02536 if (strcmp(pflname,MED_NO_PROFILE) == 0 ) {
02537 printf("\t- Profil : MED_NOPFL\n");
02538 } else {
02539 if ( (pflsize = MEDprofileSizeByName(fid,pflname)) <0 ) {
02540 MESSAGE("Erreur a la lecture du nombre de valeurs du profil : ");
02541 SSCRUTE(pflname);
02542 ret = -1; continue;
02543 }
02544
02545 printf("\t- Profil : |%s| de taille "IFORMAT"\n",pflname,pflsize);
02546
02547 pflval = (med_int*) malloc(sizeof(med_int)*pflsize);
02548 EXIT_IF(pflval == NULL,NULL,NULL);
02549 if ( MEDprofileRd(fid,pflname,pflval) <0) {
02550 MESSAGE("Erreur a la lecture des valeurs du profil : ");
02551 SSCRUTE(pflname);
02552 ret = -1;
02553 }
02554 if (!structure) {
02555 printf("\t");
02556 for (m=0;m<pflsize;m++) printf(" "IFORMAT" ",*(pflval+m));
02557 printf("\n");
02558 }
02559 free(pflval);
02560 }
02561 }
02562 }
02563 }
02564 }
02565 }
02566
02567 free(AFF_STRUCT);
02568 return ret;
02569 }
02570
02571
02572
02573
02574
02575
02576
02577
02578
02579
02580
02581
02582
02583
02584
02585 void lecture_resultats(const med_idt fid,
02586 const char * const maillage,
02587 const med_int mnumdt,
02588 const med_int mnumit,
02589 const med_switch_mode mode_coo,
02590 const med_int nmodels,
02591 const med_geometry_type* geotype_elst,
02592 const char* geotypename_elst,
02593 const int lecture_en_tete_seulement)
02594 {
02595 med_err ret,lret;
02596 char *comp, *unit;
02597 char nomcha [MED_NAME_SIZE+1]="";
02598 med_int ncomp,ncha;
02599 med_field_type typcha;
02600 int i;
02601
02602 char nommaa[MED_NAME_SIZE+1]="";
02603 med_bool localmaa = MED_FALSE;
02604 char dtunit[MED_SNAME_SIZE+1]="";
02605 med_int ncstp=0;
02606
02607
02608
02609 ncha = MEDnField(fid);
02610 EXIT_IF(ncha < 0,"lors de la lecture du nombre de champs",NULL);
02611
02612 if ( !strlen(maillage) || lecture_en_tete_seulement ) {
02613 fprintf(stdout,"\n(************************)\n");
02614 fprintf(stdout,"(* CHAMPS DU MAILLAGE : *)\n");
02615 fprintf(stdout,"(************************)\n");
02616 fprintf(stdout,"- Nombre de champs : "IFORMAT" \n",ncha);
02617 }
02618
02619
02620
02621
02622 ret = 0;
02623
02624
02625 for (i =0;i<ncha;i++) {
02626 lret = 0;
02627
02628
02629 if ((ncomp = MEDfieldnComponent(fid,i+1)) < 0) {
02630 MESSAGE("Erreur à la lecture du nombre de composantes : ");
02631 ISCRUTE(ncomp);
02632 ret = -1; continue;
02633 }
02634
02635
02636
02637 comp = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
02638 EXIT_IF(comp == NULL,NULL,NULL);
02639 unit = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
02640 EXIT_IF(unit == NULL,NULL,NULL);
02641
02642 if ( MEDfieldInfo(fid, i+1, nomcha, nommaa, &localmaa,
02643 &typcha, comp, unit, dtunit, &ncstp) < 0 ) {
02644 MESSAGE("Erreur à la demande d'information sur les champs : ");
02645 ret = -1; continue;
02646 }
02647
02648
02649 if ( !strlen(maillage) || lecture_en_tete_seulement ) {
02650 printf("\nChamp numero : |%d| \n",i+1);
02651 printf("Nom du champ : |%s| de type |%d|\n",nomcha,typcha);
02652 printf("Nom des composantes : |%s|\n",comp);
02653 printf("Unites des composantes : |%s| \n",unit);
02654 if (strlen(dtunit))
02655 printf("Unité des dates : |%s|\n",dtunit);
02656 if ( ncstp > 1 )
02657 printf("Nombre d'étapes de calcul : |"IFORMAT"| \n",ncstp);
02658 }
02659
02660
02661 if (lecture_en_tete_seulement) {
02662 free(comp);
02663 free(unit);
02664 continue;
02665 }
02666
02667
02668 lret = getFieldsOn(fid, maillage, mnumdt, mnumit, nmodels,geotype_elst,geotypename_elst,
02669 nomcha, dtunit, typcha, ncomp, comp, unit, MED_NODE,mode_coo, ncstp);
02670
02671
02672 if (lret == 0) lret = getFieldsOn(fid, maillage, mnumdt, mnumit , nmodels,geotype_elst,geotypename_elst,
02673 nomcha, dtunit, typcha, ncomp, comp, unit, MED_CELL,mode_coo, ncstp);
02674 else { MESSAGE("Erreur à la lecture des champs aux noeuds "); ret = -1; continue;}
02675
02676 if (lret == 0) lret = getFieldsOn(fid, maillage, mnumdt, mnumit , nmodels,geotype_elst,geotypename_elst,
02677 nomcha, dtunit, typcha, ncomp, comp, unit, MED_DESCENDING_FACE,mode_coo, ncstp);
02678 else { MESSAGE("Erreur à la lecture des champs aux mailles "); ret = -1; continue;}
02679
02680 if (lret == 0) lret = getFieldsOn(fid, maillage, mnumdt, mnumit , nmodels,geotype_elst,geotypename_elst,
02681 nomcha, dtunit, typcha, ncomp, comp, unit, MED_DESCENDING_EDGE,mode_coo, ncstp);
02682 else {MESSAGE("Erreur à la lecture des champs aux faces "); ret = -1; continue;}
02683
02684 if (lret == 0) lret = getFieldsOn(fid, maillage, mnumdt, mnumit , nmodels,geotype_elst,geotypename_elst,
02685 nomcha, dtunit, typcha, ncomp, comp, unit, MED_NODE_ELEMENT,mode_coo, ncstp);
02686 else {MESSAGE("Erreur a la lecture des champs aux aretes "); ret = -1; continue;}
02687
02688 if (lret != 0) {MESSAGE("Erreur a la lecture des champs aux noeuds des mailles "); ret = -1;};
02689
02690 if (nmodels)
02691 lret = getFieldsOn(fid, maillage, mnumdt, mnumit , nmodels, geotype_elst,geotypename_elst,
02692 nomcha, dtunit, typcha, ncomp, comp, unit, MED_STRUCT_ELEMENT,mode_coo, ncstp);
02693 if (lret != 0) {MESSAGE("Erreur a la lecture des champs aux éléments de sructure "); ret = -1;};
02694
02695 free(comp);
02696 free(unit);
02697
02698 }
02699
02700 return;
02701 }
02702
02703
02704
02705
02706
02707
02708
02709
02710
02711
02712
02713
02714 void lecture_parametres_scalaires(med_idt fid,
02715 int lecture_en_tete_seulement)
02716 {
02717 med_err ret = 0;
02718 char nom_scalaire[MED_NAME_SIZE+1];
02719 char description[MED_COMMENT_SIZE+1];
02720 med_int vali;
02721 med_float valr;
02722 med_int i,n,npdt,j;
02723 med_parameter_type type;
02724 med_int numdt,numo;
02725 med_float dt;
02726 char dt_unit[MED_SNAME_SIZE+1];
02727
02728
02729
02730 n = MEDnParameter(fid);
02731 EXIT_IF(n < 0,"lors de la lecture du nombre de scalaires",NULL);
02732
02733 if (n) {
02734 fprintf(stdout,"\n(*******************************)\n");
02735 fprintf(stdout,"(* VARIABLES SCALAIRES : *)\n");
02736 fprintf(stdout,"(*******************************)\n\n");
02737 fprintf(stdout,"- Nombre de variables scalaires : "IFORMAT"\n",n);
02738 }
02739 if (lecture_en_tete_seulement)
02740 return ;
02741
02742 for (i=1;i<=n;i++) {
02743
02744
02745 ret = MEDparameterInfo( fid,i,nom_scalaire,&type,description,
02746 dt_unit, &npdt );
02747 EXIT_IF(ret < 0,"lors de la lecture des parametres d'un scalaire",NULL);
02748 fprintf(stdout,"- Scalaire n°"IFORMAT" de nom %s \n",i,nom_scalaire);
02749 if (type == MED_FLOAT64)
02750 fprintf(stdout," Type flottant. \n");
02751 else
02752 fprintf(stdout," Type entier. \n");
02753 printf(" Description associee : [%s] \n",description);
02754
02755
02756
02757 EXIT_IF(npdt < 0,
02758 "lors de la lecture du nombre de pas de temps d'un scalaire"
02759 ,NULL);
02760 fprintf(stdout," Nombre de valeurs stockees : "IFORMAT" \n",npdt);
02761
02762 for (j=1;j<=npdt;j++) {
02763
02764 ret = MEDparameterComputationStepInfo(fid,nom_scalaire,j, &numdt,&numo,&dt);
02765 EXIT_IF(ret < 0,
02766 "lors de la lecture des parametres d'un pas de temps d'un scalaire",
02767 NULL);
02768
02769 if (numdt == MED_NO_DT)
02770 fprintf(stdout," - Aucun de pas de temps \n");
02771 else
02772 fprintf(stdout,
02773 " - Pas de de temps de numero "IFORMAT" de valeur %f [%s] \n",numdt,
02774 dt,dt_unit);
02775 if (numo == MED_NO_IT)
02776 fprintf(stdout," - Aucun numero d'ordre \n");
02777 else
02778 fprintf(stdout," - Numero d'ordre : "IFORMAT" \n",numo);
02779
02780 if (type == MED_FLOAT64) {
02781 ret = MEDparameterValueRd(fid,nom_scalaire,numdt,numo,(unsigned char * ) &valr);
02782 fprintf(stdout," - Valeur : %f \n",valr);
02783 }
02784 else {
02785 ret = MEDparameterValueRd(fid,nom_scalaire,numdt,numo,(unsigned char * ) &vali);
02786 fprintf(stdout," - Valeur : "IFORMAT" \n",vali);
02787 }
02788 EXIT_IF(ret < 0,"lors de la lecture de la valeur d'un scalaire",NULL);
02789
02790 }
02791 }
02792
02793 return ;
02794 }
02795
02796
02797
02798
02799
02800
02801
02802
02803
02804
02805
02806
02807 void lecture_profils(med_idt fid,
02808 int lecture_en_tete_seulement)
02809 {
02810 med_err ret;
02811 char pflname[MED_NAME_SIZE+1]="";
02812 med_int npro,*pflval,nval;
02813 int i,j;
02814
02815
02816
02817 npro = MEDnProfile(fid);
02818 EXIT_IF(npro < 0,"lors de la lecture du nombre de profils",NULL);
02819
02820 if (npro) {
02821 fprintf(stdout,"\n(*************)\n");
02822 fprintf(stdout, "(* PROFILS : *)\n");
02823 fprintf(stdout, "(*************)\n");
02824 printf("\nNombre de profils stockes : "IFORMAT"\n\n",npro);
02825 }
02826
02827 for (i=1 ; i <= npro ; i++ ) {
02828 if ( MEDprofileInfo(fid, i, pflname, &nval) < 0) {
02829 MESSAGE("Erreur a la demande d'information sur le profil n° : "); ISCRUTE_int(i);
02830 ret = -1;continue;
02831 }
02832 printf("\t- Profil n°%i de nom |%s| et de taille "IFORMAT"\n",i,pflname,nval);
02833 pflval = (med_int*) malloc(sizeof(med_int)*nval);
02834 if ( MEDprofileRd(fid, pflname, pflval) < 0) {
02835 MESSAGE("Erreur a la lecture des valeurs du profil : ");
02836 SSCRUTE(pflname);
02837 ret = -1;
02838 } else {
02839 if (!structure) {
02840 printf("\t");
02841 for (j=0;j<nval;j++) printf(" "IFORMAT" ",*(pflval+j));
02842 }
02843 printf("\n\n");
02844 }
02845 free(pflval);
02846 }
02847 return;
02848 }
02849
02850
02851
02852
02853
02854
02855
02856
02857
02858
02859
02860
02861 void lecture_modeles_elstruct(med_idt fid,
02862 int lecture_en_tete_seulement)
02863 {
02864 med_err _ret=0;
02865 int _i =0,_j=0,_k=0, _n=0,_nvalue=0;
02866 med_int _nstructelement=0;
02867
02868 med_geometry_type _geotype=MED_NONE;
02869
02870 char _elementname[MED_NAME_SIZE+1]="";
02871 med_int _elementdim=0;
02872 char _supportmeshname[MED_NAME_SIZE+1]="";
02873 med_entity_type _entitytype=MED_UNDEF_ENTITY_TYPE;
02874 med_int _nnode=0;
02875 med_int _ncell=0;
02876 med_geometry_type _geocelltype=MED_NONE;
02877 char _geocelltypename[MED_SNAME_SIZE+1]="";
02878 med_int _nconstantattribute=0;
02879 med_bool _anyprofile=0;
02880 med_int _nvariableattribute=0;
02881
02882 char _constattname[MED_NAME_SIZE+1]="";
02883 med_attribute_type _constatttype=MED_ATT_UNDEF;
02884 char _varattname[MED_NAME_SIZE+1]="";
02885 med_attribute_type _varatttype=MED_ATT_UNDEF;
02886 med_int _ncomponent=0;
02887 med_entity_type _attentitytype=MED_UNDEF_ENTITY_TYPE;
02888 char _profilename[MED_NAME_SIZE+1]="";
02889 med_int _profilesize=0;
02890
02891 unsigned char * _value=NULL;
02892 void (*_printf)(const void*);
02893 med_int _atttypesize=0;
02894
02895 _nstructelement = MEDnStructElement(fid);
02896 EXIT_IF(_nstructelement < 0,"lors de la lecture du nombre d'éléments de structure",NULL);
02897
02898 if(_nstructelement) {
02899 fprintf(stdout,"\n(*************************************)\n");
02900 fprintf(stdout, "(* MODELES D'ELEMENTS DE STRUCTURE : *)\n");
02901 fprintf(stdout, "(*************************************)\n");
02902 printf("\nNombre d'éléments de structure : "IFORMAT"\n\n",_nstructelement);
02903 }
02904
02905 for ( _i=1; _i<= _nstructelement; ++_i) {
02906
02907 _ret= MEDstructElementInfo(fid,_i,_elementname,&_geotype,&_elementdim,_supportmeshname,
02908 &_entitytype,&_nnode,&_ncell,&_geocelltype,&_nconstantattribute,&_anyprofile,
02909 &_nvariableattribute );
02910 EXIT_IF(_ret < 0,"lors de la demande d'information sur les éléments de structure",NULL);
02911
02912 fprintf(stdout,"\nElément de structure n°%d |%s| de type géométrique n°%d et de dimension "IFORMAT"\n",
02913 _i,_elementname,_geotype,_elementdim);
02914 if ( strlen(_supportmeshname) ) {
02915 fprintf(stdout,"\t Maillage support de nom |%s|",_supportmeshname);
02916 if (_ncell) {
02917 MEDmeshGeotypeName(fid,_geocelltype,_geocelltypename);
02918 fprintf(stdout," avec "IFORMAT" maille(s) de type |%s| et",_ncell,_geocelltypename);
02919 }
02920 if (_nnode)
02921 fprintf(stdout," avec "IFORMAT" noeud(s)\n",_nnode);
02922 else {
02923 fprintf(stderr,"\n Erreur : les noeuds doivent être définis s'il existe un maillage support\n");
02924 }
02925 } else
02926 fprintf(stdout,"\t Maillage support implicite sur noeud\n");
02927
02928 fprintf(stdout,"\t Nombre d'attribut(s) constant(s) : "IFORMAT"",_nconstantattribute);
02929 if (_anyprofile) fprintf(stdout,", avec profil.\n"); else fprintf(stdout,", sans profil.\n");
02930
02931 if ( _nconstantattribute ) {
02932 for (_j=1;_j<=_nconstantattribute;++_j) {
02933 _ret= MEDstructElementConstAttInfo(fid, _elementname,_j,
02934 _constattname, &_constatttype, &_ncomponent,
02935 &_attentitytype, _profilename, &_profilesize );
02936 EXIT_IF(_ret < 0,"lors de la demande d'information sur les attributs constants des éléments de structure",NULL);
02937
02938 fprintf(stdout,"\t\t Attribut constant de nom |%s| de type %d à "IFORMAT" composantes\n",
02939 _constattname,_constatttype,_ncomponent);
02940
02941 if (!_profilesize) {
02942 if (_attentitytype == MED_NODE) _nvalue = _nnode; else _nvalue=_ncell;
02943 } else {
02944 _nvalue = _profilesize;
02945 }
02946 _n = _ncomponent*_nvalue;
02947 if ( _attentitytype == MED_ATT_NAME) ++_n;
02948 _atttypesize = MEDstructElementAttSizeof(_constatttype);
02949 _value = (unsigned char *) malloc(_n*_atttypesize);
02950 if ( _attentitytype == MED_ATT_NAME) --_n;
02951
02952 _ret= MEDstructElementConstAttRd(fid, _elementname,_constattname, _value );
02953 if (_ret < 0 ) free(_value);
02954 EXIT_IF(_ret < 0,"lors de la lecture des valeurs des attributs constants",NULL);
02955 _printf=MEDstructPrintFunction(_constatttype);
02956
02957 if (!structure) {
02958 fprintf(stdout,"\t\t - Valeurs de l'attribut sur les d'entité |%s|",
02959 MED23MESH_GET_ENTITY_TYPENAME[_attentitytype+1]);
02960 if ( _profilesize)
02961 fprintf(stdout," avec un profil |%s| de taille "IFORMAT": ",_profilename,_profilesize);
02962 else
02963 fprintf(stdout," sans profil : ");
02964
02965 for (_k=0;_k<_nvalue*_ncomponent;_k++) {
02966
02967 if ( !(_k % _ncomponent) )
02968 fprintf(stdout,"\n [ %5"MED_IFORMAT" ] : ", (_k/_ncomponent +1) );
02969 _printf( (void *)( (char *)(_value) + _k*_atttypesize) );
02970 }
02971 printf("\n");
02972 }
02973
02974 free(_value);
02975 printf("\n");
02976 }
02977 }
02978
02979 fprintf(stdout,"\t Nombre d'attribut(s) variable(s) : "IFORMAT"\n",_nvariableattribute);
02980 if ( _nvariableattribute ) {
02981 for (_j=1;_j<=_nvariableattribute;++_j) {
02982 _ret = MEDstructElementVarAttInfo(fid, _elementname,_j,_varattname,&_varatttype,&_ncomponent );
02983 EXIT_IF(_ret < 0,"lors de la lecture des valeurs des attributs variables",NULL);
02984 fprintf(stdout,"\t\t Attribut variable de nom |%s| de type %d à "IFORMAT" composantes\n",
02985 _varattname,_varatttype,_ncomponent);
02986 }
02987 }
02988
02989 }
02990
02991 return;
02992 }
02993
02994
02995
02996
02997
02998
02999
03000
03001
03002
03003
03004
03005 void lecture_fonctions_interpolation(med_idt fid,
03006 int lecture_en_tete_seulement)
03007 {
03008
03009 med_err _ret=-1;
03010 med_int _ninterp=0;
03011 int _interpit =0;
03012 char _interpname[MED_NAME_SIZE+1]="";
03013 med_geometry_type _geotype =MED_NONE;
03014 char _geotypename[MED_SNAME_SIZE+1]="";
03015 med_int _geodim=0,_geonnodes=0;
03016 med_bool _cellnodes =MED_FALSE;
03017 med_int _nbasisfunc =0;
03018 med_int _nvariable =0;
03019 med_int _maxdegree =0;
03020 med_int _nmaxcoefficient =0;
03021 int _basisfuncit =0;
03022 int _powerit =0;
03023 med_int _ncoefficient =0;
03024 med_int* _power =NULL;
03025 med_float* _coefficient =NULL;
03026 int _coefficientit =0;
03027
03028
03029 _ninterp = MEDnInterp(fid);
03030 if (_ninterp) {
03031 fprintf(stdout,"\n(********************************)\n");
03032 fprintf(stdout, "(* FONCTIONS D'INTERPOLATION : *)\n");
03033 fprintf(stdout, "(********************************)\n");
03034 printf("\nNombre de fonctions d'interpolation : "IFORMAT"\n\n",_ninterp);
03035 }
03036
03037 for ( _interpit=1; _interpit<= _ninterp; ++_interpit) {
03038
03039 if (MEDinterpInfo(fid,_interpit,_interpname,&_geotype,&_cellnodes,&_nbasisfunc,
03040 &_nvariable,&_maxdegree,&_nmaxcoefficient) < 0 ) {
03041 MESSAGE("Erreur à la demande d'information de la fonction d'interpolation n°");
03042 ISCRUTE_int(_interpit);
03043 _ret = -1;continue;
03044 }
03045
03046 MEDmeshGeotypeName(fid,_geotype,_geotypename);
03047 fprintf(stdout,"Fonction d'interpolation n° %d |%s| sur le type géométrique |%s|\n",
03048 _interpit,_interpname, _geotypename);
03049
03050 if ( MEDmeshGeotypeParameter(fid,_geotype,&_geodim,&_geonnodes) <0 ) {
03051 MESSAGE("Erreur à la lecture du nom associé au typegeo : "); ISCRUTE_int(_geotype);
03052 _ret = -1;continue;
03053 }
03054
03055 if ( _cellnodes ) {
03056 if ( _nbasisfunc == _geonnodes )
03057 fprintf(stdout,"\t Les noeuds de construction sont les noeuds de la maille de référence.\n");
03058 else {
03059 MESSAGE("Erreur : le nombre de noeuds de construction "\
03060 "est différent du nombre de noeuds de la maille de référence.\n");
03061 ISCRUTE(_nbasisfunc); ISCRUTE(_geonnodes);
03062 _ret = -1;continue;
03063 }
03064 }
03065
03066
03067
03068
03069
03070
03071
03072 fprintf(stdout,"\t Il y a "IFORMAT" fonctions de base avec "IFORMAT" variables\n ",_nbasisfunc,_nvariable);
03073 fprintf(stdout,"\t Le degré maximum des fonctions de base est "IFORMAT" et possèdent au maximum "IFORMAT" coefficients\n"
03074 ,_maxdegree,_nmaxcoefficient);
03075
03076
03077 _coefficient = (med_float*) calloc(sizeof(med_float),_nmaxcoefficient);
03078 _power = (med_int*) calloc(sizeof(med_int),_nvariable*_nmaxcoefficient);
03079
03080 for ( _basisfuncit=1; _basisfuncit<= _nbasisfunc; ++_basisfuncit) {
03081
03082
03083 if ( (_ret = MEDinterpBaseFunctionRd( fid,_interpname,_basisfuncit,&_ncoefficient,_power,_coefficient) <0) ) {
03084 MESSAGE("Erreur à la lecture de la fonction de base n°");ISCRUTE_int(_basisfuncit);
03085 _ret=-1;continue;
03086 } else {
03087 if (!structure) {
03088
03089 fprintf(stdout,"\n\t Tableau de coefficients de la fonctions de base n° %d :\n\t",_basisfuncit);
03090 for ( _coefficientit=1; _coefficientit<= _ncoefficient; ++_coefficientit)
03091 fprintf(stdout," %4f ",_coefficient[_coefficientit]);
03092
03093 fprintf(stdout,"\n\t Tableau de puissances de la fonctions de base n° %d :\n\t",_basisfuncit);
03094 for ( _powerit=1; _powerit<= _nvariable*_ncoefficient; ++_powerit)
03095 fprintf(stdout," %4"MED_IFORMAT" ",_power[_powerit]);
03096 }
03097 }
03098 }
03099 fprintf(stdout,"\n");
03100 free(_coefficient);
03101 free(_power);
03102
03103 }
03104
03105 return;
03106 }
03107
03108
03109
03110
03111
03112
03113
03114
03115
03116
03117
03118
03119 void lecture_liens(med_idt fid,
03120 int lecture_en_tete_seulement)
03121 {
03122 med_err ret;
03123 char nomlien[MED_NAME_SIZE+1]="";
03124 char *lien = NULL;
03125 med_int nln=0,nval=0;
03126 int i;
03127
03128
03129
03130 nln = MEDnLink(fid);
03131
03132 if (nln) {
03133 fprintf(stdout,"\n(***********)\n");
03134 fprintf(stdout, "(* LIENS : *)\n");
03135 fprintf(stdout, "(***********)\n");
03136 printf("\nNombre de liens : "IFORMAT"\n\n",nln);
03137 }
03138
03139 for (i=1 ; i <= nln ; i++ ) {
03140 if ( MEDlinkInfo(fid, i, nomlien, &nval) < 0) {
03141 MESSAGE("Erreur a la demande d'information sur le lien n° : "); ISCRUTE_int(i);
03142 ret = -1;continue;
03143 }
03144 printf("\t- Lien n°%i de nom |%s| et de taille "IFORMAT"\n",i,nomlien,nval);
03145
03146 lien = (char * ) malloc((nval+1)*sizeof(char));
03147 EXIT_IF(lien == NULL,NULL,NULL);
03148
03149 if ( MEDlinkRd(fid, nomlien, lien ) < 0 ) {
03150 MESSAGE("Erreur a la lecture du lien : ");
03151 SSCRUTE(nomlien);SSCRUTE(lien);
03152 ret = -1;
03153 } else {
03154 lien[nval] = '\0';
03155 printf("\t\t|%s|\n\n",lien);
03156 }
03157 free(lien);
03158 }
03159 return;
03160 }
03161
03162
03163
03164
03165
03166
03167
03168
03169
03170
03171
03172
03173
03174
03175
03176 void lecture_localisation(med_idt fid,
03177 const med_switch_mode mode_coo,
03178 int lecture_en_tete_seulement)
03179 {
03180 med_err ret = 0;
03181 med_int nloc=0,locsdim=0,ngauss=0;
03182 med_geometry_type type_geo;
03183 med_float *refcoo=NULL, *gscoo=NULL, *wg=NULL;
03184 char locname [MED_NAME_SIZE+1]="";
03185 char geointerpname [MED_NAME_SIZE+1]="";
03186 char ipointstructmeshname[MED_NAME_SIZE+1]="";
03187 med_int nsectionmeshcell = 0;
03188 med_geometry_type sectiongeotype;
03189 char sectiongeotypename[MED_NAME_SIZE+1]="";
03190 med_int locentdim=0;
03191 med_int locnnodes=0;
03192 char _locgeotypename[MED_NAME_SIZE+1]="";
03193 int t1=0,t2=0,t3=0;
03194 int i=0,j=0;
03195
03196
03197
03198 nloc = MEDnLocalization(fid);
03199 if (nloc) {
03200 fprintf(stdout,"\n(********************************************)\n");
03201 fprintf(stdout, "(* LOCALISATIONS DES POINTS D'INTEGRATION : *)\n");
03202 fprintf(stdout, "(********************************************)\n");
03203 printf("\nNombre de localisations stockees : "IFORMAT"\n\n",nloc);
03204 }
03205
03206 for (i=1 ; i <= nloc ; i++ ) {
03207 if ( MEDlocalizationInfo(fid, i, locname, &type_geo, &locsdim, &ngauss,
03208 geointerpname, ipointstructmeshname, &nsectionmeshcell,
03209 §iongeotype) < 0) {
03210 MESSAGE("Erreur a la demande d'information sur la localisation n° : "); ISCRUTE_int(i);
03211 ret = -1;continue;
03212 }
03213 printf("\t- Loc. n°%i de nom |%s| de dimension "IFORMAT" avec "IFORMAT" pts de GAUSS \n",i,locname,locsdim,ngauss);
03214
03215 if ( MEDmeshGeotypeName(fid, type_geo,_locgeotypename) <0 ) {
03216 MESSAGE("Erreur à la lecture du nom associé au typegeo : "); ISCRUTE_int(type_geo);
03217 ret = -1;continue;
03218 }
03219
03220 if ( MEDmeshGeotypeParameter(fid, type_geo,&locentdim,&locnnodes) <0 ) {
03221 MESSAGE("Erreur à la lecture du nom associé au typegeo : "); ISCRUTE_int(type_geo);
03222 ret = -1;continue;
03223 }
03224
03225 if (strlen(ipointstructmeshname)) {
03226 if ( MEDmeshGeotypeName(fid, sectiongeotype,sectiongeotypename) <0 ) {
03227 MESSAGE("Erreur à la lecture du nom associé au sectiongeotype : "); ISCRUTE_int(sectiongeotype);
03228 SSCRUTE(ipointstructmeshname);
03229 ret = -1;continue;
03230 }
03231 }
03232
03233 t1 = locnnodes*locsdim;
03234 t2 = ngauss*locsdim;
03235 t3 = ngauss;
03236 refcoo = (med_float *) malloc(sizeof(med_float)*t1 );
03237 gscoo = (med_float *) malloc(sizeof(med_float)*t2 );
03238 wg = (med_float *) malloc(sizeof(med_float)*t3 );
03239
03240 if ( MEDlocalizationRd(fid, locname, mode_coo, refcoo, gscoo, wg ) < 0) {
03241 MESSAGE("Erreur a la lecture des valeurs de la localisation : ");
03242 SSCRUTE(locname);
03243 ret = -1;
03244 } else {
03245 if (!structure) {
03246 printf("\t Coordonnees de l'element de reference de type |%s| :\n\t\t",_locgeotypename);
03247
03248 for (j=0;j<locnnodes*locsdim;j++) {
03249 if (mode_coo == MED_FULL_INTERLACE && !(j % locsdim))
03250 fprintf(stdout,"\n [ %5"MED_IFORMAT" ] : ", (j/locsdim + 1) );
03251 if (mode_coo == MED_NO_INTERLACE && ! (j % locnnodes))
03252 fprintf(stdout,"\n\n ");
03253 fprintf(stdout," %-+9.6f ",*(refcoo+j));
03254 }
03255 printf("\n");
03256 printf("\t Localisation des points de GAUSS : \n\t\t");
03257
03258 for (j=0;j<ngauss*locsdim;j++) {
03259 if (mode_coo == MED_FULL_INTERLACE && !(j % locsdim))
03260 fprintf(stdout,"\n [ %5"MED_IFORMAT" ] : ", (j/locsdim + 1) );
03261 if (mode_coo == MED_NO_INTERLACE && ! (j % ngauss))
03262 fprintf(stdout,"\n\n ");
03263 fprintf(stdout," %-+9.6f ",*(gscoo+j));
03264 }
03265 printf("\n");
03266 printf("\t Poids associes aux points de GAUSS :\n\t\t");
03267 for (j=0;j<t3;j++) printf(" %f ",*(wg+j));
03268 printf("\n");
03269 }
03270 if (strlen(ipointstructmeshname)) {
03271 printf("\t Maillage support de section d'élément de structure |%s|.\n",ipointstructmeshname);
03272 printf("\t Mailles des sections d'élément de structure de type |%s|.\n",sectiongeotypename);
03273 printf("\t Nombre de mailles par section d'élément de structure : "IFORMAT".\n",nsectionmeshcell);
03274 }
03275 if (strlen(geointerpname)) {
03276 printf("\t Tranformation géométrique associée à la localisation |%s|.\n",geointerpname);
03277 }
03278 printf("\n\n");
03279 }
03280 free(refcoo);
03281 free(gscoo);
03282 free(wg);
03283 }
03284
03285 return;
03286 }
03287
03288
03289 med_idt ouverture_fichier_MED(char *fichier)
03290 {
03291 med_idt fid;
03292 med_err ret = 0;
03293 med_int majeur,mineur,release;
03294 med_bool hdfok;
03295 med_bool medok;
03296
03297
03298 ret = (int) access(fichier,F_OK);
03299 if (ret <0) { SSCRUTE(fichier);}
03300 EXIT_IF(ret < 0,"Le fichier n'est pas accessible ou n'existe pas ",
03301 fichier);
03302
03303
03304 ret = MEDfileCompatibility (fichier,&hdfok, &medok );
03305 EXIT_IF(ret < 0,"Impossible de déterminer la compatibilité de format. ",
03306 fichier);
03307
03308 EXIT_IF(!hdfok,"Le fichier n'est pas dans un format HDF compatible ", fichier);
03309 EXIT_IF(!medok,"Le fichier n'est pas dans un format MED compatible ", fichier);
03310
03311
03312 MEDlibraryNumVersion(&majeur,&mineur,&release);
03313 fprintf(stdout,
03314 "- Lecture du fichier à l'aide de la bibliotheque MED V"IFORMAT"."IFORMAT"."IFORMAT" \n",
03315 majeur,mineur,release);
03316
03317
03318 fid = MEDfileOpen(fichier,MED_ACC_RDONLY);
03319 EXIT_IF( fid < 0,"Ouverture du du fichier ",fichier);
03320
03321 MEDfileNumVersionRd(fid, &majeur, &mineur, &release);
03322 EXIT_IF(( (majeur < 2) || ( (majeur == 2) && (mineur < 2)) ), "Le fichier est antérieur à la version 2.2", NULL);
03323
03324 return fid;
03325 }
03326
03327 void lecture_en_tete(med_idt fid,char* fichier)
03328 {
03329 char fichier_en_tete[MED_COMMENT_SIZE+1];
03330 med_err ret = 0;
03331
03332
03333
03334 ret = MEDfileCommentRd(fid,fichier_en_tete);
03335
03336
03337 if (ret >= 0)
03338 fprintf(stdout,"- En-tete du fichier : %s \n",fichier_en_tete);
03339
03340 return;
03341 }
03342
03343 void parametrage(med_switch_mode *mode_coo,
03344 med_connectivity_mode *typ_con)
03345 {
03346 int reponse;
03347 char _temp[256]="";
03348
03349 fprintf(stdout,"(*****************)\n");
03350 fprintf(stdout,"(* PARAMETRAGE : *)\n");
03351 fprintf(stdout,"(*****************)\n");
03352 fprintf(stdout,"- Mode d'affichage des coordonnées des noeuds ? \n");
03353 fprintf(stdout," 1. Mode entrelacé : taper 1 \n");
03354 fprintf(stdout," 2. Mode non entrelacé : taper 2 \n");
03355 reponse = 0;
03356 do {
03357 fprintf(stdout," Reponse : ");
03358 if (!scanf("%d",&reponse)) fgets(_temp, 256, stdin) ;
03359 } while (reponse != 1 && reponse != 2);
03360 if (reponse == 1)
03361 *mode_coo = MED_FULL_INTERLACE;
03362 else
03363 *mode_coo = MED_NO_INTERLACE;
03364
03365 fprintf(stdout,"- Connectivité des éléments ? \n");
03366 fprintf(stdout," 1. Nodale : taper 1 \n");
03367 fprintf(stdout," 2. Descendante : taper 2 \n");
03368 reponse = 0;
03369 do {
03370 fprintf(stdout," Reponse : ");
03371 if (!scanf("%d",&reponse)) fgets(_temp, 256, stdin) ;
03372 } while (reponse != 1 && reponse != 2);
03373 if (reponse == 1)
03374 *typ_con = MED_NODAL;
03375 else
03376 *typ_con = MED_DESCENDING;
03377
03378 return;
03379 }
03380
03381
03382 void lecture_information_maillage(const med_idt fid,
03383 const int numero,
03384 char * nommaa,
03385 med_int * const mdim,
03386 med_int * const edim,
03387 med_mesh_type * const type_maillage,
03388 char * const maillage_description,
03389 med_int * const nstep,
03390 char * const dtunit,
03391 char * const nomcoo,
03392 char * const unicoo,
03393 med_axis_type *const rep)
03394 {
03395 char nom_universel[MED_LNAME_SIZE+1];
03396 med_err ret = 0;
03397 med_sorting_type sortingtype;
03398
03399 fprintf(stdout,"\n(**********************************************************)\n");
03400 fprintf(stdout,"(* INFORMATIONS GENERALES SUR LE MAILLAGE DE CALCUL N°%2.2d: *)\n",numero);
03401 fprintf(stdout,"(**********************************************************)\n\n");
03402
03403
03404 ret = MEDmeshInfo(fid, numero,nommaa,edim,mdim,type_maillage,maillage_description,
03405 dtunit,&sortingtype,nstep,rep,nomcoo,unicoo);
03406 EXIT_IF(ret < 0,"Lecture des informations sur le maillage",NULL);
03407
03408
03409 fprintf(stdout,"- Nom du maillage : <<%s>>\n",nommaa);
03410 fprintf(stdout,"- Dimension du maillage : "IFORMAT"\n",*mdim);
03411 if (*edim > *mdim)
03412 fprintf(stdout,"- La dimension de l'espace est "IFORMAT" \n",*edim);
03413 if (*type_maillage == MED_UNSTRUCTURED_MESH)
03414 fprintf(stdout,"- Type du maillage : MED_NON_STRUCTURE \n");
03415 else
03416 fprintf(stdout,"- Type du maillage : MED_STRUCTURE \n");
03417 fprintf(stdout,"- Description associee au maillage : %s\n",
03418 maillage_description);
03419
03420 if ( *nstep > 1 )
03421 fprintf(stdout,"- Nombre d'étapes de calcul associées au maillage : "IFORMAT"\n",
03422 *nstep);
03423 if (strlen(dtunit))
03424 fprintf(stdout,"- Unité des dates d'étapes de calcul associées au maillage : %s\n",
03425 dtunit);
03426
03427
03428 ret = MEDmeshUniversalNameRd(fid,nommaa,nom_universel);
03429 if (ret == 0)
03430 fprintf(stdout,"- Nom universel du maillage : %s \n",nom_universel);
03431
03432 return;
03433 }
03434
03435
03436
03437
03438
03439
03440
03441
03442
03443
03444
03445 int main (int argc, char **argv)
03446 {
03447 med_err ret = 0;
03448 med_idt fid;
03449 int i=0,numero=0,firstmesh=0,lastmesh=0,meshit=0;
03450 med_switch_mode mode_coo = MED_UNDEF_INTERLACE;
03451 med_connectivity_mode typ_con = MED_UNDEF_CONNECTIVITY_MODE;
03452 int lecture_en_tete_seulement = 0;
03453 med_int mdim=0,nmaa=0,nmaasup=0;
03454 char nommaa[MED_NAME_SIZE+1];
03455 char maillage_description[MED_COMMENT_SIZE+1];
03456 med_mesh_type type_maillage;
03457 med_int edim;
03458 int decalage;
03459 char nomcoo[3*MED_SNAME_SIZE+1]="";
03460 char unicoo[3*MED_SNAME_SIZE+1]="";
03461 char dtunit[MED_SNAME_SIZE+1]="";
03462 med_int nstep=0,numdt=MED_NO_DT,numit=MED_NO_IT;
03463 int csit=0;
03464 med_float dt=0.0;
03465 med_axis_type rep;
03466
03467
03468 char *filename=NULL,*typ_con_param=NULL,*mode_coo_param=NULL;
03469 size_t _bannerlen=0;
03470 char _temp[MAXBANNERLEN+1]="";
03471 char * _bannerstr=NULL;
03472
03473
03474
03475 med_int _nmodels=0;
03476 med_geometry_type *_geotype_elst = NULL;
03477 char *_geotypename_elst = NULL;
03478
03479
03480
03481
03482
03483
03484
03485 structure = 0;
03486 decalage = 0;
03487 if (argc > 2 && strcmp(argv[1], "--structure") == 0) {
03488 --argc;++decalage;
03489 structure = 1;
03490 }
03491
03492 if ( (argc != 2) && (argc != 5) )
03493
03494 fprintf(stderr,"Utilisation mdump [--structure] monfichier.med [ NODALE|DESCENDANTE "
03495 "NO_INTERLACE|FULL_INTERLACE|LECTURE_EN_TETE_SEULEMENT N°MAILLAGE|0 pour tous ] \n");
03496 EXIT_IF( (argc != 2) && (argc != 5),"nombre de parametres incorrect\n",NULL);
03497
03498
03499
03500
03501
03502 filename = argv[1+decalage];
03503 fid = ouverture_fichier_MED(filename);
03504
03505
03506
03507
03508
03509
03510
03511 fprintf(stdout,"\n >>>>>> DUMP DU FICHIER %s >>>>>>\n",filename);
03512
03513
03514 lecture_en_tete(fid,filename);
03515
03516
03517 if (argc == 2)
03518 parametrage(&mode_coo,&typ_con);
03519 else {
03520 typ_con_param=argv[2 + decalage];
03521
03522 if (! strcmp(typ_con_param,"NODALE")) typ_con = MED_NODAL;
03523 if (! strcmp(typ_con_param,"DESCENDANTE")) typ_con = MED_DESCENDING;
03524 EXIT_IF( typ_con==MED_UNDEF_CONNECTIVITY_MODE,"Le paramètre de connectivité doit être soit NODALE|DESCENDANTE",NULL);
03525 mode_coo_param=argv[3 + decalage];
03526
03527 if (!strcmp(mode_coo_param,"NO_INTERLACE")) mode_coo = MED_NO_INTERLACE;
03528 if (!strcmp(mode_coo_param,"FULL_INTERLACE")) mode_coo = MED_FULL_INTERLACE;
03529 if (!strcmp(mode_coo_param,"LECTURE_EN_TETE_SEULEMENT")) { lecture_en_tete_seulement = MED_LECTURE_ENTETE_SEULEMENT;
03530 mode_coo = MED_FULL_INTERLACE;}
03531 EXIT_IF( (mode_coo==MED_UNDEF_INTERLACE) ,
03532 "Le paramètre d'entrelacement doit être soit "
03533 "NO_INTERLACE|FULL_INTERLACE|LECTURE_EN_TETE_SEULEMENT",NULL);
03534 }
03535
03536
03537
03538
03539
03540 nmaa = MEDnMesh(fid);
03541
03542
03543
03544 if (argc == 2) {
03545 if (nmaa >0) {
03546 fprintf(stdout,"- Il y a "IFORMAT" maillages dans ce fichier \n",nmaa);
03547 fprintf(stdout," Lequel voulez-vous lire (0 pour tous|1|2|3|...|n) ?\n");
03548 do {
03549 fprintf(stdout," Reponse : ");
03550 if (!scanf("%d",&numero)) fgets(_temp, 256, stdin) ;
03551 } while ( (numero > nmaa) || (numero < 0) );
03552 } else {
03553 fprintf(stdout,"- Il n'y a pas de maillage dans ce fichier \n");
03554 }
03555 } else {
03556 if ( argc == 5 ) {
03557 numero = atoi(argv[4 + decalage]);
03558 EXIT_IF(numero > nmaa || numero < 0,"ce numero de maillage n'existe pas", NULL);
03559 }
03560 }
03561
03562
03563
03564
03565
03566 nmaasup= MEDnSupportMesh(fid);
03567 if (nmaasup ) {
03568 fprintf(stdout, "\n(*****************************************************)\n");
03569 fprintf(stdout, "(* INFORMATIONS GENERALES SUR LES MAILLAGES SUPPORT: *)\n");
03570 fprintf(stdout, "(*****************************************************)\n");
03571 }
03572 for (meshit=1;meshit <= nmaasup;++meshit) {
03573
03574
03575 MEDsupportMeshInfo(fid, meshit, nommaa, &edim, &mdim,
03576 maillage_description, &rep, nomcoo, unicoo);
03577 fprintf(stdout,"\n(*******************************************)\n");
03578 fprintf(stdout,"(******** Maillage support n°%2.2d/%2.2"MED_IFORMAT" : *******)\n",meshit,nmaasup);
03579 fprintf(stdout,"(*******************************************)\n");
03580
03581 fprintf(stdout,"- Nom du maillage support : <<%s>>\n",nommaa);
03582 fprintf(stdout,"- Dimension du maillage : "IFORMAT"\n",mdim);
03583 if (edim > mdim)
03584 fprintf(stdout,"- La dimension de l'espace est "IFORMAT" \n",edim);
03585
03586 lecture_maillage_non_structure(fid,nommaa,MED_NO_DT,MED_NO_IT,mdim,edim,mode_coo,typ_con,
03587 nomcoo,unicoo,&rep, &_nmodels, &_geotype_elst,&_geotypename_elst,
03588 MED_LECTURE_MAILLAGE_SUPPORT_UNIQUEMENT);
03589
03590 }
03591
03592
03593
03594
03595
03596
03597
03598 lecture_parametres_scalaires(fid,lecture_en_tete_seulement);
03599
03600
03601
03602
03603
03604 lecture_localisation(fid,mode_coo,lecture_en_tete_seulement);
03605
03606
03607
03608
03609
03610 lecture_profils(fid,lecture_en_tete_seulement);
03611
03612
03613
03614
03615
03616
03617 lecture_modeles_elstruct( fid, lecture_en_tete_seulement);
03618
03619
03620
03621
03622
03623 lecture_fonctions_interpolation( fid, lecture_en_tete_seulement);
03624
03625
03626
03627
03628
03629 lecture_liens(fid,lecture_en_tete_seulement);
03630
03631
03632
03633
03634
03635 if (numero) {
03636 firstmesh=numero;lastmesh=numero;
03637 } else {
03638 firstmesh=1;lastmesh=nmaa;
03639 }
03640
03641 for (meshit=firstmesh;meshit<=lastmesh;++meshit) {
03642
03643 lecture_information_maillage(fid,meshit,nommaa,&mdim,&edim,&type_maillage,
03644 maillage_description,&nstep,dtunit,nomcoo,unicoo,&rep);
03645
03646
03647 for (csit=1; csit <= nstep; ++csit) {
03648
03649 ret = MEDmeshComputationStepInfo(fid, nommaa, csit, &numdt, &numit, &dt);
03650 EXIT_IF(ret < 0,"lors de l'appel à MEDmeshComputationStepInfo",NULL);
03651
03652
03653
03654
03655
03656
03657
03658 _bannerstr ="(* MAILLAGE DE CALCUL |%s| n°%2.2d A L'ETAPE DE CALCUL (n°dt,n°it)="
03659 "(% 2.2"MED_IFORMAT",% 2.2"MED_IFORMAT"): %.*s*)\n";
03660 snprintf(_temp,MAXBANNERLEN+1,_bannerstr,nommaa,meshit,numdt,numit,0,"");
03661 _bannerlen =strlen(_temp);
03662 fprintf(stdout,"\n(");
03663 for (i=0;i< _bannerlen-6; i++) fprintf(stdout,"*");
03664 fprintf(stdout,")\n%s(",_temp);
03665 for (i=0;i< _bannerlen-6; i++) fprintf(stdout,"*");
03666 fprintf(stdout,")\n");
03667
03668
03669
03670
03671
03672
03673 if (type_maillage == MED_UNSTRUCTURED_MESH)
03674 lecture_maillage_non_structure(fid,nommaa,numdt,numit,mdim,edim,mode_coo,typ_con,
03675 nomcoo,unicoo,&rep,
03676 &_nmodels,&_geotype_elst,&_geotypename_elst,
03677 lecture_en_tete_seulement);
03678 else {
03679 lecture_maillage_structure(fid,nommaa,numdt,numit,mdim,edim,mode_coo,
03680 nomcoo,unicoo,lecture_en_tete_seulement);
03681 }
03682
03683
03684 lecture_resultats(fid,nommaa,numdt,numit,mode_coo,
03685 _nmodels,_geotype_elst,_geotypename_elst,
03686 lecture_en_tete_seulement);
03687
03688 free(_geotype_elst);
03689 free(_geotypename_elst);
03690 }
03691 }
03692
03693
03694
03695
03696 ret = MEDfileClose(fid);
03697 EXIT_IF(ret < 0,"lors de la fermeture du fichier",argv[1 + decalage]);
03698
03699 fprintf(stdout,"\n >>>>>> FIN DU DUMP DU FICHIER %s >>>>>>\n",argv[1 + decalage]);
03700
03701 return EXIT_SUCCESS;
03702 }