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