iwinfo.hh

Go to the documentation of this file.
00001 #ifndef __IWAVE_M_TUPLE
00002 #define __IWAVE_M_TUPLE
00003 
00004 #include "std_cpp_includes.hh"
00005 #include "utils.h"
00006 #include "except.hh"
00007 #include "write.hh"
00008 #include "model.h"
00009 
00010 // values for "active" flags
00011 #define ACTIVE_LINEAR 2
00012 #define ACTIVE_NONLINEAR 1
00013 
00018 using RVL::RVLException;
00019 
00020 size_t pow2(int);
00021 
00022 /* max number of data tuples permitted */
00023 #define IWAVEMAXDATA 256
00024 
00025 // forward declaration
00026 class IWaveInfo;
00027 
00056 typedef void (*FD_TIMESTEP)(std::vector<RDOM *> dom, bool fwd, int iv, void* fdpars);
00057 
00087 /*
00088 typedef int (*FD_MODELINIT)(PARARRAY * pars, 
00089                 FILE * stream, 
00090                 grid const & g,
00091                 ireal dt,
00092                 std::vector<std::string> & active,
00093                 void ** specs);
00094 */
00095 typedef int (*FD_MODELINIT)(PARARRAY pars, 
00096                 FILE * stream, 
00097                 IMODEL & model);
00098 
00100 typedef void (*FD_MODELDEST)(void ** specs);
00101 
00102 
00123 typedef int (*FD_TIMEGRID)(PARARRAY * pars, 
00124                FILE * stream, 
00125                grid const & g, 
00126                ireal & dt,
00127                ireal & rhs);
00128 
00159   typedef int (*FD_STENCIL)(void * specs,
00160                 FILE * stream,
00161                 int ndim, 
00162                 IPNT gtype[RDOM_MAX_NARR], 
00163                 STENCIL * sten);
00164 
00179 typedef void (*FD_CHECK)(RDOM * dom,
00180              void * specs,
00181              FILE * stream);
00182 
00192 typedef void (*FD_LOOPDEF)(int const * gmin,
00193                int const * gmax,
00194                float tmax,
00195                int input,
00196                FILE * stream,
00197                void * specs);
00198 
00199 /*
00200   IWAVE field spec struct. Model field structure 
00201   by static array of these. By convention the reference
00202   grid corresponds to the first of these fields.
00203 */
00204 
00205 typedef struct s_field {
00206   std::string field;
00207   int dynamic;
00208   int substep;
00209   IPNT gtype;
00210 } FIELD;
00211 
00212 /* modeling task tuple - pertains only to forward 
00213    model. Couples keywords to rarray indices. Task can define 
00214    input or output, and can be active (coordinates of point in 
00215    operator domain) or passive (auxiliary parameters needed in
00216    simulation 
00217 
00218    i/o harness for simulation spec'd via a static array of these.
00219    by convention the first element should give the input connection
00220    for the first model field, and provides the keyword for looking
00221    up the external data source for the primary model grid.
00222 
00223    BIG CHANGE spring 16: input and active are ints, not bools. Value
00224    of 0 for active signifies inactive (ie. not part of domain space of
00225    op). Input=1 and active = 2 signifies linear input (source), which
00226    is treated as outout for adjoint with deriv=0 - in that case active
00227    outputs turn into input.
00228 */
00229 typedef struct s_iokeys {
00230   std::string keyword;
00231   int rarrindex;
00232   int input;
00233   int active;
00234 } IOKEY;
00235 
00238 class IWaveInfo {
00239 public:
00243   static std::string iwave_model;
00244   static FIELD iwave_fields[]; 
00245   static IOKEY iwave_iokeys[];
00246   static FD_MODELINIT minit;
00247   static FD_MODELDEST mdest;
00248   static FD_TIMESTEP timestep;
00249   static FD_TIMEGRID timegrid;
00250   static FD_STENCIL createstencil;
00251   static FD_CHECK check;
00252   static FD_LOOPDEF loopdef;
00253   
00254   // these are redundant relic of previous design, but don't want to chase
00255   // them down right now - 05.01.14
00256   std::string get_iwave_model() const { return this->iwave_model; }
00257   IOKEY * get_iwave_iokeys() const { return &(this->iwave_iokeys[0]); }
00258   FIELD * get_iwave_fields() const { return &(this->iwave_fields[0]); }
00259   FD_MODELINIT get_minit() const { return this->minit; }
00260   FD_MODELDEST get_mdest() const { return this->mdest; }
00261   FD_TIMEGRID get_timegrid() const { return this->timegrid; }
00262   FD_TIMESTEP get_timestep() const { return this->timestep; }
00263   FD_STENCIL get_stencil() const { return this->createstencil;}
00264   FD_CHECK get_check() const { return this->check; }
00265   FD_LOOPDEF get_loopdef() const { return this->loopdef; }
00266   // defined
00267   int get_num_fields() const;
00268   int get_num_iokeys() const;
00269   // legit return values are non-negative - negative return
00270   // indicates that this keyword is not amongst the basic i/o
00271   // keywords
00272   int get_property_iokeys(const std::string keyword,
00273               const std::string property) const;
00274   
00275   ostream & write_iwave_fields(ostream & str) const;
00276   ostream & write_iwave_iokeys(ostream & str) const;
00277 };
00278 
00279 namespace TSOpt {
00280 
00281   using RVL::RVLException;
00282   using RVL::Writeable;
00283 
00284   /* task component: defines relation between IWAVEs in
00285      IWaveTreeState, keywords indexing i/o info (filenames), input
00286      flags, and indices of rarrays in the simulation RDOM.
00287    */
00288   typedef struct s_task_reln {
00289     int iwaveindex;   
00290     std::string keyword;
00291     int rarrindex;
00292     bool input;
00293   } TASK_RELN;
00294 
00295   /* generates list of task relations defining i/o patterns for
00296      derivatives of a model. IO represented by a IODefn
00297      object. Algorithm: for order i, loops over 2^i copies of IO.
00298      In all cases, passive relations unaltered from basic model - all
00299      belong in order 0 branch. Forward mode: active inputs in comp 0
00300      (reference model), 1, 2, 4,...,2^{i-1}, with same access pattern
00301      as basic model. Keyword in comp 2^k altered by addition of suffix
00302      _d{k}. Active outputs in comp 2^{i}-1. Adjoint mode: inputs same
00303      except for comp 2^{i-1}, which becomes output with keyword suffix
00304      _b{i-1}. All forward ouputs in comp 2^{i-1} become inputs.
00305   */
00306     
00307   void IOTask(std::vector<TASK_RELN *> & tr, int order, bool fwd, IWaveInfo const & ic);
00308 
00309   void IOTaskWriter(std::vector<TASK_RELN *> const & tr, ostream & str);
00310 
00311 }
00312 
00313 #endif

Generated on 5 Jan 2017 for IWAVECORE by  doxygen 1.4.7