deal.II version GIT relicensing-6842-g793a97d2aa 2026-10-02 14:00:01+00:00
\(\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\}}\)
Loading...
Searching...
No Matches
sparse_matrix_collection.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2013 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_mg_sparse_matrix_collection_h
14#define dealii_mg_sparse_matrix_collection_h
15
16#include <deal.II/base/config.h>
17
19
23#include <deal.II/lac/vector.h>
24
27
28#include <memory>
29
31
32namespace mg
33{
38 template <typename number>
61
62
63 template <typename number>
64 void
65 SparseMatrixCollection<number>::resize(const unsigned int minlevel,
66 const unsigned int maxlevel)
67 {
68 matrix.resize(minlevel, maxlevel);
69 matrix.clear_elements();
70 matrix_up.resize(minlevel + 1, maxlevel);
71 matrix_up.clear_elements();
72 matrix_down.resize(minlevel + 1, maxlevel);
73 matrix_down.clear_elements();
74 matrix_in.resize(minlevel, maxlevel);
75 matrix_in.clear_elements();
76 matrix_out.resize(minlevel, maxlevel);
77 matrix_out.clear_elements();
78 sparsity.resize(minlevel, maxlevel);
79 sparsity_edge.resize(minlevel, maxlevel);
80 }
81
82
83 template <typename number>
84 template <int dim, int spacedim>
85 void
87 const DoFHandler<dim, spacedim> &dof_handler)
88 {
89 AssertIndexRange(sparsity.max_level(),
90 dof_handler.get_triangulation().n_levels());
91
92 for (unsigned int level = sparsity.min_level();
93 level <= sparsity.max_level();
94 ++level)
95 {
96 DynamicSparsityPattern dsp(dof_handler.n_dofs(level));
98 sparsity[level].copy_from(dsp);
99 matrix[level].reinit(sparsity[level]);
100 matrix_in[level].reinit(sparsity[level]);
101 matrix_out[level].reinit(sparsity[level]);
102 if (level > 0)
103 {
104 DynamicSparsityPattern ci_sparsity;
105 ci_sparsity.reinit(dof_handler.n_dofs(level - 1),
106 dof_handler.n_dofs(level));
108 ci_sparsity,
109 level);
110 sparsity_edge[level].copy_from(ci_sparsity);
111 matrix_up[level].reinit(sparsity_edge[level]);
112 matrix_down[level].reinit(sparsity_edge[level]);
113 }
114 }
115 }
116
117 template <typename number>
118 void
120 {
121 matrix = 0.;
122 matrix_in = 0.;
123 matrix_out = 0.;
124 matrix_up = 0.;
125 matrix_down = 0.;
126 }
127
128} // namespace mg
129
131
132#endif
const Triangulation< dim, spacedim > & get_triangulation() const
types::global_dof_index n_dofs() const
void reinit(const size_type m, const size_type n, const IndexSet &rowset=IndexSet())
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:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
unsigned int level
Definition grid_out.cc:4642
#define AssertIndexRange(index, range)
void make_flux_sparsity_pattern(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternBase &sparsity, const unsigned int level, const AffineConstraints< number > &constraints={}, const bool keep_constrained_dofs=true)
Definition mg_tools.cc:604
void make_flux_sparsity_pattern_edge(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternBase &sparsity, const unsigned int level)
Definition mg_tools.cc:677
Definition mg.h:79