From 2447c614140aaf6ec6e64ff9a11625525afe310b Mon Sep 17 00:00:00 2001 From: bangerth Date: Mon, 25 Mar 2013 14:53:34 +0000 Subject: [PATCH] Patch by Juan Carlos Araujo Cabarcas: Explain how to use ARPACK as an alternative to SLEPc. git-svn-id: https://svn.dealii.org/trunk@29027 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 14 ++-- deal.II/examples/step-36/doc/results.dox | 89 +++++++++++++++++++++++- 2 files changed, 95 insertions(+), 8 deletions(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index f1a687f089..c81a48e340 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -42,6 +42,11 @@ this function.
    +
  1. New: The results section of step-36 now explains how to use ARPACK + as an alternative to SLEPc as eigenvalue solver. +
    + (Juan Carlos Araujo Cabarcas, 2013/03/25) +
  2. New: deal.II now uses CMake as its configuration and build tool. Please read through the readme and other installation files for information about how the @@ -58,7 +63,6 @@ this function.
    (Matthias Maier, 2013/03/07) -
@@ -78,10 +82,10 @@ sense. (Guido Kanschat, 2013/03/21) -
  • Added GridOut::write_svg to allow for the output of two-dimensional -triangulations in two space dimensions in the SVG format (Scalable Vector -Graphics, an XML-based vector image format recommended by the World -Wide Web Consortium W3C). This function also provides cell coloring +
  • Added GridOut::write_svg to allow for the output of two-dimensional +triangulations in two space dimensions in the SVG format (Scalable Vector +Graphics, an XML-based vector image format recommended by the World +Wide Web Consortium W3C). This function also provides cell coloring and cell labeling for the visualization of basic cell properties.
    (Christian Wülker, 2013/03/21) diff --git a/deal.II/examples/step-36/doc/results.dox b/deal.II/examples/step-36/doc/results.dox index fbbb313f63..9684b72a4e 100644 --- a/deal.II/examples/step-36/doc/results.dox +++ b/deal.II/examples/step-36/doc/results.dox @@ -190,11 +190,94 @@ PETScWrappers and SLEPcWrappers and is suitable for running on serial machine architecture. However, for larger grids and with a larger number of degrees-of-freedom, we may want to run our application on parallel architectures. A parallel implementation of the above code -can be particuarily useful here since the generalized eigenspectrum +can be particularily useful here since the generalized eigenspectrum problem is somewhat more expensive to solve than the standard problems -considered most of the earlier tutorials. Fortunately, modifying the above -program to be MPI complient is a relatively straightforward +considered in most of the earlier tutorials. Fortunately, modifying the above +program to be MPI compliant is a relatively straightforward procedure. A sketch of how this can be done can be found in @ref step_17 "step-17". +
  • Finally, there are alternatives to using the SLEPc eigenvalue +solvers. deal.II has interfaces to one of them, ARPACK (see +http://www.dealii.org/developer/external-libs/arpack.html), implemented in the +ArpackSolver class. Here is a short and quick overview of what one would need +to change to use it, provided you have a working installation of ARPACK and +deal.II has been configured properly for it (see the deal.II ReadMe file +at http://www.dealii.org/readme.html): + +First, in order to use the ARPACK interfaces, we can go back to using standard +deal.II matrices and vectors, so we start by replacing the PETSc and SLEPc +headers +@code +#include +#include +#include +@endcode +with these: +@code +#include +#include +#include +#include +@endcode +ARPACK allows complex eigenvalues, so we will also need +@code +#include +@endcode + +Secondly, we switch back to the deal.II matrix and vector definitions in the +main class: +@code + SparsityPattern sparsity_pattern; + SparseMatrix stiffness_matrix, mass_matrix; + std::vector > eigenfunctions; + std::vector> eigenvalues; +@endcode +and initialize them as usual in make_grid_and_dofs(): +@code + sparsity_pattern.reinit (dof_handler.n_dofs(), + dof_handler.n_dofs(), + dof_handler.max_couplings_between_dofs()); + + DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern); + constraints.condense (sparsity_pattern); + sparsity_pattern.compress(); + + stiffness_matrix.reinit (sparsity_pattern); + mass_matrix.reinit (sparsity_pattern); +@endcode + +For solving the eigenvalue problem with ARPACK, we finally need to modify +solve(): +@code + template + unsigned int EigenvalueProblem::solve () + { + const unsigned int num_eigs = + parameters.get_integer ("Number of eigenvalues/eigenfunctions"); + + SolverControl solver_control (dof_handler.n_dofs(), 1e-9); + + SparseDirectUMFPACK inverse; + inverse.initialize (stiffness_matrix); + + const unsigned int num_arnoldi_vectors = 2*num_eigs + 2 + ArpackSolver::AdditionalData additional_data(num_arnoldi_vectors); + + ArpackSolver eigensolver (solver_control, additional_data); + eigensolver.solve (stiffness_matrix, + mass_matrix, + preconditioner, + eigenvalues, + eigenfunctions, + num_eigs); + + for (unsigned int i=0; i -- 2.39.5