HermesCommon  2.0
hermes_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_HERMES_FUNCTION_H
17 #define __H2D_HERMES_FUNCTION_H
18 
19 #include "compat.h"
20 #include "ord.h"
21 #include "exceptions.h"
22 #include "mixins.h"
23 
24 namespace Hermes
25 {
26  struct HERMES_API SplineCoeff
27  {
28  double a, b, c, d; // four coefficients of a cubic spline.
29  };
30 
41  template<typename Scalar>
42  class HERMES_API Hermes1DFunction : public Hermes::Mixins::Loggable
43  {
44  public:
47 
49  Hermes1DFunction(Scalar value);
50 
52  virtual Scalar value(Scalar x) const;
53 
55  virtual Hermes::Ord value(Hermes::Ord x) const;
56 
58  virtual Scalar derivative(Scalar x) const;
59 
61  virtual Hermes::Ord derivative(Hermes::Ord x) const;
62 
65  bool is_constant() const;
66 
67  protected:
69  bool is_const;
71  Scalar const_value;
72  };
73 
84  template<typename Scalar>
85  class HERMES_API Hermes2DFunction : public Hermes::Mixins::Loggable
86  {
87  public:
90 
92  Hermes2DFunction(Scalar value);
93 
95  virtual Scalar value(Scalar x, Scalar y) const;
96 
98  virtual Hermes::Ord value(Hermes::Ord x, Hermes::Ord y) const;
99 
101  virtual Scalar derivative_x(Scalar x, Scalar y) const;
102  virtual Scalar derivative_y(Scalar x, Scalar y) const;
103 
105  virtual Hermes::Ord derivative_x(Hermes::Ord x, Hermes::Ord y) const;
106  virtual Hermes::Ord derivative_y(Hermes::Ord x, Hermes::Ord y) const;
107 
110  bool is_constant() const;
111 
112  protected:
114  bool is_const;
116  Scalar const_value;
117  };
118 
128  template<typename Scalar>
129  class HERMES_API Hermes3DFunction : public Hermes::Mixins::Loggable
130  {
131  public:
134 
136  Hermes3DFunction(Scalar value);
137 
139  virtual Scalar value(Scalar x, Scalar y, Scalar z) const;
140 
142  virtual Hermes::Ord value(Hermes::Ord x, Hermes::Ord y, Hermes::Ord z) const;
143 
145  virtual Scalar derivative_x(Scalar x, Scalar y, Scalar z) const;
146  virtual Scalar derivative_y(Scalar x, Scalar y, Scalar z) const;
147  virtual Scalar derivative_z(Scalar x, Scalar y, Scalar z) const;
148 
150  virtual Hermes::Ord derivative_x(Hermes::Ord x, Hermes::Ord y, Hermes::Ord z) const;
151  virtual Hermes::Ord derivative_y(Hermes::Ord x, Hermes::Ord y, Hermes::Ord z) const;
152  virtual Hermes::Ord derivative_z(Hermes::Ord x, Hermes::Ord y, Hermes::Ord z) const;
153 
156  bool is_constant() const;
157 
158  protected:
160  bool is_const;
162  Scalar const_value;
163  };
164 }
165 
166 #endif