system_matrix.clear();
system_precon.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();
DoFTools::make_sparsity_pattern(dof_handler, dsp,
constraints, true);
SparsityTools::distribute_sparsity_pattern (dsp,
dof_handler.locally_owned_dofs_per_processor(),
mpi_communicator,
locally_relevant_dofs);
system_matrix.reinit(dsp);
system_precon.reinit(dsp);
locally_relevant_solution.reinit (owned_partitioning,
relevant_partitioning,
mpi_communicator);
system_rhs.reinit (owned_partitioning,
mpi_communicator);
Next I assemble the matrices and use "constraint object" to distribute local to global as follows
cell->get_dof_indices (local_dof_indices);
constraints.distribute_local_to_global(cell_matrix, cell_rhs,
local_dof_indices,
system_matrix,
system_rhs);
constraints.distribute_local_to_global(cell_precond,
local_dof_indices,
system_precon);
However at these two last lines the excution crashes with the message
You are trying an operation on a vector that is only allowed if the vector has no ghost elements, but the vector you are operating on does have ghost elements. Specifically, vectors with ghost elements are read-only and cannot appear in operations that write into these vectors.
why is this happening. I am not creating the system_rhs with ghost elements.
Any help is appriciated. Thank you.
Best,
Ashkan