MAJ_236_300_joint.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_config.h"
00020 #include "med_outils.h"
00021 #include "med_versioned.h"
00022 #include <string.h>
00023 
00024 
00025 #include "MAJ_236_300.h"
00026 #include "MAJ_version.h"
00027 
00028 
00029 int afficheCorres(med_idt fid, const char * const maa, char *jnt,
00030                  med_entity_type typ_ent_local,   med_geometry_type typ_geo_local,
00031                  med_entity_type typ_ent_distant, med_geometry_type typ_geo_distant,
00032                  char *type);
00033 
00034 med_err MAJ_236_300_joint(med_idt fid, const char * const maa)
00035 
00036 
00037 {
00038   med_err ret = 0;
00039   char    maa_dist[MED_NAME_SIZE+1];
00040   med_int mdim,sdim;
00041   med_int njnt,ncor,ndom,nc;
00042   char jnt[MED_NAME_SIZE+1],corr[MED_NAME_SIZE+1];
00043   char des[MED_COMMENT_SIZE+1];
00044   med_int           njstep=0,nodtitncor=0,nentity=0;
00045   med_entity_type   typ_ent_local,typ_ent_distant;
00046   med_geometry_type typ_geo_local,typ_geo_distant;
00047   int i,j,k;
00048 
00049   MAJ_version_num(fid,2,3,6);
00050 
00051   /* Lecture du nombre de joints */
00052   if ((njnt = MEDnSubdomainJoint(fid,maa)) < 0) {
00053     MESSAGE("Erreur a la lecture du nombre de joints");
00054     return -1;
00055   }
00056 /*   printf("Nombre de joints : "IFORMAT" \n",njnt); */
00057 
00058   /* Lecture de tous les joints du maillage */
00059   for (i = 0;i<njnt;i++) {
00060 /*     printf("Joint numero : %d \n",i+1); */
00061 
00062     /* Lecture des infos sur le joints */
00063     if (MEDsubdomainJointInfo(fid,maa,i+1,jnt,des,&ndom,maa_dist,&njstep,&nodtitncor) < 0) {
00064       MESSAGE("Erreur a la lecture du joint d'indice");
00065       ISCRUTE_int(i+1);
00066       return -1;
00067     }
00068 /*     printf("Nom du joint: |%s| \n",jnt); */
00069 /*     printf("Description du joint      : |%s| \n",des); */
00070 /*     printf("Domaine en regard         : "IFORMAT" \n",ndom); */
00071 /*     printf("Maillage distant          : |%s| \n",maa_dist); */
00072 /*     printf("Nombre d'étapes de calcul : "IFORMAT" \n",njstep); */
00073 /*     printf("Nombre de correspondance pour (NO_DT,NO_IT) : "IFORMAT" \n",nodtitncor); */
00074 
00075     fprintf(stdout,"  >>> Normalisation du joint [%s] du maillage [%s] \n",
00076             jnt,maa);
00077 
00078     /* Creation du joint */
00079     MAJ_version_num(fid,3,0,8);
00080     if (MEDsubdomainJointCr(fid,maa,jnt,des,ndom,maa_dist) < 0) {
00081       MESSAGE("Erreur a la creation du joint");
00082       return -1;
00083     }
00084     MAJ_version_num(fid,2,3,6);
00085 
00086     /* lecture des correspondances une par une
00087        sans connaitre leur type a priori
00088        -> utilisation de la fonction MEDjointTypeCorres */
00089 
00090     ncor=1;
00091 
00092     while ( ncor <= nodtitncor ) {
00093 /*       ISCRUTE(ncor); */
00094       if ( MEDsubdomainCorrespondenceSizeInfo(fid,maa,jnt,MED_NO_DT,MED_NO_IT,ncor,
00095                                               &typ_ent_local,&typ_geo_local,&typ_ent_distant,&typ_geo_distant,
00096                                               &nentity) < 0 ) {
00097         MESSAGE("Erreur a la lecture des infos sur le nombre d'entite en regard");
00098         return -1;
00099       }
00100 
00101       /* Lecture de la correspondance Noeud Noeud */
00102       if ( afficheCorres(fid,maa,jnt,typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant,"------") < 0)
00103         return -1;
00104 
00105       ncor++;
00106     }
00107 
00108   }
00109   MAJ_version_num(fid,3,0,8);
00110 
00111   return ret;
00112 }
00113 
00114 
00115 
00116 
00117 int afficheCorres(med_idt fid, const char * const maa, char *jnt,
00118                  med_entity_type typ_ent_local,   med_geometry_type typ_geo_local,
00119                  med_entity_type typ_ent_distant, med_geometry_type typ_geo_distant,
00120                  char *type)
00121 {
00122   med_int nc;
00123   med_int *cortab;
00124   int k,ncor,ret=0;
00125 
00126   if ( MEDsubdomainCorrespondenceSize(fid,maa,jnt,MED_NO_DT,MED_NO_IT,
00127                                       typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant,
00128                                       &nc) < 0) {
00129     MESSAGE("Erreur a la lecture des infos sur le nombre d'entite en regard de type");
00130     SSCRUTE(type);
00131     return -1;
00132   }
00133 
00134 /*   printf("nb de couples d'entites en regard |%s|: "IFORMAT" \n",type,nc); */
00135 
00136   if (nc > 0) {
00137     cortab = (med_int*) malloc(sizeof(med_int)*nc*2);
00138     if ((ret=MEDsubdomainCorrespondenceRd(fid,maa,jnt,MED_NO_DT,MED_NO_IT,
00139                                           typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant,
00140                                           cortab)) < 0) {
00141       MESSAGE("Erreur a la lecture des correspondances sur ");
00142       SSCRUTE(type);
00143       ret = -1;
00144     }
00145     if (ret == 0) {
00146       MAJ_version_num(fid,3,0,8);
00147       for (k=0;k<nc;k++)
00148 /*      printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",k+1,*(cortab+2*k), */
00149 /*             *(cortab+2*k+1)); */
00150       /* Ecriture de la correspondance Noeud Maille */
00151       if (MEDsubdomainCorrespondenceWr(fid,maa,jnt,MED_NO_DT,MED_NO_IT,
00152                                        typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant,
00153                                        nc,cortab) < 0) {
00154         MESSAGE("Erreur a l'ecriture du tableau des correspondances :");
00155         ret = -1;
00156       }
00157       MAJ_version_num(fid,2,3,6);
00158 
00159     }
00160     free(cortab);
00161   }
00162   return ret;
00163 }
00164 

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