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
trace.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-02-10
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 __Trace_H
30 #define __Trace_H 1
31 
32 namespace Feel
33 {
34 namespace vf
35 {
37 
44 template<typename ExprT>
45 class Trace
46 {
47 public:
48 
49  static const size_type context = ExprT::context;
50  static const bool is_terminal = false;
51 
52  static const uint16_type imorder = ExprT::imorder;
53  static const bool imIsPoly = ExprT::imIsPoly;
54 
55  template<typename Func>
56  struct HasTestFunction
57  {
58  static const bool result = ExprT::template HasTestFunction<Func>::result;
59  };
60 
61  template<typename Func>
62  struct HasTrialFunction
63  {
64  static const bool result = ExprT::template HasTrialFunction<Func>::result;
65  };
66 
67 
71 
72  typedef ExprT expression_type;
73  typedef typename expression_type::value_type value_type;
74  typedef Trace<ExprT> this_type;
75 
76 
78 
82 
83  explicit Trace( expression_type const & __expr )
84  :
85  M_expr( __expr )
86  {}
87  Trace( Trace const & te )
88  :
89  M_expr( te.M_expr )
90  {}
91  ~Trace()
92  {}
93 
95 
99 
100 
102 
106 
107 
109 
113 
114 
116 
120 
121  expression_type const& expression() const
122  {
123  return M_expr;
124  }
125 
127 
128  //template<typename Geo_t, typename Basis_i_t = fusion::map<fusion::pair<vf::detail::gmc<0>,boost::shared_ptrvf::detail::gmc<0> > > >, typename Basis_j_t = Basis_i_t>
129  template<typename Geo_t, typename Basis_i_t, typename Basis_j_t>
130  struct tensor
131  {
132  typedef typename expression_type::template tensor<Geo_t, Basis_i_t, Basis_j_t> tensor_expr_type;
133  typedef typename tensor_expr_type::value_type value_type;
134 
135  typedef typename tensor_expr_type::shape expr_shape;
136  BOOST_MPL_ASSERT_MSG( ( boost::is_same<mpl::int_<expr_shape::M>,mpl::int_<expr_shape::N> >::value ), INVALID_TENSOR_SHOULD_BE_RANK_2_OR_0, ( mpl::int_<expr_shape::M>, mpl::int_<expr_shape::N> ) );
137  typedef Shape<expr_shape::nDim,Scalar,false,false> shape;
138 
139 
140  template <class Args> struct sig
141  {
142  typedef value_type type;
143  };
144 
145  struct is_zero
146  {
147  static const bool value = tensor_expr_type::is_zero::value;
148  };
149 
150  tensor( this_type const& expr,
151  Geo_t const& geom, Basis_i_t const& fev, Basis_j_t const& feu )
152  :
153  M_tensor_expr( expr.expression(), geom, fev, feu )
154  {
155  }
156 
157  tensor( this_type const& expr,
158  Geo_t const& geom, Basis_i_t const& fev )
159  :
160  M_tensor_expr( expr.expression(), geom, fev )
161  {
162  }
163 
164  tensor( this_type const& expr, Geo_t const& geom )
165  :
166  M_tensor_expr( expr.expression(), geom )
167  {
168  }
169  template<typename IM>
170  void init( IM const& im )
171  {
172  M_tensor_expr.init( im );
173  }
174  void update( Geo_t const& geom, Basis_i_t const& fev, Basis_j_t const& feu )
175  {
176  M_tensor_expr.update( geom, fev, feu );
177  }
178  void update( Geo_t const& geom, Basis_i_t const& fev )
179  {
180  M_tensor_expr.update( geom, fev );
181  }
182  void update( Geo_t const& geom )
183  {
184  M_tensor_expr.update( geom );
185  }
186  void update( Geo_t const& geom, uint16_type face )
187  {
188  M_tensor_expr.update( geom, face );
189  }
190 
191 
192  value_type
193  evalij( uint16_type i, uint16_type j ) const
194  {
195  return M_tensor_expr.evalij( i, j );
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  value_type res = value_type( 0 );
203 
204  for ( uint16_type l = 0; l < expr_shape::M; ++l )
205  res += M_tensor_expr.evalijq( i, j, l, l, q );
206 
207  return res;
208  }
209  template<int PatternContext>
210  value_type
211  evalijq( uint16_type i, uint16_type j, uint16_type /*c1*/, uint16_type /*c2*/, uint16_type q,
212  mpl::int_<PatternContext> ) const
213  {
214  value_type res = value_type( 0 );
215 
216  for ( uint16_type l = 0; l < expr_shape::M; ++l )
217  res += M_tensor_expr.evalijq( i, j, l, l, q, mpl::int_<PatternContext>() );
218 
219  return res;
220  }
221 
222  value_type
223  evaliq( uint16_type i, uint16_type /*c1*/, uint16_type /*c2*/, uint16_type q ) const
224  {
225  value_type res = value_type( 0 );
226 
227  for ( uint16_type l = 0; l < expr_shape::M; ++l )
228  res += M_tensor_expr.evaliq( i, l, l, q );
229 
230  return res;
231  }
232 
233  value_type
234  evalq( uint16_type /*c1*/, uint16_type /*c2*/, uint16_type q ) const
235  {
236  value_type res = value_type( 0 );
237 
238  for ( uint16_type l = 0; l < expr_shape::M; ++l )
239  res += M_tensor_expr.evalq( l, l, q );
240 
241  return res;
242  }
243 
244  tensor_expr_type M_tensor_expr;
245  };
246 
247 private:
248  mutable expression_type M_expr;
249 };
251 
255 template<typename ExprT>
256 inline
257 Expr< Trace<ExprT> >
258 trace( ExprT v )
259 {
260  typedef Trace<ExprT> trace_t;
261  return Expr< trace_t >( trace_t( v ) );
262 }
263 
264 }
265 }
266 #endif /* __Trace_H */
size_t size_type
Indices (starting from 0)
Definition: feelcore/feel.hpp:319

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