Rheolef  7.1
an efficient C++ finite element environment
tensor3.h
Go to the documentation of this file.
1 # ifndef _RHEOLEF_TENSOR3_H
2 # define _RHEOLEF_TENSOR3_H
3 //
4 // This file is part of Rheolef.
5 //
6 // Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7 //
8 // Rheolef is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // Rheolef is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with Rheolef; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 //
22 // =========================================================================
23 
24 namespace rheolef {
65 } // namespace rheolef
66 
67 #include "rheolef/point.h"
68 #include "rheolef/tensor.h"
69 namespace rheolef {
70 
71 // [verbatim_tensor3_basic]
72 template<class T>
74 public:
75 
76  typedef size_t size_type;
77  typedef T element_type;
78  typedef T float_type;
79 
80 // allocators:
81 
82  tensor3_basic (const T& init_val = 0);
84 
85 // affectation:
86 
88  tensor3_basic<T>& operator= (const T& val);
89 
90 // accessors:
91 
93  const T& operator()(size_type i, size_type j, size_type k) const;
94 
95 // algebra
96  tensor3_basic<T> operator* (const T& k) const;
97  tensor3_basic<T> operator/ (const T& k) const;
104  tensor3_basic<T>& operator*= (const T& k);
105  tensor3_basic<T>& operator/= (const T& k) { return operator*= (1./k); }
106 
107 // inputs/outputs:
108 
109  std::ostream& put (std::ostream& s, size_type d = 3) const;
110  std::istream& get (std::istream&);
111 // [verbatim_tensor3_basic]
112 
113 // data:
114 protected:
115  T _x [3][3][3];
116 // [verbatim_tensor3_basic_cont]
117 };
118 // [verbatim_tensor3_basic_cont]
119 
120 // [verbatim_tensor3]
122 // [verbatim_tensor3]
123 
124 // -----------------------------------------------------------------------
125 // inlined
126 // -----------------------------------------------------------------------
127 template<class T> struct float_traits<tensor3_basic<T> > { typedef typename float_traits<T>::type type; };
128 template<class T> struct scalar_traits<tensor3_basic<T> > { typedef T type; };
129 
130 template<class T>
131 inline
133 {
134  operator= (init_val);
135 }
136 template<class T>
137 inline
139 {
140  operator= (a);
141 }
142 template<class T>
143 inline
144 T&
146 {
147  return _x[i%3][j%3][k%3];
148 }
149 template<class T>
150 inline
151 const T&
153 {
154  return _x[i%3][j%3][k%3];
155 }
156 template <class T>
157 inline
160 {
161  tensor3_basic<T> b = *this;
162  b *= k;
163  return b;
164 }
165 template <class T, class U>
166 inline
167 typename
168 std::enable_if<
171 >::type
172 operator* (const U& k, const tensor3_basic<T>& a)
173 {
174  return a*k;
175 }
176 template <class T>
177 inline
180 {
181  return operator* (1./k);
182 }
183 template <class U>
184 U dddot (const tensor3_basic<U>&, const tensor3_basic<U>&);
185 
186 template <class T>
187 inline
188 T
190 {
191  return dddot(a,a);
192 }
193 template <class T>
194 inline
195 T
197 {
198  return norm2(a-b);
199 }
200 template <class U>
201 inline
202 U
204 {
205  return sqrt(norm2(a));
206 }
207 template <class U>
208 inline
209 U
211 {
212  return norm(a-b);
213 }
214 
215 // inputs/outputs:
216 template<class T>
217 inline
218 std::istream& operator>> (std::istream& in, tensor3_basic<T>& a)
219 {
220  return a.get (in);
221 }
222 template<class T>
223 inline
224 std::ostream& operator<< (std::ostream& out, const tensor3_basic<T>& a)
225 {
226  return a.put (out);
227 }
228 
229 }// namespace rheolef
230 # endif /* _RHEOLEF_TENSOR3_H */
rheolef::float_traits< tensor3_basic< T > >::type
float_traits< T >::type type
Definition: tensor3.h:127
rheolef::tensor3
tensor3_basic< Float > tensor3
Definition: tensor3.h:121
rheolef::tensor3_basic::get
std::istream & get(std::istream &)
rheolef::float_traits
helper for std::complex<T>: get basic T type
Definition: Float.h:93
rheolef::io::out
Definition: rheostream.h:167
rheolef::point_basic
Definition: point.h:87
rheolef::tensor3_basic::float_type
T float_type
Definition: tensor3.h:78
rheolef::tensor3_basic::operator*=
tensor3_basic< T > & operator*=(const T &k)
Definition: tensor3.cc:126
rheolef::tensor3_basic::_x
T _x[3][3][3]
Definition: tensor3.h:115
rheolef::operator*
csr< T, sequential > operator*(const T &lambda, const csr< T, sequential > &a)
Definition: csr.h:437
rheolef::tensor_basic
Definition: tensor.h:90
rheolef::dddot
T dddot(const tensor3_basic< T > &a, const tensor3_basic< T > &b)
Definition: tensor3.cc:94
rheolef::type
rheolef::std type
rheolef::tensor3_basic::operator*
tensor3_basic< T > operator*(const T &k) const
Definition: tensor3.h:159
rheolef::norm
T norm(const vec< T, M > &x)
norm(x): see the expression page for the full documentation
Definition: vec.h:387
rheolef::norm2
T norm2(const vec< T, M > &x)
norm2(x): see the expression page for the full documentation
Definition: vec.h:379
rheolef::tensor3_basic::operator=
tensor3_basic< T > & operator=(const tensor3_basic< T > &a)
Definition: tensor3.cc:38
rheolef::tensor3_basic::operator/=
tensor3_basic< T > & operator/=(const T &k)
Definition: tensor3.h:105
rheolef::tensor3_basic::element_type
T element_type
Definition: tensor3.h:77
a
Definition: diffusion_isotropic.h:25
rheolef::tensor3_basic::put
std::ostream & put(std::ostream &s, size_type d=3) const
Definition: tensor3.cc:140
rheolef::tensor3_basic< T >
tensor_basic< T > tensor3_basic< T >
Definition: piola_fem.h:137
rheolef::tensor3_basic::size_type
size_t size_type
Definition: tensor3.h:76
rheolef::scalar_traits< tensor3_basic< T > >::type
T type
Definition: tensor3.h:128
rheolef::tensor3_basic
Definition: tensor3.h:73
rheolef::tensor3_basic::operator/
tensor3_basic< T > operator/(const T &k) const
Definition: tensor3.h:179
rheolef::operator>>
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition: catchmark.h:88
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::float_traits::type
T type
Definition: Float.h:94
rheolef::tensor3_basic::operator+
tensor3_basic< T > operator+(const tensor3_basic< T > &b) const
Definition: tensor3.cc:72
mkgeo_ball.d
d
Definition: mkgeo_ball.sh:154
mkgeo_ball.b
b
Definition: mkgeo_ball.sh:152
rheolef::tensor3_basic::operator+=
tensor3_basic< T > & operator+=(const tensor3_basic< T > &)
Definition: tensor3.cc:106
rheolef::details::is_rheolef_arithmetic
Definition: Float.h:150
size_type
field::size_type size_type
Definition: branch.cc:425
rheolef::scalar_traits
helper for point_basic<T> & tensor_basic<T>: get basic T type
Definition: point.h:324
rheolef::tensor3_basic::operator-
tensor3_basic< T > operator-(const tensor3_basic< T > &b) const
Definition: tensor3.cc:83
rheolef::tensor3_basic::tensor3_basic
tensor3_basic(const T &init_val=0)
Definition: tensor3.h:132
rheolef::tensor3_basic::operator-=
tensor3_basic< T > & operator-=(const tensor3_basic< T > &)
Definition: tensor3.cc:116
rheolef::tensor3_basic::operator()
T & operator()(size_type i, size_type j, size_type k)
Definition: tensor3.h:145
rheolef::operator<<
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition: catchmark.h:99
rheolef::dist2
T dist2(const point_basic< T > &x, const point_basic< T > &y)
Definition: point.h:293
T
Expr1::float_type T
Definition: field_expr.h:218
rheolef::dist
T dist(const point_basic< T > &x, const point_basic< T > &y)
Definition: point.h:299