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
systemimplicitnonlinear.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: 2009-01-04
7 
8  Copyright (C) 2009 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 __SystemImplicitNonLinear_H
30 #define __SystemImplicitNonLinear_H 1
31 
33 
34 
35 namespace Feel
36 {
44 template<typename SpaceType>
45 class SystemImplicitNonLinear : public SystemImplicit<SpaceType>
46 {
48 public:
49 
50 
54 
55 
57 
61 
64 
65  typedef typename super::value_type value_type;
66  typedef typename super::functionspace_type functionspace_type;
67  typedef typename super::functionspace_type functionspace_ptrtype;
68  typedef typename super::element_type element_type;
69 
70  typedef typename super::backend_type backend_type;
71  typedef typename super::backend_ptrtype backend_ptrtype;
72  typedef typename super::sparse_matrix_type sparse_matrix_type;
73  typedef typename super::sparse_matrix_ptrtype sparse_matrix_ptrtype;
74  typedef typename super::vector_type vector_type;
75  typedef typename super::vector_ptrtype vector_ptrtype;
76 
78 
82 
84  SystemImplicitNonLinear( functionspace_ptrtype const& Xh, po::variables_map const& vm );
89 
91 
95 
98  {
99  if ( this != &o )
100  {
101  super::operator=( o );
102  M_J = o.M_J;
103  M_R = o.M_R;
104  }
105 
106  return *this;
107  }
109 
113 
115  sparse_matrix_ptrtype const& jacobian() const
116  {
117  return M_J;
118  }
119 
121  sparse_matrix_ptrtype& jacobian()
122  {
123  return M_J;
124  }
125 
127  vector_ptrtype const& residual() const
128  {
129  return M_R;
130  }
131 
133  vector_ptrtype & residual()
134  {
135  return M_R;
136  }
137 
139 
143 
144 
146 
150 
152  virtual void updateResidual( const vector_ptrtype& X, vector_ptrtype& R ) = 0;
153 
155  virtual void updateJacobian( const vector_ptrtype& X, sparse_matrix_ptrtype& J ) = 0;
156 
158  void solve( element_type& u )
159  {
160  vector_ptrtype U( M_backend->newVector( this->functionSpace() ) );
161  *U = u;
162 
163  this->updateResidual( U, M_R );
164  this->updateJacobian( U, M_J );
165 
166  M_backend->nlSolve( M_J, U, M_R, 1e-10, 10 );
167  u = *U;
168  }
170 
171 
172 
173 protected:
174 
175  sparse_matrix_ptrtype M_J;
176  vector_ptrtype M_R;
177 
178 private:
179 
180 };
181 template<typename SpaceType>
183  po::variables_map const& vm )
184  :
185  super( Xh, vm ),
186  M_J( M_backend->newMatrix( Xh, Xh ) ),
187  M_R( M_backend->newVector( Xh ) )
188 
189 {
190  M_backend->nlSolver()->residual = boost::bind( &self_type::updateResidual, boost::ref( *this ), _1, _2 );
191  M_backend->nlSolver()->jacobian = boost::bind( &self_type::updateJacobian, boost::ref( *this ), _1, _2 );
192 
193 }
194 template<typename SpaceType>
196  :
197  super( sil ),
198  M_J( sil.M_J ),
199  M_R( sil.M_R )
200 
201 {}
202 
203 
204 }
205 #endif /* __SystemImplicitNonLinear_H */

Generated on Sun Oct 20 2013 08:25:05 for Feel++ by doxygen 1.8.4