libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
dense_submatrix.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_DENSE_SUBMATRIX_H
21 #define LIBMESH_DENSE_SUBMATRIX_H
22 
23 // Local Includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/dense_matrix.h"
26 #include "libmesh/dense_subvector.h"
27 #include "libmesh/int_range.h"
28 
29 // C++ includes
30 
31 namespace libMesh
32 {
33 
42 template<typename T>
44 {
45 public:
46 
57  DenseSubMatrix(DenseMatrix<T> & new_parent,
58  const unsigned int ioff=0,
59  const unsigned int joff=0,
60  const unsigned int m=0,
61  const unsigned int n=0);
62 
67  DenseSubMatrix (DenseSubMatrix &&) = default;
68  DenseSubMatrix (const DenseSubMatrix &) = default;
69  DenseSubMatrix & operator= (const DenseSubMatrix &) = default;
71  virtual ~DenseSubMatrix() = default;
72 
79 
83  virtual void zero() override final;
84 
92  T operator() (const unsigned int i,
93  const unsigned int j) const;
94 
102  T & operator() (const unsigned int i,
103  const unsigned int j);
104 
112  virtual T el(const unsigned int i,
113  const unsigned int j) const override final
114  { return (*this)(i,j); }
115 
123  virtual T & el(const unsigned int i,
124  const unsigned int j) override final
125  { return (*this)(i,j); }
126 
132  virtual void left_multiply (const DenseMatrixBase<T> & M2) override final;
133 
139  virtual void right_multiply (const DenseMatrixBase<T> & M3) override final;
140 
149  void reposition(const unsigned int ioff,
150  const unsigned int joff,
151  const unsigned int new_m,
152  const unsigned int new_n);
153 
159  unsigned int i_off() const { return _i_off; }
160 
166  unsigned int j_off() const { return _j_off; }
167 
176  void condense(const unsigned int i,
177  const unsigned int j,
178  const T val,
179  DenseSubVector<T> & rhs)
180  {
181  this->parent().condense(this->i_off()+i,
182  this->j_off()+j,
183  val, rhs.parent());
184  }
185 
186 private:
187 
193 
197  unsigned int _i_off;
198 
202  unsigned int _j_off;
203 };
204 
205 
206 // --------------------------------------------------
207 // Constructor
208 template<typename T>
209 inline
211  const unsigned int ioff,
212  const unsigned int joff,
213  const unsigned int new_m,
214  const unsigned int new_n) :
215  DenseMatrixBase<T>(new_m,new_n),
216  _parent_matrix(new_parent)
217 {
218  this->reposition (ioff, joff, new_m, new_n);
219 }
220 
221 
222 template<typename T>
223 inline
224 void DenseSubMatrix<T>::reposition(const unsigned int ioff,
225  const unsigned int joff,
226  const unsigned int new_m,
227  const unsigned int new_n)
228 {
229  _i_off = ioff;
230  _j_off = joff;
231  this->_m = new_m;
232  this->_n = new_n;
233 
234  // Make sure we still fit in the parent matrix.
235  libmesh_assert_less_equal ((this->i_off() + this->m()), _parent_matrix.m());
236  libmesh_assert_less_equal ((this->j_off() + this->n()), _parent_matrix.n());
237 }
238 
239 
240 
241 template<typename T>
242 inline
244 {
245  for (auto i : make_range(this->m()))
246  for (auto j : make_range(this->n()))
247  _parent_matrix(i + this->i_off(),
248  j + this->j_off()) = 0.;
249 }
250 
251 
252 
253 template<typename T>
254 inline
255 T DenseSubMatrix<T>::operator () (const unsigned int i,
256  const unsigned int j) const
257 {
258  libmesh_assert_less (i, this->m());
259  libmesh_assert_less (j, this->n());
260  libmesh_assert_less (i + this->i_off(), _parent_matrix.m());
261  libmesh_assert_less (j + this->j_off(), _parent_matrix.n());
262 
263  return _parent_matrix (i + this->i_off(),
264  j + this->j_off());
265 }
266 
267 
268 template<typename T>
269 inline
270 T & DenseSubMatrix<T>::operator () (const unsigned int i,
271  const unsigned int j)
272 {
273  libmesh_assert_less (i, this->m());
274  libmesh_assert_less (j, this->n());
275  libmesh_assert_less (i + this->i_off(), _parent_matrix.m());
276  libmesh_assert_less (j + this->j_off(), _parent_matrix.n());
277 
278  return _parent_matrix (i + this->i_off(),
279  j + this->j_off());
280 }
281 
282 
283 } // namespace libMesh
284 
285 
286 #endif // LIBMESH_DENSE_SUBMATRIX_H
unsigned int n() const
返回矩阵的列维度。
unsigned int _i_off
子矩阵在父矩阵中的行偏移。
DenseVector< T > & parent()
virtual void right_multiply(const DenseMatrixBase< T > &M3) overridefinal
覆盖基类的虚函数,右乘子矩阵。
定义了一个用于有限元计算的稠密子向量。 在将元素载荷向量累加到全局向量之前存储这些载荷向量时特别有用,尤其是在存在方程组的情况下。 所有重写的虚拟函数在 dense_vector_base.h 中有文档说明。
DenseMatrix< T > & parent()
返回对父矩阵的引用。
unsigned int _j_off
子矩阵在父矩阵中的列偏移。
unsigned int m() const
返回矩阵的行维度。
unsigned int i_off() const
返回子矩阵在父矩阵中的行偏移。
void condense(const unsigned int i, const unsigned int j, const T val, DenseSubVector< T > &rhs)
将矩阵的 (i,j) 元素压缩成值 val 对于施加边界条件在数值模拟中很有用。保持矩阵的对称性。
为有限元类型的计算定义密集子矩阵。 在将元素刚度矩阵相加到全局矩阵之前存储非常有用,特别是在存在方程组时。 所有重写的虚拟函数在 dense_matrix_base.h 中有文档。
DenseSubMatrix & operator=(const DenseSubMatrix &)=default
virtual T & el(const unsigned int i, const unsigned int j) overridefinal
覆盖基类的虚函数,返回子矩阵的 (i,j) 元素的可写引用。
virtual void zero() overridefinal
覆盖基类的虚拟函数,将子矩阵的所有元素设置为零。
DenseSubMatrix(DenseMatrix< T > &new_parent, const unsigned int ioff=0, const unsigned int joff=0, const unsigned int m=0, const unsigned int n=0)
构造函数。创建矩阵 parent 的密集子矩阵。子矩阵的维度为 , 子矩阵的 元素位于父矩阵中的 位置。
T operator()(const unsigned int i, const unsigned int j) const
返回子矩阵的 (i,j) 元素。
void reposition(const unsigned int ioff, const unsigned int joff, const unsigned int new_m, const unsigned int new_n)
修改子矩阵在父矩阵中的位置。
virtual T el(const unsigned int i, const unsigned int j) const overridefinal
覆盖基类的虚函数,返回子矩阵的 (i,j) 元素。
为有限元类型的计算定义了一个抽象的稠密矩阵基类。例如 DenseSubMatrices 可以从这个类派生出来。
定义用于有限元类型计算的密集矩阵。 用于在求和成全局矩阵之前存储单元刚度矩阵。所有被覆盖的虚函数都记录在dense_matrix_base.h中。
Definition: dof_map.h:65
unsigned int j_off() const
返回子矩阵在父矩阵中的列偏移。
virtual ~DenseSubMatrix()=default
virtual void left_multiply(const DenseMatrixBase< T > &M2) overridefinal
覆盖基类的虚函数,左乘子矩阵。
DenseMatrix< T > & _parent_matrix
包含该子矩阵的父矩阵。 引用父矩阵的对象,表示该子矩阵属于哪个父矩阵。