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
eye.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 __Eye_H
30 #define __Eye_H 1
31 
32 #include <blitz/array.h>
33 
34 
35 namespace Feel
36 {
37 namespace vf
38 {
40 namespace detail
41 {
48 template<int M, int N = M>
49 class Eye
50 {
51 public:
52 
53 
57  static const size_type context = 0;
58 
59  static const uint16_type imorder = 0;
60  static const bool imIsPoly = true;
61 
62  template<typename Func>
63  struct HasTestFunction
64  {
65  static const bool result = false;
66  };
67 
68  template<typename Func>
69  struct HasTrialFunction
70  {
71  static const bool result = false;
72  };
73 
74  typedef Eye<M,N> this_type;
75  typedef double value_type;
77 
81 
82  Eye()
83  :
84  M_eye( M, N )
85  {
86  blitz::firstIndex i;
87  blitz::secondIndex j;
88  M_eye = !( i-j );
89  }
90 
91  Eye( Eye const & eig )
92  :
93  M_eye( eig.M_eye )
94  {
95  }
96  ~Eye()
97  {}
98 
100 
104 
105 
107 
111 
112 
114 
118 
119 
121 
125 
126  blitz::Array<value_type,2> eye() const
127  {
128  return M_eye;
129  }
130 
132  template<typename Geo_t, typename Basis_i_t, typename Basis_j_t>
133  struct tensor
134  {
135  typedef this_type expression_type;
136  typedef typename expression_type::value_type value_type;
137  typedef value_type return_value_type;
138  typedef typename mpl::if_<fusion::result_of::has_key<Geo_t, vf::detail::gmc<0> >,
139  mpl::identity<vf::detail::gmc<0> >,
140  mpl::identity<vf::detail::gmc<1> > >::type::type key_type;
141  typedef typename fusion::result_of::value_at_key<Geo_t,key_type>::type::element_type* gmc_ptrtype;
142  typedef typename fusion::result_of::value_at_key<Geo_t,key_type>::type::element_type gmc_type;
143 
144  struct INVALID_SHAPE {};
145  static const bool eq11 = M==1&&N==1;
146  static const bool eqD1 = M==gmc_type::nDim&&N==1;
147  static const bool eq1D = M==1&&N==gmc_type::nDim;
148  static const bool eqDD = M==gmc_type::nDim&&N==gmc_type::nDim;
149  typedef typename mpl::if_< mpl::bool_<eq11>,
150  mpl::identity<Shape<gmc_type::nDim, Scalar, false, false> >,
151  typename mpl::if_< mpl::bool_<eqD1>,
152  mpl::identity<Shape<gmc_type::nDim, Vectorial, false, false> >,
153  typename mpl::if_< mpl::bool_<eq1D>,
154  mpl::identity<Shape<gmc_type::nDim, Vectorial, true, false> >,
155  typename mpl::if_< mpl::bool_<eqDD>,
156  mpl::identity<Shape<gmc_type::nDim, Tensor2, false, false> >,
157  mpl::identity<INVALID_SHAPE> >::type>::type>::type>::type::type shape;
158 
159 
160  template <class Args> struct sig
161  {
162  typedef value_type type;
163  };
164 
165  tensor( this_type const& expr,Geo_t const&, Basis_i_t const&, Basis_j_t const& )
166  :
167  M_expr( expr )
168  {
169  }
170 
171  tensor( this_type const& expr,Geo_t const&, Basis_i_t const& )
172  :
173  M_expr( expr )
174  {
175  }
176 
177  tensor( this_type const& expr, Geo_t const& )
178  :
179  M_expr( expr )
180  {
181  }
182 
183  void update( Geo_t const&, Basis_i_t const&, Basis_j_t const& )
184  {
185  }
186  void update( Geo_t const&, Basis_i_t const& )
187  {
188  }
189  void update( Geo_t const& )
190  {
191  }
192 
193 
194  value_type
195  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q ) const
196  {
197  Feel::detail::ignore_unused_variable_warning( i );
198  Feel::detail::ignore_unused_variable_warning( j );
199  Feel::detail::ignore_unused_variable_warning( q );
200  return eval( c1, c2, mpl::bool_<shape::is_scalar>() );
201  }
202 
203  template<int PatternContext>
204  value_type
205  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q,
206  mpl::int_<PatternContext> ) const
207  {
208  Feel::detail::ignore_unused_variable_warning( i );
209  Feel::detail::ignore_unused_variable_warning( j );
210  Feel::detail::ignore_unused_variable_warning( q );
211  return eval( c1, c2, mpl::bool_<shape::is_scalar>() );
212  }
213 
214  value_type
215  evaliq( uint16_type i, uint16_type c1, uint16_type c2, uint16_type q ) const
216  {
217  Feel::detail::ignore_unused_variable_warning( i );
218  Feel::detail::ignore_unused_variable_warning( q );
219  return eval( c1, c2, mpl::bool_<shape::is_scalar>() );
220  }
221  value_type
222  evalq( uint16_type c1, uint16_type c2, uint16_type q ) const
223  {
224  Feel::detail::ignore_unused_variable_warning( q );
225  return eval( c1, c2, mpl::bool_<shape::is_scalar>() );
226  }
227  private:
228  value_type
229  eval( int c1, int c2, mpl::bool_<true> ) const
230  {
231  Feel::detail::ignore_unused_variable_warning( c1 );
232  Feel::detail::ignore_unused_variable_warning( c2 );
233  return M_expr.eye()( 0, 0 );
234  }
235  value_type
236  eval( int c1, int c2, mpl::bool_<false> ) const
237  {
238  return M_expr.eye()( c1, c2 );
239  }
240  this_type M_expr;
241  };
242 private:
243  blitz::Array<value_type,2> M_eye;
244 
245 };
246 } // detail
248 
255 template<int M, int N>
256 inline
257 Expr<vf::detail::Eye<M,N> >
258 eye()
259 {
260  return Expr< vf::detail::Eye<M,N> >( vf::detail::Eye<M, N>() );
261 }
262 } // vf
263 } // Feel
264 #endif /* __Eye_H */

Generated on Fri Oct 25 2013 14:24:09 for Feel++ by doxygen 1.8.4