// <code>dsp</code> will be released once the information has been copied to
// <code>sparsity_pattern</code>.
{
- BlockDynamicSparsityPattern dsp(2, 2);
-
- dsp.block(0, 0).reinit(n_u, n_u);
- dsp.block(1, 0).reinit(n_p, n_u);
- dsp.block(0, 1).reinit(n_u, n_p);
- dsp.block(1, 1).reinit(n_p, n_p);
-
- dsp.collect_sizes();
+ BlockDynamicSparsityPattern dsp(dofs_per_block, dofs_per_block);
Table<2, DoFTools::Coupling> coupling(dim + 1, dim + 1);
-
for (unsigned int c = 0; c < dim + 1; ++c)
for (unsigned int d = 0; d < dim + 1; ++d)
if (!((c == dim) && (d == dim)))
}
{
- BlockDynamicSparsityPattern preconditioner_dsp(2, 2);
-
- preconditioner_dsp.block(0, 0).reinit(n_u, n_u);
- preconditioner_dsp.block(1, 0).reinit(n_p, n_u);
- preconditioner_dsp.block(0, 1).reinit(n_u, n_p);
- preconditioner_dsp.block(1, 1).reinit(n_p, n_p);
-
- preconditioner_dsp.collect_sizes();
+ BlockDynamicSparsityPattern preconditioner_dsp(dofs_per_block,
+ dofs_per_block);
Table<2, DoFTools::Coupling> preconditioner_coupling(dim + 1, dim + 1);
-
for (unsigned int c = 0; c < dim + 1; ++c)
for (unsigned int d = 0; d < dim + 1; ++d)
if (((c == dim) && (d == dim)))
system_matrix.reinit(sparsity_pattern);
preconditioner_matrix.reinit(preconditioner_sparsity_pattern);
- solution.reinit(2);
- solution.block(0).reinit(n_u);
- solution.block(1).reinit(n_p);
- solution.collect_sizes();
-
- system_rhs.reinit(2);
- system_rhs.block(0).reinit(n_u);
- system_rhs.block(1).reinit(n_p);
- system_rhs.collect_sizes();
+ solution.reinit(dofs_per_block);
+ system_rhs.reinit(dofs_per_block);
}
const unsigned int n_u = stokes_dofs_per_block[0],
n_p = stokes_dofs_per_block[1],
n_T = temperature_dof_handler.n_dofs();
+ const std::vector<unsigned int> stokes_block_sizes = {n_u, n_p};
std::cout << "Number of active cells: " << triangulation.n_active_cells()
<< " (on " << triangulation.n_levels() << " levels)" << std::endl
{
stokes_matrix.clear();
- BlockDynamicSparsityPattern dsp(2, 2);
-
- dsp.block(0, 0).reinit(n_u, n_u);
- dsp.block(0, 1).reinit(n_u, n_p);
- dsp.block(1, 0).reinit(n_p, n_u);
- dsp.block(1, 1).reinit(n_p, n_p);
-
- dsp.collect_sizes();
+ BlockDynamicSparsityPattern dsp(stokes_block_sizes, stokes_block_sizes);
Table<2, DoFTools::Coupling> coupling(dim + 1, dim + 1);
Mp_preconditioner.reset();
stokes_preconditioner_matrix.clear();
- BlockDynamicSparsityPattern dsp(2, 2);
-
- dsp.block(0, 0).reinit(n_u, n_u);
- dsp.block(0, 1).reinit(n_u, n_p);
- dsp.block(1, 0).reinit(n_p, n_u);
- dsp.block(1, 1).reinit(n_p, n_p);
-
- dsp.collect_sizes();
+ BlockDynamicSparsityPattern dsp(stokes_block_sizes, stokes_block_sizes);
Table<2, DoFTools::Coupling> coupling(dim + 1, dim + 1);
for (unsigned int c = 0; c < dim + 1; ++c)
const unsigned int n_u = darcy_dofs_per_block[0],
n_p = darcy_dofs_per_block[1],
n_s = saturation_dof_handler.n_dofs();
+ const std::vector<unsigned int> darcy_block_sizes = {n_u, n_p};
std::cout << "Number of active cells: " << triangulation.n_active_cells()
<< " (on " << triangulation.n_levels() << " levels)" << std::endl
{
darcy_matrix.clear();
- BlockDynamicSparsityPattern dsp(2, 2);
-
- dsp.block(0, 0).reinit(n_u, n_u);
- dsp.block(0, 1).reinit(n_u, n_p);
- dsp.block(1, 0).reinit(n_p, n_u);
- dsp.block(1, 1).reinit(n_p, n_p);
-
- dsp.collect_sizes();
+ BlockDynamicSparsityPattern dsp(darcy_block_sizes, darcy_block_sizes);
Table<2, DoFTools::Coupling> coupling(dim + 1, dim + 1);
-
for (unsigned int c = 0; c < dim + 1; ++c)
for (unsigned int d = 0; d < dim + 1; ++d)
if (!((c == dim) && (d == dim)))
Mp_preconditioner.reset();
darcy_preconditioner_matrix.clear();
- BlockDynamicSparsityPattern dsp(2, 2);
-
- dsp.block(0, 0).reinit(n_u, n_u);
- dsp.block(0, 1).reinit(n_u, n_p);
- dsp.block(1, 0).reinit(n_p, n_u);
- dsp.block(1, 1).reinit(n_p, n_p);
-
- dsp.collect_sizes();
+ BlockDynamicSparsityPattern dsp(darcy_block_sizes, darcy_block_sizes);
Table<2, DoFTools::Coupling> coupling(dim + 1, dim + 1);
for (unsigned int c = 0; c < dim + 1; ++c)
saturation_matrix.reinit(dsp);
}
- std::vector<IndexSet> darcy_partitioning(2);
- darcy_partitioning[0] = complete_index_set(n_u);
- darcy_partitioning[1] = complete_index_set(n_p);
+ const std::vector<IndexSet> darcy_partitioning = {complete_index_set(n_u),
+ complete_index_set(n_p)};
+
darcy_solution.reinit(darcy_partitioning, MPI_COMM_WORLD);
- darcy_solution.collect_sizes();
last_computed_darcy_solution.reinit(darcy_partitioning, MPI_COMM_WORLD);
- last_computed_darcy_solution.collect_sizes();
second_last_computed_darcy_solution.reinit(darcy_partitioning,
MPI_COMM_WORLD);
- second_last_computed_darcy_solution.collect_sizes();
darcy_rhs.reinit(darcy_partitioning, MPI_COMM_WORLD);
- darcy_rhs.collect_sizes();
- IndexSet saturation_partitioning = complete_index_set(n_s);
+ const IndexSet saturation_partitioning = complete_index_set(n_s);
saturation_solution.reinit(saturation_partitioning, MPI_COMM_WORLD);
old_saturation_solution.reinit(saturation_partitioning, MPI_COMM_WORLD);
old_old_saturation_solution.reinit(saturation_partitioning, MPI_COMM_WORLD);
// Setup the sparsity pattern and tangent matrix
tangent_matrix.clear();
{
- const types::global_dof_index n_dofs_u = dofs_per_block[u_dof];
- const types::global_dof_index n_dofs_p = dofs_per_block[p_dof];
- const types::global_dof_index n_dofs_J = dofs_per_block[J_dof];
-
- BlockDynamicSparsityPattern dsp(n_blocks, n_blocks);
-
- dsp.block(u_dof, u_dof).reinit(n_dofs_u, n_dofs_u);
- dsp.block(u_dof, p_dof).reinit(n_dofs_u, n_dofs_p);
- dsp.block(u_dof, J_dof).reinit(n_dofs_u, n_dofs_J);
-
- dsp.block(p_dof, u_dof).reinit(n_dofs_p, n_dofs_u);
- dsp.block(p_dof, p_dof).reinit(n_dofs_p, n_dofs_p);
- dsp.block(p_dof, J_dof).reinit(n_dofs_p, n_dofs_J);
-
- dsp.block(J_dof, u_dof).reinit(n_dofs_J, n_dofs_u);
- dsp.block(J_dof, p_dof).reinit(n_dofs_J, n_dofs_p);
- dsp.block(J_dof, J_dof).reinit(n_dofs_J, n_dofs_J);
- dsp.collect_sizes();
+ BlockDynamicSparsityPattern dsp(dofs_per_block, dofs_per_block);
// The global system matrix initially has the following structure
// @f{align*}
// We then set up storage vectors
system_rhs.reinit(dofs_per_block);
- system_rhs.collect_sizes();
-
solution_n.reinit(dofs_per_block);
- solution_n.collect_sizes();
// ...and finally set up the quadrature
// point history:
const std::vector<BlockVector<double>::size_type> block_sizes = {
n_p, n_u, n_p, n_u, n_p, n_p, n_p, n_p, n_p};
- BlockDynamicSparsityPattern dsp(9, 9);
- for (unsigned int k = 0; k < 9; ++k)
- for (unsigned int j = 0; j < 9; ++j)
- dsp.block(j, k).reinit(block_sizes[j], block_sizes[k]);
- dsp.collect_sizes();
+ BlockDynamicSparsityPattern dsp(block_sizes, block_sizes);
// The bulk of the function is in setting up which of these
collect_sizes();
}
+
+
void
BlockVector::reinit(const std::vector<IndexSet> ¶llel_partitioning,
const std::vector<IndexSet> &ghost_values,
}
+
void
BlockVector::reinit(const BlockVector &v, const bool omit_zeroing_entries)
{