Test_MEDfieldInterpWr.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2015  EDF R&D, CEA/DEN
00004  *  MED is free software: you can redistribute it and/or modify
00005  *  it under the terms of the GNU Lesser General Public License as published by
00006  *  the Free Software Foundation, either version 3 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  MED is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Lesser General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Lesser General Public License
00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #include <med.h>
00019 #define MESGERR 1
00020 #include <med_utils.h>
00021 #include <string.h>
00022 
00023 #ifdef DEF_LECT_ECR
00024 #define MODE_ACCES MED_ACC_RDWR
00025 #elif DEF_LECT_AJOUT
00026 #define MODE_ACCES MED_ACC_RDEXT
00027 #else
00028 #define MODE_ACCES MED_ACC_CREAT
00029 #endif
00030 
00031 int main (int argc, char **argv)
00032 
00033 {
00034   med_err           _ret=-1;
00035   med_idt           _fid=0;
00036 
00037   char _meshname1[MED_NAME_SIZE+1]   = "meshname1";
00038   char _axisname[3*MED_SNAME_SIZE+1] = "x               y               z               ";
00039   char _unitname[3*MED_SNAME_SIZE+1] = "cm              cm              cm              ";
00040 
00041   char _fieldname1[MED_NAME_SIZE+1]  = "champ reel";
00042   char _componentname1[2*MED_SNAME_SIZE+1] = "comp1           comp2           ";
00043                                    /*12345678901234561234567890123456*/
00044   char _unitname1[2*MED_SNAME_SIZE+1] = "unit1           unit2           ";
00045   char _dtunit[MED_SNAME_SIZE+1] = "s";
00046   med_int _ncomponentname1  = 2;
00047 
00048 
00049   /*Exemple 1 :
00050 
00051   - Elément de référence de type géométrique MED_TRIA3
00052   - Point X(X1,X2) quelconque dans le plan de l'élément de référence
00053   - Fonctions de base : P1(X)=1-X1-X2 ; P2(X)=X1; P3(X)=X2;
00054     (issu du choix de la base polynomiale (1,X1,X2)
00055      et des trois noeuds de la maille de référence pour
00056      construire l'interpolation)
00057   */
00058   const char         _interpname1[]   ="interpname1";
00059   med_geometry_type  _geotype1        =MED_TRIA3;
00060 
00061 
00062   /* Ouverture en mode creation du fichier "current.med" */
00063   _fid = MEDfileOpen("current.med",MODE_ACCES);
00064   if (_fid < 0) {
00065     MESSAGE("Erreur a la creation du fichier current.med");
00066     return -1;
00067   }
00068 
00069   /* Creation de _meshname1 de dimension 2 dans un espace de dimension 3*/
00070   if (MEDmeshCr( _fid, _meshname1, 3, 2, MED_UNSTRUCTURED_MESH,
00071                  "Maillage vide","s", MED_SORT_DTIT,
00072                  MED_CARTESIAN, _axisname, _unitname) < 0) {
00073     MESSAGE("Erreur a la creation du maillage : "); SSCRUTE(_meshname1);
00074     goto ERROR;
00075   }
00076 
00077 
00078  /* Creation du champ réel n°1 */
00079   if ( MEDfieldCr(_fid,_fieldname1,MED_FLOAT64,
00080                   _ncomponentname1,_componentname1,_unitname1,_dtunit,_meshname1 ) < 0) {
00081     MESSAGE("Erreur à la création du champ : ");SSCRUTE(_fieldname1);
00082     goto ERROR;
00083   };
00084 
00085 
00086   if ( (_ret =  MEDfieldInterpWr(_fid,
00087                                  _fieldname1,
00088                                  _interpname1) <0) ) {
00089     MESSAGE("Erreur à l'écriture de la fonction d'interpolation n°1 sur le champ : ");SSCRUTE(_fieldname1);
00090   }
00091 
00092 
00093  ERROR:
00094   if (MEDfileClose(_fid) < 0) {
00095     MESSAGE("ERROR : file closing");
00096     return -1;
00097   }
00098 
00099 
00100   return _ret;
00101 
00102 }
00103 

Généré le Thu Oct 8 14:26:17 2015 pour MED fichier par  doxygen 1.6.1