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 med_int _rnaxis = 0;
00046
00047 const med_int _nnoe = 5;
00048
00049
00050
00051 med_float coo[5*3] = {0.0, 0.0, 0.0, 0.1 , 0.0, 0.0,
00052 1.0, 0.0, 0.0, 1.1 , 0.0, 0.0,
00053 2.0, 0.0, 0.0 };
00054 med_float * _rcoo=NULL;
00055
00056 med_int nse2 = 4;
00057 med_int se2[10] = {1,2, 2,3, 3,4, 4,5};
00058 med_int * _rse2=NULL;
00059
00060 const char _supportmeshname[]="SUPPORT_POUTRE";
00061 char _axisname[3*MED_SNAME_SIZE+1]="";
00062 char _axisunit[3*MED_SNAME_SIZE+1]="";
00063
00064 char _rsupportmeshname[MED_NAME_SIZE+1]="";
00065 char _raxisname[3*MED_SNAME_SIZE+1]="";
00066 char _raxisunit[3*MED_SNAME_SIZE+1]="";
00067 char _rdescription[MED_COMMENT_SIZE+1]="";
00068 med_axis_type _raxistype;
00069 med_bool _chgt=MED_FALSE,_trsf=MED_FALSE;
00070
00071 strcat(_axisname,"x ");
00072 strcat(_axisname,"y ");
00073 strcat(_axisname,"z ");
00074 strcat(_axisunit,"cm ");
00075 strcat(_axisunit,"cm ");
00076 strcat(_axisunit,"cm ");
00077
00078
00079 if ((_fid = MEDfileOpen("current.med",MODE_ACCES)) < 0) {
00080 MESSAGE("Impossible de creer le fichier current.med");
00081 return -1;
00082 }
00083
00084 if (MEDsupportMeshCr( _fid, _supportmeshname, _meshdim, _meshdim,"Maillage support ED de type poutre",
00085 MED_CARTESIAN,_axisname, _axisname) < 0) {
00086 MESSAGE("Erreur a la creation du maillage support : "); SSCRUTE(_supportmeshname);
00087 return -1;
00088 }
00089
00090
00091
00092 if (MEDmeshNodeCoordinateWr(_fid,_supportmeshname,MED_NO_DT,MED_NO_IT,MED_UNDEF_DT,
00093 MED_FULL_INTERLACE, _nnoe, coo) < 0) {
00094 MESSAGE("Erreur a l'écriture des coordonnees des noeuds du maillage support");
00095 return -1;
00096 }
00097
00098
00099
00100 if ( MEDmeshElementConnectivityWr(_fid,_supportmeshname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
00101 MED_CELL, MED_SEG2, MED_NODAL,
00102 MED_FULL_INTERLACE, nse2, se2) < 0 ) {
00103 MESSAGE("Impossible d'ecrire la connectivité des segments du maillage support : ");
00104 return -1;
00105 }
00106
00107 if (MEDsupportMeshCr( _fid, "MED_BILLE_SUPPORT", _meshdim, _meshdim,"Maillage support ED de type bille",
00108 MED_CARTESIAN,_axisname, _axisname) < 0) {
00109 MESSAGE("Erreur a la creation du maillage support : "); SSCRUTE(_supportmeshname);
00110 return -1;
00111 }
00112
00113
00114
00115 if (MEDmeshNodeCoordinateWr(_fid,"MED_BILLE_SUPPORT",MED_NO_DT,MED_NO_IT,MED_UNDEF_DT,
00116 MED_FULL_INTERLACE, 1, coo) < 0) {
00117 MESSAGE("Erreur a l'écriture des coordonnees des noeuds du maillage support : MED_BILLE_SUPPORT.");
00118 return -1;
00119 }
00120
00121
00122 if ( (_n =MEDnSupportMesh(_fid)) < 0 ) {
00123 MESSAGE("Erreur à la lecture du nombre de maillages supports : ");
00124 return -1;
00125 }
00126
00127 for (_i=1; _i <= _n; ++_i) {
00128
00129 if ( (_rnaxis = MEDsupportMeshnAxis(_fid, _i)) < 0) {
00130 MESSAGE("Erreur à la lecture du nombre d'axe du repère d'un maillage support : ");
00131 return -1;
00132 }
00133 printf("\t -Dimension de l'espace : %d\n",_rnaxis);
00134
00135 if ( MEDsupportMeshInfo(_fid, _i ,
00136 _rsupportmeshname, &_rspacedim, &_rmeshdim, _rdescription,
00137 &_raxistype, _raxisname, _raxisunit) < 0 ) {
00138 MESSAGE("Erreur à la lecture des informations sur le maillage support : "); SSCRUTE(_supportmeshname);
00139 return -1;
00140 }
00141
00142 printf("Maillage support de nom : |%s| , de dimension : %d.\n",_rsupportmeshname, _rmeshdim);
00143 printf("\t -Dimension de l'espace : %d\n",_rspacedim);
00144 printf("\t -Description du maillage : %s\n",_rdescription);
00145 printf("\t -Noms des axes : %s\n",_raxisname);
00146 printf("\t -Unités des axes : %s\n",_raxisunit);
00147
00148
00149 _rnnoe = MEDmeshnEntity(_fid,_rsupportmeshname,MED_NO_DT,MED_NO_IT,
00150 MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,
00151 &_chgt,&_trsf);
00152 if (_rnnoe < 0) {
00153 MESSAGE("Erreur a la lecture du nombre de noeuds. ");
00154 return -1;
00155 } else
00156 printf("Nombre de noeuds du maillage support: "IFORMAT" \n",_rnnoe);
00157
00158
00159 if (_rnnoe > 0) {
00160
00161 _rcoo = (med_float*) calloc(_rnnoe*_rspacedim,sizeof(med_float));
00162
00163 if ( MEDmeshNodeCoordinateRd(_fid, _rsupportmeshname, MED_NO_DT, MED_NO_IT,MED_FULL_INTERLACE, _rcoo) < 0 ) {
00164 MESSAGE("Erreur a la lecture des coordonnees des noeuds");
00165 return -1;
00166 } else {
00167 printf("Valeur de _rcoo : ");
00168 for (_j=0;_j<_rnnoe*_rspacedim;_j++) printf("%4.2f ",_rcoo[_j]);
00169 printf("\n");
00170 }
00171
00172 free(_rcoo);
00173 }
00174
00175
00176 _rnse2 = MEDmeshnEntity(_fid,_rsupportmeshname,MED_NO_DT,MED_NO_IT,
00177 MED_CELL,MED_SEG2,MED_CONNECTIVITY,MED_NODAL,
00178 &_chgt,&_trsf);
00179
00180 if (_rnse2 < 0) {
00181 MESSAGE("Erreur a la lecture du nombre de segments.");
00182 return -1;
00183 } else
00184 printf("Nombre de segments du maillage support: "IFORMAT" \n",_rnse2);
00185
00186 if (_rnse2 > 0) {
00187
00188 _rse2 = (med_int*) calloc(_rnse2*2,sizeof(med_int));
00189
00190 if ( MEDmeshElementConnectivityRd(_fid, _rsupportmeshname, MED_NO_DT, MED_NO_IT,
00191 MED_CELL,MED_SEG2,MED_NODAL,MED_FULL_INTERLACE, _rse2) < 0 ) {
00192 MESSAGE("Erreur a la lecture des connectivités des segments");
00193 return -1;
00194 } else {
00195 printf("Valeur de _rse2 : ");
00196 for (_j=0;_j<_rnse2*2;_j++) printf("%d ",_rse2[_j]);
00197 printf("\n");
00198 }
00199
00200 free(_rse2);
00201 }
00202
00203 }
00204
00205 return 0;
00206 }