* Create a sparse matrix of
* dimensions @p m times @p n, with
* an initial guess of @p
- * n_nonzero_per_row nonzero elements
- * per row. PETSc is able to cope
- * with the situation that more than
- * this number of elements are later
- * allocated for a row, but this
+ * n_nonzero_per_row and @p
+ * n_offdiag_nonzero_per_row nonzero
+ * elements per row (see documentation
+ * of the MatCreateAIJ PETSc function
+ * for more information about these
+ * parameters). PETSc is able to
+ * cope with the situation that more
+ * than this number of elements are
+ * later allocated for a row, but this
* involves copying data, and is thus
* expensive.
*
const size_type local_rows,
const size_type local_columns,
const size_type n_nonzero_per_row,
- const bool is_symmetric = false);
+ const bool is_symmetric = false,
+ const size_type n_offdiag_nonzero_per_row = 0);
/**
* Initialize a rectangular matrix
* with @p m rows and @p n columns.
* The maximal number of nonzero
- * entries for each row separately is
- * given by the @p row_lengths array.
+ * entries for diagonal and off-
+ * diagonal blocks of each row is
+ * given by the @p row_lengths and
+ * @p offdiag_row_lengths arrays.
*
* For the meaning of the @p
* local_row and @p local_columns
const size_type local_rows,
const size_type local_columns,
const std::vector<size_type> &row_lengths,
- const bool is_symmetric = false);
+ const bool is_symmetric = false,
+ const std::vector<size_type> &offdiag_row_lengths = std::vector<size_type>());
/**
* Initialize using the given
const size_type local_rows,
const size_type local_columns,
const size_type n_nonzero_per_row,
- const bool is_symmetric = false);
+ const bool is_symmetric = false,
+ const size_type n_offdiag_nonzero_per_row = 0);
/**
* Throw away the present matrix and
const size_type local_rows,
const size_type local_columns,
const std::vector<size_type> &row_lengths,
- const bool is_symmetric = false);
+ const bool is_symmetric = false,
+ const std::vector<size_type> &offdiag_row_lengths = std::vector<size_type>());
/**
* Initialize using the given
const size_type local_rows,
const size_type local_columns,
const size_type n_nonzero_per_row,
- const bool is_symmetric = false);
+ const bool is_symmetric = false,
+ const size_type n_offdiag_nonzero_per_row = 0);
/**
* Same as previous function.
const size_type local_rows,
const size_type local_columns,
const std::vector<size_type> &row_lengths,
- const bool is_symmetric = false);
+ const bool is_symmetric = false,
+ const std::vector<size_type> &offdiag_row_lengths = std::vector<size_type>());
/**
* Same as previous functions.
const size_type local_rows,
const size_type local_columns,
const size_type n_nonzero_per_row,
- const bool is_symmetric)
+ const bool is_symmetric,
+ const size_type n_offdiag_nonzero_per_row)
:
communicator (communicator)
{
do_reinit (m, n, local_rows, local_columns,
- n_nonzero_per_row, is_symmetric);
+ n_nonzero_per_row, is_symmetric,
+ n_offdiag_nonzero_per_row);
}
const size_type local_rows,
const size_type local_columns,
const std::vector<size_type> &row_lengths,
- const bool is_symmetric)
+ const bool is_symmetric,
+ const std::vector<size_type> &offdiag_row_lengths)
:
communicator (communicator)
{
do_reinit (m, n, local_rows, local_columns,
- row_lengths, is_symmetric);
+ row_lengths, is_symmetric, offdiag_row_lengths);
}
const size_type local_rows,
const size_type local_columns,
const size_type n_nonzero_per_row,
- const bool is_symmetric)
+ const bool is_symmetric,
+ const size_type n_offdiag_nonzero_per_row)
{
this->communicator = communicator;
AssertThrow (ierr == 0, ExcPETScError(ierr));
do_reinit (m, n, local_rows, local_columns,
- n_nonzero_per_row, is_symmetric);
+ n_nonzero_per_row, is_symmetric,
+ n_offdiag_nonzero_per_row);
}
const size_type local_rows,
const size_type local_columns,
const std::vector<size_type> &row_lengths,
- const bool is_symmetric)
+ const bool is_symmetric,
+ const std::vector<size_type> &offdiag_row_lengths)
{
this->communicator = communicator;
#endif
AssertThrow (ierr == 0, ExcPETScError(ierr));
- do_reinit (m, n, local_rows, local_columns, row_lengths, is_symmetric);
+ do_reinit (m, n, local_rows, local_columns,
+ row_lengths, is_symmetric, offdiag_row_lengths);
}
const size_type local_rows,
const size_type local_columns,
const size_type n_nonzero_per_row,
- const bool is_symmetric)
+ const bool is_symmetric,
+ const size_type n_offdiag_nonzero_per_row)
{
Assert (local_rows <= m, ExcLocalRowsTooLarge (local_rows, m));
= MatCreateMPIAIJ (communicator,
local_rows, local_columns,
m, n,
- n_nonzero_per_row, 0, 0, 0,
+ n_nonzero_per_row, 0,
+ n_offdiag_nonzero_per_row, 0,
&matrix);
#else
ierr
= MatCreateAIJ (communicator,
local_rows, local_columns,
m, n,
- n_nonzero_per_row, 0, 0, 0,
+ n_nonzero_per_row, 0,
+ n_offdiag_nonzero_per_row, 0,
&matrix);
AssertThrow (ierr == 0, ExcPETScError(ierr));
const size_type local_rows,
const size_type local_columns,
const std::vector<size_type> &row_lengths,
- const bool is_symmetric)
+ const bool is_symmetric,
+ const std::vector<size_type> &offdiag_row_lengths)
{
Assert (local_rows <= m, ExcLocalRowsTooLarge (local_rows, m));
// tricks with conversions of pointers
const std::vector<PetscInt> int_row_lengths (row_lengths.begin(),
row_lengths.end());
+ const std::vector<PetscInt> int_offdiag_row_lengths (offdiag_row_lengths.begin(),
+ offdiag_row_lengths.end());
//TODO: There must be a significantly better way to provide information about the off-diagonal blocks of the matrix. this way, petsc keeps allocating tiny chunks of memory, and gets completely hung up over this
= MatCreateMPIAIJ (communicator,
local_rows, local_columns,
m, n,
- 0, &int_row_lengths[0], 0, 0,
+ 0, &int_row_lengths[0],
+ 0, offdiag_row_lengths.size() ? &int_offdiag_row_lengths[0] : 0,
&matrix);
#else
ierr
= MatCreateAIJ (communicator,
local_rows, local_columns,
m, n,
- 0, &int_row_lengths[0], 0, 0,
+ 0, &int_row_lengths[0],
+ 0, offdiag_row_lengths.size() ? &int_offdiag_row_lengths[0] : 0,
&matrix);
AssertThrow (ierr == 0, ExcPETScError(ierr));