$extrastylesheet
tensor_value.h
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 
00020 #ifndef LIBMESH_TENSOR_VALUE_H
00021 #define LIBMESH_TENSOR_VALUE_H
00022 
00023 // Local includes
00024 #include "libmesh/type_tensor.h"
00025 
00026 // C++ includes
00027 
00028 namespace libMesh
00029 {
00030 
00039 template <typename T>
00040 class TensorValue : public TypeTensor<T>
00041 {
00042 public:
00043 
00048   TensorValue  ();
00049 
00054   explicit TensorValue  (const T xx,
00055                          const T xy=0,
00056                          const T xz=0,
00057                          const T yx=0,
00058                          const T yy=0,
00059                          const T yz=0,
00060                          const T zx=0,
00061                          const T zy=0,
00062                          const T zz=0);
00063 
00068   template <typename Scalar>
00069   explicit TensorValue  (const Scalar xx,
00070                          const Scalar xy=0,
00071                          const Scalar xz=0,
00072                          const Scalar yx=0,
00073                          const Scalar yy=0,
00074                          const Scalar yz=0,
00075                          const Scalar zx=0,
00076                          const Scalar zy=0,
00077                          typename
00078                          boostcopy::enable_if_c<ScalarTraits<Scalar>::value,
00079                          const Scalar>::type zz=0);
00080 
00084   template <typename T2>
00085   TensorValue (const TypeVector<T2>& vx);
00086 
00090   template <typename T2>
00091   TensorValue (const TypeVector<T2>& vx, const TypeVector<T2>& vy);
00092 
00096   template <typename T2>
00097   TensorValue (const TypeVector<T2>& vx, const TypeVector<T2>& vy, const TypeVector<T2>& vz);
00098 
00099 
00103   template <typename T2>
00104   TensorValue (const TensorValue<T2>& p);
00105 
00109   template <typename T2>
00110   TensorValue (const TypeTensor<T2>& p);
00111 
00112 
00113 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
00114 
00119   TensorValue (const TypeTensor<Real>& p_re,
00120                const TypeTensor<Real>& p_im);
00121 #endif
00122 
00123 
00127   template <typename Scalar>
00128   typename boostcopy::enable_if_c<
00129     ScalarTraits<Scalar>::value,
00130     TensorValue&>::type
00131   operator = (const Scalar& libmesh_dbg_var(p) )
00132   { libmesh_assert_equal_to (p, Scalar(0)); this->zero(); return *this; }
00133 
00134 
00135 private:
00136 
00137 
00138 };
00139 
00140 
00141 
00146 typedef TensorValue<Real>   RealTensorValue;
00147 typedef TensorValue<Number> NumberTensorValue;
00148 typedef RealTensorValue     RealTensor;
00149 typedef NumberTensorValue   Tensor;
00150 
00151 
00152 
00153 //------------------------------------------------------
00154 // Inline functions
00155 template <typename T>
00156 inline
00157 TensorValue<T>::TensorValue () :
00158   TypeTensor<T> ()
00159 {
00160 }
00161 
00162 
00163 
00164 template <typename T>
00165 inline
00166 TensorValue<T>::TensorValue
00167 (const T xx,
00168  const T xy,
00169  const T xz,
00170  const T yx,
00171  const T yy,
00172  const T yz,
00173  const T zx,
00174  const T zy,
00175  const T zz) :
00176   TypeTensor<T> (xx,xy,xz,yx,yy,yz,zx,zy,zz)
00177 {
00178 }
00179 
00180 
00181 template <typename T>
00182 template <typename Scalar>
00183 inline
00184 TensorValue<T>::TensorValue
00185 (const Scalar xx,
00186  const Scalar xy,
00187  const Scalar xz,
00188  const Scalar yx,
00189  const Scalar yy,
00190  const Scalar yz,
00191  const Scalar zx,
00192  const Scalar zy,
00193  typename
00194  boostcopy::enable_if_c<ScalarTraits<Scalar>::value,
00195  const Scalar>::type zz) :
00196   TypeTensor<T> (xx,xy,xz,yx,yy,yz,zx,zy,zz)
00197 {
00198 }
00199 
00200 
00201 
00202 template <typename T>
00203 template <typename T2>
00204 inline
00205 TensorValue<T>::TensorValue (const TensorValue<T2>& p) :
00206   TypeTensor<T> (p)
00207 {
00208 }
00209 
00210 
00211 
00212 template <typename T>
00213 template <typename T2>
00214 inline
00215 TensorValue<T>::TensorValue (const TypeVector<T2>& vx) :
00216   TypeTensor<T> (vx)
00217 {
00218 }
00219 
00220 
00221 
00222 template <typename T>
00223 template <typename T2>
00224 inline
00225 TensorValue<T>::TensorValue (const TypeVector<T2>& vx,
00226                              const TypeVector<T2>& vy) :
00227   TypeTensor<T> (vx, vy)
00228 {
00229 }
00230 
00231 
00232 
00233 template <typename T>
00234 template <typename T2>
00235 inline
00236 TensorValue<T>::TensorValue (const TypeVector<T2>& vx,
00237                              const TypeVector<T2>& vy,
00238                              const TypeVector<T2>& vz) :
00239   TypeTensor<T> (vx, vy, vz)
00240 {
00241 }
00242 
00243 
00244 
00245 template <typename T>
00246 template <typename T2>
00247 inline
00248 TensorValue<T>::TensorValue (const TypeTensor<T2>& p) :
00249   TypeTensor<T> (p)
00250 {
00251 }
00252 
00253 
00254 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
00255 template <typename T>
00256 inline
00257 TensorValue<T>::TensorValue (const TypeTensor<Real>& p_re,
00258                              const TypeTensor<Real>& p_im) :
00259   TypeTensor<T> (Complex (p_re(0,0), p_im(0,0)),
00260                  Complex (p_re(0,1), p_im(0,1)),
00261                  Complex (p_re(0,2), p_im(0,2)),
00262                  Complex (p_re(1,0), p_im(1,0)),
00263                  Complex (p_re(1,1), p_im(1,1)),
00264                  Complex (p_re(1,2), p_im(1,2)),
00265                  Complex (p_re(2,0), p_im(2,0)),
00266                  Complex (p_re(2,1), p_im(2,1)),
00267                  Complex (p_re(2,2), p_im(2,2)))
00268 {
00269 }
00270 #endif
00271 
00272 
00273 } // namespace libMesh
00274 
00275 #endif // LIBMESH_TENSOR_VALUE_H