00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <med.h>
00020 #define MESGERR 1
00021 #include <med_utils.h>
00022 #include <string.h>
00023
00024 #ifdef DEF_LECT_ECR
00025 #define MODE_ACCES MED_ACC_RDWR
00026 #elif DEF_LECT_AJOUT
00027 #define MODE_ACCES MED_ACC_RDEXT
00028 #else
00029 #define MODE_ACCES MED_ACC_CREAT
00030 #endif
00031
00032 int main (int argc, char **argv)
00033
00034 {
00035
00036 int _i = 0;
00037 int _j = 0;
00038 med_idt _fid = 0;
00039 med_int _meshdim = 3;
00040 med_int _rmeshdim = 0;
00041 med_int _rspacedim = 0;
00042 med_int _n = 0;
00043 med_int _rnnoe = 0;
00044 med_int _rnse2 = 0;
00045
00046 const med_int _nnoe = 5;
00047
00048
00049
00050 med_float coo[5*3] = {0.0, 0.0, 0.0, 0.1 , 0.0, 0.0,
00051 1.0, 0.0, 0.0, 1.1 , 0.0, 0.0,
00052 2.0, 0.0, 0.0 };
00053 med_float * _rcoo=NULL;
00054
00055 med_int nse2 = 4;
00056 med_int se2[10] = {1,2, 2,3, 3,4, 4,5};
00057 med_int * _rse2=NULL;
00058
00059 const char _supportmeshname[]="SUPPORT_POUTRE";
00060 char _axisname[3*MED_SNAME_SIZE+1]="";
00061 char _axisunit[3*MED_SNAME_SIZE+1]="";
00062
00063 char _rsupportmeshname[MED_NAME_SIZE+1]="";
00064 char _raxisname[3*MED_SNAME_SIZE+1]="";
00065 char _raxisunit[3*MED_SNAME_SIZE+1]="";
00066 char _rdescription[MED_COMMENT_SIZE+1]="";
00067 med_axis_type _raxistype;
00068 med_bool _chgt=MED_FALSE,_trsf=MED_FALSE;
00069
00070 strcat(_axisname,"x ");
00071 strcat(_axisname,"y ");
00072 strcat(_axisname,"z ");
00073 strcat(_axisunit,"cm ");
00074 strcat(_axisunit,"cm ");
00075 strcat(_axisunit,"cm ");
00076
00077
00078 if ((_fid = MEDfileOpen("current.med",MODE_ACCES)) < 0) {
00079 MESSAGE("Impossible de creer le fichier current.med");
00080 return -1;
00081 }
00082
00083 if (MEDsupportMeshCr( _fid, _supportmeshname, _meshdim, _meshdim,"Maillage support ED de type poutre",
00084 MED_CARTESIAN,_axisname, _axisname) < 0) {
00085 MESSAGE("Erreur a la creation du maillage support : "); SSCRUTE(_supportmeshname);
00086 return -1;
00087 }
00088
00089
00090
00091 if (MEDmeshNodeCoordinateWr(_fid,_supportmeshname,MED_NO_DT,MED_NO_IT,MED_UNDEF_DT,
00092 MED_FULL_INTERLACE, _nnoe, coo) < 0) {
00093 MESSAGE("Erreur a l'écriture des coordonnees des noeuds du maillage support");
00094 return -1;
00095 }
00096
00097
00098
00099 if ( MEDmeshElementConnectivityWr(_fid,_supportmeshname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
00100 MED_CELL, MED_SEG2, MED_NODAL,
00101 MED_FULL_INTERLACE, nse2, se2) < 0 ) {
00102 MESSAGE("Impossible d'ecrire la connectivité des segments du maillage support : ");
00103 return -1;
00104 }
00105
00106 if (MEDsupportMeshCr( _fid, "MED_BILLE_SUPPORT", _meshdim, _meshdim,"Maillage support ED de type bille",
00107 MED_CARTESIAN,_axisname, _axisname) < 0) {
00108 MESSAGE("Erreur a la creation du maillage support : "); SSCRUTE(_supportmeshname);
00109 return -1;
00110 }
00111
00112
00113
00114 if (MEDmeshNodeCoordinateWr(_fid,"MED_BILLE_SUPPORT",MED_NO_DT,MED_NO_IT,MED_UNDEF_DT,
00115 MED_FULL_INTERLACE, 1, coo) < 0) {
00116 MESSAGE("Erreur a l'écriture des coordonnees des noeuds du maillage support : MED_BILLE_SUPPORT.");
00117 return -1;
00118 }
00119
00120
00121 if ( (_n =MEDnSupportMesh(_fid)) < 0 ) {
00122 MESSAGE("Erreur à la lecture du nombre de maillages supports : ");
00123 return -1;
00124 }
00125
00126 for (_i=1; _i <= _n; ++_i) {
00127
00128
00129 if ( MEDsupportMeshInfo(_fid, _i ,
00130 _rsupportmeshname, &_rspacedim, &_rmeshdim, _rdescription,
00131 &_raxistype, _raxisname, _raxisunit) < 0 ) {
00132 MESSAGE("Erreur à la lecture des informations sur le maillage support : "); SSCRUTE(_supportmeshname);
00133 return -1;
00134 }
00135
00136 printf("Maillage support de nom : |%s| , de dimension : %d.\n",_rsupportmeshname, _rmeshdim);
00137 printf("\t -Dimension de l'espace : %d\n",_rspacedim);
00138 printf("\t -Description du maillage : %s\n",_rdescription);
00139 printf("\t -Noms des axes : %s\n",_raxisname);
00140 printf("\t -Unités des axes : %s\n",_raxisunit);
00141
00142
00143 _rnnoe = MEDmeshnEntity(_fid,_rsupportmeshname,MED_NO_DT,MED_NO_IT,
00144 MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,
00145 &_chgt,&_trsf);
00146 if (_rnnoe < 0) {
00147 MESSAGE("Erreur a la lecture du nombre de noeuds. ");
00148 return -1;
00149 } else
00150 printf("Nombre de noeuds du maillage support: "IFORMAT" \n",_rnnoe);
00151
00152
00153 if (_rnnoe > 0) {
00154
00155 _rcoo = (med_float*) calloc(_rnnoe*_rspacedim,sizeof(med_float));
00156
00157 if ( MEDmeshNodeCoordinateRd(_fid, _rsupportmeshname, MED_NO_DT, MED_NO_IT,MED_FULL_INTERLACE, _rcoo) < 0 ) {
00158 MESSAGE("Erreur a la lecture des coordonnees des noeuds");
00159 return -1;
00160 } else {
00161 printf("Valeur de _rcoo : ");
00162 for (_j=0;_j<_rnnoe*_rspacedim;_j++) printf("%4.2f ",_rcoo[_j]);
00163 printf("\n");
00164 }
00165
00166 free(_rcoo);
00167 }
00168
00169
00170 _rnse2 = MEDmeshnEntity(_fid,_rsupportmeshname,MED_NO_DT,MED_NO_IT,
00171 MED_CELL,MED_SEG2,MED_CONNECTIVITY,MED_NODAL,
00172 &_chgt,&_trsf);
00173
00174 if (_rnse2 < 0) {
00175 MESSAGE("Erreur a la lecture du nombre de segments.");
00176 return -1;
00177 } else
00178 printf("Nombre de segments du maillage support: "IFORMAT" \n",_rnse2);
00179
00180 if (_rnse2 > 0) {
00181
00182 _rse2 = (med_int*) calloc(_rnse2*2,sizeof(med_int));
00183
00184 if ( MEDmeshElementConnectivityRd(_fid, _rsupportmeshname, MED_NO_DT, MED_NO_IT,
00185 MED_CELL,MED_SEG2,MED_NODAL,MED_FULL_INTERLACE, _rse2) < 0 ) {
00186 MESSAGE("Erreur a la lecture des connectivités des segments");
00187 return -1;
00188 } else {
00189 printf("Valeur de _rse2 : ");
00190 for (_j=0;_j<_rnse2*2;_j++) printf("%d ",_rse2[_j]);
00191 printf("\n");
00192 }
00193
00194 free(_rse2);
00195 }
00196
00197 }
00198
00199 return 0;
00200 }