$extrastylesheet
vector_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_VECTOR_VALUE_H
00021 #define LIBMESH_VECTOR_VALUE_H
00022 
00023 // Local includes
00024 #include "libmesh/type_vector.h"
00025 
00026 // C++ includes
00027 
00028 namespace libMesh
00029 {
00030 
00039 template <typename T>
00040 class VectorValue : public TypeVector<T>
00041 {
00042 public:
00043 
00048   VectorValue ();
00049 
00054   VectorValue (const T x,
00055                const T y=0,
00056                const T z=0);
00057 
00062   template <typename Scalar>
00063   VectorValue (const Scalar x,
00064                const Scalar y=0,
00065                typename
00066                boostcopy::enable_if_c<ScalarTraits<Scalar>::value,
00067                const Scalar>::type z=0);
00068 
00072   template <typename T2>
00073   VectorValue (const VectorValue<T2>& p);
00074 
00078   template <typename T2>
00079   VectorValue (const TypeVector<T2>& p);
00080 
00081 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
00082 
00087   VectorValue (const TypeVector<Real>& p_re,
00088                const TypeVector<Real>& p_im);
00089 #endif
00090 
00094   template <typename Scalar>
00095   typename boostcopy::enable_if_c<
00096     ScalarTraits<Scalar>::value,
00097     VectorValue&>::type
00098   operator = (const Scalar& libmesh_dbg_var(p))
00099   { libmesh_assert_equal_to (p, Scalar(0)); this->zero(); return *this; }
00100 
00101 
00102 private:
00103 
00104 
00105 };
00106 
00107 
00108 
00113 typedef VectorValue<Real>   RealVectorValue;
00114 typedef VectorValue<Number> NumberVectorValue;
00115 typedef RealVectorValue     RealGradient;
00116 typedef NumberVectorValue   Gradient;
00117 
00118 
00119 
00120 //------------------------------------------------------
00121 // Inline functions
00122 
00123 template <typename T>
00124 inline
00125 VectorValue<T>::VectorValue () :
00126   TypeVector<T> ()
00127 {
00128 }
00129 
00130 
00131 template <typename T>
00132 inline
00133 VectorValue<T>::VectorValue (const T x,
00134                              const T y,
00135                              const T z) :
00136   TypeVector<T> (x,y,z)
00137 {
00138 }
00139 
00140 
00141 
00142 template <typename T>
00143 template <typename Scalar>
00144 inline
00145 VectorValue<T>::VectorValue (const Scalar x,
00146                              const Scalar y,
00147                              typename
00148                              boostcopy::enable_if_c<ScalarTraits<Scalar>::value,
00149                              const Scalar>::type z) :
00150   TypeVector<T> (x,y,z)
00151 {
00152 }
00153 
00154 
00155 
00156 template <typename T>
00157 template <typename T2>
00158 inline
00159 VectorValue<T>::VectorValue (const VectorValue<T2>& p) :
00160   TypeVector<T> (p)
00161 {
00162 }
00163 
00164 
00165 
00166 template <typename T>
00167 template <typename T2>
00168 inline
00169 VectorValue<T>::VectorValue (const TypeVector<T2>& p) :
00170   TypeVector<T> (p)
00171 {
00172 }
00173 
00174 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
00175 template <typename T>
00176 inline
00177 VectorValue<T>::VectorValue (const TypeVector<Real>& p_re,
00178                              const TypeVector<Real>& p_im) :
00179   TypeVector<T> (Complex (p_re(0), p_im(0)),
00180                  Complex (p_re(1), p_im(1)),
00181                  Complex (p_re(2), p_im(2)))
00182 {
00183 }
00184 #endif
00185 
00186 
00187 } // namespace libMesh
00188 
00189 #endif // LIBMESH_VECTOR_VALUE_H