MED fichier
test14.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 : test14.c
20  *
21  * - Description : ecriture des noeuds d'un maillage MED
22  * a l'aide des routines de niveau 2
23  * equivalent a test4.c
24  *
25  *****************************************************************************/
26 
27 #include <med.h>
28 #define MESGERR 1
29 #include <med_utils.h>
30 
31 #ifdef DEF_LECT_ECR
32 #define MODE_ACCES MED_ACC_RDWR
33 #elif DEF_LECT_AJOUT
34 #define MODE_ACCES MED_ACC_RDEXT
35 #else
36 #define MODE_ACCES MED_ACC_CREAT
37 #endif
38 
39 int main (int argc, char **argv)
40 
41 
42 {
43  med_idt fid;
44  /* la dimension du maillage */
45  med_int mdim = 2;
46  /* nom du maillage de longueur maxi MED_NAME_SIZE */
47  char maa[MED_NAME_SIZE+1] = "maa1";
48  /* le nombre de noeuds */
49  med_int nnoe = 4;
50  /* table des coordonnees
51  profil : (dimension * nombre de noeuds) */
52  med_float coo[8] = {0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0};
53  /* tables des noms et des unites des coordonnees
54  profil : (dimension*MED_SNAME_SIZE+1) */
55  /* 12345678901234561234567890123456 */
56  char nomcoo[2*MED_SNAME_SIZE+1] = "x y ";
57  char unicoo[2*MED_SNAME_SIZE+1] = "cm cm ";
58  /* tables des noms, numeros, numeros de familles des noeuds
59  autant d'elements que de noeuds - les noms ont pout longueur
60  MED_SNAME_SIZE */
61  /* 1234567890123456123456789012345612345678901234561234567890123456 */
62  char nomnoe[4*MED_SNAME_SIZE+1] = "nom1 nom2 nom3 nom4 ";
63  med_int numnoe[4] = {1,2,3,4};
64  med_int nufano[4] = {0,1,2,2};
65 
66  /* Creation du fichier test14.med */
67  if ((fid = MEDfileOpen("test14.med",MODE_ACCES)) < 0) {
68  MESSAGE("Erreur a la creation du fichier test14.med");
69  return -1;
70  }
71 
72 
73  /* Creation du maillage */
74  if (MEDmeshCr( fid, maa, mdim, mdim, MED_UNSTRUCTURED_MESH,
75  "un maillage pour test14","s", MED_SORT_DTIT,
76  MED_CARTESIAN, nomcoo, unicoo) < 0) {
77  MESSAGE("Erreur a la creation du maillage : "); SSCRUTE(maa);
78  return -1;
79  }
80 
81  /* Ecriture des noeuds d'un maillage MED :
82  - Des cooordonnees en mode MED_FULL_INTERLACE : (X1,Y1,X2,Y2,X3,Y3,...)
83  dans un repere cartesien
84  - Des noms (optionnel dans un fichier MED)
85  - Des numeros (optionnel dans un fichier MED)
86  - Des numeros de familles des noeuds */
88  nnoe,coo,MED_TRUE,nomnoe,MED_TRUE,numnoe,MED_TRUE,
89  nufano) < 0) {
90  MESSAGE("Erreur a l'ecriture des noeuds du maillage");
91  return -1;
92  }
93 
94  /* Fermeture du fichier */
95  if (MEDfileClose(fid) < 0) {
96  MESSAGE("Erreur a la fermeture du fichier");
97  return -1;
98  }
99 
100  return 0;
101 }
102 
103 
104 
105 
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_SNAME_SIZE
#define MED_SNAME_SIZE
Definition: med.h:82
med_idt
hid_t med_idt
Definition: med.h:331
MED_TRUE
Definition: med.h:260
MESSAGE
#define MESSAGE(chaine)
Definition: med_utils.h:324
med_int
int med_int
Definition: med.h:342
med.h
main
int main(int argc, char **argv)
Definition: test14.c:38
med_float
double med_float
Definition: med.h:336
MED_NO_DT
#define MED_NO_DT
Definition: med.h:320
SSCRUTE
#define SSCRUTE(chaine)
Definition: med_utils.h:323
MEDmeshNodeWr
MEDC_EXPORT med_err MEDmeshNodeWr(const med_idt fid, const char *const meshname, const med_int numdt, const med_int numit, const med_float dt, const med_switch_mode switchmode, const med_int nentity, const med_float *const coordinate, const med_bool withnodename, const char *const nodename, const med_bool withnodenumber, const med_int *const nodenumber, const med_bool withfamnumber, const med_int *const famnumber)
Cette routine permet l'écriture des noeuds d'un maillage non structuré pour une étape de calcul donné...
Definition: MEDmeshNodeWr.c:45
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
MED_UNDEF_DT
#define MED_UNDEF_DT
Definition: med.h:322
MED_NO_IT
#define MED_NO_IT
Definition: med.h:321
MODE_ACCES
#define MODE_ACCES
Definition: test14.c:35
med_utils.h