Hermes2D  3.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 #include "element_to_refine.h"
20 #include "../mesh/mesh.h"
21 #include "adapt/error_calculator.h"
22 
47 namespace Hermes
48 {
49  namespace Hermes2D
50  {
52  namespace RefinementSelectors
53  {
55 
59  template<typename Scalar>
60  class HERMES_API Selector : public Hermes::Mixins::Loggable, public Hermes::Mixins::TimeMeasurable
61  {
62  public:
63  virtual ~Selector() {};
65 
71  virtual bool select_refinement(Element* element, int quad_order, MeshFunction<Scalar>* rsln, ElementToRefine& refinement) = 0;
72 
73  protected:
75  const int min_order;
77  const int max_order;
78 
80 
81  Selector(int min_order = 1, int max_order = H2DRS_DEFAULT_ORDER) : min_order(min_order), max_order(max_order) {};
82 
83  template<typename T> friend class Adapt;
84  template<typename T> friend class KellyTypeAdapt;
85  };
86 
88  template<typename Scalar>
89  class HERMES_API HOnlySelector : public Selector < Scalar > {
90  public:
92  HOnlySelector() : Selector<Scalar>() {};
93  protected:
95 
96  virtual bool select_refinement(Element* element, int quad_order, MeshFunction<Scalar>* rsln, ElementToRefine& refinement);
97 
98  template<typename T> friend class Adapt;
99  template<typename T> friend class KellyTypeAdapt;
100  };
101 
103  template<typename Scalar>
104  class HERMES_API POnlySelector : public Selector < Scalar > {
106  const int order_h_inc;
108  const int order_v_inc;
109  public:
111 
114  POnlySelector(int max_order = H2DRS_DEFAULT_ORDER, int order_h_inc = 1, int order_v_inc = 1);
115 
116  protected:
118 
119  virtual bool select_refinement(Element* element, int quad_order, MeshFunction<Scalar>* rsln, ElementToRefine& refinement);
120 
121  template<typename T> friend class Adapt;
122  template<typename T> friend class KellyTypeAdapt;
123  };
124  }
125  }
126 }
127 #endif
Definition: adapt.h:24
Stores one element of a mesh.
Definition: element.h:107
const int min_order
A minimum allowed order.
Definition: selector.h:75
Represents a function defined on a mesh.
Definition: mesh_function.h:56
const int max_order
A maximum allowed order.
Definition: selector.h:77
A parent of all refinement selectors. Abstract class.
Definition: function.h:29
#define H2DRS_DEFAULT_ORDER
A default order. Used to indicate an unkonwn order or a maximum support order.
Definition: global.h:103
Selector(int min_order=1, int max_order=H2DRS_DEFAULT_ORDER)
Constructor.
Definition: selector.h:81