INMOST Mathematical Modelling Toolkit
inmost_variable.h
Go to the documentation of this file.
1
2 #ifndef INMOST_AUTODIFF_ETVAR_H_INCLUDED
3 #define INMOST_AUTODIFF_ETVAR_H_INCLUDED
4 #include "inmost_common.h"
5 #include "inmost_expression.h"
6 #include "inmost_mesh.h"
7 #include "inmost_autodiff.h"
8 #include "inmost_solver.h"
9 #include <sstream> //for debug
10 #include <new>
11
12 #if defined(USE_AUTODIFF) && (!defined(USE_MESH) || !defined(USE_SOLVER))
13 #warning "USE_AUTODIFF require USE_MESH"
14 #undef USE_AUTODIFF
15 #endif
16
17
18 //TODO:
19 // 1. Incorporate tables
20 // 2. (ok, test) implement condition
21 // 3. (ok, test) implement stencil
22 // 4. (???) copying of basic_dynamic_variable
23 // 5. Consider optimization by checking zero variation multipliers, check that assembly do not degrade.
24 // 6. Document everything
25
26
27
28 #if defined(USE_AUTODIFF)
29 namespace INMOST
30 {
31
32
33  class enhanced_multivar_expression : public shell_expression<enhanced_multivar_expression>
34  {
35  Automatizator & aut;
37  Sparse::Row entries;
38  public:
39  enhanced_multivar_expression(Automatizator & paut) :aut(paut),value(0) {}
40  enhanced_multivar_expression(const enhanced_multivar_expression & other) : aut(other.aut), value(other.value), entries(other.entries) {}
42  {
43  Sparse::RowMerger & merger = aut.GetMerger();
44  expr.GetDerivative(1.0,merger);
45  merger.RetriveRow(entries);
46  merger.Clear();
47  value = expr.GetValue();
48  }
50  : aut(paut), value(pvalue) {}
52  : aut(paut), value(pvalue), entries(pentries) {}
54  : aut(paut), value(pvalue)
55  {
56  entries.Push(pindex,pdmult);
57  }
59  {
61  if( ptag < AD_CTAG )
62  {
63  value = aut.GetDynamicValue(e,ptag,comp);
66  index = aut.GetDynamicIndex(e,ptag,comp);
67  }
68  else value = aut.GetStaticValue(e,ptag,comp);
69  if( index != ENUMUNDEF) entries.Push(index,1.0);
70  }
71  __INLINE INMOST_DATA_REAL_TYPE GetValue() const { return value; }
73  {
74  for(Sparse::Row::const_iterator it = entries.Begin(); it != entries.End(); ++it)
75  r[it->first] += it->second*mult;
76  }
78  {
79  Sparse::RowMerger & merger = aut.GetMerger();
80  GetDerivative(mult,merger);
82  merger.RetriveRow(r);
83  merger.Clear();
84  }
86  {
87  entries.Clear();
88  value = pvalue;
89  return * this;
90  }
92  {
93  Sparse::RowMerger & merger = aut.GetMerger();
94  expr.GetDerivative(1.0,merger);
95  merger.RetriveRow(entries);
96  merger.Clear();
97  value = expr.GetValue();
98  return * this;
99  }
101  {
102  aut = other.aut;
103  value = other.value;
104  entries = other.entries;
105  return *this;
106  }
107  __INLINE Sparse::Row & GetRow() {return entries;}
108  __INLINE const Sparse::Row & GetRow() const {return entries;}
110  {
111  value += expr.GetValue();
112  Sparse::RowMerger & merger = aut.GetMerger();
113  merger.PushRow(1.0,entries);
114  expr.GetDerivative(1.0,merger);
115  merger.RetriveRow(entries);
116  merger.Clear();
117  return *this;
118  }
120  {
121  value -= expr.GetValue();
122  Sparse::RowMerger & merger = aut.GetMerger();
123  merger.PushRow(1.0,entries);
124  expr.GetDerivative(-1.0,merger);
125  merger.RetriveRow(entries);
126  merger.Clear();
127  return *this;
128  }
130  {
131  INMOST_DATA_REAL_TYPE lval = value, rval = expr.GetValue();
132  Sparse::RowMerger & merger = aut.GetMerger();
133  merger.PushRow(rval,entries);
134  expr.GetDerivative(lval,merger);
135  merger.RetriveRow(entries);
136  merger.Clear();
137  value *= rval;
138  return *this;
139  }
141  {
142  INMOST_DATA_REAL_TYPE lval = value, rval = expr.GetValue();
143  INMOST_DATA_REAL_TYPE reciprocial_rval = 1.0/rval;
144  value *= reciprocial_rval;
145  Sparse::RowMerger & merger = aut.GetMerger();
146  merger.PushRow(reciprocial_rval,entries);
147  expr.GetDerivative(-value*reciprocial_rval,merger);
148  merger.RetriveRow(entries);
149  merger.Clear();
150  return *this;
151  }
153  {
154  value += right;
155  return *this;
156  }
158  {
159  value -= right;
160  return *this;
161  }
163  {
164  value *= right;
165  for(Sparse::Row::iterator it = entries.Begin(); it != entries.End(); ++it) it->second *= right;
166  return *this;
167  }
169  {
170  value /= right;
171  for(Sparse::Row::iterator it = entries.Begin(); it != entries.End(); ++it) it->second /= right;
172  return *this;
173  }
174  bool check_nans() const
175  {
176  if( value != value ) return true;
177  for(Sparse::Row::const_iterator it = entries.Begin(); it != entries.End(); ++it)
178  if( it->second != it->second ) return true;
179  return false;
180  }
181  friend class multivar_expression;
182  operator multivar_expression () {return multivar_expression(value,entries);}
183  };
184
186
187
188  template<typename T> class enhance
189  {
190  public:
191  virtual operator T () = 0;
192  };
193
194  template<> class enhance<INMOST_DATA_REAL_TYPE>
195  {
196  public:
198  enhance(Automatizator & aut) {(void *)&aut;}
199  operator INMOST_DATA_REAL_TYPE () {return 0.0;}
200  };
201
202  template<> class enhance<var_expression>
203  {
204  Automatizator & aut;
205  public:
207  enhance(Automatizator & aut) : aut(aut) {}
209  };
210
211  template<> class enhance<multivar_expression>
212  {
213  Automatizator & aut;
214  public:
216  enhance(Automatizator & aut) : aut(aut) {}
218  };
219
221  {
222  Automatizator & aut;
223  public:
225  enhance(Automatizator & aut) : aut(aut) {}
227  };
228
229  template<class Op, class A>
231  {
232  A arg;
233  Op operand;
234  public:
235  unary_pool(const A & parg) : arg(parg), operand(arg) {}
236  unary_pool(const unary_pool & other) : arg(other.arg), operand(arg) {}
237  unary_pool & operator = (unary_pool const & other) {arg = other.arg; operand = Op(arg);}
238  const shell_expression<A> & get_arg() {return arg;}
239  Op & get_op() {return operand;}
240  const Op & get_op() const {return operand;}
241  };
242
243
244  template<class Op, class A>
246  {
247  A left;
248  INMOST_DATA_REAL_TYPE right;
249  Op operand;
250  public:
251  unary_const_pool(const A & pleft, INMOST_DATA_REAL_TYPE pright) : left(pleft), right(pright), operand(left,right) {}
252  unary_const_pool(const unary_const_pool & other) : left(other.left), right(other.right), operand(left,right) {}
253  unary_const_pool & operator = (unary_const_pool const & other) {left = other.left; right = other.right; operand = Op(left,right);}
254  const shell_expression<A> & get_arg() {return left;}
255  Op & get_op() {return operand;}
256  const Op & get_op() const {return operand;}
257  };
258
259  template<class Op, class A, class B>
261  {
262
263  A left;
264  B right;
265  Op operand;
266  public:
267  binary_pool(const A & pleft, const B & pright) : left(pleft), right(pright), operand(left,right) {}
268  binary_pool(const binary_pool & other) : left(other.left), right(other.right), operand(left,right) {}
269  binary_pool & operator =(binary_pool const & other) {left = other.left; right = other.right; operand = Op(left,right);}
270  const shell_expression<A> & get_left() {return left;}
271  const shell_expression<B> & get_right() {return right;}
272  Op & get_op() {return operand;}
273  const Op & get_op() const {return operand;}
275  };
276
277  template<class Op, class A, class B, class C>
279  {
280  A cond;
281  B left;
282  C right;
283  Op operand;
284  public:
285  ternary_pool(const A & pcond, const B & pleft, const C & pright) : cond(pcond), left(pleft), right(pright), operand(cond,left,right) {}
286  ternary_pool(const ternary_pool & other) : cond(other.cond), left(other.left), right(other.right), operand(cond,left,right) {}
287  ternary_pool & operator =(ternary_pool const & other) {cond = other.cond; left = other.left; right = other.right; operand = Op(cond,left,right);}
288  const shell_expression<A> & get_cond() {return cond;}
289  const shell_expression<B> & get_left() {return left;}
290  const shell_expression<C> & get_right() {return right;}
291  Op & get_op() {return operand;}
292  const Op & get_op() const {return operand;}
294  };
295
296  template<class A, class ArgA>
297  class unary_pool_expression : public shell_expression<unary_pool_expression<A,ArgA> >
298  {
299  unary_pool<A,ArgA> pool;
300  public:
301  unary_pool_expression(const unary_pool<A,ArgA> & ppool) : pool(ppool) {}
302  unary_pool_expression(const unary_pool_expression & other) : pool(other.pool) {}
303  unary_pool_expression & operator = (unary_pool_expression const & other) {pool = other.pool;}
304  __INLINE INMOST_DATA_REAL_TYPE GetValue() const { return pool.get_op().GetValue(); }
305  __INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const {pool.get_op().GetDerivative(mult,r);}
306  __INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const {pool.get_op().GetDerivative(mult,r);}
307  };
308
309  template<class A, class ArgA>
310  class unary_const_pool_expression : public shell_expression<unary_const_pool_expression<A,ArgA> >
311  {
313  public:
315  unary_const_pool_expression(const unary_const_pool_expression & other) : pool(other.pool) {}
317  __INLINE INMOST_DATA_REAL_TYPE GetValue() const { return pool.get_op().GetValue(); }
318  __INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const {pool.get_op().GetDerivative(mult,r);}
319  __INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const {pool.get_op().GetDerivative(mult,r);}
320  };
321
322  template<class A, class ArgA, class ArgB>
323  class binary_pool_expression : public shell_expression<binary_pool_expression<A,ArgA,ArgB> >
324  {
326  public:
327  binary_pool_expression(const binary_pool<A,ArgA,ArgB> & ppool) : pool(ppool) {}
328  binary_pool_expression(const binary_pool_expression & other) : pool(other.pool) {}
329  binary_pool_expression & operator = (binary_pool_expression const & other) {pool = other.pool;}
330  __INLINE INMOST_DATA_REAL_TYPE GetValue() const { return pool.get_op().GetValue(); }
331  __INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const {pool.get_op().GetDerivative(mult,r);}
332  __INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const {pool.get_op().GetDerivative(mult,r);}
333  };
334
335  template<class A, class ArgA, class ArgB, class ArgC>
336  class ternary_pool_expression : public shell_expression<ternary_pool_expression<A,ArgA,ArgB,ArgC> >
337  {
339  public:
341  ternary_pool_expression(const ternary_pool_expression & other) : pool(other.pool) {}
342  ternary_pool_expression & operator = (ternary_pool_expression const & other) {pool = other.pool;}
343  __INLINE INMOST_DATA_REAL_TYPE GetValue() const { return pool.get_op().GetValue(); }
344  __INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger & r) const {pool.get_op().GetDerivative(mult,r);}
345  __INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const {pool.get_op().GetDerivative(mult,r);}
346  };
347
349  {
350  public:
351  virtual INMOST_DATA_REAL_TYPE Value (const Storage & e) const = 0;
352  virtual multivar_expression Variable(const Storage & e) const = 0;
353  virtual enhanced_multivar_expression Variable(Automatizator & aut, const Storage & e) const = 0;
354  virtual void GetVariation(const Storage & e, Sparse::Row & r) const = 0;
355  virtual void GetVariation(const Storage & e, Sparse::RowMerger & r) const = 0;
356  };
357
358  template<typename RetType>
360  {
361  public:
362  virtual RetType operator()(const Storage & e) const = 0;
363  };
364
365  template<>
367  {
368  const abstract_dynamic_variable & var;
369  public:
371  get_variable(const abstract_dynamic_variable & var) : var(var) {}
372  get_variable(Automatizator & aut, const abstract_dynamic_variable & var) : var(var) {}
373  multivar_expression operator()(const Storage & e) const {return var.Variable(e);}
374  };
375
376  template<>
378  {
379  const abstract_dynamic_variable & var;
380  public:
382  get_variable(const abstract_dynamic_variable & var) : var(var) {}
383  get_variable(Automatizator & aut, const abstract_dynamic_variable & var) : var(var) {}
384  INMOST_DATA_REAL_TYPE operator()(const Storage & e) const {return var.Value(e);}
385  };
386
387  template<>
389  {
390  Automatizator & aut;
391  const abstract_dynamic_variable & var;
392  public:
394  get_variable(Automatizator & aut, const abstract_dynamic_variable & var) : aut(aut), var(var) {}
395  enhanced_multivar_expression operator ()(const Storage & e) const {return var.Variable(aut,e);}
396  };
397
398
399
400  template<class VariableType>
402  {
403  public:
404  typedef VariableType Var;
405  virtual INMOST_DATA_REAL_TYPE Value(const Storage & e) const = 0;
406  virtual multivar_expression Variable(const Storage & e) const = 0;
407  virtual enhanced_multivar_expression Variable(Automatizator & aut, const Storage & e) const = 0;
408  virtual VariableType operator[](const Storage & e) const = 0;
409  virtual void GetVariation(const Storage & e, Sparse::Row & r) const = 0;
410  virtual void GetVariation(const Storage & e, Sparse::RowMerger & r) const = 0;
411  };
412
413  template<class VariableType, class Derived>
414  class shell_dynamic_variable : virtual public basic_dynamic_variable<VariableType>
415  {
416  public:
417  typedef VariableType Var;
418  virtual INMOST_DATA_REAL_TYPE Value(const Storage & e) const {return static_cast<const Derived *>(this)->Value(e);}
419  virtual multivar_expression operator ()(const Storage & e) const {return static_cast<const Derived *>(this)->Variable(e);}
420  virtual enhanced_multivar_expression operator ()(Automatizator & aut,const Storage & e) const {return static_cast<const Derived *>(this)->Variable(aut,e);}
421  virtual VariableType operator[](const Storage & e) const {return (*static_cast<const Derived *>(this))[e];}
422  virtual void GetVariation(const Storage & e, Sparse::Row & r) const {static_cast<const Derived *>(this)->GetVariation(e,r);}
423  virtual void GetVariation(const Storage & e, Sparse::RowMerger & r) const {static_cast<const Derived *>(this)->GetVariation(e,r);}
424  };
425
426  class dynamic_variable : public shell_dynamic_variable<var_expression,dynamic_variable>
427  {
428  private:
429  Automatizator & aut;
430  Tag index_tag, value_tag;
433  public:
434  dynamic_variable(Automatizator & paut, INMOST_DATA_ENUM_TYPE pregval, INMOST_DATA_ENUM_TYPE pcomp = 0) : aut(paut), comp(pcomp)
435  {
436  if( pregval != ENUMUNDEF )
437  {
439  if( pregval < AD_CTAG )
440  {
441  value_tag = aut.GetDynamicValueTag(pregval);
442  index_tag = aut.GetDynamicIndexTag(pregval);
443  }
444  else
445  {
446  value_tag = aut.GetStaticValueTag(pregval);
447  index_tag = Tag();
448  }
449  }
450  }
451  dynamic_variable(const dynamic_variable & other) : aut(other.aut), index_tag(other.index_tag), value_tag(other.value_tag), mask(other.mask), comp(other.comp) {}
453  {
454  aut = other.aut;
455  index_tag = other.index_tag;
456  value_tag = other.value_tag;
458  comp = other.comp;
459  }
460  INMOST_DATA_REAL_TYPE Value(const Storage & e) const {return e->Real(value_tag);}
463  {
465  return multivar_expression(e->Real(value_tag),e->Integer(index_tag));
466  else
467  return multivar_expression(e->Real(value_tag));
468  }
470  {
472  return enhanced_multivar_expression(aut,e->Real(value_tag),e->Integer(index_tag));
473  else
474  return enhanced_multivar_expression(aut,e->Real(value_tag));
475  }
476  var_expression operator [](const Storage & e) const {return var_expression(e->Real(value_tag),(!mask || e->GetMarker(mask))?e->Integer(index_tag):ENUMUNDEF);}
477  Tag IndexTag() {return index_tag;}
478  Tag ValueTag() {return value_tag;}
479  void GetVariation(const Storage & e, Sparse::Row & r) const { (*this)[e].GetDerivative(1.0,r); }
480  void GetVariation(const Storage & e, Sparse::RowMerger & r) const { (*this)[e].GetDerivative(1.0,r); }
482  };
483
484  template<class A>
485  class stencil_variable : public shell_dynamic_variable< stencil_expression<typename A::Var>, stencil_variable<A> >
486  {
487  private:
488  Automatizator & aut;
489  INMOST_DATA_ENUM_TYPE stnclind;
490  const A & Arg;
491  void * user_data;
492  public:
493  stencil_variable(Automatizator & paut, INMOST_DATA_ENUM_TYPE pstnclind, const shell_dynamic_variable<typename A::Var,A> & parg, void * puser_data = NULL) : aut(paut), stnclind(pstnclind), Arg(parg), user_data(puser_data) {}
494  stencil_variable(const stencil_variable & other) : aut(other.aut), stnclind(other.stnclind), Arg(other.Arg), user_data(other.user_data) {}
495  stencil_variable & operator =(const stencil_variable & other) {aut = other.aut; stnclind = other.stnclind; Arg = other.Arg; user_data = other.user_data;}
496  INMOST_DATA_REAL_TYPE Value(const Storage & e) const {return (*this)[e].GetValue();}
498  {
499  multivar_expression ret = (*this)[e];
500  return ret;
501  }
503  {
505  ret = (*this)[e];
506  return ret;
507  }
509  {
512  aut.GetStencil(stnclind, e, user_data, stncl);
513  tmp.resize(stncl.size());
514  for(INMOST_DATA_ENUM_TYPE k = 0; k < stncl.size(); ++k)
515  tmp[k] = std::make_pair(stncl[k].first, Arg(stncl[k].second));
517  }
518  void GetVariation(const Storage & e, Sparse::Row & r) const { (*this)[e].GetDerivative(1.0,r); }
519  void GetVariation(const Storage & e, Sparse::RowMerger & r) const { (*this)[e].GetDerivative(1.0,r); }
520  };
521
522  template<class Expr, class A>
523  class unary_custom_variable : public shell_dynamic_variable< unary_pool_expression<Expr, typename A::Var >,unary_custom_variable<Expr,A> >
524  {
525  private:
526  const A & Arg;
527  public:
529  : Arg(parg) {}
530  unary_custom_variable(const unary_custom_variable & other) : Arg(other.Arg) {}
531  unary_custom_variable & operator =(unary_custom_variable const & other) {Arg = other.Arg;}
532  INMOST_DATA_REAL_TYPE Value(const Storage & e) const {return (*this)[e].GetValue();}
534  {
535  multivar_expression ret = (*this)[e];
536  return ret;
537  }
539  {
541  ret = (*this)[e];
542  return ret;
543  }
545  {
548  }
549  void GetVariation(const Storage & e, Sparse::Row & r) const { (*this)[e].GetDerivative(1.0,r); }
550  void GetVariation(const Storage & e, Sparse::RowMerger & r) const { (*this)[e].GetDerivative(1.0,r); }
551  };
552
553
554  template<class Expr, class A, class B>
555  class binary_custom_variable : public shell_dynamic_variable< binary_pool_expression<Expr, typename A::Var, typename B::Var >,binary_custom_variable<Expr,A,B> >
556  {
557  private:
558  const A & Left;
559  const B & Right;
560  public:
562  : Left(pleft), Right(pright) {}
563  binary_custom_variable(const binary_custom_variable & other) : Left(other.Left), Right(other.Right) {}
564  binary_custom_variable & operator =(binary_custom_variable const & other) {Left = other.Left; Right = other.Right;}
565  INMOST_DATA_REAL_TYPE Value(const Storage & e) const {return (*this)[e].GetValue();}
567  {
568  multivar_expression ret = (*this)[e];
569  return ret;
570  }
572  {
574  ret = (*this)[e];
575  return ret;
576  }
578  {
581  }
582  void GetVariation(const Storage & e, Sparse::Row & r) const { (*this)[e].GetDerivative(1.0,r); }
583  void GetVariation(const Storage & e, Sparse::RowMerger & r) const { (*this)[e].GetDerivative(1.0,r); }
584  };
585
586  template<class Expr, class A>
587  class unary_const_custom_variable : public shell_dynamic_variable< unary_const_pool_expression<Expr, typename A::Var >,unary_const_custom_variable<Expr,A> >
588  {
589  private:
590  const A & Left;
591  INMOST_DATA_REAL_TYPE Right;
592  public:
594  : Left(pleft), Right(pright) {}
595  unary_const_custom_variable(const unary_const_custom_variable & other) : Left(other.Left), Right(other.Right) {}
596  unary_const_custom_variable & operator =(unary_const_custom_variable const & other) {Left = other.Left; Right = other.Right;}
597  INMOST_DATA_REAL_TYPE Value(const Storage & e) const {return (*this)[e].GetValue();}
599  {
600  multivar_expression ret = (*this)[e];
601  return ret;
602  }
604  {
606  ret = (*this)[e];
607  return ret;
608  }
610  {
611  unary_const_pool<Expr,typename A::Var> pool(Left(e),Right);
613  }
614  void GetVariation(const Storage & e, Sparse::Row & r) const { (*this)[e].GetDerivative(1.0,r); }
615  void GetVariation(const Storage & e, Sparse::RowMerger & r) const { (*this)[e].GetDerivative(1.0,r); }
616  };
617
618  template<class Expr, class A, class B, class C>
619  class ternary_custom_variable : public shell_dynamic_variable< ternary_pool_expression<Expr, typename A::Var, typename B::Var, typename C::Var >,ternary_custom_variable<Expr,A,B,C> >
620  {
621  private:
622  const A & Cond;
623  const B & Left;
624  const C & Right;
625  public:
627  : Cond(pcond), Left(pleft), Right(pright) {}
628  ternary_custom_variable(const ternary_custom_variable & other) : Left(other.Left), Right(other.Right) {}
629  ternary_custom_variable & operator =(ternary_custom_variable const & other) {Left = other.Left; Right = other.Right;}
630  INMOST_DATA_REAL_TYPE Value(const Storage & e) const {return (*this)[e].GetValue();}
632  {
633  multivar_expression ret = (*this)[e];
634  return ret;
635  }
637  {
639  ret = (*this)[e];
640  return ret;
641  }
643  {
646  }
647  void GetVariation(const Storage & e, Sparse::Row & r) const { (*this)[e].GetDerivative(1.0,r); }
648  void GetVariation(const Storage & e, Sparse::RowMerger & r) const { (*this)[e].GetDerivative(1.0,r); }
649  };
652 }
653
678 template<class A> __INLINE INMOST::stencil_variable<A> stencil(INMOST::Automatizator & aut, INMOST_DATA_ENUM_TYPE stncl, INMOST::shell_dynamic_variable<typename A::Var,A> const & Arg, void * user_data = NULL) { return INMOST::stencil_variable<A>(aut,stncl,Arg,user_data); }
679
680
681
682
683
684 #endif
685 #endif
__INLINE INMOST::expr operator-(const INMOST_DATA_REAL_TYPE &left, const INMOST::expr &right)
enhanced_multivar_expression Variable(Automatizator &aut, const Storage &e) const
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row &r) const
binary_custom_variable(const shell_dynamic_variable< typename A::Var, A > &pleft, const shell_dynamic_variable< typename B::Var, B > &pright)
bool isUnknown(const Storage &e) const
unary_const_custom_variable & operator=(unary_const_custom_variable const &other)
__INLINE INMOST::unary_custom_variable< INMOST::abs_expression< typename A::Var >, A > fabs(INMOST::shell_dynamic_variable< typename A::Var, A > const &Arg)
unary_pool_expression & operator=(unary_pool_expression const &other)
dynamic_variable & operator=(const dynamic_variable &other)
const shell_expression< A > & get_cond()
__INLINE INMOST_DATA_REAL_TYPE GetDynamicValue(const Storage &e, INMOST_DATA_ENUM_TYPE ind, INMOST_DATA_ENUM_TYPE comp=0)
ternary_pool(const A &pcond, const B &pleft, const C &pright)
__INLINE INMOST_DATA_REAL_TYPE GetStaticValue(const Storage &e, INMOST_DATA_ENUM_TYPE ind, INMOST_DATA_ENUM_TYPE comp=0)
virtual multivar_expression Variable(const Storage &e) const =0
enhanced_multivar_expression Variable(Automatizator &aut, const Storage &e) const
var_expression operator[](const Storage &e) const
unary_const_custom_variable(const shell_dynamic_variable< typename A::Var, A > &pleft, INMOST_DATA_REAL_TYPE pright)
__INLINE integer & Integer(const Tag &tag) const
Definition: inmost_mesh.h:3246
enhanced_multivar_expression(Automatizator &paut, INMOST_DATA_REAL_TYPE pvalue)
multivar_expression Variable(const Storage &e) const
abstract_dynamic_variable abstract_variable
__INLINE enhanced_multivar_expression & operator-=(basic_expression const &expr)
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger &r) const
const shell_expression< A > & get_left()
INMOST_DATA_REAL_TYPE Value(const Storage &e) const
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row &r) const
Class to store the sparse matrix row.
Definition: inmost_sparse.h:90
get_variable(Automatizator &aut, const abstract_dynamic_variable &var)
void PushRow(INMOST_DATA_REAL_TYPE coef, Row &r, bool PreSortRow=false)
unary_pool_expression(const unary_pool< A, ArgA > &ppool)
ternary_custom_variable(const shell_dynamic_variable< typename A::Var, A > &pcond, const shell_dynamic_variable< typename B::Var, B > &pleft, const shell_dynamic_variable< typename C::Var, C > &pright)
__INLINE INMOST_DATA_REAL_TYPE GetValue() const
void Clear()
__INLINE INMOST::expr operator+(const INMOST_DATA_REAL_TYPE &left, const INMOST::expr &right)
stencil_variable(Automatizator &paut, INMOST_DATA_ENUM_TYPE pstnclind, const shell_dynamic_variable< typename A::Var, A > &parg, void *puser_data=NULL)
INMOST_DATA_ENUM_TYPE GetStencil(INMOST_DATA_ENUM_TYPE stnclind, const Storage &elem, void *user_data, stencil_pairs &ret)
stencil_variable(const stencil_variable &other)
enhanced_multivar_expression(Automatizator &paut, INMOST_DATA_REAL_TYPE pvalue, const Sparse::Row &pentries)
binary_custom_variable(const binary_custom_variable &other)
INMOST_DATA_REAL_TYPE Value(const Storage &e) const
dynamic_variable(const dynamic_variable &other)
stencil_expression< typename A::Var > operator[](const Storage &e) const
void GetVariation(const Storage &e, Sparse::RowMerger &r) const
unary_pool(const A &parg)
const Op & get_op() const
void resize(size_type n, element c=element())
Definition: container.hpp:1772
multivar_expression Variable(const Storage &e) const
enhanced_multivar_expression(Automatizator &paut, const basic_expression &expr)
unary_const_pool(const unary_const_pool &other)
virtual VariableType operator[](const Storage &e) const =0
#define INMOST_DATA_REAL_TYPE
virtual INMOST_DATA_REAL_TYPE Value(const Storage &e) const =0
__INLINE INMOST::sqrt_expression< A > sqrt(INMOST::shell_expression< A > const &Arg)
INMOST_DATA_REAL_TYPE operator()(const Storage &e) const
get_variable(const abstract_dynamic_variable &var)
virtual void GetVariation(const Storage &e, Sparse::Row &r) const =0
void Clear()
Clear all data of the current row.
multivar_expression operator()(const Storage &e) const
unary_custom_variable(const shell_dynamic_variable< typename A::Var, A > &parg)
enhanced_multivar_expression Variable(Automatizator &aut, const Storage &e) const
__INLINE INMOST::cos_expression< A > cos(INMOST::shell_expression< A > const &Arg)
virtual INMOST_DATA_REAL_TYPE Value(const Storage &e) const =0
enhanced_multivar_expression(Automatizator &paut)
void GetVariation(const Storage &e, Sparse::Row &r) const
unary_pool_expression< Expr, typename A::Var > operator[](const Storage &e) const
__INLINE INMOST_DATA_REAL_TYPE GetValue() const
multivar_expression Variable(const Storage &e) const
multivar_expression Variable(const Storage &e) const
unary_const_pool & operator=(unary_const_pool const &other)
__INLINE INMOST::expr operator/(const INMOST_DATA_REAL_TYPE &left, const INMOST::expr &right)
__INLINE Tag GetDynamicValueTag(INMOST_DATA_ENUM_TYPE ind)
unary_const_pool_expression(const unary_const_pool_expression &other)
virtual void GetVariation(const Storage &e, Sparse::Row &r) const =0
ternary_custom_variable(const ternary_custom_variable &other)
get_variable(Automatizator &aut, const abstract_dynamic_variable &var)
virtual void GetVariation(const Storage &e, Sparse::Row &r) const
enhanced_multivar_expression Variable(Automatizator &aut, const Storage &e) const
__INLINE bool check_nans(INMOST_DATA_REAL_TYPE val)
enhanced_multivar_expression enhanced_variable
__INLINE INMOST::expr stencil(INMOST_DATA_ENUM_TYPE stncl, const INMOST::expr &v)
ternary_pool_expression & operator=(ternary_pool_expression const &other)
INMOST_DATA_REAL_TYPE Value(const Storage &e) const
unary_const_pool(const A &pleft, INMOST_DATA_REAL_TYPE pright)
void GetVariation(const Storage &e, Sparse::RowMerger &r) const
virtual multivar_expression Variable(const Storage &e) const =0
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger &r) const
void GetVariation(const Storage &e, Sparse::RowMerger &r) const
__INLINE enhanced_multivar_expression & operator*=(basic_expression const &expr)
ternary_pool(const ternary_pool &other)
__INLINE enhanced_multivar_expression & operator=(INMOST_DATA_REAL_TYPE pvalue)
Entries::iterator iterator
void Push(INMOST_DATA_ENUM_TYPE ind, INMOST_DATA_REAL_TYPE val)
__INLINE INMOST::sin_expression< A > sin(INMOST::shell_expression< A > const &Arg)
const Op & get_op() const
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger &r) const
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row &r) const
__INLINE const Sparse::Row & GetRow() const
unary_custom_variable & operator=(unary_custom_variable const &other)
binary_pool_expression & operator=(binary_pool_expression const &other)
const Op & get_op() const
virtual INMOST_DATA_REAL_TYPE Value(const Storage &e) const
virtual multivar_expression operator()(const Storage &e) const
__INLINE Tag GetDynamicIndexTag(INMOST_DATA_ENUM_TYPE ind)
Sparse::RowMerger & GetMerger()
__INLINE INMOST_DATA_REAL_TYPE GetValue() const
enhanced_multivar_expression(Automatizator &paut, INMOST_DATA_REAL_TYPE pvalue, INMOST_DATA_ENUM_TYPE pindex, INMOST_DATA_REAL_TYPE pdmult=1.0)
__INLINE size_type size() const
Definition: container.hpp:1780
binary_pool(const binary_pool &other)
unary_const_pool_expression(const unary_const_pool< A, ArgA > &ppool)
ternary_pool_expression< Expr, typename A::Var, typename B::Var, typename C::Var > operator[](const Storage &e) const
binary_pool & operator=(binary_pool const &other)
#define __INLINE
Definition: inmost_common.h:75
binary_pool_expression(const binary_pool< A, ArgA, ArgB > &ppool)
void GetVariation(const Storage &e, Sparse::RowMerger &r) const
ternary_pool_expression(const ternary_pool< A, ArgA, ArgB, ArgC > &ppool)
ternary_custom_variable & operator=(ternary_custom_variable const &other)
__INLINE bool GetMarker(MarkerType n) const
Definition: inmost_mesh.h:3438
binary_pool_expression(const binary_pool_expression &other)
virtual INMOST_DATA_REAL_TYPE GetValue() const =0
enhanced_multivar_expression(Automatizator &paut, const Storage &e, INMOST_DATA_ENUM_TYPE ptag, INMOST_DATA_ENUM_TYPE comp=0)
__INLINE INMOST::log_expression< A > log(INMOST::shell_expression< A > const &Arg)
void GetVariation(const Storage &e, Sparse::Row &r) const
const shell_expression< A > & get_arg()
unary_custom_variable(const unary_custom_variable &other)
unary_pool & operator=(unary_pool const &other)
INMOST_DATA_REAL_TYPE Value(const Storage &e) const
__INLINE INMOST_DATA_REAL_TYPE GetValue() const
enhanced_multivar_expression type
get_variable(const abstract_dynamic_variable &var)
#define ENUMUNDEF
__INLINE INMOST::expr condition(const INMOST::expr &cond, const INMOST::expr &if_gt_zero, const INMOST::expr &if_le_zero)
void GetVariation(const Storage &e, Sparse::Row &r) const
void GetVariation(const Storage &e, Sparse::Row &r) const
ternary_pool & operator=(ternary_pool const &other)
enhanced_multivar_expression type
#define INMOST_DATA_ENUM_TYPE
void GetVariation(const Storage &e, Sparse::Row &r) const
void GetVariation(const Storage &e, Sparse::Row &r) const
dynamic_variable(Automatizator &paut, INMOST_DATA_ENUM_TYPE pregval, INMOST_DATA_ENUM_TYPE pcomp=0)
unary_pool(const unary_pool &other)
void GetVariation(const Storage &e, Sparse::RowMerger &r) const
virtual void GetVariation(const Storage &e, Sparse::RowMerger &r) const
__INLINE INMOST::expr operator*(const INMOST_DATA_REAL_TYPE &left, const INMOST::expr &right)
binary_custom_variable & operator=(binary_custom_variable const &other)
__INLINE enhanced_multivar_expression & operator/=(basic_expression const &expr)
enhanced_multivar_expression(const enhanced_multivar_expression &other)
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row &r) const
__INLINE INMOST::exp_expression< A > exp(INMOST::shell_expression< A > const &Arg)
INMOST_DATA_ENUM_TYPE Index(const Storage &e) const
Entries::const_iterator const_iterator
multivar_expression Variable(const Storage &e) const
virtual VariableType operator[](const Storage &e) const
unary_const_custom_variable(const unary_const_custom_variable &other)
const shell_expression< C > & get_right()
virtual RetType operator()(const Storage &e) const =0
enhanced_multivar_expression Variable(Automatizator &aut, const Storage &e) const
void GetVariation(const Storage &e, Sparse::RowMerger &r) const
const Op & get_op() const
const shell_expression< B > & get_right()
const shell_expression< A > & get_arg()
multivar_expression Variable(const Storage &e) const
__INLINE INMOST::pow_expression< A, B > pow(INMOST::shell_expression< A > const &Left, INMOST::shell_expression< B > const &Right)
void AddRow(INMOST_DATA_REAL_TYPE coef, Row &r, bool PreSortRow=false)
unary_const_pool_expression< Expr, typename A::Var > operator[](const Storage &e) const
INMOST_DATA_REAL_TYPE Value(const Storage &e) const
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger &r) const
__INLINE INMOST_DATA_ENUM_TYPE GetDynamicIndex(const Storage &e, INMOST_DATA_ENUM_TYPE ind, INMOST_DATA_ENUM_TYPE comp=0)
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row &r) const
unary_const_pool_expression & operator=(unary_const_pool_expression const &other)
Definition: inmost_data.h:185
__INLINE INMOST_DATA_REAL_TYPE GetValue() const
get_variable(Automatizator &aut, const abstract_dynamic_variable &var)
__INLINE Tag GetStaticValueTag(INMOST_DATA_ENUM_TYPE ind)
binary_pool_expression< Expr, typename A::Var, typename B::Var > operator[](const Storage &e) const
stencil_variable & operator=(const stencil_variable &other)
INMOST_DATA_REAL_TYPE Value(const Storage &e) const
ternary_pool_expression(const ternary_pool_expression &other)
binary_pool(const A &pleft, const B &pright)
__INLINE real & Real(const Tag &tag) const
Definition: inmost_mesh.h:3242
INMOST_DATA_ENUM_TYPE MarkerType
Low 8 bits - marker mask, rest high bits - position of marker.
Definition: inmost_data.h:62
enhanced_multivar_expression Variable(Automatizator &aut, const Storage &e) const
virtual void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger &r) const =0
const shell_expression< B > & get_left()
__INLINE void GetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::RowMerger &r) const
__INLINE enhanced_multivar_expression & operator+=(basic_expression const &expr)
unary_pool_expression(const unary_pool_expression &other)
__INLINE INMOST::variation_multiplication_expression< A > variation(INMOST::shell_expression< A > const &Arg, INMOST_DATA_REAL_TYPE Mult)