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