Hermes2D  2.0
selector.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_REFINEMENT_SELECTOR_H
17 #define __H2D_REFINEMENT_SELECTOR_H
18 
19 #ifndef _MSC_VER
20 #include "../mesh/refinement_type.h"
21 
22 namespace Hermes
23 {
24  namespace Hermes2D
25  {
26  class ElementToRefine;
27  struct Element;
28  template<typename Scalar> class Solution;
29  }
30 }
31 #else
32 #include "../mesh/element_to_refine.h"
33 #endif
34 #include "../mesh/mesh.h"
35 
60 namespace Hermes
61 {
62  namespace Hermes2D
63  {
64 #define H2DRS_DEFAULT_ORDER -1
65 #define H2DRS_MAX_ORDER 9
66 
67 
68  namespace RefinementSelectors {
70 
74  template<typename Scalar>
75  class HERMES_API Selector : public Hermes::Mixins::Loggable, public Hermes::Mixins::TimeMeasurable
76  {
77  public:
78  virtual ~Selector() {};
79  protected:
80  const int max_order;
81 
82 
83  Selector(int max_order = H2DRS_DEFAULT_ORDER) : max_order(max_order), isAClone(false) {};
84 
86  virtual Selector<Scalar>* clone() = 0;
87 
89 
95  virtual bool select_refinement(Element* element, int quad_order, Solution<Scalar>* rsln, ElementToRefine& refinement) = 0;
96 
98 
103  virtual void generate_shared_mesh_orders(const Element* element, const int orig_quad_order, const int refinement, int tgt_quad_orders[H2D_MAX_ELEMENT_SONS], const int* suggested_quad_orders) = 0;
104 
105  template<typename T> friend class Adapt;
106  template<typename T> friend class KellyTypeAdapt;
107 
109  protected:
110  bool isAClone;
111  };
112 
114  template<typename Scalar>
115  class HERMES_API HOnlySelector : public Selector<Scalar> {
116  public:
118  HOnlySelector() : Selector<Scalar>() {};
119 
121  virtual Selector<Scalar>* clone();
122 
123  protected:
125 
126  virtual bool select_refinement(Element* element, int quad_order, Solution<Scalar>* rsln, ElementToRefine& refinement);
127 
129 
131  virtual void generate_shared_mesh_orders(const Element* element, const int orig_quad_order, const int refinement, int tgt_quad_orders[H2D_MAX_ELEMENT_SONS], const int* suggested_quad_orders);
132  template<typename T> friend class Adapt;
133  template<typename T> friend class KellyTypeAdapt;
134  };
135 
137  template<typename Scalar>
138  class HERMES_API POnlySelector : public Selector<Scalar> {
139  const int order_h_inc;
140  const int order_v_inc;
141  public:
143 
146  POnlySelector(int max_order, int order_h_inc, int order_v_inc);
147 
149  virtual Selector<Scalar>* clone();
150 
151  protected:
153 
154  virtual bool select_refinement(Element* element, int quad_order, Solution<Scalar>* rsln, ElementToRefine& refinement);
155 
157 
159  virtual void generate_shared_mesh_orders(const Element* element, const int orig_quad_order, const int refinement, int tgt_quad_orders[H2D_MAX_ELEMENT_SONS], const int* suggested_quad_orders);
160  template<typename T> friend class Adapt;
161  template<typename T> friend class KellyTypeAdapt;
162  };
163  }
164  }
165 }
166 #endif