Hermes2D  3.0
orderizer.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_ORDERIZER_H
17 #define __H2D_ORDERIZER_H
18 
19 #include "../space/space.h"
20 #include "global.h"
21 #ifndef NOGLUT
22 #include <pthread.h>
23 #endif
24 #include "../quadrature/quad_all.h"
25 #include "../mesh/traverse.h"
26 
27 namespace Hermes
28 {
29  namespace Hermes2D
30  {
31  namespace Views
32  {
36  class HERMES_API Orderizer
37  {
38  public:
39 
40  Orderizer();
41  ~Orderizer();
42 
44  template<typename Scalar>
45  void save_orders_vtk(SpaceSharedPtr<Scalar> space, const char* file_name);
46 
48  template<typename Scalar>
49  void save_markers_vtk(SpaceSharedPtr<Scalar> space, const char* file_name);
50 
52  template<typename Scalar>
53  void save_mesh_vtk(SpaceSharedPtr<Scalar> space, const char* file_name);
54 
56  void calc_vertices_aabb(double* min_x, double* max_x,
57  double* min_y, double* max_y) const;
58 
60  template<typename Scalar>
61  void process_space(SpaceSharedPtr<Scalar> space, bool show_edge_orders = false);
62 
63  int get_labels(int*& lvert, char**& ltext, double2*& lbox) const;
64 
65  int get_num_vertices();
66  double3* get_vertices();
67 
68  void lock_data() const;
69  void unlock_data() const;
70 
71  int3* get_triangles();
72  int* get_triangle_markers();
73  int get_num_triangles();
74 
75  int2* get_edges();
76  int* get_edge_markers();
77  int get_num_edges();
78 
79  void free();
80  protected:
81 #ifndef NOGLUT
82  mutable pthread_mutex_t data_mutex;
83 #endif
84  int2* edges;
88  void add_edge(int iv1, int iv2, int marker);
89 
92  void reallocate(MeshSharedPtr mesh);
93 
94  char buffer[1000];
95  char* labels[11][11];
96 
98  double3* verts;
99  int label_size, label_count;
100  int* lvert;
101  char** ltext;
102  double2* lbox;
103 
105  int3* tris;
108 
110  int vertex_count, triangle_count, edges_count;
112  int vertex_size, triangle_size, edges_size;
113 
114  void add_triangle(int iv0, int iv1, int iv2, int marker);
115 
116  static void calc_aabb(double* x, double* y, int stride, int num, double* min_x, double* max_x, double* min_y, double* max_y);
117 
118  int add_vertex();
119 
120  void make_vert(int & index, double x, double y, double val);
121  };
122  }
123  }
124 }
125 #endif
Definition: adapt.h:24
Used to pass the instances of Space around.
Definition: space.h:34
Common definitions for Hermes2D.
int3 * tris
triangles: vertex index triplets
Definition: orderizer.h:105
::xsd::cxx::tree::buffer< char > buffer
Binary buffer type.
int * tri_markers
triangle_markers: triangle markers, ordering equal to tris
Definition: orderizer.h:107
int vertex_count
Real numbers of vertices, triangles and edges.
Definition: orderizer.h:110
int * edge_markers
edge_markers: edge markers, ordering equal to edges
Definition: orderizer.h:87
int vertex_size
Size of arrays of vertices, triangles and edges.
Definition: orderizer.h:112
double3 * verts
vertices: (x, y, value) triplets
Definition: orderizer.h:98