Hermes2D  3.0
refmap.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_REFMAP_H
17 #define __H2D_REFMAP_H
18 
19 #include "../global.h"
20 #include "../shapeset/precalc.h"
21 #include "../mesh/mesh.h"
22 #include "../quadrature/quad_all.h"
23 #include "shapeset/shapeset_h1_all.h"
24 
25 namespace Hermes
26 {
27  namespace Hermes2D
28  {
29  class Element;
30  class Mesh;
31 
40  class HERMES_API RefMap : public Transformable
41  {
42  public:
43  RefMap();
44 
45  ~RefMap();
46 
49  void set_quad_2d(Quad2D* quad_2d);
50 
52  Quad2D* get_quad_2d() const;
53 
56  virtual void set_active_element(Element* e);
57 
63  double3* get_tangent(int edge, int order = -1);
64 
67  static void untransform(Element* e, double x, double y, double& xi1, double& xi2);
68 
74  static Element* element_on_physical_coordinates(bool use_MeshHashGrid, MeshSharedPtr mesh, double x, double y, double* x_reference = nullptr, double* y_reference = nullptr);
75 
81  static bool is_element_on_physical_coordinates(Element* e, double x, double y, double* x_reference = nullptr, double* y_reference = nullptr);
82 
86  double* get_phys_x(int order);
87 
91  double* get_phys_y(int order);
92 
95  inline bool is_jacobian_const() const
96  {
97  return is_const;
98  }
99 
101  inline int get_inv_ref_order() const
102  {
103  return inv_ref_order;
104  }
105 
108  inline double get_const_jacobian() const
109  {
110  return const_jacobian;
111  }
112 
115  inline double2x2* get_const_inv_ref_map()
116  {
117  return &const_inv_ref_map;
118  }
119 
122  inline double* get_jacobian(int order)
123  {
124  if (this->is_const)
125  throw Hermes::Exceptions::Exception("RefMap::get_jacobian() called with a const jacobian.");
126  if (order != this->jacobian_calculated)
127  this->calc_inv_ref_map(order);
128  return this->jacobian;
129  }
130 
134  inline double2x2* get_inv_ref_map(int order)
135  {
136  if (this->is_const)
137  throw Hermes::Exceptions::Exception("RefMap::get_inv_ref_map() called with a const jacobian.");
138  if (order != this->inv_ref_map_calculated)
139  this->calc_inv_ref_map(order);
140  return this->inv_ref_map;
141  }
142 
144  void inv_ref_map_at_point(double xi1, double xi2, double& x, double& y, double2x2& m);
145 
146 #ifdef H2D_USE_SECOND_DERIVATIVES
147  double3x2* get_second_ref_map(int order);
149 
151  void second_ref_map_at_point(double xi1, double xi2, double& x, double& y, double3x2& mm);
152 #endif
153 
155  virtual void push_transform(int son);
156 
158  virtual void pop_transform();
159 
161  void force_transform(uint64_t sub_idx, Trf* ctm);
162 
163  static void set_element_iro_cache(Element* element);
164 
165  private:
167  void reinit_storage();
168 
169  H1ShapesetJacobi ref_map_shapeset;
170  PrecalcShapesetAssembling ref_map_pss;
171 
173  bool is_const;
174 
176  double const_jacobian;
177  double2x2 const_inv_ref_map;
178  double3x2 const_second_ref_map;
179  double const_direct_ref_map[2][2];
180 
182  double jacobian[H2D_MAX_INTEGRATION_POINTS_COUNT];
183  int jacobian_calculated;
184  double2x2 inv_ref_map[H2D_MAX_INTEGRATION_POINTS_COUNT];
185  int inv_ref_map_calculated;
186  double3x2 second_ref_map[H2D_MAX_INTEGRATION_POINTS_COUNT];
187  int second_ref_map_calculated;
188  double direct_ref_map[2][2][H2D_MAX_INTEGRATION_POINTS_COUNT];
189  int direct_ref_map_calculated;
190  int inv_ref_order;
191 
193  double phys_x[H2D_MAX_INTEGRATION_POINTS_COUNT];
194  int phys_x_calculated;
195  double phys_y[H2D_MAX_INTEGRATION_POINTS_COUNT];
196  int phys_y_calculated;
197  double3 tan[H2D_MAX_NUMBER_EDGES][H2D_MAX_INTEGRATION_POINTS_COUNT];
198  int tan_calculated[H2D_MAX_NUMBER_EDGES];
199 
200  Quad2D* quad_2d;
201 
202  void calc_inv_ref_map(int order);
203 
206  void calc_const_inv_ref_map();
207 
208 #ifdef H2D_USE_SECOND_DERIVATIVES
209  void calc_second_ref_map(int order);
210 #endif
211  void calc_phys_x(int order);
212 
213  void calc_phys_y(int order);
214 
215  void calc_tangent(int edge, int eo);
216 
219  int calc_inv_ref_order();
220 
221  unsigned short indices[70];
222 
223  int nc;
224 
225  double2* coeffs;
226 
227  double2 lin_coeffs[H2D_MAX_NUMBER_EDGES];
228  };
229  }
230 }
231 #endif
PrecalcShapeset variant for fast assembling.
Definition: precalc.h:109
Definition: adapt.h:24
Stores one element of a mesh.
Definition: element.h:107
Shape functions based on integrated Jacobi polynomials.
bool is_jacobian_const() const
Definition: refmap.h:95
double get_const_jacobian() const
Definition: refmap.h:108
#define H2D_MAX_NUMBER_EDGES
A maximum number of edges of an element.
Definition: global.h:31
int get_inv_ref_order() const
Returns the increase in the integration order due to the reference map.
Definition: refmap.h:101
double * get_jacobian(int order)
Definition: refmap.h:122
2D transformation.
Definition: transformable.h:29
Represents the reference mapping.
Definition: refmap.h:40
double2x2 * get_inv_ref_map(int order)
Definition: refmap.h:134
double2x2 * get_const_inv_ref_map()
Definition: refmap.h:115