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 #include <med.h>
00026 #define MESGERR 1
00027 #include <med_utils.h>
00028
00029 #ifdef DEF_LECT_ECR
00030 #define MODE_ACCES MED_ACC_RDWR
00031 #elif DEF_LECT_AJOUT
00032 #define MODE_ACCES MED_ACC_RDEXT
00033 #else
00034 #define MODE_ACCES MED_ACC_CREAT
00035 #endif
00036
00037 int afficheCorres(med_idt fid, char *maa, char *jnt,
00038 med_entity_type typ_ent_local, med_geometry_type typ_geo_local,
00039 med_entity_type typ_ent_distant, med_geometry_type typ_geo_distant,
00040 char *type);
00041
00042 int main (int argc, char **argv)
00043
00044
00045 {
00046 med_err ret = 0;
00047 med_idt fid;
00048 char maa[MED_NAME_SIZE+1],maa_dist[MED_NAME_SIZE+1];
00049 med_int mdim,sdim;
00050 med_int njnt,ncor,ndom,nc;
00051 char jnt[MED_NAME_SIZE+1],corr[MED_NAME_SIZE+1];
00052 char des[MED_COMMENT_SIZE+1];
00053 char dtunit[MED_SNAME_SIZE+1]="";
00054 char nomcoo[3*MED_SNAME_SIZE+1];
00055 char unicoo[3*MED_SNAME_SIZE+1];
00056 med_axis_type rep;
00057 med_mesh_type type;
00058 med_sorting_type sort;
00059 med_int nstep=0,njstep=0,nodtitncor=0,nentity=0;
00060 med_entity_type typ_ent_local,typ_ent_distant;
00061 med_geometry_type typ_geo_local,typ_geo_distant;
00062 int i,j,k;
00063
00064 if (argc != 2) {
00065 MESSAGE("Il faut passer un fichier MED en paramètre");
00066 return -1;
00067 }
00068
00069
00070 if ((fid = MEDfileOpen(argv[1],MED_ACC_RDONLY)) < 0) {
00071 MESSAGE("Erreur à l'ouverture du fichier : "); SSCRUTE(argv[1]);
00072 return -1;
00073 }
00074
00075 if ((sdim=MEDmeshnAxis(fid, 1)) <0) {
00076 MESSAGE("Erreur à la lecture de la dimension de l'espace du maillage :");
00077 SSCRUTE(maa);
00078 return -1;
00079 }
00080
00081
00082 if ( MEDmeshInfo( fid, 1, maa, &sdim, &mdim, &type, des, dtunit, &sort,
00083 &nstep, &rep, nomcoo,unicoo) < 0 ) {
00084 MESSAGE("Erreur a la lecture des informations sur le maillage : ");SSCRUTE(maa);
00085 return -1;
00086 } else {
00087 printf("Maillage de nom : |%s| , de dimension : "IFORMAT" , et de type %d\n",maa,mdim,type);
00088 printf("\t -Dimension de l'espace : "IFORMAT"\n",sdim);
00089 printf("\t -Description du maillage : |%s|\n",des);
00090 printf("\t -Noms des axes : |%s|\n",nomcoo);
00091 printf("\t -Unités des axes : |%s|\n",unicoo);
00092 printf("\t -Type de repère : %d\n",rep);
00093 printf("\t -Nombre d'étapes de calcul : "IFORMAT"\n",nstep);
00094 printf("\t -Unité des dates : |%s|\n\n",dtunit);
00095 }
00096
00097
00098 if ((njnt = MEDnSubdomainJoint(fid,maa)) < 0) {
00099 MESSAGE("Erreur a la lecture du nombre de joints");
00100 return -1;
00101 }
00102 printf("Nombre de joints : "IFORMAT" \n",njnt);
00103
00104
00105 for (i = 0;i<njnt;i++) {
00106 printf("Joint numero : %d \n",i+1);
00107
00108
00109 if (MEDsubdomainJointInfo(fid,maa,i+1,jnt,des,&ndom,maa_dist,&njstep,&nodtitncor) < 0) {
00110 MESSAGE("Erreur a la lecture du joint d'indice");
00111 ISCRUTE_int(i+1);
00112 return -1;
00113 }
00114 printf("Nom du joint: |%s| \n",jnt);
00115 printf("Description du joint : |%s| \n",des);
00116 printf("Domaine en regard : "IFORMAT" \n",ndom);
00117 printf("Maillage distant : |%s| \n",maa_dist);
00118 printf("Nombre d'étapes de calcul : "IFORMAT" \n",njstep);
00119 printf("Nombre de correspondance pour (NO_DT,NO_IT) : "IFORMAT" \n",nodtitncor);
00120
00121
00122
00123
00124
00125
00126
00127 afficheCorres(fid,maa,jnt,MED_NODE,0,MED_NODE,0,"noeud/noeud");
00128
00129
00130 afficheCorres(fid,maa,jnt,MED_NODE,0,MED_CELL,MED_TRIA3,"noeud/TRIA3");
00131
00132
00133
00134
00135
00136
00137 ncor=1;
00138
00139 while ( ncor <= nodtitncor ) {
00140 ISCRUTE(ncor);
00141 if ( MEDsubdomainCorrespondenceSizeInfo(fid,maa,jnt,MED_NO_DT,MED_NO_IT,ncor,
00142 &typ_ent_local,&typ_geo_local,&typ_ent_distant,&typ_geo_distant,
00143 &nentity) < 0 ) {
00144 MESSAGE("Erreur a la lecture des infos sur le nombre d'entite en regard");
00145 return -1;
00146 }
00147
00148
00149 afficheCorres(fid,maa,jnt,typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant,"------");
00150
00151 ncor++;
00152 }
00153
00154 }
00155
00156
00157 if (MEDfileClose(fid) < 0) {
00158 MESSAGE("Erreur a la fermeture du fichier ");
00159 return -1;
00160 }
00161
00162 return ret;
00163 }
00164
00165
00166
00167
00168 int afficheCorres(med_idt fid, char *maa, char *jnt,
00169 med_entity_type typ_ent_local, med_geometry_type typ_geo_local,
00170 med_entity_type typ_ent_distant, med_geometry_type typ_geo_distant,
00171 char *type)
00172 {
00173 med_int nc;
00174 med_int *cortab;
00175 int k,ncor,ret=0;
00176
00177 ISCRUTE_int(typ_ent_local);ISCRUTE_int(typ_geo_local);
00178 ISCRUTE_int(typ_ent_distant);ISCRUTE_int(typ_geo_distant);
00179 if ( MEDsubdomainCorrespondenceSize(fid,maa,jnt,MED_NO_DT,MED_NO_IT,
00180 typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant,
00181 &nc) < 0) {
00182 MESSAGE("Erreur a la lecture des infos sur le nombre d'entite en regard de type");
00183 SSCRUTE(type);
00184 return -1;
00185 }
00186
00187 printf("nb de couples d'entites en regard |%s|: "IFORMAT" \n",type,nc);
00188
00189 if (nc > 0) {
00190 cortab = (med_int*) malloc(sizeof(med_int)*nc*2);
00191 if ((ret=MEDsubdomainCorrespondenceRd(fid,maa,jnt,MED_NO_DT,MED_NO_IT,
00192 typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant,
00193 cortab)) < 0) {
00194 MESSAGE("Erreur a la lecture des correspondances sur ");
00195 SSCRUTE(type);
00196 ret = -1;
00197 }
00198 if (ret == 0)
00199 for (k=0;k<nc;k++)
00200 printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",k+1,*(cortab+2*k),
00201 *(cortab+2*k+1));
00202 free(cortab);
00203 }
00204 return ret;
00205 }
00206