Reference documentation for deal.II version GIT c14369f203 2023-10-01 07:40:02+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\}}\)
petsc_matrix_base.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2004 - 2023 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 
17 
18 #ifdef DEAL_II_WITH_PETSC
19 
20 # include <deal.II/lac/exceptions.h>
25 
27 
28 namespace PETScWrappers
29 {
30  namespace MatrixIterators
31  {
32 # ifndef DOXYGEN
33  void
35  {
36  // if we are asked to visit the past-the-end line (or a line that is not
37  // stored on the current processor), then simply release all our caches
38  // and go on with life
39  if (matrix->in_local_range(this->a_row) == false)
40  {
41  colnum_cache.reset();
42  value_cache.reset();
43 
44  return;
45  }
46 
47  // get a representation of the present row
48  PetscInt ncols;
49  const PetscInt *colnums;
50  const PetscScalar *values;
51 
52  PetscErrorCode ierr =
53  MatGetRow(*matrix, this->a_row, &ncols, &colnums, &values);
54  AssertThrow(ierr == 0, ExcPETScError(ierr));
55 
56  // copy it into our caches if the line
57  // isn't empty. if it is, then we've
58  // done something wrong, since we
59  // shouldn't have initialized an
60  // iterator for an empty line (what
61  // would it point to?)
62  Assert(ncols != 0, ExcInternalError());
63  colnum_cache =
64  std::make_shared<std::vector<size_type>>(colnums, colnums + ncols);
65  value_cache =
66  std::make_shared<std::vector<PetscScalar>>(values, values + ncols);
67 
68  // and finally restore the matrix
69  ierr = MatRestoreRow(*matrix, this->a_row, &ncols, &colnums, &values);
70  AssertThrow(ierr == 0, ExcPETScError(ierr));
71  }
72 # endif
73  } // namespace MatrixIterators
74 
75 
76 
78  : matrix(nullptr)
79  , last_action(VectorOperation::unknown)
80  {}
81 
82 
84  : matrix(A)
85  , last_action(VectorOperation::unknown)
86  {
87  const PetscErrorCode ierr =
88  PetscObjectReference(reinterpret_cast<PetscObject>(matrix));
89  AssertThrow(ierr == 0, ExcPETScError(ierr));
90  }
91 
92  void
94  {
96  ExcMessage("Cannot assign a new Mat."));
97  PetscErrorCode ierr =
98  PetscObjectReference(reinterpret_cast<PetscObject>(A));
99  AssertThrow(ierr == 0, ExcPETScError(ierr));
100  ierr = MatDestroy(&matrix);
101  AssertThrow(ierr == 0, ExcPETScError(ierr));
102  matrix = A;
103  }
104 
106  {
107  PetscErrorCode ierr = MatDestroy(&matrix);
108  (void)ierr;
109  AssertNothrow(ierr == 0, ExcPETScError(ierr));
110  }
111 
112  void
114  {
115  // destroy the matrix...
116  {
117  const PetscErrorCode ierr = MatDestroy(&matrix);
118  AssertThrow(ierr == 0, ExcPETScError(ierr));
119  }
120 
121  // ...and replace it by an empty
122  // sequential matrix
123  const int m = 0, n = 0, n_nonzero_per_row = 0;
124  const PetscErrorCode ierr = MatCreateSeqAIJ(
125  PETSC_COMM_SELF, m, n, n_nonzero_per_row, nullptr, &matrix);
126  AssertThrow(ierr == 0, ExcPETScError(ierr));
127  }
128 
129 
130 
131  MatrixBase &
133  {
134  (void)d;
136 
138 
139  const PetscErrorCode ierr = MatZeroEntries(matrix);
140  AssertThrow(ierr == 0, ExcPETScError(ierr));
141 
142  return *this;
143  }
144 
145 
146 
147  void
148  MatrixBase::clear_row(const size_type row, const PetscScalar new_diag_value)
149  {
150  std::vector<size_type> rows(1, row);
151  clear_rows(rows, new_diag_value);
152  }
153 
154 
155 
156  void
157  MatrixBase::clear_rows(const std::vector<size_type> &rows,
158  const PetscScalar new_diag_value)
159  {
161 
162  // now set all the entries of these rows
163  // to zero
164  const std::vector<PetscInt> petsc_rows(rows.begin(), rows.end());
165 
166  // call the functions. note that we have
167  // to call them even if #rows is empty,
168  // since this is a collective operation
169  IS index_set;
170 
171  PetscErrorCode ierr;
172  ierr = ISCreateGeneral(get_mpi_communicator(),
173  rows.size(),
174  petsc_rows.data(),
175  PETSC_COPY_VALUES,
176  &index_set);
177  AssertThrow(ierr == 0, ExcPETScError(ierr));
178 
179  ierr = MatZeroRowsIS(matrix, index_set, new_diag_value, nullptr, nullptr);
180  AssertThrow(ierr == 0, ExcPETScError(ierr));
181  ierr = ISDestroy(&index_set);
182  AssertThrow(ierr == 0, ExcPETScError(ierr));
183  }
184 
185  void
186  MatrixBase::clear_rows_columns(const std::vector<size_type> &rows,
187  const PetscScalar new_diag_value)
188  {
190 
191  // now set all the entries of these rows
192  // to zero
193  const std::vector<PetscInt> petsc_rows(rows.begin(), rows.end());
194 
195  // call the functions. note that we have
196  // to call them even if #rows is empty,
197  // since this is a collective operation
198  IS index_set;
199 
200  PetscErrorCode ierr;
201  ierr = ISCreateGeneral(get_mpi_communicator(),
202  rows.size(),
203  petsc_rows.data(),
204  PETSC_COPY_VALUES,
205  &index_set);
206  AssertThrow(ierr == 0, ExcPETScError(ierr));
207 
208  ierr =
209  MatZeroRowsColumnsIS(matrix, index_set, new_diag_value, nullptr, nullptr);
210  AssertThrow(ierr == 0, ExcPETScError(ierr));
211  ierr = ISDestroy(&index_set);
212  AssertThrow(ierr == 0, ExcPETScError(ierr));
213  }
214 
215 
216 
217  PetscScalar
218  MatrixBase::el(const size_type i, const size_type j) const
219  {
220  PetscInt petsc_i = i, petsc_j = j;
221 
222  PetscScalar value;
223 
224  const PetscErrorCode ierr =
225  MatGetValues(matrix, 1, &petsc_i, 1, &petsc_j, &value);
226  AssertThrow(ierr == 0, ExcPETScError(ierr));
227 
228  return value;
229  }
230 
231 
232 
233  PetscScalar
235  {
236  Assert(m() == n(), ExcNotQuadratic());
237 
238  // this doesn't seem to work any
239  // different than any other element
240  return el(i, i);
241  }
242 
243 
244 
245  void
247  {
248  {
249 # ifdef DEBUG
250  // Check that all processors agree that last_action is the same (or none!)
251 
252  int my_int_last_action = last_action;
253  int all_int_last_action;
254 
255  const int ierr = MPI_Allreduce(&my_int_last_action,
256  &all_int_last_action,
257  1,
258  MPI_INT,
259  MPI_BOR,
261  AssertThrowMPI(ierr);
262 
263  AssertThrow(all_int_last_action !=
265  ExcMessage("Error: not all processors agree on the last "
266  "VectorOperation before this compress() call."));
267 # endif
268  }
269 
270  AssertThrow(
272  ExcMessage(
273  "Missing compress() or calling with wrong VectorOperation argument."));
274 
275  // flush buffers
276  PetscErrorCode ierr = MatAssemblyBegin(matrix, MAT_FINAL_ASSEMBLY);
277  AssertThrow(ierr == 0, ExcPETScError(ierr));
278 
279  ierr = MatAssemblyEnd(matrix, MAT_FINAL_ASSEMBLY);
280  AssertThrow(ierr == 0, ExcPETScError(ierr));
281 
283  }
284 
285 
286 
289  {
290  PetscInt n_rows, n_cols;
291 
292  const PetscErrorCode ierr = MatGetSize(matrix, &n_rows, &n_cols);
293  AssertThrow(ierr == 0, ExcPETScError(ierr));
294 
295  return n_rows;
296  }
297 
298 
299 
302  {
303  PetscInt n_rows, n_cols;
304 
305  const PetscErrorCode ierr = MatGetSize(matrix, &n_rows, &n_cols);
306  AssertThrow(ierr == 0, ExcPETScError(ierr));
307 
308  return n_cols;
309  }
310 
311 
312 
315  {
316  PetscInt n_rows;
317 
318  const PetscErrorCode ierr = MatGetLocalSize(matrix, &n_rows, nullptr);
319  AssertThrow(ierr == 0, ExcPETScError(ierr));
320 
321  return n_rows;
322  }
323 
324 
325 
326  std::pair<MatrixBase::size_type, MatrixBase::size_type>
328  {
329  PetscInt begin, end;
330 
331  const PetscErrorCode ierr =
332  MatGetOwnershipRange(static_cast<const Mat &>(matrix), &begin, &end);
333  AssertThrow(ierr == 0, ExcPETScError(ierr));
334 
335  return {begin, end};
336  }
337 
338 
339 
342  {
343  PetscInt n_cols;
344 
345  const PetscErrorCode ierr = MatGetLocalSize(matrix, nullptr, &n_cols);
346  AssertThrow(ierr == 0, ExcPETScError(ierr));
347 
348  return n_cols;
349  }
350 
351 
352 
353  std::pair<MatrixBase::size_type, MatrixBase::size_type>
355  {
356  PetscInt begin, end;
357 
358  const PetscErrorCode ierr =
359  MatGetOwnershipRangeColumn(static_cast<const Mat &>(matrix),
360  &begin,
361  &end);
362  AssertThrow(ierr == 0, ExcPETScError(ierr));
363 
364  return {begin, end};
365  }
366 
367 
368 
369  std::uint64_t
371  {
372  MatInfo mat_info;
373  const PetscErrorCode ierr = MatGetInfo(matrix, MAT_GLOBAL_SUM, &mat_info);
374  AssertThrow(ierr == 0, ExcPETScError(ierr));
375 
376  // MatInfo logs quantities as PetscLogDouble. So we need to cast it to match
377  // our interface.
378  return static_cast<std::uint64_t>(mat_info.nz_used);
379  }
380 
381 
382 
385  {
386  // TODO: this function will probably only work if compress() was called on
387  // the matrix previously. however, we can't do this here, since it would
388  // impose global communication and one would have to make sure that this
389  // function is called the same number of times from all processors,
390  // something that is unreasonable. there should simply be a way in PETSc to
391  // query the number of entries in a row bypassing the call to compress(),
392  // but I can't find one
393  Assert(row < m(), ExcInternalError());
394 
395  // get a representation of the present
396  // row
397  PetscInt ncols;
398  const PetscInt *colnums;
399  const PetscScalar *values;
400 
401  // TODO: this is probably horribly inefficient; we should lobby for a way to
402  // query this information from PETSc
403  PetscErrorCode ierr = MatGetRow(*this, row, &ncols, &colnums, &values);
404  AssertThrow(ierr == 0, ExcPETScError(ierr));
405 
406  // then restore the matrix and return the number of columns in this row as
407  // queried previously. Starting with PETSc 3.4, MatRestoreRow actually
408  // resets the last three arguments to nullptr, to avoid abuse of pointers
409  // now dangling. as a consequence, we need to save the size of the array
410  // and return the saved value.
411  const PetscInt ncols_saved = ncols;
412  ierr = MatRestoreRow(*this, row, &ncols, &colnums, &values);
413  AssertThrow(ierr == 0, ExcPETScError(ierr));
414 
415  return ncols_saved;
416  }
417 
418 
419  PetscReal
421  {
422  PetscReal result;
423 
424  const PetscErrorCode ierr = MatNorm(matrix, NORM_1, &result);
425  AssertThrow(ierr == 0, ExcPETScError(ierr));
426 
427  return result;
428  }
429 
430 
431 
432  PetscReal
434  {
435  PetscReal result;
436 
437  const PetscErrorCode ierr = MatNorm(matrix, NORM_INFINITY, &result);
438  AssertThrow(ierr == 0, ExcPETScError(ierr));
439 
440  return result;
441  }
442 
443 
444 
445  PetscReal
447  {
448  PetscReal result;
449 
450  const PetscErrorCode ierr = MatNorm(matrix, NORM_FROBENIUS, &result);
451  AssertThrow(ierr == 0, ExcPETScError(ierr));
452 
453  return result;
454  }
455 
456 
457  PetscScalar
459  {
460  VectorBase tmp(v);
461  vmult(tmp, v);
462  return tmp * v;
463  }
464 
465 
466  PetscScalar
468  const VectorBase &v) const
469  {
470  VectorBase tmp(u);
471  vmult(tmp, v);
472  return u * tmp;
473  }
474 
475 
476  PetscScalar
478  {
479  PetscScalar result;
480 
481  const PetscErrorCode ierr = MatGetTrace(matrix, &result);
482  AssertThrow(ierr == 0, ExcPETScError(ierr));
483 
484  return result;
485  }
486 
487 
488 
489  MatrixBase &
490  MatrixBase::operator*=(const PetscScalar a)
491  {
492  const PetscErrorCode ierr = MatScale(matrix, a);
493  AssertThrow(ierr == 0, ExcPETScError(ierr));
494 
495  return *this;
496  }
497 
498 
499 
500  MatrixBase &
501  MatrixBase::operator/=(const PetscScalar a)
502  {
503  const PetscScalar factor = 1. / a;
504  const PetscErrorCode ierr = MatScale(matrix, factor);
505  AssertThrow(ierr == 0, ExcPETScError(ierr));
506 
507  return *this;
508  }
509 
510 
511 
512  MatrixBase &
513  MatrixBase::add(const PetscScalar factor, const MatrixBase &other)
514  {
515  const PetscErrorCode ierr =
516  MatAXPY(matrix, factor, other, DIFFERENT_NONZERO_PATTERN);
517  AssertThrow(ierr == 0, ExcPETScError(ierr));
518 
519  return *this;
520  }
521 
522 
523  void
524  MatrixBase::vmult(VectorBase &dst, const VectorBase &src) const
525  {
526  Assert(&src != &dst, ExcSourceEqualsDestination());
527 
528  const PetscErrorCode ierr = MatMult(matrix, src, dst);
529  AssertThrow(ierr == 0, ExcPETScError(ierr));
530  }
531 
532 
533 
534  void
535  MatrixBase::Tvmult(VectorBase &dst, const VectorBase &src) const
536  {
537  Assert(&src != &dst, ExcSourceEqualsDestination());
538 
539  const PetscErrorCode ierr = MatMultTranspose(matrix, src, dst);
540  AssertThrow(ierr == 0, ExcPETScError(ierr));
541  }
542 
543 
544 
545  void
547  {
548  Assert(&src != &dst, ExcSourceEqualsDestination());
549 
550  const PetscErrorCode ierr = MatMultAdd(matrix, src, dst, dst);
551  AssertThrow(ierr == 0, ExcPETScError(ierr));
552  }
553 
554 
555 
556  void
558  {
559  Assert(&src != &dst, ExcSourceEqualsDestination());
560 
561  const PetscErrorCode ierr = MatMultTransposeAdd(matrix, src, dst, dst);
562  AssertThrow(ierr == 0, ExcPETScError(ierr));
563  }
564 
565 
566  namespace internals
567  {
568  void
569  perform_mmult(const MatrixBase &inputleft,
570  const MatrixBase &inputright,
571  MatrixBase &result,
572  const VectorBase &V,
573  const bool transpose_left)
574  {
575  const bool use_vector = (V.size() == inputright.m() ? true : false);
576  if (transpose_left == false)
577  {
578  Assert(inputleft.n() == inputright.m(),
579  ExcDimensionMismatch(inputleft.n(), inputright.m()));
580  }
581  else
582  {
583  Assert(inputleft.m() == inputright.m(),
584  ExcDimensionMismatch(inputleft.m(), inputright.m()));
585  }
586 
587  result.clear();
588 
589  PetscErrorCode ierr;
590 
591  if (use_vector == false)
592  {
593  if (transpose_left)
594  {
595  ierr = MatTransposeMatMult(inputleft,
596  inputright,
597  MAT_INITIAL_MATRIX,
598  PETSC_DEFAULT,
599  &result.petsc_matrix());
600  AssertThrow(ierr == 0, ExcPETScError(ierr));
601  }
602  else
603  {
604  ierr = MatMatMult(inputleft,
605  inputright,
606  MAT_INITIAL_MATRIX,
607  PETSC_DEFAULT,
608  &result.petsc_matrix());
609  AssertThrow(ierr == 0, ExcPETScError(ierr));
610  }
611  }
612  else
613  {
614  Mat tmp;
615  ierr = MatDuplicate(inputleft, MAT_COPY_VALUES, &tmp);
616  AssertThrow(ierr == 0, ExcPETScError(ierr));
617  if (transpose_left)
618  {
619 # if DEAL_II_PETSC_VERSION_LT(3, 8, 0)
620  ierr = MatTranspose(tmp, MAT_REUSE_MATRIX, &tmp);
621 # else
622  ierr = MatTranspose(tmp, MAT_INPLACE_MATRIX, &tmp);
623 # endif
624  AssertThrow(ierr == 0, ExcPETScError(ierr));
625  }
626  ierr = MatDiagonalScale(tmp, nullptr, V);
627  AssertThrow(ierr == 0, ExcPETScError(ierr));
628  ierr = MatMatMult(tmp,
629  inputright,
630  MAT_INITIAL_MATRIX,
631  PETSC_DEFAULT,
632  &result.petsc_matrix());
633  AssertThrow(ierr == 0, ExcPETScError(ierr));
634  ierr = MatDestroy(&tmp);
635  AssertThrow(ierr == 0, ExcPETScError(ierr));
636  }
637  }
638  } // namespace internals
639 
640  void
642  const MatrixBase &B,
643  const VectorBase &V) const
644  {
645  internals::perform_mmult(*this, B, C, V, false);
646  }
647 
648  void
650  const MatrixBase &B,
651  const VectorBase &V) const
652  {
653  internals::perform_mmult(*this, B, C, V, true);
654  }
655 
656  PetscScalar
658  const VectorBase &x,
659  const VectorBase &b) const
660  {
661  // avoid the use of a temporary, and
662  // rather do one negation pass more than
663  // necessary
664  vmult(dst, x);
665  dst -= b;
666  dst *= -1;
667 
668  return dst.l2_norm();
669  }
670 
671 
672 
673  MatrixBase::operator Mat() const
674  {
675  return matrix;
676  }
677 
678  Mat &
680  {
681  return matrix;
682  }
683 
684  void
686  {
687 # if DEAL_II_PETSC_VERSION_LT(3, 8, 0)
688  const PetscErrorCode ierr = MatTranspose(matrix, MAT_REUSE_MATRIX, &matrix);
689 # else
690  const PetscErrorCode ierr =
691  MatTranspose(matrix, MAT_INPLACE_MATRIX, &matrix);
692 # endif
693  AssertThrow(ierr == 0, ExcPETScError(ierr));
694  }
695 
696  PetscBool
697  MatrixBase::is_symmetric(const double tolerance)
698  {
699  PetscBool truth;
701  const PetscErrorCode ierr = MatIsSymmetric(matrix, tolerance, &truth);
702  AssertThrow(ierr == 0, ExcPETScError(ierr));
703  return truth;
704  }
705 
706  PetscBool
707  MatrixBase::is_hermitian(const double tolerance)
708  {
709  PetscBool truth;
710 
712  const PetscErrorCode ierr = MatIsHermitian(matrix, tolerance, &truth);
713  AssertThrow(ierr == 0, ExcPETScError(ierr));
714 
715  return truth;
716  }
717 
718  void
719  MatrixBase::write_ascii(const PetscViewerFormat format)
720  {
722  MPI_Comm comm = PetscObjectComm(reinterpret_cast<PetscObject>(matrix));
723 
724  // Set options
725  PetscErrorCode ierr =
726  PetscViewerSetFormat(PETSC_VIEWER_STDOUT_(comm), format);
727  AssertThrow(ierr == 0, ExcPETScError(ierr));
728 
729  // Write to screen
730  ierr = MatView(matrix, PETSC_VIEWER_STDOUT_(comm));
731  AssertThrow(ierr == 0, ExcPETScError(ierr));
732  }
733 
734  void
735  MatrixBase::print(std::ostream &out, const bool /*alternative_output*/) const
736  {
737  PetscBool has;
738 
739  PetscErrorCode ierr = MatHasOperation(matrix, MATOP_GET_ROW, &has);
740  AssertThrow(ierr == 0, ExcPETScError(ierr));
741 
742  Mat vmatrix = matrix;
743  if (!has)
744  {
745  ierr = MatConvert(matrix, MATAIJ, MAT_INITIAL_MATRIX, &vmatrix);
746  AssertThrow(ierr == 0, ExcPETScError(ierr));
747  }
748 
749  std::pair<MatrixBase::size_type, MatrixBase::size_type> loc_range =
750  local_range();
751 
752  PetscInt ncols;
753  const PetscInt *colnums;
754  const PetscScalar *values;
755 
757  for (row = loc_range.first; row < loc_range.second; ++row)
758  {
759  ierr = MatGetRow(vmatrix, row, &ncols, &colnums, &values);
760  AssertThrow(ierr == 0, ExcPETScError(ierr));
761 
762  for (PetscInt col = 0; col < ncols; ++col)
763  {
764  out << "(" << row << "," << colnums[col] << ") " << values[col]
765  << std::endl;
766  }
767 
768  ierr = MatRestoreRow(vmatrix, row, &ncols, &colnums, &values);
769  AssertThrow(ierr == 0, ExcPETScError(ierr));
770  }
771  if (vmatrix != matrix)
772  {
773  ierr = MatDestroy(&vmatrix);
774  AssertThrow(ierr == 0, ExcPETScError(ierr));
775  }
776  AssertThrow(out.fail() == false, ExcIO());
777  }
778 
779 
780 
781  std::size_t
783  {
784  MatInfo info;
785  const PetscErrorCode ierr = MatGetInfo(matrix, MAT_LOCAL, &info);
786  AssertThrow(ierr == 0, ExcPETScError(ierr));
787 
788  return sizeof(*this) + static_cast<size_type>(info.memory);
789  }
790 
791 } // namespace PETScWrappers
792 
794 
795 #endif // DEAL_II_WITH_PETSC
void add(const size_type i, const size_type j, const PetscScalar value)
size_type row_length(const size_type row) const
std::size_t memory_consumption() const
VectorOperation::values last_action
void vmult(VectorBase &dst, const VectorBase &src) const
void clear_rows(const std::vector< size_type > &rows, const PetscScalar new_diag_value=0)
MPI_Comm get_mpi_communicator() const
PetscScalar diag_element(const size_type i) const
size_type local_domain_size() const
const_iterator begin() const
MatrixBase & operator/=(const PetscScalar factor)
void mmult(MatrixBase &C, const MatrixBase &B, const VectorBase &V) const
PetscBool is_symmetric(const double tolerance=1.e-12)
types::global_dof_index size_type
PetscReal frobenius_norm() const
MatrixBase & operator=(const MatrixBase &)=delete
virtual ~MatrixBase() override
std::pair< size_type, size_type > local_domain() const
const_iterator end() const
void Tvmult_add(VectorBase &dst, const VectorBase &src) const
void print(std::ostream &out, const bool alternative_output=false) const
PetscScalar el(const size_type i, const size_type j) const
PetscBool is_hermitian(const double tolerance=1.e-12)
PetscScalar matrix_scalar_product(const VectorBase &u, const VectorBase &v) const
void Tvmult(VectorBase &dst, const VectorBase &src) const
void clear_rows_columns(const std::vector< size_type > &row_and_column_indices, const PetscScalar new_diag_value=0)
MatrixBase & operator*=(const PetscScalar factor)
PetscScalar residual(VectorBase &dst, const VectorBase &x, const VectorBase &b) const
void Tmmult(MatrixBase &C, const MatrixBase &B, const VectorBase &V) const
void write_ascii(const PetscViewerFormat format=PETSC_VIEWER_DEFAULT)
void vmult_add(VectorBase &dst, const VectorBase &src) const
std::pair< size_type, size_type > local_range() const
void compress(const VectorOperation::values operation)
PetscScalar matrix_norm_square(const VectorBase &v) const
std::uint64_t n_nonzero_elements() const
void clear_row(const size_type row, const PetscScalar new_diag_value=0)
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:477
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:478
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcScalarAssignmentOnlyForZeroValue()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
#define Assert(cond, exc)
Definition: exceptions.h:1616
#define AssertThrowMPI(error_code)
Definition: exceptions.h:1916
#define AssertNothrow(cond, exc)
Definition: exceptions.h:1658
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcSourceEqualsDestination()
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcNotQuadratic()
#define AssertThrow(cond, exc)
Definition: exceptions.h:1705
@ matrix
Contents is actually a matrix.
static const char A
static const char V
void perform_mmult(const MatrixBase &inputleft, const MatrixBase &inputright, MatrixBase &result, const VectorBase &V, const bool transpose_left)
SymmetricTensor< 2, dim, Number > C(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
const MPI_Comm comm