# MAJ_21_22_localisation_Gauss.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
    00024 #include "med_config.h"
    00025 #include "med_outils.h"
    00026 #include <string.h>
    00027
    00028 /* #ifdef __cplusplus */
    00029 /* } */
    00030 /* #endif */
    00031
    00032 #include "med21.h"
    00033 #include "med_hdfi21.h"
    00034 #include "MAJ_21_22.h"
    00035
    00036 void MAJ_21_22_localisation_Gauss(med_idt fid,char *nom_modele,med_int ngauss)
    00037 {
    00038   med_err ret;
    00039   med_geometrie_element type;
    00040   med_float *refcoo, *gaucoo, *poids;
    00041   char nom_type[4];
    00042   med_int edim, nsom,n,nlu;
    00043   int i;
    00044   char nom[MED_TAILLE_NOM+1];
    00045
    00046   /* On regarde si la localisation bidon existe deja
    00047      Si oui on s'en va */
    00048   n = MEDnGauss(fid);
    00049   if (n > 0)
    00050     for (i=1;i<=n;i++) {
    00051       ret = MEDgaussInfo(fid,i,nom,&type,&nlu);
    00052       if (! strcmp(nom,nom_modele)) return;
    00053     }
    00054
    00055   /* On deduit le type en fonction de nom_modele */
    00056   strncpy(nom_type,nom_modele,3);
    00057   nom_type[3] = '\0';
    00058   if (! strcmp(nom_type,(char *)(MED_NOM_SE2)))
    00059     type = MED_SEG2;
    00060   if (! strcmp(nom_type,(char *)(MED_NOM_SE3)))
    00061     type = MED_SEG3;
    00062   if (! strcmp(nom_type,(char *)(MED_NOM_TR3)))
    00063     type = MED_TRIA3;
    00064   if (! strcmp(nom_type,(char *)(MED_NOM_TR6)))
    00065     type = MED_TRIA6;
    00066   if (! strcmp(nom_type,(char *)(MED_NOM_QU4)))
    00067     type = MED_QUAD4;
    00068   if (! strcmp(nom_type,(char *)(MED_NOM_QU8)))
    00069     type = MED_QUAD8;
    00070   if (! strcmp(nom_type,(char *)(MED_NOM_TE4)))
    00071     type = MED_TETRA4;
    00072   if (! strcmp(nom_type,(char *)(MED_NOM_T10)))
    00073     type = MED_TETRA10;
    00074     if (! strcmp(nom_type,(char *)(MED_NOM_HE8)))
    00075     type = MED_HEXA8;
    00076   if (! strcmp(nom_type,(char *)(MED_NOM_H20)))
    00077     type = MED_HEXA20;
    00078   if (! strcmp(nom_type,(char *)(MED_NOM_PE6)))
    00079     type = MED_PENTA6;
    00080   if (! strcmp(nom_type,(char *)(MED_NOM_P15)))
    00081     type = MED_PENTA15;
    00082   if (! strcmp(nom_type,(char *)(MED_NOM_PY5)))
    00083     type = MED_PYRA5;
    00084   if (! strcmp(nom_type,(char *)(MED_NOM_P13)))
    00085     type = MED_PYRA13;
    00086
    00087   /* Dimension de la maille */
    00088   edim = type / 100;
    00089   nsom = type % 100;
    00090
    00091   /* On definit des coordonnées et des poids bidon */
    00092   refcoo = (med_float*) malloc(sizeof(med_float)*edim*nsom);
    00093   EXIT_IF(refcoo == NULL,NULL,NULL);
    00094   for (i=0;i<edim*nsom;i++) *(refcoo+i) = 0.;
    00095   gaucoo = (med_float*) malloc(sizeof(med_float)*edim*ngauss);
    00096   EXIT_IF(gaucoo == NULL,NULL,NULL);
    00097   for (i=0;i<edim*ngauss;i++) *(gaucoo+i) = 0.;
    00098   poids  = (med_float*) malloc(sizeof(med_float)*ngauss);
    00099   EXIT_IF(poids == NULL,NULL,NULL);
    00100   for (i=0;i<ngauss;i++) *(poids+i) = 0.;
    00101
    00102   /* On ecrit la localisation bidon */
    00103   ret = MEDgaussEcr(fid,type,refcoo,MED_FULL_INTERLACE,ngauss,gaucoo,poids,nom_modele);
    00104   EXIT_IF(ret < 0,"Ecriture de la localisation des points de Gauss",nom_modele);
    00105
    00106   /* On libere la memoire */
    00107   free(refcoo);
    00108   free(gaucoo);
    00109   free(poids);
    00110 }