Hermes2D  2.0
curved.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_CURVED_H
17 #define __H2D_CURVED_H
18 
19 #include "../global.h"
20 #include "../shapeset/shapeset_common.h"
21 
22 namespace Hermes
23 {
24  namespace Hermes2D
25  {
26  class Element;
27  class H1ShapesetJacobi;
28  class PrecalcShapeset;
29  class Quad1DStd;
30  class Quad2DStd;
31  struct Trf;
32 
42  struct HERMES_API Nurbs
43  {
44  Nurbs()
45  {
46  ref = 0; twin = false;
47  };
48  void unref();
49 
50  int degree;
51  int np;
52  double3* pt;
53  int nk;
54  double* kv;
55  int ref;
56  bool twin;
57  bool arc;
58  double angle;
59  };
60 
65  class HERMES_API CurvMap
66  {
67  public:
68  CurvMap()
69  {
70  coeffs = NULL;};
71  CurvMap(CurvMap* cm);
72  ~CurvMap();
73  private:
76  bool toplevel;
77  union
78  {
79  // if toplevel=true, this structure belongs to a base mesh element
80  // and the array 'nurbs' points to (up to four) NURBS curved edges
82  struct
83  {
84  // if toplevel=false, this structure belongs to a refined element
85  // and 'parent' points to the base mesh element CurvMap structure;
86  Element* parent;
87  uint64_t part;
88  };
89  };
90 
92  int order;
93 
96  int nc;
97  double2* coeffs;
98 
104  void update_refmap_coeffs(Element* e);
105 
106  void get_mid_edge_points(Element* e, double2* pt, int n);
107 
108  static double** edge_proj_matrix;
109  static double** bubble_proj_matrix_tri;
110  static double** bubble_proj_matrix_quad;
111 
112  static double* edge_p;
113  static double* bubble_tri_p;
114  static double* bubble_quad_p;
115 
116  static Quad1DStd quad1d;
117  static Quad2DStd quad2d;
118 
119  static Trf ctm;
120 
122  static double nurbs_basis_fn(int i, int k, double t, double* knot);
123 
124  // Nurbs curve: t goes from -1 to 1, function returns x, y coordinates in plane
125  // as well as the unit normal and unit tangential vectors. This is done using
126  // the Wikipedia page http://en.wikipedia.org/wiki/Non-uniform_rational_B-spline.
127  static void nurbs_edge(Element* e, Nurbs* nurbs, int edge, double t, double& x,
128  double& y, double& n_x, double& n_y, double& t_x, double& t_y);
129 
130  static const double2 ref_vert[2][H2D_MAX_NUMBER_VERTICES];
131 
133  static void nurbs_edge_0(Element* e, Nurbs* nurbs, int edge, double t, double& x, double& y, double& n_x, double& n_y, double& t_x, double& t_y);
134  static void calc_ref_map_tri(Element* e, Nurbs** nurbs, double xi_1, double xi_2, double& x, double& y);
135  static void calc_ref_map_quad(Element* e, Nurbs** nurbs, double xi_1, double xi_2,
136  double& x, double& y);
137 
138  static void calc_ref_map(Element* e, Nurbs** nurbs, double xi_1, double xi_2, double2& f);
139 
140  static void precalculate_cholesky_projection_matrix_edge(H1ShapesetJacobi* ref_map_shapeset, PrecalcShapeset* ref_map_pss);
141  static double** calculate_bubble_projection_matrix(int nb, int* indices, H1ShapesetJacobi* ref_map_shapeset, PrecalcShapeset* ref_map_pss, ElementMode2D mode);
142  static void precalculate_cholesky_projection_matrices_bubble(H1ShapesetJacobi* ref_map_shapeset, PrecalcShapeset* ref_map_pss);
143 
144  static void edge_coord(Element* e, int edge, double t, double2& x, double2& v);
145  static void calc_edge_projection(Element* e, int edge, Nurbs** nurbs, int order, double2* proj, H1ShapesetJacobi* ref_map_shapeset, PrecalcShapeset* ref_map_pss);
146 
147  static void old_projection(Element* e, int order, double2* proj, double* old[2], H1ShapesetJacobi* ref_map_shapeset, PrecalcShapeset* ref_map_pss);
148  static void calc_bubble_projection(Element* e, Nurbs** nurbs, int order, double2* proj, H1ShapesetJacobi* ref_map_shapeset, PrecalcShapeset* ref_map_pss);
149 
150  static void ref_map_projection(Element* e, Nurbs** nurbs, int order, double2* proj, H1ShapesetJacobi* ref_map_shapeset, PrecalcShapeset* ref_map_pss);
151 
152  static bool warning_issued;
153  template<typename T> friend class Space;
154  template<typename T> friend class H1Space;
155  template<typename T> friend class L2Space;
156  template<typename T> friend class HcurlSpace;
157  template<typename T> friend class HdivSpace;
158  template<typename T> friend class DiscreteProblem;
159  template<typename T> friend class DiscreteProblemLinear;
160  template<typename T> friend class Adapt;
161  template<typename T> friend class KellyTypeAdapt;
162  friend class RefMap;
163  friend class Mesh;
164  friend class MeshReader;
165  friend class MeshReaderH2D;
166  friend class MeshReaderH2DXML;
167  friend CurvMap* create_son_curv_map(Element* e, int son);
168  };
169  }
170 }
171 #endif