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
convection.hpp
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): Samuel Quinodoz
6  Christophe Prud'homme <christophe.prudhomme@feelpp.org>
7  Date: 2009-02-25
8 
9  Copyright (C) 2007 Samuel Quinodoz
10  Copyright (C) 2009 Université Joseph Fourier (Grenoble I)
11 
12  This library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU Lesser General Public
14  License as published by the Free Software Foundation; either
15  version 3.0 of the License, or (at your option) any later version.
16 
17  This library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  Lesser General Public License for more details.
21 
22  You should have received a copy of the GNU Lesser General Public
23  License along with this library; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26 #ifndef __Convection_H
27 #define __Convection_H 1
28 
35 #include <feel/options.hpp>
36 //#include <feel/feelcore/applicationxml.hpp>
38 
39 // (non)linear algebra backend
40 #include <feel/feelalg/backend.hpp>
41 
42 // quadrature rules
43 #include <feel/feelpoly/im.hpp>
44 
45 // function space
46 #include <feel/feeldiscr/functionspace.hpp>
47 
48 // linear operators
50 #include <feel/feeldiscr/operatorlagrangep1.hpp>
51 
52 // exporter
53 #include <feel/feelfilters/exporter.hpp>
54 
55 
56 
57 // use the Feel namespace
58 using namespace Feel;
59 using namespace Feel::vf;
60 
61 #if !defined( CONVECTION_DIM )
62 #define CONVECTION_DIM 2
63 #endif
64 #if !defined( CONVECTION_ORDER_U )
65 #define CONVECTION_ORDER_U 2
66 #endif
67 #if !defined( CONVECTION_ORDER_P )
68 #define CONVECTION_ORDER_P 1
69 #endif
70 #if !defined( CONVECTION_ORDER_T )
71 #define CONVECTION_ORDER_T 2
72 #endif
73 #if !defined( CRB_SOLVER )
74 #define CRB_SOLVER 0
75 #endif
76 
85 //template< int Order_s, int Order_p, int Order_t >
86 class Convection : public Application
87 {
88  typedef Application super;
89 public:
90 
91  //typedef Convection<Order_s, Order_p, Order_t> self_type;
92  static const int Order_s = CONVECTION_ORDER_U;
93  static const int Order_p = CONVECTION_ORDER_P;
94  static const int Order_t = CONVECTION_ORDER_T;
95  typedef Convection self_type;
96 
97  // Definitions pour mesh
100  typedef boost::shared_ptr<mesh_type> mesh_ptrtype;
101 
103  typedef boost::shared_ptr<backend_type> backend_ptrtype;
104 
105  typedef backend_type::sparse_matrix_ptrtype sparse_matrix_ptrtype;
106  typedef backend_type::vector_ptrtype vector_ptrtype;
107 
108  // space and associated elements definitions
109  typedef Lagrange<Order_s, Vectorial,Continuous,PointSetFekete> basis_u_type; // velocity space
110  typedef Lagrange<Order_p, Scalar,Continuous,PointSetFekete> basis_p_type; // pressure space
111  typedef Lagrange<Order_t, Scalar,Continuous,PointSetFekete> basis_t_type; // temperature space
112 
113 #if defined( FEELPP_USE_LM )
114  typedef Lagrange<0, Scalar> basis_l_type; // multipliers for pressure space
115  typedef bases< basis_u_type , basis_p_type , basis_t_type,basis_l_type> basis_type;
116 #else
117  typedef bases< basis_u_type , basis_p_type , basis_t_type> basis_type;
118 #endif
119 
121  typedef double value_type;
122 
125  typedef boost::shared_ptr<space_type> space_ptrtype;
126  typedef typename space_type::element_type element_type;
127  typedef typename element_type:: sub_element<0>::type element_0_type;
128  typedef typename element_type:: sub_element<1>::type element_1_type;
129  typedef typename element_type:: sub_element<2>::type element_2_type;
130 #if defined( FEELPP_USE_LM )
131  typedef typename element_type:: sub_element<3>::type element_3_type;
132 #endif
133 
135  typedef boost::shared_ptr<oplin_type> oplin_ptrtype;
136  typedef FsFunctionalLinear<space_type> funlin_type;
137  typedef boost::shared_ptr<funlin_type> funlin_ptrtype;
138 
139  // Definition pour les exportations
141 
142  // Constructeur
143  Convection( int argc , char** argv , AboutData const& , po::options_description const& );
144 
145  // generate the mesh
146  Feel::gmsh_ptrtype createMesh();
147 
148 
149  // Definition de la procedure pour faire tourner le code
150  void run();
151 
152  void updateResidual( const vector_ptrtype& X, vector_ptrtype& R );
153  void updateJacobian( const vector_ptrtype& X, sparse_matrix_ptrtype& J );
154 
155 
156  // Definition de la procedure pour resoudre le systeme lineaire
157  void solve( sparse_matrix_ptrtype& D, element_type& u, vector_ptrtype& F );
158 
159  // Definition de la procedure pour exporter les solutions
160  void exportResults( boost::format, element_type& U, double t );
161  void exportResults( element_type& U, int i );
162 
163 private:
164  void initLinearOperator( sparse_matrix_ptrtype& L );
165  void initLinearOperator2( sparse_matrix_ptrtype& L );
166  void updateJacobian1( const vector_ptrtype& X, sparse_matrix_ptrtype& J );
167  void updateJacobian2( const vector_ptrtype& X, sparse_matrix_ptrtype& J );
168 private:
169 
170  backend_ptrtype M_backend;
171 
172  space_ptrtype Xh;
173  boost::shared_ptr<OperatorLagrangeP1<typename space_type::sub_functionspace<2>::type::element_type> > P1h;
174 
175  oplin_ptrtype M_oplin;
176  funlin_ptrtype M_lf;
177 
178  sparse_matrix_ptrtype M_L;
179  sparse_matrix_ptrtype M_D;
180  vector_ptrtype F;
181 
182  //pas de temps
183  //value_type dt;
184 
185  // Exporters
186  boost::shared_ptr<export_type> exporter;
187 
188  // Timers
189  std::map<std::string,std::pair<boost::timer,double> > timers;
190 
191  std::vector <double> Grashofs;
192  double M_current_Grashofs;
193  double M_current_Prandtl;
194 };
195 #endif /* __Convection_H */

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