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
operatorlinearparametrized.hpp
Go to the documentation of this file.
1 /* -*- mode: c++ -*-
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2010-03-03
7 
8  Copyright (C) 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 2.1 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 __OperatorLinearParametrized_H
30 #define __OperatorLinearParametrized_H 1
31 
33 
34 namespace Feel
35 {
43 template<class DomainSpace, class DualImageSpace>
44 class OperatorLinearParametrized : public OperatorLinear<DomainSpace, DualImageSpace>
45 {
47 public:
48 
49 
53 
54 
56 
60  // -- TYPEDEFS --
63 
64  typedef typename super::domain_space_type domain_space_type;
65  typedef typename super::dual_image_space_type dual_image_space_type;
66  typedef typename super::domain_space_ptrtype domain_space_ptrtype;
67  typedef typename super::dual_image_space_ptrtype dual_image_space_ptrtype;
68  typedef typename domain_space_type::element_type domain_element_type;
69 
70  typedef typename super::backend_type backend_type;
71  typedef typename super::backend_ptrtype backend_ptrtype;
73  typedef typename backend_type::vector_type vector_type;
74  typedef typename backend_type::vector_ptrtype vector_ptrtype;
75  typedef boost::shared_ptr<matrix_type> matrix_ptrtype;
76 
77  template<typename T, typename Storage>
78  struct domain_element: public super::domain_space_type::template Element<T,Storage> {};
79 
80  typedef FsFunctionalLinear<DualImageSpace> image_element_type;
81 
82  /* parameter space */
84  typedef boost::shared_ptr<parameterspace_type> parameterspace_ptrtype;
86  typedef parameterspace_type::element_ptrtype parameter_ptrtype;
88  typedef parameterspace_type::sampling_ptrtype sampling_ptrtype;
89 
90  typedef Eigen::VectorXd theta_vector_type;
91 
93 
97 
100  :
101  super_type()
102  {}
103 
105  OperatorLinearParametrized( OperatorLinearParametrized const & olp, bool deep_copy = false )
106  :
107  super_type( olp, deep_copy )
108  {}
109 
116  OperatorLinearParametrized( domain_space_ptrtype domainSpace,
117  dual_image_space_ptrtype dualImageSpace,
118  backend_ptrtype backend )
119  :
120  super_type( domainSpace, dualImageSpace, backend )
121  {
122  }
123 
126  {}
127 
128  void
129  init( domain_space_ptrtype domainSpace,
130  dual_image_space_ptrtype dualImageSpace,
131  backend_ptrtype backend )
132  {
133  super::init( domainSpace, dualImageSpace, backend );
134  }
136 
140 
143  {
144  if ( this != &o )
145  {
146  }
147 
148  return *this;
149  }
151 
155 
157  parameterspace_ptrtype parameterSpace() const
158  {
159  return M_Dmu;
160  }
161 
165  theta_vector_type const& thetaq() const
166  {
167  return M_thetaq;
168  }
169 
174  value_type thetaq( int q ) const
175  {
176  return M_thetaq( q );
177  }
178 
180 
184 
185 
187 
191 
196  virtual theta_vector_type computeThetaq( parameter_type const& mu ) = 0;
197 
198  // fill underlying matrix
199  template<class ExprT>
200  this_type& add( int q, ExprT const& e )
201  {
202  // M_matrix->clear();
203  form2( this->domainSpace(),
204  this->dualImageSpace(),
205  M_Aq[q],
206  _init=true
207 
208  ) = e;
209  return *this;
210  }
211 
212  // add to underlying matrix
213  template<class ExprT>
214  this_type& operator+=( ExprT const& e )
215  {
216  form2( this->domainSpace(),
217  this->dualImageSpace(),
218  M_matrix,
219  _init=false ) += e;
220  return *this;
221  }
222 
226  offline_merge_type update( parameter_type const& mu )
227  {
228  this->computeThetaq( mu );
229  return offlineMerge( mu );
230  }
231 
236  sparse_matrix_type merge( parameter_type const& mu );
237 
239 
240 
241 
242 protected:
243 
248  std::vector<sparse_matrix_ptrtype> M_Aq;
249 
253  parameterspace_ptrtype M_Dmu;
254 
256  theta_vector_type M_thetaq;
257 };
258 
259 template<class DomainSpace, class DualImageSpace>
262 {
263  sparse_matrix_ptrtype A( M_backend->newMatrix( domainSpace(), dualImageSpace() ) )
264 
265  A->close();
266  *A = *M_Aq[0];
267  A->scale( this->thetaq( 0 ) );
268 
269  for ( int q = 1; q < Qa(); ++q )
270  {
271  A->addMatrix( this->thetaq( q ), M_Aq[q] );
272  }
273 
274  return A;
275 }
276 } // Feel
277 #endif /* __OperatorLinearParametrized_H */
Linear Operator between function spaces, represented by a matrix.
Definition: operatorlinear.hpp:43
sparse_matrix_type merge(parameter_type const &mu)
parameterspace_ptrtype M_Dmu
Definition: operatorlinearparametrized.hpp:253
Definition: solverlinear.hpp:33
OperatorLinearParametrized()
default constructor
Definition: operatorlinearparametrized.hpp:99
parameterspace_ptrtype parameterSpace() const
return the parameter space
Definition: operatorlinearparametrized.hpp:157
OperatorLinearParametrized(domain_space_ptrtype domainSpace, dual_image_space_ptrtype dualImageSpace, backend_ptrtype backend)
Definition: operatorlinearparametrized.hpp:116
theta_vector_type const & thetaq() const
return the coefficient vector
Definition: operatorlinearparametrized.hpp:165
OperatorLinearParametrized(OperatorLinearParametrized const &olp, bool deep_copy=false)
copy constructor
Definition: operatorlinearparametrized.hpp:105
An interface for linear parametrized operators.
Definition: operatorlinearparametrized.hpp:44
value_type thetaq(int q) const
return the coefficient vector q component
Definition: operatorlinearparametrized.hpp:174
Parameter space sampling class.
Definition: parameterspace.hpp:219
std::vector< sparse_matrix_ptrtype > M_Aq
Definition: operatorlinearparametrized.hpp:248
Parameter space class.
Definition: parameterspace.hpp:58
OperatorLinearParametrized & operator=(OperatorLinearParametrized const &o)
copy operator
Definition: operatorlinearparametrized.hpp:142
Definition: matrixsparse.hpp:76
~OperatorLinearParametrized()
destructor
Definition: operatorlinearparametrized.hpp:125
theta_vector_type M_thetaq
coefficients of the Aq matrices
Definition: operatorlinearparametrized.hpp:256
offline_merge_type update(parameter_type const &mu)
update the model wrt mu
Definition: operatorlinearparametrized.hpp:226
virtual theta_vector_type computeThetaq(parameter_type const &mu)=0
compute the theta coefficient for both bilinear and linear form
element of a parameter space
Definition: parameterspace.hpp:84

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