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
symm.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): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2007-03-05
7 
8  Copyright (C) 2007-2011 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 __Sym_H
30 #define __Sym_H 1
31 
32 namespace Feel
33 {
34 namespace vf
35 {
37 
44 template<typename ExprT, int Part = 1>
45 class Sym
46 {
47 public:
48 
49  static const size_type context = ExprT::context;
50  static const bool is_symetric = Part;
51  static const bool is_terminal = false;
52 
53  static const uint16_type imorder = ExprT::imorder;
54  static const bool imIsPoly = ExprT::imIsPoly;
55 
56  template<typename Func>
57  struct HasTestFunction
58  {
59  static const bool result = ExprT::template HasTestFunction<Func>::result;
60  };
61 
62  template<typename Func>
63  struct HasTrialFunction
64  {
65  static const bool result = ExprT::template HasTrialFunction<Func>::result;
66  };
67 
68 
72 
73  typedef ExprT expression_type;
74  typedef typename expression_type::value_type value_type;
75  typedef Sym<ExprT,Part> this_type;
76 
77 
79 
83 
84  explicit Sym( expression_type const & __expr )
85  :
86  M_expr( __expr )
87  {}
88  Sym( Sym const & te )
89  :
90  M_expr( te.M_expr )
91  {}
92  ~Sym()
93  {}
94 
96 
100 
101 
103 
107 
108 
110 
114 
115 
117 
121 
122  expression_type const& expression() const
123  {
124  return M_expr;
125  }
126 
128 
129  template<typename Geo_t, typename Basis_i_t, typename Basis_j_t>
130  struct tensor
131  {
132  typedef typename expression_type::template tensor<Geo_t, Basis_i_t, Basis_j_t> tensor_expr_type;
133  typedef typename tensor_expr_type::value_type value_type;
134 
135  typedef typename tensor_expr_type::shape shape;
136 
137  template <class Args> struct sig
138  {
139  typedef value_type type;
140  };
141 
142  struct is_zero
143  {
144  static const bool value = tensor_expr_type::is_zero::value;
145  };
146 
147  tensor( this_type const& expr,
148  Geo_t const& geom, Basis_i_t const& fev, Basis_j_t const& feu )
149  :
150  M_tensor_expr( expr.expression(), geom, fev, feu )
151  {
152  }
153 
154  tensor( this_type const& expr,
155  Geo_t const& geom, Basis_i_t const& fev )
156  :
157  M_tensor_expr( expr.expression(), geom, fev )
158  {
159  }
160 
161  tensor( this_type const& expr, Geo_t const& geom )
162  :
163  M_tensor_expr( expr.expression(), geom )
164  {
165  }
166 
167  template<typename IM>
168  void init( IM const& im )
169  {
170  M_tensor_expr.init( im );
171  }
172  void update( Geo_t const& geom, Basis_i_t const& fev, Basis_j_t const& feu )
173  {
174  M_tensor_expr.update( geom, fev, feu );
175  }
176  void update( Geo_t const& geom, Basis_i_t const& fev )
177  {
178  M_tensor_expr.update( geom, fev );
179  }
180  void update( Geo_t const& geom )
181  {
182  M_tensor_expr.update( geom );
183  }
184  void update( Geo_t const& geom, uint16_type face )
185  {
186  M_tensor_expr.update( geom, face );
187  }
188 
189  value_type
190  evalijq( uint16_type i, uint16_type j, uint16_type c1, uint16_type c2, uint16_type q ) const
191  {
192  value_type a = M_tensor_expr.evalijq( i, j, c1, c2, q );
193  value_type at = M_tensor_expr.evalijq( i, j, c2, c1, q );
194 
195  if ( Part == 1 )
196  return 0.5*( a+at );
197 
198  else
199  return 0.5*( a-at );
200  }
201  value_type
202  evaliq( uint16_type i, uint16_type c1, uint16_type c2, uint16_type q ) const
203  {
204  value_type a = M_tensor_expr.evaliq( i, c1, c2, q );
205  value_type at = M_tensor_expr.evaliq( i, c2, c1, q );
206 
207  if ( Part == 1 )
208  return 0.5*( a+at );
209 
210  else
211  return 0.5*( a-at );
212  }
213  value_type
214  evalq( uint16_type c1, uint16_type c2, uint16_type q ) const
215  {
216  value_type a = M_tensor_expr.evalq( c1, c2, q );
217  value_type at = M_tensor_expr.evalq( c2, c1, q );
218 
219  if ( Part == 1 )
220  return 0.5*( a+at );
221 
222  else
223  return 0.5*( a-at );
224  }
225 
226  private:
227  tensor_expr_type M_tensor_expr;
228  };
229 
230 private:
231  mutable expression_type M_expr;
232 };
234 
238 template<typename ExprT>
239 inline
240 Expr< Sym<ExprT,1> >
241 sym( ExprT v )
242 {
243  typedef Sym<ExprT,1> sym_t;
244  return Expr< sym_t >( sym_t( v ) );
245 }
246 
250 template<typename ExprT>
251 inline
252 Expr< Sym<ExprT,0> >
253 antisym( ExprT v )
254 {
255  typedef Sym<ExprT,0> sym_t;
256  return Expr< sym_t >( sym_t( v ) );
257 }
258 
259 }
260 }
261 #endif /* __Unsym_H */

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