libMesh
sum_shell_matrix.h
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 #ifndef LIBMESH_SUM_SHELL_MATRIX_H
21 #define LIBMESH_SUM_SHELL_MATRIX_H
22 
23 // Local includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/reference_counted_object.h"
26 #include "libmesh/libmesh.h"
27 #include "libmesh/shell_matrix.h"
28 
29 // C++ includes
30 #include <vector>
31 
32 namespace libMesh
33 {
34 
43 template <typename T>
44 class SumShellMatrix : public ShellMatrix<T>
45 {
46 public:
55  SumShellMatrix (const Parallel::Communicator & comm_in
56  LIBMESH_CAN_DEFAULT_TO_COMMWORLD);
57 
61  explicit
62  SumShellMatrix (const std::vector<ShellMatrix<T> *> & mat,
63  const Parallel::Communicator & comm_in
64  LIBMESH_CAN_DEFAULT_TO_COMMWORLD);
65 
69  virtual ~SumShellMatrix ();
70 
71  virtual numeric_index_type m () const libmesh_override;
72 
73  virtual numeric_index_type n () const libmesh_override;
74 
75  virtual void vector_mult (NumericVector<T> & dest,
76  const NumericVector<T> & arg) const libmesh_override;
77 
78  virtual void vector_mult_add (NumericVector<T> & dest,
79  const NumericVector<T> & arg) const libmesh_override;
80 
81  virtual void get_diagonal (NumericVector<T> & dest) const libmesh_override;
82 
86  std::vector<ShellMatrix<T> *> matrices;
87 };
88 
89 
90 
91 //-----------------------------------------------------------------------
92 // SumShellMatrix inline members
93 template <typename T>
94 inline
96  ShellMatrix<T>(comm_in),
97  matrices()
98 {}
99 
100 
101 
102 template <typename T>
103 inline
104 SumShellMatrix<T>::SumShellMatrix (const std::vector<ShellMatrix<T> *> & mat,
105  const Parallel::Communicator & comm_in):
106  ShellMatrix<T>(comm_in),
107  matrices(mat)
108 {}
109 
110 
111 
112 template <typename T>
113 inline
115 {}
116 
117 
118 } // namespace libMesh
119 
120 
121 #endif // LIBMESH_SUM_SHELL_MATRIX_H
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.
Encapsulates the MPI_Comm object.
Definition: parallel.h:657
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.
dof_id_type numeric_index_type
Definition: id_types.h:92
std::vector< ShellMatrix< T > * > matrices
A vector of pointers to the summands.
virtual ~SumShellMatrix()
Destructor.
Generic shell matrix, i.e.
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
SumShellMatrix(const Parallel::Communicator &comm_in LIBMESH_CAN_DEFAULT_TO_COMMWORLD)
Constructor; initializes an empty sum.