$extrastylesheet
type_n_tensor.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_TYPE_N_TENSOR_H
00021 #define LIBMESH_TYPE_N_TENSOR_H
00022 
00023 // Local includes
00024 #include "libmesh/libmesh_common.h"
00025 #include "libmesh/type_vector.h"
00026 
00027 // C++ includes
00028 #include <cstdlib> // *must* precede <cmath> for proper std:abs() on PGI, Sun Studio CC
00029 #include <cmath>
00030 
00031 namespace libMesh
00032 {
00033 
00034 
00045 template <unsigned int N, typename T>
00046 class TypeNTensor
00047 {
00048 public:
00049   TypeNTensor () {}
00050 
00051   TypeNTensor (const T&) {}
00052 
00053   TypeNTensor (const TypeVector<T>&) {}
00054 
00055   TypeNTensor (const TypeTensor<T>&) {}
00056 
00057   operator TypeVector<T> () const { libmesh_not_implemented(); return 0; }
00058   operator VectorValue<T> () const { libmesh_not_implemented(); return 0; }
00059 
00060   operator TypeTensor<T> () const { libmesh_not_implemented(); return 0; }
00061   operator TensorValue<T> () const { libmesh_not_implemented(); return 0; }
00062 
00066   ~TypeNTensor() {}
00067 
00071   const TypeNTensor<N-1,T> slice (const unsigned int /*i*/) const
00072   { return TypeNTensor<N-1,T>(); }
00073 
00077   TypeNTensor<N-1,T> slice (const unsigned int /*i*/)
00078   { return TypeNTensor<N-1,T>(); }
00079 
00083   template<typename T2>
00084   TypeNTensor<N,typename CompareTypes<T, T2>::supertype>
00085   operator + (const TypeNTensor<N,T2> &) const
00086   { return TypeNTensor<N,typename CompareTypes<T,T2>::supertype>(); }
00087 
00091   template<typename T2>
00092   const TypeNTensor<N,T> & operator += (const TypeNTensor<N,T2> &/*rhs*/)
00093   { return *this; }
00094 
00098   template<typename T2>
00099   TypeNTensor<N,typename CompareTypes<T, T2>::supertype>
00100   operator - (const TypeNTensor<N,T2> &) const
00101   { return TypeNTensor<N,typename CompareTypes<T,T2>::supertype>(); }
00102 
00106   template<typename T2>
00107   const TypeNTensor<N,T> & operator -= (const TypeNTensor<N,T2> &)
00108   { return *this; }
00109 
00113   TypeNTensor<N,T> operator - () const
00114   { return *this; }
00115 
00119   template <typename Scalar>
00120   typename boostcopy::enable_if_c<
00121     ScalarTraits<Scalar>::value,
00122     TypeNTensor<N,typename CompareTypes<T, Scalar>::supertype> >::type
00123   operator * (const Scalar) const
00124   { return TypeNTensor<N,typename CompareTypes<T, Scalar>::supertype>(); }
00125 
00129   template <typename Scalar>
00130   const TypeNTensor<N,T> & operator *= (const Scalar) { return *this; }
00131 
00135   template <typename Scalar>
00136   typename boostcopy::enable_if_c<
00137     ScalarTraits<Scalar>::value,
00138     TypeNTensor<N,typename CompareTypes<T, Scalar>::supertype> >::type
00139   operator / (const Scalar) const { return *this; }
00140 
00144   const TypeNTensor<N,T> & operator /= (const T) { return *this; }
00145 
00151   template <typename T2>
00152   typename CompareTypes<T,T2>::supertype
00153   contract (const TypeNTensor<N,T2> &) const { return 0; }
00154 
00159   Real size_sq() const { return 0.;}
00160 
00164   bool operator == (const TypeNTensor<N,T>& /*rhs*/) const
00165   { return true; }
00166 
00171   bool operator < (const TypeNTensor<N,T>& /*rhs*/) const
00172   { return false; }
00173 
00178   bool operator > (const TypeNTensor<N,T>& /*rhs*/) const
00179   { return false; }
00180 
00184   void print(std::ostream& /*os = libMesh::out*/) const {}
00185 
00190   friend std::ostream& operator << (std::ostream& os,
00191                                     const TypeNTensor<N,T>& t)
00192   {
00193     t.print(os);
00194     return os;
00195   }
00196 };
00197 
00198 
00199 } // namespace libMesh
00200 
00201 #endif // LIBMESH_TYPE_N_TENSOR_H