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
petsc_parallel_full_matrix.cc
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) 2004 - 2026 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
14
15#ifdef DEAL_II_WITH_PETSC
16
17# include <deal.II/base/mpi.h>
18
22
23
24#endif // DEAL_II_WITH_PETSC
25
27
28#ifdef DEAL_II_WITH_PETSC
29
30namespace PETScWrappers
31{
32 namespace MPI
33 {
35 {
36 // just like for vectors and sparse matrices: since we
37 // create an empty matrix, we can as
38 // well make it sequential
39 const PetscInt m = 0, n = 0;
40 const PetscErrorCode ierr =
41 MatCreateSeqDense(PETSC_COMM_SELF, m, n, nullptr, &matrix);
42 AssertThrow(ierr == 0, ExcPETScError(ierr));
43 }
44
45
46
48 : MatrixBase(A)
49 {}
50
51
52
54 {
55 PetscErrorCode ierr = MatDestroy(&matrix);
56 AssertNothrow(ierr == 0, ExcPETScError(ierr));
57 }
58
59
60
61 FullMatrix::FullMatrix(const MPI_Comm communicator,
62 const size_type m,
63 const size_type n,
64 const size_type local_rows_per_process,
65 const size_type local_columns_per_process)
66 {
68 communicator, m, n, local_rows_per_process, local_columns_per_process);
69 }
70
71
72
73 void
74 FullMatrix::reinit(const MPI_Comm communicator,
75 const size_type m,
76 const size_type n,
77 const size_type local_rows_per_process,
78 const size_type local_columns_per_process)
79 {
80 // get rid of old matrix and generate a new one
81 const PetscErrorCode ierr = MatDestroy(&matrix);
82 AssertThrow(ierr == 0, ExcPETScError(ierr));
83
85 communicator, m, n, local_rows_per_process, local_columns_per_process);
86 }
87
88
89
91 FullMatrix::operator=(const value_type d)
92 {
94 return *this;
95 }
96
97
98
99 void
100 FullMatrix::do_reinit(const MPI_Comm communicator,
101 const size_type m,
102 const size_type n,
103 const size_type local_rows_per_process,
104 const size_type local_columns_per_process)
105 {
106 // convert dimensions into PETScInt
107 AssertThrowIntegerConversion(static_cast<PetscInt>(m), m);
108 AssertThrowIntegerConversion(static_cast<PetscInt>(n), n);
109
110 // create a matrix
111 // this will create by default a sequential dense matrix(MATSEQDENSE) if
112 // constructed with a single process communicator and a distributed dense
113 // matrix (MATMPIDENSE) if constructed with more than one.
114 PetscErrorCode ierr = MatCreateDense(communicator,
115 local_rows_per_process,
116 local_columns_per_process,
117 m,
118 n,
119 nullptr,
120 &matrix);
121 AssertThrow(ierr == 0, ExcPETScError(ierr));
122 }
123
124
125
126 } // namespace MPI
127
128} // namespace PETScWrappers
129
130#endif // DEAL_II_WITH_PETSC
void do_reinit(const MPI_Comm communicator, const size_type m, const size_type n, const size_type local_rows_per_process, const size_type local_columns_per_process)
MatrixBase & operator=(const MatrixBase &)=delete
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define AssertThrowIntegerConversion(index1, index2)
#define AssertNothrow(cond, exc)
#define AssertThrow(cond, exc)
void reinit(const MPI_Comm communicator, const size_type m, const size_type n, const size_type local_rows_per_process, const size_type local_columns_per_process)
FullMatrix & operator=(const value_type d)