Hermes2D  2.0
mesh_function.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_MESH_FUNCTION_H
17 #define __H2D_MESH_FUNCTION_H
18 
19 #include "function.h"
20 #include "../mesh/refmap.h"
21 #include "../mesh/mesh.h"
22 #include "exceptions.h"
23 
24 namespace Hermes
25 {
26  namespace Hermes2D
27  {
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43  template<typename Scalar>
44  class HERMES_API MeshFunction : public Function<Scalar>, public Hermes::Hermes2D::Mixins::StateQueryable
45  {
46  public:
47 
48  MeshFunction();
49  MeshFunction(const Mesh *mesh);
50  virtual ~MeshFunction();
51 
53  virtual bool isOkay() const;
54  inline std::string getClassName() const { return "MeshFunction"; }
55 
56  virtual void init();
57  virtual void reinit();
58 
59  virtual void set_quad_2d(Quad2D* quad_2d);
60 
61  virtual void set_active_element(Element* e);
62 
63  const Mesh* get_mesh() const;
64  RefMap* get_refmap(bool update = true);
65  void set_refmap(RefMap* refmap_to_set);
66 
67  virtual int get_edge_fn_order(int edge);
68 
70  virtual Func<Scalar>* get_pt_value(double x, double y) = 0;
71 
74  virtual void handle_overflow_idx();
75 
77  virtual void push_transform(int son);
78 
79  virtual void pop_transform();
80 
81  virtual MeshFunction<Scalar>* clone() const
82  {
83  throw Hermes::Exceptions::Exception("You need to implement MeshFunction::clone() to be able to use paralellization");
84  return NULL;
85  }
86 
87  protected:
88  ElementMode2D mode;
89  const Mesh* mesh;
90  RefMap* refmap;
91 
92  void force_transform(MeshFunction<Scalar>* mf);
93 
94  void update_refmap();
95 
96  void force_transform(uint64_t sub_idx, Trf* ctm);
97 
98  friend class RefMap;
99  template<typename T> friend class KellyTypeAdapt;
100  template<typename T> friend class Adapt;
101 
102  template<typename T> friend class Func;
103  template<typename T> friend class Geom;
104 
105  template<typename T> friend HERMES_API Func<T>* init_fn(MeshFunction<T>*fu, const int order);
106 
107  template<typename T> friend class DiscontinuousFunc;
108  template<typename T> friend class DiscreteProblem;
109  template<typename T> friend class DiscreteProblemLinear;
110  template<typename T> friend class NeighborSearch;
111  };
112  }
113 }
114 
115 #endif