Hermes2D  3.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 #include "../shapeset/precalc.h"
22 
23 namespace Hermes
24 {
25  namespace Hermes2D
26  {
27  class Element;
28  class RefMap;
29  class Quad1DStd;
30  class Quad2DStd;
31  struct Trf;
32 
33  enum CurvType
34  {
35  ArcType,
36  NurbsType
37  };
38 
39  class HERMES_API Curve
40  {
41  public:
42  Curve(CurvType type);
43  virtual ~Curve();
44  CurvType type;
45  };
46 
47  class HERMES_API Arc : public Curve
48  {
49  public:
50  Arc();
51  Arc(double angle);
52  Arc(const Arc* other);
53 
55  double angle;
56 
58  static const unsigned char degree = 2;
59 
61  static const unsigned char np = 3;
62  // there are 6 knots: {0, 0, 0, 1, 1, 1}
63  static const unsigned char nk = 6;
64  double kv[6];
65  double3 pt[3];
66  };
67 
77  class HERMES_API Nurbs : public Curve
78  {
79  public:
80  Nurbs();
81  Nurbs(const Nurbs* other);
82  ~Nurbs();
83 
85  unsigned char degree;
87  unsigned char np;
89  double3* pt;
91  unsigned char nk;
93  double* kv;
94  };
95 
100  class HERMES_API CurvMap
101  {
102  public:
103  CurvMap();
104  CurvMap(const CurvMap* cm);
105  ~CurvMap();
106  void free();
107 
110  bool toplevel;
111 
112  // if toplevel=true, this structure belongs to a base mesh element
113  // and the array 'nurbs' points to (up to four) NURBS curved edges
114  Curve* curves[H2D_MAX_NUMBER_EDGES];
115 
116  // if toplevel=false, this structure belongs to a refined element
117  // and 'parent' points to the base mesh element CurvMap structure;
118  Element* parent;
119  uint64_t sub_idx;
120 
122  unsigned short order;
123 
129  void update_refmap_coeffs(Element* e);
130 
131  private:
132  PrecalcShapesetAssembling ref_map_pss;
133 
135  Trf* ctm;
136 
140  unsigned short nc;
142  double2* coeffs;
143 
144  void get_mid_edge_points(Element* e, double2* pt, unsigned short n);
145 
147  static double nurbs_basis_fn(unsigned short i, unsigned short k, double t, double* knot);
148 
152  static void nurbs_edge(Element* e, Curve* curve, int edge, double t, double& x,
153  double& y);
154 
156  static const double2 ref_vert[2][H2D_MAX_NUMBER_VERTICES];
157 
159  static void nurbs_edge_0(Element* e, Curve* nurbs, unsigned short edge, double t, double& x, double& y, double& n_x, double& n_y, double& t_x, double& t_y);
160 
162  static void calc_ref_map_tri(Element* e, Curve** nurbs, double xi_1, double xi_2, double& x, double& y);
163  static void calc_ref_map_quad(Element* e, Curve** nurbs, double xi_1, double xi_2,
164  double& x, double& y);
165 
166  static void calc_ref_map(Element* e, Curve** nurbs, double xi_1, double xi_2, double2& f);
167 
170  void edge_coord(Element* e, unsigned short edge, double t, double2& x) const;
171  void calc_edge_projection(Element* e, unsigned short edge, Curve** nurbs, unsigned short order, double2* proj) const;
172 
174  void old_projection(Element* e, unsigned short order, double2* proj, double* old[2]);
175  void calc_bubble_projection(Element* e, Curve** nurbs, unsigned short order, double2* proj);
176 
177  static CurvMap* create_son_curv_map(Element* e, int son);
178 
179  template<typename T> friend class Space;
180  template<typename T> friend class H1Space;
181  template<typename T> friend class L2Space;
182  template<typename T> friend class HcurlSpace;
183  template<typename T> friend class HdivSpace;
184  template<typename T> friend class DiscreteProblem;
185  template<typename T> friend class Adapt;
186  template<typename T> friend class KellyTypeAdapt;
187  friend class RefMap;
188  friend class Mesh;
189  friend class MeshReader;
190  friend class MeshReaderH2D;
191  friend class MeshReaderH2DXML;
192  friend class MeshReaderH2DBSON;
193  };
194 
196  {
197  public:
198  CurvMapStatic();
199  ~CurvMapStatic();
200 
205  double** calculate_bubble_projection_matrix(short* indices, ElementMode2D mode);
206  void precalculate_cholesky_projection_matrices_bubble();
207 
210  unsigned short edge_proj_matrix_size;
215 
217  double* edge_p;
219  double* bubble_tri_p;
220  unsigned short tri_bubble_np;
222  double* bubble_quad_p;
223  unsigned short quad_bubble_np;
224  };
225 
228  }
229 }
230 #endif
unsigned char np
number of control points
Definition: curved.h:87
PrecalcShapeset variant for fast assembling.
Definition: precalc.h:109
Definition: adapt.h:24
void precalculate_cholesky_projection_matrix_edge()
Definition: curved.cpp:153
Stores one element of a mesh.
Definition: element.h:107
double ** edge_proj_matrix
projection matrix for each edge is the same
Definition: curved.h:209
Represents a finite element mesh. Typical usage: MeshSharedPtr mesh; Hermes::Hermes2D::MeshReaderH2DX...
Definition: mesh.h:61
unsigned short order
current polynomial degree of the refmap approximation
Definition: curved.h:122
Represents one NURBS curve.
Definition: curved.h:77
double ** bubble_proj_matrix_tri
projection matrix for triangle bubbles
Definition: curved.h:212
double angle
arc angle
Definition: curved.h:55
::xsd::cxx::tree::type type
C++ type corresponding to the anyType XML Schema built-in type.
double * bubble_tri_p
diagonal vector in cholesky factorization
Definition: curved.h:219
#define H2D_MAX_NUMBER_EDGES
A maximum number of edges of an element.
Definition: global.h:31
unsigned char nk
knot vector length
Definition: curved.h:91
2D transformation.
Definition: transformable.h:29
double ** calculate_bubble_projection_matrix(short *indices, ElementMode2D mode)
Calculate the H1 seminorm products (, ) for all 0 <= i, j < n, n is the number of bubble functions...
Definition: curved.cpp:74
#define H2D_MAX_NUMBER_VERTICES
A maximum number of vertices of an element.
Definition: global.h:32
double ** bubble_proj_matrix_quad
projection matrix for quad bubbles
Definition: curved.h:214
double * bubble_quad_p
diagonal vector in cholesky factorization
Definition: curved.h:222
unsigned char degree
curve degree (2=quadratic, etc.)
Definition: curved.h:85
Represents a finite element space over a domain.
Definition: api2d.h:34
Represents the reference mapping.
Definition: refmap.h:40
CurvMapStatic curvMapStatic
Global instance used inside Hermes which is also accessible to users.
Definition: curved.cpp:256
double * kv
knot vector
Definition: curved.h:93
double * edge_p
diagonal vector in cholesky factorization
Definition: curved.h:217
double3 * pt
control points and their weights
Definition: curved.h:89