libMesh
vector_value.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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_VECTOR_VALUE_H
21 #define LIBMESH_VECTOR_VALUE_H
22 
23 // Local includes
24 #include "libmesh/type_vector.h"
25 
26 // C++ includes
27 
28 namespace libMesh
29 {
30 
40 template <typename T>
41 class VectorValue : public TypeVector<T>
42 {
43 public:
44 
49  VectorValue ();
50 
55  VectorValue (const T & x,
56  const T & y=0,
57  const T & z=0);
58 
63  template <typename Scalar1, typename Scalar2, typename Scalar3>
64  VectorValue (typename
65  boostcopy::enable_if_c<ScalarTraits<Scalar1>::value,
66  const Scalar1>::type & x,
67  typename
68  boostcopy::enable_if_c<ScalarTraits<Scalar2>::value,
69  const Scalar2>::type & y = 0,
70  typename
71  boostcopy::enable_if_c<ScalarTraits<Scalar3>::value,
72  const Scalar3>::type & z = 0);
73 
74 
81  template <typename Scalar>
82  VectorValue (const Scalar & x,
83  typename
84  boostcopy::enable_if_c<ScalarTraits<Scalar>::value,
85  const Scalar>::type * sfinae = nullptr);
86 
87 
91  template <typename T2>
92  VectorValue (const VectorValue<T2> & p);
93 
97  template <typename T2>
98  VectorValue (const TypeVector<T2> & p);
99 
100 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
101 
106  VectorValue (const TypeVector<Real> & p_re,
107  const TypeVector<Real> & p_im);
108 #endif
109 
113  template <typename Scalar>
114  typename boostcopy::enable_if_c<
116  VectorValue &>::type
117  operator = (const Scalar & libmesh_dbg_var(p))
118  { libmesh_assert_equal_to (p, Scalar(0)); this->zero(); return *this; }
119 };
120 
121 
122 
127 typedef VectorValue<Real> RealVectorValue;
128 typedef VectorValue<Number> NumberVectorValue;
131 
132 
133 
134 //------------------------------------------------------
135 // Inline functions
136 
137 template <typename T>
138 inline
140  TypeVector<T> ()
141 {
142 }
143 
144 
145 template <typename T>
146 inline
148  const T & y,
149  const T & z) :
150  TypeVector<T> (x,y,z)
151 {
152 }
153 
154 
155 
156 template <typename T>
157 template <typename Scalar1, typename Scalar2, typename Scalar3>
158 inline
161  const Scalar1>::type & x,
162  typename
164  const Scalar2>::type & y,
165  typename
167  const Scalar3>::type & z) :
168  TypeVector<T> (x,y,z)
169 {
170 }
171 
172 
173 template <typename T>
174 template <typename Scalar>
175 inline
176 VectorValue<T>::VectorValue (const Scalar & x,
177  typename
179  const Scalar>::type * /*sfinae*/) :
180  TypeVector<T> (x)
181 {
182 }
183 
184 template <typename T>
185 template <typename T2>
186 inline
188  TypeVector<T> (p)
189 {
190 }
191 
192 
193 
194 template <typename T>
195 template <typename T2>
196 inline
198  TypeVector<T> (p)
199 {
200 }
201 
202 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
203 template <typename T>
204 inline
206  const TypeVector<Real> & p_im) :
207  TypeVector<T> (Complex (p_re(0), p_im(0)),
208  Complex (p_re(1), p_im(1)),
209  Complex (p_re(2), p_im(2)))
210 {
211 }
212 #endif
213 
214 
215 } // namespace libMesh
216 
217 #endif // LIBMESH_VECTOR_VALUE_H
libMesh::RealGradient
RealVectorValue RealGradient
Definition: hp_coarsentest.h:49
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::boostcopy::enable_if_c
Definition: compare_types.h:38
libMesh::TypeVector::zero
void zero()
Set all entries of the vector to 0.
Definition: type_vector.h:964
libMesh::RealVectorValue
VectorValue< Real > RealVectorValue
Useful typedefs to allow transparent switching between Real and Complex data types.
Definition: hp_coarsentest.h:46
libMesh::VectorValue
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
Definition: exact_solution.h:54
libMesh::VectorValue::VectorValue
VectorValue()
Empty constructor.
Definition: vector_value.h:139
libMesh::ScalarTraits
Definition: compare_types.h:63
libMesh::Complex
std::complex< Real > Complex
Definition: libmesh_common.h:160
libMesh::Gradient
NumberVectorValue Gradient
Definition: exact_solution.h:58
libMesh::NumberVectorValue
VectorValue< Number > NumberVectorValue
Definition: exact_solution.h:57
libMesh::VectorValue::operator=
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, VectorValue & >::type operator=(const Scalar &libmesh_dbg_var(p))
Assignment-from-scalar operator.
Definition: vector_value.h:117
libMesh::TypeVector
This class defines a vector in LIBMESH_DIM dimensional space of type T.
Definition: tensor_tools.h:45
libMesh::ScalarTraits::value
static const bool value
Definition: compare_types.h:64