Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
function.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2007-07-20
7 
8  Copyright (C) 2007-2012 Universite Joseph Fourier (Grenoble I)
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 3.0 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
29 #ifndef __Function_H
30 #define __Function_H 1
31 
32 namespace Feel
33 {
34 namespace vf
35 {
37 
44 template<typename Func>
45 class Function
46 {
47 public:
48 
49 
53 
54 
55  static const size_type context = vm::POINT;
56  static const bool is_terminal = false;
57  static const uint16_type imorder = Func::imorder;
58  static const bool imIsPoly = Func::imIsPoly;
59 
60  template<typename Funct>
61  struct HasTestFunction
62  {
63  static const bool result = false;
64  };
65  template<typename Funct>
66  struct HasTrialFunction
67  {
68  static const bool result = false;
69  };
70 
71  typedef Func expression_type;
72  typedef Function<Func> this_type;
73  typedef typename expression_type::value_type value_type;
75 
79 
80  explicit Function( expression_type const & fun )
81  :
82  M_fun( fun )
83  {}
84  Function( Function const & fun )
85  :
86  M_fun( fun.M_fun )
87  {}
88  ~Function()
89  {}
90 
92 
96 
97 
99 
103 
104 
106 
110 
111 
113 
117 
118  const expression_type& fun() const
119  {
120  return M_fun;
121  }
122 
124 
125 
126  template<typename Geo_t, typename Basis_i_t, typename Basis_j_t>
127  struct tensor
128  {
129  typedef typename expression_type::value_type value_type;
130 
131  typedef typename mpl::if_<fusion::result_of::has_key<Geo_t,vf::detail::gmc<0> >,
132  mpl::identity<vf::detail::gmc<0> >,
133  mpl::identity<vf::detail::gmc<1> > >::type::type key_type;
134  typedef typename fusion::result_of::value_at_key<Geo_t,key_type>::type::element_type* gmc_ptrtype;
135  typedef typename fusion::result_of::value_at_key<Geo_t,key_type>::type::element_type gmc_type;
136  typedef typename mpl::if_<mpl::equal_to<mpl::int_<Func::rank>,mpl::int_<0> >,
137  mpl::identity<Shape<gmc_type::nDim, Scalar, false, false> >,
138  typename mpl::if_<mpl::equal_to<mpl::int_<Func::rank>,mpl::int_<1> >,
139  mpl::identity<Shape<gmc_type::nDim, Vectorial, false, false> >,
140  mpl::identity<Shape<gmc_type::nDim, Tensor2, false, false> > >::type >::type::type shape;
141 
142  struct is_zero
143  {
144  static const bool value = false;
145  };
146 
147  tensor( this_type const& expr,
148  Geo_t const& geom, Basis_i_t const& /*fev*/, Basis_j_t const& /*feu*/ )
149  :
150  M_fun( expr.fun() ),
151  M_gmc( fusion::at_key<key_type>( geom ).get() )
152  {}
153 
154  tensor( this_type const& expr,
155  Geo_t const& geom, Basis_i_t const& /*fev*/ )
156  :
157  M_fun( expr.fun() ),
158  M_gmc( fusion::at_key<key_type>( geom ).get() )
159  {}
160 
161  tensor( this_type const& expr, Geo_t const& geom )
162  :
163  M_fun( expr.fun() ),
164  M_gmc( fusion::at_key<key_type>( geom ).get() )
165  {
166  }
167 
168  template<typename IM>
169  void init( IM const& im )
170  {
171 
172  }
173  void update( Geo_t const& geom, Basis_i_t const& /*fev*/, Basis_j_t const& /*feu*/ )
174  {
175  update( geom );
176  }
177  void update( Geo_t const& geom, Basis_i_t const& /*fev*/ )
178  {
179  update( geom );
180  }
181  void update( Geo_t const& geom )
182  {
183  M_gmc = fusion::at_key<key_type>( geom ).get();
184  }
185 
186  void update( Geo_t const& geom, uint16_type /*face*/ )
187  {
188  M_gmc = fusion::at_key<key_type>( geom ).get();
189  }
190 
191 
192  value_type
193  evalij( uint16_type i, uint16_type j ) const
194  {
195  return 0;
196  }
197 
198 
199  value_type
200  evalijq( uint16_type /*i*/, uint16_type /*j*/, uint16_type c1, uint16_type c2, uint16_type q ) const
201  {
202  return M_fun( c1, c2, M_gmc->xReal( q ), M_gmc->unitNormal( q ) );
203  }
204  template<int PatternContext>
205  value_type
206  evalijq( uint16_type /*i*/, uint16_type /*j*/, uint16_type c1, uint16_type c2, uint16_type q,
207  mpl::int_<PatternContext> ) const
208  {
209  return M_fun( c1, c2, M_gmc->xReal( q ), M_gmc->unitNormal( q ) );
210  }
211 
212 
213 
214  value_type
215  evaliq( uint16_type i, uint16_type c1, uint16_type c2, uint16_type q ) const
216  {
217  return M_fun( c1, c2, M_gmc->xReal( q ), M_gmc->unitNormal( q ) );
218  }
219 
220  value_type
221  evalq( uint16_type c1, uint16_type c2, uint16_type q ) const
222  {
223  return M_fun( c1, c2, M_gmc->xReal( q ), M_gmc->unitNormal( q ) );
224  }
225 
226  Func M_fun;
227  gmc_ptrtype M_gmc;
228  };
229 
230 private:
231  mutable expression_type M_fun;
232 };
234 
239 template<typename Func>
240 inline
241 Expr< Function<Func> >
242 idf( Func f )
243 {
244  typedef Function<Func> func_t;
245  return Expr< func_t >( func_t( f ) );
246 }
247 
248 } // vf
249 } // Feel
250 #endif /* __Function_H */
size_t size_type
Indices (starting from 0)
Definition: feelcore/feel.hpp:319

Generated on Sun Dec 22 2013 13:11:00 for Feel++ by doxygen 1.8.5