G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsFunctionExpr.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsCore/gsFunction.h>
17 
18 namespace gismo
19 {
20 
50 template<typename T>
51 class gsFunctionExpr : public gsFunction<T>
52 {
53 public:
54  typedef T Scalar_t;
55 
57  typedef memory::shared_ptr< gsFunctionExpr > Ptr;
58 
60  typedef memory::unique_ptr<gsFunctionExpr> uPtr;
61 
62 public:
63 
66 
68  gsFunctionExpr(const std::string & expression_string, short_t ddim);
69 
71  gsFunctionExpr(const std::string & expression_string1,
72  const std::string & expression_string2,
73  short_t ddim);
74 
76  gsFunctionExpr(const std::string & expression_string1,
77  const std::string & expression_string2,
78  const std::string & expression_string3,
79  short_t ddim);
80 
82  gsFunctionExpr(const std::string & expression_string1,
83  const std::string & expression_string2,
84  const std::string & expression_string3,
85  const std::string & expression_string4,
86  short_t ddim);
87 
89  gsFunctionExpr(const std::string & expression_string1,
90  const std::string & expression_string2,
91  const std::string & expression_string3,
92  const std::string & expression_string4,
93  const std::string & expression_string5,
94  const std::string & expression_string6,
95  const std::string & expression_string7,
96  const std::string & expression_string8,
97  const std::string & expression_string9,
98  short_t ddim);
99 
100  gsFunctionExpr(const std::vector<std::string> & expression_string, short_t ddim);
101 
102  gsFunctionExpr(const gsFunctionExpr& other);
103 
105  static uPtr make(const std::string & expression_string, short_t ddim)
106  { return uPtr(new gsFunctionExpr(expression_string, ddim)); }
107 
109  static uPtr make(const std::string & expression_string1, const std::string & expression_string2, short_t ddim)
110  { return uPtr(new gsFunctionExpr(expression_string1, expression_string2, ddim)); }
111 
113  static uPtr make(const std::string & expression_string1, const std::string & expression_string2,
114  const std::string & expression_string3, short_t ddim)
115  { return uPtr(new gsFunctionExpr(expression_string1, expression_string2, expression_string3, ddim)); }
116 
118  static uPtr make(const std::string & expression_string1, const std::string & expression_string2,
119  const std::string & expression_string3, const std::string & expression_string4, short_t ddim)
120  { return uPtr(new gsFunctionExpr(expression_string1, expression_string2, expression_string3, expression_string4, ddim)); }
121 
123  static uPtr make(const std::string & expression_string1, const std::string & expression_string2,
124  const std::string & expression_string3, const std::string & expression_string4,
125  const std::string & expression_string5, const std::string & expression_string6,
126  const std::string & expression_string7, const std::string & expression_string8,
127  const std::string & expression_string9, short_t ddim)
128  { return uPtr(new gsFunctionExpr(expression_string1, expression_string2, expression_string3, expression_string4,
129  expression_string5, expression_string6, expression_string7, expression_string8, expression_string9, ddim)); }
130 
131 #if EIGEN_HAS_RVALUE_REFERENCES
133 
134  gsFunctionExpr& operator=(const gsFunctionExpr& other);
135 
136  gsFunctionExpr& operator=(gsFunctionExpr&& other);
137 #else
138  gsFunctionExpr& operator=(gsFunctionExpr other);
139 #endif
140 
141  ~gsFunctionExpr();
142 
143  GISMO_CLONE_FUNCTION(gsFunctionExpr)
144 
145 
146  void addComponent(const std::string & strExpression);
147 
148 private:
149 
150  // initializes the symbol table
151  void init(const short_t dim);
152 
153 public:
154 
155  // Function expression can be used as a global function defined
156  // for any real value, on any subdomain
157  virtual const gsFunctionExpr & piece(const index_t) const
158  {
159  return *this;
160  }
161 
162  // Documented in gsFunction class
163  short_t domainDim() const;
164 
165  // Documented in gsFunction class
166  short_t targetDim() const;
167 
168  // returns the string expression for component \a i
169  const std::string & expression(int i = 0) const;
170 
172  void set_x (T const & v) const;
174  void set_y (T const & v) const;
176  void set_z (T const & v) const;
178  void set_w (T const & v) const;
180  void set_u (T const & v) const;
182  void set_v (T const & v) const;
184  void set_t (T const & t) const;
185 
186  // see gsFunction for documentation
187  virtual void eval_into(const gsMatrix<T>& u, gsMatrix<T>& result) const;
188 
189  // see gsFunction for documentation
190  virtual void eval_component_into(const gsMatrix<T>& u,
191  const index_t comp,
192  gsMatrix<T>& result) const;
193 
194  // see gsFunction for documentation
195  virtual void deriv_into(const gsMatrix<T>& u,
196  gsMatrix<T>& result) const;
197 
198  // see gsFunction for documentation
199  virtual void deriv2_into(const gsMatrix<T>& u,
200  gsMatrix<T>& result) const;
201 
202  // see gsFunction for documentation
203  gsMatrix<T> hess(const gsMatrix<T>& u, unsigned coord = 0) const;
204 
205  // see gsFunction for documentation
206  gsMatrix<T> laplacian(const gsMatrix<T>& u) const;
207 
209  gsMatrix<T> * mderiv(const gsMatrix<T>& u, const index_t k, const index_t j) const;
210 
211  // see gsFunction for documentation
212  std::ostream &print(std::ostream &os) const;
213 
214  void swap(gsFunctionExpr& other)
215  { std::swap(this->my, other.my); }
216 
217 // Data members
218 private:
219  class gsFunctionExprPrivate;
220  typedef gsFunctionExprPrivate PrivateData_t;
221 
222  PrivateData_t * my;
223 
224 }; // class gsFunctionExpr
225 
226 
227 #ifdef GISMO_WITH_PYBIND11
228 
232  void pybind11_init_gsFunctionExpr(pybind11::module &m);
233 
234 #endif // GISMO_WITH_PYBIND11
235 
236 } // namespace gismo
237 
238 
239 #ifndef GISMO_BUILD_LIB
240 #include GISMO_HPP_HEADER(gsFunctionExpr.hpp)
241 #endif
gsMatrix< T > laplacian(const gsMatrix< T > &u) const
Evaluate the Laplacian at points u.
Definition: gsFunctionExpr.hpp:708
virtual void eval_component_into(const gsMatrix< T > &u, const index_t comp, gsMatrix< T > &result) const
Evaluate the function for component comp in the target dimension at points u into result...
Definition: gsFunctionExpr.hpp:536
virtual void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate second derivatives of the function at points u into result.
Definition: gsFunctionExpr.hpp:588
virtual void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate derivatives of the function at points u into result.
Definition: gsFunctionExpr.hpp:559
void set_z(T const &v) const
Sets the symbol &quot;z&quot; to a value.
Definition: gsFunctionExpr.hpp:498
short_t targetDim() const
Dimension of the target space.
Definition: gsFunctionExpr.hpp:474
#define short_t
Definition: gsConfig.h:35
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the function at points u into result.
Definition: gsFunctionExpr.hpp:513
void set_u(T const &v) const
Sets the symbol &quot;u&quot; to a value.
Definition: gsFunctionExpr.hpp:504
void addComponent(const std::string &strExpression)
Adds another component to this (vector) function.
Definition: gsFunctionExpr.hpp:480
#define index_t
Definition: gsConfig.h:32
void set_y(T const &v) const
Sets the symbol &quot;y&quot; to a value.
Definition: gsFunctionExpr.hpp:495
A function from a n-dimensional domain to an m-dimensional image.
Definition: gsFunction.h:59
memory::unique_ptr< gsFunction > uPtr
Unique pointer for gsFunction.
Definition: gsFunction.h:68
void set_v(T const &v) const
Sets the symbol &quot;v&quot; to a value.
Definition: gsFunctionExpr.hpp:507
virtual const gsFunctionExpr & piece(const index_t) const
Returns the piece(s) of the function(s) at subdomain k.
Definition: gsFunctionExpr.h:157
static uPtr make(const std::string &expression_string1, const std::string &expression_string2, const std::string &expression_string3, const std::string &expression_string4, const std::string &expression_string5, const std::string &expression_string6, const std::string &expression_string7, const std::string &expression_string8, const std::string &expression_string9, short_t ddim)
Make function taking nine expression strings (9D vector valued function) used for (3x3) matrix coeffi...
Definition: gsFunctionExpr.h:123
static uPtr make(const std::string &expression_string1, const std::string &expression_string2, short_t ddim)
Make function taking two expression strings (2D vector valued function)
Definition: gsFunctionExpr.h:109
gsMatrix< T > * mderiv(const gsMatrix< T > &u, const index_t k, const index_t j) const
Mixed derivative wrt variables k and j.
Definition: gsFunctionExpr.hpp:677
memory::shared_ptr< gsFunctionExpr > Ptr
Shared pointer for gsFunctionExpr.
Definition: gsFunctionExpr.h:57
short_t domainDim() const
Dimension of the (source) domain.
Definition: gsFunctionExpr.hpp:468
static uPtr make(const std::string &expression_string, short_t ddim)
Make function taking an expression string and the domain dimension (scalar function) ...
Definition: gsFunctionExpr.h:105
void set_t(T const &t) const
Sets the symbol &quot;t&quot; to a value.
Definition: gsFunctionExpr.hpp:510
gsFuncCoordinate< T > coord(const index_t c) const
Returns the scalar function giving the i-th coordinate of this function.
Definition: gsFunction.hpp:32
void set_x(T const &v) const
Sets the symbol &quot;x&quot; to a value.
Definition: gsFunctionExpr.hpp:492
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsFunctionExpr.hpp:740
static uPtr make(const std::string &expression_string1, const std::string &expression_string2, const std::string &expression_string3, const std::string &expression_string4, short_t ddim)
Make function taking four expression strings (4D vector valued function) used for matrix coefficients...
Definition: gsFunctionExpr.h:118
memory::unique_ptr< gsFunctionExpr > uPtr
Unique pointer for gsFunctionExpr.
Definition: gsFunctionExpr.h:60
Class defining a multivariate (real or vector) function given by a string mathematical expression...
Definition: gsFunctionExpr.h:51
gsFunctionExpr()
Default empty constructor.
Definition: gsFunctionExpr.hpp:338
Provides declaration of Function abstract interface.
static uPtr make(const std::string &expression_string1, const std::string &expression_string2, const std::string &expression_string3, short_t ddim)
Make function taking two expression strings (3D vector valued function)
Definition: gsFunctionExpr.h:113
void set_w(T const &v) const
Sets the symbol &quot;w&quot; to a value.
Definition: gsFunctionExpr.hpp:501