HermesCommon  3.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 "util/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  // four coefficients of a cubic spline.
29  double a, b, c, d;
30  };
31 
42  template<typename Scalar>
43  class HERMES_API Hermes1DFunction : public Hermes::Mixins::Loggable
44  {
45  public:
48 
50  Hermes1DFunction(Scalar value);
51 
53  virtual Scalar value(Scalar x) const;
54 
56  virtual Hermes::Ord value(Hermes::Ord x) const;
57 
59  virtual Scalar derivative(Scalar x) const;
60 
62  virtual Hermes::Ord derivative(Hermes::Ord x) const;
63 
66  bool is_constant() const;
67 
68  protected:
70  bool is_const;
72  Scalar const_value;
73  };
74 
85  template<typename Scalar>
86  class HERMES_API Hermes2DFunction : public Hermes::Mixins::Loggable
87  {
88  public:
91 
93  Hermes2DFunction(Scalar value);
94 
96  virtual Scalar value(Scalar x, Scalar y) const;
97 
99  virtual Hermes::Ord value(Hermes::Ord x, Hermes::Ord y) const;
100 
102  virtual Scalar derivative_x(Scalar x, Scalar y) const;
103  virtual Scalar derivative_y(Scalar x, Scalar y) const;
104 
106  virtual Hermes::Ord derivative_x(Hermes::Ord x, Hermes::Ord y) const;
107  virtual Hermes::Ord derivative_y(Hermes::Ord x, Hermes::Ord y) const;
108 
111  bool is_constant() const;
112 
113  protected:
115  bool is_const;
117  Scalar const_value;
118  };
119 
129  template<typename Scalar>
130  class HERMES_API Hermes3DFunction : public Hermes::Mixins::Loggable
131  {
132  public:
135 
137  Hermes3DFunction(Scalar value);
138 
140  virtual Scalar value(Scalar x, Scalar y, Scalar z) const;
141 
143  virtual Hermes::Ord value(Hermes::Ord x, Hermes::Ord y, Hermes::Ord z) const;
144 
146  virtual Scalar derivative_x(Scalar x, Scalar y, Scalar z) const;
147  virtual Scalar derivative_y(Scalar x, Scalar y, Scalar z) const;
148  virtual Scalar derivative_z(Scalar x, Scalar y, Scalar z) const;
149 
151  virtual Hermes::Ord derivative_x(Hermes::Ord x, Hermes::Ord y, Hermes::Ord z) const;
152  virtual Hermes::Ord derivative_y(Hermes::Ord x, Hermes::Ord y, Hermes::Ord z) const;
153  virtual Hermes::Ord derivative_z(Hermes::Ord x, Hermes::Ord y, Hermes::Ord z) const;
154 
157  bool is_constant() const;
158 
159  protected:
161  bool is_const;
163  Scalar const_value;
164  };
165 }
166 
167 #endif
Scalar const_value
If the function is constant, this is the value.
General namespace for the Hermes library.
Scalar const_value
If the function is constant, this is the value.
bool is_const
The function is constant.
File containing definition of exceptions classes.
bool is_const
The function is constant.
Scalar const_value
If the function is constant, this is the value.
File containing platform compatibility layer, especially for Win / MSVC.
Mix-in classes for one functionality, for various classes to be derived from.
Contains class Ord for calculation of integration order.
bool is_const
The function is constant.
Class the output of which is loggable, i.e. that uses functionality of info(), warn() Contains the cl...
Definition: mixins.h:62