From e17b552732666690fe4d85e66a32003425a1cd19 Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Mon, 27 Apr 2015 13:54:56 -0500 Subject: [PATCH] Replace PETScWrappers::Vector by PETScWrappers::MPI::Vector in step-36. --- examples/step-36/step-36.cc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/step-36/step-36.cc b/examples/step-36/step-36.cc index 016c174c58..4372c37ee9 100644 --- a/examples/step-36/step-36.cc +++ b/examples/step-36/step-36.cc @@ -44,6 +44,9 @@ #include #include +// IndexSet is used to set the size of PETScWrappers::Vector: +#include + // PETSc appears here because SLEPc depends on this library: #include #include @@ -89,9 +92,9 @@ namespace Step36 // the right hand side. We also need not just one solution function, but a // whole set of these for the eigenfunctions we want to compute, along // with the corresponding eigenvalues: - PETScWrappers::SparseMatrix stiffness_matrix, mass_matrix; - std::vector eigenfunctions; - std::vector eigenvalues; + PETScWrappers::SparseMatrix stiffness_matrix, mass_matrix; + std::vector eigenfunctions; + std::vector eigenvalues; // And then we need an object that will store several run-time parameters // that we will specify in an input file: @@ -194,11 +197,18 @@ namespace Step36 // The next step is to take care of the eigenspectrum. In this case, the // outputs are eigenvalues and eigenfunctions, so we set the size of the // list of eigenfunctions and eigenvalues to be as large as we asked for - // in the input file: + // in the input file. When using a PETScWrappers::MPI::Vector, the Vector + // is initialized using an IndexSet. IndexSet is used not only to resize the + // PETScWrappers::MPI::Vector but it also associates an index in the + // PETScWrappers::MPI::Vector with a degree of freedom (see step-40 for a + // more detailed explanation). This assocation is done by the add_range() + // function: + IndexSet eigenfunction_index_set(dof_handler.n_dofs ()); + eigenfunction_index_set.add_range(0, dof_handler.n_dofs ()); eigenfunctions .resize (parameters.get_integer ("Number of eigenvalues/eigenfunctions")); for (unsigned int i=0; i