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
ones.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-04-11
7 
8  Copyright (C) 2007 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 __Ones_H
30 #define __Ones_H 1
31 
32 //#include <blitz/array.h>
33 #include <boost/multi_array.hpp>
34 
35 
36 namespace Feel
37 {
38 namespace vf
39 {
41 namespace detail
42 {
56 template<int M, int N>
57 class Ones
58 {
59 public:
60 
61 
65  static const size_type context = 0;
66 
67  static const uint16_type imorder = 0;
68  static const bool imIsPoly = true;
69  static const bool is_terminal = true;
70 
71  template<typename Func>
72  struct HasTestFunction
73  {
74  static const bool result = false;
75  };
76 
77  template<typename Func>
78  struct HasTrialFunction
79  {
80  static const bool result = false;
81  };
82 
83  typedef Ones<M,N> this_type;
84  typedef double value_type;
86 
90 
91  template<typename EigenMatrix>
92  Ones( EigenMatrix const& m )
93  :
94  M_values( m )
95  {
96 
97  }
98 
99  Ones( Ones const & eig )
100  :
101  M_values( eig.M_values )
102  {}
103  ~Ones()
104  {}
105 
107 
111 
112 
114 
118 
119 
121 
125 
126 
128 
132 
133  //blitz::Array<value_type,2> ones() const { return M_values; }
134  Eigen::Matrix<double,M,N> const& ones() const
135  {
136  return M_values;
137  }
138 
140  template<typename Geo_t, typename Basis_i_t, typename Basis_j_t>
141  struct tensor
142  {
143  typedef this_type expression_type;
144  typedef typename expression_type::value_type value_type;
145  typedef value_type return_value_type;
146  typedef typename mpl::if_<fusion::result_of::has_key<Geo_t,vf::detail::gmc<0> >,
147  mpl::identity<vf::detail::gmc<0> >,
148  mpl::identity<vf::detail::gmc<1> > >::type::type key_type;
149  typedef typename fusion::result_of::value_at_key<Geo_t,key_type>::type::element_type* gmc_ptrtype;
150  typedef typename fusion::result_of::value_at_key<Geo_t,key_type>::type::element_type gmc_type;
151 
152  struct INVALID_SHAPE {};
153  static const bool eq11 = ( M==1 )&&( N==1 );
154  static const bool eqD1 = ( M==gmc_type::nDim )&&( N==1 );
155  static const bool eq1D = ( M==1 )&&( N==gmc_type::nDim );
156  static const bool eqDD = ( M==gmc_type::nDim )&&( N==gmc_type::nDim );
157  typedef typename mpl::if_< mpl::bool_<eq11>,
158  mpl::identity<Shape<gmc_type::nDim, Scalar, false, false> >,
159  typename mpl::if_< mpl::bool_<eqD1>,
160  mpl::identity<Shape<gmc_type::nDim, Vectorial, false, false> >,
161  typename mpl::if_< mpl::bool_<eq1D>,
162  mpl::identity<Shape<gmc_type::nDim, Vectorial, true, false> >,
163  typename mpl::if_< mpl::bool_<eqDD>,
164  mpl::identity<Shape<gmc_type::nDim, Tensor2, false, false> >,
165  mpl::identity<INVALID_SHAPE> >::type>::type>::type>::type::type shape;
166 
167 
168  template <class Args> struct sig
169  {
170  typedef value_type type;
171  };
172 
173  struct is_zero
174  {
175  static const bool value = false;
176  };
177 
178  tensor( this_type const& expr,Geo_t const&, Basis_i_t const&, Basis_j_t const& )
179  :
180  M_expr( expr ),
181  M_values( expr.ones() )
182  {
183  //std::cout << "tensor::ones = " << M_expr.ones() << "\n";
184  }
185 
186  tensor( this_type const& expr,Geo_t const&, Basis_i_t const& )
187  :
188  M_expr( expr ),
189  M_values( expr.ones() )
190  {
191  }
192 
193  tensor( this_type const& expr, Geo_t const& )
194  :
195  M_expr( expr ),
196  M_values( expr.ones() )
197  {
198  }
199  template<typename IM>
200  void init( IM const& /*im*/ )
201  {
202  }
203 
204  void update( Geo_t const&, Basis_i_t const&, Basis_j_t const& )
205  {
206  }
207  void update( Geo_t const&, Basis_i_t const& )
208  {
209  }
210  void update( Geo_t const& )
211  {
212  }
213 
214 
215  value_type
216  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q ) const
217  {
218  Feel::detail::ignore_unused_variable_warning( i );
219  Feel::detail::ignore_unused_variable_warning( j );
220  Feel::detail::ignore_unused_variable_warning( q );
221  return eval( c1, c2, mpl::int_<shape::rank>() );
222  }
223 
224  template<int PatternContext>
225  value_type
226  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q,
227  mpl::int_<PatternContext> ) const
228  {
229  Feel::detail::ignore_unused_variable_warning( i );
230  Feel::detail::ignore_unused_variable_warning( j );
231  Feel::detail::ignore_unused_variable_warning( q );
232  return eval( c1, c2, mpl::int_<shape::rank>() );
233  }
234 
235  value_type
236  evaliq( uint16_type i, uint16_type c1, uint16_type c2, uint16_type q ) const
237  {
238  Feel::detail::ignore_unused_variable_warning( i );
239  Feel::detail::ignore_unused_variable_warning( q );
240  return eval( c1, c2, mpl::int_<shape::rank>() );
241  }
242  value_type
243  evalq( uint16_type c1, uint16_type c2, uint16_type q ) const
244  {
245  Feel::detail::ignore_unused_variable_warning( q );
246  return eval( c1, c2, mpl::int_<shape::rank>() );
247  }
248  private:
249  value_type
250  eval( int c1, int c2, mpl::int_<0> ) const
251  {
252  Feel::detail::ignore_unused_variable_warning( c1 );
253  Feel::detail::ignore_unused_variable_warning( c2 );
254  return M_values(0,0);
255  }
256  value_type
257  eval( int c1, int c2, mpl::int_<1> ) const
258  {
259  if ( shape::is_transposed )
260  return M_values(0,c2);
261 
262  return M_values(c1,0);
263  }
264  value_type
265  eval( int c1, int c2, mpl::int_<2> ) const
266  {
267  return M_values(c1,c2);
268  }
269  this_type M_expr;
270  Eigen::Matrix<double,M,N> M_values;
271  };
272 private:
273  Eigen::Matrix<double,M,N> M_values;
274 
275 };
276 } // detail
278 
292 template<int M, int N=M>
293 inline
294 Expr<vf::detail::Ones<M,N> >
295 ones()
296 {
297  return Expr<vf::detail::Ones<M,N> >( vf::detail::Ones<M, N>(Eigen::Matrix<double,M,N>::Ones()) );
298 }
299 
300 template<int M, int N=M>
301 inline
302 Expr<vf::detail::Ones<M,N> >
303 zero()
304 {
305  return Expr<vf::detail::Ones<M,N> >( vf::detail::Ones<M, N>(Eigen::Matrix<double,M,N>::Zero()) );
306 }
307 
308 template<int M, int N=M>
309 inline
310 Expr<vf::detail::Ones<M,N> >
311 eye()
312 {
313  return Expr<vf::detail::Ones<M,N> >( vf::detail::Ones<M, N>(Eigen::Matrix<double,M,N>::Identity()) );
314 }
315 
316 template<int M, int N=M>
317 inline
318 Expr<vf::detail::Ones<M,N> >
319 Id()
320 {
321  return Expr<vf::detail::Ones<M,N> >( vf::detail::Ones<M, N>(Eigen::Matrix<double,M,N>::Identity()) );
322 }
323 
324 template<int M, int N=M>
325 inline
326 Expr<vf::detail::Ones<M,N> >
327 constant( double value )
328 {
329  return Expr<vf::detail::Ones<M,N> >( vf::detail::Ones<M, N>(Eigen::Matrix<double,M,N>::Constant( value )) );
330 }
331 
332 } // vf
333 } // Feel
334 #endif /* __Ones_H */

Generated on Sun Oct 20 2013 08:25:02 for Feel++ by doxygen 1.8.4