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
fec.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-03-13
7 
8  Copyright (C) 2009-2011 Universite 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 __FEC_H
30 #define __FEC_H 1
31 
32 namespace Feel
33 {
34 namespace vf
35 {
37 namespace detail
38 {
39 template<uint16_type Type, typename FormContextType>
40 struct FEContextInit
41 {
42  // 0 : test, 1 : trial
43  static const uint16_type type = Type;
44 
45  typedef typename mpl::if_<mpl::equal_to<mpl::int_<type>, mpl::int_<0> >, mpl::identity<typename FormContextType::test_fe_type>, mpl::identity<typename FormContextType::trial_fe_type> >::type::type fe_type;
46  typedef boost::shared_ptr<fe_type> fe_ptrtype;
47  typedef typename mpl::if_<mpl::equal_to<mpl::int_<type>, mpl::int_<0> >, mpl::identity<typename FormContextType::test_fecontext_type>,mpl::identity<typename FormContextType::trial_fecontext_type> >::type::type fecontext_type;
48  typedef boost::shared_ptr<fecontext_type> fecontext_ptrtype;
49 
50  typedef typename mpl::if_<mpl::equal_to<mpl::int_<type>, mpl::int_<0> >,
51  mpl::identity<typename FormContextType::test_geometric_mapping_context_ptrtype>,
52  mpl::identity<typename FormContextType::trial_geometric_mapping_context_ptrtype> >::type::type geometric_mapping_context_ptrtype;
53 
54  //typedef typename FormContextType::test_geometric_mapping_context_ptrtype geometric_mapping_context_ptrtype;
55 
56  //typedef typename FormContextType::form_type form_type;
57  typedef FormContextType form_type;
58  typedef boost::shared_ptr<form_type> form_ptrtype;
59 
60  template<typename Sig>
61  struct result;
62 
63  template<typename T>
64  struct result<FEContextInit( T )>
65  {
66  typedef fusion::pair<typename boost::remove_reference<T>::type::first_type,fecontext_ptrtype> type;
67  };
68 
69  FEContextInit( fe_ptrtype const& fe, FormContextType const& form )
70  :
71  M_fe( fe ),
72  M_form( form )
73  {}
74  template<typename T>
75  fusion::pair<typename boost::remove_reference<T>::type::first_type,fecontext_ptrtype>
76  operator()( T const& t ) const
77  {
78  return operator()( t, mpl::int_<type>() );
79  }
80 
81 private:
82 
83  // Test FE context
84  template<typename T>
85  fusion::pair<typename boost::remove_reference<T>::type::first_type,fecontext_ptrtype>
86  operator()( T const& t, mpl::int_<0> ) const
87  {
88  geometric_mapping_context_ptrtype gmcptr( t.second );
89  typedef typename boost::remove_reference<T>::type::first_type first_type;
90  return fusion::make_pair<first_type>( fecontext_ptrtype( new fecontext_type( M_fe,
91  gmcptr,
92  M_form.testPc( gmcptr->faceId(), gmcptr->permutation() ) ) ) );
93  }
94 
95  // Trial FE context
96  template<typename T>
97  fusion::pair<typename boost::remove_reference<T>::type::first_type,fecontext_ptrtype>
98  operator()( T const& t, mpl::int_<1> ) const
99  {
100  geometric_mapping_context_ptrtype gmcptr( t.second );
101  typedef typename boost::remove_reference<T>::type::first_type first_type;
102  return fusion::make_pair<first_type>( fecontext_ptrtype( new fecontext_type( M_fe,
103  gmcptr,
104  M_form.trialPc( gmcptr->faceId(), gmcptr->permutation() ) ) ) );
105  }
106 
107  fe_ptrtype const& M_fe;
108  form_type const& M_form;
109 };
110 
111 
112 template<uint16_type Type, typename FormContextType>
113 struct FEContextUpdate
114 {
115  // 0 : test, 1 : trial
116  static const uint16_type type = Type;
117 
118  //typedef typename FormContextType::test_geometric_mapping_context_ptrtype geometric_mapping_context_ptrtype;
119  //typedef typename FormContextType::map_test_geometric_mapping_context_type map_geometric_mapping_context_type;
120  typedef typename mpl::if_<mpl::equal_to<mpl::int_<type>, mpl::int_<0> >,
121  mpl::identity<typename FormContextType::test_geometric_mapping_context_ptrtype>,
122  mpl::identity<typename FormContextType::trial_geometric_mapping_context_ptrtype> >::type::type geometric_mapping_context_ptrtype;
123 
124  typedef typename mpl::if_<mpl::equal_to<mpl::int_<type>, mpl::int_<0> >,
125  mpl::identity<typename FormContextType::map_test_geometric_mapping_context_type>,
126  mpl::identity<typename FormContextType::map_trial_geometric_mapping_context_type> >::type::type map_geometric_mapping_context_type;
127 
128 
129  //typedef typename FormContextType::form_type form_type;
130  typedef FormContextType form_type;
131  typedef boost::shared_ptr<form_type> form_ptrtype;
132 
133  FEContextUpdate( map_geometric_mapping_context_type const& mapgmc,
134  form_type const& form )
135  :
136  M_mapgmc( mapgmc ),
137  M_form( form )
138  {}
139 
140  template<typename T>
141  void operator()( T& t ) const
142  {
143  return operator()( t, mpl::int_<type>() );
144  }
145  template<typename T>
146  void operator()( T& t, mpl::int_<0> ) const
147  {
148  typedef typename boost::remove_reference<T>::type::first_type first_type;
149  geometric_mapping_context_ptrtype gmcptr( fusion::at_key<first_type>( M_mapgmc ) );
150  t.second->update( gmcptr, M_form.testPc( gmcptr->faceId(), gmcptr->permutation() ) );
151  }
152  template<typename T>
153  void operator()( T& t, mpl::int_<1> ) const
154  {
155  typedef typename boost::remove_reference<T>::type::first_type first_type;
156  geometric_mapping_context_ptrtype gmcptr( fusion::at_key<first_type>( M_mapgmc ) );
157  t.second->update( gmcptr, M_form.trialPc( gmcptr->faceId(), gmcptr->permutation() ) );
158  }
159 
160  map_geometric_mapping_context_type const& M_mapgmc;
161  form_type const& M_form;
162 };
163 
164 
165 }
167 } // vf
168 }
169 #endif /* __FEC_H */

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