00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
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 
00041 
00042 
00043 
00044 
00045 
00046 
00047   const char                _varattname1_1[MED_NAME_SIZE+1]="MED_VFOO_ATR1_1";
00048  
00049 
00050   const med_int             _varatrvalue1_1[3]={ 22 , 24, 25 };
00051 
00052 
00053 
00054 
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   
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}; 
00079 
00080 
00081   
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  
00089 
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   
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