From 9c30820a009a522f98b6ddc3541623523fcb4f62 Mon Sep 17 00:00:00 2001 From: "Toby D. Young" Date: Tue, 22 Sep 2009 21:07:17 +0000 Subject: [PATCH] silly fix git-svn-id: https://svn.dealii.org/trunk@19498 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/slepc_solver.h | 131 ++++++++++-------- .../lac/slepc_spectral_transformation.h | 27 +++- deal.II/lac/source/slepc_solver.cc | 22 ++- .../source/slepc_spectral_transformation.cc | 16 ++- 4 files changed, 123 insertions(+), 73 deletions(-) diff --git a/deal.II/lac/include/lac/slepc_solver.h b/deal.II/lac/include/lac/slepc_solver.h index c254626d51..fd7381a32e 100755 --- a/deal.II/lac/include/lac/slepc_solver.h +++ b/deal.II/lac/include/lac/slepc_solver.h @@ -1,3 +1,16 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// Author: Toby D. Young, Polish Academy of Sciences, 2008, 2009 +// +// Copyright (C) 2009 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- #ifndef __deal2__slepc_solver_h #define __deal2__slepc_solver_h @@ -20,43 +33,48 @@ DEAL_II_NAMESPACE_OPEN * selected based on flags passed to the eigenvalue problem solver * context. Derived classes set the right flags to set the right * solver. On the other hand, note that: the AdditionalData structure - * is a dummy structure and is there for backward/forward + * is a dummy structure and exisats for backward/forward * compatibility. * * SLEPcWrappers can be implemented in application codes in the * following way: @verbatim - SolverControl solver_control (1000, 1e-10); + SolverControl solver_control (1000, 1e-9); SolverArnoldi system (solver_control, mpi_communicator); - system.solve (A, B, lambda, x, n_eigenvectors); + system.solve (A, B, eigenvalues, eigenvectors, + size_of_spectrum); @endverbatim - * for the generalized eigenvalue problem $Ax=B\lambda x$. See also - * @ref step_36 "step-36" for a hands-on example. + + * for the generalized eigenvalue problem $Ax=B\lambda x$, where the + * variable const unsigned int size_of_spectrum tells + * SLEPc the number of eigenvector/eigenvalue pairs to solve for: See + * also @ref step_36 "step-36" for a hands-on example. * * An alternative implementation to the one above is to use the API * internals directly within the application code. In this way the * calling sequence requires calling several of SolverBase functions * rather than just one. This freedom is intended for use of the * SLEPcWrappers that require a greater handle on the eigenvalue - * problem solver context. See also: + * problem solver context. See also the API of: @verbatim template void SolverBase::solve (const PETScWrappers::MatrixBase &A, - const PETScWrappers::MatrixBase &B, - std::vector &kr, - std::vector &vr, - const unsigned int n_eigenvectors) - {code...} + const PETScWrappers::MatrixBase &B, + std::vector &kr, + std::vector &vr, + const unsigned int n_eigenvectors) + { ... } @endverbatim * as an example on how to do this. * - * See also the @ref PETScWrappers "PETScWrappers", on which the - * SLEPcWrappers depend, for additional explanations. + * For further information and explanations on handling the @ref + * SLEPcWrappers "SLEPcWrappers", see also the @ref PETScWrappers + * "PETScWrappers", on which they depend. * * @ingroup SLEPcWrappers - * @author Toby D. Young and Rickard Armiento 2008, 2009 + * @author Toby D. Young 2008, 2009; and Rickard Armiento 2008 */ namespace SLEPcWrappers { @@ -106,25 +124,28 @@ namespace SLEPcWrappers * eigenvectors, at least twice the * memory size of vr is * being used (and can be more). To - * avoid doing this, use instead - * the calling sequence used here - * is fairly standard: Initialise; - * set up matrices for solving; - * actually solve the system; - * gather the solution(s); and - * reset. + * avoid doing this, the fairly + * standard calling sequence + * excecuted here is used: + * Initialise; Set up matrices for + * solving; Actually solve the + * system; Gather the solution(s); + * and reset. * * Note that the number of * converged eigenvectors can be * larger than the number of * eigenvectors requested; this is * due to a round off error - * (success) of the eigenvalue + * (success) of the eigenproblem * solver context. If this is found - * to be the case, we simply do not + * to be the case we simply do not * bother with more eigenpairs than - * requested but handle that it may - * be more by ignoring any extras. + * requested, but handle that it + * may be more than specified by + * ignoring any extras. By default + * one eigenvector/eigenvalue pair + * is computed. */ template void @@ -134,7 +155,7 @@ namespace SLEPcWrappers const unsigned int n_eigenvectors); /** - * Same as above, but here is a + * Same as above, but here a * composite method for solving the * system $A x=\lambda B x$. */ @@ -156,8 +177,8 @@ namespace SLEPcWrappers set_matrices (const PETScWrappers::MatrixBase &A); /** - * Same as above, but here is a - * composite method for solving the + * Same as above, but here + * initialize solver for the linear * system $A x=\lambda B x$. */ void @@ -208,8 +229,9 @@ namespace SLEPcWrappers /** * Access the solutions for a * solved eigenvector problem, pair - * index solutions, index = 0 - * ... n_converged-1 + * index solutions, + * $\text{index}\,\in\,0\hdots + * \text{n_converged}-1$. */ void get_eigenpair (const unsigned int index, @@ -225,17 +247,17 @@ namespace SLEPcWrappers /** * Retrieve the SLEPc solver object - * used internally. + * that is internally used. */ EPS * get_EPS (); /** - * Access to object that controls - * convergence. + * Access to the object that + * controls convergence. */ - SolverControl &control() const; + SolverControl &control () const; /** * Exceptions. @@ -496,26 +518,21 @@ namespace SLEPcWrappers { unsigned int n_converged; - set_matrices(A); - solve(n_eigenvectors,&n_converged); + set_matrices (A); + solve (n_eigenvectors,&n_converged); if (n_converged > n_eigenvectors) - { - n_converged = n_eigenvectors; - } + n_converged = n_eigenvectors; AssertThrow (vr.size() >= 1, ExcSLEPcWrappersUsageError()); - vr.resize(n_converged, vr.front()); - kr.resize(n_converged); + vr.resize (n_converged, vr.front()); + kr.resize (n_converged); for (unsigned int index=0; index < n_converged; - ++index) - { - get_eigenpair(index, kr[index], vr[index]); - } + +index) + get_eigenpair (index, kr[index], vr[index]); } - template void SolverBase::solve (const PETScWrappers::MatrixBase &A, @@ -526,26 +543,24 @@ namespace SLEPcWrappers { unsigned int n_converged; - set_matrices(A,B); - solve(n_eigenvectors,&n_converged); + set_matrices (A,B); + solve (n_eigenvectors, &n_converged); if (n_converged > n_eigenvectors) - { - n_converged = n_eigenvectors; - } + n_converged = n_eigenvectors; + + // TODO: Fix this properly + if (n_converged < n_eigenvectors) + {} AssertThrow (vr.size() >= 1, ExcSLEPcWrappersUsageError()); - vr.resize(n_converged, vr.front()); - kr.resize(n_converged); + vr.resize (n_converged, vr.front()); + kr.resize (n_converged); for (unsigned int index=0; index < n_converged; ++index) - { - get_eigenpair(index, kr[index], vr[index]); - } + get_eigenpair (index, kr[index], vr[index]); } - - } DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/lac/include/lac/slepc_spectral_transformation.h b/deal.II/lac/include/lac/slepc_spectral_transformation.h index 0b229a3386..347165f6fa 100755 --- a/deal.II/lac/include/lac/slepc_spectral_transformation.h +++ b/deal.II/lac/include/lac/slepc_spectral_transformation.h @@ -1,3 +1,16 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// Author: Toby D. Young, Polish Academy of Sciences, 2009 +// +// Copyright (C) 2009 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- #ifndef __deal2__slepc_spectral_transformation_h #define __deal2__slepc_spectral_transformation_h @@ -262,16 +275,17 @@ namespace SLEPcWrappers public: /** - * Standardized data struct to - * pipe additional data to the - * solver. + * Standardized data struct to pipe + * additional data to the solver. */ struct AdditionalData { /** - * Constructor. Requires two shift parameters + * Constructor. Requires two shift + * parameters */ - AdditionalData (const double shift_parameter = 0, const double antishift_parameter = 0); + AdditionalData (const double shift_parameter = 0, + const double antishift_parameter = 0); /** * Shift and antishift parameter. @@ -284,7 +298,8 @@ namespace SLEPcWrappers /** * Constructor. */ - TransformationCayley (const double shift, const double antishift); + TransformationCayley (const double shift, + const double antishift); protected: diff --git a/deal.II/lac/source/slepc_solver.cc b/deal.II/lac/source/slepc_solver.cc index abde8c09ce..9f042f3c9b 100644 --- a/deal.II/lac/source/slepc_solver.cc +++ b/deal.II/lac/source/slepc_solver.cc @@ -1,3 +1,16 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// Author: Toby D. Young, Polish Academy of Sciences, 2008, 2009 +// +// Copyright (C) 2009 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- #include #include @@ -10,9 +23,6 @@ #ifdef DEAL_II_USE_SLEPC -#if (PETSC_VERSION_MAJOR == 2) && (PETSC_VERSION_MINOR < 2) -#include -#endif #include DEAL_II_NAMESPACE_OPEN @@ -41,7 +51,7 @@ namespace SLEPcWrappers SolverBase::~SolverBase () { - if( solver_data != 0 ) + if (solver_data != 0) solver_data.reset (); } @@ -138,8 +148,8 @@ namespace SLEPcWrappers } void - SolverBase::get_eigenpair (const unsigned int index, - double &kr, + SolverBase::get_eigenpair (const unsigned int index, + double &kr, PETScWrappers::VectorBase &vr) { AssertThrow (solver_data != 0, ExcSLEPcWrappersUsageError()); diff --git a/deal.II/lac/source/slepc_spectral_transformation.cc b/deal.II/lac/source/slepc_spectral_transformation.cc index 6b4839c39f..33a29b0474 100644 --- a/deal.II/lac/source/slepc_spectral_transformation.cc +++ b/deal.II/lac/source/slepc_spectral_transformation.cc @@ -1,3 +1,16 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// Author: Toby D. Young, Polish Academy of Sciences, 2009 +// +// Copyright (C) 2009 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- #include #include @@ -10,9 +23,6 @@ #ifdef DEAL_II_USE_SLEPC -#if (PETSC_VERSION_MAJOR == 2) && (PETSC_VERSION_MINOR < 2) -# include -#endif #include DEAL_II_NAMESPACE_OPEN -- 2.39.5