MEDstructElementCr.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2015  EDF R&D, CEA/DEN
00004  *  MED is free software: you can redistribute it and/or modify
00005  *  it under the terms of the GNU Lesser General Public License as published by
00006  *  the Free Software Foundation, either version 3 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  MED is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Lesser General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Lesser General Public License
00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 
00019 #include <med.h>
00020 #include <med_config.h>
00021 #include <med_outils.h>
00022 
00023 #include <string.h>
00024 #include <stdlib.h>
00025 
00047 /*PENSEZ A DOCUMENTER LE CAS DE PARTICULE (SANS MAILLAGE SUPPORT : MOT CLE A DEFINIR )*/
00048 
00049 med_geometry_type
00050 MEDstructElementCr(const med_idt                 fid,
00051                    const char*             const modelname,
00052                    const med_int                 modeldim,
00053                    const char*             const supportmeshname,
00054                    const med_entity_type         sentitytype,
00055                    const med_geometry_type       sgeotype
00056                    )
00057 {
00058   med_access_mode   _MED_ACCESS_MODE;
00059   med_err           _err=-1;
00060   med_idt           _root=0,_elemid=0;
00061   med_int           _ret=-1;
00062   char              _path[MED_TAILLE_STRCT+MED_NAME_SIZE+1]=MED_STRCT;
00063   med_size          _tmpn=0;
00064   med_geometry_type _stgeotype=0;
00065   med_int           _medintstgeotype = 0;
00066   med_int           _medintsgeotype  = sgeotype;
00067   med_int           _intentitytype   = sentitytype;
00068   med_int           _nnode=0,_ncell=0;
00069   med_bool          _chgt=MED_FALSE,_trsf=MED_FALSE;
00070 
00071 /*   char           _entitytypename[MED_TAILLE_NOM_ENTITE+1]=""; */
00072 
00073   /*
00074    * On inhibe le gestionnaire d'erreur
00075    */
00076   _MEDmodeErreurVerrouiller();
00077  if (_MEDcheckVersion30(fid) < 0) goto ERROR;
00078 
00079   if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
00080     MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
00081     goto ERROR;
00082   }
00083 
00084   if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
00085     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
00086     ISCRUTE_int(_MED_ACCESS_MODE);
00087     goto ERROR;
00088   }
00089 
00090   /*
00091    * Si le DataGroup /STRUCT/ n'existe pas, on le cree
00092    */
00093   if ((_root = _MEDdatagroupOpen(fid,_path)) < 0)
00094     if ((_root = _MEDdatagroupCrOrderCr(fid,_path)) < 0) {
00095       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_path);
00096      goto ERROR;
00097     }
00098 
00099   NOFINALBLANK(modelname,ERROR);
00100 
00101   /*
00102    * Si le DataGroup /STRUCT/<modelname> n'existe pas, on le cree
00103    */
00104   if ((_elemid = _MEDdatagroupOpen(_root,modelname)) < 0) {
00105     if ((_elemid = _MEDdatagroupCreer(_root,modelname)) < 0) {
00106       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,modelname);
00107       SSCRUTE(_path);goto ERROR;
00108     }
00109   } else {
00110     /*
00111      * Lecture de l'attribut MED_NOM_NEO (num�ro de type g�om�trique associ� � un �l�ment de structure)
00112      */
00113     if ( _MEDattrEntierLire(_elemid,MED_NOM_NEO,&_medintstgeotype) < 0 ) {
00114       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
00115       SSCRUTE(MED_NOM_NEO);ISCRUTE(_medintstgeotype);
00116       goto ERROR;
00117     }
00118     _stgeotype = _medintstgeotype;
00119   }
00120   strcat(_path,modelname);
00121 
00122   /*
00123    * Creation/Ecriture de l'attribut MED_NOM_DIM (dimension de l'�l�ment)
00124    */
00125   if ( _MEDattributeIntWr(_elemid,MED_NOM_DIM,&modeldim) < 0 ) {
00126     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
00127     SSCRUTE(MED_NOM_DIM);ISCRUTE(modeldim);
00128     goto ERROR;
00129   }
00130 
00131   /*
00132    * Creation/Ecriture de l'attribut MED_NOM_NOM (nom du maillage support)
00133    */
00134   if ( _MEDattributeStringWr(_elemid,MED_NOM_NOM,MED_NAME_SIZE,supportmeshname) < 0) {
00135     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
00136     SSCRUTE(MED_NOM_NOM);SSCRUTE(supportmeshname);
00137     goto ERROR;
00138   }
00139 
00140   /*
00141    * Creation/Ecriture de l'attribut MED_NOM_ENT (type d'entit� support)
00142    */
00143 /*   if (_MEDgetEntityTypeName(_entitytypename,sentitytype) < 0) { */
00144 /*     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG); */
00145 /*     ISCRUTE_int(sentitytype);SSCRUTE(_entitytypename);SSCRUTE(_path); */
00146 /*     goto ERROR; */
00147 /*   } */
00148 
00149   if ( _MEDattributeIntWr(_elemid,MED_NOM_ENT,&_intentitytype) < 0 ) {
00150     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
00151     SSCRUTE(MED_NOM_ENT);ISCRUTE(_intentitytype);
00152     goto ERROR;
00153   }
00154 
00155   /*
00156     Lecture dans le maillages support du nombre de noeuds
00157     S'il n'y a pas de maillage support : 1
00158   */
00159   if (strlen(supportmeshname)) {
00160     if ( (_nnode = MEDmeshnEntity(fid,supportmeshname,MED_NO_DT,MED_NO_IT,
00161                                      MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,
00162                                      &_chgt,&_trsf) )  <= 0) {
00163       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
00164       ISCRUTE(_nnode);goto ERROR;
00165     }
00166   } else {
00167     _nnode=1;
00168   }
00169 
00170   if (strlen(supportmeshname)) {
00171     if ( (_ncell = MEDmeshnEntity(fid,supportmeshname,MED_NO_DT,MED_NO_IT,
00172                                      MED_CELL,sgeotype,MED_CONNECTIVITY,MED_NODAL,
00173                                      &_chgt,&_trsf) )  < 0) {
00174       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
00175       ISCRUTE(_ncell);goto ERROR;
00176     }
00177   } else {
00178     _ncell=0;
00179   }
00180 
00181   /*
00182    * Creation/Ecriture de l'attribut MED_NOM_GEO (type g�om�trique des mailles support)
00183    */
00184   _medintsgeotype = sgeotype;
00185   if ( _MEDattributeIntWr(_elemid,MED_NOM_GEO,&_medintsgeotype) < 0 ) {
00186     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
00187     SSCRUTE(MED_NOM_GEO);ISCRUTE(_medintsgeotype);
00188     goto ERROR;
00189   }
00190 
00191   /*
00192    * Creation/Ecriture de l'attribut MED_NOM_NAV (nombre d'attributs variables associ�s � un �l�ment de structure)
00193    */
00194 /*   if ( _MEDattributeIntWr(_elemid,MED_NOM_NAV,&nvariableattribute) < 0 ) { */
00195 /*     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path); */
00196 /*     SSCRUTE(MED_NOM_NAV);ISCRUTE(nvariableattribute); */
00197 /*     goto ERROR; */
00198 /*   } */
00199 
00200   /*
00201    * Creation/Ecriture de l'attribut MED_NOM_NAC (nombre d'attributs constant associ�s � un �l�ment de structure)
00202    */
00203 /*   if ( _MEDattributeIntWr(_elemid,MED_NOM_NAC,&nconstattribute) < 0 ) { */
00204 /*     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path); */
00205 /*     SSCRUTE(MED_NOM_NAC);ISCRUTE(nconstattribute); */
00206 /*     goto ERROR; */
00207 /*   } */
00208 
00209 
00210   /*
00211    *  Nombre d'�l�ments de structure
00212    */
00213   if ( !_stgeotype ) {
00214 
00215     /*Si l'�l�ment de struture ne pr�-existait pas,
00216       il a �t� cr�e en d�but de proc�dure (il y a au moins 1 �l�ment dans le groupe) */
00217     if ((_err=_MEDnObjects(fid,MED_STRCT,&_tmpn)) <0) {
00218       MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_STRUCT,MED_STRCT);
00219       goto ERROR;
00220     }
00221 
00222     _stgeotype=_tmpn+MED_STRUCT_GEO_INTERNAL;
00223     _medintstgeotype=_stgeotype;
00224 
00225     /*
00226      * Ecriture de l'attribut MED_NOM_NEO (num�ro de type g�om�trique associ� � un �l�ment de structure)
00227      */
00228     if ( _MEDattributeIntWr(_elemid,MED_NOM_NEO,&_medintstgeotype) < 0 ) {
00229       MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
00230       SSCRUTE(MED_NOM_NEO);ISCRUTE(_medintstgeotype);
00231       goto ERROR;
00232     }
00233   }
00234 
00235   _ret = _stgeotype;
00236 
00237  ERROR:
00238 
00239   if (_elemid>0)     if (_MEDdatagroupFermer(_elemid) < 0) {
00240     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
00241     ISCRUTE_id(_elemid);
00242   }
00243 
00244   if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
00245     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_STRCT);
00246     ISCRUTE_id(_root);
00247   }
00248 
00249   return _ret;
00250 
00251 }

Généré le Thu Oct 8 14:26:16 2015 pour MED fichier par  doxygen 1.6.1