UsesCase_MEDinterp_2.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 
00024 #include <med.h>
00025 #define MESGERR 1
00026 #include <med_utils.h>
00027 
00028 #include <string.h>
00029 
00030 int main (int argc, char **argv) {
00031   med_idt fid;
00032   const char interpname[MED_NAME_SIZE+1] = "MED_TRIA3 interpolation family";
00033   med_geometry_type geotype                    =MED_NONE;
00034   med_bool          cellnodes                  =MED_FALSE;
00035   med_int           nbasisfunc              =0;
00036   med_int           nvariable               =0;
00037   med_int           maxdegree                  =0;
00038   med_int           nmaxcoefficient            =0;
00039   int               basisfuncit                =0;
00040   int               powerit                    =0;
00041   med_int           ncoefficient            =0;
00042   med_int*          power                      =NULL;
00043   med_float*        coefficient                =NULL;
00044   int               coefficientit              =0;
00045   int ret=-1;
00046 
00047 
00048   
00049   fid = MEDfileOpen("UsesCase_MEDinterp_1.med",MED_ACC_RDONLY);
00050   if (fid < 0) {
00051     MESSAGE("ERROR : file creation ...");
00052     goto ERROR;
00053   }
00054  
00055   
00056   if (MEDinterpInfoByName(fid,interpname,&geotype,&cellnodes,&nbasisfunc,
00057                           &nvariable,&maxdegree,&nmaxcoefficient) < 0) {
00058     MESSAGE("ERROR : interpolation function information ...");
00059     goto ERROR;
00060   }
00061 
00062   
00063   for ( basisfuncit=1; basisfuncit<= nbasisfunc; ++basisfuncit) {
00064 
00065     if ((ncoefficient = MEDinterpBaseFunctionCoefSize(fid,interpname,basisfuncit) ) <0 ) {
00066       MESSAGE("ERROR : read number of coefficient in the base function ...");
00067       goto ERROR;
00068     }
00069 
00070     coefficient = (med_float*) calloc(sizeof(med_float),ncoefficient);
00071     power       = (med_int*)   calloc(sizeof(med_int),nvariable*ncoefficient);
00072     
00073     if (MEDinterpBaseFunctionRd(fid,interpname,basisfuncit,&ncoefficient,power,coefficient) < 0) {
00074       MESSAGE("ERROR : read base function ...");
00075       free(coefficient); free(power);
00076       goto ERROR;
00077     }
00078 
00079     free(coefficient);
00080     free(power);
00081   }
00082 
00083   ret=0;
00084  ERROR:
00085   
00086   
00087   
00088   if (MEDfileClose(fid) < 0) {
00089     MESSAGE("ERROR : close file ...");             
00090     ret=-1; 
00091   } 
00092   
00093   return ret;
00094 }