MED fichier
test12.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  * - Nom du fichier : test12.c
20  *
21  * - Description : ecriture d'une equivalence dans un maillage MED
22  *
23  *****************************************************************************/
24 
25 #include <med.h>
26 #define MESGERR 1
27 #include <med_utils.h>
28 
29 #ifdef DEF_LECT_ECR
30 #define MODE_ACCES MED_ACC_RDWR
31 #elif DEF_LECT_AJOUT
32 #define MODE_ACCES MED_ACC_RDEXT
33 #else
34 #define MODE_ACCES MED_ACC_CREAT
35 #endif
36 
37 int main (int argc, char **argv)
38 
39 
40 {
41  med_idt fid;
42  char maa[MED_NAME_SIZE+1]= "maa1";
43  char equ[MED_NAME_SIZE+1] = "equivalence";
44  char des[MED_COMMENT_SIZE+1] = "equivalence sur les mailles MED_TRIA3";
45  med_int mdim = 3;
46  med_int ncor = 3;
47  med_int cor[6] = {1,2,3,4,5,6};
48  char nomcoo[3*MED_SNAME_SIZE+1] = "x y z ";
49  char unicoo[3*MED_SNAME_SIZE+1] = "cm cm cm ";
50 
51 
52  /* Creation du fichier "test12.med" */
53  if ((fid = MEDfileOpen("test12.med",MODE_ACCES)) < 0) {
54  MESSAGE("Erreur a la creation du fichier test12.med");
55  return -1;
56  }
57 
58  if (MEDmeshCr( fid, maa, 3, 3, MED_UNSTRUCTURED_MESH,
59  "un maillage pour test12","s", MED_SORT_DTIT,
60  MED_CARTESIAN, nomcoo, unicoo) < 0) {
61  MESSAGE("Erreur a la creation du maillage : "); SSCRUTE(maa);
62  return -1;
63  }
64 
65  /* Creation de l'equivalence */
66  if (MEDequivalenceCr(fid,maa,equ,des) < 0)
67  {
68  MESSAGE("Erreur a la creation de l'equivalence");
69  return -1;
70  }
71 
72  /* Ecriture des sur les mailles MED_TRIA3 */
74  MED_CELL,MED_TRIA3,ncor,cor) < 0)
75  {
76  MESSAGE("Erreur a l'ecriture du tableau des correspondances");
77  return -1;
78  }
79 
80  /* Fermeture du fichier */
81  if (MEDfileClose(fid) < 0) {
82  MESSAGE("Erreur a la fermeture du fichier");
83  return -1;
84  }
85 
86  return 0;
87 }
88 
89 
90 
91 
MED_CARTESIAN
Definition: med.h:258
MED_TRIA3
#define MED_TRIA3
Definition: med.h:203
MED_SORT_DTIT
Definition: med.h:309
MED_COMMENT_SIZE
#define MED_COMMENT_SIZE
Definition: med.h:79
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_SNAME_SIZE
#define MED_SNAME_SIZE
Definition: med.h:82
med_idt
hid_t med_idt
Definition: med.h:331
MED_CELL
Definition: med.h:143
MESSAGE
#define MESSAGE(chaine)
Definition: med_utils.h:324
med_int
int med_int
Definition: med.h:342
main
int main(int argc, char **argv)
Definition: test12.c:36
med.h
MODE_ACCES
#define MODE_ACCES
Definition: test12.c:33
MED_NO_DT
#define MED_NO_DT
Definition: med.h:320
SSCRUTE
#define SSCRUTE(chaine)
Definition: med_utils.h:323
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:81
MED_UNSTRUCTURED_MESH
Definition: med.h:131
MEDfileClose
MEDC_EXPORT med_err MEDfileClose(med_idt fid)
Fermeture d'un fichier MED.
Definition: MEDfileClose.c:30
MEDequivalenceCorrespondenceWr
MEDC_EXPORT med_err MEDequivalenceCorrespondenceWr(const med_idt fid, const char *const meshname, const char *const equivname, const med_int numdt, const med_int numit, const med_entity_type entitype, const med_geometry_type geotype, const med_int nentity, const med_int *const correspondence)
Cette routine permet d'écrire un tableau de correspondances entre les entités d'un maillage dans une ...
Definition: MEDequivalenceCorrespondenceWr.c:43
MED_NO_IT
#define MED_NO_IT
Definition: med.h:321
MEDequivalenceCr
MEDC_EXPORT med_err MEDequivalenceCr(const med_idt fid, const char *const meshname, const char *const equivname, const char *const description)
Cette routine permet la création d'une équivalence portant sur les entités d'un maillage.
Definition: MEDequivalenceCr.c:37
med_utils.h