Hermes2D  3.0
postprocessing.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_POSTPROCESSING_H
17 #define __H2D_POSTPROCESSING_H
18 
19 #include "../forms.h"
20 #include "../function/mesh_function.h"
21 #include "../space/space.h"
22 
23 namespace Hermes
24 {
25  namespace Hermes2D
26  {
28  namespace PostProcessing
29  {
30  template<typename Scalar>
31  class HERMES_API Limiter
32  : public Hermes::Mixins::TimeMeasurable,
33  public Hermes::Mixins::Loggable,
35  public Hermes::Mixins::StateQueryable
36  {
37  public:
38  Limiter(SpaceSharedPtr<Scalar> space, Scalar* solution_vector);
39  Limiter(std::vector<SpaceSharedPtr<Scalar> > spaces, Scalar* solution_vector);
40  virtual ~Limiter();
41 
43  MeshFunctionSharedPtr<Scalar> get_solution();
45  void get_solutions(std::vector<MeshFunctionSharedPtr<Scalar> > solutions);
47  std::vector<int> get_changed_element_ids() const;
48 
50  virtual bool isOkay() const;
51  inline std::string getClassName() const { return "Limiter"; }
52 
54  void set_solution_vector(Scalar* sln);
55 
57  Scalar* get_solution_vector();
58 
59  protected:
60  int component_count;
61  std::vector<SpaceSharedPtr<Scalar> > spaces;
62  Scalar* solution_vector;
63  std::vector<MeshFunctionSharedPtr<Scalar> > limited_solutions;
64  std::vector<int> changed_element_ids;
65 
66  virtual void process() = 0;
67 
68  private:
69  void init(Scalar* solution_vector_);
70  };
71 
72  class HERMES_API VertexBasedLimiter
73  : public Limiter < double >
74  {
75  public:
76  VertexBasedLimiter(SpaceSharedPtr<double> space, double* solution_vector, int maximum_polynomial_order);
77  VertexBasedLimiter(std::vector<SpaceSharedPtr<double> > spaces, double* solution_vector, int maximum_polynomial_order);
78  virtual ~VertexBasedLimiter();
79  std::vector<std::pair<int, double> > get_correction_factors() const;
80  void print_detailed_info(bool print_details = true);
81  int maximum_polynomial_order;
82  void set_p_coarsening_only();
83  static bool wider_bounds_on_boundary;
84 
85  private:
86  bool p_coarsening_only;
87 
88  void init(int maximum_polynomial_order);
89 
90  void process();
91 
92  void prepare_min_max_vertex_values(bool quadratic);
93 
96  double get_centroid_value_multiplied(Element* e, int component, int mixed_derivative_index);
97 
98  double get_edge_midpoint_value_multiplied(Element* e, int component, int mixed_derivative_index, int edge);
99 
100  void impose_linear_correction_factor(Element* e, int component);
101 
103  bool impose_quadratic_correction_factor(Element* e, int component);
104 
105  double*** vertex_min_values;
106  double*** vertex_max_values;
107  void allocate_vertex_values();
108  void deallocate_vertex_values();
109 
110  int mixed_derivatives_count;
111  std::vector<std::pair<int, double> > correction_factors;
112  bool print_details;
113  };
114 
117  template<typename Scalar>
118  class HERMES_API IntegralCalculator :
120  public Hermes::Mixins::Loggable
121  {
122  public:
126  IntegralCalculator(MeshFunctionSharedPtr<Scalar> source_function, int number_of_integrals);
127  IntegralCalculator(std::vector<MeshFunctionSharedPtr<Scalar> > source_functions, int number_of_integrals);
128 
131  virtual Scalar* calculate(std::vector<std::string> markers) = 0;
132 
135  virtual Scalar* calculate(std::string marker);
136 
138  virtual void order(Func<Hermes::Ord> **fns, Hermes::Ord* result) = 0;
139 
140  protected:
141  std::vector<MeshFunctionSharedPtr<Scalar> > source_functions;
142  int number_of_integrals;
143 
144  void add_results(Scalar* results_local, Scalar* results);
145  };
146 
148  template<typename Scalar>
149  class HERMES_API VolumetricIntegralCalculator : public IntegralCalculator < Scalar >
150  {
151  public:
152  VolumetricIntegralCalculator(MeshFunctionSharedPtr<Scalar> source_function, int number_of_integrals);
153  VolumetricIntegralCalculator(std::vector<MeshFunctionSharedPtr<Scalar> > source_functions, int number_of_integrals);
154 
158  virtual void integral(int n, double* wt, Func<Scalar> **fns, GeomVol<double> *e, Scalar* result) = 0;
159 
162  Scalar* calculate(std::vector<std::string> markers);
164  };
165 
167  template<typename Scalar>
168  class HERMES_API SurfaceIntegralCalculator : public IntegralCalculator < Scalar >
169  {
170  public:
171  SurfaceIntegralCalculator(MeshFunctionSharedPtr<Scalar> source_function, int number_of_integrals);
172  SurfaceIntegralCalculator(std::vector<MeshFunctionSharedPtr<Scalar> > source_functions, int number_of_integrals);
173 
177  virtual void integral(int n, double* wt, Func<Scalar> **fns, GeomSurf<double> *e, Scalar* result) = 0;
178 
181  Scalar* calculate(std::vector<std::string> markers);
183  };
184  }
185  }
186 }
187 
188 #endif
Definition: adapt.h:24
Class utilizes parallel calculation.
Definition: mixins2d.h:37
Stores one element of a mesh.
Definition: element.h:107
Used to pass the instances of Space around.
Definition: space.h:34
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.