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
twovalued.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-05-07
7 
8  Copyright (C) 2007-2010 Université 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 __TwoValued_H
30 #define __TwoValued_H 1
31 
32 
33 #include <boost/fusion/container/generation/make_map.hpp>
34 
35 namespace Feel
36 {
37 namespace vf
38 {
40 
47 template<typename ExprT>
48 class SumvExpr
49 {
50 public:
51 
52  static const size_type context = ExprT::context;
53  static const bool is_terminal = false;
54 
55  static const uint16_type imorder = ExprT::imorder;
56  static const bool imIsPoly = ExprT::imIsPoly;
57 
58  template<typename Func>
59  struct HasTestFunction
60  {
61  static const bool result = false;
62  };
63 
64  template<typename Func>
65  struct HasTrialFunction
66  {
67  static const bool result = false;
68  };
69 
70 
74 
75  typedef ExprT expression_type;
76  typedef typename expression_type::value_type value_type;
77  typedef SumvExpr<ExprT> this_type;
78 
80 
84 
85  explicit SumvExpr( expression_type const & __expr )
86  :
87  M_expr( __expr )
88  {}
89  ~SumvExpr()
90  {}
91 
93 
97 
98  template<typename Geo_t, typename Basis_i_t = fusion::map<fusion::pair<vf::detail::gmc<0>,boost::shared_ptr<vf::detail::gmc<0> > > >, typename Basis_j_t = Basis_i_t>
99  struct tensor
100  {
101  typedef mpl::int_<fusion::result_of::template size<Geo_t>::type::value> map_size;
102  //BOOST_MPL_ASSERT_MSG( map_size::value == 2, INVALID_GEOMAP, (map_size,Geo_t ));
103 
104  typedef typename mpl::if_<mpl::equal_to<map_size,mpl::int_<2> >,
105  vf::detail::gmc<1>,
106  vf::detail::gmc<0> >::type gmc1;
107 
108  typedef typename fusion::result_of::value_at_key<Geo_t,vf::detail::gmc<0> >::type left_gmc_ptrtype;
109  typedef typename fusion::result_of::value_at_key<Geo_t,vf::detail::gmc<0> >::type::element_type left_gmc_type;
110  typedef typename fusion::result_of::value_at_key<Geo_t,gmc1 >::type right_gmc_ptrtype;
111  typedef typename fusion::result_of::value_at_key<Geo_t,gmc1 >::type::element_type right_gmc_type;
112 
113  typedef fusion::map<fusion::pair<vf::detail::gmc<0>, left_gmc_ptrtype> > map_left_gmc_type;
114  typedef fusion::map<fusion::pair<vf::detail::gmc<0>, right_gmc_ptrtype> > map_right_gmc_type;
115 
116  typedef typename expression_type::template tensor<map_left_gmc_type, Basis_i_t, Basis_j_t> left_tensor_expr_type;
117  typedef typename expression_type::template tensor<map_right_gmc_type, Basis_i_t, Basis_j_t> right_tensor_expr_type;
118  typedef typename left_tensor_expr_type::value_type value_type;
119 
120  typedef typename left_tensor_expr_type::shape shape;
121 
122  struct is_zero
123  {
124  static const bool value = false;
125  };
126 
127  template <class Args> struct sig
128  {
129  typedef value_type type;
130  };
131 
132  tensor( this_type const& expr,
133  Geo_t const& geom, Basis_i_t const& fev, Basis_j_t const& feu )
134  :
135  M_gmc_left( fusion::at_key<vf::detail::gmc<0> >( geom ) ),
136  M_gmc_right( fusion::at_key<gmc1 >( geom ) ),
137  M_left_map( fusion::make_map<vf::detail::gmc<0> >( M_gmc_left ) ),
138  M_right_map( fusion::make_map<vf::detail::gmc<0> >( M_gmc_right ) ),
139  M_tensor_expr_left( expr.expression(), M_left_map, fev, feu ),
140  M_tensor_expr_right( expr.expression(), M_right_map, fev, feu )
141  {}
142 
143  tensor( this_type const& expr,
144  Geo_t const& geom, Basis_i_t const& fev )
145  :
146  M_gmc_left( fusion::at_key<vf::detail::gmc<0> >( geom ) ),
147  M_gmc_right( fusion::at_key<gmc1 >( geom ) ),
148  M_left_map( fusion::make_map<vf::detail::gmc<0> >( M_gmc_left ) ),
149  M_right_map( fusion::make_map<vf::detail::gmc<0> >( M_gmc_right ) ),
150  M_tensor_expr_left( expr.expression(), M_left_map, fev ),
151  M_tensor_expr_right( expr.expression(), M_right_map, fev )
152  {}
153 
154  tensor( this_type const& expr, Geo_t const& geom )
155  :
156  M_gmc_left( fusion::at_key<vf::detail::gmc<0> >( geom ) ),
157  M_gmc_right( fusion::at_key<gmc1 >( geom ) ),
158  M_left_map( fusion::make_map<vf::detail::gmc<0> >( M_gmc_left ) ),
159  M_right_map( fusion::make_map<vf::detail::gmc<0> >( M_gmc_right ) ),
160  M_tensor_expr_left( expr.expression(), M_left_map ),
161  M_tensor_expr_right( expr.expression(), M_right_map )
162  {
163  }
164 
165  template<typename IM>
166  void init( IM const& im )
167  {
168  M_tensor_expr_left.init( im );
169  M_tensor_expr_right.init( im );
170  }
171  void update( Geo_t const& geom, Basis_i_t const& fev, Basis_j_t const& feu )
172  {
173  typedef mpl::int_<fusion::result_of::template size<Geo_t>::type::value> map_size;
174  FEELPP_ASSERT( map_size::value == 2 )( map_size::value ).error( "invalid map size (should be 2)" );
175 
176  M_gmc_left = fusion::at_key<vf::detail::gmc<0> >( geom );
177  M_gmc_right = fusion::at_key<gmc1 >( geom );
178  FEELPP_ASSERT( M_gmc_left != M_gmc_right )( M_gmc_left->id() )( M_gmc_right->id() ).error( "same geomap, something is wrong" );
179 
180  M_left_map = fusion::make_map<vf::detail::gmc<0> >( M_gmc_left );
181  M_right_map = fusion::make_map<vf::detail::gmc<0> >( M_gmc_right );
182  M_tensor_expr_left.update( M_left_map );
183  M_tensor_expr_right.update( M_right_map );
184  }
185  void update( Geo_t const& geom, Basis_i_t const& fev )
186  {
187  typedef mpl::int_<fusion::result_of::template size<Geo_t>::type::value> map_size;
188  FEELPP_ASSERT( map_size::value == 2 )( map_size::value ).error( "invalid map size (should be 2)" );
189 
190  M_gmc_left = fusion::at_key<vf::detail::gmc<0> >( geom );
191  M_gmc_right = fusion::at_key<gmc1 >( geom );
192  FEELPP_ASSERT( M_gmc_left != M_gmc_right )( M_gmc_left->id() )( M_gmc_right->id() ).error( "same geomap, something is wrong" );
193 
194  M_left_map = fusion::make_map<vf::detail::gmc<0> >( M_gmc_left );
195  M_right_map = fusion::make_map<vf::detail::gmc<0> >( M_gmc_right );
196  M_tensor_expr_left.update( M_left_map );
197  M_tensor_expr_right.update( M_right_map );
198  }
199  void update( Geo_t const& geom )
200  {
201  typedef mpl::int_<fusion::result_of::template size<Geo_t>::type::value> map_size;
202  FEELPP_ASSERT( map_size::value == 2 )( map_size::value ).error( "invalid map size (should be 2)" );
203 
204  M_gmc_left = fusion::at_key<vf::detail::gmc<0> >( geom );
205  M_gmc_right = fusion::at_key<gmc1 >( geom );
206  FEELPP_ASSERT( M_gmc_left != M_gmc_right )( M_gmc_left->id() )( M_gmc_right->id() ).error( "same geomap, something is wrong" );
207 
208  M_left_map = fusion::make_map<vf::detail::gmc<0> >( M_gmc_left );
209  M_right_map = fusion::make_map<vf::detail::gmc<0> >( M_gmc_right );
210  M_tensor_expr_left.update( M_left_map );
211  M_tensor_expr_right.update( M_right_map );
212 
213 
214  }
215  void update( Geo_t const& geom, uint16_type face )
216  {
217  typedef mpl::int_<fusion::result_of::template size<Geo_t>::type::value> map_size;
218  FEELPP_ASSERT( map_size::value == 2 )( map_size::value ).error( "invalid map size (should be 2)" );
219 
220  M_gmc_left = fusion::at_key<vf::detail::gmc<0> >( geom );
221  M_gmc_right = fusion::at_key<gmc1 >( geom );
222  FEELPP_ASSERT( M_gmc_left != M_gmc_right )( M_gmc_left->id() )( M_gmc_right->id() ).error( "same geomap, something is wrong" );
223 
224  M_left_map = fusion::make_map<vf::detail::gmc<0> >( M_gmc_left );
225  M_right_map = fusion::make_map<vf::detail::gmc<0> >( M_gmc_right );
226  M_tensor_expr_left.update( M_left_map, face );
227  M_tensor_expr_right.update( M_right_map, face );
228 
229 
230  }
231 
232 
233  value_type
234  evalij( uint16_type i, uint16_type j ) const
235  {
236  return M_tensor_expr_left.evalij( i, j ) + M_tensor_expr_right.evalij( i, j );
237  }
238 
239 
240  value_type
241  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q ) const
242  {
243  return M_tensor_expr_left.evalq( c1, c2, q ) + M_tensor_expr_right.evalq( c1, c2, q );
244  }
245  template<int PatternContext>
246  value_type
247  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q,
248  mpl::int_<PatternContext> ) const
249  {
250  return M_tensor_expr_left.evalq( c1, c2, q, mpl::int_<PatternContext>() ) +
251  M_tensor_expr_right.evalq( c1, c2, q, mpl::int_<PatternContext>() );
252  }
253 
254 
255  value_type
256  evaliq( uint16_type i, uint16_type c1, uint16_type c2, uint16_type q ) const
257  {
258  //DVLOG(2) << "sumv_left= " << M_tensor_expr_left.evalq( q, c1, c2 ) << "\n"
259  //<< "sumv_right= " << M_tensor_expr_right.evalq( q, c1, c2 ) << "\n";
260  Feel::detail::ignore_unused_variable_warning( i );
261  value_type resl = M_tensor_expr_left.evalq( c1, c2, q );
262  value_type resr = M_tensor_expr_right.evalq( c1, c2, q );
263  value_type res = resl + resr;
264  //DVLOG(2) << "resl( " << i << "," << c1 << "," << c2 << "," << q << ")=" << resl << "\n";
265  //DVLOG(2) << "resr( " << i << "," << c1 << "," << c2 << "," << q << ")=" << resr << "\n";
266  //DVLOG(2) << "res( " << i << "," << c1 << "," << c2 << "," << q << ")=" << res << "\n";
267  return res;
268  }
269 
270  value_type
271  evalq( uint16_type c1, uint16_type c2, uint16_type q ) const
272  {
273  //DVLOG(2) << "sumv_left= " << M_tensor_expr_left.evalq( q, c1, c2 ) << "\n"
274  //<< "sumv_right= " << M_tensor_expr_right.evalq( q, c1, c2 ) << "\n";
275  return M_tensor_expr_left.evalq( c1, c2, q )+M_tensor_expr_right.evalq( c1, c2, q );
276  }
277 
278 
279  left_gmc_ptrtype M_gmc_left;
280  right_gmc_ptrtype M_gmc_right;
281  map_left_gmc_type M_left_map;
282  map_right_gmc_type M_right_map;
283  left_tensor_expr_type M_tensor_expr_left;
284  right_tensor_expr_type M_tensor_expr_right;
285  };
286 
288 
292 
293  bool isSymetric() const
294  {
295  return M_expr.isSymetric();
296  }
297 
298  expression_type const& expression() const
299  {
300  return M_expr;
301  }
302 
304 
308 
310 
314 
316 
317 protected:
318 
319 private:
320 
321  expression_type M_expr;
322 };
323 
324 
325 
333 template<typename ExprT, int Side>
334 class SumExpr
335 {
336 public:
337 
338  static const size_type context = ExprT::context;
339  static const bool is_terminal = false;
340 
341  static const uint16_type imorder = ExprT::imorder;
342  static const bool imIsPoly = ExprT::imIsPoly;
343 
344  template<typename Func>
345  struct HasTestFunction
346  {
347  static const bool result = ExprT::template HasTestFunction<Func>::result;
348  };
349 
350  template<typename Func>
351  struct HasTrialFunction
352  {
353  static const bool result = false;
354  };
355 
356 
360 
361  typedef ExprT expression_type;
362  typedef typename expression_type::value_type value_type;
363  typedef SumExpr<ExprT,Side> this_type;
364 
366 
370 
371  explicit SumExpr( expression_type const & __expr )
372  :
373  M_expr( __expr )
374  {}
375  ~SumExpr()
376  {}
377 
379 
383 
384  template<typename Geo_t, typename Basis_i_t, typename Basis_j_t>
385  struct tensor
386  {
387  typedef mpl::int_<fusion::result_of::template size<Geo_t>::type::value> map_size;
388  //BOOST_MPL_ASSERT_MSG( map_size::value == 2, INVALID_GEOMAP, (map_size,Geo_t ));
389 
390  typedef typename mpl::if_<mpl::equal_to<map_size,mpl::int_<2> >,
391  vf::detail::gmc<1>,
392  vf::detail::gmc<0> >::type gmc1;
393 
394  typedef typename mpl::if_<typename fusion::result_of::has_key<Basis_i_t,vf::detail::gmc<0> >,
395  mpl::identity<vf::detail::gmc<0> >,
396  mpl::identity<vf::detail::gmc<1> > >::type::type key_type;
397  template<typename T>
398  struct ttt
399  {
400  typedef typename T::geometric_mapping_context_type type;
401  };
402  struct yyy
403  {
404  typedef typename fusion::result_of::value_at_key<Geo_t,key_type >::type::element_type type;
405  };
406  typedef typename fusion::result_of::value_at_key<Basis_i_t,key_type >::type::element_type e_type;
407  typedef typename mpl::if_<boost::is_same<e_type,key_type >,
408  mpl::identity<yyy >,
409  mpl::identity<ttt<e_type> > >::type::type::type gmc_type;
410 
411  typedef boost::shared_ptr<gmc_type> gmc_ptrtype;
412 
413 
414  typedef fusion::map<fusion::pair<key_type, gmc_ptrtype> > map_gmc_type;
415 
416  typedef typename expression_type::template tensor<map_gmc_type, Basis_i_t, Basis_j_t> tensor_expr_type;
417 
418  typedef typename tensor_expr_type::value_type value_type;
419 
420  typedef typename tensor_expr_type::shape shape;
421 
422  template <class Args> struct sig
423  {
424  typedef value_type type;
425  };
426 
427  struct is_zero
428  {
429  static const bool value = !fusion::result_of::has_key<Basis_i_t,vf::detail::gmc<Side> >::value;
430  //static const bool value = false;
431  };
432 
433  tensor( this_type const& expr,
434  Geo_t const& /*geom*/, Basis_i_t const& fev, Basis_j_t const& /*feu*/ )
435  :
436  M_gmc( fusion::at_key<key_type >( fev )->gmContext() ),
437  M_map( fusion::make_map<key_type >( M_gmc ) ),
438  M_tensor_expr( expr.expression(), M_map, fev )
439  {
440  DVLOG(2) << "expr SumExpr<" << Side << "> is_zero " << is_zero::value << "\n";
441  }
442 
443  tensor( this_type const& expr,
444  Geo_t const& /*geom*/, Basis_i_t const& fev )
445  :
446  M_gmc( fusion::at_key<key_type >( fev )->gmContext() ),
447  M_map( fusion::make_map<key_type >( M_gmc ) ),
448  M_tensor_expr( expr.expression(), M_map, fev )
449  {
450  DVLOG(2) << "expr SumExpr is_zero " << is_zero::value << "\n";
451  }
452 
453  template<typename IM>
454  void init( IM const& im )
455  {
456  M_tensor_expr.init( im );
457  }
458  void update( Geo_t const& geom, Basis_i_t const& fev, Basis_j_t const& /*feu*/ )
459  {
460  update( geom, fev, fusion::result_of::has_key<Basis_i_t,vf::detail::gmc<Side> >() );
461  }
462  void update( Geo_t const& geom, Basis_i_t const& fev )
463  {
464  update( geom, fev, fusion::result_of::has_key<Basis_i_t,vf::detail::gmc<Side> >() );
465  }
466  void update( Geo_t const& /*geom*/, Basis_i_t const& fev, mpl::true_ )
467  {
468  M_gmc = fusion::at_key<vf::detail::gmc<Side> >( fev )->gmContext();
469  M_map = fusion::make_map<vf::detail::gmc<Side> >( M_gmc );
470  M_tensor_expr.update( M_map, fev );
471  }
472  void update( Geo_t const& /*geom*/, Basis_i_t const& /*fev*/, mpl::false_ )
473  {
474 
475  }
476 
477 
478  value_type
479  evalij( uint16_type i, uint16_type j ) const
480  {
481  return M_tensor_expr.evalij( i, j );
482  }
483 
484 
485  value_type
486  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q ) const
487  {
488  Feel::detail::ignore_unused_variable_warning( j );
489  return evaliq( i, c1, c2, q, fusion::result_of::has_key<Basis_i_t,vf::detail::gmc<Side> >() );
490  }
491  template<int PatternContext>
492  value_type
493  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q,
494  mpl::int_<PatternContext> ) const
495  {
496  Feel::detail::ignore_unused_variable_warning( j );
497  return evaliq( i, c1, c2, q, fusion::result_of::has_key<Basis_i_t,vf::detail::gmc<Side> >() );
498  }
499 
500 
501  value_type
502  evaliq( uint16_type i, uint16_type c1, uint16_type c2, uint16_type q ) const
503  {
504  return evaliq( i, c1, c2, q, fusion::result_of::has_key<Basis_i_t,vf::detail::gmc<Side> >() );
505  }
506 
507  value_type
508  evaliq( uint16_type i, uint16_type c1, uint16_type c2, uint16_type q, mpl::true_ ) const
509  {
510  return M_tensor_expr.evaliq( i, c1, c2, q );
511  }
512 
513  value_type
514  evaliq( uint16_type i, uint16_type c1, uint16_type c2, uint16_type q, mpl::false_ ) const
515  {
516  Feel::detail::ignore_unused_variable_warning( i );
517  Feel::detail::ignore_unused_variable_warning( c1 );
518  Feel::detail::ignore_unused_variable_warning( c2 );
519  Feel::detail::ignore_unused_variable_warning( q );
520  return value_type( 0 );
521  }
522 
523  gmc_ptrtype M_gmc;
524  map_gmc_type M_map;
525  tensor_expr_type M_tensor_expr;
526  };
527 
529 
533 
534  bool isSymetric() const
535  {
536  return M_expr.isSymetric();
537  }
538 
539  expression_type const& expression() const
540  {
541  return M_expr;
542  }
543 
545 
549 
551 
555 
557 
558 protected:
559 
560 private:
561 
562  expression_type M_expr;
563 };
564 
572 template<typename ExprT, int Side>
573 class SumTExpr
574 {
575 public:
576 
577  static const size_type context = ExprT::context;
578  static const bool is_terminal = false;
579 
580  static const uint16_type imorder = ExprT::imorder;
581  static const bool imIsPoly = ExprT::imIsPoly;
582 
583  template<typename Func>
584  struct HasTestFunction
585  {
586  static const bool result = false;
587  };
588 
589  template<typename Func>
590  struct HasTrialFunction
591  {
592  static const bool result = ExprT::template HasTrialFunction<Func>::result;
593  };
594 
598 
599  typedef ExprT expression_type;
600  typedef typename expression_type::value_type value_type;
601  typedef SumTExpr<ExprT,Side> this_type;
602 
604 
608 
609  explicit SumTExpr( expression_type const & __expr )
610  :
611  M_expr( __expr )
612  {}
613  ~SumTExpr()
614  {}
615 
617 
621 
622  template<typename Geo_t, typename Basis_i_t, typename Basis_j_t>
623  struct tensor
624  {
625  typedef mpl::int_<fusion::result_of::template size<Geo_t>::type::value> map_size;
626  //BOOST_MPL_ASSERT_MSG( map_size::value == 2, INVALID_GEOMAP, (map_size,Geo_t ));
627 
628  typedef typename mpl::if_<mpl::equal_to<map_size,mpl::int_<2> >,
629  vf::detail::gmc<1>,
630  vf::detail::gmc<0> >::type gmc1;
631 
632  typedef typename mpl::if_<typename fusion::result_of::has_key<Basis_j_t,vf::detail::gmc<0> >,
633  mpl::identity<vf::detail::gmc<0> >,
634  mpl::identity<vf::detail::gmc<1> > >::type::type key_type;
635 
636  template<typename T>
637  struct ttt
638  {
639  typedef typename T::geometric_mapping_context_type type;
640  };
641  struct yyy
642  {
643  typedef typename fusion::result_of::value_at_key<Geo_t,key_type >::type::element_type type;
644  };
645  typedef typename fusion::result_of::value_at_key<Basis_j_t,key_type >::type::element_type e_type;
646  typedef typename mpl::if_<boost::is_same<e_type,key_type >,
647  mpl::identity<yyy >,
648  mpl::identity<ttt<e_type> > >::type::type::type gmc_type;
649 
650  typedef boost::shared_ptr<gmc_type> gmc_ptrtype;
651 
652  typedef fusion::map<fusion::pair<key_type, gmc_ptrtype> > map_gmc_type;
653 
654  typedef typename expression_type::template tensor<map_gmc_type, Basis_i_t, Basis_j_t> tensor_expr_type;
655 
656  typedef typename tensor_expr_type::value_type value_type;
657 
658  typedef typename tensor_expr_type::shape shape;
659 
660  template <class Args> struct sig
661  {
662  typedef value_type type;
663  };
664 
665  struct is_zero
666  {
667  static const bool value = !fusion::result_of::has_key<Basis_j_t,vf::detail::gmc<Side> >::value;
668  //static const bool value = false;
669  };
670 
671  tensor( this_type const& expr,
672  Geo_t const& /*geom*/, Basis_i_t const& fev, Basis_j_t const& feu )
673  :
674  M_gmc( fusion::at_key<key_type>( feu )->gmContext() ),
675  M_map( fusion::make_map<key_type>( M_gmc ) ),
676  M_tensor_expr( expr.expression(), M_map, fev, feu )
677  {
678  DVLOG(2) << "expr SumTExpr<" << Side << "> is_zero " << is_zero::value << "\n";
679  }
680 
681  template<typename IM>
682  void init( IM const& im )
683  {
684  M_tensor_expr.init( im );
685  }
686  void update( Geo_t const& geom, Basis_i_t const& fev, Basis_j_t const& feu )
687  {
688  update( geom, fev, feu, fusion::result_of::has_key<Basis_j_t,vf::detail::gmc<Side> >() );
689  }
690  void update( Geo_t const& /*geom*/, Basis_i_t const& fev, Basis_j_t const& feu, mpl::true_ )
691  {
692  M_gmc = fusion::at_key<key_type>( feu )->gmContext();
693  M_map = fusion::make_map<key_type>( M_gmc );
694  M_tensor_expr.update( M_map, fev, feu );
695  }
696  void update( Geo_t const& /*geom*/, Basis_i_t const& fev, Basis_j_t const& feu, mpl::false_ )
697  {
698  Feel::detail::ignore_unused_variable_warning( fev );
699  Feel::detail::ignore_unused_variable_warning( feu );
700  }
701 
702 
703  value_type
704  evalij( uint16_type i, uint16_type j ) const
705  {
706  return M_tensor_expr.evalij( i, j );
707  }
708 
709 
710  value_type
711  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q ) const
712  {
713  return evalijq( i, j, c1,c2, q, fusion::result_of::has_key<Basis_j_t,vf::detail::gmc<Side> >() );
714  }
715  template<int PatternContext>
716  value_type
717  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q,
718  mpl::int_<PatternContext> ) const
719  {
720  return evalijq( i, j, c1,c2, q, mpl::int_<PatternContext>(), fusion::result_of::has_key<Basis_j_t,vf::detail::gmc<Side> >() );
721  }
722 
723 
724  value_type
725  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q, mpl::true_ ) const
726  {
727  return M_tensor_expr.evalijq( i, j, c1, c2, q );
728  }
729 
730  value_type
731  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q, mpl::false_ ) const
732  {
733  Feel::detail::ignore_unused_variable_warning( i );
734  Feel::detail::ignore_unused_variable_warning( j );
735  Feel::detail::ignore_unused_variable_warning( c1 );
736  Feel::detail::ignore_unused_variable_warning( c2 );
737  Feel::detail::ignore_unused_variable_warning( q );
738  return value_type( 0 );
739  }
740  template<int PatternContext>
741  value_type
742  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q,
743  mpl::int_<PatternContext>, mpl::true_ ) const
744  {
745  return M_tensor_expr.evalijq( i, j, c1, c2, q, mpl::int_<PatternContext>() );
746  }
747  template<int PatternContext>
748  value_type
749  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q,
750  mpl::int_<PatternContext>, mpl::false_ ) const
751  {
752  Feel::detail::ignore_unused_variable_warning( i );
753  Feel::detail::ignore_unused_variable_warning( j );
754  Feel::detail::ignore_unused_variable_warning( c1 );
755  Feel::detail::ignore_unused_variable_warning( c2 );
756  Feel::detail::ignore_unused_variable_warning( q );
757  return value_type( 0 );
758  }
759 
760  private:
761 
762  gmc_ptrtype M_gmc;
763  map_gmc_type M_map;
764  tensor_expr_type M_tensor_expr;
765  };
766 
768 
772 
773  expression_type const& expression() const
774  {
775  return M_expr;
776  }
777 
779 
783 
785 
789 
791 
792 protected:
793 
794 private:
795 
796  expression_type M_expr;
797 };
799 
800 
802 
809 template<typename ExprT, double func( double,double )>
810 class FaceExprV
811 {
812 public:
813 
814  static const size_type context = ExprT::context;
815  static const bool is_terminal = false;
816 
817  static const uint16_type imorder = ExprT::imorder;
818  static const bool imIsPoly = ExprT::imIsPoly;
819 
820  template<typename Func>
821  struct HasTestFunction
822  {
823  static const bool result = ExprT::template HasTestFunction<Func>::result;
824  };
825 
826  template<typename Func>
827  struct HasTrialFunction
828  {
829  static const bool result = ExprT::template HasTrialFunction<Func>::result;
830  };
831 
835 
836  typedef ExprT expression_type;
837  typedef typename expression_type::value_type value_type;
838  typedef FaceExprV<ExprT, func> this_type;
839 
841 
845 
846  explicit FaceExprV( expression_type const & __expr )
847  :
848  M_expr( __expr )
849  {}
850  ~FaceExprV()
851  {}
852 
854 
858 
859  template<typename Geo_t, typename Basis_i_t = fusion::map<fusion::pair<vf::detail::gmc<0>,boost::shared_ptr<vf::detail::gmc<0> > > >, typename Basis_j_t = Basis_i_t>
860  struct tensor
861  {
862  typedef mpl::int_<fusion::result_of::template size<Geo_t>::type::value> map_size;
863  //BOOST_MPL_ASSERT_MSG( map_size::value == 2, INVALID_GEOMAP, (map_size,Geo_t ));
864 
865  typedef typename mpl::if_<mpl::equal_to<map_size,mpl::int_<2> >,
866  vf::detail::gmc<1>,
867  vf::detail::gmc<0> >::type gmc1;
868 
869  typedef typename fusion::result_of::value_at_key<Geo_t,vf::detail::gmc<0> >::type left_gmc_ptrtype;
870  typedef typename fusion::result_of::value_at_key<Geo_t,vf::detail::gmc<0> >::type::element_type left_gmc_type;
871  typedef typename fusion::result_of::value_at_key<Geo_t,gmc1 >::type right_gmc_ptrtype;
872  typedef typename fusion::result_of::value_at_key<Geo_t,gmc1 >::type::element_type right_gmc_type;
873 
874  typedef fusion::map<fusion::pair<vf::detail::gmc<0>, left_gmc_ptrtype> > map_left_gmc_type;
875  typedef fusion::map<fusion::pair<vf::detail::gmc<0>, right_gmc_ptrtype> > map_right_gmc_type;
876 
877  typedef typename expression_type::template tensor<map_left_gmc_type, Basis_i_t, Basis_j_t> left_tensor_expr_type;
878  typedef typename expression_type::template tensor<map_right_gmc_type, Basis_i_t, Basis_j_t> right_tensor_expr_type;
879  typedef typename left_tensor_expr_type::value_type value_type;
880 
881  typedef typename left_tensor_expr_type::shape shape;
882 
883  template <class Args> struct sig
884  {
885  typedef value_type type;
886  };
887 
888  struct is_zero
889  {
890  static const bool value = false;
891  };
892 
893  tensor( this_type const& expr,
894  Geo_t const& geom, Basis_i_t const& fev, Basis_j_t const& feu )
895  :
896  M_gmc_left( fusion::at_key<vf::detail::gmc<0> >( geom ) ),
897  M_gmc_right( fusion::at_key<gmc1 >( geom ) ),
898  M_left_map( fusion::make_map<vf::detail::gmc<0> >( M_gmc_left ) ),
899  M_right_map( fusion::make_map<vf::detail::gmc<0> >( M_gmc_right ) ),
900  M_tensor_expr_left( expr.expression(), M_left_map, fev, feu ),
901  M_tensor_expr_right( expr.expression(), M_right_map, fev, feu )
902  {}
903 
904  tensor( this_type const& expr,
905  Geo_t const& geom, Basis_i_t const& fev )
906  :
907  M_gmc_left( fusion::at_key<vf::detail::gmc<0> >( geom ) ),
908  M_gmc_right( fusion::at_key<gmc1 >( geom ) ),
909  M_left_map( fusion::make_map<vf::detail::gmc<0> >( M_gmc_left ) ),
910  M_right_map( fusion::make_map<vf::detail::gmc<0> >( M_gmc_right ) ),
911  M_tensor_expr_left( expr.expression(), M_left_map, fev ),
912  M_tensor_expr_right( expr.expression(), M_right_map, fev )
913  {}
914 
915  tensor( this_type const& expr, Geo_t const& geom )
916  :
917  M_gmc_left( fusion::at_key<vf::detail::gmc<0> >( geom ) ),
918  M_gmc_right( fusion::at_key<gmc1 >( geom ) ),
919  M_left_map( fusion::make_map<vf::detail::gmc<0> >( M_gmc_left ) ),
920  M_right_map( fusion::make_map<vf::detail::gmc<0> >( M_gmc_right ) ),
921  M_tensor_expr_left( expr.expression(), M_left_map ),
922  M_tensor_expr_right( expr.expression(), M_right_map )
923  {
924  }
925  template<typename IM>
926  void init( IM const& im )
927  {
928  M_tensor_expr_left.init( im );
929  M_tensor_expr_right.init( im );
930  }
931  void update( Geo_t const& geom, Basis_i_t const& fev, Basis_j_t const& feu )
932  {
933  typedef mpl::int_<fusion::result_of::template size<Geo_t>::type::value> map_size;
934  FEELPP_ASSERT( map_size::value == 2 )( map_size::value ).error( "invalid map size (should be 2)" );
935 
936  M_gmc_left = fusion::at_key<vf::detail::gmc<0> >( geom );
937  M_gmc_right = fusion::at_key<gmc1 >( geom );
938  FEELPP_ASSERT( M_gmc_left != M_gmc_right )( M_gmc_left->id() )( M_gmc_right->id() ).error( "same geomap, something is wrong" );
939 
940  M_left_map = fusion::make_map<vf::detail::gmc<0> >( M_gmc_left );
941  M_right_map = fusion::make_map<vf::detail::gmc<0> >( M_gmc_right );
942  M_tensor_expr_left.update( M_left_map );
943  M_tensor_expr_right.update( M_right_map );
944  }
945  void update( Geo_t const& geom, Basis_i_t const& /*fev*/ )
946  {
947  typedef mpl::int_<fusion::result_of::template size<Geo_t>::type::value> map_size;
948  FEELPP_ASSERT( map_size::value == 2 )( map_size::value ).error( "invalid map size (should be 2)" );
949 
950  M_gmc_left = fusion::at_key<vf::detail::gmc<0> >( geom );
951  M_gmc_right = fusion::at_key<gmc1 >( geom );
952  FEELPP_ASSERT( M_gmc_left != M_gmc_right )( M_gmc_left->id() )( M_gmc_right->id() ).error( "same geomap, something is wrong" );
953 
954  M_left_map = fusion::make_map<vf::detail::gmc<0> >( M_gmc_left );
955  M_right_map = fusion::make_map<vf::detail::gmc<0> >( M_gmc_right );
956  M_tensor_expr_left.update( M_left_map );
957  M_tensor_expr_right.update( M_right_map );
958  }
959  void update( Geo_t const& geom )
960  {
961  }
962  void update( Geo_t const& geom, uint16_type face )
963  {
964  typedef mpl::int_<fusion::result_of::template size<Geo_t>::type::value> map_size;
965  FEELPP_ASSERT( map_size::value == 2 )( map_size::value ).error( "invalid map size (should be 2)" );
966 
967  M_gmc_left = fusion::at_key<vf::detail::gmc<0> >( geom );
968  M_gmc_right = fusion::at_key<gmc1 >( geom );
969  FEELPP_ASSERT( M_gmc_left != M_gmc_right )( M_gmc_left->id() )( M_gmc_right->id() ).error( "same geomap, something is wrong" );
970 
971  M_left_map = fusion::make_map<vf::detail::gmc<0> >( M_gmc_left );
972  M_right_map = fusion::make_map<vf::detail::gmc<0> >( M_gmc_right );
973  M_tensor_expr_left.update( M_left_map, face );
974  M_tensor_expr_right.update( M_right_map, face );
975 
976 
977  }
978 
979  value_type
980  evalij( uint16_type i, uint16_type j ) const
981  {
982  return func( M_tensor_expr_left.evalij( i, j ), M_tensor_expr_right.evalij( i, j ) );
983  }
984 
985 
986  value_type
987  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q ) const
988  {
989  return func( M_tensor_expr_left.evalijq( i, j, c1, c2, q ),
990  M_tensor_expr_right.evalijq( i, j, c1, c2, q ) );
991  }
992  template<int PatternContext>
993  value_type
994  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q,
995  mpl::int_<PatternContext> ) const
996  {
997  return func( M_tensor_expr_left.evalijq( i, j, c1, c2, q, mpl::int_<PatternContext>() ),
998  M_tensor_expr_right.evalijq( i, j, c1, c2, q, mpl::int_<PatternContext>() ) );
999  }
1000 
1001 
1002  value_type
1003  evaliq( uint16_type i, uint16_type c1, uint16_type c2, uint16_type q ) const
1004  {
1005  return func( M_tensor_expr_left.evaliq( i, c1, c2, q ),
1006  M_tensor_expr_right.evaliq( i, c1, c2, q ) );
1007  }
1008 
1009  value_type
1010  evalq( uint16_type c1, uint16_type c2, uint16_type q ) const
1011  {
1012  return func( M_tensor_expr_left.evalq( c1, c2, q ),
1013  M_tensor_expr_right.evalq( c1, c2, q ) );
1014  }
1015 
1016 
1017  left_gmc_ptrtype M_gmc_left;
1018  right_gmc_ptrtype M_gmc_right;
1019  map_left_gmc_type M_left_map;
1020  map_right_gmc_type M_right_map;
1021  left_tensor_expr_type M_tensor_expr_left;
1022  right_tensor_expr_type M_tensor_expr_right;
1023  };
1024 
1026 
1030 
1031  bool isSymetric() const
1032  {
1033  return M_expr.isSymetric();
1034  }
1035 
1036  expression_type const& expression() const
1037  {
1038  return M_expr;
1039  }
1040 
1042 
1046 
1048 
1052 
1054 
1055 protected:
1056 
1057 private:
1058 
1059  expression_type M_expr;
1060 };
1061 
1062 namespace detail
1063 {
1064 inline double max( double a, double b )
1065 {
1066  return std::max( a, b );
1067 }
1068 inline double min( double a, double b )
1069 {
1070  return std::min( a, b );
1071 }
1072 
1073 inline double left( double a, double /*b*/ )
1074 {
1075  return a;
1076 }
1077 inline double right( double /*a*/, double b )
1078 {
1079  return b;
1080 }
1081 }
1082 
1084 
1085 template<typename ExprT>
1086 inline
1087 auto
1088 sumv( ExprT const& v ) -> decltype( expr( SumvExpr<ExprT>( v ) ) )
1089 {
1090  typedef SumvExpr<ExprT> sumv_t;
1091  return expr( sumv_t( v ) );
1092 }
1093 
1094 template<typename ExprT>
1095 inline
1096 auto
1097 leftface( ExprT const& v ) -> decltype( expr( SumExpr<ExprT,0>( v ) ) )
1098 {
1099  typedef SumExpr<ExprT,0> sumT_t;
1100  return expr( sumT_t( v ) );
1101 }
1102 
1103 template<typename ExprT>
1104 inline
1105 auto
1106 rightface( ExprT const& v ) -> decltype( expr( SumExpr<ExprT,1>( v ) ) )
1107 {
1108  typedef SumExpr<ExprT,1> sumT_t;
1109  return expr( sumT_t( v ) );
1110 }
1111 
1112 
1116 template<typename ExprT>
1117 inline
1118 Expr< SumTExpr<ExprT, 0> >
1119 leftfacet( ExprT const& v )
1120 {
1121  typedef SumTExpr<ExprT,0> sumT_t;
1122  return expr( sumT_t( v ) );
1123 }
1124 
1128 template<typename ExprT>
1129 inline
1130 Expr< SumTExpr<ExprT, 1> >
1131 rightfacet( ExprT const& v )
1132 {
1133  typedef SumTExpr<ExprT,1> sumT_t;
1134  return expr( sumT_t( v ) );
1135 }
1136 
1137 #if 0
1138 
1141 template<typename U>
1142 auto
1143 jump( U const& u ) -> decltype( leftface( u*N() ) + rightface( u*N() ) )
1144 {
1145  return ( leftface( u*N() ) + rightface( u *N() ) );
1146 }
1150 template<typename U>
1151 auto
1152 jumpt( U const& u ) -> decltype( leftfacet( u*N() ) + rightfacet( u*N() ) )
1153 {
1154  return ( leftfacet( u*N() ) + rightfacet( u*N() ) );
1155 }
1159 template<typename U>
1160 auto
1161 average( U const& u ) -> decltype( 0.5*( leftface( u )+rightface( u ) ) )
1162 {
1163  return 0.5*( leftface( u )+rightface( u ) );
1164 }
1168 template<typename U>
1169 auto
1170 averaget( U const&u ) -> decltype( 0.5*( leftfacet( u )+rightfacet( u ) ) )
1171 {
1172  return 0.5*( leftfacet( u )+rightfacet( u ) );
1173 }
1174 #else
1175 #define jump( u ) (::Feel::vf::leftface((u)*::Feel::vf::N())+::Feel::vf::rightface((u)*::Feel::vf::N()))
1176 #define average( u ) (.5*(::Feel::vf::leftface((u))+::Feel::vf::rightface((u))))
1177 
1178 #define jumpt( u ) (::Feel::vf::leftfacet((u)*::Feel::vf::N())+::Feel::vf::rightfacet((u)*::Feel::vf::N()))
1179 #define averaget( u ) (.5*(::Feel::vf::leftfacet((u))+::Feel::vf::rightfacet((u))))
1180 
1181 #endif
1182 
1183 template<typename ExprT>
1184 inline
1185 Expr< FaceExprV<ExprT,vf::detail::max > >
1186 maxface( ExprT const& v )
1187 {
1188  typedef FaceExprV<ExprT,vf::detail::max > maxface_t;
1189  return Expr< maxface_t >( maxface_t( v ) );
1190 }
1191 template<typename ExprT>
1192 inline
1193 Expr< FaceExprV<ExprT,vf::detail::min > >
1194 minface( ExprT const& v )
1195 {
1196  typedef FaceExprV<ExprT,vf::detail::min > minface_t;
1197  return Expr< minface_t >( minface_t( v ) );
1198 }
1199 
1200 
1201 template<typename ExprT>
1202 inline
1203 Expr< FaceExprV<ExprT,vf::detail::left> >
1204 leftfacev( ExprT const& v )
1205 {
1206  typedef FaceExprV<ExprT,vf::detail::left> leftface_t;
1207  return Expr< leftface_t >( leftface_t( v ) );
1208 }
1209 template<typename ExprT>
1210 inline
1211 Expr< FaceExprV<ExprT,vf::detail::right> >
1212 rightfacev( ExprT const& v )
1213 {
1214  typedef FaceExprV<ExprT,vf::detail::right> rightface_t;
1215  return Expr< rightface_t >( rightface_t( v ) );
1216 }
1217 
1218 #if 0
1219 
1222 template<typename U>
1223 auto
1224 jumpv( U const& u ) -> decltype( ( leftfacev( u*N() )+rightfacev( u*N() ) ) )
1225 {
1226  return leftfacev( u*N() )+rightfacev( u*N() );
1227 }
1231 template<typename U>
1232 auto
1233 averagev( U const& u ) -> decltype( .5*( leftfacev( u )+rightfacev( u ) ) )
1234 {
1235  return .5*( leftfacev( u )+rightfacev( u ) );
1236 }
1237 #else
1238 #define jumpv( u ) (::Feel::vf::leftfacev((u)*::Feel::vf::N())+::Feel::vf::rightfacev((u)*::Feel::vf::N()))
1239 
1242 #define averagev( u ) (.5*(::Feel::vf::leftfacev((u))+::Feel::vf::rightfacev((u))))
1243 
1244 #endif
1245 } // vf
1246 } // Feel
1247 #endif /* __TwoValued_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