Hermes, The following line is wrong: *DynamicSparsityPattern dsp(locally_relevant_dofs.n_elements(), locally_relevant_dofs.n_elements());*
This constructor says that you want a sparsity pattern that has *locally_relevant_dofs.n_elements() *elements. This is not the case. You want a sparsity pattern that has as many elements as the total numbers of dofs. Also since you want to use MPI, you need to provide a third argument, the locally_owned IndexSet. You can also simply use: *DynamicSparsityPattern dsp(locally_relevant_dofs);* Best, Bruno On Thursday, September 9, 2021 at 5:29:56 AM UTC-4 [email protected] wrote: > Dear all, > > I adapted step-29 to run in parallel, similar as step-40. With 1 MPI rank > it works, however, when using more than 1 rank I get a running error > (attached is the full output) > > *An error occurred in line <74> of file > </var/folders/8z/hlb6vc015qjggytkxn84m6_c0000gn/T/heltai/spack-stage/spack-stage-dealii-9.3.0-zy7k3uwnakcqjvrajvacy5l4jrl7eaex/spack-src/source/dofs/dof_tools_sparsity.cc> > > in function* > > * void dealii::DoFTools::make_sparsity_pattern(const DoFHandler<dim, > spacedim> &, SparsityPatternType &, const AffineConstraints<number> &, > const bool, const types::subdomain_id) [dim = 2, spacedim = 2, > SparsityPatternType = dealii::DynamicSparsityPattern, number = double]* > > *The violated condition was: * > > * sparsity.n_rows() == n_dofs* > > *Additional information: * > > * Dimension 26752 not equal to 51842* > > I found out that the problem is in the setp_system() function. The > problematic line is in red. Could you please help me to figure out the > issue? > > > *template <int dim>* > > * void UltrasoundProblem<dim>::setup_system()** {* > > * deallog << "Setting up system... ";* > > * deallog << "OK1... ";* > > * dof_handler.distribute_dofs(fe);* > > * locally_owned_dofs = dof_handler.locally_owned_dofs();* > > * DoFTools::extract_locally_relevant_dofs(dof_handler, > locally_relevant_dofs);* > > * locally_relevant_solution.reinit(locally_owned_dofs, * > *locally_relevant_dofs,**mpi_communicator);* > > * system_rhs.reinit(locally_owned_dofs, mpi_communicator);* > > * constraints.clear();* > > * constraints.reinit(locally_relevant_dofs);* > > * DoFTools::make_hanging_node_constraints(dof_handler, constraints);* > > * VectorTools::interpolate_boundary_values(dof_handler,** 1,* > *DirichletBoundaryValues<dim>(),**constraints);* > > * constraints.close();* > > * DynamicSparsityPattern dsp(locally_relevant_dofs.n_elements(), > locally_relevant_dofs.n_elements());* > > * DoFTools::make_sparsity_pattern(dof_handler, > dsp,constraints,false);//THIS* > > > * > SparsityTools::distribute_sparsity_pattern(dsp,dof_handler.locally_owned_dofs(),mpi_communicator,locally_relevant_dofs);* > > * system_matrix.reinit(locally_owned_dofs,locally_owned_dofs, dsp, > mpi_communicator);* > > * }* > > > Thank you very much > > H. > > > > -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/f621e3ee-3bce-49b3-9151-1b5a3e4edc55n%40googlegroups.com.
