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
constrainedpolynomialset.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-04-30
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 __ConstrainedPolynomialSet_H
30 #define __ConstrainedPolynomialSet_H 1
31 
32 
33 namespace Feel
34 {
35 
36 template<typename P> class Functional;
37 template<typename P> class FunctionalSet;
38 
42 template<typename Poly>
43 class ConstrainedPolynomialSet
44  :
45 public mpl::if_<mpl::bool_<Poly::is_scalar>,
46  mpl::identity<PolynomialSet<Poly> >,
47  mpl::identity<PolynomialSet<Poly, Vectorial> > >::type::type
48 {
49  typedef typename mpl::if_<mpl::bool_<Poly::is_scalar>,
50  mpl::identity<PolynomialSet<Poly> >,
51  mpl::identity<PolynomialSet<Poly, Vectorial> > >::type::type super;
52 public:
56 
57  static const uint16_type nDim = super::nDim;
58  static const uint16_type nOrder = super::nOrder;
59  static const bool is_vectorial = super::is_vectorial;
60  static const bool is_scalar = super::is_scalar;
61  static const uint16_type nComponents = super::nComponents;
63 
67  typedef ConstrainedPolynomialSet<Poly> self_type;
68  typedef Poly space_type;
69  typedef typename super::value_type value_type;
70  typedef typename super::basis_type basis_type;
71 
72  typedef typename super::polyset_type polyset_type;
73  typedef Functional<space_type> constraint_type;
74  typedef FunctionalSet<space_type> constraintset_type;
75 
76 
77  typedef PolynomialSet<space_type, Scalar> component_type;
78  typedef typename mpl::if_<mpl::bool_<is_scalar>,
79  mpl::identity<Polynomial<space_type> >,
80  mpl::identity<Polynomial<space_type, Vectorial> > >::type::type polynomial_type;
81 
82  typedef typename super::convex_type convex_type;
83  typedef typename basis_type::matrix_type matrix_type;
84  typedef typename basis_type::points_type points_type;
85 
86 
87  BOOST_STATIC_ASSERT( ( boost::is_same<typename matrix_type::value_type, value_type>::value ) );
88  BOOST_STATIC_ASSERT( ( boost::is_same<typename matrix_type::value_type, typename points_type::value_type>::value ) );
89 
91 
95 
96  ConstrainedPolynomialSet()
97  :
98  super()
99  {}
100 
101  void setConstraints( constraintset_type const& fset )
102  {
103  // form the matrix associated with the functional fset applied
104  // to the functionSpace
105  matrix_type m( fset( fset.functionSpace() ) );
106 
107  //std::cout << "[ConstrainedPolynomialSet] m = " << m << "\n";
108 
109  // apply svd to determine the intersection of the kernels of
110  // the linear functionals
111  if ( is_vectorial )
112  {
113  //m = vectorialToMatrix( m, nComponents );
114  std::cout << "[ConstrainedPolynomialSet] v2m(m) = " << m << "\n";
115  }
116 
117  SVD<matrix_type> svd( m );
118 
119  //extract the coefficients of V associated with the null
120  //singular values
121  matrix_type mv ( ublas::subrange( svd.V(), svd.S().size(), svd.V().size1(), 0, m.size2() ) );
122  //std::cout << "[ConstrainedPolynomialSet] mv = " << mv << "\n";
123  this->setCoefficient( polyset_type::toType( mv ), true );
124 
125  }
126 
128 };
129 } // Feel
130 #endif /* __ConstrainedPolynomialSet_H */

Generated on Sun Oct 20 2013 08:24:54 for Feel++ by doxygen 1.8.4