libMesh
tensor_value.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 
40 template <typename T>
41 class TensorValue : public TypeTensor<T>
42 {
43 public:
44 
49  TensorValue ();
50 
55  explicit TensorValue (const T xx,
56  const T xy=0,
57  const T xz=0,
58  const T yx=0,
59  const T yy=0,
60  const T yz=0,
61  const T zx=0,
62  const T zy=0,
63  const T zz=0);
64 
69  template <typename Scalar>
70  explicit TensorValue (const Scalar xx,
71  const Scalar xy=0,
72  const Scalar xz=0,
73  const Scalar yx=0,
74  const Scalar yy=0,
75  const Scalar yz=0,
76  const Scalar zx=0,
77  const Scalar zy=0,
78  typename
79  boostcopy::enable_if_c<ScalarTraits<Scalar>::value,
80  const Scalar>::type zz=0);
81 
85  template <typename T2>
86  TensorValue (const TypeVector<T2> & vx);
87 
91  template <typename T2>
92  TensorValue (const TypeVector<T2> & vx,
93  const TypeVector<T2> & vy);
94 
98  template <typename T2>
99  TensorValue (const TypeVector<T2> & vx,
100  const TypeVector<T2> & vy,
101  const TypeVector<T2> & vz);
102 
103 
107  template <typename T2>
108  TensorValue (const TensorValue<T2> & p);
109 
113  template <typename T2>
114  TensorValue (const TypeTensor<T2> & p);
115 
116 
117 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
118 
123  TensorValue (const TypeTensor<Real> & p_re,
124  const TypeTensor<Real> & p_im);
125 #endif
126 
127 
131  template <typename Scalar>
132  typename boostcopy::enable_if_c<
134  TensorValue &>::type
135  operator = (const Scalar & libmesh_dbg_var(p) )
136  { libmesh_assert_equal_to (p, Scalar(0)); this->zero(); return *this; }
137 };
138 
139 
140 
147 typedef RealTensorValue RealTensor;
148 typedef NumberTensorValue Tensor;
149 
150 
151 
152 //------------------------------------------------------
153 // Inline functions
154 template <typename T>
155 inline
157  TypeTensor<T> ()
158 {
159 }
160 
161 
162 
163 template <typename T>
164 inline
166  const T xy,
167  const T xz,
168  const T yx,
169  const T yy,
170  const T yz,
171  const T zx,
172  const T zy,
173  const T zz) :
174  TypeTensor<T> (xx,xy,xz,yx,yy,yz,zx,zy,zz)
175 {
176 }
177 
178 
179 template <typename T>
180 template <typename Scalar>
181 inline
183  const Scalar xy,
184  const Scalar xz,
185  const Scalar yx,
186  const Scalar yy,
187  const Scalar yz,
188  const Scalar zx,
189  const Scalar zy,
190  typename
191  boostcopy::enable_if_c<ScalarTraits<Scalar>::value,
192  const Scalar>::type zz) :
193  TypeTensor<T> (xx,xy,xz,yx,yy,yz,zx,zy,zz)
194 {
195 }
196 
197 
198 
199 template <typename T>
200 template <typename T2>
201 inline
203  TypeTensor<T> (p)
204 {
205 }
206 
207 
208 
209 template <typename T>
210 template <typename T2>
211 inline
213  TypeTensor<T> (vx)
214 {
215 }
216 
217 
218 
219 template <typename T>
220 template <typename T2>
221 inline
223  const TypeVector<T2> & vy) :
224  TypeTensor<T> (vx, vy)
225 {
226 }
227 
228 
229 
230 template <typename T>
231 template <typename T2>
232 inline
234  const TypeVector<T2> & vy,
235  const TypeVector<T2> & vz) :
236  TypeTensor<T> (vx, vy, vz)
237 {
238 }
239 
240 
241 
242 template <typename T>
243 template <typename T2>
244 inline
246  TypeTensor<T> (p)
247 {
248 }
249 
250 
251 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
252 template <typename T>
253 inline
255  const TypeTensor<Real> & p_im) :
256  TypeTensor<T> (Complex (p_re(0,0), p_im(0,0)),
257  Complex (p_re(0,1), p_im(0,1)),
258  Complex (p_re(0,2), p_im(0,2)),
259  Complex (p_re(1,0), p_im(1,0)),
260  Complex (p_re(1,1), p_im(1,1)),
261  Complex (p_re(1,2), p_im(1,2)),
262  Complex (p_re(2,0), p_im(2,0)),
263  Complex (p_re(2,1), p_im(2,1)),
264  Complex (p_re(2,2), p_im(2,2)))
265 {
266 }
267 #endif
268 
269 
270 } // namespace libMesh
271 
272 #endif // LIBMESH_TENSOR_VALUE_H
void zero()
Set all entries of the tensor to 0.
Definition: type_tensor.h:1248
RealTensorValue RealTensor
The libMesh namespace provides an interface to certain functionality in the library.
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TensorValue & >::type operator=(const Scalar &libmesh_dbg_var(p))
Assignment-from-scalar operator.
Definition: tensor_value.h:135
This class defines a tensor in LIBMESH_DIM dimensional space of type T.
Definition: tensor_tools.h:32
TensorValue()
Empty constructor.
Definition: tensor_value.h:156
TensorValue< Real > RealTensorValue
Useful typedefs to allow transparent switching between Real and Complex data types.
TensorValue< Number > NumberTensorValue
This class defines a vector in LIBMESH_DIM dimensional space of type T.
Definition: tensor_tools.h:30
PetscErrorCode Vec Mat libmesh_dbg_var(j)
std::complex< Real > Complex
NumberTensorValue Tensor
static const bool value
Definition: compare_types.h:58
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.