#include <deal.II/base/subscriptor.h>
#include <deal.II/base/template_constraints.h>
+#include <lac/sparsity_pattern.h>
#include <deal.II/fe/fe.h>
#include <vector>
DEAL_II_NAMESPACE_OPEN
/**
- * @warning This class is still experimental and will most likely be
- * changed in a future release.
+ * @deprecated This class is experimental and will be
+ * removed in a future release.
*
* A vector of index sets listing the indices of small blocks of a
* linear system. For each block, the indices in that block are
/// The iterator for individual indices
typedef block_container::const_iterator const_iterator;
+ /**
+ * Since SparsityPattern can
+ * handle the tasks of BlockList,
+ * this function allows us to
+ * create one from an already
+ * filled BlockList. A first step
+ * to make BlockList obsolete.
+ *
+ * The additional integer
+ * argument is the dimension of
+ * the vector space.
+ */
+ void create_sparsity_pattern(SparsityPattern& sparsity, unsigned int n) const;
+
/**
* Add the indices in
* <tt>indices</tt> to block
};
+inline
+void
+BlockList::create_sparsity_pattern(SparsityPattern& sparsity, unsigned int n) const
+{
+ std::vector<unsigned int> sizes(size());
+ for (unsigned int b=0;b<size();++b)
+ sizes[b] = block_size(b);
+
+ sparsity.reinit(size(), n, sizes);
+ for (unsigned int b=0;b<size();++b)
+ {
+ for (const_iterator i = begin(b); i != end(b); ++i)
+ sparsity.add(b,*i);
+ }
+ sparsity.compress();
+}
+
+
inline
void
BlockList::add(const unsigned int block, const std::vector<unsigned int>& indices)
const bool invert_diagonal,
const bool same_diagonal)
:
- block_list(bl),
relaxation(relaxation),
invert_diagonal(invert_diagonal),
same_diagonal(same_diagonal),
inversion(PreconditionBlockBase<inverse_type>::gauss_jordan),
threshold(0.)
-{}
+{
+ bl.create_sparsity_pattern(block_list, 0);
+}
template <class MATRIX, typename inverse_type>
additional_data = ¶meters;
this->inversion = parameters.inversion;
- this->reinit(additional_data->block_list.size(), 0, additional_data->same_diagonal,
+ this->reinit(additional_data->block_list.n_rows(), 0, additional_data->same_diagonal,
additional_data->inversion);
if (additional_data->invert_diagonal)
}
else
{
- for (unsigned int block=0;block<additional_data->block_list.size();++block)
+ for (unsigned int block=0;block<additional_data->block_list.n_rows();++block)
{
- const unsigned int bs = additional_data->block_list.block_size(block);
+ const unsigned int bs = additional_data->block_list.row_length(block);
M_cell.reinit(bs, bs);
// Copy rows for this block
// into the matrix for the
// diagonal block
- BlockList::const_iterator row = additional_data->block_list.begin(block);
+ SparsityPattern::row_iterator row
+ = additional_data->block_list.row_begin(block);
for (unsigned int row_cell=0; row_cell<bs; ++row_cell, ++row)
{
//TODO:[GK] Optimize here
entry != M.end(*row); ++entry)
{
const unsigned int column = entry->column();
- const unsigned int col_cell = additional_data->block_list.local_index(block, column);
+ const unsigned int col_cell = additional_data->block_list.row_position(block, column);
if (col_cell != numbers::invalid_unsigned_int)
M_cell(row_cell, col_cell) = entry->value();
}
const bool permutation_empty = additional_data->order.size() == 0;
const unsigned int n_permutations = (permutation_empty)
? 1U : additional_data->order.size();
- const unsigned int n_blocks = additional_data->block_list.size();
+ const unsigned int n_blocks = additional_data->block_list.n_rows();
if (!permutation_empty)
for (unsigned int i=0;i<additional_data->order.size();++i)
? (additional_data->order[n_permutations-1-perm][raw_block])
: (additional_data->order[perm][raw_block]));
- const unsigned int bs = additional_data->block_list.block_size(block);
+ const unsigned int bs = additional_data->block_list.row_length(block);
b_cell.reinit(bs);
x_cell.reinit(bs);
// Collect off-diagonal parts
- BlockList::const_iterator row = additional_data->block_list.begin(block);
+ SparsityPattern::row_iterator row = additional_data->block_list.row_begin(block);
for (unsigned int row_cell=0; row_cell<bs; ++row_cell, ++row)
{
b_cell(row_cell) = src(*row);
// Apply inverse diagonal
this->inverse_vmult(block, x_cell, b_cell);
// Store in result vector
- row=additional_data->block_list.begin(block);
+ row=additional_data->block_list.row_begin(block);
for (unsigned int row_cell=0; row_cell<bs; ++row_cell, ++row)
dst(*row) = prev(*row) + additional_data->relaxation * x_cell(row_cell);
}