med_err MEDmeshEntityFamilyNumberWr(const med_idt fid, const char* const meshname, const med_int numdt, const med_int numit, const med_entity_type entitype, const med_geometry_type geotype, const med_int nentity, const med_int * const number) { med_err _ret = -1; med_entity_type _entitytype=entitype; if ( entitype == MED_NODE_ELEMENT ) _entitytype=MED_NODE ; _ret= _MEDmeshAdvancedWr(fid, meshname, MED_FAMILY_NUMBER, MED_NO_NAME, MED_INTERNAL_UNDEF, numdt, numit, MED_UNDEF_DT, /*Si la s�quence de calcul n'existe pas, ce champ sera initialisé correctement par d'autres appels.*/ _entitytype, geotype, MED_NODAL, MED_UNDEF_STMODE, MED_SAME_PROFILE_INTERNAL, MED_FULL_INTERLACE, /*Pas d'utilit� ici, car nconstituent==1*/ MED_ALL_CONSTITUENT, NULL, nentity, number); return _ret; }
med_err MEDmeshEntityAttributeAdvancedWr(const med_idt fid, const char* const meshname, const med_data_type datatype, const med_int numdt, const med_int numit, const med_entity_type entitype, const med_geometry_type geotype, const med_filter * const filter, const void * const attval) { med_err _ret=-1; switch (datatype) { case MED_NAME: case MED_NUMBER: case MED_FAMILY_NUMBER: break; default: MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_PARAMETER,""); ISCRUTE_int(datatype); goto ERROR; } _ret= _MEDmeshAdvancedWr(fid, meshname, datatype, MED_NO_NAME, MED_INTERNAL_UNDEF, numdt, numit, MED_UNDEF_DT, /*Si la séquence de calcul n'existe pas, ce champ sera initialisé correctement par d'autres appels.*/ entitype, geotype, MED_NODAL, MED_UNDEF_PFLMODE, MED_NO_PROFILE, MED_UNDEF_INTERLACE, MED_ALL_CONSTITUENT, filter, MED_UNDEF_SIZE, attval); ERROR: return _ret; }
med_err MEDmeshElementConnectivityWithProfileWr(const med_idt fid, const char* const meshname, const med_int numdt, const med_int numit, const med_float dt, const med_entity_type entitype, const med_geometry_type geotype, const med_connectivity_mode cmode, const med_storage_mode storagemode, const char * const profilename, const med_switch_mode switchmode, const med_int dimselect, const med_int nentity, const med_int* const connectivity) { return _MEDmeshAdvancedWr(fid, meshname, MED_CONNECTIVITY, MED_NO_NAME, MED_INTERNAL_UNDEF, numdt, numit, dt, entitype, geotype, cmode, storagemode, profilename, switchmode, dimselect, NULL, nentity, connectivity); }
med_err MEDmeshPolyhedronWr(const med_idt fid, const char* const meshname, const med_int numdt, const med_int numit, const med_float dt, const med_entity_type entitype, const med_connectivity_mode cmode, const med_int faceindexsize, const med_int * const faceindex, const med_int nodeindexsize, const med_int * const nodeindex, const med_int * const connectivity ) { med_access_mode _MED_ACCESS_MODE; med_idt _meshid=0; med_err _ret = -1; med_data_type _datatype = MED_UNDEF_DATATYPE; med_int _connectivitysize = 0; /* * On inhibe le gestionnaire d'erreur HDF 5 */ _MEDmodeErreurVerrouiller(); if (_MEDcheckVersion30(fid) < 0) goto ERROR; if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) { MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG); goto ERROR; } if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) { MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG); ISCRUTE_int(_MED_ACCESS_MODE); goto ERROR; } /* Tester le type d'entité ? * MAILLE Ok * FACE OK * ARETE ? * NOEUD KO * NOEUD_MAILLE ? */ switch(cmode) { case MED_NODAL : _connectivitysize = nodeindex[nodeindexsize-1] - nodeindex[0]; break; case MED_DESCENDING : _connectivitysize = nodeindexsize; break; default : return -1; } if (_MEDmeshAdvancedWr(fid, meshname, MED_CONNECTIVITY, MED_NO_NAME, MED_INTERNAL_UNDEF, numdt, numit, dt, entitype, MED_POLYHEDRON, cmode, MED_UNDEF_PFLMODE, MED_NO_PROFILE, MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, NULL, _connectivitysize, connectivity) < 0 ) { MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedWr (MED_CONNECTIVITY) "); goto ERROR; } if (_MEDmeshAdvancedWr(fid, meshname, MED_INDEX_NODE, MED_NO_NAME, MED_INTERNAL_UNDEF, numdt, numit, dt, entitype, MED_POLYHEDRON, cmode, MED_UNDEF_PFLMODE, MED_SAME_PROFILE_INTERNAL, MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, NULL, nodeindexsize, nodeindex) < 0 ) { MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedWr (MED_INDEX_NODE) "); goto ERROR; } if (_MEDmeshAdvancedWr(fid, meshname, MED_INDEX_FACE, MED_NO_NAME, MED_INTERNAL_UNDEF, numdt, numit, dt, entitype, MED_POLYHEDRON, cmode, MED_UNDEF_PFLMODE, MED_SAME_PROFILE_INTERNAL, MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, NULL, faceindexsize, faceindex) < 0 ) { MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedWr (MED_INDEX_FACE) "); goto ERROR; } _ret = 0; ERROR: return _ret; }
med_err MEDmeshNodeCoordinateWr(const med_idt fid, const char* const meshname, const med_int numdt, const med_int numit, const med_float dt, const med_switch_mode switchmode, const med_int nentity, const med_float* const coordinate) { med_idt _meshid = 0; med_idt _datagroup1=0,_datagroup2=0,_datagroup3=0,_datagroup_trsf=0; med_idt _dataset_trsf = 0; med_err _ret = -1; med_grid_type _gridtype = MED_UNDEF_GRID_TYPE; med_int _intgridtype = 0; med_int _intmeshtype = 0; med_int _meshdim = 0; char _meshpath [MED_TAILLE_SUP_MAA+MED_NAME_SIZE+1]=""; char _geotypename[MED_TAILLE_NOM_ENTITE+1]=""; char _datagroup_trsfname[MED_TAILLE_NOM_ENTITE+MED_TAILLE_COOTRF+1]=MED_NOM_NOE MED_COOTRF; int _i=0; med_bool _isasupportmesh=MED_FALSE,_isasoftlink=MED_FALSE; med_int _0 = 0; med_int _medintgeotype = MED_NO_GEOTYPE; if (_MEDcheckVersion30(fid) < 0) goto ERROR; /* Ouverture du maillage de calcul ou du maillage support */ if ((_meshid=_MEDmeshDatagroupOpen(fid,meshname,_meshpath,&_isasupportmesh)) < 0) { MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_MESH_MSG); SSCRUTE(_meshpath); goto ERROR; } /* Lecture du type de maillage (attribut MED_NOM_TYP) */ if (_MEDattrEntierLire(_meshid,MED_NOM_TYP,&_intmeshtype) < 0) { MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG); SSCRUTE(meshname);SSCRUTE(MED_NOM_TYP);ISCRUTE(_intmeshtype);goto ERROR; } /*Sortir en erreur si maillage support et numdt,numit != MED_NO_PDT,MED_NO_IT*/ /* Accès (création éventuelle) du datagroup numdt,numit */ if ( _isasupportmesh ) { if (( numdt != MED_NO_DT) && (numit != MED_NO_IT) ) { MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_PARAMETER,MED_ERR_MESH_MSG); SSCRUTE(meshname);ISCRUTE(numdt);ISCRUTE(numit);goto ERROR; } } else if ( (_datagroup1 =_MEDmeshAssociatedGroupCr(fid, MED_MAA, meshname, numdt, numit, dt,MED_FALSE, "." ) ) < 0 ) { MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAssociatedGroupCr"); goto ERROR; } /* Création de la structure de connectivité assoiciée aux grilles MED_CURVILLINEAR_GRID*/ if ( ( (med_mesh_type) _intmeshtype ) != MED_UNSTRUCTURED_MESH ) { /* Lecture de l'attribut MED_NOM_GTY */ if (_MEDattrEntierLire(_meshid,MED_NOM_GTY,&_intgridtype) < 0) { MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG); SSCRUTE(meshname);SSCRUTE(MED_NOM_GTY);ISCRUTE_int(_gridtype);goto ERROR; } _gridtype= (med_grid_type) _intgridtype; if ( _gridtype == MED_CURVILINEAR_GRID ) { if ((_datagroup2 = _MEDdatagroupOuvrir(_datagroup1,MED_NOM_MAI)) < 0) { if ((_datagroup2 = _MEDdatagroupCreer(_datagroup1,MED_NOM_MAI)) < 0) { MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,MED_NOM_MAI); SSCRUTE(meshname);ISCRUTE(numdt);ISCRUTE(numit); goto ERROR; } if ( _MEDattributeIntWr(_datagroup2,MED_NOM_CGT,&_0) < 0) { MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG); SSCRUTE(meshname);ISCRUTE(numit);ISCRUTE(numdt);SSCRUTE(MED_NOM_CGT); goto ERROR; } /* Lecture de l'attribut MED_NOM_DIM */ if (_MEDattrEntierLire(_meshid,MED_NOM_DIM,&_meshdim) < 0) { MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG); SSCRUTE(meshname);SSCRUTE(MED_NOM_DIM);ISCRUTE(_meshdim);goto ERROR; } switch ( _meshdim ) { case 1 : strcpy(_geotypename,MED_NOM_SE2); _medintgeotype = MED_SEG2; break; case 2 : strcpy(_geotypename,MED_NOM_QU4); _medintgeotype = MED_QUAD4; break; case 3 : strcpy(_geotypename,MED_NOM_HE8); break; _medintgeotype = MED_HEXA8; case 0 : strcpy(_geotypename,MED_NOM_PO1); _medintgeotype = MED_POINT1; break; default : MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_PARAMETER,""); SSCRUTE(meshname);ISCRUTE(numdt);ISCRUTE(numit); goto ERROR; } if ((_datagroup3 = _MEDdatagroupCreer(_datagroup2,_geotypename)) < 0) { MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_geotypename); SSCRUTE(meshname);ISCRUTE(numdt);ISCRUTE(numit); goto ERROR; } if ( _MEDattributeStringWr(_datagroup3,MED_NOM_PFL,MED_NAME_SIZE,MED_NO_PROFILE_INTERNAL) < 0) { MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG); SSCRUTE(meshname);ISCRUTE(numit);ISCRUTE(numdt); goto ERROR; } if ( _MEDattributeIntWr(_datagroup3,MED_NOM_CGT,&_0) < 0) { MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG); SSCRUTE(meshname);ISCRUTE(numit);ISCRUTE(numdt);SSCRUTE(MED_NOM_CGT); goto ERROR; } if ( _MEDattributeIntWr(_datagroup3,MED_NOM_CGS,&_0) < 0) { MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG); SSCRUTE(meshname);ISCRUTE(numit);ISCRUTE(numdt);SSCRUTE(MED_NOM_CGS); goto ERROR; } if (_MEDattributeIntWr(_datagroup3,MED_NOM_GEO,&_medintgeotype) < 0) { MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_GEO); ISCRUTE(_medintgeotype); goto ERROR; } } } else { MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_GRIDTYPE,MED_ERR_MESH_MSG); SSCRUTE(meshname);SSCRUTE(MED_NOM_GTY);ISCRUTE_int(_gridtype);goto ERROR; } } /*Réinitialisation du lien MED_TRSF_NOM/MED_COORDINATE_TRSF s'il existe */ /*Si un dataset de transformation existe une erreur est générée par _MEDsoftlinkDel */ if ( !_isasupportmesh) if ((_datagroup_trsf = _MEDdatagroupOuvrir(_datagroup1,_datagroup_trsfname)) > 0) { if ( _MEDisasoftlink(_datagroup_trsf, MED_NOM_TRF,MED_FALSE, &_isasoftlink ) < 0 ) { MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_LINK,MED_NOM_COO); goto ERROR; } if (_isasoftlink ) { if ( _MEDsoftlinkDel(_datagroup_trsf, MED_NOM_TRF, MED_TRUE) < 0 ) { MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDsoftlinkDel"); goto ERROR; } } else { if ( (_dataset_trsf = _MEDdatasetOuvrir(_datagroup_trsf,MED_NOM_TRF)) >= 0 ) { _MEDdatasetFermer(_dataset_trsf); MED_ERR_(_ret,MED_ERR_NULL,MED_ERR_DATASET,MED_NOM_TRF); goto ERROR; } } } /*Ecriture des coordonnées*/ if ( _MEDmeshAdvancedWr(fid, meshname, MED_COORDINATE, MED_NO_NAME, MED_INTERNAL_UNDEF, numdt, numit, dt, MED_NODE, MED_NONE, MED_NO_CMODE, MED_UNDEF_PFLMODE, MED_NO_PROFILE, switchmode, MED_ALL_CONSTITUENT, NULL, nentity, coordinate) < 0 ) { MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedWr"); goto ERROR; } _ret = 0; ERROR: if (_datagroup_trsf>0) if (_MEDdatagroupFermer(_datagroup_trsf) < 0) { MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroup_trsfname); ISCRUTE_id(_datagroup_trsf); } if (_datagroup3>0) if (_MEDdatagroupFermer(_datagroup3) < 0) { MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_geotypename); ISCRUTE_id(_datagroup3); } if (_datagroup2>0) if (_MEDdatagroupFermer(_datagroup2) < 0) { MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_NOM_MAI); ISCRUTE_id(_datagroup2); } if (_datagroup1>0) if (_MEDdatagroupFermer(_datagroup1) < 0) { MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath); ISCRUTE_id(_datagroup1);ISCRUTE(numdt);ISCRUTE(numit); } if (_meshid>0) if (_MEDdatagroupFermer(_meshid) < 0) { MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,meshname); ISCRUTE_id(_meshid); } return _ret; }
med_err MEDmeshNodeCoordinateAdvancedWr(const med_idt fid, const char* const meshname, const med_int numdt, const med_int numit, const med_float dt, const med_filter * const filter, const med_float* const coordinate) { med_err _ret = -1; med_idt _meshid = 0,_datagroup1=0,_datagroup_trsf=0; med_idt _dataset_trsf = 0; med_int _intmeshtype = 0; char _meshpath [MED_MESH_SUPPORT_GRP_SIZE+MED_NAME_SIZE+1]=""; char _datagroup_trsfname[MED_TAILLE_NOM_ENTITE+MED_TAILLE_COOTRF+1]=MED_NOM_NOE MED_COOTRF; med_bool _isasupportmesh=MED_FALSE,_isasoftlink=MED_FALSE; if (_MEDcheckVersion30(fid) < 0) goto ERROR; /* Maillage de calcul ou maillage support */ if ((_meshid=_MEDmeshDatagroupOpen(fid,meshname,_meshpath,&_isasupportmesh)) < 0) { MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_MESH_MSG); SSCRUTE(_meshpath); goto ERROR; } /* Lecture de l'attribut du type de maillage MED_NOM_TYP */ if (_MEDattrEntierLire(_meshid,MED_NOM_TYP,&_intmeshtype) < 0) { MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG); SSCRUTE(meshname);SSCRUTE(MED_NOM_TYP);ISCRUTE(_intmeshtype);goto ERROR; } if ( _isasupportmesh ) { if (( numdt != MED_NO_DT) && (numit != MED_NO_IT) ) { MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_PARAMETER,MED_ERR_MESH_MSG); SSCRUTE(meshname);ISCRUTE(numdt);ISCRUTE(numit);goto ERROR; } } else if ( (_datagroup1 =_MEDmeshAssociatedGroupCr(fid, MED_MESH_GRP, meshname, numdt, numit, dt, MED_FALSE, "." ) ) < 0 ) { MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAssociatedGroupCr"); goto ERROR; } /*Réinitialisation du lien MED_TRSF_NOM/MED_COORDINATE_TRSF s'il existe */ /*Si un dataset de transformation existe une erreur est générée par _MEDsoftlinkDel */ /*Réinitialisation du lien MED_TRSF_NOM/MED_COORDINATE_TRSF s'il existe */ /*Si un dataset de transformation existe une erreur est générée par _MEDsoftlinkDel */ if ( !_isasupportmesh) if ((_datagroup_trsf = _MEDdatagroupOuvrir(_datagroup1,_datagroup_trsfname)) > 0) { if ( _MEDisasoftlink(_datagroup_trsf, MED_NOM_TRF,MED_FALSE, &_isasoftlink ) < 0 ) { MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_LINK,MED_NOM_COO); goto ERROR; } if (_isasoftlink ) { if ( _MEDsoftlinkDel(_datagroup_trsf, MED_NOM_TRF, MED_TRUE) < 0 ) { MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDsoftlinkDel"); goto ERROR; } } else { if ( (_dataset_trsf = _MEDdatasetOuvrir(_datagroup_trsf,MED_NOM_TRF)) >= 0 ) { _MEDdatasetFermer(_dataset_trsf); MED_ERR_(_ret,MED_ERR_NULL,MED_ERR_DATASET,MED_NOM_TRF); goto ERROR; } } } if ( ( (med_mesh_type) _intmeshtype ) == MED_UNSTRUCTURED_MESH ) { if ( _MEDmeshAdvancedWr(fid, meshname, MED_COORDINATE, MED_NO_NAME, MED_INTERNAL_UNDEF, numdt, numit, dt, MED_NODE, MED_NONE, MED_NO_CMODE, MED_UNDEF_STMODE, MED_NO_PROFILE, MED_UNDEF_INTERLACE, MED_ALL_CONSTITUENT, filter, MED_UNDEF_SIZE, coordinate) <0 ) { MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedWr"); goto ERROR; } } else { MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_MESHTYPE,MED_ERR_MESH_MSG); SSCRUTE(meshname);SSCRUTE(MED_NOM_GTY);goto ERROR; } _ret = 0; ERROR: if (_datagroup_trsf>0) if (_MEDdatagroupFermer(_datagroup_trsf) < 0) { MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroup_trsfname); ISCRUTE_id(_datagroup_trsf); } if (_datagroup1>0) if (_MEDdatagroupFermer(_datagroup1) < 0) { MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath); ISCRUTE_id(_datagroup1);ISCRUTE(numdt);ISCRUTE(numit); } if (_meshid>0) if (_MEDdatagroupFermer(_meshid) < 0) { MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,meshname); ISCRUTE_id(_meshid); } return _ret; }