libMesh
Loading...
Searching...
No Matches
sum_shell_matrix.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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
25namespace libMesh
26{
27
28template <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
42template <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
56template <typename T>
58 const NumericVector<T> & arg) const
59{
60 dest.zero();
61 this->vector_mult_add(dest,arg);
62}
63
64
65
66template <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
76template <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
91template class LIBMESH_EXPORT SumShellMatrix<Number>;
92
93} // namespace libMesh
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
virtual void zero()=0
Set all entries to zero.
virtual std::unique_ptr< NumericVector< T > > zero_clone() const =0
This class combines any number of shell matrices to a single shell matrix by summing them together.
virtual void vector_mult(NumericVector< T > &dest, const NumericVector< T > &arg) const override
Multiplies the matrix with arg and stores the result in dest.
virtual numeric_index_type n() const override
virtual void get_diagonal(NumericVector< T > &dest) const override
Copies the diagonal part of the matrix into dest.
virtual void vector_mult_add(NumericVector< T > &dest, const NumericVector< T > &arg) const override
Multiplies the matrix with arg and adds the result to dest.
virtual numeric_index_type m() const override
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153
libmesh_assert(ctx)
dof_id_type numeric_index_type
Definition id_types.h:99