# Test_MEDmeshStructElementVarAttWr.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 #include <med.h>
    00020 #define MESGERR 1
    00021 #include <med_utils.h>
    00022 #include <string.h>
    00023
    00024 #ifdef DEF_LECT_ECR
    00025 #define MODE_ACCES MED_ACC_RDWR
    00026 #elif DEF_LECT_AJOUT
    00027 #define MODE_ACCES MED_ACC_RDEXT
    00028 #else
    00029 #define MODE_ACCES MED_ACC_CREAT
    00030 #endif
    00031
    00032 int main (int argc, char **argv)
    00033
    00034 {
    00035   med_err           _ret=0;
    00036   med_idt           _fid=0;
    00037   med_geometry_type _geotype=MED_NONE;
    00038
    00039   const char        _elementname1[]="MED_BILLE";
    00040 /*   med_int           _elementdim1=3; */
    00041 /*   const char        _supportmeshname1[]="MED_BILLE_SUPPORT"; */
    00042 /*   med_entity_type   _entitytype1=MED_NODE; */
    00043 /*   med_int           _nnode1=1; */
    00044 /*   med_int           _ncell1=0; */
    00045 /*   med_int           _geocelltype1=MED_NONE; */
    00046
    00047   const char                _varattname1_1[MED_NAME_SIZE+1]="MED_VFOO_ATR1_1";
    00048  /*  const med_attribute_type  _varatttype1_1=MED_ATT_INT; */
    00049 /*   const med_int             _ncomponent1_1=1; */
    00050   const med_int             _varatrvalue1_1[3]={ 22 , 24, 25 };
    00051
    00052 /*   const char                _varattname1_2[MED_NAME_SIZE+1]="MED_VFOO_ATR1_2"; */
    00053 /*   const med_attribute_type  _varatttype1_2=MED_ATT_FLOAT64; */
    00054 /*   const med_int             _ncomponent1_2=2; */
    00055
    00056   const char                _varattname1_3[MED_NAME_SIZE+1]="MED_VFOO_ATR1_3";
    00057   const med_attribute_type  _varatttype1_3=MED_ATT_NAME;
    00058   const med_int             _ncomponent1_3=1;
    00059   /*Ce qui suit est une seule chaine */
    00060   const char                _varatrvalue1_3[3*MED_NAME_SIZE+1]=
    00061     { "*--------------------------------1-----------------------------*"
    00062       "*--------------------------------2-----------------------------*"
    00063       "*--------------------------------3-----------------------------*"
    00064     };
    00065
    00066   const char   _meshname[]="maa1";
    00067   char         _axisname[3*MED_SNAME_SIZE+1]="";
    00068   char         _axisunit[3*MED_SNAME_SIZE+1]="";
    00069
    00070   strcat(_axisname,"x               ");
    00071   strcat(_axisname,"y               ");
    00072   strcat(_axisname,"z               ");
    00073   strcat(_axisunit,"cm              ");
    00074   strcat(_axisunit,"cm              ");
    00075   strcat(_axisunit,"cm              ");
    00076
    00077   const med_int _nentity = 3;
    00078   const med_int _con[3]={ 2, 4 ,5}; /* (3 billes dont les centres sont les noeuds 2, 4 et 5 du maillage maa1 )*/
    00079
    00080
    00081   /* Ouverture en mode lecture du fichier Test_MEDstructuElement.med */
    00082   _fid = MEDfileOpen("current.med",MODE_ACCES);
    00083   if (_fid < 0) {
    00084     MESSAGE("Erreur à l'ouverture du fichier current.med");
    00085     return -1;
    00086   }
    00087
    00088  /* Creation du maillage "maa1" de type MED_UNSTRUCTURED_MESH
    00089      et de dimension 3 */
    00090   if (MEDmeshCr(_fid,_meshname,3,3,MED_UNSTRUCTURED_MESH, "un premier maillage","s",MED_SORT_DTIT,
    00091                 MED_CARTESIAN,_axisname,_axisunit) < 0) {
    00092     MESSAGE("Erreur a la creation du maillage maa1");
    00093     return -1;
    00094   }
    00095
    00096   _geotype = MEDstructElementGeotype(_fid,_elementname1);
    00097
    00098   /* ecriture des connectivites des segments */
    00099   if ( MEDmeshElementConnectivityWr(_fid,_meshname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
    00100                                     MED_STRUCT_ELEMENT, _geotype, MED_NODAL,
    00101                                     MED_FULL_INTERLACE, _nentity, _con) < 0 ) {
    00102     MESSAGE("Impossible d'ecrire la connectivité des billes: ");
    00103     return -1;
    00104   }
    00105
    00106   if (MEDmeshStructElementVarAttWr(_fid,
    00107                                    _meshname,
    00108                                    MED_NO_DT,
    00109                                    MED_NO_IT,
    00110                                    _geotype,
    00111                                    _varattname1_1,
    00112                                    _nentity,
    00113                                    _varatrvalue1_1
    00114                                    ) < 0 ) {
    00115     return -1;
    00116   }
    00117
    00118   if (MEDmeshStructElementVarAttWr(_fid,
    00119                                    _meshname,
    00120                                    MED_NO_DT,
    00121                                    MED_NO_IT,
    00122                                    _geotype,
    00123                                    _varattname1_3,
    00124                                    _nentity,
    00125                                    _varatrvalue1_3
    00126                                    ) < 0 ) {
    00127     return -1;
    00128   }
    00129
    00130   if ( MEDmeshComputationStepCr(_fid,_meshname,MED_NO_DT,MED_NO_IT,
    00131                                 1,MED_NO_IT,0.5) < 0) {
    00132     fprintf(stderr,"Erreur a la creation du pas de temps du maillage %s\n",_meshname);
    00133     return -1;
    00134   }
    00135
    00136   return _ret;
    00137
    00138 }
    00139