MED fichier

Test_MEDmeshStructElementVarAttWr.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2021 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
MED_CARTESIAN
Definition: med.h:258
MED_FULL_INTERLACE
Definition: med.h:96
MED_SORT_DTIT
Definition: med.h:309
MEDmeshCr
MEDC_EXPORT med_err MEDmeshCr(const med_idt fid, const char *const meshname, const med_int spacedim, const med_int meshdim, const med_mesh_type meshtype, const char *const description, const char *const dtunit, const med_sorting_type sortingtype, const med_axis_type axistype, const char *const axisname, const char *const axisunit)
Cette routine permet de créer un maillage dans un fichier.
Definition: MEDmeshCr.c:45
MEDfileOpen
MEDC_EXPORT med_idt MEDfileOpen(const char *const filename, const med_access_mode accessmode)
Ouverture d'un fichier MED.
Definition: MEDfileOpen.c:42
med_geometry_type
int med_geometry_type
Definition: med.h:194
MED_SNAME_SIZE
#define MED_SNAME_SIZE
Definition: med.h:82
MED_NODAL
Definition: med.h:255
med_idt
hid_t med_idt
Definition: med.h:331
MED_STRUCT_ELEMENT
Definition: med.h:144
med_err
herr_t med_err
Definition: med.h:332
MEDmeshStructElementVarAttWr
MEDC_EXPORT med_err MEDmeshStructElementVarAttWr(const med_idt fid, const char *const meshname, const med_int numdt, const med_int numit, const med_geometry_type mgeotype, const char *const varattname, const med_int nentity, const void *const value)
Cette routine écrit les valeurs d'un attribut caractéristique variable sur les éléments de structure ...
Definition: MEDmeshStructElementVarAttWr.c:42
MEDmeshComputationStepCr
MEDC_EXPORT med_err MEDmeshComputationStepCr(const med_idt fid, const char *const meshname, const med_int numdt1, const med_int numit1, const med_int numdt2, const med_int numit2, const med_float dt2)
Cette routine permet de créer une nouvelle étape de calcul dans un maillage.
Definition: MEDmeshComputationStepCr.c:40
MESSAGE
#define MESSAGE(chaine)
Definition: med_utils.h:324
med_int
int med_int
Definition: med.h:342
med_attribute_type
med_attribute_type
Definition: med.h:173
med.h
MED_NO_DT
#define MED_NO_DT
Definition: med.h:320
MED_NONE
#define MED_NONE
Definition: med.h:231
main
int main(int argc, char **argv)
Definition: Test_MEDmeshStructElementVarAttWr.c:32
MED_ATT_NAME
Definition: med.h:175
MEDstructElementGeotype
MEDC_EXPORT med_geometry_type MEDstructElementGeotype(const med_idt fid, const char *const modelname)
Cette routine renvoie le type géométrique mgeotype associé au modèle d'éléments de structure de nom m...
Definition: MEDstructElementGeotype.c:38
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:81
MED_UNSTRUCTURED_MESH
Definition: med.h:131
MED_UNDEF_DT
#define MED_UNDEF_DT
Definition: med.h:322
MEDmeshElementConnectivityWr
MEDC_EXPORT med_err MEDmeshElementConnectivityWr(const med_idt fid, const char *const meshname, const med_int numdt, const med_int numit, const med_float dt, const med_entity_type entitype, const med_geometry_type geotype, const med_connectivity_mode cmode, const med_switch_mode switchmode, const med_int nentity, const med_int *const connectivity)
Cette routine permet d'écrire dans un maillage le tableau des connectivités pour un type géométrique ...
Definition: MEDmeshElementConnectivityWr.c:42
MED_NO_IT
#define MED_NO_IT
Definition: med.h:321
MODE_ACCES
#define MODE_ACCES
Definition: Test_MEDmeshStructElementVarAttWr.c:29
med_utils.h