Yes, it looks like you can not copy a DSP with an IndexSet into a SparsityPattern. We could make that work but it also is not a very useful operation. Can you try replacing DynamicSparsityPattern dsp (locally_relevant_dofs); with DynamicSparsityPattern dsp; ? This is not efficient for large computations because the DSP now stores all rows, but you might be able to copy it to a SparsityPattern now.
Or, you could look at the implementation of print_svg(). It should be easy to write an implementation for DSP based on it. On Sat, Feb 11, 2017 at 2:09 AM, Kartik Jujare <kartik.juj...@gmail.com> wrote: > Hello everyone, > > This question is regarding DynamicSparsityPattern and SparsityPattern. > > I am trying, as a small exercise to parallelize step files and observe the > output. In the step-2 file. I am not able to use the copy_from() function > when I run it in parallel. Could anyone please suggest a workaround to view > the svg file for each processor or point out any mistake that I might have > made? > > Following is the distribute_dofs function. > > * The gnuplots get printed out properly but it is for the Dynamic Matrix: > > > void distribute_dofs (parallel::distributed::Triangulation<dim> > &triangulation, > DoFHandler<dim> &dof_handler, MPI_Comm > mpi_communicator) > { > static const FE_Q<dim> finite_element(1); > > > IndexSet locally_owned_dofs = dof_handler.locally_owned_dofs(); > IndexSet locally_relevant_dofs; > > > ConstraintMatrix constraints; > > dof_handler.distribute_dofs (finite_element); > > > locally_owned_dofs = dof_handler.locally_owned_dofs (); > DoFTools::extract_locally_relevant_dofs (dof_handler, > locally_relevant_dofs); > > > /*constraints.clear (); > constraints.reinit (locally_relevant_dofs); > constraints.close ();*/ > > > DynamicSparsityPattern dsp (locally_relevant_dofs); > > > DoFTools::make_sparsity_pattern (dof_handler, dsp, > constraints, false); > SparsityTools::distribute_sparsity_pattern (dsp, > > dof_handler.n_locally_owned_dofs_per_processor(), > mpi_communicator, > locally_relevant_dofs); > > > std::ofstream out ("sparsity_pattern_1_" + Utilities::int_to_string > (triangulation.locally_owned_subdomain(), 4)); > > > dsp.print_gnuplot(out); > > > /* SparsityPattern sparsity_pattern; > sparsity_pattern.copy_from (dsp); > > > std::ofstream out ("sparsity_pattern_1_" + Utilities::int_to_string > (triangulation.locally_owned_subdomain(), 4) + ".svg"); > sparsity_pattern.print_svg (out);*/ > > > } > > > The following is the error obtained after I uncomment the sparsity pattern > block: > > An error occurred in line <341> of file > </home/dulcet/deal.ii-candi/tmp/unpack/deal.II-v8.4.2/source/lac/dynamic_sparsity_pattern.cc> > in function > bool > dealii::DynamicSparsityPattern::exists(dealii::DynamicSparsityPattern::size_type, > dealii::DynamicSparsityPattern::size_type) const > The violated condition was: > rowset.size()==0 || rowset.is_element(i) > The name and call sequence of the exception was: > ExcInternalError() > Additional Information: > This exception -- which is used in many places in the library -- usually > indicates that some condition which the author of the code thought must be > satisfied at a certain point in an algorithm, is not fulfilled. An example > would be that the first part of an algo > rithm sorts elements of an array in ascending order, and a second part of > the algorithm later encounters an an element that is not larger than the > previous one. > > There is usually not very much you can do if you encounter such an exception > since it indicates an error in deal.II, not in your own program. Try to come > up with the smallest possible program that still demonstrates the error and > contact the deal.II mailing list > s with it to obtain help. > > Stacktrace: > ----------- > #0 /home/dulcet/deal.ii-candi/deal.II-v8.4.2/lib/libdeal_II.g.so.8.4.2: > dealii::DynamicSparsityPattern::exists(unsigned int, unsigned int) const > #1 /home/dulcet/deal.ii-candi/deal.II-v8.4.2/lib/libdeal_II.g.so.8.4.2: > void > dealii::SparsityPattern::copy_from<dealii::DynamicSparsityPattern>(dealii::DynamicSparsityPattern > const&) > #2 ./step-2: > distribute_dofs(dealii::parallel::distributed::Triangulation<2, 2>&, > dealii::DoFHandler<2, 2>&, ompi_communicator_t*) > #3 ./step-2: main > > > Thanks in advance. > > Regards, > Kartik Jujare > > -- > The deal.II project is located at > https://urldefense.proofpoint.com/v2/url?u=http-3A__www.dealii.org_&d=DwIBaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=4k7iKXbjGC8LfYxVJJXiaYVu6FRWmEjX38S7JmlS9Vw&m=6tg7Wykd3f22NQtXx4hSf5Zg4g44ZuuUYYJTPC2l_2U&s=JfXNNQ1rFPxGDk_tuzlEnQJXnWVmKnX8Rg7L7EWn9xg&e= > > For mailing list/forum options, see > https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_forum_dealii-3Fhl-3Den&d=DwIBaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=4k7iKXbjGC8LfYxVJJXiaYVu6FRWmEjX38S7JmlS9Vw&m=6tg7Wykd3f22NQtXx4hSf5Zg4g44ZuuUYYJTPC2l_2U&s=NcfL1PZvJEQ1q3gIRlhIsL2CS8dnsCcrrTYN63e3OS0&e= > > --- > 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 dealii+unsubscr...@googlegroups.com. > For more options, visit > https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_optout&d=DwIBaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=4k7iKXbjGC8LfYxVJJXiaYVu6FRWmEjX38S7JmlS9Vw&m=6tg7Wykd3f22NQtXx4hSf5Zg4g44ZuuUYYJTPC2l_2U&s=OSxtDbuaQNK1SYGlpkdsvLDWZNoGIC3HG9vr0MyvVD4&e= > . -- Timo Heister http://www.math.clemson.edu/~heister/ -- 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 dealii+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.