Hermes2D  2.0
linearizer_base.h
1 // This file is part of Hermes2D.
2 //
3 // Copyright 2009 Ivo Hanak <hanak@byte.cz>
4 // Copyright 2005-2008 Jakub Cerveny <jakub.cerveny@gmail.com>
5 // Copyright 2005-2008 Lenka Dubcova <dubcova@gmail.com>
6 // Copyright 2005-2008 Pavel Solin <solin@unr.edu>
7 //
8 // Hermes2D is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // Hermes2D is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with Hermes2D. If not, see <http://www.gnu.org/licenses/>.
20 
21 #ifndef __H2D_LINEARIZER_SUPPORT_H
22 #define __H2D_LINEARIZER_SUPPORT_H
23 
24 #include "global.h"
25 #include "../quadrature/quad_all.h"
26 
27 namespace Hermes
28 {
29  namespace Hermes2D
30  {
31  namespace Views
32  {
33  const double HERMES_EPS_LOW = 0.007;
34  const double HERMES_EPS_NORMAL = 0.0004;
35  const double HERMES_EPS_HIGH = 0.0001;
36  const double HERMES_EPS_VERYHIGH = 0.000002;
37 
39 
45  extern double3 lin_pts_0_tri[];
46 
47  extern double3 lin_pts_0_quad[];
48 
49  extern double3 lin_pts_1_tri[12];
50 
51  extern double3 lin_pts_1_quad[21];
52 
53  extern int quad_indices[9][5];
54 
55  extern int tri_indices[5][3];
56 
57  extern int lin_np_tri[2];
58  extern int lin_np_quad[2];
59  extern int* lin_np[2];
60 
61  extern double3* lin_tables_tri[2];
62  extern double3* lin_tables_quad[2];
63  extern double3** lin_tables[2];
64 
65  class Quad2DLin : public Quad2D
66  {
67  public:
68  Quad2DLin();
69  };
70 
71  extern HERMES_API Quad2DLin g_quad_lin;
72 
74 
75  class HERMES_API LinearizerBase : public Hermes::Mixins::TimeMeasurable, public Hermes::Mixins::Loggable
76  {
77  public:
78  void set_max_absolute_value(double max_abs);
79 
80  double get_min_value() const;
81  double get_max_value() const;
82 
83  void lock_data() const;
84  void unlock_data() const;
85 
86  int3* get_triangles();
87  int* get_triangle_markers();
88  int get_num_triangles();
89  int2* get_edges();
90  int* get_edge_markers();
91  int get_num_edges();
92 
95  virtual bool is_empty();
96 
98  void free();
99 
100  protected:
101  LinearizerBase(bool auto_max = true);
102  ~LinearizerBase();
103 
104  void process_edge(int iv1, int iv2, int marker);
105 
106  bool empty;
107 
108  double max;
109 
110  void regularize_triangle(int iv0, int iv1, int iv2, int mid0, int mid1, int mid2, int marker);
111 
112  bool auto_max;
113 
114  int3* tris;
116  int2* edges;
118  int* hash_table;
119  int4 * info;
120 
121  int vertex_count, triangle_count, edges_count;
122  int vertex_size, triangle_size, edges_size;
123 
124  double eps;
125 
126  double min_val, max_val;
127 
128  int del_slot;
129 
130  int peek_vertex(int p1, int p2);
131 
132  void add_edge(int iv1, int iv2, int marker);
133  void add_triangle(int iv0, int iv1, int iv2, int marker);
134 
135  int hash(int p1, int p2);
136 
137  mutable pthread_mutex_t data_mutex;
138 
139  Hermes::Exceptions::Exception* caughtException;
140 
142  static void calc_aabb(double* x, double* y, int stride, int num, double* min_x, double* max_x, double* min_y, double* max_y);
143  friend class MeshView;
144  friend class OrderView;
145  friend class ScalarView;
146  friend class VectorView;
147  friend class StreamView;
148  };
149 
150  const int LIN_MAX_LEVEL = 6;
151  }
152  }
153 }
154 
155 #endif