sum_shell_matrix.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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
22 #include "libmesh/numeric_vector.h"
23 
24 namespace libMesh
25 {
26 
27 template <typename T>
29 {
30  libmesh_assert(!matrices.empty());
31  const numeric_index_type n_rows = matrices[0]->m();
32 #ifndef NDEBUG
33  for (std::size_t i=1; i<matrices.size(); ++i)
34  libmesh_assert_equal_to (matrices[i]->m(), n_rows);
35 #endif
36  return n_rows;
37 }
38 
39 
40 
41 template <typename T>
43 {
44  libmesh_assert(!matrices.empty());
45  const numeric_index_type n_cols = matrices[0]->n();
46 #ifndef NDEBUG
47  for (std::size_t i=1; i<matrices.size(); ++i)
48  libmesh_assert_equal_to (matrices[i]->n(), n_cols);
49 #endif
50  return n_cols;
51 }
52 
53 
54 
55 template <typename T>
57  const NumericVector<T> & arg) const
58 {
59  dest.zero();
60  this->vector_mult_add(dest,arg);
61 }
62 
63 
64 
65 template <typename T>
67  const NumericVector<T> & arg) const
68 {
69  for (std::size_t i=0; i<matrices.size(); ++i)
70  matrices[i]->vector_mult_add(dest, arg);
71 }
72 
73 
74 
75 template <typename T>
77 {
78  std::unique_ptr<NumericVector<T>> a = dest.zero_clone();
79  for (std::size_t i=0; i<matrices.size(); ++i)
80  {
81  matrices[i]->get_diagonal(*a);
82  dest += *a;
83  }
84 }
85 
86 
87 
88 //------------------------------------------------------------------
89 // Explicit instantiations
90 template class SumShellMatrix<Number>;
91 
92 } // namespace libMesh
virtual std::unique_ptr< NumericVector< T > > zero_clone() const =0
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
Definition: diff_context.h:40
virtual numeric_index_type n() const override
virtual void zero()=0
virtual numeric_index_type m() const override
virtual void vector_mult_add(NumericVector< T > &dest, const NumericVector< T > &arg) const override
dof_id_type numeric_index_type
Definition: id_types.h:92
virtual void vector_mult(NumericVector< T > &dest, const NumericVector< T > &arg) const override
virtual void get_diagonal(NumericVector< T > &dest) const override