libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
sum_shell_matrix.C
浏览该文件的文档.
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 // Local includes
21 #include "libmesh/sum_shell_matrix.h"
22 #include "libmesh/numeric_vector.h"
23 #include "libmesh/int_range.h"
24 
25 namespace libMesh
26 {
27 
28 template <typename T>
30 {
31  libmesh_assert(!matrices.empty());
32  const numeric_index_type n_rows = matrices[0]->m();
33 #ifndef NDEBUG
34  for (auto i : index_range(matrices))
35  libmesh_assert_equal_to (matrices[i]->m(), n_rows);
36 #endif
37  return n_rows;
38 }
39 
40 
41 
42 template <typename T>
44 {
45  libmesh_assert(!matrices.empty());
46  const numeric_index_type n_cols = matrices[0]->n();
47 #ifndef NDEBUG
48  for (auto i : index_range(matrices))
49  libmesh_assert_equal_to (matrices[i]->n(), n_cols);
50 #endif
51  return n_cols;
52 }
53 
54 
55 
56 template <typename T>
58  const NumericVector<T> & arg) const
59 {
60  dest.zero();
61  this->vector_mult_add(dest,arg);
62 }
63 
64 
65 
66 template <typename T>
68  const NumericVector<T> & arg) const
69 {
70  for (auto i : index_range(matrices))
71  matrices[i]->vector_mult_add(dest, arg);
72 }
73 
74 
75 
76 template <typename T>
78 {
79  std::unique_ptr<NumericVector<T>> a = dest.zero_clone();
80  for (auto i : index_range(matrices))
81  {
82  matrices[i]->get_diagonal(*a);
83  dest += *a;
84  }
85 }
86 
87 
88 
89 //------------------------------------------------------------------
90 // Explicit instantiations
91 template class LIBMESH_EXPORT SumShellMatrix<Number>;
92 
93 } // namespace libMesh
virtual std::unique_ptr< NumericVector< T > > zero_clone() const =0
返回一个智能指针,指向具有相同类型、大小和分区的此向量的副本,但所有条目都为零。
提供了不同线性代数库的向量存储方案的统一接口。
Definition: dof_map.h:67
将任意数量的壳矩阵组合成一个单独的壳矩阵,通过将它们相加在一起的类。
virtual numeric_index_type n() const override
获取矩阵的列维度。
virtual void zero()=0
将所有条目设置为零。等同于 v = 0,但更明显且更快。
virtual numeric_index_type m() const override
获取矩阵的行维度。
virtual void vector_mult_add(NumericVector< T > &dest, const NumericVector< T > &arg) const override
将矩阵与参数arg相乘,然后将结果添加到dest中。
dof_id_type numeric_index_type
Definition: id_types.h:99
virtual void vector_mult(NumericVector< T > &dest, const NumericVector< T > &arg) const override
将矩阵与参数arg相乘,并将结果存储在dest中。
virtual void get_diagonal(NumericVector< T > &dest) const override
将矩阵的对角部分复制到dest中。