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
operators2.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: 2005-01-17
7 
8  Copyright (C) 2005,2006 EPFL
9  Copyright (C) 2006,2007 Universite Joseph Fourier (Grenoble I)
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 3.0 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
30 #if !defined( __FEELPP_VF_OPERATORS2_HPP )
31 #define __FEELPP_VF_OPERATORS2_HPP 1
32 
33 # include <boost/preprocessor/stringize.hpp>
34 
35 namespace Feel
36 {
37 namespace vf
38 {
40 template <class Element1, class Element2>
41 class OpMass
42 {
43 public:
44 
45  static const size_type context = vm::JACOBIAN;
46 
47  static const uint16_type imorder = Element1::functionspace_type::basis_type::nOrder+Element2::functionspace_type::basis_type::nOrder;
48  static const bool imIsPoly = true;
49 
50  typedef Element1 test_element_type;
51  typedef Element2 trial_element_type;
52  typedef OpMass<test_element_type, trial_element_type> this_type;
53  typedef this_type self_type;
54 
55  typedef typename test_element_type::return_value_type return_value_type;
56  typedef typename strongest_numeric_type<typename test_element_type::value_type,
57  typename trial_element_type::value_type>::type value_type;
58 
59  typedef ublas::matrix<value_type> matrix_type;
60 
61  OpMass ( test_element_type const& v,
62  trial_element_type const& u )
63  :
64  M_v ( v ),
65  M_u ( u ),
66  M_exact_mass( M_v.functionSpace()->basis()->coeff() )
67  {
68  DVLOG(2) << "[" BOOST_PP_STRINGIZE( OpMass ) "] default constructorn";
69 
70  M_exact_mass = ublas::prod( return_value_type::toMatrix( M_v.functionSpace()->basis()->coeff() ),
71  ublas::trans( return_value_type::toMatrix( M_v.functionSpace()->basis()->coeff() ) ) );
72 
73  }
74  OpMass( OpMass const& op )
75  :
76  M_v ( op.M_v ),
77  M_u ( op.M_u ),
78  M_exact_mass( op.M_exact_mass )
79  //M_quad_mass() TO BE USED IF QUADRATURE IS NEEDED (transformation order >= 2)
80  {
81  DVLOG(2) << "[" BOOST_PP_STRINGIZE( OpMass ) "] copy constructorn";
82 
83  }
84 
85  test_element_type const& testFunction() const
86  {
87  return M_v;
88  }
89  trial_element_type const& trialFunction() const
90  {
91  return M_u;
92  }
93 
94  value_type exactMass( uint16_type i, uint16_type j ) const
95  {
96  return M_exact_mass( i, j );
97  }
98  matrix_type exactMass() const
99  {
100  return M_exact_mass;
101  }
102 
103  template<typename Geo_t, typename Basis_i_t, typename Basis_j_t = Basis_i_t>
104  struct tensor
105  {
106  typedef this_type expression_type;
107  typedef Basis_i_t test_basis_context_type;
108  typedef Basis_j_t trial_basis_context_type;
109 
110  typedef typename test_basis_context_type::value_type value_type;
111  typedef typename test_basis_context_type::polyset_type return_value_type;
112 
113  static const uint16_type nComponents = return_value_type::nComponents;
114 
115  tensor( this_type const& expr,
116  Geo_t const& /*geom*/,
117  Basis_i_t const& fev,
118  Basis_j_t const& feu )
119  :
120  M_mat( expr.exactMass() ),
121  M_fev( fev ),
122  M_feu( feu )
123  {}
124 
125  void update( Geo_t const& geom, Basis_i_t const& fev, Basis_j_t const& feu )
126  {
127  // no need to update in case of exact integration
128 
129  }
130 
131  value_type
132  operator()( uint16_type i, uint16_type j ) const
133  {
134  return M_mat( i, j );
135  }
136 
137 
138  value_type
139  operator()( uint16_type i, uint16_type j, int q ) const
140  {
141  return M_mat( i, j );
142  //return 0;//M_expr.quadratureMass( q, i, j );
143  }
144 
145  test_basis_context_type const& M_fev;
146  trial_basis_context_type const& M_feu;
147  //this_type const& M_expr;
148  matrix_type const& M_mat;
149  };
150 
151 protected:
152  OpMass () {}
153 
154  test_element_type const& M_v;
155  trial_element_type const& M_u;
156  ublas::matrix<value_type> M_exact_mass;
157 };
159 
162 template <class Element1, class Element2>
163 inline Expr< OpMass< Element1, Element2> >
164 mass( Element1 const& el1, Element2 const& el2 )
165 {
166  typedef OpMass< Element1, Element2> expr_t;
167  return Expr< expr_t >( expr_t( el1, el2 ) );
168 }
169 
170 } // vf
171 } // feel
172 
173 #endif /* __FEELPP_VF_OPERATORS2_HPP */

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