| 1 |
/* This file is part of MED. |
| 2 |
* |
| 3 |
* COPYRIGHT (C) 1999 - 2020 EDF R&D, CEA/DEN |
| 4 |
* MED is free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation, either version 3 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
* |
| 9 |
* MED is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU Lesser General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU Lesser General Public License |
| 15 |
* along with MED. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
|
| 19 |
#include <med.h> |
| 20 |
#define MESGERR 1 |
| 21 |
#include <med_utils.h> |
| 22 |
#include <string.h> |
| 23 |
|
| 24 |
#ifdef DEF_LECT_ECR |
| 25 |
#define MODE_ACCES MED_ACC_RDWR |
| 26 |
#elif DEF_LECT_AJOUT |
| 27 |
#define MODE_ACCES MED_ACC_RDEXT |
| 28 |
#else |
| 29 |
#define MODE_ACCES MED_ACC_CREAT |
| 30 |
#endif |
| 31 |
|
| 32 |
int main (int argc, char **argv) |
| 33 |
|
| 34 |
{ |
| 35 |
med_err _ret=0; |
| 36 |
med_idt _fid=0; |
| 37 |
med_geometry_type _geotype=MED_NONE; |
| 38 |
|
| 39 |
const char _elementname1[]="MED_BILLE"; |
| 40 |
/* med_int _elementdim1=3; */ |
| 41 |
/* const char _supportmeshname1[]="MED_BILLE_SUPPORT"; */ |
| 42 |
/* med_entity_type _entitytype1=MED_NODE; */ |
| 43 |
/* med_int _nnode1=1; */ |
| 44 |
/* med_int _ncell1=0; */ |
| 45 |
/* med_int _geocelltype1=MED_NONE; */ |
| 46 |
|
| 47 |
const char _varattname1_1[MED_NAME_SIZE+1]="MED_VFOO_ATR1_1"; |
| 48 |
/* const med_attribute_type _varatttype1_1=MED_ATT_INT; */ |
| 49 |
/* const med_int _ncomponent1_1=1; */ |
| 50 |
const med_int _varatrvalue1_1[3]={ 22 , 24, 25 }; |
| 51 |
|
| 52 |
/* const char _varattname1_2[MED_NAME_SIZE+1]="MED_VFOO_ATR1_2"; */ |
| 53 |
/* const med_attribute_type _varatttype1_2=MED_ATT_FLOAT64; */ |
| 54 |
/* const med_int _ncomponent1_2=2; */ |
| 55 |
|
| 56 |
const char _varattname1_3[MED_NAME_SIZE+1]="MED_VFOO_ATR1_3"; |
| 57 |
const med_attribute_type _varatttype1_3=MED_ATT_NAME; |
| 58 |
const med_int _ncomponent1_3=1; |
| 59 |
/*Ce qui suit est une seule chaine */ |
| 60 |
const char _varatrvalue1_3[3*MED_NAME_SIZE+1]= |
| 61 |
{ "*--------------------------------1-----------------------------*" |
| 62 |
"*--------------------------------2-----------------------------*" |
| 63 |
"*--------------------------------3-----------------------------*" |
| 64 |
}; |
| 65 |
|
| 66 |
const char _meshname[]="maa1"; |
| 67 |
char _axisname[3*MED_SNAME_SIZE+1]=""; |
| 68 |
char _axisunit[3*MED_SNAME_SIZE+1]=""; |
| 69 |
|
| 70 |
strcat(_axisname,"x "); |
| 71 |
strcat(_axisname,"y "); |
| 72 |
strcat(_axisname,"z "); |
| 73 |
strcat(_axisunit,"cm "); |
| 74 |
strcat(_axisunit,"cm "); |
| 75 |
strcat(_axisunit,"cm "); |
| 76 |
|
| 77 |
const med_int _nentity = 3; |
| 78 |
const med_int _con[3]={ 2, 4 ,5}; /* (3 billes dont les centres sont les noeuds 2, 4 et 5 du maillage maa1 )*/ |
| 79 |
|
| 80 |
|
| 81 |
/* Ouverture en mode lecture du fichier Test_MEDstructuElement.med */ |
| 82 |
_fid = MEDfileOpen("current.med",MODE_ACCES); |
| 83 |
if (_fid < 0) { |
| 84 |
MESSAGE("Erreur à l'ouverture du fichier current.med"); |
| 85 |
return -1; |
| 86 |
} |
| 87 |
|
| 88 |
/* Creation du maillage "maa1" de type MED_UNSTRUCTURED_MESH |
| 89 |
et de dimension 3 */ |
| 90 |
if (MEDmeshCr(_fid,_meshname,3,3,MED_UNSTRUCTURED_MESH, "un premier maillage","s",MED_SORT_DTIT, |
| 91 |
MED_CARTESIAN,_axisname,_axisunit) < 0) { |
| 92 |
MESSAGE("Erreur a la creation du maillage maa1"); |
| 93 |
return -1; |
| 94 |
} |
| 95 |
|
| 96 |
_geotype = MEDstructElementGeotype(_fid,_elementname1); |
| 97 |
|
| 98 |
/* ecriture des connectivites des segments */ |
| 99 |
if ( MEDmeshElementConnectivityWr(_fid,_meshname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, |
| 100 |
MED_STRUCT_ELEMENT, _geotype, MED_NODAL, |
| 101 |
MED_FULL_INTERLACE, _nentity, _con) < 0 ) { |
| 102 |
MESSAGE("Impossible d'ecrire la connectivité des billes: "); |
| 103 |
return -1; |
| 104 |
} |
| 105 |
|
| 106 |
if (MEDmeshStructElementVarAttWr(_fid, |
| 107 |
_meshname, |
| 108 |
MED_NO_DT, |
| 109 |
MED_NO_IT, |
| 110 |
_geotype, |
| 111 |
_varattname1_1, |
| 112 |
_nentity, |
| 113 |
_varatrvalue1_1 |
| 114 |
) < 0 ) { |
| 115 |
return -1; |
| 116 |
} |
| 117 |
|
| 118 |
if (MEDmeshStructElementVarAttWr(_fid, |
| 119 |
_meshname, |
| 120 |
MED_NO_DT, |
| 121 |
MED_NO_IT, |
| 122 |
_geotype, |
| 123 |
_varattname1_3, |
| 124 |
_nentity, |
| 125 |
_varatrvalue1_3 |
| 126 |
) < 0 ) { |
| 127 |
return -1; |
| 128 |
} |
| 129 |
|
| 130 |
if ( MEDmeshComputationStepCr(_fid,_meshname,MED_NO_DT,MED_NO_IT, |
| 131 |
1,MED_NO_IT,0.5) < 0) { |
| 132 |
fprintf(stderr,"Erreur a la creation du pas de temps du maillage %s\n",_meshname); |
| 133 |
return -1; |
| 134 |
} |
| 135 |
|
| 136 |
return _ret; |
| 137 |
|
| 138 |
} |
| 139 |
|