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
geometricdata.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: 2006-03-14
7 
8  Copyright (C) 2006 EPFL
9  Copyright (C) 2007-2010 Université Joseph Fourier (Grenoble I)
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 3.0 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
30 #ifndef __GeometricData_H
31 #define __GeometricData_H 1
32 
33 # include <boost/preprocessor/comparison/less.hpp>
34 # include <boost/preprocessor/logical/and.hpp>
35 # include <boost/preprocessor/control/if.hpp>
36 # include <boost/preprocessor/list/at.hpp>
37 # include <boost/preprocessor/list/cat.hpp>
38 # include <boost/preprocessor/list/for_each_product.hpp>
39 # include <boost/preprocessor/logical/or.hpp>
40 # include <boost/preprocessor/tuple/to_list.hpp>
41 # include <boost/preprocessor/tuple/eat.hpp>
42 # include <boost/preprocessor/facilities/empty.hpp>
43 # include <boost/preprocessor/punctuation/comma.hpp>
44 # include <boost/preprocessor/facilities/identity.hpp>
45 
46 namespace Feel
47 {
48 namespace vf
49 {
51 # /* Information about C operators */
52 #
53 # /* Accessors for the operator datatype. */
54 # define VF_GD_SYMBOL(O) BOOST_PP_TUPLE_ELEM(7, 0, O)
55 # define VF_GD_NAME(O) BOOST_PP_TUPLE_ELEM(7, 1, O)
56 # define VF_GD_DIM(O) BOOST_PP_TUPLE_ELEM(7, 2, O)
57 # define VF_GD_CONTEXT(O) BOOST_PP_TUPLE_ELEM(7, 3, O)
58 # define VF_GD_RETURN(O) BOOST_PP_TUPLE_ELEM(7, 4, O)
59 # define VF_GD_VALUE(O) BOOST_PP_TUPLE_ELEM(7, 5, O)
60 # define VF_GD_IMORDER(O) BOOST_PP_TUPLE_ELEM(7, 6, O)
61 
62 #
63 
64 const size_type jn = vm::JACOBIAN|vm::NORMAL;
65 const size_type jkbn = vm::JACOBIAN|vm::KB|vm::NORMAL;
66 const size_type jt = vm::JACOBIAN|vm::NORMAL|vm::TANGENT;
67 const size_type jp = vm::JACOBIAN|vm::POINT;
68 const size_type jkp = vm::KB|vm::JACOBIAN|vm::POINT;
69 
70 # /* List of applicative unary operators. */
71 #if 1
72 # define VF_GD \
73  BOOST_PP_TUPLE_TO_LIST( \
74  21, \
75  ( \
76  ( N , GDN , 0, jkbn, Vectorial, M_gmc->unitNormal( q )[ c1 ] , 0), \
77  ( Nx , GDNx , 0, jkbn, Scalar , M_gmc->unitNormal( q )[ 0 ] , 0), \
78  ( Ny , GDNy , 1, jkbn, Scalar , M_gmc->unitNormal( q )[ 1 ] , 0), \
79  ( Nz , GDNz , 2, jkbn, Scalar , M_gmc->unitNormal( q )[ 2 ] , 0), \
80  ( Nref , GDNref , 0, 0, Vectorial, M_gmc->refNormal( q )[ c1 ] , 0), \
81  ( normalNorm, GDnormalNorm, 0, 0, Scalar, M_gmc->normalNorm( q ) , 0), \
82  ( T , GDT , 0, jt, Vectorial, M_gmc->tangent( q )[ c1 ], 0), \
83  ( Tx , GDTx , 0, jt, Scalar , M_gmc->tangent( q )[ 0 ] , 0), \
84  ( Ty , GDTy , 1, jt, Scalar , M_gmc->tangent( q )[ 1 ] , 0), \
85  ( Tz , GDTz , 2, jt, Scalar , M_gmc->tangent( q )[ 2 ] , 0), \
86  ( detJ , GDDetJ , 0, jp, Scalar , M_gmc->J( q ) , 0), \
87  ( J , GDJ , 0, jkp,Tensor2 , M_gmc->K( c1, c2, q ) , 0), \
88  ( JinvT , GDJinv , 0, jkp,Tensor2 , M_gmc->B( c1, c2, q ) , 0), \
89  ( P , GDP , 0, jp, Vectorial, M_gmc->xReal( q )[ c1 ] , 1), \
90  ( Px , GDPx , 0, jp, Scalar , M_gmc->xReal( q )[ 0 ] , 1), \
91  ( Py , GDPy , 1, jp, Scalar , M_gmc->xReal( q )[ 1 ] , 1), \
92  ( Pz , GDPz , 2, jp, Scalar , M_gmc->xReal( q )[ 2 ] , 1), \
93  ( C , GDC , 0, jp, Vectorial, M_gmc->barycenterReal()[c1] , 0), \
94  ( Cx , GDCx , 0, jp, Scalar , M_gmc->barycenterReal()[0] , 0), \
95  ( Cy , GDCy , 1, jp, Scalar , M_gmc->barycenterReal()[1] , 0), \
96  ( Cz , GDCz , 2, jp, Scalar , M_gmc->barycenterReal()[2] , 0) \
97  ) \
98  )
99 
100 # define VF_GD2 \
101  BOOST_PP_TUPLE_TO_LIST( \
102  9, \
103  ( \
104  ( h , GDH , 0, 0 , Scalar , M_gmc->h() , 0), \
105  ( hFace , GDHFace , 0, 0 , Scalar , M_gmc->hFace() , 0), \
106  ( meas , GDMeas , 0, 0 , Scalar , M_gmc->meas() , 0), \
107  ( measPEN , GDMeasPEN , 0, 0 , Scalar , M_gmc->measurePointElementNeighbors(), 0), \
108  ( nPEN , GDNPEN , 0, 0 , Scalar , M_gmc->element().numberOfPointElementNeighbors(), 0), \
109  ( measFace, GDHMeasFace,0, 0 , Scalar , M_gmc->measFace() , 0), \
110  ( eid , GDEid , 0, 0 , Scalar , M_gmc->id() , 0), \
111  ( emarker , GDEmarker , 0, 0 , Scalar , M_gmc->marker().value() , 0), \
112  ( emarker2, GDEmarker2, 0, 0 , Scalar , M_gmc->marker2().value() , 0) \
113  ) \
114  ) \
115 
116 #else
117 # define VF_GD \
118  BOOST_PP_TUPLE_TO_LIST( \
119  20, \
120  ( \
121  ( N , GDN , 0, jn, Vectorial, M_gmc->unitNormal( q )[ c1 ] , 0), \
122  ( Nx , GDNx , 0, jn, Scalar , M_gmc->unitNormal( q )[ 0 ] , 0), \
123  ( Ny , GDNy , 1, jn, Scalar , M_gmc->unitNormal( q )[ 1 ] , 0), \
124  ( Nz , GDNz , 2, jn, Scalar , M_gmc->unitNormal( q )[ 2 ] , 0), \
125  ( T , GDT , 0, jn, Vectorial, M_gmc->unitTangent( q )[ c1 ], 0), \
126  ( Tx , GDTx , 0, jn, Scalar , M_gmc->unitTangent( q )[ 0 ] , 0), \
127  ( Ty , GDTy , 1, jn, Scalar , M_gmc->unitTangent( q )[ 1 ] , 0), \
128  ( Tz , GDTz , 2, jn, Scalar , M_gmc->unitTangent( q )[ 2 ] , 0), \
129  ( P , GDP , 0, jp, Vectorial, M_gmc->xReal( q )[ c1 ] , 1), \
130  ( Px , GDPx , 0, jp, Scalar , M_gmc->xReal( q )[ 0 ] , 1), \
131  ( Py , GDPy , 1, jp, Scalar , M_gmc->xReal( q )[ 1 ] , 1), \
132  ( Pz , GDPz , 2, jp, Scalar , M_gmc->xReal( q )[ 2 ] , 1), \
133  ( C , GDC , 0, jp, Vectorial, M_gmc->barycenterReal()[c1] , 0), \
134  ( Cx , GDCx , 0, jp, Scalar , M_gmc->barycenterReal()[0] , 0), \
135  ( Cy , GDCy , 1, jp, Scalar , M_gmc->barycenterReal()[1] , 0), \
136  ( Cz , GDCz , 2, jp, Scalar , M_gmc->barycenterReal()[2] , 0), \
137  ( h , GDH , 0, 0 , Scalar , M_gmc->h() , 0), \
138  ( hFace , GDHFace , 0, 0 , Scalar , M_gmc->hFace() , 0), \
139  ( eid , GDEid , 0, 0 , Scalar , M_gmc->id() , 0), \
140  ( emarker , GDEmarker , 0, 0 , Scalar , M_gmc->marker().value() , 0) \
141  ) \
142  ) \
143 
144 
145 #endif
146 #
147 
148 # /* Generates code for all binary operators and integral type pairs. */
149 # define VF_ARRAY_GD(_, O) \
150  VF_ARRAY_GD_CODE O \
151 
152 
153 #define VF_ARRAY_GD_CODE(O) \
154  class VF_GD_NAME( O ) \
155  { \
156  public: \
157  \
158  static const size_type context = VF_GD_CONTEXT( O ); \
159  static const bool is_terminal = false; \
160  \
161  static const uint16_type imorder = VF_GD_IMORDER(O); \
162  static const bool imIsPoly = true; \
163  \
164  template<typename Func> \
165  struct HasTestFunction \
166  { \
167  static const bool result = false; \
168  }; \
169  \
170  template<typename Func> \
171  struct HasTrialFunction \
172  { \
173  static const bool result = false; \
174  }; \
175  typedef VF_GD_NAME(O) this_type; \
176  typedef double value_type; \
177  \
178  VF_GD_NAME(O) () \
179  { \
180  } \
181  VF_GD_NAME(O) ( VF_GD_NAME(O) const& /*__vf*/ ) \
182  { \
183  } \
184  template<typename TheExpr> \
185  struct Lambda \
186  { \
187  typedef this_type type; \
188  }; \
189  template<typename TheExpr> \
190  typename Lambda<TheExpr>::type \
191  operator()( TheExpr const& e ) { return this_type(); } \
192  \
193  \
194  template<typename Geo_t, typename Basis_i_t, typename Basis_j_t = Basis_i_t> \
195  struct tensor \
196  { \
197  typedef this_type expression_type; \
198  typedef typename mpl::if_<fusion::result_of::has_key<Geo_t,vf::detail::gmc<0> >, \
199  mpl::identity<vf::detail::gmc<0> >, \
200  mpl::identity<vf::detail::gmc<1> > >::type::type key_type; \
201  typedef typename fusion::result_of::value_at_key<Geo_t,key_type>::type::element_type* gmc_ptrtype; \
202  typedef typename fusion::result_of::value_at_key<Geo_t,key_type>::type::element_type gmc_type; \
203  typedef typename gmc_type::value_type value_type; \
204  typedef VF_GD_RETURN(O)<gmc_type::NDim> return_value_type; \
205  typedef Shape<gmc_type::NDim, VF_GD_RETURN(O), false> shape; \
206  \
207  struct is_zero { static const bool value = false; }; \
208  \
209  tensor( this_type const& /*expr*/, \
210  Geo_t const& geom, \
211  Basis_i_t const& /*fev*/, Basis_j_t const& /*feu*/ ) \
212  : \
213  M_gmc( fusion::at_key<key_type>( geom ).get() ) \
214  {} \
215  tensor( this_type const& /*expr*/, \
216  Geo_t const& geom, \
217  Basis_i_t const& /*fev*/ ) \
218  : \
219  M_gmc( fusion::at_key<key_type>( geom ).get() ) \
220  {} \
221  tensor( this_type const& /*expr*/, \
222  Geo_t const& geom ) \
223  : \
224  M_gmc( fusion::at_key<key_type>( geom ).get() ) \
225  {} \
226  template<typename IM> \
227  void init( IM const& im ) \
228  { \
229  } \
230  void update( Geo_t const& geom, Basis_i_t const& /*fev*/, Basis_j_t const& /*feu*/ ) \
231  { \
232  update( geom ); \
233  } \
234  void update( Geo_t const& geom, Basis_i_t const& /*fev*/ ) \
235  { \
236  update( geom ); \
237  } \
238  void update( Geo_t const& geom ) \
239  { \
240  M_gmc = fusion::at_key<key_type>( geom ).get(); \
241  } \
242  void update( Geo_t const& geom, uint16_type face ) \
243  { \
244  /*BOOST_STATIC_ASSERT( dim_ok );*/ \
245  update( geom ); \
246  } \
247  \
248  value_type \
249  evalijq( uint16_type /*i*/, uint16_type /*j*/, uint16_type c1, uint16_type c2, uint16_type q ) const \
250  { \
251  return evalq_( c1, c2, q, mpl::bool_<(VF_GD_DIM(O) < gmc_type::NDim)>(), mpl::int_<100>() ); \
252  } \
253  template<int PatternContext> \
254  value_type \
255  evalijq( uint16_type /*i*/, uint16_type /*j*/, uint16_type c1, uint16_type c2, uint16_type q, mpl::int_<PatternContext> ) const \
256  { \
257  return evalq_( c1, c2, q, mpl::bool_<(VF_GD_DIM(O) < gmc_type::NDim)>(), mpl::int_<100>() ); \
258  } \
259  \
260  value_type \
261  evaliq( uint16_type /*i*/, uint16_type c1, uint16_type c2, uint16_type q ) const \
262  { \
263  return evalq_( c1, c2, q, mpl::bool_<(VF_GD_DIM(O) < gmc_type::NDim)>(), mpl::int_<100>() ); \
264  } \
265  value_type \
266  evalq( uint16_type c1, uint16_type c2, uint16_type q ) const \
267  { \
268  return evalq_( c1, c2, q, mpl::bool_<(VF_GD_DIM(O) < gmc_type::NDim)>(), mpl::int_<100>() ); \
269  } \
270  private: \
271  value_type \
272  evalq_( uint16_type, uint16_type, uint16_type /*q*/, mpl::bool_<false>, mpl::int_<100> ) const \
273  { \
274  return 0; \
275  } \
276  value_type \
277  evalq_( uint16_type c1, uint16_type c2, uint16_type q, mpl::bool_<true>, mpl::int_<100> ) const \
278  { \
279  Feel::detail::ignore_unused_variable_warning(q); \
280  Feel::detail::ignore_unused_variable_warning(c1); \
281  Feel::detail::ignore_unused_variable_warning(c2); \
282  return VF_GD_VALUE( O ); \
283  } \
284  gmc_ptrtype M_gmc; \
285  }; \
286  }; \
287  inline \
288  Expr< VF_GD_NAME( O )> \
289  VF_GD_SYMBOL(O)() \
290  { \
291  typedef VF_GD_NAME( O ) expr_t; \
292  return Expr< expr_t >( expr_t() ); \
293  } \
294 
295 
296 //
297 // Generate the code
298 //
299 BOOST_PP_LIST_FOR_EACH_PRODUCT( VF_ARRAY_GD, 1, ( VF_GD ) )
300 BOOST_PP_LIST_FOR_EACH_PRODUCT( VF_ARRAY_GD, 1, ( VF_GD2 ) )
302 } // vf
303 } // Feel
304 #endif /* __GeometricData_H */
size_t size_type
Indices (starting from 0)
Definition: feelcore/feel.hpp:319

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