const unsigned int n_q_points = quadrature_formula.size();
FullMatrix<double> cell_matrix (dofs_per_cell, dofs_per_cell);
- Vector<double> cell_rhs (dofs_per_cell);
+ LA::Vector cell_rhs (dofs_per_cell);
- std::vector<unsigned int> local_dof_indices (dofs_per_cell);
+ std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
const Coefficient<dim> coefficient;
std::vector<double> coefficient_values (n_q_points);
* default argument keeps all
* entries.
*/
- CompressedSimpleSparsityPattern (const unsigned int m,
- const unsigned int n,
+ CompressedSimpleSparsityPattern (const size_type m,
+ const size_type n,
const IndexSet &rowset = IndexSet());
+ /**
+ * Create a square matrix using
+ * the index set.
+ */
+ CompressedSimpleSparsityPattern (const IndexSet &indexset);
+
/**
* Initialize a square matrix of
* dimension @p n.
* user call whatever function
* she desires.
*/
- void reinit (const unsigned int n_block_rows,
- const unsigned int n_block_columns);
+ void reinit (const size_type n_block_rows,
+ const size_type n_block_columns);
+
+ /**
+ * Efficiently reinit the block matrix for a parallel computation.
+ * Only the BlockSparsityPattern of the Simple type can efficiently
+ * store large sparsity patterns in parallel, so this is the only
+ * supported argument.
+ * The IndexSets describe the locally owned range of DoFs for each block.
+ * Note that each IndexSet needs to contiguous. For a symmetric structure
+ * hand in the same vector for the first two arguments.
+ */
+ void reinit(const std::vector<IndexSet> &rows,
+ const std::vector<IndexSet> &cols,
+ const BlockCompressedSimpleSparsityPattern &bcsp,
+ const MPI_Comm &com);
+
+
+ /**
+ * Same as above but only for a symmetric structure only.
+ */
+ void reinit(const std::vector<IndexSet> &sizes,
+ const BlockCompressedSimpleSparsityPattern &bcsp,
+ const MPI_Comm &com);
+
+
+
/**
* Matrix-vector multiplication:
* let $dst = M*src$ with $M$
* the start.
*/
template <typename SparsityType>
- void reinit (const MPI_Comm &communicator,
- const SparsityType &sparsity_pattern,
- const std::vector<unsigned int> &local_rows_per_process,
- const std::vector<unsigned int> &local_columns_per_process,
- const unsigned int this_process,
- const bool preset_nonzero_locations = true);
+ void reinit (const MPI_Comm &communicator,
+ const SparsityType &sparsity_pattern,
+ const std::vector<size_type> &local_rows_per_process,
+ const std::vector<size_type> &local_columns_per_process,
+ const unsigned int this_process,
+ const bool preset_nonzero_locations = true);
+ /**
+ * Create a matrix where the size() of the IndexSets determine the global
+ * number of rows and columns and the entries of the IndexSet give
+ * the rows and columns for the calling processor.
+ * Note that only contiguous IndexSets are supported.
+ */
+ template <typename SparsityType>
+ void reinit (const IndexSet & local_rows,
+ const IndexSet & local_columns,
+ const SparsityType &sparsity_pattern,
+ const MPI_Comm &communicator);
+
/**
* Return a reference to the MPI
* communicator object in use with
* Same as previous functions.
*/
template <typename SparsityType>
- void do_reinit (const SparsityType &sparsity_pattern,
- const std::vector<unsigned int> &local_rows_per_process,
- const std::vector<unsigned int> &local_columns_per_process,
- const unsigned int this_process,
- const bool preset_nonzero_locations);
+ void do_reinit (const SparsityType &sparsity_pattern,
+ const std::vector<size_type> &local_rows_per_process,
+ const std::vector<size_type> &local_columns_per_process,
+ const unsigned int this_process,
+ const bool preset_nonzero_locations);
+ /**
+ * Same as previous functions.
+ */
+ template <typename SparsityType>
+ void do_reinit (const IndexSet & local_rows,
+ const IndexSet & local_columns,
+ const SparsityType &sparsity_pattern);
+
/**
* To allow calling protected
* prepare_add() and
}
+CompressedSimpleSparsityPattern::CompressedSimpleSparsityPattern (const IndexSet &rowset_)
+ :
+ rows(0),
+ cols(0),
+ rowset(0)
+{
+ reinit (rowset_.size(), rowset_.size(), rowset_);
+}
+
- CompressedSimpleSparsityPattern::CompressedSimpleSparsityPattern (const unsigned int n)
+ CompressedSimpleSparsityPattern::CompressedSimpleSparsityPattern (const size_type n)
:
rows(0),
cols(0),
return *this;
}
+ void
+ SparseMatrix::copy_from (const SparseMatrix &other)
+ {
+ if (&other == this)
+ return;
+
+ this->communicator = other.communicator;
+ int ierr = MatCopy(other.matrix, matrix, SAME_NONZERO_PATTERN);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+ }
void
- SparseMatrix::reinit (const MPI_Comm &communicator,
- const unsigned int m,
- const unsigned int n,
- const unsigned int local_rows,
- const unsigned int local_columns,
- const unsigned int n_nonzero_per_row,
- const bool is_symmetric)
+ SparseMatrix::reinit (const MPI_Comm &communicator,
+ const size_type m,
+ const size_type n,
+ const size_type local_rows,
+ const size_type local_columns,
+ const size_type n_nonzero_per_row,
+ const bool is_symmetric)
{
this->communicator = communicator;
preset_nonzero_locations);
}
+ template <typename SparsityType>
+ void
+ SparseMatrix::
+ reinit (const IndexSet & local_rows,
+ const IndexSet & local_columns,
+ const SparsityType &sparsity_pattern,
+ const MPI_Comm &communicator)
+ {
+ this->communicator = communicator;
+ // get rid of old matrix and generate a
+ // new one
+#if DEAL_II_PETSC_VERSION_LT(3,2,0)
+ const int ierr = MatDestroy (matrix);
+#else
+ const int ierr = MatDestroy (&matrix);
+#endif
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ do_reinit (local_rows, local_columns, sparsity_pattern);
+ }
void
- SparseMatrix::do_reinit (const unsigned int m,
- const unsigned int n,
- const unsigned int local_rows,
- const unsigned int local_columns,
- const unsigned int n_nonzero_per_row,
- const bool is_symmetric)
+ SparseMatrix::do_reinit (const size_type m,
+ const size_type n,
+ const size_type local_rows,
+ const size_type local_columns,
+ const size_type n_nonzero_per_row,
+ const bool is_symmetric)
{
Assert (local_rows <= m, ExcLocalRowsTooLarge (local_rows, m));
const unsigned int,
const bool);
+ template void
+ SparseMatrix::
+ reinit (const IndexSet &,
+ const IndexSet &,
+ const CompressedSimpleSparsityPattern &,
+ const MPI_Comm &);
+
template void
SparseMatrix::do_reinit (const SparsityPattern &,
- const std::vector<unsigned int> &,
- const std::vector<unsigned int> &,
+ const std::vector<size_type> &,
+ const std::vector<size_type> &,
const unsigned int ,
const bool);
template void
//one index and the value per local
//entry.
return sizeof(*this)
- + this->local_size()*( sizeof(double)+sizeof(int) );
+ + this->local_size()*( sizeof(double)+
+ sizeof(TrilinosWrappers::types::int_type) );
}
+ void
+ VectorBase::update_ghost_values() const
+ {
+ }
+
} /* end of namespace TrilinosWrappers */