UsesCase_MEDfield_15.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 #define MESGERR 1
00025 #include <med_utils.h>
00026 
00027 #include <string.h>
00028 
00029 
00030 int main (int argc, char **argv) {
00031   med_idt fid=0,mfid=0;
00032   const char meshname[MED_NAME_SIZE+1] = "COMPUT_MESH";
00033   const char fieldname[MED_NAME_SIZE+1] = "SPEED";
00034   const med_int ncomponent = 3;
00035      
00036   const char componentname[3*MED_SNAME_SIZE+1] = "Vx              Vy              Vz";
00037   const char componentunit[3*MED_SNAME_SIZE+1] = "m/s             m/s             m/s";
00038   med_geometry_type geotype=MED_NONE;
00039   const med_int npart = 3;
00040   char structelementname[MED_NAME_SIZE+1]="";
00041   const med_float part_speed1[3*3] = { 1.1, 2.2, 3.3,
00042                                  4.4, 5.5, 6.6,
00043                                  7.7, 8.8, 9.9 };
00044   int ret=-1;
00045 
00046 
00047   
00048   fid = MEDfileOpen("UsesCase_MEDfield_15.med",MED_ACC_CREAT);
00049   if (fid < 0) {
00050     MESSAGE("ERROR : file creation ...");
00051     goto ERROR;
00052   }
00053 
00054   
00055   if (MEDlinkWr(fid,meshname,"./UsesCase_MEDstructElement_1.med") < 0) {
00056     MESSAGE("ERROR : create mesh link ...");
00057     goto ERROR;
00058   }
00059 
00060   
00061 
00062 
00063   if (( mfid=MEDfileObjectsMount(fid,  "UsesCase_MEDstructElement_1.med",MED_ELSTRUCT)) < 0 ) {
00064     MESSAGE("ERROR : file mounting ...");
00065     goto ERROR;
00066   }
00067 
00068   strcpy(structelementname,MED_PARTICLE_NAME);
00069   geotype = MEDstructElementGeotype(fid,structelementname);
00070 
00071 
00072   
00073 
00074 
00075 
00076 
00077 
00078 
00079   if (MEDfieldCr(fid, fieldname, MED_FLOAT64,
00080                  ncomponent, componentname, componentunit,
00081                  "ms", meshname) < 0) {
00082     MESSAGE("ERROR : create field");
00083     goto ERROR;
00084   }
00085 
00086   if (MEDfieldValueWithProfileWr(fid, fieldname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, MED_STRUCT_ELEMENT, geotype, 
00087                                  MED_COMPACT_PFLMODE, MED_NO_PROFILE, MED_NO_LOCALIZATION,
00088                                  MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
00089                                  npart, (unsigned char*) part_speed1) < 0) {
00090     MESSAGE("ERROR : write field values on MED_PARTICLE ");
00091     goto ERROR;
00092   }
00093 
00094   if ( MEDfileObjectsUnmount(fid, mfid, MED_ELSTRUCT) < 0 ) {
00095     MESSAGE("ERROR : file unmounting ...");
00096     goto ERROR;
00097   }
00098 
00099   ret=0;
00100  ERROR:
00101 
00102   
00103   if (MEDfileClose(fid) < 0) {
00104     MESSAGE("ERROR : close file ...");
00105     ret=-1;
00106   }
00107   
00108   return ret;
00109 }
00110