libMesh
sum_shell_matrix.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 
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 {
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 void vector_mult(NumericVector< T > &dest, const NumericVector< T > &arg) const libmesh_override
Multiplies the matrix with arg and stores the result in dest.
virtual void get_diagonal(NumericVector< T > &dest) const libmesh_override
Copies the diagonal part of the matrix into dest.
virtual numeric_index_type n() const libmesh_override
Numeric vector.
Definition: dof_map.h:66
This class combines any number of shell matrices to a single shell matrix by summing them together...
The libMesh namespace provides an interface to certain functionality in the library.
virtual void zero()=0
Set all entries to zero.
libmesh_assert(j)
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
dof_id_type numeric_index_type
Definition: id_types.h:92
virtual UniquePtr< NumericVector< T > > zero_clone() const =0
virtual void vector_mult_add(NumericVector< T > &dest, const NumericVector< T > &arg) const libmesh_override
Multiplies the matrix with arg and adds the result to dest.
virtual numeric_index_type m() const libmesh_override