Reference documentation for deal.II version 9.3.3
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
sparse_matrix_collection.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2003 - 2020 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_mg_sparse_matrix_collection_h
17#define dealii_mg_sparse_matrix_collection_h
18
19#include <deal.II/base/config.h>
20
22
25#include <deal.II/lac/vector.h>
26
29
30#include <memory>
31
33
34namespace mg
35{
40 template <typename number>
42 {
43 public:
44 void
45 resize(const unsigned int minlevel, const unsigned int maxlevel);
46
47 template <int dim, int spacedim>
48 void
49 reinit(const DoFHandler<dim, spacedim> &dof_handler);
50
51 void
52 set_zero();
53
56
62 };
63
64
65 template <typename number>
66 void
67 SparseMatrixCollection<number>::resize(const unsigned int minlevel,
68 const unsigned int maxlevel)
69 {
70 matrix.resize(minlevel, maxlevel);
71 matrix.clear_elements();
72 matrix_up.resize(minlevel + 1, maxlevel);
73 matrix_up.clear_elements();
74 matrix_down.resize(minlevel + 1, maxlevel);
75 matrix_down.clear_elements();
76 matrix_in.resize(minlevel, maxlevel);
77 matrix_in.clear_elements();
78 matrix_out.resize(minlevel, maxlevel);
79 matrix_out.clear_elements();
80 sparsity.resize(minlevel, maxlevel);
81 sparsity_edge.resize(minlevel, maxlevel);
82 }
83
84
85 template <typename number>
86 template <int dim, int spacedim>
87 void
89 const DoFHandler<dim, spacedim> &dof_handler)
90 {
91 AssertIndexRange(sparsity.max_level(),
92 dof_handler.get_triangulation().n_levels());
93
94 for (unsigned int level = sparsity.min_level();
95 level <= sparsity.max_level();
96 ++level)
97 {
98 DynamicSparsityPattern dsp(dof_handler.n_dofs(level));
100 sparsity[level].copy_from(dsp);
101 matrix[level].reinit(sparsity[level]);
102 matrix_in[level].reinit(sparsity[level]);
103 matrix_out[level].reinit(sparsity[level]);
104 if (level > 0)
105 {
106 DynamicSparsityPattern ci_sparsity;
107 ci_sparsity.reinit(dof_handler.n_dofs(level - 1),
108 dof_handler.n_dofs(level));
110 ci_sparsity,
111 level);
112 sparsity_edge[level].copy_from(ci_sparsity);
113 matrix_up[level].reinit(sparsity_edge[level]);
114 matrix_down[level].reinit(sparsity_edge[level]);
115 }
116 }
117 }
118
119 template <typename number>
120 void
122 {
123 matrix = 0.;
124 matrix_in = 0.;
125 matrix_out = 0.;
126 matrix_up = 0.;
127 matrix_down = 0.;
128 }
129
130} // namespace mg
131
133
134#endif
const Triangulation< dim, spacedim > & get_triangulation() const
types::global_dof_index n_dofs() const
unsigned int n_levels() const
void reinit(const DoFHandler< dim, spacedim > &dof_handler)
MGLevelObject< SparseMatrix< number > > matrix_in
MGLevelObject< SparseMatrix< number > > matrix
MGLevelObject< SparseMatrix< number > > matrix_out
MGLevelObject< SparseMatrix< number > > matrix_up
MGLevelObject< SparsityPattern > sparsity
void resize(const unsigned int minlevel, const unsigned int maxlevel)
MGLevelObject< SparsityPattern > sparsity_edge
MGLevelObject< SparseMatrix< number > > matrix_down
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
unsigned int level
Definition: grid_out.cc:4590
#define AssertIndexRange(index, range)
Definition: exceptions.h:1690
void reinit(const size_type m, const size_type n, const IndexSet &rowset=IndexSet())
@ matrix
Contents is actually a matrix.
void make_flux_sparsity_pattern(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternType &sparsity, const unsigned int level)
Definition: mg_tools.cc:628
void make_flux_sparsity_pattern_edge(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternType &sparsity, const unsigned int level)
Definition: mg_tools.cc:703
Definition: mg.h:82