/[ascend]/trunk/models/johnpye/datareader/dr.c
ViewVC logotype

Diff of /trunk/models/johnpye/datareader/dr.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1774 by jpye, Mon May 19 02:52:08 2008 UTC revision 1775 by jpye, Wed May 21 09:51:59 2008 UTC
# Line 30  Line 30 
30  #include <utilities/ascPanic.h>  #include <utilities/ascPanic.h>
31  #include <utilities/ascEnvVar.h>  #include <utilities/ascEnvVar.h>
32    
33    #define DR_DEBUG 0
34    
35  /*------------------------------------------------------------------------------  /*------------------------------------------------------------------------------
36    FORWARD DECLARATIONS    FORWARD DECLARATIONS
37  */  */
# Line 319  int datareader_locate(DataReader *d, dou Line 321  int datareader_locate(DataReader *d, dou
321              (*d->indepfn)(d,t2);              (*d->indepfn)(d,t2);
322          }while(*t2 < t && d->i < d->ndata);          }while(*t2 < t && d->i < d->ndata);
323      }      }
324    #if DR_DEBUG
325      CONSOLE_DEBUG("d->i==%d, t1[0] = %lf, t2[0] = %lf",d->i,t1[0],t2[0]);      CONSOLE_DEBUG("d->i==%d, t1[0] = %lf, t2[0] = %lf",d->i,t1[0],t2[0]);
326    #endif
327    
328      if(d->i == d->ndata || d->i == 0){      if(d->i == d->ndata || d->i == 0){
329          return 1;          return 1;
# Line 348  int datareader_func(DataReader *d, doubl Line 352  int datareader_func(DataReader *d, doubl
352      double t,g,dt;      double t,g,dt;
353      t = inputs[0];      t = inputs[0];
354    
355    #if DR_DEBUG
356      CONSOLE_DEBUG("EVALUATING AT t = %lf",inputs[0]);      CONSOLE_DEBUG("EVALUATING AT t = %lf",inputs[0]);
357    #endif
358    
359      asc_assert(d->indepfn);      asc_assert(d->indepfn);
360    
# Line 357  int datareader_func(DataReader *d, doubl Line 363  int datareader_func(DataReader *d, doubl
363          ERROR_REPORTER_HERE(ASC_USER_ERROR,"Time value t=%f is out of range",t);          ERROR_REPORTER_HERE(ASC_USER_ERROR,"Time value t=%f is out of range",t);
364          return 1;          return 1;
365      }      }
366    
367    #if DR_DEBUG
368      CONSOLE_DEBUG("LOCATED AT t1 = %lf, t2 = %lf",t1[0], t2[0]);      CONSOLE_DEBUG("LOCATED AT t1 = %lf, t2 = %lf",t1[0], t2[0]);
369    #endif
370    
371      (*d->valfn)(d,v2);      (*d->valfn)(d,v2);
372      --d->i;      --d->i;
373      (*d->valfn)(d,v1);      (*d->valfn)(d,v1);
374    
375    #if DR_DEBUG
376      CONSOLE_DEBUG("LOCATED OK, d->i = %d, t1 = %lf, t2 = %lf, v1=%lf, v2=%lf", d->i, t1[0], t2[0],v1[0],v2[0]);      CONSOLE_DEBUG("LOCATED OK, d->i = %d, t1 = %lf, t2 = %lf, v1=%lf, v2=%lf", d->i, t1[0], t2[0],v1[0],v2[0]);
377    #endif
378    
379      for(i=0;i<d->noutputs;++i){      for(i=0;i<d->noutputs;++i){
380          dt = t2[0] - t1[0];          dt = t2[0] - t1[0];
381          g = (v2[i]-v1[i])/dt;          g = (v2[i]-v1[i])/dt;
382          outputs[i]=v1[i]+g*(t-(*t1));          outputs[i]=v1[i]+g*(t-(*t1));
383    #if DR_DEBUG
384          CONSOLE_DEBUG("[%d]: DT = %lf, START = %lf, GRADIENT = %lf, VALUE=%lf",i,dt, v1[i],g,outputs[i]);          CONSOLE_DEBUG("[%d]: DT = %lf, START = %lf, GRADIENT = %lf, VALUE=%lf",i,dt, v1[i],g,outputs[i]);
385    #endif
386      }      }
387    
388      return 0;      return 0;

Legend:
Removed from v.1774  
changed lines
  Added in v.1775

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22