libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
vector_value.h
浏览该文件的文档.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2023 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 #include "libmesh/compare_types.h"
26 
27 #ifdef LIBMESH_HAVE_METAPHYSICL
28 #include "metaphysicl/raw_type.h"
29 #include "metaphysicl/ct_types.h"
30 #endif
31 
32 // C++ includes
33 
34 namespace libMesh
35 {
36 
45 template <typename T>
46 class VectorValue : public TypeVector<T>
47 {
48 public:
49  typedef T value_type;
50 
51  template <typename T2>
52  struct rebind
53  {
55  };
56 
61  VectorValue ();
62 
69  VectorValue (const T & x,
70  const T & y=0,
71  const T & z=0);
72 
82  template <typename Scalar1, typename Scalar2, typename Scalar3>
83  VectorValue (typename
84  boostcopy::enable_if_c<ScalarTraits<Scalar1>::value,
85  const Scalar1>::type & x,
86  typename
87  boostcopy::enable_if_c<ScalarTraits<Scalar2>::value,
88  const Scalar2>::type & y = 0,
89  typename
90  boostcopy::enable_if_c<ScalarTraits<Scalar3>::value,
91  const Scalar3>::type & z = 0);
92 
99  template <typename Scalar>
100  VectorValue (const Scalar & x,
101  typename
102  boostcopy::enable_if_c<ScalarTraits<Scalar>::value,
103  const Scalar>::type * sfinae = nullptr);
104 
110  template <typename T2>
111  VectorValue (const VectorValue<T2> & p);
112 
118  template <typename T2>
119  VectorValue (const TypeVector<T2> & p);
120 
121 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
122 
127  VectorValue (const TypeVector<Real> & p_re,
128  const TypeVector<Real> & p_im);
129 #endif
130 
137  template <typename Scalar>
138  typename boostcopy::enable_if_c<
139  ScalarTraits<Scalar>::value,
140  VectorValue &>::type
141  operator = (const Scalar & p)
142  { libmesh_assert_equal_to (p, Scalar(0)); this->zero(); return *this; }
143 };
144 
152 
153 
154 
155 //------------------------------------------------------
156 // Inline functions
157 
158 template <typename T>
159 inline
161  TypeVector<T> ()
162 {
163 }
164 
165 
166 template <typename T>
167 inline
169  const T & y,
170  const T & z) :
171  TypeVector<T> (x,y,z)
172 {
173 }
174 
175 
176 
177 template <typename T>
178 template <typename Scalar1, typename Scalar2, typename Scalar3>
179 inline
181  boostcopy::enable_if_c<ScalarTraits<Scalar1>::value,
182  const Scalar1>::type & x,
183  typename
184  boostcopy::enable_if_c<ScalarTraits<Scalar2>::value,
185  const Scalar2>::type & y,
186  typename
187  boostcopy::enable_if_c<ScalarTraits<Scalar3>::value,
188  const Scalar3>::type & z) :
189  TypeVector<T> (x,y,z)
190 {
191 }
192 
193 
194 template <typename T>
195 template <typename Scalar>
196 inline
197 VectorValue<T>::VectorValue (const Scalar & x,
198  typename
199  boostcopy::enable_if_c<ScalarTraits<Scalar>::value,
200  const Scalar>::type * /*sfinae*/) :
201  TypeVector<T> (x)
202 {
203 }
204 
205 template <typename T>
206 template <typename T2>
207 inline
209  TypeVector<T> (p)
210 {
211 }
212 
213 
214 
215 template <typename T>
216 template <typename T2>
217 inline
219  TypeVector<T> (p)
220 {
221 }
222 
223 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
224 template <typename T>
225 inline
227  const TypeVector<Real> & p_im) :
228  TypeVector<T> (Complex (p_re(0), p_im(0)),
229  Complex (p_re(1), p_im(1)),
230  Complex (p_re(2), p_im(2)))
231 {
232 }
233 #endif
234 
235 template <typename T>
236 struct CompareTypes<VectorValue<T>, VectorValue<T>>
237 {
239 };
240 
241 template <typename T, typename T2>
242 struct CompareTypes<VectorValue<T>, VectorValue<T2>>
243 {
245 };
246 
247 template <typename T, typename T2>
248 struct CompareTypes<VectorValue<T>, TypeVector<T2>>
249 {
251 };
252 
253 template <typename T, typename T2>
254 struct CompareTypes<TypeVector<T>, VectorValue<T2>>
255 {
257 };
258 
259 } // namespace libMesh
260 
261 #ifdef LIBMESH_HAVE_METAPHYSICL
262 namespace MetaPhysicL
263 {
264 template <typename T>
265 struct RawType<libMesh::VectorValue<T>>
266 {
268 
270  {
271  value_type ret;
272  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
273  ret(i) = raw_value(in(i));
274 
275  return ret;
276  }
277 };
278 
279 template <typename T, typename U>
280 struct ReplaceAlgebraicType<libMesh::VectorValue<T>, U>
281 {
282  typedef U type;
283 };
284 }
285 #endif
286 
287 #endif // LIBMESH_VECTOR_VALUE_H
VectorValue()
空构造函数。
Definition: vector_value.h:160
RealVectorValue RealGradient
Definition: vector_value.h:150
VectorValue< typename CompareTypes< T, T2 >::supertype > supertype
Definition: vector_value.h:256
VectorValue< Real > RealVectorValue
用于实现实数或复数数据类型之间的透明切换的有用typedef。
Definition: vector_value.h:148
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, VectorValue & >::type operator=(const Scalar &p)
赋值运算符,用于将向量置为零。
Definition: vector_value.h:141
此类定义了LIBMESH_DIM维的实数或复数空间中的向量。
Definition: tensor_tools.h:35
static value_type value(const libMesh::VectorValue< T > &in)
Definition: vector_value.h:269
void zero()
将向量的所有分量设置为零。
Definition: type_vector.h:1064
NumberVectorValue Gradient
Definition: vector_value.h:151
VectorValue< typename CompareTypes< T, T2 >::supertype > supertype
Definition: vector_value.h:244
libMesh::VectorValue< typename RawType< T >::value_type > value_type
Definition: vector_value.h:267
该类定义了一个在 LIBMESH_DIM 维度空间中类型为 T 的向量。
Definition: tensor_tools.h:34
VectorValue< typename CompareTypes< T, T2 >::supertype > supertype
Definition: vector_value.h:250
std::complex< Real > Complex
VectorValue< T2 > other
Definition: vector_value.h:54
VectorValue< Number > NumberVectorValue
Definition: vector_value.h:149