tensor_value.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_TENSOR_VALUE_H
21 #define LIBMESH_TENSOR_VALUE_H
22 
23 // Local includes
24 #include "libmesh/type_tensor.h"
25 
26 // C++ includes
27 
28 namespace libMesh
29 {
30 
39 template <typename T>
40 class TensorValue : public TypeTensor<T>
41 {
42 public:
43 
48  TensorValue ();
49 
54  explicit TensorValue (const T xx,
55  const T xy=0,
56  const T xz=0,
57  const T yx=0,
58  const T yy=0,
59  const T yz=0,
60  const T zx=0,
61  const T zy=0,
62  const T zz=0);
63 
68  template <typename Scalar>
69  explicit TensorValue (const Scalar xx,
70  const Scalar xy=0,
71  const Scalar xz=0,
72  const Scalar yx=0,
73  const Scalar yy=0,
74  const Scalar yz=0,
75  const Scalar zx=0,
76  const Scalar zy=0,
77  typename
78  boostcopy::enable_if_c<ScalarTraits<Scalar>::value,
79  const Scalar>::type zz=0);
80 
84  template <typename T2>
85  TensorValue (const TypeVector<T2>& vx);
86 
90  template <typename T2>
91  TensorValue (const TypeVector<T2>& vx, const TypeVector<T2>& vy);
92 
96  template <typename T2>
97  TensorValue (const TypeVector<T2>& vx, const TypeVector<T2>& vy, const TypeVector<T2>& vz);
98 
99 
103  template <typename T2>
104  TensorValue (const TensorValue<T2>& p);
105 
109  template <typename T2>
110  TensorValue (const TypeTensor<T2>& p);
111 
112 
113 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
114 
119  TensorValue (const TypeTensor<Real>& p_re,
120  const TypeTensor<Real>& p_im);
121 #endif
122 
123 
127  template <typename Scalar>
128  typename boostcopy::enable_if_c<
129  ScalarTraits<Scalar>::value,
130  TensorValue&>::type
131  operator = (const Scalar& p)
132  { libmesh_assert_equal_to (p, Scalar(0)); this->zero(); return *this; }
133 
134 
135 private:
136 
137 
138 };
139 
140 
141 
146 typedef TensorValue<Real> RealTensorValue;
147 typedef TensorValue<Number> NumberTensorValue;
149 typedef NumberTensorValue Tensor;
150 
151 
152 
153 //------------------------------------------------------
154 // Inline functions
155 template <typename T>
156 inline
158  TypeTensor<T> ()
159 {
160 }
161 
162 
163 
164 template <typename T>
165 inline
167  (const T xx,
168  const T xy,
169  const T xz,
170  const T yx,
171  const T yy,
172  const T yz,
173  const T zx,
174  const T zy,
175  const T zz) :
176  TypeTensor<T> (xx,xy,xz,yx,yy,yz,zx,zy,zz)
177 {
178 }
179 
180 
181 template <typename T>
182 template <typename Scalar>
183 inline
185  (const Scalar xx,
186  const Scalar xy,
187  const Scalar xz,
188  const Scalar yx,
189  const Scalar yy,
190  const Scalar yz,
191  const Scalar zx,
192  const Scalar zy,
193  typename
195  const Scalar>::type zz) :
196  TypeTensor<T> (xx,xy,xz,yx,yy,yz,zx,zy,zz)
197 {
198 }
199 
200 
201 
202 template <typename T>
203 template <typename T2>
204 inline
206  TypeTensor<T> (p)
207 {
208 }
209 
210 
211 
212 template <typename T>
213 template <typename T2>
214 inline
216  TypeTensor<T> (vx)
217 {
218 }
219 
220 
221 
222 template <typename T>
223 template <typename T2>
224 inline
226  const TypeVector<T2>& vy) :
227  TypeTensor<T> (vx, vy)
228 {
229 }
230 
231 
232 
233 template <typename T>
234 template <typename T2>
235 inline
237  const TypeVector<T2>& vy,
238  const TypeVector<T2>& vz) :
239  TypeTensor<T> (vx, vy, vz)
240 {
241 }
242 
243 
244 
245 template <typename T>
246 template <typename T2>
247 inline
249  TypeTensor<T> (p)
250 {
251 }
252 
253 
254 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
255 template <typename T>
256 inline
258  const TypeTensor<Real>& p_im) :
259  TypeTensor<T> (Complex (p_re(0,0), p_im(0,0)),
260  Complex (p_re(0,1), p_im(0,1)),
261  Complex (p_re(0,2), p_im(0,2)),
262  Complex (p_re(1,0), p_im(1,0)),
263  Complex (p_re(1,1), p_im(1,1)),
264  Complex (p_re(1,2), p_im(1,2)),
265  Complex (p_re(2,0), p_im(2,0)),
266  Complex (p_re(2,1), p_im(2,1)),
267  Complex (p_re(2,2), p_im(2,2)))
268 {
269 }
270 #endif
271 
272 
273 } // namespace libMesh
274 
275 #endif // LIBMESH_TENSOR_VALUE_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:07 UTC

Hosted By:
SourceForge.net Logo