INMOST
A toolkit for distributed mathematical modeling
inmost_autodiff.h
1 
2 #ifndef INMOST_AUTODIFF_H_INCLUDED
3 #define INMOST_AUTODIFF_H_INCLUDED
4 
5 #include "inmost_common.h"
6 #include "inmost_mesh.h"
7 
8 #if defined(USE_AUTODIFF) && defined(USE_MESH)
9 
10 namespace INMOST
11 {
12  class Automatizator; //forward declaration
13 
14  //return specific type with specific template
15  template<class T> struct Demote;
16  template<> struct Demote<INMOST_DATA_INTEGER_TYPE> {typedef INMOST_DATA_INTEGER_TYPE type;};
17  template<> struct Demote<INMOST_DATA_REAL_TYPE> {typedef INMOST_DATA_REAL_TYPE type;};
18  template<> struct Demote<unknown> {typedef unknown type;};
19  template<> struct Demote<variable> {typedef unknown type;};
20  template<> struct Demote<hessian_variable> {typedef unknown type;};
21 
30  {
31  INMOST_DATA_ENUM_TYPE reg_index;
32  TagInteger offset_tag;
33  MarkerType mask;
34  bool inverse_mask;
35  ElementType etype;
36  public:
37  AbstractEntry(ElementType etype = NONE, MarkerType mask = 0, bool inverse = false)
38  : reg_index(ENUMUNDEF), offset_tag(Tag()), mask(mask), inverse_mask(inverse), etype(etype) {}
40  MarkerType GetMask() const {return mask;}
42  bool GetMaskInverse() const {return inverse_mask;}
44  void SetMask(MarkerType _mask, bool inverse = false) {mask = _mask; inverse_mask = inverse;}
46  ElementType GetElementType() const {return etype;}
48  void SetElementType(ElementType _etype) {etype = _etype;}
50  TagInteger GetOffsetTag() const {return offset_tag;}
52  void SetOffsetTag(TagInteger tag) {offset_tag = tag;}
54  bool isValid(const Storage & e) const {return reg_index != ENUMUNDEF && offset_tag.isDefined(e.GetElementType()) && (e.GetElementType() & etype) && (mask == 0 || (e->GetMarker(mask) ^ inverse_mask));}
57  virtual INMOST_DATA_REAL_TYPE Value(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const = 0;
60  virtual INMOST_DATA_REAL_TYPE & Value(const Storage & e, INMOST_DATA_ENUM_TYPE pos) = 0;
64  virtual INMOST_DATA_ENUM_TYPE Index(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const = 0;
67  virtual unknown Unknown(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const = 0;
69  virtual Matrix<value_reference> Value(const Storage& e) = 0;
71  virtual rMatrix Value(const Storage & e) const = 0;
73  virtual iMatrix Index(const Storage & e) const = 0;
75  virtual uMatrix Unknown(const Storage & e) const = 0;
78  template<typename T>
80  Access(const Storage &e) const;
84  template<typename T>
85  typename Demote<T>::type
86  Access(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const;
88  virtual uMatrix operator [](const Storage & e) const = 0;
90  virtual INMOST_DATA_ENUM_TYPE MatrixSize(const Storage & e) const = 0;
92  virtual INMOST_DATA_ENUM_TYPE Size() const = 0;
98  virtual INMOST_DATA_ENUM_TYPE Size(const Storage & e) const = 0;
100  virtual INMOST_DATA_ENUM_TYPE GetValueComp(INMOST_DATA_ENUM_TYPE unk) const = 0;
102  virtual TagRealArray GetValueTag(INMOST_DATA_ENUM_TYPE unk) const = 0;
104  virtual Mesh * GetMeshLink() const = 0;
106  virtual AbstractEntry * Copy() const = 0;
108  INMOST_DATA_ENUM_TYPE GetRegistrationIndex() const {return reg_index;}
113  virtual ~AbstractEntry() {}
114 
115  friend class Automatizator; //provide registration index from inside of Automatizator
116  friend class Model; //provide registration index from inside of Model
117  };
118 
119 
120 
123  class BlockEntry : public AbstractEntry
124  {
125  std::vector<TagRealArray> unknown_tags;
126  std::vector<INMOST_DATA_ENUM_TYPE> unknown_comp;
127  public:
129  BlockEntry(ElementType etype = NONE, MarkerType mask = 0, bool inverse = false) : AbstractEntry(etype,mask,inverse) {}
131  void ClearTags() { unknown_tags.clear(); unknown_comp.clear(); }
135  void AddTag(Tag value, INMOST_DATA_ENUM_TYPE comp = ENUMUNDEF);
137  INMOST_DATA_REAL_TYPE Value(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {return unknown_tags[pos][e][unknown_comp[pos]];}
139  INMOST_DATA_REAL_TYPE & Value(const Storage & e, INMOST_DATA_ENUM_TYPE pos) {return unknown_tags[pos][e][unknown_comp[pos]];}
141  INMOST_DATA_ENUM_TYPE Index(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {return isValid(e) ? GetOffsetTag()[e]+pos : ENUMUNDEF;}
143  unknown Unknown(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {return unknown(Value(e,pos),Index(e,pos));}
145  rMatrix Value(const Storage& e) const { rMatrix ret(MatrixSize(e), 1); for (unsigned k = 0; k < Size(); ++k) ret(k, 0) = Value(e, k); return ret; }
147  Matrix<value_reference> Value(const Storage & e) {Matrix<value_reference> ret(MatrixSize(e),1); for(unsigned k = 0; k < Size(); ++k) new (&ret(k,0)) value_reference(Value(e,k)); return ret; }
149  iMatrix Index(const Storage & e) const {iMatrix ret(MatrixSize(e),1); for(unsigned k = 0; k < Size(); ++k) ret(k,0) = Index(e,k); return ret; }
151  uMatrix Unknown(const Storage & e) const {return BlockEntry::operator [](e);}
153  uMatrix operator [](const Storage & e) const {uMatrix ret(MatrixSize(e),1); for(unsigned k = 0; k < Size(); ++k) ret(k,0) = Unknown(e,k); return ret; }
155  INMOST_DATA_ENUM_TYPE MatrixSize(const Storage & e) const {(void)e; return Size();}
157  INMOST_DATA_ENUM_TYPE Size() const {return (INMOST_DATA_ENUM_TYPE)unknown_tags.size();}
159  INMOST_DATA_ENUM_TYPE Size(const Storage & e) const
160  {
161  INMOST_DATA_ENUM_TYPE ret = 0;
162  for(unsigned k = 0; k < unknown_tags.size(); ++k)
163  if( e.HaveData(unknown_tags[k]) ) ret++;
164  return ret;
165  }
167  INMOST_DATA_ENUM_TYPE GetValueComp(INMOST_DATA_ENUM_TYPE unk) const {return unknown_comp[unk];}
169  TagRealArray GetValueTag(INMOST_DATA_ENUM_TYPE unk) const {return unknown_tags[unk];}
171  Mesh * GetMeshLink() const {return unknown_tags.back().GetMeshLink();}
173  AbstractEntry * Copy() const {BlockEntry * ret = new BlockEntry(GetElementType(),GetMask(),GetMaskInverse()); for(unsigned k = 0; k < Size(); ++k) ret->AddTag(unknown_tags[k],unknown_comp[k]); return ret; }
174  };
176  class SingleEntry : public AbstractEntry
177  {
178  TagRealArray unknown_tag;
179  INMOST_DATA_ENUM_TYPE unknown_comp;
180  public:
182  SingleEntry(ElementType etype = NONE, MarkerType mask = 0, bool inverse = false) : AbstractEntry(etype, mask, inverse) { unknown_comp = 0; }
184  SingleEntry(ElementType etype, MarkerType mask, bool inverse, Tag unknown_tag, INMOST_DATA_ENUM_TYPE unknown_comp = 0) : AbstractEntry(etype,mask,inverse), unknown_tag(unknown_tag), unknown_comp(unknown_comp) {}
186  void SetTag(Tag unknown_tag_in, INMOST_DATA_ENUM_TYPE unknown_comp_in = 0) {unknown_tag = unknown_tag_in; unknown_comp = unknown_comp_in;}
188  INMOST_DATA_REAL_TYPE Value(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {(void)pos; assert(pos==0); return unknown_tag[e][unknown_comp];}
190  INMOST_DATA_REAL_TYPE & Value(const Storage & e, INMOST_DATA_ENUM_TYPE pos) {(void)pos; assert(pos==0); return unknown_tag[e][unknown_comp];}
192  INMOST_DATA_ENUM_TYPE Index(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {(void)pos; assert(pos==0); return isValid(e) ? GetOffsetTag()[e] : ENUMUNDEF;}
194  unknown Unknown(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {assert(pos==0); return unknown(Value(e,pos),Index(e,pos));}
196  Matrix<value_reference> Value(const Storage& e) { Matrix<value_reference> ret(1, 1); new (&ret(0, 0)) value_reference(Value(e, 0)); return ret; }
198  rMatrix Value(const Storage & e) const { rMatrix ret(1,1); ret(0,0) = Value(e,0); return ret; }
200  iMatrix Index(const Storage & e) const { iMatrix ret(1,1); ret(0,0) = Index(e,0); return ret; }
202  uMatrix Unknown(const Storage & e) const {return SingleEntry::operator [](e);}
204  uMatrix operator [](const Storage & e) const { uMatrix ret(1,1); ret(0,0) = Unknown(e,0); return ret; }
206  INMOST_DATA_ENUM_TYPE MatrixSize(const Storage & e) const {(void)e; return 1;}
208  INMOST_DATA_ENUM_TYPE Size() const {return 1;}
210  INMOST_DATA_ENUM_TYPE Size(const Storage & e) const {(void)e; return e.HaveData(unknown_tag) ? 1 : 0;}
212  INMOST_DATA_ENUM_TYPE GetValueComp(INMOST_DATA_ENUM_TYPE unk) const {(void)unk; assert(unk == 0); return unknown_comp;}
214  TagRealArray GetValueTag(INMOST_DATA_ENUM_TYPE unk) const {(void)unk; assert(unk == 0); return unknown_tag;}
216  Mesh * GetMeshLink() const {return unknown_tag.GetMeshLink();}
218  AbstractEntry * Copy() const {return new SingleEntry(GetElementType(),GetMask(),GetMaskInverse(),unknown_tag,unknown_comp);}
219  };
221  class VectorEntry : public AbstractEntry
222  {
223  TagRealArray unknown_tag;
224  public:
226  VectorEntry(ElementType etype = NONE, MarkerType mask = 0, bool inverse = false) : AbstractEntry(etype,mask,inverse) {}
228  VectorEntry(ElementType etype, MarkerType mask, bool inverse, Tag unknown_tag) : AbstractEntry(etype,mask,inverse), unknown_tag(unknown_tag) {}
230  void SetTag(Tag unknown_tag_in) {unknown_tag = unknown_tag_in;}
232  INMOST_DATA_REAL_TYPE Value(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {assert(pos<unknown_tag[e].size()); return unknown_tag[e][pos];}
234  INMOST_DATA_REAL_TYPE & Value(const Storage & e, INMOST_DATA_ENUM_TYPE pos) {assert(pos<unknown_tag[e].size()); return unknown_tag[e][pos];}
236  INMOST_DATA_ENUM_TYPE Index(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {assert(pos<unknown_tag[e].size()); return isValid(e) ? GetOffsetTag()[e]+pos : ENUMUNDEF;}
238  unknown Unknown(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {assert(pos<unknown_tag[e].size()); return unknown(Value(e,pos),Index(e,pos));}
240  Matrix<value_reference> Value(const Storage& e) { Matrix<value_reference> ret(MatrixSize(e), 1); for (int k = 0; k < (int)unknown_tag[e].size(); ++k) new (&ret(k, 0)) value_reference(Value(e, k)); return ret; }
242  rMatrix Value(const Storage & e) const { rMatrix ret(MatrixSize(e),1); for(int k = 0; k < (int)unknown_tag[e].size(); ++k) ret(k,0) = Value(e,k); return ret; }
244  iMatrix Index(const Storage & e) const { iMatrix ret(MatrixSize(e),1); for(int k = 0; k < (int)unknown_tag[e].size(); ++k) ret(k,0) = Index(e,k); return ret; }
246  uMatrix Unknown(const Storage & e) const {return VectorEntry::operator [](e);}
248  uMatrix operator [](const Storage & e) const { uMatrix ret(MatrixSize(e),1); for(int k = 0; k < (int)unknown_tag[e].size(); ++k) ret(k,0) = Unknown(e,k); return ret; }
250  INMOST_DATA_ENUM_TYPE MatrixSize(const Storage & e) const {return (INMOST_DATA_ENUM_TYPE)unknown_tag[e].size();}
252  INMOST_DATA_ENUM_TYPE Size() const {return 1;}
254  INMOST_DATA_ENUM_TYPE Size(const Storage & e) const {return e.HaveData(unknown_tag) ? (INMOST_DATA_ENUM_TYPE)unknown_tag[e].size() : 0;}
256  INMOST_DATA_ENUM_TYPE GetValueComp(INMOST_DATA_ENUM_TYPE unk) const {(void)unk; assert(unk==0); return ENUMUNDEF;}
258  TagRealArray GetValueTag(INMOST_DATA_ENUM_TYPE unk) const {(void)unk; assert(unk==0); return unknown_tag;}
260  Mesh * GetMeshLink() const {return unknown_tag.GetMeshLink();}
262  AbstractEntry * Copy() const {return new VectorEntry(GetElementType(),GetMask(),GetMaskInverse(),unknown_tag);}
263  };
269  {
270  std::vector<TagRealArray> unknown_tags;
271  std::vector<INMOST_DATA_ENUM_TYPE> unknown_comp;
272  TagInteger status_tag;
273  std::vector< std::vector<bool> > status_tbl;
274  public:
276  StatusBlockEntry(ElementType etype = NONE, MarkerType mask = 0, bool inverse = false) : AbstractEntry(etype,mask,inverse), status_tag(Tag()) {}
278  StatusBlockEntry(ElementType etype, MarkerType mask, bool inverse, TagInteger status_tag) : AbstractEntry(etype,mask,inverse), status_tag(status_tag) {}
280  StatusBlockEntry(ElementType etype, MarkerType mask, bool inverse, TagInteger status_tag, const std::vector< std::vector<bool> > & status_tbl) : AbstractEntry(etype,mask,inverse), status_tag(status_tag), status_tbl(status_tbl) {}
282  void ClearTags() { unknown_tags.clear(); unknown_comp.clear(); }
286  void AddTag(Tag value, INMOST_DATA_ENUM_TYPE comp = ENUMUNDEF);
288  void AddStatus(const std::vector<bool> & stat) {status_tbl.push_back(stat);}
290  void SetStatusTag(TagInteger input) {status_tag = input;}
292  INMOST_DATA_REAL_TYPE Value(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {return unknown_tags[pos][e][unknown_comp[pos]];}
294  INMOST_DATA_REAL_TYPE & Value(const Storage & e, INMOST_DATA_ENUM_TYPE pos) {return unknown_tags[pos][e][unknown_comp[pos]];}
296  INMOST_DATA_ENUM_TYPE Index(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {return isValid(e) && status_tbl[status_tag[e]][pos] ? GetOffsetTag()[e]+pos : ENUMUNDEF;}
298  unknown Unknown(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {return unknown(Value(e,pos),Index(e,pos));}
300  Matrix<value_reference> Value(const Storage& e) { Matrix<value_reference> ret(MatrixSize(e), 1); for (INMOST_DATA_ENUM_TYPE k = 0; k < Size(); ++k) new (&ret(k, 0)) value_reference(Value(e, k)); return ret; }
302  rMatrix Value(const Storage & e) const {rMatrix ret(MatrixSize(e),1); for(INMOST_DATA_ENUM_TYPE k = 0; k < Size(); ++k) ret(k,0) = Value(e,k); return ret; }
304  iMatrix Index(const Storage & e) const {iMatrix ret(MatrixSize(e),1); for(INMOST_DATA_ENUM_TYPE k = 0; k < Size(); ++k) ret(k,0) = Index(e,k); return ret; }
306  uMatrix Unknown(const Storage & e) const {return StatusBlockEntry::operator [](e);}
308  uMatrix operator [](const Storage & e) const {uMatrix ret(MatrixSize(e),1); for(INMOST_DATA_ENUM_TYPE k = 0; k < Size(); ++k) ret(k,0) = Unknown(e,k); return ret; }
310  INMOST_DATA_ENUM_TYPE MatrixSize(const Storage & e) const {(void)e; return Size();}
312  INMOST_DATA_ENUM_TYPE Size() const {return (INMOST_DATA_ENUM_TYPE)unknown_tags.size();}
314  INMOST_DATA_ENUM_TYPE Size(const Storage & e) const;
316  INMOST_DATA_ENUM_TYPE GetValueComp(INMOST_DATA_ENUM_TYPE unk) const {return unknown_comp[unk];}
318  TagRealArray GetValueTag(INMOST_DATA_ENUM_TYPE unk) const {return unknown_tags[unk];}
320  Mesh * GetMeshLink() const {return unknown_tags.back().GetMeshLink();}
322  AbstractEntry * Copy() const;
323  };
330  class MultiEntry : public AbstractEntry
331  {
332  std::vector<AbstractEntry *> entries;
333  public:
335  MultiEntry(ElementType etype = NONE, MarkerType mask = 0, bool inverse = false) : AbstractEntry(etype,mask,inverse) {}
337  ~MultiEntry() {for(unsigned k = 0; k < entries.size(); ++k) delete entries[k];}
339  void AddEntry(const AbstractEntry & entry);
341  AbstractEntry & GetEntry(INMOST_DATA_ENUM_TYPE k) {return *entries[k];}
343  const AbstractEntry & GetEntry(INMOST_DATA_ENUM_TYPE k) const {return *entries[k];}
345  INMOST_DATA_ENUM_TYPE NumEntries() const {return (INMOST_DATA_ENUM_TYPE)entries.size();}
347  INMOST_DATA_REAL_TYPE Value(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const;
349  INMOST_DATA_REAL_TYPE & Value(const Storage & e, INMOST_DATA_ENUM_TYPE pos);
351  INMOST_DATA_ENUM_TYPE Index(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const;
353  unknown Unknown(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const;
357  rMatrix Value(const Storage & e) const;
359  iMatrix Index(const Storage & e) const;
361  uMatrix Unknown(const Storage & e) const {return MultiEntry::operator [](e);}
363  uMatrix operator [](const Storage & e) const;
365  INMOST_DATA_ENUM_TYPE MatrixSize(const Storage & e) const;
367  INMOST_DATA_ENUM_TYPE Size() const {INMOST_DATA_ENUM_TYPE ret = 0; for(unsigned k = 0; k < entries.size(); ++k) ret += entries[k]->Size(); return ret;}
369  INMOST_DATA_ENUM_TYPE Size(const Storage & e) const {INMOST_DATA_ENUM_TYPE ret = 0; for(unsigned k = 0; k < entries.size(); ++k) ret += entries[k]->Size(e); return ret;}
371  INMOST_DATA_ENUM_TYPE GetValueComp(INMOST_DATA_ENUM_TYPE unk) const;
373  TagRealArray GetValueTag(INMOST_DATA_ENUM_TYPE unk) const;
375  Mesh * GetMeshLink() const {assert(!entries.empty()); return entries.back()->GetMeshLink();}
377  AbstractEntry * Copy() const;
378  };
392  {
393  private:
394  typedef std::vector<AbstractEntry *> blk_enum;
395  typedef std::vector<INMOST_DATA_ENUM_TYPE> del_enum;
396  typedef std::vector<bool> act_enum;
397  private:
398  std::string name;
399  del_enum del_blocks;
400  blk_enum reg_blocks;
401  act_enum act_blocks;
402  INMOST_DATA_ENUM_TYPE first_num;
403  INMOST_DATA_ENUM_TYPE last_num;
404  public:
416  Automatizator(std::string name = "");
421  __INLINE INMOST_DATA_ENUM_TYPE GetFirstIndex() const { return first_num; }
423  __INLINE INMOST_DATA_ENUM_TYPE GetLastIndex() const { return last_num; }
431  INMOST_DATA_ENUM_TYPE RegisterTag(Tag t, ElementType typemask, MarkerType domain_mask = 0, bool inverse = false);
437  INMOST_DATA_ENUM_TYPE RegisterEntry(const AbstractEntry & e);
438  INMOST_DATA_ENUM_TYPE RegisterEntry(AbstractEntry & e);
443  void UnregisterEntry(INMOST_DATA_ENUM_TYPE ind);
448  void DeactivateEntry(INMOST_DATA_ENUM_TYPE ind);
453  void ActivateEntry(INMOST_DATA_ENUM_TYPE ind);
455  void EnumerateEntries(bool blocks = false);
458  __INLINE bool isRegisteredEntry(INMOST_DATA_ENUM_TYPE ind) const {return reg_blocks[ind] != NULL;}
460  INMOST_DATA_ENUM_TYPE GetIndex(const Storage & e, INMOST_DATA_ENUM_TYPE reg_index, INMOST_DATA_ENUM_TYPE pos = 0) const {return GetEntry(reg_index).Index(e,pos);}
462  INMOST_DATA_REAL_TYPE GetValue(const Storage & e, INMOST_DATA_ENUM_TYPE reg_index, INMOST_DATA_ENUM_TYPE pos = 0) const {return GetEntry(reg_index).Value(e,pos);}
464  unknown GetUnknown(const Storage & e, INMOST_DATA_ENUM_TYPE reg_index, INMOST_DATA_ENUM_TYPE pos = 0) const {return GetEntry(reg_index).Unknown(e,pos);}
466  AbstractEntry & GetEntry(INMOST_DATA_ENUM_TYPE ind) {return *reg_blocks[ind];}
468  const AbstractEntry & GetEntry(INMOST_DATA_ENUM_TYPE ind) const {return *reg_blocks[ind];}
471  std::vector<INMOST_DATA_ENUM_TYPE> ListRegisteredEntries() const;
475  };
476 } //namespace INMOST
477 
478 #endif //USE_AUTODIFF && USE_MESH
479 
480 #endif //INMOST_AUTODIFF_H_INCLUDED
This class is used to organize unknowns in abstract way, it should be registered with and managed by ...
virtual uMatrix Unknown(const Storage &e) const =0
Return vector filled with unknowns of the block with their derivatives.
virtual Mesh * GetMeshLink() const =0
Retrieve mesh pointer.
virtual unknown Unknown(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const =0
Return unknown in vector of variables of the block at certain position.
void SetMask(MarkerType _mask, bool inverse=false)
Set mask for the block.
INMOST_DATA_ENUM_TYPE GetRegistrationIndex() const
Retrieve a registration index.
virtual INMOST_DATA_REAL_TYPE Value(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const =0
Return value in vector of unknowns of the block at certain position.
virtual INMOST_DATA_ENUM_TYPE Size(const Storage &e) const =0
Total number of entries that this block expands to on given element, count variable-sized entries.
virtual INMOST_DATA_ENUM_TYPE MatrixSize(const Storage &e) const =0
The intended size of the matrix for this entry.
virtual ~AbstractEntry()
Destructor.
virtual AbstractEntry * Copy() const =0
Make a copy of the object.
ElementType GetElementType() const
Retrieve element type of the block.
virtual iMatrix Index(const Storage &e) const =0
Return vector filled with indices of unknowns of the block.
void SetOffsetTag(TagInteger tag)
Retrieve tag that stores enumeration offset on each element.
Matrix< typename Demote< T >::type > Access(const Storage &e) const
Return vector filled with either values or indices or unknowns of the block, depending on the templat...
virtual INMOST_DATA_ENUM_TYPE GetValueComp(INMOST_DATA_ENUM_TYPE unk) const =0
Retrieve component of the tag related to unknown.
bool isValid(const Storage &e) const
Check that the block is valid on given element.
void SynchronizeData()
Update variables contained in block on ghost elements of the grid.
virtual Matrix< value_reference > Value(const Storage &e)=0
Return vector filled with references to values of unknowns of the block.
TagInteger GetOffsetTag() const
Retrieve tag that stores enumeration offset on each element.
virtual TagRealArray GetValueTag(INMOST_DATA_ENUM_TYPE unk) const =0
Retrieve tag related to unknown value.
virtual INMOST_DATA_REAL_TYPE & Value(const Storage &e, INMOST_DATA_ENUM_TYPE pos)=0
Return value in vector of unknowns of the block at certain position.
void SetElementType(ElementType _etype)
Set element type for the block.
virtual uMatrix operator[](const Storage &e) const =0
Return vector filled with unknowns of the block with their derivatives.
virtual rMatrix Value(const Storage &e) const =0
Return vector filled with values of unknowns of the block.
virtual INMOST_DATA_ENUM_TYPE Size() const =0
Number of tags in block.
Demote< T >::type Access(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return either value or index or unknown at specified position of the block, depending on the template...
MarkerType GetMask() const
Retrieve mask of the block.
bool GetMaskInverse() const
Retrieve if the mask is inverted.
virtual INMOST_DATA_ENUM_TYPE Index(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const =0
Return index in vector of indices of the block at certain position.
The Automatizator class helps in defining primary unknowns of the model and enhances user experience ...
AbstractEntry & GetEntry(INMOST_DATA_ENUM_TYPE ind)
Retrieve the block from automatizator by index.
Automatizator(const Automatizator &b)
Make a copy.
void EnumerateEntries(bool blocks=false)
Set index for every data entry of dynamic tag.
__INLINE bool isRegisteredEntry(INMOST_DATA_ENUM_TYPE ind) const
Check whether the tag is still registered.
void DeactivateEntry(INMOST_DATA_ENUM_TYPE ind)
Swith a registered tag to be non-active, in this case it's unknowns are considered to be constant.
void ActivateEntry(INMOST_DATA_ENUM_TYPE ind)
Swith a registered tag to be active, in this case it's unknowns are considered to be variable.
__INLINE INMOST_DATA_ENUM_TYPE GetFirstIndex() const
Retrieve first index of unknowns, local to the processor.
INMOST_DATA_ENUM_TYPE RegisterEntry(const AbstractEntry &e)
Register block with the automatizator.
__INLINE INMOST_DATA_ENUM_TYPE GetLastIndex() const
Retrieve last index of unknowns, local to the processor.
INMOST_DATA_ENUM_TYPE GetIndex(const Storage &e, INMOST_DATA_ENUM_TYPE reg_index, INMOST_DATA_ENUM_TYPE pos=0) const
Get index of the unknown associated with the entry on element.
void SynchronizeData()
Update variables contained in all block of automatizator on ghost elements of the grid.
void UnregisterEntry(INMOST_DATA_ENUM_TYPE ind)
Erase a registered tag.
INMOST_DATA_REAL_TYPE GetValue(const Storage &e, INMOST_DATA_ENUM_TYPE reg_index, INMOST_DATA_ENUM_TYPE pos=0) const
Get value of the unknown associated with the entry on element.
~Automatizator()
Destructor for the automatizator, deletes all the tags corresponding to indices from respective meshe...
Automatizator & operator=(Automatizator const &b)
Performs assignment.
unknown GetUnknown(const Storage &e, INMOST_DATA_ENUM_TYPE reg_index, INMOST_DATA_ENUM_TYPE pos=0) const
Get unknown associated with the entry on element.
const AbstractEntry & GetEntry(INMOST_DATA_ENUM_TYPE ind) const
Retrieve the block from automatizator by index.
std::vector< INMOST_DATA_ENUM_TYPE > ListRegisteredEntries() const
Lists all the indices of registered tags.
Automatizator(std::string name="")
Makes an empty Automatizator.
INMOST_DATA_ENUM_TYPE RegisterTag(Tag t, ElementType typemask, MarkerType domain_mask=0, bool inverse=false)
Set data of tag t defined on domain_mask to be dynamic data.
This class is used to organize unknowns into blocks, blocks enumeration are managed by class Automati...
uMatrix operator[](const Storage &e) const
Return vector filled with unknowns of the block with their derivatives.
rMatrix Value(const Storage &e) const
Return vector filled with values of unknowns of the block.
INMOST_DATA_ENUM_TYPE GetValueComp(INMOST_DATA_ENUM_TYPE unk) const
Retrieve component of the tag related to unknown.
BlockEntry(ElementType etype=NONE, MarkerType mask=0, bool inverse=false)
Default constructor.
Matrix< value_reference > Value(const Storage &e)
Return vector filled with references to values of unknowns of the block.
uMatrix Unknown(const Storage &e) const
Return vector filled with unknowns of the block with their derivatives.
void AddTag(Tag value, INMOST_DATA_ENUM_TYPE comp=ENUMUNDEF)
Add a component of the tag as unknown, by default all components of the tag are added.
iMatrix Index(const Storage &e) const
Return vector filled with indices of unknowns of the block.
INMOST_DATA_REAL_TYPE & Value(const Storage &e, INMOST_DATA_ENUM_TYPE pos)
Return value in vector of unknowns of the block at certain position.
INMOST_DATA_ENUM_TYPE Size() const
Number of tags in block.
TagRealArray GetValueTag(INMOST_DATA_ENUM_TYPE unk) const
Retrieve tag related to unknown value.
void ClearTags()
Remove all existing tags.
AbstractEntry * Copy() const
Make a copy of the object.
INMOST_DATA_ENUM_TYPE MatrixSize(const Storage &e) const
The intended size of the matrix for this entry.
INMOST_DATA_REAL_TYPE Value(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return value in vector of unknowns of the block at certain position.
unknown Unknown(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return unknown in vector of variables of the block at certain position.
INMOST_DATA_ENUM_TYPE Size(const Storage &e) const
Number of entries for each tag in the block.
Mesh * GetMeshLink() const
Retrieve mesh pointer.
INMOST_DATA_ENUM_TYPE Index(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return index in vector of indices of the block at certain position.
Class for linear algebra operations on dense matrices.
A class to organize a model.
Definition: inmost_model.h:186
Stack together multiple objects of AbstractEntry class.
unknown Unknown(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return unknown in vector of variables of the block at certain position.
TagRealArray GetValueTag(INMOST_DATA_ENUM_TYPE unk) const
Retrieve tag related to unknown value.
uMatrix operator[](const Storage &e) const
Return vector filled with unknowns of the block with their derivatives.
uMatrix Unknown(const Storage &e) const
Return vector filled with unknowns of the block with their derivatives.
const AbstractEntry & GetEntry(INMOST_DATA_ENUM_TYPE k) const
Retrieve entry from block of entries.
INMOST_DATA_REAL_TYPE & Value(const Storage &e, INMOST_DATA_ENUM_TYPE pos)
Return value in vector of unknowns of the block at certain position.
INMOST_DATA_ENUM_TYPE Index(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return index in vector of indices of the block at certain position.
INMOST_DATA_ENUM_TYPE NumEntries() const
Total number of entries.
AbstractEntry * Copy() const
Make a copy of the object.
INMOST_DATA_ENUM_TYPE GetValueComp(INMOST_DATA_ENUM_TYPE unk) const
Retrieve component of the tag related to unknown.
Matrix< value_reference > Value(const Storage &e)
Return vector filled with references to values of unknowns of the block.
rMatrix Value(const Storage &e) const
Return vector filled with values of unknowns of the block.
INMOST_DATA_ENUM_TYPE Size(const Storage &e) const
Number of entries for each tag in the block.
AbstractEntry & GetEntry(INMOST_DATA_ENUM_TYPE k)
Retrieve entry from block of entries.
Mesh * GetMeshLink() const
Retrieve mesh pointer.
INMOST_DATA_ENUM_TYPE Size() const
Number of tags in block.
~MultiEntry()
Destructor.
void AddEntry(const AbstractEntry &entry)
Add entry into block of entries.
INMOST_DATA_REAL_TYPE Value(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return value in vector of unknowns of the block at certain position.
iMatrix Index(const Storage &e) const
Return vector filled with indices of unknowns of the block.
INMOST_DATA_ENUM_TYPE MatrixSize(const Storage &e) const
The intended size of the matrix for this entry.
MultiEntry(ElementType etype=NONE, MarkerType mask=0, bool inverse=false)
Default constructor.
This class is used to organize a single unknown.
INMOST_DATA_ENUM_TYPE MatrixSize(const Storage &e) const
The intended size of the matrix for this entry.
INMOST_DATA_ENUM_TYPE Size() const
Number of tags in block.
unknown Unknown(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return unknown in vector of variables of the block at certain position.
TagRealArray GetValueTag(INMOST_DATA_ENUM_TYPE unk) const
Retrieve tag related to unknown value.
INMOST_DATA_REAL_TYPE Value(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return value in vector of unknowns of the block at certain position.
INMOST_DATA_REAL_TYPE & Value(const Storage &e, INMOST_DATA_ENUM_TYPE pos)
Return value in vector of unknowns of the block at certain position.
INMOST_DATA_ENUM_TYPE GetValueComp(INMOST_DATA_ENUM_TYPE unk) const
Retrieve component of the tag related to unknown.
AbstractEntry * Copy() const
Make a copy of the object.
Mesh * GetMeshLink() const
Retrieve mesh pointer.
rMatrix Value(const Storage &e) const
Return vector filled with values of unknowns of the block.
SingleEntry(ElementType etype=NONE, MarkerType mask=0, bool inverse=false)
Default constructor.
iMatrix Index(const Storage &e) const
Return vector filled with indices of unknowns of the block.
INMOST_DATA_ENUM_TYPE Size(const Storage &e) const
Number of entries for each tag in the block.
uMatrix Unknown(const Storage &e) const
Return vector filled with unknowns of the block with their derivatives.
SingleEntry(ElementType etype, MarkerType mask, bool inverse, Tag unknown_tag, INMOST_DATA_ENUM_TYPE unknown_comp=0)
Constructor with tag.
void SetTag(Tag unknown_tag_in, INMOST_DATA_ENUM_TYPE unknown_comp_in=0)
Provide tag.
INMOST_DATA_ENUM_TYPE Index(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return index in vector of indices of the block at certain position.
uMatrix operator[](const Storage &e) const
Return vector filled with unknowns of the block with their derivatives.
Matrix< value_reference > Value(const Storage &e)
Return vector filled with references to values of unknowns of the block.
This class is used to organize unknowns into blocks and provides mechanisms to change activation stat...
StatusBlockEntry(ElementType etype, MarkerType mask, bool inverse, TagInteger status_tag, const std::vector< std::vector< bool > > &status_tbl)
Constructor with status tag and status table.
uMatrix operator[](const Storage &e) const
Return vector filled with unknowns of the block with their derivatives.
StatusBlockEntry(ElementType etype, MarkerType mask, bool inverse, TagInteger status_tag)
Constructor with status tag.
unknown Unknown(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return unknown in vector of variables of the block at certain position.
AbstractEntry * Copy() const
Make a copy of the object.
TagRealArray GetValueTag(INMOST_DATA_ENUM_TYPE unk) const
Retrieve tag related to unknown value.
INMOST_DATA_ENUM_TYPE GetValueComp(INMOST_DATA_ENUM_TYPE unk) const
Retrieve component of the tag related to unknown.
INMOST_DATA_REAL_TYPE & Value(const Storage &e, INMOST_DATA_ENUM_TYPE pos)
Return value in vector of unknowns of the block at certain position.
INMOST_DATA_REAL_TYPE Value(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return value in vector of unknowns of the block at certain position.
void AddStatus(const std::vector< bool > &stat)
Add status into table.
void AddTag(Tag value, INMOST_DATA_ENUM_TYPE comp=ENUMUNDEF)
Add a component of the tag as unknown, by default all components of the tag are added.
iMatrix Index(const Storage &e) const
Return vector filled with indices of unknowns of the block.
INMOST_DATA_ENUM_TYPE Size(const Storage &e) const
Number of entries for each tag in the block.
INMOST_DATA_ENUM_TYPE Index(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return index in vector of indices of the block at certain position.
uMatrix Unknown(const Storage &e) const
Return vector filled with unknowns of the block with their derivatives.
void SetStatusTag(TagInteger input)
Set status tag.
rMatrix Value(const Storage &e) const
Return vector filled with values of unknowns of the block.
void ClearTags()
Remove all existing tags.
INMOST_DATA_ENUM_TYPE Size() const
Number of tags in block.
Mesh * GetMeshLink() const
Retrieve mesh pointer.
StatusBlockEntry(ElementType etype=NONE, MarkerType mask=0, bool inverse=false)
Default constructor.
Matrix< value_reference > Value(const Storage &e)
Return vector filled with references to values of unknowns of the block.
INMOST_DATA_ENUM_TYPE MatrixSize(const Storage &e) const
The intended size of the matrix for this entry.
Base class for Mesh, Element, and ElementSet classes.
Definition: inmost_data.h:310
__INLINE bool HaveData(const Tag &tag) const
Check if any data is associated with Tag.
Definition: inmost_mesh.h:3928
This class provides the access to the individual mesh datum and general information about it.
Definition: inmost_data.h:193
This class is used to organize multiple unknowns resided on single tag of variable or static size.
iMatrix Index(const Storage &e) const
Return vector filled with indices of unknowns of the block.
AbstractEntry * Copy() const
Make a copy of the object.
Mesh * GetMeshLink() const
Retrieve mesh pointer.
INMOST_DATA_REAL_TYPE Value(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return value in vector of unknowns of the block at certain position.
Matrix< value_reference > Value(const Storage &e)
Return vector filled with references to values of unknowns of the block.
rMatrix Value(const Storage &e) const
Return vector filled with values of unknowns of the block.
unknown Unknown(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return unknown in vector of variables of the block at certain position.
TagRealArray GetValueTag(INMOST_DATA_ENUM_TYPE unk) const
Retrieve tag related to unknown value.
INMOST_DATA_ENUM_TYPE Size(const Storage &e) const
Number of entries for each tag in the block.
VectorEntry(ElementType etype=NONE, MarkerType mask=0, bool inverse=false)
Default constructor.
INMOST_DATA_ENUM_TYPE MatrixSize(const Storage &e) const
The intended size of the matrix for this entry.
INMOST_DATA_REAL_TYPE & Value(const Storage &e, INMOST_DATA_ENUM_TYPE pos)
Return value in vector of unknowns of the block at certain position.
uMatrix operator[](const Storage &e) const
Return vector filled with unknowns of the block with their derivatives.
uMatrix Unknown(const Storage &e) const
Return vector filled with unknowns of the block with their derivatives.
VectorEntry(ElementType etype, MarkerType mask, bool inverse, Tag unknown_tag)
Constructor with tag.
void SetTag(Tag unknown_tag_in)
Provide tag.
INMOST_DATA_ENUM_TYPE Size() const
Number of tags in block.
INMOST_DATA_ENUM_TYPE GetValueComp(INMOST_DATA_ENUM_TYPE unk) const
Retrieve component of the tag related to unknown.
INMOST_DATA_ENUM_TYPE Index(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const
Return index in vector of indices of the block at certain position.
A class that represents a variable with multiple first order and second order variations.
A class that represents a variable with multiple first order variations.