MEDchampRefInfo.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 #include <string.h>
00023 
00024 /*
00025  * - Nom de la fonction : MEDchampRefInfo
00026  * - Description : Itérateur renvoyant les maillages associés au champ <cha>
00027  *                 avec le lien eventuel à un fichier externe. 
00028  * - Parametres :
00029  *     - fid        (IN) : ID du fichier HDF courant
00030  *     - cha        (IN) : le nom du champ 
00031  *     - type_ent   (IN) : entité du champ concernée  {MED_NOEUD,MED_ARETE,MED_FACE,MED_MAILLE}
00032  *      - type_geo  (IN) : type géométrique de l'entité concerné {MED_POINT,MED_SEG2 ......}
00033  *       - indice   (IN) : itérateur commançant à 1.
00034  *       - numdt    (IN) : n° du pas de temps (MED_NOPDT si aucun)
00035  *       - numo     (IN) : n° d'ordre utilisé (MED_NONOR si aucun)
00036  *        - maa    (OUT) : le nom du  maillage  sur lequel le champ résultat s'applique au couple (numdt,numo) donné.
00037  *        - local  (OUT) : MED_VRAI si le lien est local, MED_FAUX sinon.
00038  *        - ngauss (OUT) : nombre de points de GAUSS, MED_NOGAUSS si pas de points de gauss
00039  * - Resultat : 0 en cas de succes, -1 sinon
00040  */ 
00041 
00042 med_err 
00043 MEDchampRefInfo(med_idt fid,char *champ,
00044                 med_entite_maillage type_ent, med_geometrie_element type_geo,
00045                 int indice, med_int numdt, med_int numo,
00046                 char * maa, med_booleen * local, med_int *ngauss)
00047 {
00048 
00049   med_err ret=-1;
00050   int num;
00051   med_idt datagroup3=0,gid_maa=0,gid_lien=0;
00052   char chemin[(MED_TAILLE_CHA+MED_TAILLE_NOM+1)+(2*MED_TAILLE_NOM_ENTITE+2)+(2*MED_MAX_PARA+1)+(MED_TAILLE_NOM)+1]="";
00053   char chemin_maa[MED_TAILLE_MAA+MED_TAILLE_NOM+1]="";
00054   char chemin_lien[MED_TAILLE_LIENS+MED_TAILLE_NOM+1]=""; 
00055   char nomdatagroup1[2*MED_TAILLE_NOM_ENTITE+2]="";
00056   char nomdatagroup2[2*MED_MAX_PARA+1]="";
00057   char tmp1         [MED_TAILLE_NOM_ENTITE+1]="";
00058 
00059   /*
00060    * On inhibe le gestionnaire d'erreur HDF 5
00061    */
00062   _MEDmodeErreurVerrouiller();
00063 if (MEDcheckVersion(fid) < 0) return -1;
00064 
00065 
00066   /*
00067    * On construit le nom du datagroup
00068    */
00069   strcpy(chemin,MED_CHA);
00070   strcat(chemin,champ);
00071   strcat(chemin,"/");
00072 
00073   /* 
00074    * Si le Data Group  de niveau 1 <type_ent>[.<type_geo>] n'existe pas => erreur
00075    */
00076   /* modif pour la version 2.3.3 */
00077   
00078   if (_MEDnomEntite(nomdatagroup1,type_ent) < 0)
00079     goto ERROR;
00080   if ((type_ent != MED_NOEUD)) {
00081     if (_MEDnomGeometrie30(tmp1,type_geo) < 0)
00082       goto ERROR;
00083     strcat(nomdatagroup1,".");
00084     strcat(nomdatagroup1,tmp1);
00085   }
00086   strcat(chemin,nomdatagroup1);
00087   strcat(chemin,"/");
00088 
00089   /*
00090    * Si le Data Group de niveau 2 <numdtt>.<numoo> n'existe pas => erreur
00091    */
00092   sprintf(nomdatagroup2,"%*li%*li",MED_MAX_PARA,(long ) numdt,MED_MAX_PARA,(long ) numo);
00093   
00094   strcat(chemin,nomdatagroup2);
00095   strcat(chemin,"/");
00096 
00097 
00098   /*
00099    * Cherche le datagroup de niveau 3 <maa> correspondant à l'indice <num>
00100    */
00101   num = indice - 1;
00102   if (_MEDobjetIdentifier(fid,chemin,num,maa) < 0) {
00103     MESSAGE("Impossible de trouver un groupe à l'indice spécifié : ");
00104     SSCRUTE(chemin); ISCRUTE_int(num); goto ERROR;
00105   };
00106   strcat(chemin,maa);
00107  
00108 
00109   /*
00110    * Si le Data Group de niveau 3 <maa> n'existe pas => erreur
00111    */
00112  
00113   if ((datagroup3 = _MEDdatagroupOuvrir(fid,chemin)) < 0) {
00114     MESSAGE("Erreur d'ouverture du datagroup lien au maillage : ");
00115     SSCRUTE(chemin); goto ERROR;
00116   };
00117 
00118 
00119   /* Lire le nbre des points de GAUSS*/
00120   if (_MEDattrEntierLire(datagroup3,MED_NOM_NGA,ngauss) < 0) {
00121     MESSAGE("Erreur à la lecture de l'attribut MED_NOM_NGA : ");
00122     ISCRUTE(*ngauss);goto ERROR;
00123   };
00124 
00125 
00126   /* Maillage local ou distant */
00127   strcpy(chemin_maa,MED_MAA);
00128   strcat(chemin_maa,maa);
00129   /* Le maillage est il distant */
00130   if ( (gid_maa = _MEDdatagroupOuvrir(fid,chemin_maa)) < 0)  {
00131     
00132     /* Verifie que le maillage est bien référencé comme distant */  
00133     strcpy(chemin_lien,MED_LIENS);
00134     strcat(chemin_lien,maa); 
00135     if ((gid_lien = _MEDdatagroupOuvrir(fid,chemin_lien)) < 0) {
00136 /*       MESSAGE("Le maillage n'est ni local, ni distant : "); */
00137 /*        SSCRUTE(chemin_maa);SSCRUTE(chemin_lien); goto ERROR; */
00138       *local = MED_FAUX;
00139     }
00140   
00141     *local = MED_FAUX;
00142     
00143   } else  
00144     *local = MED_VRAI;
00145     
00146   
00147   /*
00148    * On ferme tout 
00149    */
00150 
00151   ret = 0;
00152 
00153  ERROR:
00154   
00155   if (datagroup3>0)     if (_MEDdatagroupFermer(datagroup3) < 0) {
00156       MESSAGE("Impossible de fermer le datagroup : ");
00157       ISCRUTE_int(datagroup3); ret = -1; 
00158   }
00159   
00160   if (gid_maa>0)  if (_MEDdatagroupFermer(gid_maa) < 0) {
00161       MESSAGE("Impossible de fermer le datagroup : ");
00162       ISCRUTE_id(gid_maa); ret = -1; 
00163   }
00164   
00165   if (gid_lien>0) if (_MEDdatagroupFermer(gid_lien) < 0) {
00166       MESSAGE("Impossible de fermer le datagroup : ");
00167       SSCRUTE(chemin_lien); ret = -1; 
00168   }
00169 
00170   return ret; 
00171 }

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