# MAJ_21_22_localisation_Gauss.c

Aller à la documentation de ce fichier.

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