Test_MEDmeshStructElementVarAttWr.c
Aller à la documentation de ce fichier.
/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2020 EDF R&D, CEA/DEN
* MED is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MED is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MED. If not, see <http://www.gnu.org/licenses/>.
*/
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
#ifdef DEF_LECT_ECR
#define MODE_ACCES MED_ACC_RDWR
#elif DEF_LECT_AJOUT
#define MODE_ACCES MED_ACC_RDEXT
#else
#define MODE_ACCES MED_ACC_CREAT
#endif
int main (int argc, char **argv)
{
med_err _ret=0;
med_idt _fid=0;
med_geometry_type _geotype=MED_NONE;
const char _elementname1[]="MED_BILLE";
/* med_int _elementdim1=3; */
/* const char _supportmeshname1[]="MED_BILLE_SUPPORT"; */
/* med_entity_type _entitytype1=MED_NODE; */
/* med_int _nnode1=1; */
/* med_int _ncell1=0; */
/* med_int _geocelltype1=MED_NONE; */
const char _varattname1_1[MED_NAME_SIZE+1]="MED_VFOO_ATR1_1";
/* const med_attribute_type _varatttype1_1=MED_ATT_INT; */
/* const med_int _ncomponent1_1=1; */
const med_int _varatrvalue1_1[3]={ 22 , 24, 25 };
/* const char _varattname1_2[MED_NAME_SIZE+1]="MED_VFOO_ATR1_2"; */
/* const med_attribute_type _varatttype1_2=MED_ATT_FLOAT64; */
/* const med_int _ncomponent1_2=2; */
const char _varattname1_3[MED_NAME_SIZE+1]="MED_VFOO_ATR1_3";
const med_attribute_type _varatttype1_3=MED_ATT_NAME;
const med_int _ncomponent1_3=1;
/*Ce qui suit est une seule chaine */
const char _varatrvalue1_3[3*MED_NAME_SIZE+1]=
{ "*--------------------------------1-----------------------------*"
"*--------------------------------2-----------------------------*"
"*--------------------------------3-----------------------------*"
};
const char _meshname[]="maa1";
char _axisname[3*MED_SNAME_SIZE+1]="";
char _axisunit[3*MED_SNAME_SIZE+1]="";
strcat(_axisname,"x ");
strcat(_axisname,"y ");
strcat(_axisname,"z ");
strcat(_axisunit,"cm ");
strcat(_axisunit,"cm ");
strcat(_axisunit,"cm ");
const med_int _nentity = 3;
const med_int _con[3]={ 2, 4 ,5}; /* (3 billes dont les centres sont les noeuds 2, 4 et 5 du maillage maa1 )*/
/* Ouverture en mode lecture du fichier Test_MEDstructuElement.med */
_fid = MEDfileOpen("current.med",MODE_ACCES);
if (_fid < 0) {
MESSAGE("Erreur à l'ouverture du fichier current.med");
return -1;
}
/* Creation du maillage "maa1" de type MED_UNSTRUCTURED_MESH
et de dimension 3 */
if (MEDmeshCr(_fid,_meshname,3,3,MED_UNSTRUCTURED_MESH, "un premier maillage","s",MED_SORT_DTIT,
MED_CARTESIAN,_axisname,_axisunit) < 0) {
MESSAGE("Erreur a la creation du maillage maa1");
return -1;
}
_geotype = MEDstructElementGeotype(_fid,_elementname1);
/* ecriture des connectivites des segments */
if ( MEDmeshElementConnectivityWr(_fid,_meshname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
MED_STRUCT_ELEMENT, _geotype, MED_NODAL,
MED_FULL_INTERLACE, _nentity, _con) < 0 ) {
MESSAGE("Impossible d'ecrire la connectivité des billes: ");
return -1;
}
if (MEDmeshStructElementVarAttWr(_fid,
_meshname,
MED_NO_DT,
MED_NO_IT,
_geotype,
_varattname1_1,
_nentity,
_varatrvalue1_1
) < 0 ) {
return -1;
}
if (MEDmeshStructElementVarAttWr(_fid,
_meshname,
MED_NO_DT,
MED_NO_IT,
_geotype,
_varattname1_3,
_nentity,
_varatrvalue1_3
) < 0 ) {
return -1;
}
if ( MEDmeshComputationStepCr(_fid,_meshname,MED_NO_DT,MED_NO_IT,
1,MED_NO_IT,0.5) < 0) {
fprintf(stderr,"Erreur a la creation du pas de temps du maillage %s\n",_meshname);
return -1;
}
return _ret;
}
MODE_ACCES
#define MODE_ACCES
Definition Test_MEDmeshStructElementVarAttWr.c:29
main
int main(int argc, char **argv)
Definition Test_MEDmeshStructElementVarAttWr.c:32
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition build.python3.12/include/med.h:81
MED_FULL_INTERLACE
@ MED_FULL_INTERLACE
Definition build.python3.12/include/med.h:96
med_geometry_type
int med_geometry_type
Definition build.python3.12/include/med.h:194
MED_SNAME_SIZE
#define MED_SNAME_SIZE
Definition build.python3.12/include/med.h:82
MED_CARTESIAN
@ MED_CARTESIAN
Definition build.python3.12/include/med.h:258
MED_SORT_DTIT
@ MED_SORT_DTIT
Definition build.python3.12/include/med.h:300
MED_UNDEF_DT
#define MED_UNDEF_DT
Definition build.python3.12/include/med.h:313
MED_UNSTRUCTURED_MESH
@ MED_UNSTRUCTURED_MESH
Definition build.python3.12/include/med.h:131
med_int
int med_int
Definition build.python3.12/include/med.h:333
MED_NO_DT
#define MED_NO_DT
Definition build.python3.12/include/med.h:311
MED_NO_IT
#define MED_NO_IT
Definition build.python3.12/include/med.h:312
MED_NONE
#define MED_NONE
Definition build.python3.12/include/med.h:231
MED_STRUCT_ELEMENT
@ MED_STRUCT_ELEMENT
Definition build.python3.12/include/med.h:144
med_attribute_type
med_attribute_type
Definition build.python3.12/include/med.h:173
MED_ATT_NAME
@ MED_ATT_NAME
Definition build.python3.12/include/med.h:175
med_err
herr_t med_err
Definition build.python3.12/include/med.h:323
med_idt
hid_t med_idt
Definition build.python3.12/include/med.h:322
MED_NODAL
@ MED_NODAL
Definition build.python3.12/include/med.h:255
MESSAGE
#define MESSAGE(chaine)
Definition build.python3.12/include/med_utils.h:324
MEDfileOpen
MEDC_EXPORT med_idt MEDfileOpen(const char *const filename, const med_access_mode accessmode)
Ouverture d'un fichier MED.
Definition MEDfileOpen.c:42
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
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
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
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
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