Hermes2D  3.0
linearizer.h
Go to the documentation of this file.
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/>.
19 #ifndef __H2D_LINEARIZER_H
20 #define __H2D_LINEARIZER_H
21 
22 #include "thread_linearizer.h"
23 #include "linearizer_utils.h"
24 #ifndef NOGLUT
25 #include <pthread.h>
26 #endif
27 #include "../function/solution.h"
28 
29 namespace Hermes
30 {
31  namespace Hermes2D
32  {
33  namespace Views
34  {
43  template<typename LinearizerDataDimensions>
44  class HERMES_API LinearizerMultidimensional :
45  public Hermes::Mixins::TimeMeasurable,
46  public Hermes::Mixins::Loggable,
48  {
49  public:
54 
58  void process_solution(MeshFunctionSharedPtr<double> sln, int item = H2D_FN_VAL_0);
59  void process_solution(MeshFunctionSharedPtr<double>* sln, int* items);
60 
62  void save_solution_vtk(MeshFunctionSharedPtr<double> sln, const char* filename, const char* quantity_name, bool mode_3D = true, int item = H2D_FN_VAL_0);
64  void save_solution_vtk(std::vector<MeshFunctionSharedPtr<double> > slns, std::vector<int> items, const char* filename, const char* quantity_name, bool mode_3D = true);
66  void save_solution_tecplot(MeshFunctionSharedPtr<double> sln, const char* filename, const char* quantity_name, int item = H2D_FN_VAL_0);
68  void save_solution_tecplot(std::vector<MeshFunctionSharedPtr<double> > slns, std::vector<int> items, const char* filename, std::vector<std::string> quantity_names);
69 
73  void set_criterion(LinearizerCriterion criterion);
74 
76  void set_displacement(MeshFunctionSharedPtr<double> xdisp, MeshFunctionSharedPtr<double> ydisp, double dmult = 1.0);
77 
80  template<typename T>
81  class HERMES_API Iterator
82  {
83  public:
88  void operator++();
90  T& get() const;
92  int& get_marker() const;
94  bool end;
95  private:
96  int current_thread_index;
97  int current_thread;
98  int current_thread_size;
99  std::vector<int> thread_sizes;
101  void check_zero_lengths();
102  friend class LinearizerMultidimensional;
103  };
104 
112  Iterator<triangle_indices_t> triangle_indices_begin() const;
113 
115  int get_vertex_count() const;
117  int get_triangle_count() const;
119  int get_edge_count() const;
121  int get_triangle_index_count() const;
122 
123  void set_max_absolute_value(double max_abs);
124 
125  double get_min_value() const;
126  double get_max_value() const;
127 
132  void set_curvature_epsilon(double curvature_epsilon);
133 
135  double get_curvature_epsilon() const;
136 
138  void free();
139 
143 
145  void lock_data() const;
146  void unlock_data() const;
147 
149  void calc_vertices_aabb(double* min_x, double* max_x, double* min_y, double* max_y) const;
150 
151  protected:
152  Quad2D *old_quad[LinearizerDataDimensions::dimension], *old_quad_x, *old_quad_y;
153 
157 
159  void check_data(MeshFunctionSharedPtr<double>* sln);
160 
163 
164  void init(MeshFunctionSharedPtr<double>* sln, int* item);
165 
166  std::vector<MeshSharedPtr> meshes;
167 
170 
172  bool user_xdisp, user_ydisp;
173 
174 #ifndef NOGLUT
175  mutable pthread_mutex_t data_mutex;
176 #endif
177 
180 
182  double dmult;
183 
185  int item[LinearizerDataDimensions::dimension], component[LinearizerDataDimensions::dimension], value_type[LinearizerDataDimensions::dimension];
186 
187  // Finish - contour triangles calculation etc.
188  void finish(MeshFunctionSharedPtr<double>* sln);
189 
190  Traverse::State** states;
191  unsigned int num_states;
192 
193  double min_val, max_val;
194 
195  void find_min_max();
196 
197  friend class ThreadLinearizerMultidimensional < LinearizerDataDimensions > ;
198  };
199 
204  }
205  }
206 }
207 #endif
Definition: adapt.h:24
Class utilizes parallel calculation.
Definition: mixins2d.h:37
double curvature_epsilon
Standard and curvature epsilon.
Definition: linearizer.h:169
bool user_xdisp
Information if user-supplied displacement functions have been provided.
Definition: linearizer.h:172
File containing ThreadLinearizerMultidimensional class.
File containing utilities for class.
double dmult
Displacement multiplicator - used e.g. in Elasticity to multiply the displacement to make it more not...
Definition: linearizer.h:182
ThreadLinearizerMultidimensional< LinearizerDataDimensions > ** threadLinearizerMultidimensional
Assembly data.
Definition: linearizer.h:162
MeshFunctionSharedPtr< double > xdisp
Displacement functions, default to ZeroFunctions, may be supplied by set_displacement();.
Definition: linearizer.h:179
LinearizerMultidimensional< ScalarLinearizerDataDimensions< LINEARIZER_DATA_TYPE > > Linearizer
Linearizer for scalar cases - historically called Linearizer.
Definition: linearizer.h:201
LinearizerMultidimensional< VectorLinearizerDataDimensions< LINEARIZER_DATA_TYPE > > Vectorizer
Linearizer for vector cases - historically called Vectorizer.
Definition: linearizer.h:203
Abstract class for criterion according to which the linearizer stops dividing elements at some point ...
bool end
The iterator has reached the end of the data.
Definition: linearizer.h:94