forked from trilinos/Trilinos
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stratimikos belos prec (trilinos#11222)
* Add Belos as a preconditioner option to Stratimikos. Also clean up RCP usage.
- Loading branch information
Showing
15 changed files
with
889 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Belos Tpetra Preconditioning in Stratimikos | ||
|
||
The adapters in this directory allow a (unpreconditioned) Belos solver using Tpetra linear algebra to be called from a Stratimikos input deck as a preconditioner to another Belos solver. | ||
|
||
This can be used, for example, to apply Belos' polynomial preconditioner using Stratimikos. | ||
It can also be used with the fixed-point solver as the outer solver to perform iterative refinement around an inner solver. | ||
(See example in...) | ||
|
||
|
||
|
||
## Usage | ||
|
||
To enable the Belos-as-preconditioner functionality, simply include the following in your Stratimikos code: | ||
|
||
``` | ||
#include <Stratimikos_BelosTpetraPrecHelpers.hpp> | ||
``` | ||
|
||
Then, after creating your Stratimikos linearSolverBuilder, enable Belos-as-preconditioner as follows: | ||
|
||
``` | ||
// Create Stratimikos::LinearSolverBuilder | ||
Stratimikos::LinearSolverBuilder<Scalar> linearSolverBuilder; | ||
// Register Belos+Tpetra as preconditioner: | ||
// (Note: One could use Tpetra::Operator instead of Tpetra::CrsMatrix.) | ||
Stratimikos::enableBelosPrecTpetra<Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node>>(linearSolverBuilder); | ||
``` | ||
|
||
## Examples | ||
|
||
One can find the following example parameter list inputs in `trilinos/packages/stratimikos/test/` | ||
|
||
+ list1.xml | ||
+ list2.xml | ||
+ list3.xml |
74 changes: 74 additions & 0 deletions
74
packages/stratimikos/adapters/belos/src/tpetra/Stratimikos_BelosTpetraPrecHelpers.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// @HEADER | ||
// *********************************************************************** | ||
// | ||
// Stratimikos: Thyra-based strategies for linear solvers | ||
// Copyright 2012 Sandia Corporation | ||
// | ||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, | ||
// the U.S. Government retains certain rights in this software. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are | ||
// met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// | ||
// 2. Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// | ||
// 3. Neither the name of the Corporation nor the names of the | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY | ||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE | ||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
// | ||
// Questions? Contact Jennifer A. Loe (jloe@sandia.gov) | ||
// | ||
// *********************************************************************** | ||
// @HEADER | ||
#ifndef STRATIMIKOS_BELOS_PREC_TPETRA_HELPERS_HPP | ||
#define STRATIMIKOS_BELOS_PREC_TPETRA_HELPERS_HPP | ||
|
||
#include "Stratimikos_LinearSolverBuilder.hpp" | ||
#include "Thyra_BelosTpetraPreconditionerFactory_decl.hpp" | ||
#include "Thyra_BelosTpetraPreconditionerFactory_def.hpp" | ||
|
||
#include "Teuchos_RCP.hpp" | ||
#include "Teuchos_ParameterList.hpp" | ||
#include "Teuchos_TestForException.hpp" | ||
#include "Teuchos_AbstractFactoryStd.hpp" | ||
|
||
#include <string> | ||
|
||
namespace Stratimikos { | ||
|
||
template <typename MatrixType> | ||
void enableBelosPrecTpetra(LinearSolverBuilder<typename MatrixType::scalar_type>& builder, const std::string& stratName = "BelosPrecTpetra") | ||
{ | ||
const Teuchos::RCP<const Teuchos::ParameterList> precValidParams = Teuchos::sublist(builder.getValidParameters(), "Preconditioner Types"); | ||
|
||
TEUCHOS_TEST_FOR_EXCEPTION(precValidParams->isParameter(stratName), std::logic_error, | ||
"Stratimikos::enableBelosPrecTpetra cannot add \"" + stratName +"\" because it is already included in builder!"); | ||
|
||
typedef typename MatrixType::scalar_type scalar_type; | ||
typedef Thyra::PreconditionerFactoryBase<scalar_type> Base; | ||
typedef Thyra::BelosTpetraPreconditionerFactory<MatrixType> Impl; | ||
|
||
builder.setPreconditioningStrategyFactory(Teuchos::abstractFactoryStd<Base, Impl>(), stratName); | ||
} | ||
|
||
} // namespace Stratimikos | ||
|
||
#endif |
Oops, something went wrong.