Test_MEDfieldInterpWr.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=-1;
med_idt _fid=0;
char _meshname1[MED_NAME_SIZE+1] = "meshname1";
char _axisname[3*MED_SNAME_SIZE+1] = "x y z ";
char _unitname[3*MED_SNAME_SIZE+1] = "cm cm cm ";
char _fieldname1[MED_NAME_SIZE+1] = "champ reel";
char _componentname1[2*MED_SNAME_SIZE+1] = "comp1 comp2 ";
/*12345678901234561234567890123456*/
char _unitname1[2*MED_SNAME_SIZE+1] = "unit1 unit2 ";
char _dtunit[MED_SNAME_SIZE+1] = "s";
med_int _ncomponentname1 = 2;
/*Exemple 1 :
- Elément de référence de type géométrique MED_TRIA3
- Point X(X1,X2) quelconque dans le plan de l'élément de référence
- Fonctions de base : P1(X)=1-X1-X2 ; P2(X)=X1; P3(X)=X2;
(issu du choix de la base polynomiale (1,X1,X2)
et des trois noeuds de la maille de référence pour
construire l'interpolation)
*/
const char _interpname1[] ="interpname1";
med_geometry_type _geotype1 =MED_TRIA3;
/* Ouverture en mode creation du fichier "current.med" */
_fid = MEDfileOpen("current.med",MODE_ACCES);
if (_fid < 0) {
MESSAGE("Erreur a la creation du fichier current.med");
return -1;
}
/* Creation de _meshname1 de dimension 2 dans un espace de dimension 3*/
if (MEDmeshCr( _fid, _meshname1, 3, 2, MED_UNSTRUCTURED_MESH,
"Maillage vide","s", MED_SORT_DTIT,
MED_CARTESIAN, _axisname, _unitname) < 0) {
MESSAGE("Erreur a la creation du maillage : "); SSCRUTE(_meshname1);
goto ERROR;
}
/* Creation du champ réel n°1 */
if ( MEDfieldCr(_fid,_fieldname1,MED_FLOAT64,
_ncomponentname1,_componentname1,_unitname1,_dtunit,_meshname1 ) < 0) {
MESSAGE("Erreur à la création du champ : ");SSCRUTE(_fieldname1);
goto ERROR;
};
if ( (_ret = MEDfieldInterpWr(_fid,
_fieldname1,
_interpname1) <0) ) {
MESSAGE("Erreur à l'écriture de la fonction d'interpolation n°1 sur le champ : ");SSCRUTE(_fieldname1);
}
ERROR:
if (MEDfileClose(_fid) < 0) {
MESSAGE("ERROR : file closing");
return -1;
}
return _ret;
}
MODE_ACCES
#define MODE_ACCES
Definition Test_MEDfieldInterpWr.c:28
main
int main(int argc, char **argv)
Definition Test_MEDfieldInterpWr.c:31
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition build.python3.12/include/med.h:81
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_TRIA3
#define MED_TRIA3
Definition build.python3.12/include/med.h:203
MED_FLOAT64
@ MED_FLOAT64
Definition build.python3.12/include/med.h:166
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_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_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
SSCRUTE
#define SSCRUTE(chaine)
Definition build.python3.12/include/med_utils.h:323
MESSAGE
#define MESSAGE(chaine)
Definition build.python3.12/include/med_utils.h:324
MEDfieldInterpWr
MEDC_EXPORT med_err MEDfieldInterpWr(const med_idt fid, const char *const fieldname, const char *const interpname)
Cette routine associe une fonction d'interpolation interpname au champ résultat fieldname.
Definition MEDfieldInterpWr.c:36
MEDfieldCr
MEDC_EXPORT med_err MEDfieldCr(const med_idt fid, const char *const fieldname, const med_field_type fieldtype, const med_int ncomponent, const char *const componentname, const char *const componentunit, const char *const dtunit, const char *const meshname)
Cette fonction crée un champ dans un fichier.
Definition MEDfieldCr.c:44
MEDfileClose
MEDC_EXPORT med_err MEDfileClose(med_idt fid)
Fermeture d'un fichier MED.
Definition MEDfileClose.c:30
MEDfileOpen
MEDC_EXPORT med_idt MEDfileOpen(const char *const filename, const med_access_mode accessmode)
Ouverture d'un fichier MED.
Definition MEDfileOpen.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