Hermes2D  2.0
transformable.h
1 // This file is part of Hermes2D.
2 //
3 // Hermes2D is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 2 of the License, or
6 // (at your option) any later version.
7 //
8 // Hermes2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Hermes2D. If not, see <http://www.gnu.org/licenses/>.
15 
16 #ifndef __H2D_TRANSFORM_H
17 #define __H2D_TRANSFORM_H
18 
19 #include "../global.h"
20 #include "exceptions.h"
21 namespace Hermes
22 {
23  namespace Hermes2D
24  {
25  class Element;
26  template<typename Scalar> class Func;
27  namespace Views
28  {
29  class Vectorizer;
30  }
31 
33  struct Trf
34  {
35  double2 m;
36  double2 t;
37  };
38 
40  extern HERMES_API Trf tri_trf[H2D_TRF_NUM];
42  extern HERMES_API Trf quad_trf[H2D_TRF_NUM];
43 
49  class HERMES_API Transformable : public Hermes::Mixins::Loggable
50  {
51  public:
53  Element* get_active_element() const;
54 
57  void set_transform(uint64_t idx);
58 
60  uint64_t get_transform() const;
61 
62  virtual ~Transformable();
63 
68  virtual void push_transform(int son);
69 
70  protected:
71 
72  Transformable();
73 
78  virtual void set_active_element(Element* e);
79 
83  virtual void pop_transform();
84 
86  void reset_transform();
87 
89  inline double get_transform_jacobian() const { return ctm->m[0] * ctm->m[1]; }
90 
92  inline Trf* get_ctm() const { return ctm; }
93 
95  inline unsigned int get_depth() const { return top; }
96 
97  static void push_transforms(std::set<Transformable *>& transformables, int son);
98  static void pop_transforms(std::set<Transformable *>& transformables);
99  static const unsigned int H2D_MAX_TRN_LEVEL = 15;
100 
103 
107  uint64_t sub_idx;
108 
111  static const uint64_t H2D_MAX_IDX = (1ULL << 3 * H2D_MAX_TRN_LEVEL) - 1;
112 
114  Trf stack[21];
116  unsigned int top;
117 
118  template<typename T> friend class KellyTypeAdapt;
119  template<typename T> friend class Adapt;
120  template<typename T> friend class Func;
121  template<typename T> friend class Function;
122  template<typename T> friend class DiscontinuousFunc;
123  template<typename T> friend class DiscreteProblem;
124  template<typename T> friend class DiscreteProblemLinear;
125  template<typename T> friend class NeighborSearch;
126  friend class CurvMap;
127  friend class Traverse;
128  friend class Views::Vectorizer;
129  };
130  }
131 }
132 #endif