UsesCase_MEDfield_15b.c
Aller à la documentation de ce fichier.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <med.h>
00024
00025 #include "med_hdfi.h"
00026 #define MESGERR 1
00027 #include <med_utils.h>
00028
00029 #include <string.h>
00030
00031
00032 int main (int argc, char **argv) {
00033 med_idt fid2=0,oid=0;
00034 med_idt fid=0,mfid=0;
00035 const char meshname[MED_NAME_SIZE+1] = "COMPUT_MESH";
00036 const char fieldname[MED_NAME_SIZE+1] = "SPEED";
00037 const med_int ncomponent = 3;
00038
00039 const char componentname[3*MED_SNAME_SIZE+1] = "Vx Vy Vz";
00040 const char componentunit[3*MED_SNAME_SIZE+1] = "m/s m/s m/s";
00041 med_geometry_type geotype=MED_NONE;
00042 const med_int npart = 3;
00043 char structelementname[MED_NAME_SIZE+1]="";
00044 const med_float part_speed1[3*3] = { 1.1, 2.2, 3.3,
00045 4.4, 5.5, 6.6,
00046 7.7, 8.8, 9.9 };
00047 int ret=-1;
00048
00049
00050
00051 fid = MEDfileOpen("UsesCase_MEDfield_15b.med",MED_ACC_CREAT);
00052 if (fid < 0) {
00053 MESSAGE("ERROR : file creation ...");
00054 goto ERROR;
00055 }
00056
00057
00058 if (MEDlinkWr(fid,meshname,"./UsesCase_MEDstructElement_1.med") < 0) {
00059 MESSAGE("ERROR : create mesh link ...");
00060 goto ERROR;
00061 }
00062
00063
00064
00065
00066
00067
00068 fid2 = MEDfileOpen(argv[1],MED_ACC_RDONLY);
00069 if (fid2 < 0) {
00070 MESSAGE("Erreur � l'ouverture du fichier UsesCase_MEDstructElement_1_byid.med");
00071 goto ERROR;
00072 }
00073
00074
00075 if (( mfid=MEDfileObjectsMountById(fid,fid2,"/byid",MED_ELSTRUCT)) < 0 ) {
00076 MESSAGE("ERROR : file mounting ...");
00077 goto ERROR;
00078 }
00079
00080 strcpy(structelementname,MED_PARTICLE_NAME);
00081 geotype = MEDstructElementGeotype(fid,structelementname);
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 if (MEDfieldCr(fid, fieldname, MED_FLOAT64,
00092 ncomponent, componentname, componentunit,
00093 "ms", meshname) < 0) {
00094 MESSAGE("ERROR : create field");
00095 goto ERROR;
00096 }
00097
00098 if (MEDfieldValueWithProfileWr(fid, fieldname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, MED_STRUCT_ELEMENT, geotype,
00099 MED_COMPACT_PFLMODE, MED_NO_PROFILE, MED_NO_LOCALIZATION,
00100 MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
00101 npart, (unsigned char*) part_speed1) < 0) {
00102 MESSAGE("ERROR : write field values on MED_PARTICLE ");
00103 goto ERROR;
00104 }
00105
00106 if ( MEDfileObjectsUnmount(fid, mfid, MED_ELSTRUCT) < 0 ) {
00107 MESSAGE("ERROR : file unmounting ...");
00108 goto ERROR;
00109 }
00110
00111 ret=0;
00112 ERROR:
00113
00114 if (MEDfileClose(fid) < 0) {
00115 MESSAGE("ERROR : close file ...");
00116 ret=-1;
00117 }
00118
00119
00120 return ret;
00121 }
00122