_MEDlocalizationRd30.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2011  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 
00026 void
00027 _MEDlocalizationRd30(int dummy, ...) {
00028 
00029 
00030   med_err _ret = -1;
00031   med_idt _lzid=0, _root=0;
00032   med_int _nentity=0,_nbofipoint=0,_localizationspacedimension=0;
00033   med_int _intgeotype = -1;
00034   char    _path[MED_TAILLE_GAUSS+MED_NAME_SIZE+1]=MED_GAUSS;
00035   med_filter     _filter        = MED_FILTER_INIT;
00036 
00037   char     _elempath[MED_TAILLE_STRCT+MED_NAME_SIZE+1]=MED_STRCT;
00038   char     _supportmeshname[MED_NAME_SIZE+1]="";
00039   med_bool _chgt=MED_FALSE,_trsf=MED_FALSE;
00040   med_int  _nnodes=0;
00041   med_int  _supportmeshspacedimension=0;
00042   char     _meshpath[MED_TAILLE_SUP_MAA+MED_NAME_SIZE+1]=MED_SUP_MAA;
00043 
00044   MED_VARGS_DECL(const, med_idt                 , , fid               );
00045   MED_VARGS_DECL(const, char*            , const  , localizationname  );
00046   MED_VARGS_DECL(const, med_switch_mode         , , switchmode        );
00047   MED_VARGS_DECL(, med_float*      , const  , elementcoordinate       );
00048   MED_VARGS_DECL(, med_float*      , const  , ipointcoordinate        );
00049   MED_VARGS_DECL(, med_float*      , const  , weight                  );
00050   MED_VARGS_DECL(, med_err *                     ,, fret              );
00051 
00052   va_list params;
00053   va_start(params,dummy);
00054 
00055   MED_VARGS_DEF(const, med_idt                 , , fid               );
00056   MED_VARGS_DEF(const, char*            , const  , localizationname  );
00057   MED_VARGS_DEF(const, med_switch_mode         , , switchmode        );
00058   MED_VARGS_DEF(, med_float*      , const  , elementcoordinate       );
00059   MED_VARGS_DEF(, med_float*      , const  , ipointcoordinate        );
00060   MED_VARGS_DEF(, med_float*      , const  , weight                  );
00061   MED_VARGS_DEF(, med_err *                     ,, fret              );
00062 
00063   /*
00064    * On inhibe le gestionnaire d'erreur HDF 5
00065    */
00066   _MEDmodeErreurVerrouiller();
00067 
00068   /*
00069    * MED_GAUSS_ELNO est un mot cle reserve
00070    */
00071   if (! strcmp(localizationname,MED_GAUSS_ELNO)) {
00072     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_LOCALIZATION,localizationname);
00073     goto ERROR;
00074   }
00075 
00076   /*
00077    * Ouverture du dataGroup /GAUSS/
00078    */
00079   if ((_root = _MEDdatagroupOuvrir(fid,_path)) < 0) {
00080     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
00081     goto ERROR;
00082   }
00083 
00084   NOFINALBLANK(localizationname,ERROR);
00085   /*
00086    * Ouverture du dataGroup  /GAUSS/<localizationname>
00087    */
00088   if ((_lzid = _MEDdatagroupOuvrir(_root,localizationname)) < 0) {
00089     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,localizationname);
00090     SSCRUTE(_path);goto ERROR;
00091   }
00092 
00093   strcat(_path,localizationname);
00094 
00095 
00096   /*
00097    * On lit <nbofipoint> sous forme d'attribut
00098    */
00099   if (_MEDattrEntierLire(_lzid,MED_NOM_NBR,&_nbofipoint) < 0) {
00100     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00101     SSCRUTE(localizationname);SSCRUTE(MED_NOM_NBR);ISCRUTE(_nbofipoint);
00102     goto ERROR;
00103   }
00104 
00105   /*
00106    * On lit <typgeo> sous forme d'attribut
00107    */
00108   /* sizeof(enum) tjrs = sizeof(int) en C, or
00109      sur machines 64 bits par défaut med_int==long,
00110      du coup sur  machines 64 bits _MEDattributeIntWr utilise
00111      le type hdf NATIVE_LONG, ce qui pose un probl�me qd on passe
00112      un enum.
00113   */
00114   if (_MEDattrEntierLire(_lzid,MED_NOM_GEO,&_intgeotype) < 0) {
00115     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00116     SSCRUTE(localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE(_intgeotype);
00117     goto ERROR;
00118   };
00119 
00120   /*
00121    * On lit <spacedimension>
00122    */
00123   if (_MEDattrEntierLire(_lzid,MED_NOM_DIM,&_localizationspacedimension) < 0) {
00124     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00125     SSCRUTE(localizationname);SSCRUTE(MED_NOM_DIM);ISCRUTE(_localizationspacedimension);
00126     goto ERROR;
00127   };
00128 
00129 
00130   /*
00131    * On lit les coordonn�es de r�f�rence dans un dataset
00132    */
00133   if ( ! ((_intgeotype > MED_STRUCT_GEO_INTERNAL    ) &&
00134           (_intgeotype < MED_STRUCT_GEO_SUP_INTERNAL)    ) ) {
00135 
00136     _nentity = (_intgeotype%100);
00137 
00138     if ( MEDfilterEntityCr(fid,_nentity, 1, _localizationspacedimension, MED_ALL_CONSTITUENT,
00139                            switchmode,MED_UNDEF_PFLMODE,
00140                            MED_NO_PROFILE, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
00141       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
00142       goto ERROR;
00143     }
00144 
00145     if ( _MEDdatasetRd(_lzid,MED_NOM_COO,MED_INTERNAL_FLOAT64,&_filter,
00146                        (unsigned char *) elementcoordinate) < 0) {
00147       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_DATASET,MED_NOM_COO);SSCRUTE(_path);
00148       goto ERROR;
00149     }
00150 
00151     if ( MEDfilterClose(&_filter) < 0 ) {
00152       MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_LOCALIZATION_MSG); SSCRUTE(_path);
00153       goto ERROR;
00154     }
00155     /*Localisation des points d'intégration sur élément de structure */
00156   } else {
00157 
00158     if ( MEDstructElementName(fid,(med_int) _intgeotype,&_elempath[strlen(_elempath)]) < 0) {
00159       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDstructElementName");
00160       SSCRUTE(_elempath);goto ERROR;
00161     }
00162 
00163     /*
00164      * Lecture  de l'attribut MED_NOM_NOM (nom du maillage support)
00165      */
00166     if ( _MEDattributeStringRdByName(fid,_elempath,MED_NOM_NOM, MED_NAME_SIZE,
00167                                      _supportmeshname) < 0) {
00168       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_elempath);
00169       SSCRUTE(MED_NOM_NOM);SSCRUTE(_supportmeshname);
00170       goto ERROR;
00171     }
00172 
00173     /*
00174      * Lecture du nombre de noeuds support
00175      */
00176     if (strlen(_supportmeshname)) {
00177 
00178       strcat(_meshpath,_supportmeshname);
00179       if ( _MEDattributeNumRdByName(fid, _meshpath ,MED_NOM_ESP,MED_INTERNAL_INT,
00180                                     (unsigned char *) &_supportmeshspacedimension) <0 ) {
00181         MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_meshpath);
00182         SSCRUTE(MED_NOM_ESP);
00183         goto ERROR;
00184       }
00185 
00186       /* TODO : Doit-on autoriser la description des noeuds du modèle d'élément dans une localisation 
00187        dans une dimension différente de celle de l'espace du maillage support */
00188       if (_supportmeshspacedimension != _localizationspacedimension) {
00189         MED_ERR_(_ret,MED_ERR_NOTEQUAL,MED_ERR_DIMENSION,"");
00190         ISCRUTE(_localizationspacedimension);ISCRUTE(_supportmeshspacedimension);
00191         goto ERROR;
00192       }
00193 
00194 
00195       if ( (_nnodes = MEDmeshnEntity(fid,_supportmeshname,MED_NO_DT,MED_NO_IT,
00196                                      MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,
00197                                      &_chgt,&_trsf) )  <= 0) {
00198         MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
00199         ISCRUTE(_nnodes);goto ERROR;
00200       }
00201 
00202       if ( MEDmeshNodeCoordinateRd(fid, _supportmeshname,
00203                                    MED_NO_DT, MED_NO_IT, MED_FULL_INTERLACE,
00204                                    elementcoordinate) <0) {
00205         MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshNodeCoordinateRd");
00206         goto ERROR;
00207       }
00208     } else {
00209       /*TODO : générer des coordonnées pour MED_PARTICLE? */
00210       _nnodes=1;
00211     }
00212   }
00213 
00214   /*
00215    * On lit les points d'intégration
00216    */
00217 
00218   _nentity = _nbofipoint;
00219   if ( MEDfilterEntityCr(fid,_nentity, 1, _localizationspacedimension, MED_ALL_CONSTITUENT,
00220                          switchmode,MED_UNDEF_PFLMODE,
00221                          MED_NO_PROFILE, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
00222     MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
00223     goto ERROR;
00224   }
00225 
00226 #ifdef _DEBUG_
00227   ISCRUTE((_filter).nbofentity              );
00228   ISCRUTE((_filter).nbofvaluesperentity     );
00229   ISCRUTE((_filter).nbofconstituentpervalue );
00230   ISCRUTE((_filter).constituentselect       );
00231   ISCRUTE_int((_filter).switchmode              );
00232   ISCRUTE((_filter).filterarraysize         );
00233   ISCRUTE((_filter).profilearraysize        );
00234   ISCRUTE_int((_filter).storagemode             );
00235   SSCRUTE((_filter).profilename             );
00236 #endif
00237 
00238   if ( _MEDdatasetRd(_lzid,MED_NOM_GAU,MED_INTERNAL_FLOAT64,&_filter,
00239                      (unsigned char *)  ipointcoordinate) < 0) {
00240     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_DATASET,MED_NOM_GAU);SSCRUTE(_path);
00241     goto ERROR;
00242   }
00243 
00244   if ( MEDfilterClose(&_filter) < 0 ) {
00245     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_LOCALIZATION_MSG); SSCRUTE(_path);
00246     goto ERROR;
00247   }
00248 
00249   /*
00250    * On lit les poids associés
00251    */
00252 
00253   _nentity = _nbofipoint;
00254   if ( MEDfilterEntityCr(fid,_nentity, 1, 1, MED_ALL_CONSTITUENT,
00255                          switchmode,MED_UNDEF_PFLMODE,
00256                          MED_NO_PROFILE, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
00257     MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
00258     goto ERROR;
00259   }
00260 
00261   if ( _MEDdatasetRd(_lzid,MED_NOM_VAL,MED_INTERNAL_FLOAT64,&_filter,
00262                      (unsigned char *) weight) < 0) {
00263     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_DATASET,MED_NOM_VAL);SSCRUTE(_path);
00264     goto ERROR;
00265   }
00266 
00267   if ( MEDfilterClose(&_filter) < 0 ) {
00268     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_LOCALIZATION_MSG); SSCRUTE(_path);
00269     goto ERROR;
00270   }
00271 
00272 
00273   _ret = 0;
00274 
00275  ERROR:
00276 
00277   if (_lzid>0)            if (_MEDdatagroupFermer(_lzid) < 0) {
00278     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,localizationname);
00279     ISCRUTE_id(_lzid);
00280   }
00281 
00282   if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
00283     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_GAUSS);
00284     ISCRUTE_id(_root);
00285   }
00286 
00287   va_end(params);
00288   *fret = _ret;
00289 
00290   return;
00291 }

Généré le Mon Nov 7 16:21:23 2011 pour MED fichier par  doxygen 1.6.1