Reference documentation for deal.II version 9.2.0
\(\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 - 2019 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 
34 namespace mg
35 {
43  template <typename number>
45  {
46  public:
47  void
48  resize(const unsigned int minlevel, const unsigned int maxlevel);
49 
50  template <typename DoFHandlerType>
51  void
52  reinit(const DoFHandlerType &dof_handler);
53 
54  void
55  set_zero();
56 
59 
65  };
66 
67 
68  template <typename number>
69  void
70  SparseMatrixCollection<number>::resize(const unsigned int minlevel,
71  const unsigned int maxlevel)
72  {
73  matrix.resize(minlevel, maxlevel);
74  matrix.clear_elements();
75  matrix_up.resize(minlevel + 1, maxlevel);
76  matrix_up.clear_elements();
77  matrix_down.resize(minlevel + 1, maxlevel);
78  matrix_down.clear_elements();
79  matrix_in.resize(minlevel, maxlevel);
80  matrix_in.clear_elements();
81  matrix_out.resize(minlevel, maxlevel);
82  matrix_out.clear_elements();
83  sparsity.resize(minlevel, maxlevel);
84  sparsity_edge.resize(minlevel, maxlevel);
85  }
86 
87 
88  template <typename number>
89  template <typename DoFHandlerType>
90  void
91  SparseMatrixCollection<number>::reinit(const DoFHandlerType &dof_handler)
92  {
93  AssertIndexRange(sparsity.max_level(),
94  dof_handler.get_triangulation().n_levels());
95 
96  for (unsigned int level = sparsity.min_level();
97  level <= sparsity.max_level();
98  ++level)
99  {
100  DynamicSparsityPattern dsp(dof_handler.n_dofs(level));
101  MGTools::make_flux_sparsity_pattern(dof_handler, dsp, level);
102  sparsity[level].copy_from(dsp);
103  matrix[level].reinit(sparsity[level]);
104  matrix_in[level].reinit(sparsity[level]);
105  matrix_out[level].reinit(sparsity[level]);
106  if (level > 0)
107  {
108  DynamicSparsityPattern ci_sparsity;
109  ci_sparsity.reinit(dof_handler.n_dofs(level - 1),
110  dof_handler.n_dofs(level));
112  ci_sparsity,
113  level);
114  sparsity_edge[level].copy_from(ci_sparsity);
115  matrix_up[level].reinit(sparsity_edge[level]);
116  matrix_down[level].reinit(sparsity_edge[level]);
117  }
118  }
119  }
120 
121  template <typename number>
122  void
124  {
125  matrix = 0.;
126  matrix_in = 0.;
127  matrix_out = 0.;
128  matrix_up = 0.;
129  matrix_down = 0.;
130  }
131 
132 } // namespace mg
133 
135 
136 #endif
mg::SparseMatrixCollection::reinit
void reinit(const DoFHandlerType &dof_handler)
Definition: sparse_matrix_collection.h:91
MGTools::make_flux_sparsity_pattern
void make_flux_sparsity_pattern(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternType &sparsity, const unsigned int level)
Definition: mg_tools.cc:599
dynamic_sparsity_pattern.h
mg_base.h
sparse_matrix.h
mg::SparseMatrixCollection::matrix_in
MGLevelObject< SparseMatrix< number > > matrix_in
Definition: sparse_matrix_collection.h:63
mg::SparseMatrixCollection::sparsity_edge
MGLevelObject< SparsityPattern > sparsity_edge
Definition: sparse_matrix_collection.h:58
mg::SparseMatrixCollection::set_zero
void set_zero()
Definition: sparse_matrix_collection.h:123
mg::SparseMatrixCollection::matrix
MGLevelObject< SparseMatrix< number > > matrix
Definition: sparse_matrix_collection.h:60
mg::SparseMatrixCollection
Definition: sparse_matrix_collection.h:44
mg::SparseMatrixCollection::matrix_out
MGLevelObject< SparseMatrix< number > > matrix_out
Definition: sparse_matrix_collection.h:64
AssertIndexRange
#define AssertIndexRange(index, range)
Definition: exceptions.h:1649
mg
Definition: mg.h:81
Subscriptor
Definition: subscriptor.h:62
level
unsigned int level
Definition: grid_out.cc:4355
mg_tools.h
mg::SparseMatrixCollection::resize
void resize(const unsigned int minlevel, const unsigned int maxlevel)
Definition: sparse_matrix_collection.h:70
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
LAPACKSupport::matrix
@ matrix
Contents is actually a matrix.
Definition: lapack_support.h:60
DynamicSparsityPattern
Definition: dynamic_sparsity_pattern.h:323
mg_level_object.h
mg::SparseMatrixCollection::sparsity
MGLevelObject< SparsityPattern > sparsity
Definition: sparse_matrix_collection.h:57
MGLevelObject< SparsityPattern >
vector.h
config.h
mg::SparseMatrixCollection::matrix_down
MGLevelObject< SparseMatrix< number > > matrix_down
Definition: sparse_matrix_collection.h:61
DynamicSparsityPattern::reinit
void reinit(const size_type m, const size_type n, const IndexSet &rowset=IndexSet())
Definition: dynamic_sparsity_pattern.cc:301
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
mg::SparseMatrixCollection::matrix_up
MGLevelObject< SparseMatrix< number > > matrix_up
Definition: sparse_matrix_collection.h:62
MGTools::make_flux_sparsity_pattern_edge
void make_flux_sparsity_pattern_edge(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternType &sparsity, const unsigned int level)
Definition: mg_tools.cc:674