00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MESGERR
00020 #define MESGERR 1
00021 #endif
00022
00023 #include "med_config.h"
00024 #include "med_outils.h"
00025 #include "med_versioned.h"
00026 #include <string.h>
00027
00028 #include <2.3.6/med23v30.h>
00029 #include <2.3.6/med23v30_proto.h>
00030 #include <2.3.6/med_proto.h>
00031 #include "2.3.6/med23v30_misc.h"
00032
00033 #include "MAJ_236_300.h"
00034 #include "MAJ_version.h"
00035
00036 #define MAX_SPACE_DIM 3
00037
00038 void MAJ_236_300_maillages(med_idt fid)
00039 {
00040 med_err _ret = -1;
00041 med_err ret = -1;
00042 med_err _fret = -1;
00043 med_err _err = -1;
00044 int dummy=0;
00045 char _pathi[MED_TAILLE_MAA+MED_NAME_SIZE+1+2*MED_TAILLE_NOM_ENTITE+1+3+1]=MED_MAA;
00046 char _pathf[MED_TAILLE_MAA+MED_NAME_SIZE+1+2*MED_MAX_PARA+1+2*MED_TAILLE_NOM_ENTITE+1+1]=MED_MAA;
00047 char _pathgridf[MED_TAILLE_MAA+MED_NAME_SIZE+1+2*MED_MAX_PARA+1+2*MED_TAILLE_NOM_ENTITE+1+1]=MED_MAA;
00048 char _pathgridi[MED_TAILLE_MAA+MED_NAME_SIZE+1+2*MED_TAILLE_NOM_ENTITE+1+3+1]=MED_MAA;
00049 char _pathfam[MED_TAILLE_FAS+MED_NAME_SIZE+1+MED_NAME_SIZE+1]=MED_FAS;
00050 med_size _n=0;
00051 med_idt _datagroup=0;
00052 int _meshit=0;
00053 char _imeshname[MED_NAME_SIZE+1];
00054 char _fmeshname[MED_NAME_SIZE+1];
00055 char * _meshname=_imeshname;
00056 med_int _spacedim=0;
00057 med_int _meshdim=0;
00058 med_mesh_type _meshtype=MED_UNDEF_MESH_TYPE;
00059 char _description[MED_COMMENT_SIZE+1]="";
00060 char _dtunit[MED_SNAME_SIZE+1]="";
00061 med_sorting_type _sortingtype=MED_SORT_UNDEF;
00062 med_int _nstep=0;
00063 med_axis_type _axistype=MED_UNDEF_AXIS_TYPE;
00064 char _axisname[3*MED_SNAME_SIZE+1];
00065 char _axisunit[3*MED_SNAME_SIZE+1];
00066 int _itmplen=0;
00067 int _ftmplen=0;
00068 int _gitmplen=0;
00069 int _gftmplen=0;
00070 med_int _1=1;
00071 med_bool _datagroupexist=MED_FALSE,_isasoftlink=MED_FALSE;
00072 med_type_grille _gridtype;
00073 med_int _gridstruct[MAX_SPACE_DIM] = {0,0,0};
00074 med_bool _mustwrite_gridstruct= MED_FALSE;
00075 hid_t _ocp_plist_id;
00076 hid_t _lcp_plist_id;
00077 htri_t _groupexist;
00078
00079
00080
00081
00082
00083 ret=_MEDnObjects(fid,MED_MAA,&_n);
00084 MED_ERR_EXIT_IF( ( ret == (MED_ERR_COUNT + MED_ERR_DATAGROUP)),
00085 MED_ERR_COUNT,MED_ERR_MESH,MED_MAA);
00086
00087
00088
00089
00090
00091
00092 _groupexist= H5Aexists_by_name( fid, _pathi, MED_COMMENT_NAME, H5P_DEFAULT );
00093 if (_groupexist > 0) {
00094 MED_ERR_EXIT_IF( _MEDattributeStringRdByName(fid,_pathi,MED_COMMENT_NAME,MED_COMMENT_SIZE,
00095 _description ) < 0 ,
00096 MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_COMMENT_NAME);
00097
00098 H5Adelete_by_name( fid, _pathi,MED_COMMENT_NAME, H5P_DEFAULT );
00099
00100 MED_ERR_EXIT_IF( _MEDattributeStringWrByName(fid,"/",MED_COMMENT_NAME,MED_COMMENT_SIZE,
00101 _description ) < 0 ,
00102 MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_COMMENT_NAME);
00103 }
00104
00105 for (_meshit=0;_meshit<_n;++_meshit) {
00106
00107
00108
00109
00110 MED_ERR_EXIT_IF( _MEDobjectGetName(fid, MED_MAA ,_meshit, _imeshname) < 0 ,
00111 MED_ERR_ACCESS,MED_ERR_DATAGROUP,_imeshname);
00112
00113 MAJ_version_num(fid,2,3,6);
00114 _MEDmeshInfoByName236(dummy,fid, _imeshname, &_spacedim, &_meshdim, &_meshtype,
00115 _description, _dtunit, &_sortingtype, &_nstep,
00116 &_axistype, _axisname, _axisunit, &_fret);
00117 MED_ERR_EXIT_IF(_fret < 0, MED_ERR_CALL, MED_ERR_API, "MEDmeshInfoByName236");
00118 MAJ_version(fid);
00119
00120 MED_ERR_EXIT_IF( _spacedim > MAX_SPACE_DIM ,
00121 MED_ERR_INVALID,MED_ERR_PARAMETER,"_spacedim");
00122
00123 if ( MAJ_236_300_chaine(_imeshname,_fmeshname) ) {
00124
00125 fprintf(stdout," >>> Normalisation du nom de maillage [%s] \n",_imeshname);
00126
00127 strcpy(&_pathi[MED_TAILLE_MAA],_imeshname);
00128 strcpy(&_pathf[MED_TAILLE_MAA],_fmeshname);
00129
00130 ret = H5Gmove(fid, _pathi, _pathf );
00131 EXIT_IF(ret < 0,"Renommage du maillage en",_fmeshname);
00132 _meshname=_fmeshname;
00133 fprintf(stdout," >>> Normalisation du nom du maillage [%s] ... OK ... \n",_fmeshname);
00134 } else {
00135 strcpy(&_pathf[MED_TAILLE_MAA],_meshname);
00136 strcpy(&_pathi[MED_TAILLE_MAA],_meshname);
00137 }
00138
00139
00140
00141
00142
00143
00144
00145 MED_ERR_EXIT_IF( MEDmeshCr(fid, _meshname, _spacedim, _meshdim, _meshtype,
00146 _description, _dtunit, MED_SORT_DTIT,
00147 _axistype, _axisname, _axisunit) < 0,
00148 MED_ERR_CALL,MED_ERR_API,"MEDmeshCr");
00149
00150
00151 if ( _meshtype != MED_UNSTRUCTURED_MESH ) {
00152 MAJ_version_num(fid,2,3,6);
00153 MED_ERR_EXIT_IF( MEDnatureGrilleLire(fid, _meshname, &_gridtype) < 0
00154 ,MED_ERR_CALL,MED_ERR_API," MEDnatureGrilleLire");
00155
00156
00157 strcpy(&_pathgridi[MED_TAILLE_MAA],_meshname);
00158
00159 strcat(_pathgridi,"/NOE/");
00160 _gitmplen=strlen(_pathgridi);
00161
00162
00163 if ( (_gridtype == MED_GRILLE_CARTESIENNE) || (_gridtype == MED_GRILLE_POLAIRE) ) {
00164
00165 strcpy(&_pathgridi[_gitmplen],"IN1");
00166
00167 H5Adelete_by_name( fid, _pathgridi,MED_NOM_UNI, H5P_DEFAULT );
00168 H5Adelete_by_name( fid, _pathgridi,MED_NOM_NOM, H5P_DEFAULT );
00169 strcpy(&_pathgridi[_gitmplen],"IN2");
00170
00171 H5Adelete_by_name( fid, _pathgridi,MED_NOM_UNI, H5P_DEFAULT );
00172 H5Adelete_by_name( fid, _pathgridi,MED_NOM_NOM, H5P_DEFAULT );
00173 strcpy(&_pathgridi[_gitmplen],"IN3");
00174
00175 H5Adelete_by_name( fid, _pathgridi,MED_NOM_UNI, H5P_DEFAULT );
00176 H5Adelete_by_name( fid, _pathgridi,MED_NOM_NOM, H5P_DEFAULT );
00177
00178 MAJ_version(fid);
00179
00180 } else {
00181 MED_ERR_EXIT_IF( MEDstructureCoordLire(fid,_meshname,_meshdim,_gridstruct) < 0
00182 ,MED_ERR_CALL,MED_ERR_API,"MEDstructureCoordLire");
00183 strcpy(&_pathgridi[_gitmplen],"COO");
00184 H5Adelete_by_name( fid, _pathgridi,MED_NOM_IN1, H5P_DEFAULT );
00185 H5Adelete_by_name( fid, _pathgridi,MED_NOM_IN2, H5P_DEFAULT );
00186 H5Adelete_by_name( fid, _pathgridi,MED_NOM_IN3, H5P_DEFAULT );
00187
00188 MAJ_version(fid);
00189
00190 _mustwrite_gridstruct= MED_TRUE;
00191
00192 }
00193 }
00194
00195
00196 MED_ERR_EXIT_IF( MEDmeshComputationStepCr(fid,_meshname,MED_NO_DT,MED_NO_IT,
00197 MED_NO_DT,MED_NO_IT,0) < 0
00198 ,MED_ERR_CALL,MED_ERR_API,"MEDmeshComputationStepCr");
00199 _ftmplen=strlen(_pathf);
00200 _pathf[_ftmplen]='/'; ++_ftmplen;
00201 _MEDgetComputationStepName(MED_SORT_DTIT,MED_NO_DT,MED_NO_IT,&_pathf[_ftmplen]);
00202 _ftmplen+=2*MED_MAX_PARA;
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 H5Adelete_by_name( fid, _pathf,MED_NOM_CGT, H5P_DEFAULT );
00214 MED_ERR_EXIT_IF( _MEDattributeNumWrByName(fid,_pathf,MED_NOM_CGT,MED_INTERNAL_INT,
00215 (const unsigned char * const) &_1 ) < 0,
00216 MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_CGT);
00217
00218 _pathf[_ftmplen]='/';
00219 ++_ftmplen;
00220 _pathf[_ftmplen]='\0';
00221
00222 strcat(_pathi,"/");
00223 _itmplen=strlen(_pathi);
00224
00225
00226
00227
00228
00229 strcpy(&_pathi[_itmplen-1],MED_FAS);
00230
00231 MED_ERR_EXIT_IF( _MEDdatagroupExist(fid,_pathi,&_datagroupexist,&_isasoftlink) < 0 ,
00232 MED_ERR_CALL,MED_ERR_API,"_MEDdatagroupExist");
00233
00234 fprintf(stdout," >>> Normalisation des familles du maillage [%s] \n",_imeshname);
00235
00236 _datagroup = _MEDdatagroupCreer(fid,_pathfam);
00237 MED_ERR_EXIT_IF(_datagroup < 0 ,MED_ERR_CREATE,MED_ERR_DATAGROUP,_pathfam);
00238 if (_datagroup>0) {
00239 _ret= _MEDdatagroupFermer(_datagroup);
00240 MED_ERR_EXIT_IF(_ret < 0,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_pathfam);
00241 }
00242
00243 strcpy(&_pathfam[MED_TAILLE_FAS],_meshname);strcat(_pathfam,"/");
00244
00245 if( _datagroupexist) {
00246
00247 _ocp_plist_id = H5Pcreate( H5P_OBJECT_COPY );
00248 _lcp_plist_id = H5Pcreate( H5P_LINK_CREATE );
00249
00250 ret = H5Ocopy(fid,_pathi,fid,_pathfam,_ocp_plist_id,_lcp_plist_id);
00251 EXIT_IF(ret < 0,"Copie des familles dans ","/");
00252
00253 MED_ERR_EXIT_IF ( _MEDvisit(fid,_pathi,_pathfam,(medvisitorfunc) _MEDconvertStringDatasets ) < 0,
00254 MED_ERR_VISIT,MED_ERR_DATAGROUP,_pathfam);
00255 MED_ERR_EXIT_IF ( H5Ldelete(fid,_pathi,H5P_DEFAULT) < 0, MED_ERR_DELETE,MED_ERR_LINK,_pathi);
00256
00257 }
00258
00259 strcat(_pathfam,"FAMILLE_ZERO");
00260 MED_ERR_EXIT_IF( _MEDdatagroupExist(fid,_pathfam,&_datagroupexist,&_isasoftlink) < 0 ,
00261 MED_ERR_CALL,MED_ERR_API,"_MEDdatagroupExist");
00262
00263 if( !_datagroupexist) {
00264 MED_ERR_EXIT_IF ( (MEDfamilyCr(fid,_meshname,FAMILLE_ZERO, 0, 0, "") < 0),
00265 MED_ERR_CREATE,MED_ERR_FAMILY,"MEDfamilyCr");
00266 }
00267
00268
00269 strcpy(&_pathi[_itmplen-1],MED_EQS);
00270
00271 MED_ERR_EXIT_IF( MAJ_236_300_equivalence(fid,_meshname) < 0,
00272 MED_ERR_CALL,MED_ERR_API,"MAJ_236_300_equivalence");
00273 _groupexist=H5Lexists(fid, _pathi, H5P_DEFAULT );
00274 if (_groupexist) {
00275 MED_ERR_EXIT_IF( H5Ldelete(fid,_pathi,H5P_DEFAULT) < 0,
00276 MED_ERR_DELETE,MED_ERR_LINK,_pathi);
00277 }
00278
00279
00280 strcpy(&_pathi[_itmplen-1],MED_JNT);
00281
00282 MED_ERR_EXIT_IF( MAJ_236_300_joint(fid,_meshname) < 0,
00283 MED_ERR_CALL,MED_ERR_API,"MAJ_236_300_joint");
00284 _groupexist=H5Lexists(fid, _pathi, H5P_DEFAULT );
00285 if (_groupexist) {
00286 MED_ERR_EXIT_IF( H5Ldelete(fid,_pathi,H5P_DEFAULT) < 0,
00287 MED_ERR_DELETE,MED_ERR_JOINT,_pathi);
00288 }
00289
00290 _pathi[_itmplen]='\0';
00291
00292
00293
00294 fprintf(stdout," >>> Normalisation des entites [%s] du maillage [%s] \n",
00295 MED_GET_ENTITY_TYPENAME[MED_NODE+1],_meshname);
00296 MED_ERR_EXIT_IF( MAJ_236_300_entites( fid,_pathi, _pathf,_meshname, MED_NODE) < 0 ,
00297 MED_ERR_CALL,MED_ERR_API,"MAJ_236_300_entites");
00298
00299
00300 if (_mustwrite_gridstruct) {
00301 MED_ERR_EXIT_IF( MEDmeshGridStructWr(fid,_meshname,MED_NO_DT,MED_NO_IT, MED_UNDEF_DT, _gridstruct ) < 0
00302 ,MED_ERR_CALL,MED_ERR_API,"MEDmeshGridStructWr");
00303 _mustwrite_gridstruct = MED_FALSE;
00304 }
00305
00306
00307 _pathf[_ftmplen]='\0';
00308 _pathi[_itmplen]='\0';
00309
00310 fprintf(stdout," >>> Normalisation des entites [%s] du maillage [%s] \n",
00311 MED_GET_ENTITY_TYPENAME[MED_CELL+1],_meshname);
00312 MED_ERR_EXIT_IF( MAJ_236_300_entites( fid,_pathi, _pathf,_meshname, MED_CELL) < 0,
00313 MED_ERR_CALL,MED_ERR_API,"MAJ_236_300_entites");
00314
00315 _pathf[_ftmplen]='\0';
00316 _pathi[_itmplen]='\0';
00317
00318 fprintf(stdout," >>> Normalisation des entites [%s] du maillage [%s] \n",
00319 MED_GET_ENTITY_TYPENAME[MED_DESCENDING_FACE+1],_meshname);
00320 MED_ERR_EXIT_IF( MAJ_236_300_entites( fid,_pathi, _pathf,_meshname, MED_DESCENDING_FACE) < 0,
00321 MED_ERR_CALL,MED_ERR_API,"MAJ_236_300_entites");
00322 _pathf[_ftmplen]='\0';
00323 _pathi[_itmplen]='\0';
00324
00325 fprintf(stdout," >>> Normalisation des entites [%s] du maillage [%s] \n",
00326 MED_GET_ENTITY_TYPENAME[MED_DESCENDING_EDGE+1],_meshname);
00327 MED_ERR_EXIT_IF( MAJ_236_300_entites( fid,_pathi, _pathf,_meshname, MED_DESCENDING_EDGE) < 0,
00328 MED_ERR_CALL,MED_ERR_API,"MAJ_236_300_entites");
00329
00330 }
00331
00332
00333
00334
00335
00336
00337 }