From 7a79179fc3f53a1513a286f200dea41e2b583059 Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Fri, 19 Feb 2021 15:32:30 +0100 Subject: [PATCH 01/15] Some smaller changes. --- packages/shylu/shylu_dd/frosch/cmake/ShyLU_DDFROSch_config.h.in | 1 - .../FROSch_AlgebraicOverlappingOperator_def.hpp | 1 + packages/shylu/shylu_dd/frosch/test/Overlap/main.cpp | 2 +- .../shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/main.cpp | 2 +- .../shylu_dd/frosch/test/Thyra_Xpetra_Stokes_HDF5/main.cpp | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/shylu/shylu_dd/frosch/cmake/ShyLU_DDFROSch_config.h.in b/packages/shylu/shylu_dd/frosch/cmake/ShyLU_DDFROSch_config.h.in index ffbe87d4a515..d5bb94e856be 100644 --- a/packages/shylu/shylu_dd/frosch/cmake/ShyLU_DDFROSch_config.h.in +++ b/packages/shylu/shylu_dd/frosch/cmake/ShyLU_DDFROSch_config.h.in @@ -20,5 +20,4 @@ #cmakedefine HAVE_SHYLU_DDFROSCH_ZOLTAN2 - #cmakedefine HAVE_SHYLU_DDFROSCH_HDF5 diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_AlgebraicOverlappingOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_AlgebraicOverlappingOperator_def.hpp index 5e044695eec0..c9728f62a135 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_AlgebraicOverlappingOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_AlgebraicOverlappingOperator_def.hpp @@ -287,6 +287,7 @@ namespace FROSch { template int AlgebraicOverlappingOperator::updateLocalOverlappingMatrices() { + FROSCH_DETAILTIMER_START_LEVELID(updateLocalOverlappingMatricesTime,"AlgebraicOverlappingOperator::updateLocalOverlappingMatrices"); if (this->IsComputed_) { // already computed once and we want to recycle the information. That is why we reset OverlappingMatrix_ to K_, because K_ has been reset at this point this->OverlappingMatrix_ = this->K_; } diff --git a/packages/shylu/shylu_dd/frosch/test/Overlap/main.cpp b/packages/shylu/shylu_dd/frosch/test/Overlap/main.cpp index 5a169a0196d0..d8b8197f5b3f 100644 --- a/packages/shylu/shylu_dd/frosch/test/Overlap/main.cpp +++ b/packages/shylu/shylu_dd/frosch/test/Overlap/main.cpp @@ -264,7 +264,7 @@ int main(int argc, char *argv[]) RepeatedMaps[block] = BuildRepeatedMapNonConst(K[block]->getCrsGraph()); //RCP fancy = fancyOStream(rcpFromRef(cout)); RepeatedMaps[block]->describe(*fancy,VERB_EXTREME); } - Comm->barrier(); if (Comm->getRank()==0) cout << "##############################\n# Assembly Monolythic System #\n##############################\n" << endl; + Comm->barrier(); if (Comm->getRank()==0) cout << "##############################\n# Assembly Monolithic System #\n##############################\n" << endl; RCP > KMonolithic; if (NumberOfBlocks>1) { diff --git a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/main.cpp b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/main.cpp index ae8ede79082e..b3cc1ae3776a 100644 --- a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/main.cpp +++ b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/main.cpp @@ -264,7 +264,7 @@ int main(int argc, char *argv[]) RepeatedMaps[block] = BuildRepeatedMapNonConst(K[block]->getCrsGraph()); //RCP fancy = fancyOStream(rcpFromRef(cout)); RepeatedMaps[block]->describe(*fancy,VERB_EXTREME); } - Comm->barrier(); if (Comm->getRank()==0) cout << "##############################\n# Assembly Monolythic System #\n##############################\n" << endl; + Comm->barrier(); if (Comm->getRank()==0) cout << "##############################\n# Assembly Monolithic System #\n##############################\n" << endl; RCP > KMonolithic; if (NumberOfBlocks>1) { diff --git a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Stokes_HDF5/main.cpp b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Stokes_HDF5/main.cpp index 3050bc298051..48fcee1275e9 100644 --- a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Stokes_HDF5/main.cpp +++ b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Stokes_HDF5/main.cpp @@ -172,7 +172,7 @@ int main(int argc, char *argv[]) RCP parameterList = getParametersFromXmlFile(xmlFile); - Comm->barrier(); if (Comm->getRank()==0) cout << "##############################\n# Import Monolythic System #\n##############################\n" << endl; + Comm->barrier(); if (Comm->getRank()==0) cout << "##############################\n# Import Monolithic System #\n##############################\n" << endl; unsigned Dimension = 2; RCP hDF5IO(new HDF5(*EpetraComm)); From ec9bd893dc37aee529346b5374fae53cc8e9a598 Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Fri, 26 Feb 2021 14:56:01 +0100 Subject: [PATCH 02/15] Amesos2 and Thyra Solvers implemented. --- .../shylu/shylu_dd/frosch/src/CMakeLists.txt | 13 + ...FROSch_LocalPartitionOfUnityBasis_decl.hpp | 4 +- .../FROSch_LocalPartitionOfUnityBasis_def.hpp | 4 +- .../FROSch_Amesos2SolverEpetra_decl.hpp | 133 ++++++++++ .../FROSch_Amesos2SolverEpetra_def.hpp | 152 ++++++++++++ .../FROSch_Amesos2SolverTpetra_decl.hpp | 131 ++++++++++ .../FROSch_Amesos2SolverTpetra_def.hpp | 152 ++++++++++++ .../FROSch_SolverFactory_decl.hpp | 96 ++++++++ .../FROSch_SolverFactory_def.hpp | 108 ++++++++ .../SolverInterfaces/FROSch_Solver_decl.hpp | 161 ++++++++++++ .../SolverInterfaces/FROSch_Solver_def.hpp | 97 ++++++++ .../FROSch_ThyraPreconditioner_decl.hpp | 136 +++++++++++ .../FROSch_ThyraPreconditioner_def.hpp | 127 ++++++++++ .../FROSch_ThyraSolver_decl.hpp | 129 ++++++++++ .../FROSch_ThyraSolver_def.hpp | 129 ++++++++++ .../src/Tools/FROSch_SubdomainSolver_decl.hpp | 4 +- .../src/Tools/FROSch_SubdomainSolver_def.hpp | 4 +- .../shylu_dd/frosch/src/Tools/FROSch_Timers.h | 12 + .../shylu/shylu_dd/frosch/test/CMakeLists.txt | 1 + .../frosch/test/SolverFactory/CMakeLists.txt | 117 +++++++++ .../ParameterLists/CMakeLists.txt | 8 + .../ParameterList_Amesos2_Klu.xml | 4 + ...ditioner_FROSch_OneLevelPreconditioner.xml | 18 ++ .../ParameterList_ThyraSolver_Belos_GMRES.xml | 22 ++ .../frosch/test/SolverFactory/main.cpp | 231 ++++++++++++++++++ 25 files changed, 1985 insertions(+), 8 deletions(-) create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_decl.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_decl.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_def.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_decl.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_def.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_decl.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_def.hpp create mode 100644 packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt create mode 100644 packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/CMakeLists.txt create mode 100644 packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Amesos2_Klu.xml create mode 100644 packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml create mode 100644 packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_ThyraSolver_Belos_GMRES.xml create mode 100644 packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp diff --git a/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt b/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt index 777a880849f6..142a794a3422 100644 --- a/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt +++ b/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt @@ -34,6 +34,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/CoarseSpaces) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/InterfaceSets) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/SchwarzOperators) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/SchwarzPreconditioners) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/SolverInterfaces) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/Tools) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/Adapters) @@ -115,6 +116,18 @@ APPEND_SET(HEADERS SchwarzPreconditioners/FROSch_TwoLevelBlockPreconditioner_def.hpp SchwarzPreconditioners/FROSch_TwoLevelPreconditioner_decl.hpp SchwarzPreconditioners/FROSch_TwoLevelPreconditioner_def.hpp + SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp + SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp + SolverInterfaces/FROSch_Amesos2SolverTpetra_decl.hpp + SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp + SolverInterfaces/FROSch_Solver_decl.hpp + SolverInterfaces/FROSch_Solver_def.hpp + SolverInterfaces/FROSch_SolverFactory_decl.hpp + SolverInterfaces/FROSch_SolverFactory_def.hpp + SolverInterfaces/FROSch_ThyraPreconditioner_decl.hpp + SolverInterfaces/FROSch_ThyraPreconditioner_def.hpp + SolverInterfaces/FROSch_ThyraSolver_decl.hpp + SolverInterfaces/FROSch_ThyraSolver_def.hpp Tools/FROSch_ExtractSubmatrices_decl.hpp Tools/FROSch_ExtractSubmatrices_def.hpp Tools/FROSch_Output.h diff --git a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_LocalPartitionOfUnityBasis_decl.hpp b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_LocalPartitionOfUnityBasis_decl.hpp index 5a0bb8c0dce8..7c1e5b2e2fda 100644 --- a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_LocalPartitionOfUnityBasis_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_LocalPartitionOfUnityBasis_decl.hpp @@ -39,8 +39,8 @@ // ************************************************************************ //@HEADER -#ifndef _FROSCH_PARTITIONOFUNITYBASIS_DECL_hpp -#define _FROSCH_PARTITIONOFUNITYBASIS_DECL_hpp +#ifndef _FROSCH_PARTITIONOFUNITYBASIS_DECL_HPP +#define _FROSCH_PARTITIONOFUNITYBASIS_DECL_HPP #include #include diff --git a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_LocalPartitionOfUnityBasis_def.hpp b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_LocalPartitionOfUnityBasis_def.hpp index 8d76287d3eeb..b842c52cc6a9 100644 --- a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_LocalPartitionOfUnityBasis_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_LocalPartitionOfUnityBasis_def.hpp @@ -39,8 +39,8 @@ // ************************************************************************ //@HEADER -#ifndef _FROSCH_PARTITIONOFUNITYBASIS_DEF_hpp -#define _FROSCH_PARTITIONOFUNITYBASIS_DEF_hpp +#ifndef _FROSCH_PARTITIONOFUNITYBASIS_DEF_HPP +#define _FROSCH_PARTITIONOFUNITYBASIS_DEF_HPP #include diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp new file mode 100644 index 000000000000..5e7520e03e37 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp @@ -0,0 +1,133 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef FROSCH_AMESOS2SOLVEREPETRA_DECL_HPP +#define FROSCH_AMESOS2SOLVEREPETRA_DECL_HPP + +#include + +#include "Amesos2.hpp" + +#include + +// FROSch +#include + + +namespace FROSch { + + using namespace Teuchos; + using namespace Xpetra; + + template + class Amesos2SolverEpetra : public Solver { + + protected: + + // Xpetra + using ConstXMatrixPtr = typename Solver::ConstXMatrixPtr; + + using XMultiVector = typename Solver::XMultiVector; + using XMultiVectorPtr = typename Solver::XMultiVectorPtr; + + using XMultiVectorFactory = typename Solver::XMultiVectorFactory; + + // Epetra + using ECrsMatrix = Epetra_CrsMatrix; + using ECrsMatrixPtr = RCP; + using ConstECrsMatrixPtr = RCP; + + using EMultiVector = Epetra_MultiVector; + using EMultiVectorPtr = RCP; + + // Teuchos + using ParameterListPtr = typename Solver::ParameterListPtr; + + // Amesos2 + using Amesos2SolverEpetraPtr = RCP >; + + public: + + ~Amesos2SolverEpetra(); + + //! Initialize the internal solver + virtual int initialize(); + + //! Compute the internal solver + virtual int compute(); + + /*! + \brief Computes the operator-multivector application. + + Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + \beta \cdot Y\f$. However, the details of operation + vary according to the values of \c alpha and \c beta. Specifically + - if beta == 0, apply() must overwrite \c Y, so that any values in \c Y (including NaNs) are ignored. + - if alpha == 0, apply() may short-circuit the operator, so that any values in \c X (including NaNs) are ignored. + */ + void apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode=NO_TRANS, + SC alpha=ScalarTraits::one(), + SC beta=ScalarTraits::zero()) const; + + int updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize=false); + + protected: + + //! Constructor + Amesos2SolverEpetra(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description); + + mutable XMultiVectorPtr Y_ = null; + + Amesos2SolverEpetraPtr Amesos2Solver_; + + friend class SolverFactory; + }; + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp new file mode 100644 index 000000000000..fe5d08d0f121 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp @@ -0,0 +1,152 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_AMESOS2SOLVEREPETRA_DEF_HPP +#define _FROSCH_AMESOS2SOLVEREPETRA_DEF_HPP + +#include + + +namespace FROSch { + + using namespace std; + using namespace Teuchos; + using namespace Xpetra; + + template + Amesos2SolverEpetra::~Amesos2SolverEpetra() + { + Amesos2Solver_.reset(); + } + + template + int Amesos2SolverEpetra::initialize() + { + FROSCH_TIMER_START_SOLVER(initializeTime,"Amesos2SolverEpetra::initialize"); + this->IsInitialized_ = true; + this->IsComputed_ = false; + Amesos2Solver_->symbolicFactorization(); + return 0; + } + + template + int Amesos2SolverEpetra::compute() + { + FROSCH_TIMER_START_SOLVER(computeTime,"Amesos2SolverEpetra::compute"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::Amesos2SolverEpetra : ERROR: !this->IsInitialized_"); + this->IsComputed_ = true; + Amesos2Solver_->numericFactorization(); + return 0; + } + + template + void Amesos2SolverEpetra::apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode, + SC alpha, + SC beta) const + { + FROSCH_TIMER_START_SOLVER(applyTime,"Amesos2SolverEpetra::apply"); + FROSCH_ASSERT(this->IsComputed_,"FROSch::Amesos2SolverEpetra : ERROR: !this->IsComputed_."); + + const EpetraMultiVectorT * xEpetraMultiVectorX = dynamic_cast *>(&x); + RCP epetraMultiVectorX = xEpetraMultiVectorX->getEpetra_MultiVector(); + + if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),x.getNumVectors()); + EpetraMultiVectorT * xEpetraMultiVectorY = dynamic_cast *>(Y_.get()); + RCP epetraMultiVectorY = xEpetraMultiVectorY->getEpetra_MultiVector(); + + Amesos2Solver_->setX(epetraMultiVectorY); + Amesos2Solver_->setB(epetraMultiVectorX); + + FROSCH_ASSERT(mode==NO_TRANS,"FROSch::Amesos2SolverEpetra : ERROR: mode!=NO_TRANS"); + Amesos2Solver_->solve(); // Was ist, wenn man mit der transponierten Matrix lösen will + + y.update(alpha,*Y_,beta); + } + + template + int Amesos2SolverEpetra::updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize) + { + FROSCH_TIMER_START_SOLVER(updateMatrixTime,"Amesos2SolverEpetra::updateMatrix"); + this->K_ = k; + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverEpetra : ERROR: K_ is null."); + + const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); + const EpetraCrsMatrixT& xEpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); + ECrsMatrixPtr epetraMat = xEpetraMat.getEpetra_CrsMatrixNonConst(); + TEUCHOS_TEST_FOR_EXCEPT(epetraMat.is_null()); + + if (reuseInitialize) { + Amesos2Solver_->setA(epetraMat,Amesos2::SYMBFACT); + } else { + Amesos2Solver_->setA(epetraMat,Amesos2::CLEAN); + } + return 0; + } + + template + Amesos2SolverEpetra::Amesos2SolverEpetra(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description) : + Solver (k,parameterList,description) + { + FROSCH_TIMER_START_SOLVER(Amesos2SolverEpetraTime,"Amesos2SolverEpetra::Amesos2SolverEpetra"); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverEpetra : ERROR: K_ is null."); + + const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); + const EpetraCrsMatrixT& xEpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); + ECrsMatrixPtr epetraMat = xEpetraMat.getEpetra_CrsMatrixNonConst(); + TEUCHOS_TEST_FOR_EXCEPT(epetraMat.is_null()); + + EMultiVectorPtr xTmp; + EMultiVectorPtr bTmp; + + Amesos2Solver_ = Amesos2::create(this->ParameterList_->get("Solver","Mumps"),epetraMat,xTmp,bTmp); + ParameterListPtr amesos2ParameterList = sublist(this->ParameterList_,"Amesos2"); + amesos2ParameterList->setName("Amesos2"); + Amesos2Solver_->setParameters(amesos2ParameterList); + } + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_decl.hpp new file mode 100644 index 000000000000..4a3d96f939bc --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_decl.hpp @@ -0,0 +1,131 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_AMESOS2SOLVERTPETRA_DECL_HPP +#define _FROSCH_AMESOS2SOLVERTPETRA_DECL_HPP + +#include + +#include "Amesos2.hpp" + +// FROSch +#include + + +namespace FROSch { + + using namespace Teuchos; + using namespace Xpetra; + + template + class Amesos2SolverTpetra : public Solver { + + protected: + + // Xpetra + using ConstXMatrixPtr = typename Solver::ConstXMatrixPtr; + + using XMultiVector = typename Solver::XMultiVector; + using XMultiVectorPtr = typename Solver::XMultiVectorPtr; + + using XMultiVectorFactory = typename Solver::XMultiVectorFactory; + + // Tpetra + using TCrsMatrix = Tpetra::CrsMatrix; + using TCrsMatrixPtr = RCP; + using ConstTCrsMatrixPtr = RCP; + + using TMultiVector = Tpetra::MultiVector; + using TMultiVectorPtr = RCP; + + // Teuchos + using ParameterListPtr = typename Solver::ParameterListPtr; + + // Amesos2 + using Amesos2SolverTpetraPtr = RCP >; + + public: + + ~Amesos2SolverTpetra(); + + //! Initialize the internal solver + virtual int initialize(); + + //! Compute the internal solver + virtual int compute(); + + /*! + \brief Computes the operator-multivector application. + + Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + \beta \cdot Y\f$. However, the details of operation + vary according to the values of \c alpha and \c beta. Specifically + - if beta == 0, apply() must overwrite \c Y, so that any values in \c Y (including NaNs) are ignored. + - if alpha == 0, apply() may short-circuit the operator, so that any values in \c X (including NaNs) are ignored. + */ + void apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode=NO_TRANS, + SC alpha=ScalarTraits::one(), + SC beta=ScalarTraits::zero()) const; + + int updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize=false); + + protected: + + //! Constructor + Amesos2SolverTpetra(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description); + + mutable XMultiVectorPtr Y_ = null; + + Amesos2SolverTpetraPtr Amesos2Solver_; + + friend class SolverFactory; + }; + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp new file mode 100644 index 000000000000..a483fa188ca5 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp @@ -0,0 +1,152 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_AMESOS2SOLVERTPETRA_DEF_HPP +#define _FROSCH_AMESOS2SOLVERTPETRA_DEF_HPP + +#include + + +namespace FROSch { + + using namespace std; + using namespace Teuchos; + using namespace Xpetra; + + template + Amesos2SolverTpetra::~Amesos2SolverTpetra() + { + Amesos2Solver_.reset(); + } + + template + int Amesos2SolverTpetra::initialize() + { + FROSCH_TIMER_START_SOLVER(initializeTime,"Amesos2SolverTpetra::initialize"); + this->IsInitialized_ = true; + this->IsComputed_ = false; + Amesos2Solver_->symbolicFactorization(); + return 0; + } + + template + int Amesos2SolverTpetra::compute() + { + FROSCH_TIMER_START_SOLVER(computeTime,"Amesos2SolverTpetra::compute"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::Amesos2SolverTpetra : ERROR: !this->IsInitialized_"); + this->IsComputed_ = true; + Amesos2Solver_->numericFactorization(); + return 0; + } + + template + void Amesos2SolverTpetra::apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode, + SC alpha, + SC beta) const + { + FROSCH_TIMER_START_SOLVER(applyTime,"Amesos2SolverTpetra::apply"); + FROSCH_ASSERT(this->IsComputed_,"FROSch::Amesos2SolverTpetra : ERROR: !this->IsComputed_."); + + const TpetraMultiVector * xTpetraMultiVectorX = dynamic_cast *>(&x); + TMultiVectorPtr tpetraMultiVectorX = xTpetraMultiVectorX->getTpetra_MultiVector(); + + if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),x.getNumVectors()); + const TpetraMultiVector * xTpetraMultiVectorY = dynamic_cast *>(Y_.get()); + TMultiVectorPtr tpetraMultiVectorY = xTpetraMultiVectorY->getTpetra_MultiVector(); + + Amesos2Solver_->setX(tpetraMultiVectorY); + Amesos2Solver_->setB(tpetraMultiVectorX); + + FROSCH_ASSERT(mode==NO_TRANS,"FROSch::Amesos2SolverTpetra : ERROR: mode!=NO_TRANS"); + Amesos2Solver_->solve(); // Was ist, wenn man mit der transponierten Matrix lösen will + + y.update(alpha,*Y_,beta); + } + + template + int Amesos2SolverTpetra::updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize) + { + FROSCH_TIMER_START_SOLVER(updateMatrixTime,"Amesos2SolverTpetra::updateMatrix"); + this->K_ = k; + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverTpetra : ERROR: K_ is null."); + + const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); + const TpetraCrsMatrix& xTpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); + ConstTCrsMatrixPtr tpetraMat = xTpetraMat.getTpetra_CrsMatrix(); + TEUCHOS_TEST_FOR_EXCEPT(tpetraMat.is_null()); + + if (reuseInitialize) { + Amesos2Solver_->setA(tpetraMat,Amesos2::SYMBFACT); + } else { + Amesos2Solver_->setA(tpetraMat,Amesos2::CLEAN); + } + return 0; + } + + template + Amesos2SolverTpetra::Amesos2SolverTpetra(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description) : + Solver (k,parameterList,description) + { + FROSCH_TIMER_START_SOLVER(Amesos2SolverTpetraTime,"Amesos2SolverTpetra::Amesos2SolverTpetra"); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverTpetra : ERROR: K_ is null."); + + const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); + const TpetraCrsMatrix& xTpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); + ConstTCrsMatrixPtr tpetraMat = xTpetraMat.getTpetra_CrsMatrix(); + TEUCHOS_TEST_FOR_EXCEPT(tpetraMat.is_null()); + + TMultiVectorPtr xTmp; + TMultiVectorPtr bTmp; + + Amesos2Solver_ = Amesos2::create(this->ParameterList_->get("Solver","Mumps"),tpetraMat,xTmp,bTmp); + ParameterListPtr amesos2ParameterList = sublist(this->ParameterList_,"Amesos2"); + amesos2ParameterList->setName("Amesos2"); + Amesos2Solver_->setParameters(amesos2ParameterList); + } + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp new file mode 100644 index 000000000000..2d7efa2f7ef3 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp @@ -0,0 +1,96 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_SOLVER_FACTORY_DECL_HPP +#define _FROSCH_SOLVER_FACTORY_DECL_HPP + +#include + +// FROSch +#include +#ifdef HAVE_SHYLU_DDFROSCH_EPETRA +#include +#endif +#include +#if defined(HAVE_SHYLU_DDFROSCH_THYRA) && defined(HAVE_SHYLU_DDFROSCH_STRATIMIKOS) +#include +#include +#endif + + +namespace FROSch { + + using namespace Teuchos; + using namespace Xpetra; + + template + class SolverFactory { + + protected: + + using XMatrixPtr = typename Solver::XMatrixPtr; + using ConstXMatrixPtr = typename Solver::ConstXMatrixPtr; + + using ParameterListPtr = typename Solver::ParameterListPtr; + +#ifdef HAVE_SHYLU_DDFROSCH_EPETRA + using Amesos2SolverEpetraPtr = RCP >; +#endif + using Amesos2SolverTpetraPtr = RCP >; +#if defined(HAVE_SHYLU_DDFROSCH_THYRA) && defined(HAVE_SHYLU_DDFROSCH_STRATIMIKOS) + using ThyraPreconditionerPtr = RCP >; + using ThyraSolverPtr = RCP >; +#endif + using SolverPtr = RCP >; + + public: + + static SolverPtr Build(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description); + }; + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp new file mode 100644 index 000000000000..6588a382c2d5 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp @@ -0,0 +1,108 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_SOLVER_FACTORY_DEF_HPP +#define _FROSCH_SOLVER_FACTORY_DEF_HPP + +#include "FROSch_SolverFactory_decl.hpp" + + +namespace FROSch { + + using namespace Teuchos; + using namespace Xpetra; + + template + typename SolverFactory::SolverPtr SolverFactory::Build(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description) + { + // RCP fancy = fancyOStream(rcpFromRef(cout)); k->describe(*fancy,VERB_EXTREME); + if (!parameterList->get("SolverType","Amesos").compare("Amesos")) { + //return AmesosSolverPtr(new AmesosSolver(k,parameterList,description)); + } else if (!parameterList->get("SolverType","Amesos").compare("Amesos2")) { + if (k->getRowMap()->lib()==UseEpetra) { +#ifdef HAVE_SHYLU_DDFROSCH_EPETRA + return Amesos2SolverEpetraPtr(new Amesos2SolverEpetra(k,parameterList,description)); +#else + ThrowErrorMissingPackage("FROSch::SolverFactory", "Epetra"); +#endif + } else if (k->getRowMap()->lib()==UseTpetra) { + return Amesos2SolverTpetraPtr(new Amesos2SolverTpetra(k,parameterList,description)); + } else { + FROSCH_ASSERT(false, "FROSch::SolverFactory : ERROR: This can't happen. Either use Epetra or Tetra linear algebra stack."); + } + } else if (!parameterList->get("SolverType","Amesos").compare("Ifpack2")) { + //return Ifpack2SolverPtr(new Ifpack2Solver(k,parameterList,description)); + } else if (!parameterList->get("SolverType","Amesos").compare("MueLu")) { + //return MueLuSolverPtr(new MueLuSolver(k,parameterList,description)); + } else if (!parameterList->get("SolverType","Amesos").compare("ThyraPreconditioner")) { +#ifdef HAVE_SHYLU_DDFROSCH_THYRA +#ifdef HAVE_SHYLU_DDFROSCH_STRATIMIKOS + return ThyraPreconditionerPtr(new ThyraPreconditioner(k,parameterList,description)); +#else + ThrowErrorMissingPackage("FROSch::SolverFactory", "Stratimikos"); +#endif +#else + ThrowErrorMissingPackage("FROSch::SolverFactory", "Thyra"); +#endif + } else if (!parameterList->get("SolverType","Amesos").compare("ThyraSolver")) { +#ifdef HAVE_SHYLU_DDFROSCH_THYRA +#ifdef HAVE_SHYLU_DDFROSCH_STRATIMIKOS + return ThyraSolverPtr(new ThyraSolver(k,parameterList,description)); +#else + ThrowErrorMissingPackage("FROSch::SolverFactory", "Stratimikos"); +#endif +#else + ThrowErrorMissingPackage("FROSch::SolverFactory", "Thyra"); +#endif + } else if (!parameterList->get("SolverType","Amesos").compare("TwoLevelBlockPreconditioner")) { + //return TwoLevelBlockPreconditionerSolverPtr(new TwoLevelBlockPreconditionerSolver(k,parameterList,description)); + } else if (!parameterList->get("SolverType","Amesos").compare("TwoLevelPreconditioner")) { + //return TwoLevelPreconditionerSolverPtr(new TwoLevelPreconditionerSolver(k,parameterList,description)); + } else { + FROSCH_ASSERT(false,"SolverType unknown..."); + } + return null; // Can we get rid of this? Without there used to be a warning... + } +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_decl.hpp new file mode 100644 index 000000000000..cd8dda561cae --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_decl.hpp @@ -0,0 +1,161 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_SOLVER_DECL_HPP +#define _FROSCH_SOLVER_DECL_HPP + +#include + +//Teuchos +#include "Teuchos_ParameterList.hpp" +#include "Teuchos_RCP.hpp" + +// FROSch +#include + + +namespace FROSch { + + using namespace Teuchos; + using namespace Xpetra; + + template + class SolverFactory; + + template + class Solver : public Operator { + + protected: + + // Xpetra + using XMap = Map; + using XMapPtr = RCP; + using ConstXMapPtr = RCP; + + using XMatrix = Matrix; + using XMatrixPtr = RCP; + using ConstXMatrixPtr = RCP; + + using XMultiVector = MultiVector; + using XMultiVectorPtr = RCP; + using ConstXMultiVectorPtr = RCP; + + using XMultiVectorFactory = MultiVectorFactory; + + // Teuchos + using ParameterListPtr = RCP; + + public: + + //! Initialize the internal solver + virtual int initialize() = 0; + + //! Compute the internal solver + virtual int compute() = 0; + + /*! + \brief Computes the operator-multivector application. + + Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + \beta \cdot Y\f$. However, the details of operation + vary according to the values of \c alpha and \c beta. Specifically + - if beta == 0, apply() must overwrite \c Y, so that any values in \c Y (including NaNs) are ignored. + - if alpha == 0, apply() may short-circuit the operator, so that any values in \c X (including NaNs) are ignored. + */ + virtual void apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode=NO_TRANS, + SC alpha=ScalarTraits::one(), + SC beta=ScalarTraits::zero()) const = 0; + + //! Get domain map + virtual ConstXMapPtr getDomainMap() const; + + //! Get range map + virtual ConstXMapPtr getRangeMap() const; + + //! Get #IsInitialized_ + bool isInitialized() const; + + //! Get #IsComputed_ + bool isComputed() const; + + virtual int updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize=false) = 0; + + /*! + \brief Computes a residual using the operator + */ + virtual void residual(const XMultiVector & X, + const XMultiVector & B, + XMultiVector& R) const; + + protected: + + //! Constructor + Solver(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description); + + //! Matrix + ConstXMatrixPtr K_; + + //! Parameter list + ParameterListPtr ParameterList_; + + //! Description of the solver + string Description_; + + bool IsInitialized_ = false; + + bool IsComputed_ = false; + + friend class SolverFactory; + }; + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_def.hpp new file mode 100644 index 000000000000..4f148c849842 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_def.hpp @@ -0,0 +1,97 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_SOLVER_DEF_HPP +#define _FROSCH_SOLVER_DEF_HPP + +#include + + +namespace FROSch { + + using namespace Teuchos; + using namespace Xpetra; + + template + typename Solver::ConstXMapPtr Solver::getDomainMap() const + { + return K_->getRangeMap(); + } + + template + typename Solver::ConstXMapPtr Solver::getRangeMap() const + { + return K_->getDomainMap(); + } + + template + bool Solver::isInitialized() const + { + return IsInitialized_; + } + + template + bool Solver::isComputed() const + { + return IsComputed_; + } + + template + void Solver::residual(const XMultiVector & x, + const XMultiVector & b, + XMultiVector& r) const + { + apply(x,r); + r.update(ScalarTraits::one(),b,-ScalarTraits::one()); + } + + template + Solver::Solver(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description) : + K_ (k), + ParameterList_ (parameterList), + Description_ (description) + {} + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_decl.hpp new file mode 100644 index 000000000000..1ca7eccbf093 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_decl.hpp @@ -0,0 +1,136 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_THYRAPRECONDITIONER_DECL_HPP +#define _FROSCH_THYRAPRECONDITIONER_DECL_HPP + +#include + +#include "Stratimikos_DefaultLinearSolverBuilder.hpp" + +// FROSch +#include + + +namespace FROSch { + + using namespace Teuchos; + using namespace Thyra; + using namespace Xpetra; + + template + class ThyraPreconditioner : public Solver { + + protected: + + // Xpetra + using XMatrix = typename Solver::XMatrix; + using XMatrixPtr = typename Solver::XMatrixPtr; + using ConstXMatrixPtr = typename Solver::ConstXMatrixPtr; + + using XMultiVector = typename Solver::XMultiVector; + using XMultiVectorPtr = typename Solver::XMultiVectorPtr; + using ConstXMultiVectorPtr = typename Solver::ConstXMultiVectorPtr; + + using XMultiVectorFactory = typename Solver::XMultiVectorFactory; + + // Tpetra + using TCrsMatrix = Tpetra::CrsMatrix; + using TCrsMatrixPtr = RCP; + using ConstTCrsMatrixPtr = RCP; + + using TMultiVector = Tpetra::MultiVector; + using TMultiVectorPtr = RCP; + + // Teuchos + using ParameterListPtr = typename Solver::ParameterListPtr; + + // Thyra + using MultiVectorBasePtr = RCP >; + using ConstMultiVectorBasePtr = RCP >; + using PreconditionerBasePtr = RCP >; + using PreconditionerFactoryBasePtr = RCP >; + + public: + + //! Initialize the internal solver + virtual int initialize(); + + //! Compute the internal solver + virtual int compute(); + + /*! + \brief Computes the operator-multivector application. + + Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + \beta \cdot Y\f$. However, the details of operation + vary according to the values of \c alpha and \c beta. Specifically + - if beta == 0, apply() must overwrite \c Y, so that any values in \c Y (including NaNs) are ignored. + - if alpha == 0, apply() may short-circuit the operator, so that any values in \c X (including NaNs) are ignored. + */ + void apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode=NO_TRANS, + SC alpha=ScalarTraits::one(), + SC beta=ScalarTraits::zero()) const; + + int updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize=false); + + protected: + + //! Constructor + ThyraPreconditioner(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description); + + // mutable MultiVectorBasePtr Y_ = null; + + PreconditionerBasePtr ThyraPreconditioner_; + + friend class SolverFactory; + }; + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_def.hpp new file mode 100644 index 000000000000..511aca474669 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_def.hpp @@ -0,0 +1,127 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_THYRAPRECONDITIONER_DEF_HPP +#define _FROSCH_THYRAPRECONDITIONER_DEF_HPP + +#include + + +namespace FROSch { + + using namespace Stratimikos; + using namespace Teuchos; + using namespace Thyra; + using namespace Xpetra; + + template + int ThyraPreconditioner::initialize() + { + FROSCH_TIMER_START_SOLVER(initializeTime,"ThyraPreconditioner::initialize"); + this->IsInitialized_ = true; + this->IsComputed_ = false; + return 0; + } + + template + int ThyraPreconditioner::compute() + { + FROSCH_TIMER_START_SOLVER(computeTime,"ThyraPreconditioner::compute"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::ThyraPreconditioner : ERROR: !this->IsInitialized_"); + this->IsComputed_ = true; + return 0; + } + + template + void ThyraPreconditioner::apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode, + SC alpha, + SC beta) const + { + FROSCH_TIMER_START_SOLVER(applyTime,"ThyraPreconditioner::apply"); + FROSCH_ASSERT(this->IsComputed_,"FROSch::ThyraPreconditioner : ERROR: !this->IsComputed_."); + + ConstMultiVectorBasePtr xThyra = ThyraUtils::toThyraMultiVector(rcpFromRef(x)); + MultiVectorBasePtr yThyra = rcp_const_cast >(ThyraUtils::toThyraMultiVector(rcpFromRef(y))); + + EOpTransp tMode = NOTRANS; + switch (mode) { + case Teuchos::NO_TRANS: tMode = Thyra::NOTRANS; break; + case Teuchos::TRANS: tMode = Thyra::TRANS; break; + case Teuchos::CONJ_TRANS: tMode = Thyra::CONJTRANS; break; + default: FROSCH_ASSERT(false,"FROSch::ThyraPreconditioner : ERROR: mode unknown."); + } + + ThyraPreconditioner_->getUnspecifiedPrecOp()->apply(tMode,*xThyra,yThyra.ptr(),alpha,beta); + } + + template + int ThyraPreconditioner::updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize) + { + FROSCH_ASSERT(false,"FROSch::ThyraPreconditioner : ERROR: updateMatrix() is not implemented for the ThyraPreconditioner yet."); + return 0; + } + + template + ThyraPreconditioner::ThyraPreconditioner(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description) : + Solver (k,parameterList,description) + { + FROSCH_TIMER_START_SOLVER(ThyraPreconditionerTime,"ThyraPreconditioner::ThyraPreconditioner"); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::ThyraPreconditioner : ERROR: K_ is null."); + + const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); + RCP > thyraOp = ThyraUtils::toThyra(crsOp.getCrsMatrix()); + + DefaultLinearSolverBuilder linearSolverBuilder; + enableFROSch(linearSolverBuilder); + linearSolverBuilder.setParameterList(sublist(this->ParameterList_,"ThyraPreconditioner")); + + PreconditionerFactoryBasePtr thyraFactory = linearSolverBuilder.createPreconditioningStrategy(""); + ThyraPreconditioner_ = prec(*thyraFactory,thyraOp); + } + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_decl.hpp new file mode 100644 index 000000000000..5e4d19b37ac9 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_decl.hpp @@ -0,0 +1,129 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_THYRASOLVER_DECL_HPP +#define _FROSCH_THYRASOLVER_DECL_HPP + +#include + +#include "Stratimikos_DefaultLinearSolverBuilder.hpp" + +// FROSch +#include + + +namespace FROSch { + + using namespace Teuchos; + using namespace Thyra; + using namespace Xpetra; + + template + class ThyraSolver : public Solver { + + protected: + + // Xpetra + using XMatrix = typename Solver::XMatrix; + using XMatrixPtr = typename Solver::XMatrixPtr; + using ConstXMatrixPtr = typename Solver::ConstXMatrixPtr; + + using XMultiVector = typename Solver::XMultiVector; + using XMultiVectorPtr = typename Solver::XMultiVectorPtr; + using ConstXMultiVectorPtr = typename Solver::ConstXMultiVectorPtr; + + using XMultiVectorFactory = typename Solver::XMultiVectorFactory; + + // Teuchos + using ParameterListPtr = typename Solver::ParameterListPtr; + + // Thyra + using MultiVectorBasePtr = RCP >; + using ConstMultiVectorBasePtr = RCP >; + using LinearOpWithSolveBasePtr = RCP >; + using LinearOpWithSolveFactoryBasePtr = RCP >; + + public: + + //! Initialize the internal solver + virtual int initialize(); + + //! Compute the internal solver + virtual int compute(); + + /*! + \brief Computes the operator-multivector application. + + Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + \beta \cdot Y\f$. However, the details of operation + vary according to the values of \c alpha and \c beta. Specifically + - if beta == 0, apply() must overwrite \c Y, so that any values in \c Y (including NaNs) are ignored. + - if alpha == 0, apply() may short-circuit the operator, so that any values in \c X (including NaNs) are ignored. + */ + void apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode=NO_TRANS, + SC alpha=ScalarTraits::one(), + SC beta=ScalarTraits::zero()) const; + + int updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize=false); + + protected: + + //! Constructor + ThyraSolver(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description); + + mutable XMultiVectorPtr YX_ = null; + mutable MultiVectorBasePtr YT_ = null; + + LinearOpWithSolveBasePtr ThyraSolver_; + + friend class SolverFactory; + }; + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_def.hpp new file mode 100644 index 000000000000..ad0356095c7f --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_def.hpp @@ -0,0 +1,129 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_THYRASOLVER_DEF_HPP +#define _FROSCH_THYRASOLVER_DEF_HPP + +#include + + +namespace FROSch { + + using namespace Stratimikos; + using namespace Teuchos; + using namespace Thyra; + using namespace Xpetra; + + template + int ThyraSolver::initialize() + { + FROSCH_TIMER_START_SOLVER(initializeTime,"ThyraSolver::initialize"); + this->IsInitialized_ = true; + this->IsComputed_ = false; + return 0; + } + + template + int ThyraSolver::compute() + { + FROSCH_TIMER_START_SOLVER(computeTime,"ThyraSolver::compute"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::ThyraSolver : ERROR: !this->IsInitialized_"); + this->IsComputed_ = true; + return 0; + } + + template + void ThyraSolver::apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode, + SC alpha, + SC beta) const + { + FROSCH_TIMER_START_SOLVER(applyTime,"ThyraSolver::apply"); + FROSCH_ASSERT(this->IsComputed_,"FROSch::ThyraSolver : ERROR: !this->IsComputed_."); + + ConstMultiVectorBasePtr xThyra = ThyraUtils::toThyraMultiVector(rcpFromRef(x)); + if (YX_.is_null()) YX_ = XMultiVectorFactory::Build(y.getMap(),y.getNumVectors()); + if (YT_.is_null()) YT_ = rcp_const_cast >(ThyraUtils::toThyraMultiVector(YX_)); + + EOpTransp tMode = NOTRANS; + switch (mode) { + case Teuchos::NO_TRANS: tMode = Thyra::NOTRANS; break; + case Teuchos::TRANS: tMode = Thyra::TRANS; break; + case Teuchos::CONJ_TRANS: tMode = Thyra::CONJTRANS; break; + default: FROSCH_ASSERT(false,"FROSch::ThyraPreconditionerTpetra : ERROR: mode unknown."); + } + + SolveStatus status = solve(*ThyraSolver_,tMode,*xThyra,YT_.ptr()); + y.update(alpha,*YX_,beta); + } + + template + int ThyraSolver::updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize) + { + FROSCH_ASSERT(false,"FROSch::ThyraSolver : ERROR: updateMatrix() is not implemented for the ThyraSolver yet."); + return 0; + } + + template + ThyraSolver::ThyraSolver(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description) : + Solver (k,parameterList,description) + { + FROSCH_TIMER_START_SOLVER(ThyraSolverTime,"ThyraSolver::ThyraSolver"); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::ThyraSolver : ERROR: K_ is null."); + + const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); + RCP > thyraOp = ThyraUtils::toThyra(crsOp.getCrsMatrix()); + + DefaultLinearSolverBuilder linearSolverBuilder; + enableFROSch(linearSolverBuilder); + linearSolverBuilder.setParameterList(sublist(this->ParameterList_,"ThyraSolver")); + + LinearOpWithSolveFactoryBasePtr thyraFactory = linearSolverBuilder.createLinearSolveStrategy(""); + ThyraSolver_ = linearOpWithSolve(*thyraFactory,thyraOp); + } + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_decl.hpp b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_decl.hpp index c2419d0bfea9..7f726e7c282b 100644 --- a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_decl.hpp @@ -39,8 +39,8 @@ // ************************************************************************ //@HEADER -#ifndef _FROSCH_SUBDOMAINSOLVER_DECL_hpp -#define _FROSCH_SUBDOMAINSOLVER_DECL_hpp +#ifndef _FROSCH_SUBDOMAINSOLVER_DECL_HPP +#define _FROSCH_SUBDOMAINSOLVER_DECL_HPP #include diff --git a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_def.hpp b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_def.hpp index b61c978a7cd5..d2934833e31b 100644 --- a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_def.hpp @@ -39,8 +39,8 @@ // ************************************************************************ //@HEADER -#ifndef _FROSCH_SUBDOMAINSOLVER_DEF_hpp -#define _FROSCH_SUBDOMAINSOLVER_DEF_hpp +#ifndef _FROSCH_SUBDOMAINSOLVER_DEF_HPP +#define _FROSCH_SUBDOMAINSOLVER_DEF_HPP #include diff --git a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Timers.h b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Timers.h index 7644784bfacf..0b7a5b92e34e 100644 --- a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Timers.h +++ b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Timers.h @@ -75,6 +75,10 @@ #define FROSCH_DETAILTIMER_STOP(A) FROSCH_TIMER_STOP(A); #endif + #ifndef FROSCH_TIMER_START_SOLVER + #define FROSCH_TIMER_START_SOLVER(A,S) RCP A = rcp(new TimeMonitor(*TimeMonitor::getNewTimer(std::string("FROSch: ") + std::string(S) + " (" + this->Description_ + std::string(")")))); + #endif + #ifndef FROSCH_TIMER_START_SUBDOMAINSOLVER #define FROSCH_TIMER_START_SUBDOMAINSOLVER(A,S) RCP A = rcp(new TimeMonitor(*TimeMonitor::getNewTimer(std::string("FROSch: ") + std::string(S) + " (" + this->Description_ + std::string(")")))); #endif @@ -103,6 +107,10 @@ #define FROSCH_DETAILTIMER_STOP(A) #endif + #ifndef FROSCH_TIMER_START_SOLVER + #define FROSCH_TIMER_START_SOLVER(A,S) + #endif + #ifndef FROSCH_TIMER_START_SUBDOMAINSOLVER #define FROSCH_TIMER_START_SUBDOMAINSOLVER(A,S) #endif @@ -131,6 +139,10 @@ #define FROSCH_DETAILTIMER_STOP(A) #endif + #ifndef FROSCH_TIMER_START_SOLVER + #define FROSCH_TIMER_START_SOLVER(A,S) + #endif + #ifndef FROSCH_TIMER_START_SUBDOMAINSOLVER #define FROSCH_TIMER_START_SUBDOMAINSOLVER(A,S) #endif diff --git a/packages/shylu/shylu_dd/frosch/test/CMakeLists.txt b/packages/shylu/shylu_dd/frosch/test/CMakeLists.txt index b4489414ee64..cb5901acc0d6 100644 --- a/packages/shylu/shylu_dd/frosch/test/CMakeLists.txt +++ b/packages/shylu/shylu_dd/frosch/test/CMakeLists.txt @@ -3,6 +3,7 @@ ADD_SUBDIRECTORIES( InterfacePartitionOfUnity InterfaceSets LocalPartitionOfUnityBasis + SolverFactory ) IF(ShyLU_DDFROSch_ENABLE_Belos AND Kokkos_ENABLE_SERIAL AND ShyLU_DDFROSch_ENABLE_Stratimikos AND ShyLU_DDFROSch_ENABLE_Thyra) diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt b/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt new file mode 100644 index 000000000000..023ecb336c96 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt @@ -0,0 +1,117 @@ +TRIBITS_ADD_EXECUTABLE( +solverfactory +SOURCES main.cpp +) + +ADD_SUBDIRECTORIES( +ParameterLists +) + +############### +# Amesos2 Klu # +############### +## Epetra +IF(HAVE_SHYLU_DDFROSCH_EPETRA AND NOT Tpetra_DefaultNode STREQUAL "Kokkos::Compat::KokkosCudaWrapperNode") +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_klu_DIM2_EPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_Amesos2_Klu.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 1 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_klu_DIM3_EPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_Amesos2_Klu.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 1 +) +ENDIF() +##Tpetra +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_klu_DIM2_TPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_Amesos2_Klu.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 1 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_klu_DIM3_TPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_Amesos2_Klu.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 1 +) + +##################################################### +# ThyraPreconditioner FROSch OneLevelPreconditioner # +##################################################### +## Epetra +IF(HAVE_SHYLU_DDFROSCH_EPETRA AND NOT Tpetra_DefaultNode STREQUAL "Kokkos::Compat::KokkosCudaWrapperNode") +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_thyrapreconditioner_frosch_onelevelpreconditionerDIM2_EPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 4 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_thyrapreconditioner_frosch_onelevelpreconditionerDIM3_EPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 8 +) +ENDIF() +##Tpetra +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_thyrapreconditioner_frosch_onelevelpreconditionerDIM2_TPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 4 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_thyrapreconditioner_frosch_onelevelpreconditionerDIM3_TPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 8 +) + + +########################### +# ThyraSolver Belos GMRES # +########################### +## Epetra +IF(HAVE_SHYLU_DDFROSCH_EPETRA AND NOT Tpetra_DefaultNode STREQUAL "Kokkos::Compat::KokkosCudaWrapperNode") +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_thyrasolver_belos_gmres_DIM2_EPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_ThyraSolver_Belos_GMRES.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 4 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_thyrasolver_belos_gmres_DIM3_EPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_ThyraSolver_Belos_GMRES.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 8 +) +ENDIF() +##Tpetra +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_thyrasolver_belos_gmres_DIM2_TPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_ThyraSolver_Belos_GMRES.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 4 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_thyrasolver_belos_gmres_DIM3_TPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_ThyraSolver_Belos_GMRES.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 8 +) diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/CMakeLists.txt b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/CMakeLists.txt new file mode 100644 index 000000000000..3485856406a9 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/CMakeLists.txt @@ -0,0 +1,8 @@ +TRIBITS_COPY_FILES_TO_BINARY_DIR(SolverFactoryCopyFiles +DEST_FILES ParameterList_Amesos2_Klu.xml + ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml + ParameterList_ThyraSolver_Belos_GMRES.xml +SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} +DEST_DIR ${CMAKE_CURRENT_BINARY_DIR} +EXEDEPS solverfactory +) diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Amesos2_Klu.xml b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Amesos2_Klu.xml new file mode 100644 index 000000000000..122fa5b85963 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Amesos2_Klu.xml @@ -0,0 +1,4 @@ + + + + diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml new file mode 100644 index 000000000000..d27f0dd1ac15 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_ThyraSolver_Belos_GMRES.xml b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_ThyraSolver_Belos_GMRES.xml new file mode 100644 index 000000000000..019dc03e7331 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_ThyraSolver_Belos_GMRES.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp b/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp new file mode 100644 index 000000000000..efc7c6982407 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp @@ -0,0 +1,231 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#include + +#include + +#include +#include +#include +#include + +// Galeri::Xpetra +#include "Galeri_XpetraProblemFactory.hpp" +#include "Galeri_XpetraMatrixTypes.hpp" +#include "Galeri_XpetraParameters.hpp" +#include "Galeri_XpetraUtils.hpp" +#include "Galeri_XpetraMaps.hpp" + +// Thyra includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_SHYLU_DDFROSCH_EPETRA +#include +#endif +#include +#include + +// Stratimikos includes +#include + +#include + +// Xpetra include +#include +#include +#ifdef HAVE_SHYLU_DDFROSCH_EPETRA +#include +#endif +#include + +// FROSch thyra includes +#include + + +using UN = unsigned; +using SC = double; +using LO = int; +using GO = FROSch::DefaultGlobalOrdinal; +using NO = KokkosClassic::DefaultNode::DefaultNodeType; + +using namespace std; +using namespace Teuchos; +using namespace Xpetra; +using namespace FROSch; +using namespace Thyra; + +int main(int argc, char *argv[]) +{ + oblackholestream blackhole; + GlobalMPISession mpiSession(&argc,&argv,&blackhole); + + RCP > CommWorld = DefaultPlatform::getDefaultPlatform().getComm(); + + CommandLineProcessor My_CLP; + + RCP out = VerboseObjectBase::getDefaultOStream(); + + int M = 4; + My_CLP.setOption("M",&M,"H / h."); + int Dimension = 2; + My_CLP.setOption("DIM",&Dimension,"Dimension."); + int Overlap = 0; + My_CLP.setOption("O",&Overlap,"Overlap."); + string xmlFile = "ParameterList.xml"; + My_CLP.setOption("PLIST",&xmlFile,"File name of the parameter list."); + bool useepetra = false; + My_CLP.setOption("USEEPETRA","USETPETRA",&useepetra,"Use Epetra infrastructure for the linear algebra."); + + My_CLP.recogniseAllOptions(true); + My_CLP.throwExceptions(false); + CommandLineProcessor::EParseCommandLineReturn parseReturn = My_CLP.parse(argc,argv); + if (parseReturn == CommandLineProcessor::PARSE_HELP_PRINTED) { + return(EXIT_SUCCESS); + } + + CommWorld->barrier(); + RCP stackedTimer = rcp(new StackedTimer("FROSch Solver Factory Test")); + TimeMonitor::setStackedTimer(stackedTimer); + + int N = 0; + int color=1; + if (Dimension == 2) { + N = (int) (pow(CommWorld->getSize(),1/2.) + 100*numeric_limits::epsilon()); // 1/H + if (CommWorld->getRank()getSize(),1/3.) + 100*numeric_limits::epsilon()); // 1/H + if (CommWorld->getRank() > Comm = CommWorld->split(color,CommWorld->getRank()); + + if (color==0) { + + RCP parameterList = getParametersFromXmlFile(xmlFile); + + Comm->barrier(); + if (Comm->getRank()==0) { + cout << "##################\n# Parameter List #\n##################" << endl; + parameterList->print(cout); + cout << endl; + } + + Comm->barrier(); if (Comm->getRank()==0) cout << "##############################\n# Assembly Laplacian #\n##############################\n" << endl; + + ParameterList GaleriList; + GaleriList.set("nx", GO(N*M)); + GaleriList.set("ny", GO(N*M)); + GaleriList.set("nz", GO(N*M)); + GaleriList.set("mx", GO(N)); + GaleriList.set("my", GO(N)); + GaleriList.set("mz", GO(N)); + + RCP > UniqueNodeMap; + RCP > UniqueMap; + RCP > Coordinates; + RCP > K; + if (Dimension==2) { + UniqueNodeMap = Galeri::Xpetra::CreateMap(xpetraLib,"Cartesian2D",Comm,GaleriList); // RCP fancy = fancyOStream(rcpFromRef(cout)); nodeMap->describe(*fancy,VERB_EXTREME); + UniqueMap = Xpetra::MapFactory::Build(UniqueNodeMap,2); + Coordinates = Galeri::Xpetra::Utils::CreateCartesianCoordinates,MultiVector >("2D",UniqueMap,GaleriList); + RCP,CrsMatrixWrap,MultiVector > > Problem = Galeri::Xpetra::BuildProblem,CrsMatrixWrap,MultiVector >("Elasticity2D",UniqueMap,GaleriList); + K = Problem->BuildMatrix(); + } else if (Dimension==3) { + UniqueNodeMap = Galeri::Xpetra::CreateMap(xpetraLib,"Cartesian3D",Comm,GaleriList); // RCP fancy = fancyOStream(rcpFromRef(cout)); nodeMap->describe(*fancy,VERB_EXTREME); + UniqueMap = Xpetra::MapFactory::Build(UniqueNodeMap,3); + Coordinates = Galeri::Xpetra::Utils::CreateCartesianCoordinates,MultiVector >("3D",UniqueMap,GaleriList); + RCP,CrsMatrixWrap,MultiVector > > Problem = Galeri::Xpetra::BuildProblem,CrsMatrixWrap,MultiVector >("Elasticity3D",UniqueMap,GaleriList); + K = Problem->BuildMatrix(); + } + + RCP > xSolution = MultiVectorFactory::Build(UniqueMap,1); + RCP > xRightHandSide = MultiVectorFactory::Build(UniqueMap,1); + + xSolution->putScalar(ScalarTraits::zero()); + xRightHandSide->putScalar(ScalarTraits::one()); + + Comm->barrier(); if (Comm->getRank()==0) cout << "###########################\n# Construct Solver #\n###########################" << endl; + + RCP > FROSchSolverInterface = SolverFactory::Build(K,parameterList,"Solver Tester"); + + FROSchSolverInterface->initialize(); + + FROSchSolverInterface->compute(); + + Comm->barrier(); if (Comm->getRank()==0) cout << "\n#########\n# Solve #\n#########" << endl; + + FROSchSolverInterface->apply(*xRightHandSide,*xSolution); + + Comm->barrier(); if (Comm->getRank()==0) cout << "\n#############\n# Finished! #\n#############" << endl; + } + + CommWorld->barrier(); + stackedTimer->stop("Thyra Elasticity Test"); + StackedTimer::OutputOptions options; + options.output_fraction = options.output_histogram = options.output_minmax = true; + stackedTimer->report(*out,CommWorld,options); + + return(EXIT_SUCCESS); + +} From f9e32e2aa602d50b8db9f06715e42015d1d9968a Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Fri, 26 Feb 2021 18:08:30 +0100 Subject: [PATCH 03/15] Belos solver. --- .../shylu/shylu_dd/frosch/src/CMakeLists.txt | 2 + .../FROSch_BelosSolverEpetra_decl.hpp | 143 ++++++++++++++++++ .../FROSch_BelosSolverEpetra_def.hpp | 142 +++++++++++++++++ .../FROSch_BelosSolverTpetra_decl.hpp | 141 +++++++++++++++++ .../FROSch_BelosSolverTpetra_def.hpp | 142 +++++++++++++++++ .../FROSch_SolverFactory_decl.hpp | 12 ++ .../FROSch_SolverFactory_def.hpp | 42 +++-- .../frosch/test/SolverFactory/CMakeLists.txt | 44 +++++- .../ParameterList_Belos_GMRES.xml | 4 + .../frosch/test/SolverFactory/main.cpp | 2 +- 10 files changed, 656 insertions(+), 18 deletions(-) create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_decl.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_decl.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp create mode 100644 packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Belos_GMRES.xml diff --git a/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt b/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt index 142a794a3422..afc918414a63 100644 --- a/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt +++ b/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt @@ -120,6 +120,8 @@ APPEND_SET(HEADERS SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp SolverInterfaces/FROSch_Amesos2SolverTpetra_decl.hpp SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp + SolverInterfaces/FROSch_BelosSolverEpetra_decl.hpp + SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp SolverInterfaces/FROSch_Solver_decl.hpp SolverInterfaces/FROSch_Solver_def.hpp SolverInterfaces/FROSch_SolverFactory_decl.hpp diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_decl.hpp new file mode 100644 index 000000000000..292b1b1221e9 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_decl.hpp @@ -0,0 +1,143 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_BELOSSOLVEREPETRA_DECL_HPP +#define _FROSCH_BELOSSOLVEREPETRA_DECL_HPP + +#include + +#include + +#include +#include +#include +#include + +// FROSch +#include + + +namespace FROSch { + + using namespace Teuchos; + using namespace Xpetra; + + template + class BelosSolverEpetra : public Solver { + + protected: + + // Xpetra + using ConstXMatrixPtr = typename Solver::ConstXMatrixPtr; + + using XMultiVector = typename Solver::XMultiVector; + using XMultiVectorPtr = typename Solver::XMultiVectorPtr; + + using XMultiVectorFactory = typename Solver::XMultiVectorFactory; + + // Epetra + using EOperator = Epetra_Operator; + + using ECrsMatrix = Epetra_CrsMatrix; + using ECrsMatrixPtr = RCP; + using ConstECrsMatrixPtr = RCP; + + using EMultiVector = Epetra_MultiVector; + using EMultiVectorPtr = RCP; + + // Teuchos + using ParameterListPtr = typename Solver::ParameterListPtr; + + // Belos + using BelosLinearProblem = Belos::LinearProblem; + using BelosLinearProblemPtr = RCP; + using BelosSolverFactory = Belos::SolverFactory; + using BelosSolverFactoryPtr = RCP; + using BelosSolverManager = Belos::SolverManager; + using BelosSolverManagerPtr = RCP; + + public: + + //! Initialize the internal solver + virtual int initialize(); + + //! Compute the internal solver + virtual int compute(); + + /*! + \brief Computes the operator-multivector application. + + Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + \beta \cdot Y\f$. However, the details of operation + vary according to the values of \c alpha and \c beta. Specifically + - if beta == 0, apply() must overwrite \c Y, so that any values in \c Y (including NaNs) are ignored. + - if alpha == 0, apply() may short-circuit the operator, so that any values in \c X (including NaNs) are ignored. + */ + void apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode=NO_TRANS, + SC alpha=ScalarTraits::one(), + SC beta=ScalarTraits::zero()) const; + + int updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize=false); + + protected: + + //! Constructor + BelosSolverEpetra(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description); + + mutable XMultiVectorPtr Y_ = null; + + BelosLinearProblemPtr BelosLinearProblem_; + + BelosSolverManagerPtr BelosSolver_; + + friend class SolverFactory; + }; + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp new file mode 100644 index 000000000000..806fea31d24c --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp @@ -0,0 +1,142 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_BELOSSOLVEREPETRA_DEF_HPP +#define _FROSCH_BELOSSOLVEREPETRA_DEF_HPP + +#include + + +namespace FROSch { + + using namespace std; + using namespace Teuchos; + using namespace Xpetra; + + template + int BelosSolverEpetra::initialize() + { + FROSCH_TIMER_START_SOLVER(initializeTime,"BelosSolverEpetra::initialize"); + this->IsInitialized_ = true; + this->IsComputed_ = false; + return 0; + } + + template + int BelosSolverEpetra::compute() + { + FROSCH_TIMER_START_SOLVER(computeTime,"BelosSolverEpetra::compute"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::BelosSolverEpetra : ERROR: !this->IsInitialized_"); + this->IsComputed_ = true; + return 0; + } + + template + void BelosSolverEpetra::apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode, + SC alpha, + SC beta) const + { + FROSCH_TIMER_START_SOLVER(applyTime,"BelosSolverEpetra::apply"); + FROSCH_ASSERT(this->IsComputed_,"FROSch::BelosSolverEpetra : ERROR: !this->IsComputed_."); + + const EpetraMultiVectorT * xEpetraMultiVectorX = dynamic_cast *>(&x); + RCP epetraMultiVectorX = xEpetraMultiVectorX->getEpetra_MultiVector(); + + if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),x.getNumVectors()); + EpetraMultiVectorT * xEpetraMultiVectorY = dynamic_cast *>(Y_.get()); + RCP epetraMultiVectorY = xEpetraMultiVectorY->getEpetra_MultiVector(); + + BelosLinearProblem_->setProblem(epetraMultiVectorY,epetraMultiVectorX); + BelosSolver_->solve(); + + y.update(alpha,*Y_,beta); + } + + template + int BelosSolverEpetra::updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize) + { + FROSCH_TIMER_START_SOLVER(updateMatrixTime,"BelosSolverEpetra::updateMatrix"); + this->K_ = k; + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::BelosSolverEpetra : ERROR: K_ is null."); + + const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); + const EpetraCrsMatrixT& xEpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); + ECrsMatrixPtr epetraMat = xEpetraMat.getEpetra_CrsMatrixNonConst(); + TEUCHOS_TEST_FOR_EXCEPT(epetraMat.is_null()); + + BelosLinearProblem_->setOperator(epetraMat); + + return 0; + } + + template + BelosSolverEpetra::BelosSolverEpetra(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description) : + Solver (k,parameterList,description) + { + FROSCH_TIMER_START_SOLVER(BelosSolverEpetraTime,"BelosSolverEpetra::BelosSolverEpetra"); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::BelosSolverEpetra : ERROR: K_ is null."); + + const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); + const EpetraCrsMatrixT& xEpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); + ECrsMatrixPtr epetraMat = xEpetraMat.getEpetra_CrsMatrixNonConst(); + TEUCHOS_TEST_FOR_EXCEPT(epetraMat.is_null()); + + EMultiVectorPtr xTmp; + EMultiVectorPtr bTmp; + + BelosLinearProblem_.reset(new BelosLinearProblem(epetraMat,xTmp,bTmp)); + + BelosSolverFactory belosFactory; + ParameterListPtr solverParameterList = sublist(this->ParameterList_,"Belos"); + + BelosSolver_ = belosFactory.create(solverParameterList->get("Solver","GMRES"),sublist(solverParameterList,solverParameterList->get("Solver","GMRES"))); + + BelosSolver_->setProblem(BelosLinearProblem_); + } + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_decl.hpp new file mode 100644 index 000000000000..191ef55f3ad1 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_decl.hpp @@ -0,0 +1,141 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_BELOSSOLVERTPETRA_DECL_HPP +#define _FROSCH_BELOSSOLVERTPETRA_DECL_HPP + +#include + +#include +#include +#include +#include + +// FROSch +#include + + +namespace FROSch { + + using namespace Teuchos; + using namespace Xpetra; + + template + class BelosSolverTpetra : public Solver { + + protected: + + // Xpetra + using ConstXMatrixPtr = typename Solver::ConstXMatrixPtr; + + using XMultiVector = typename Solver::XMultiVector; + using XMultiVectorPtr = typename Solver::XMultiVectorPtr; + + using XMultiVectorFactory = typename Solver::XMultiVectorFactory; + + // Tpetra + using TOperator = Tpetra::Operator; + + using TCrsMatrix = Tpetra::CrsMatrix; + using TCrsMatrixPtr = RCP; + using ConstTCrsMatrixPtr = RCP; + + using TMultiVector = Tpetra::MultiVector; + using TMultiVectorPtr = RCP; + + // Teuchos + using ParameterListPtr = typename Solver::ParameterListPtr; + + // Belos + using BelosLinearProblem = Belos::LinearProblem; + using BelosLinearProblemPtr = RCP; + using BelosSolverFactory = Belos::SolverFactory; + using BelosSolverFactoryPtr = RCP; + using BelosSolverManager = Belos::SolverManager; + using BelosSolverManagerPtr = RCP; + + public: + + //! Initialize the internal solver + virtual int initialize(); + + //! Compute the internal solver + virtual int compute(); + + /*! + \brief Computes the operator-multivector application. + + Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + \beta \cdot Y\f$. However, the details of operation + vary according to the values of \c alpha and \c beta. Specifically + - if beta == 0, apply() must overwrite \c Y, so that any values in \c Y (including NaNs) are ignored. + - if alpha == 0, apply() may short-circuit the operator, so that any values in \c X (including NaNs) are ignored. + */ + void apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode=NO_TRANS, + SC alpha=ScalarTraits::one(), + SC beta=ScalarTraits::zero()) const; + + int updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize=false); + + protected: + + //! Constructor + BelosSolverTpetra(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description); + + mutable XMultiVectorPtr Y_ = null; + + BelosLinearProblemPtr BelosLinearProblem_; + + BelosSolverManagerPtr BelosSolver_; + + friend class SolverFactory; + }; + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp new file mode 100644 index 000000000000..60cf93ba7a58 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp @@ -0,0 +1,142 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_BELOSSOLVERTPETRA_DEF_HPP +#define _FROSCH_BELOSSOLVERTPETRA_DEF_HPP + +#include + + +namespace FROSch { + + using namespace std; + using namespace Teuchos; + using namespace Xpetra; + + template + int BelosSolverTpetra::initialize() + { + FROSCH_TIMER_START_SOLVER(initializeTime,"BelosSolverTpetra::initialize"); + this->IsInitialized_ = true; + this->IsComputed_ = false; + return 0; + } + + template + int BelosSolverTpetra::compute() + { + FROSCH_TIMER_START_SOLVER(computeTime,"BelosSolverTpetra::compute"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::BelosSolverTpetra : ERROR: !this->IsInitialized_"); + this->IsComputed_ = true; + return 0; + } + + template + void BelosSolverTpetra::apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode, + SC alpha, + SC beta) const + { + FROSCH_TIMER_START_SOLVER(applyTime,"BelosSolverTpetra::apply"); + FROSCH_ASSERT(this->IsComputed_,"FROSch::BelosSolverTpetra : ERROR: !this->IsComputed_."); + + const TpetraMultiVector * xTpetraMultiVectorX = dynamic_cast *>(&x); + TMultiVectorPtr tpetraMultiVectorX = xTpetraMultiVectorX->getTpetra_MultiVector(); + + if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),x.getNumVectors()); + const TpetraMultiVector * xTpetraMultiVectorY = dynamic_cast *>(Y_.get()); + TMultiVectorPtr tpetraMultiVectorY = xTpetraMultiVectorY->getTpetra_MultiVector(); + + BelosLinearProblem_->setProblem(tpetraMultiVectorY,tpetraMultiVectorX); + BelosSolver_->solve(); + + y.update(alpha,*Y_,beta); + } + + template + int BelosSolverTpetra::updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize) + { + FROSCH_TIMER_START_SOLVER(updateMatrixTime,"BelosSolverTpetra::updateMatrix"); + this->K_ = k; + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::BelosSolverTpetra : ERROR: K_ is null."); + + const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); + const TpetraCrsMatrix& xTpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); + ConstTCrsMatrixPtr tpetraMat = xTpetraMat.getTpetra_CrsMatrix(); + TEUCHOS_TEST_FOR_EXCEPT(tpetraMat.is_null()); + + BelosLinearProblem_->setOperator(tpetraMat); + + return 0; + } + + template + BelosSolverTpetra::BelosSolverTpetra(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description) : + Solver (k,parameterList,description) + { + FROSCH_TIMER_START_SOLVER(BelosSolverTpetraTime,"BelosSolverTpetra::BelosSolverTpetra"); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::BelosSolverTpetra : ERROR: K_ is null."); + + const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); + const TpetraCrsMatrix& xTpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); + ConstTCrsMatrixPtr tpetraMat = xTpetraMat.getTpetra_CrsMatrix(); + TEUCHOS_TEST_FOR_EXCEPT(tpetraMat.is_null()); + + TMultiVectorPtr xTmp; + TMultiVectorPtr bTmp; + + BelosLinearProblem_.reset(new BelosLinearProblem(tpetraMat,xTmp,bTmp)); + + BelosSolverFactory belosFactory; + ParameterListPtr solverParameterList = sublist(this->ParameterList_,"Belos"); + + BelosSolver_ = belosFactory.create(solverParameterList->get("Solver","GMRES"),sublist(solverParameterList,solverParameterList->get("Solver","GMRES"))); + + BelosSolver_->setProblem(BelosLinearProblem_); + } + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp index 2d7efa2f7ef3..4ea50ae39252 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp @@ -50,6 +50,12 @@ #include #endif #include +#ifdef HAVE_SHYLU_DDFROSCH_BELOS +#ifdef HAVE_SHYLU_DDFROSCH_EPETRA +#include +#endif +#include +#endif #if defined(HAVE_SHYLU_DDFROSCH_THYRA) && defined(HAVE_SHYLU_DDFROSCH_STRATIMIKOS) #include #include @@ -78,6 +84,12 @@ namespace FROSch { using Amesos2SolverEpetraPtr = RCP >; #endif using Amesos2SolverTpetraPtr = RCP >; +#ifdef HAVE_SHYLU_DDFROSCH_BELOS +#ifdef HAVE_SHYLU_DDFROSCH_EPETRA + using BelosSolverEpetraPtr = RCP >; +#endif + using BelosSolverTpetraPtr = RCP >; +#endif #if defined(HAVE_SHYLU_DDFROSCH_THYRA) && defined(HAVE_SHYLU_DDFROSCH_STRATIMIKOS) using ThyraPreconditionerPtr = RCP >; using ThyraSolverPtr = RCP >; diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp index 6588a382c2d5..ffe07dffe88f 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp @@ -56,47 +56,63 @@ namespace FROSch { string description) { // RCP fancy = fancyOStream(rcpFromRef(cout)); k->describe(*fancy,VERB_EXTREME); - if (!parameterList->get("SolverType","Amesos").compare("Amesos")) { + if (!parameterList->get("SolverType","Amesos2").compare("Amesos")) { //return AmesosSolverPtr(new AmesosSolver(k,parameterList,description)); - } else if (!parameterList->get("SolverType","Amesos").compare("Amesos2")) { + } else if (!parameterList->get("SolverType","Amesos2").compare("Amesos2")) { if (k->getRowMap()->lib()==UseEpetra) { #ifdef HAVE_SHYLU_DDFROSCH_EPETRA return Amesos2SolverEpetraPtr(new Amesos2SolverEpetra(k,parameterList,description)); #else - ThrowErrorMissingPackage("FROSch::SolverFactory", "Epetra"); + ThrowErrorMissingPackage("FROSch::SolverFactory","Epetra"); #endif } else if (k->getRowMap()->lib()==UseTpetra) { return Amesos2SolverTpetraPtr(new Amesos2SolverTpetra(k,parameterList,description)); } else { FROSCH_ASSERT(false, "FROSch::SolverFactory : ERROR: This can't happen. Either use Epetra or Tetra linear algebra stack."); } - } else if (!parameterList->get("SolverType","Amesos").compare("Ifpack2")) { + } else if (!parameterList->get("SolverType","Amesos2").compare("Belos")) { +#ifdef HAVE_SHYLU_DDFROSCH_BELOS + if (k->getRowMap()->lib()==UseEpetra) { +#ifdef HAVE_SHYLU_DDFROSCH_EPETRA + return BelosSolverEpetraPtr(new BelosSolverEpetra(k,parameterList,description)); +#else + ThrowErrorMissingPackage("FROSch::SolverFactory","Epetra"); +#endif + } else if (k->getRowMap()->lib()==UseTpetra) { + return BelosSolverTpetraPtr(new BelosSolverTpetra(k,parameterList,description)); + } else { + FROSCH_ASSERT(false, "FROSch::SolverFactory : ERROR: This can't happen. Either use Epetra or Tetra linear algebra stack."); + } +#else + ThrowErrorMissingPackage("FROSch::SolverFactory","Belos"); +#endif + } else if (!parameterList->get("SolverType","Amesos2").compare("Ifpack2")) { //return Ifpack2SolverPtr(new Ifpack2Solver(k,parameterList,description)); - } else if (!parameterList->get("SolverType","Amesos").compare("MueLu")) { + } else if (!parameterList->get("SolverType","Amesos2").compare("MueLu")) { //return MueLuSolverPtr(new MueLuSolver(k,parameterList,description)); - } else if (!parameterList->get("SolverType","Amesos").compare("ThyraPreconditioner")) { + } else if (!parameterList->get("SolverType","Amesos2").compare("ThyraPreconditioner")) { #ifdef HAVE_SHYLU_DDFROSCH_THYRA #ifdef HAVE_SHYLU_DDFROSCH_STRATIMIKOS return ThyraPreconditionerPtr(new ThyraPreconditioner(k,parameterList,description)); #else - ThrowErrorMissingPackage("FROSch::SolverFactory", "Stratimikos"); + ThrowErrorMissingPackage("FROSch::SolverFactory","Stratimikos"); #endif #else - ThrowErrorMissingPackage("FROSch::SolverFactory", "Thyra"); + ThrowErrorMissingPackage("FROSch::SolverFactory","Thyra"); #endif - } else if (!parameterList->get("SolverType","Amesos").compare("ThyraSolver")) { + } else if (!parameterList->get("SolverType","Amesos2").compare("ThyraSolver")) { #ifdef HAVE_SHYLU_DDFROSCH_THYRA #ifdef HAVE_SHYLU_DDFROSCH_STRATIMIKOS return ThyraSolverPtr(new ThyraSolver(k,parameterList,description)); #else - ThrowErrorMissingPackage("FROSch::SolverFactory", "Stratimikos"); + ThrowErrorMissingPackage("FROSch::SolverFactory","Stratimikos"); #endif #else - ThrowErrorMissingPackage("FROSch::SolverFactory", "Thyra"); + ThrowErrorMissingPackage("FROSch::SolverFactory","Thyra"); #endif - } else if (!parameterList->get("SolverType","Amesos").compare("TwoLevelBlockPreconditioner")) { + } else if (!parameterList->get("SolverType","Amesos2").compare("TwoLevelBlockPreconditioner")) { //return TwoLevelBlockPreconditionerSolverPtr(new TwoLevelBlockPreconditionerSolver(k,parameterList,description)); - } else if (!parameterList->get("SolverType","Amesos").compare("TwoLevelPreconditioner")) { + } else if (!parameterList->get("SolverType","Amesos2").compare("TwoLevelPreconditioner")) { //return TwoLevelPreconditionerSolverPtr(new TwoLevelPreconditionerSolver(k,parameterList,description)); } else { FROSCH_ASSERT(false,"SolverType unknown..."); diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt b/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt index 023ecb336c96..bb4de2a69c9f 100644 --- a/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt @@ -14,14 +14,14 @@ ParameterLists IF(HAVE_SHYLU_DDFROSCH_EPETRA AND NOT Tpetra_DefaultNode STREQUAL "Kokkos::Compat::KokkosCudaWrapperNode") TRIBITS_ADD_TEST( solverfactory -NAME test_solverfactory_klu_DIM2_EPETRA +NAME test_solverfactory_amesos2_klu_DIM2_EPETRA ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_Amesos2_Klu.xml --USEEPETRA" COMM mpi NUM_MPI_PROCS 1 ) TRIBITS_ADD_TEST( solverfactory -NAME test_solverfactory_klu_DIM3_EPETRA +NAME test_solverfactory_amesos2_klu_DIM3_EPETRA ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_Amesos2_Klu.xml --USEEPETRA" COMM mpi NUM_MPI_PROCS 1 @@ -30,19 +30,55 @@ ENDIF() ##Tpetra TRIBITS_ADD_TEST( solverfactory -NAME test_solverfactory_klu_DIM2_TPETRA +NAME test_solverfactory_amesos2_klu_DIM2_TPETRA ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_Amesos2_Klu.xml --USETPETRA" COMM mpi NUM_MPI_PROCS 1 ) TRIBITS_ADD_TEST( solverfactory -NAME test_solverfactory_klu_DIM3_TPETRA +NAME test_solverfactory_amesos2_klu_DIM3_TPETRA ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_Amesos2_Klu.xml --USETPETRA" COMM mpi NUM_MPI_PROCS 1 ) +############### +# Belos GMRES # +############### +## Epetra +IF(HAVE_SHYLU_DDFROSCH_EPETRA AND NOT Tpetra_DefaultNode STREQUAL "Kokkos::Compat::KokkosCudaWrapperNode") +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_belos_gmres_DIM2_EPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_Belos_GMRES.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 1 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_belos_gmres_DIM3_EPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_Belos_GMRES.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 1 +) +ENDIF() +##Tpetra +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_belos_gmres_DIM2_TPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_Belos_GMRES.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 1 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_belos_gmres_DIM3_TPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_Belos_GMRES.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 1 +) + ##################################################### # ThyraPreconditioner FROSch OneLevelPreconditioner # ##################################################### diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Belos_GMRES.xml b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Belos_GMRES.xml new file mode 100644 index 000000000000..113d6f9392fd --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Belos_GMRES.xml @@ -0,0 +1,4 @@ + + + + diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp b/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp index efc7c6982407..dc9146051f4e 100644 --- a/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp @@ -221,7 +221,7 @@ int main(int argc, char *argv[]) } CommWorld->barrier(); - stackedTimer->stop("Thyra Elasticity Test"); + stackedTimer->stop("FROSch Solver Factory Test"); StackedTimer::OutputOptions options; options.output_fraction = options.output_histogram = options.output_minmax = true; stackedTimer->report(*out,CommWorld,options); From 384766dacdc83c92e693d464dff573da5cef457f Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Fri, 26 Feb 2021 18:09:15 +0100 Subject: [PATCH 04/15] Small typo. --- .../src/SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp index 5e7520e03e37..88a4905288bc 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp @@ -39,8 +39,8 @@ // ************************************************************************ //@HEADER -#ifndef FROSCH_AMESOS2SOLVEREPETRA_DECL_HPP -#define FROSCH_AMESOS2SOLVEREPETRA_DECL_HPP +#ifndef _FROSCH_AMESOS2SOLVEREPETRA_DECL_HPP +#define _FROSCH_AMESOS2SOLVEREPETRA_DECL_HPP #include From 484d903abb81f84161ceeef767b6abeb68ce5eb3 Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Sun, 28 Feb 2021 16:19:42 +0100 Subject: [PATCH 05/15] AmesosEpetra and Ifpack2. --- .../FROSch_Amesos2SolverEpetra_def.hpp | 3 +- .../FROSch_Amesos2SolverTpetra_def.hpp | 3 +- .../FROSch_AmesosSolverEpetra_decl.hpp | 140 +++++++++++++++++ .../FROSch_AmesosSolverEpetra_def.hpp | 143 ++++++++++++++++++ .../FROSch_BelosSolverEpetra_def.hpp | 3 +- .../FROSch_BelosSolverTpetra_def.hpp | 3 +- ...ROSch_Ifpack2PreconditionerTpetra_decl.hpp | 131 ++++++++++++++++ ...FROSch_Ifpack2PreconditionerTpetra_def.hpp | 126 +++++++++++++++ .../FROSch_SolverFactory_decl.hpp | 14 +- .../FROSch_SolverFactory_def.hpp | 19 ++- .../shylu_dd/frosch/test/Overlap/main.cpp | 2 +- .../frosch/test/SolverFactory/CMakeLists.txt | 48 +++++- .../ParameterLists/CMakeLists.txt | 5 +- .../ParameterList_Amesos_Klu.xml | 4 + .../ParameterList_Ifpack2_RILUK.xml | 4 + .../frosch/test/SolverFactory/main.cpp | 6 +- .../test/Thyra_Xpetra_Elasticity/main.cpp | 2 +- .../frosch/test/Thyra_Xpetra_Laplace/main.cpp | 2 +- 18 files changed, 639 insertions(+), 19 deletions(-) create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_decl.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_decl.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp create mode 100644 packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Amesos_Klu.xml create mode 100644 packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Ifpack2_RILUK.xml diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp index fe5d08d0f121..805c102d6de0 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp @@ -131,6 +131,7 @@ namespace FROSch { Solver (k,parameterList,description) { FROSCH_TIMER_START_SOLVER(Amesos2SolverEpetraTime,"Amesos2SolverEpetra::Amesos2SolverEpetra"); + FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseEpetra,"FROSch::Amesos2SolverEpetra : ERROR: Not compatible with Tpetra.") FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverEpetra : ERROR: K_ is null."); const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); @@ -141,7 +142,7 @@ namespace FROSch { EMultiVectorPtr xTmp; EMultiVectorPtr bTmp; - Amesos2Solver_ = Amesos2::create(this->ParameterList_->get("Solver","Mumps"),epetraMat,xTmp,bTmp); + Amesos2Solver_ = Amesos2::create(this->ParameterList_->get("Solver","Klu"),epetraMat,xTmp,bTmp); ParameterListPtr amesos2ParameterList = sublist(this->ParameterList_,"Amesos2"); amesos2ParameterList->setName("Amesos2"); Amesos2Solver_->setParameters(amesos2ParameterList); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp index a483fa188ca5..9c3081d32aaa 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp @@ -131,6 +131,7 @@ namespace FROSch { Solver (k,parameterList,description) { FROSCH_TIMER_START_SOLVER(Amesos2SolverTpetraTime,"Amesos2SolverTpetra::Amesos2SolverTpetra"); + FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseTpetra,"FROSch::Amesos2SolverTpetra : ERROR: Not compatible with Epetra.") FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverTpetra : ERROR: K_ is null."); const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); @@ -141,7 +142,7 @@ namespace FROSch { TMultiVectorPtr xTmp; TMultiVectorPtr bTmp; - Amesos2Solver_ = Amesos2::create(this->ParameterList_->get("Solver","Mumps"),tpetraMat,xTmp,bTmp); + Amesos2Solver_ = Amesos2::create(this->ParameterList_->get("Solver","Klu"),tpetraMat,xTmp,bTmp); ParameterListPtr amesos2ParameterList = sublist(this->ParameterList_,"Amesos2"); amesos2ParameterList->setName("Amesos2"); Amesos2Solver_->setParameters(amesos2ParameterList); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_decl.hpp new file mode 100644 index 000000000000..d4765adcbbb9 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_decl.hpp @@ -0,0 +1,140 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_AMESOSSOLVEREPETRA_DECL_HPP +#define _FROSCH_AMESOSSOLVEREPETRA_DECL_HPP + +#include + +#include "Amesos_ConfigDefs.h" +#include "Amesos.h" +#include "Amesos_BaseSolver.h" + +#include + +// FROSch +#include + + +namespace FROSch { + + using namespace Teuchos; + using namespace Xpetra; + + template + class AmesosSolverEpetra : public Solver { + + protected: + + // Xpetra + using ConstXMatrixPtr = typename Solver::ConstXMatrixPtr; + + using XMultiVector = typename Solver::XMultiVector; + using XMultiVectorPtr = typename Solver::XMultiVectorPtr; + + using XMultiVectorFactory = typename Solver::XMultiVectorFactory; + + // Epetra + using ECrsMatrix = Epetra_CrsMatrix; + using ECrsMatrixPtr = RCP; + using ConstECrsMatrixPtr = RCP; + + using EMultiVector = Epetra_MultiVector; + using EMultiVectorPtr = RCP; + + using ELinearProblem = Epetra_LinearProblem; + using ELinearProblemPtr = RCP; + + // Teuchos + using ParameterListPtr = typename Solver::ParameterListPtr; + + // Amesos + using AmesosSolverPtr = RCP; + + public: + + ~AmesosSolverEpetra(); + + //! Initialize the internal solver + virtual int initialize(); + + //! Compute the internal solver + virtual int compute(); + + /*! + \brief Computes the operator-multivector application. + + Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + \beta \cdot Y\f$. However, the details of operation + vary according to the values of \c alpha and \c beta. Specifically + - if beta == 0, apply() must overwrite \c Y, so that any values in \c Y (including NaNs) are ignored. + - if alpha == 0, apply() may short-circuit the operator, so that any values in \c X (including NaNs) are ignored. + */ + void apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode=NO_TRANS, + SC alpha=ScalarTraits::one(), + SC beta=ScalarTraits::zero()) const; + + int updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize=false); + + protected: + + //! Constructor + AmesosSolverEpetra(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description); + + mutable XMultiVectorPtr Y_ = null; + + AmesosSolverPtr AmesosSolver_; + + ELinearProblemPtr EpetraLinearProblem_; + + friend class SolverFactory; + }; + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp new file mode 100644 index 000000000000..0079308695f2 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp @@ -0,0 +1,143 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_AMESOSSOLVEREPETRA_DEF_HPP +#define _FROSCH_AMESOSSOLVEREPETRA_DEF_HPP + +#include + + +namespace FROSch { + + using namespace std; + using namespace Teuchos; + using namespace Xpetra; + + template + AmesosSolverEpetra::~AmesosSolverEpetra() + { + AmesosSolver_.reset(); + EpetraLinearProblem_.reset(); + } + + template + int AmesosSolverEpetra::initialize() + { + FROSCH_TIMER_START_SOLVER(initializeTime,"AmesosSolverEpetra::initialize"); + this->IsInitialized_ = true; + this->IsComputed_ = false; + AMESOS_CHK_ERR(AmesosSolver_->SymbolicFactorization()); + return 0; + } + + template + int AmesosSolverEpetra::compute() + { + FROSCH_TIMER_START_SOLVER(computeTime,"AmesosSolverEpetra::compute"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::AmesosSolverEpetra : ERROR: !this->IsInitialized_"); + this->IsComputed_ = true; + AMESOS_CHK_ERR(AmesosSolver_->NumericFactorization()); + return 0; + } + + template + void AmesosSolverEpetra::apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode, + SC alpha, + SC beta) const + { + FROSCH_TIMER_START_SOLVER(applyTime,"AmesosSolverEpetra::apply"); + FROSCH_ASSERT(this->IsComputed_,"FROSch::AmesosSolverEpetra : ERROR: !this->IsComputed_."); + + const EpetraMultiVectorT * xEpetraMultiVectorX = dynamic_cast *>(&x); + RCP epetraMultiVectorX = xEpetraMultiVectorX->getEpetra_MultiVector(); + + if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),x.getNumVectors()); + EpetraMultiVectorT * xEpetraMultiVectorY = dynamic_cast *>(Y_.get()); + RCP epetraMultiVectorY = xEpetraMultiVectorY->getEpetra_MultiVector(); + + EpetraLinearProblem_->SetLHS(epetraMultiVectorY.get()); + EpetraLinearProblem_->SetRHS(epetraMultiVectorX.get()); + + FROSCH_ASSERT(mode==NO_TRANS,"FROSch::AmesosSolverEpetra : ERROR: mode!=NO_TRANS"); + EpetraLinearProblem_->GetMatrix()->SetUseTranspose(mode==TRANS); + AmesosSolver_->Solve(); + + y.update(alpha,*Y_,beta); + } + + template + int AmesosSolverEpetra::updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize) + { + FROSCH_ASSERT(false,"FROSch::AmesosSolverEpetra : ERROR: updateMatrix() is not implemented for the AmesosSolverEpetra yet."); + return 0; + } + + template + AmesosSolverEpetra::AmesosSolverEpetra(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description) : + Solver (k,parameterList,description) + { + FROSCH_TIMER_START_SOLVER(AmesosSolverEpetraTime,"AmesosSolverEpetra::AmesosSolverEpetra"); + FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseEpetra,"FROSch::AmesosSolverEpetra : ERROR: Not compatible with Tpetra.") + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::AmesosSolverEpetra : ERROR: K_ is null."); + + const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); + const EpetraCrsMatrixT& xEpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); + ECrsMatrixPtr epetraMat = xEpetraMat.getEpetra_CrsMatrixNonConst(); + TEUCHOS_TEST_FOR_EXCEPT(epetraMat.is_null()); + + EMultiVectorPtr xTmp; + EMultiVectorPtr bTmp; + + EpetraLinearProblem_.reset(new ELinearProblem(epetraMat.get(),xTmp.get(),bTmp.get())); + + Amesos amesosFactory; + AmesosSolver_.reset(amesosFactory.Create(this->ParameterList_->get("Solver","Klu"),*EpetraLinearProblem_)); + AmesosSolver_->SetParameters(this->ParameterList_->sublist("Amesos")); + } + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp index 806fea31d24c..3495870c0aff 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp @@ -82,7 +82,7 @@ namespace FROSch { const EpetraMultiVectorT * xEpetraMultiVectorX = dynamic_cast *>(&x); RCP epetraMultiVectorX = xEpetraMultiVectorX->getEpetra_MultiVector(); - if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),x.getNumVectors()); + if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),y.getNumVectors()); EpetraMultiVectorT * xEpetraMultiVectorY = dynamic_cast *>(Y_.get()); RCP epetraMultiVectorY = xEpetraMultiVectorY->getEpetra_MultiVector(); @@ -117,6 +117,7 @@ namespace FROSch { Solver (k,parameterList,description) { FROSCH_TIMER_START_SOLVER(BelosSolverEpetraTime,"BelosSolverEpetra::BelosSolverEpetra"); + FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseEpetra,"FROSch::BelosSolverEpetra : ERROR: Not compatible with Tpetra.") FROSCH_ASSERT(!this->K_.is_null(),"FROSch::BelosSolverEpetra : ERROR: K_ is null."); const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp index 60cf93ba7a58..a2fcca011b58 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp @@ -82,7 +82,7 @@ namespace FROSch { const TpetraMultiVector * xTpetraMultiVectorX = dynamic_cast *>(&x); TMultiVectorPtr tpetraMultiVectorX = xTpetraMultiVectorX->getTpetra_MultiVector(); - if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),x.getNumVectors()); + if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),y.getNumVectors()); const TpetraMultiVector * xTpetraMultiVectorY = dynamic_cast *>(Y_.get()); TMultiVectorPtr tpetraMultiVectorY = xTpetraMultiVectorY->getTpetra_MultiVector(); @@ -117,6 +117,7 @@ namespace FROSch { Solver (k,parameterList,description) { FROSCH_TIMER_START_SOLVER(BelosSolverTpetraTime,"BelosSolverTpetra::BelosSolverTpetra"); + FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseTpetra,"FROSch::BelosSolverTpetra : ERROR: Not compatible with Epetra.") FROSCH_ASSERT(!this->K_.is_null(),"FROSch::BelosSolverTpetra : ERROR: K_ is null."); const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_decl.hpp new file mode 100644 index 000000000000..be40af9492d4 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_decl.hpp @@ -0,0 +1,131 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_IFPACK2PRECONDITIONERTPETRA_DECL_HPP +#define _FROSCH_IFPACK2PRECONDITIONERTPETRA_DECL_HPP + +#include + +// FROSch +#include + + +namespace FROSch { + + using namespace Teuchos; + using namespace Xpetra; + + template + class Ifpack2PreconditionerTpetra : public Solver { + + protected: + + // Xpetra + using ConstXMatrixPtr = typename Solver::ConstXMatrixPtr; + + using XMultiVector = typename Solver::XMultiVector; + using XMultiVectorPtr = typename Solver::XMultiVectorPtr; + + using XMultiVectorFactory = typename Solver::XMultiVectorFactory; + + // Tpetra + using TOperator = Tpetra::Operator; + + using TRowMatrix = Tpetra::RowMatrix; + using TRowMatrixPtr = RCP; + using ConstTRowMatrixPtr = RCP; + + using TCrsMatrix = Tpetra::CrsMatrix; + using TCrsMatrixPtr = RCP; + using ConstTCrsMatrixPtr = RCP; + + using TMultiVector = Tpetra::MultiVector; + using TMultiVectorPtr = RCP; + + // Teuchos + using ParameterListPtr = typename Solver::ParameterListPtr; + + // Ifpack2 + using Ifpack2PreconditionerPtr = RCP >; + + public: + + //! Initialize the internal solver + virtual int initialize(); + + //! Compute the internal solver + virtual int compute(); + + /*! + \brief Computes the operator-multivector application. + + Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + \beta \cdot Y\f$. However, the details of operation + vary according to the values of \c alpha and \c beta. Specifically + - if beta == 0, apply() must overwrite \c Y, so that any values in \c Y (including NaNs) are ignored. + - if alpha == 0, apply() may short-circuit the operator, so that any values in \c X (including NaNs) are ignored. + */ + void apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode=NO_TRANS, + SC alpha=ScalarTraits::one(), + SC beta=ScalarTraits::zero()) const; + + int updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize=false); + + protected: + + //! Constructor + Ifpack2PreconditionerTpetra(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description); + + Ifpack2PreconditionerPtr Ifpack2Preconditioner_; + + friend class SolverFactory; + }; + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp new file mode 100644 index 000000000000..c3b251aa5732 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp @@ -0,0 +1,126 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_IFPACK2PRECONDITIONERTPETRA_DEF_HPP +#define _FROSCH_IFPACK2PRECONDITIONERTPETRA_DEF_HPP + +#include + + +namespace FROSch { + + using namespace std; + using namespace Teuchos; + using namespace Xpetra; + + template + int Ifpack2PreconditionerTpetra::initialize() + { + FROSCH_TIMER_START_SOLVER(initializeTime,"Ifpack2PreconditionerTpetra::initialize"); + this->IsInitialized_ = true; + this->IsComputed_ = false; + Ifpack2Preconditioner_->initialize(); + return 0; + } + + template + int Ifpack2PreconditionerTpetra::compute() + { + FROSCH_TIMER_START_SOLVER(computeTime,"Ifpack2PreconditionerTpetra::compute"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::Ifpack2PreconditionerTpetra : ERROR: !this->IsInitialized_"); + this->IsComputed_ = true; + Ifpack2Preconditioner_->compute(); + return 0; + } + + template + void Ifpack2PreconditionerTpetra::apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode, + SC alpha, + SC beta) const + { + FROSCH_TIMER_START_SOLVER(applyTime,"Ifpack2PreconditionerTpetra::apply"); + FROSCH_ASSERT(this->IsComputed_,"FROSch::Ifpack2PreconditionerTpetra : ERROR: !this->IsComputed_."); + + const TpetraMultiVector * xTpetraMultiVectorX = dynamic_cast *>(&x); + TMultiVectorPtr tpetraMultiVectorX = xTpetraMultiVectorX->getTpetra_MultiVector(); + + const TpetraMultiVector * xTpetraMultiVectorY = dynamic_cast *>(&y); + TMultiVectorPtr tpetraMultiVectorY = xTpetraMultiVectorY->getTpetra_MultiVector(); + + Ifpack2Preconditioner_->apply(*tpetraMultiVectorX,*tpetraMultiVectorY,mode,alpha,beta); + } + + template + int Ifpack2PreconditionerTpetra::updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize) + { + FROSCH_ASSERT(false,"FROSch::Ifpack2PreconditionerTpetra : ERROR: updateMatrix() is not implemented for the Ifpack2PreconditionerTpetra yet."); + return 0; + } + + template + Ifpack2PreconditionerTpetra::Ifpack2PreconditionerTpetra(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description) : + Solver (k,parameterList,description) + { + FROSCH_TIMER_START_SOLVER(Ifpack2PreconditionerTpetraTime,"Ifpack2PreconditionerTpetra::Ifpack2PreconditionerTpetra"); + FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseTpetra,"FROSch::Ifpack2PreconditionerTpetra : ERROR: Not compatible with Epetra.") + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Ifpack2PreconditionerTpetra : ERROR: K_ is null."); + + const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); + const TpetraCrsMatrix& xTpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); + ConstTCrsMatrixPtr tpetraMat = xTpetraMat.getTpetra_CrsMatrix(); + TEUCHOS_TEST_FOR_EXCEPT(tpetraMat.is_null()); + + Ifpack2::Details::OneLevelFactory ifpack2Factory; + Ifpack2Preconditioner_ = ifpack2Factory.create(this->ParameterList_->get("Solver","RILUK"),tpetraMat); + + ParameterListPtr ifpack2ParameterList = sublist(this->ParameterList_,"Ifpack2"); + ifpack2ParameterList->setName("Ifpack2"); + Ifpack2Preconditioner_->setParameters(*ifpack2ParameterList); + } + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp index 4ea50ae39252..496faef6889e 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp @@ -46,6 +46,9 @@ // FROSch #include +#if defined(HAVE_SHYLU_DDFROSCH_AMESOS) && defined(HAVE_SHYLU_DDFROSCH_EPETRA) +#include +#endif #ifdef HAVE_SHYLU_DDFROSCH_EPETRA #include #endif @@ -56,6 +59,9 @@ #endif #include #endif +#ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 +#include +#endif #if defined(HAVE_SHYLU_DDFROSCH_THYRA) && defined(HAVE_SHYLU_DDFROSCH_STRATIMIKOS) #include #include @@ -80,6 +86,10 @@ namespace FROSch { using ParameterListPtr = typename Solver::ParameterListPtr; + using SolverPtr = RCP >; +#if defined(HAVE_SHYLU_DDFROSCH_AMESOS) && defined(HAVE_SHYLU_DDFROSCH_EPETRA) + using AmesosSolverEpetraPtr = RCP >; +#endif #ifdef HAVE_SHYLU_DDFROSCH_EPETRA using Amesos2SolverEpetraPtr = RCP >; #endif @@ -90,11 +100,13 @@ namespace FROSch { #endif using BelosSolverTpetraPtr = RCP >; #endif +#ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 + using Ifpack2PreconditionerTpetraPtr = RCP >; +#endif #if defined(HAVE_SHYLU_DDFROSCH_THYRA) && defined(HAVE_SHYLU_DDFROSCH_STRATIMIKOS) using ThyraPreconditionerPtr = RCP >; using ThyraSolverPtr = RCP >; #endif - using SolverPtr = RCP >; public: diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp index ffe07dffe88f..5a019f8beaf6 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp @@ -55,9 +55,17 @@ namespace FROSch { ParameterListPtr parameterList, string description) { - // RCP fancy = fancyOStream(rcpFromRef(cout)); k->describe(*fancy,VERB_EXTREME); if (!parameterList->get("SolverType","Amesos2").compare("Amesos")) { - //return AmesosSolverPtr(new AmesosSolver(k,parameterList,description)); +#ifdef HAVE_SHYLU_DDFROSCH_AMESOS + FROSCH_ASSERT(k->getRowMap()->lib()==UseEpetra,"FROSch::SolverFactory : ERROR: Amesos is not compatible with Tpetra."); +#ifdef HAVE_SHYLU_DDFROSCH_EPETRA + return AmesosSolverEpetraPtr(new AmesosSolverEpetra(k,parameterList,description)); +#else + ThrowErrorMissingPackage("FROSch::SolverFactory","Epetra"); +#endif +#else + ThrowErrorMissingPackage("FROSch::SolverFactory","Amesos"); +#endif } else if (!parameterList->get("SolverType","Amesos2").compare("Amesos2")) { if (k->getRowMap()->lib()==UseEpetra) { #ifdef HAVE_SHYLU_DDFROSCH_EPETRA @@ -87,7 +95,12 @@ namespace FROSch { ThrowErrorMissingPackage("FROSch::SolverFactory","Belos"); #endif } else if (!parameterList->get("SolverType","Amesos2").compare("Ifpack2")) { - //return Ifpack2SolverPtr(new Ifpack2Solver(k,parameterList,description)); +#ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 + FROSCH_ASSERT(k->getRowMap()->lib()==UseTpetra,"FROSch::SolverFactory : ERROR: Ifpack2 is not compatible with Epetra."); + return Ifpack2PreconditionerTpetraPtr(new Ifpack2PreconditionerTpetra(k,parameterList,description)); +#else + ThrowErrorMissingPackage("FROSch::SolverFactory","Ifpack2"); +#endif } else if (!parameterList->get("SolverType","Amesos2").compare("MueLu")) { //return MueLuSolverPtr(new MueLuSolver(k,parameterList,description)); } else if (!parameterList->get("SolverType","Amesos2").compare("ThyraPreconditioner")) { diff --git a/packages/shylu/shylu_dd/frosch/test/Overlap/main.cpp b/packages/shylu/shylu_dd/frosch/test/Overlap/main.cpp index d8b8197f5b3f..527b36bd1540 100644 --- a/packages/shylu/shylu_dd/frosch/test/Overlap/main.cpp +++ b/packages/shylu/shylu_dd/frosch/test/Overlap/main.cpp @@ -115,7 +115,7 @@ int main(int argc, char *argv[]) RCP out = VerboseObjectBase::getDefaultOStream(); - int M = 4; + int M = 3; My_CLP.setOption("M",&M,"H / h."); int Dimension = 2; My_CLP.setOption("DIM",&Dimension,"Dimension."); diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt b/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt index bb4de2a69c9f..c0fa5d6ba861 100644 --- a/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt @@ -7,6 +7,27 @@ ADD_SUBDIRECTORIES( ParameterLists ) +############## +# Amesos Klu # +############## +## Epetra +IF(HAVE_SHYLU_DDFROSCH_EPETRA AND NOT Tpetra_DefaultNode STREQUAL "Kokkos::Compat::KokkosCudaWrapperNode") +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_amesos_klu_DIM2_EPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_Amesos_Klu.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 1 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_amesos_klu_DIM3_EPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_Amesos_Klu.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 1 +) +ENDIF() + ############### # Amesos2 Klu # ############### @@ -53,14 +74,14 @@ solverfactory NAME test_solverfactory_belos_gmres_DIM2_EPETRA ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_Belos_GMRES.xml --USEEPETRA" COMM mpi -NUM_MPI_PROCS 1 +NUM_MPI_PROCS 4 ) TRIBITS_ADD_TEST( solverfactory NAME test_solverfactory_belos_gmres_DIM3_EPETRA ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_Belos_GMRES.xml --USEEPETRA" COMM mpi -NUM_MPI_PROCS 1 +NUM_MPI_PROCS 8 ) ENDIF() ##Tpetra @@ -69,14 +90,33 @@ solverfactory NAME test_solverfactory_belos_gmres_DIM2_TPETRA ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_Belos_GMRES.xml --USETPETRA" COMM mpi -NUM_MPI_PROCS 1 +NUM_MPI_PROCS 4 ) TRIBITS_ADD_TEST( solverfactory NAME test_solverfactory_belos_gmres_DIM3_TPETRA ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_Belos_GMRES.xml --USETPETRA" COMM mpi -NUM_MPI_PROCS 1 +NUM_MPI_PROCS 8 +) + +################# +# Ifpack2 RILUK # +################# +##Tpetra +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_ifpack2_riluk_DIM2_TPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_Ifpack2_RILUK.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 4 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_ifpack2_riluk_DIM3_TPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_Ifpack2_RILUK.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 8 ) ##################################################### diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/CMakeLists.txt b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/CMakeLists.txt index 3485856406a9..7b12dd5020f8 100644 --- a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/CMakeLists.txt +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/CMakeLists.txt @@ -1,5 +1,8 @@ TRIBITS_COPY_FILES_TO_BINARY_DIR(SolverFactoryCopyFiles -DEST_FILES ParameterList_Amesos2_Klu.xml +DEST_FILES ParameterList_Amesos_Klu.xml + ParameterList_Amesos2_Klu.xml + ParameterList_Belos_GMRES.xml + ParameterList_Ifpack2_RILUK.xml ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml ParameterList_ThyraSolver_Belos_GMRES.xml SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Amesos_Klu.xml b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Amesos_Klu.xml new file mode 100644 index 000000000000..50297c77c64c --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Amesos_Klu.xml @@ -0,0 +1,4 @@ + + + + diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Ifpack2_RILUK.xml b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Ifpack2_RILUK.xml new file mode 100644 index 000000000000..4c4a0d772d4f --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_Ifpack2_RILUK.xml @@ -0,0 +1,4 @@ + + + + diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp b/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp index dc9146051f4e..fc30c5321ba7 100644 --- a/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) RCP out = VerboseObjectBase::getDefaultOStream(); - int M = 4; + int M = 3; My_CLP.setOption("M",&M,"H / h."); int Dimension = 2; My_CLP.setOption("DIM",&Dimension,"Dimension."); @@ -171,7 +171,7 @@ int main(int argc, char *argv[]) cout << endl; } - Comm->barrier(); if (Comm->getRank()==0) cout << "##############################\n# Assembly Laplacian #\n##############################\n" << endl; + Comm->barrier(); if (Comm->getRank()==0) cout << "######################\n# Assembly Laplacian #\n######################\n" << endl; ParameterList GaleriList; GaleriList.set("nx", GO(N*M)); @@ -205,7 +205,7 @@ int main(int argc, char *argv[]) xSolution->putScalar(ScalarTraits::zero()); xRightHandSide->putScalar(ScalarTraits::one()); - Comm->barrier(); if (Comm->getRank()==0) cout << "###########################\n# Construct Solver #\n###########################" << endl; + Comm->barrier(); if (Comm->getRank()==0) cout << "####################\n# Construct Solver #\n####################" << endl; RCP > FROSchSolverInterface = SolverFactory::Build(K,parameterList,"Solver Tester"); diff --git a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/main.cpp b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/main.cpp index 043574b75a6c..1811cdd3c9f9 100644 --- a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/main.cpp +++ b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/main.cpp @@ -115,7 +115,7 @@ int main(int argc, char *argv[]) RCP out = VerboseObjectBase::getDefaultOStream(); - int M = 4; + int M = 3; My_CLP.setOption("M",&M,"H / h."); int Dimension = 2; My_CLP.setOption("DIM",&Dimension,"Dimension."); diff --git a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/main.cpp b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/main.cpp index b3cc1ae3776a..d05ebaf770d2 100644 --- a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/main.cpp +++ b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/main.cpp @@ -115,7 +115,7 @@ int main(int argc, char *argv[]) RCP out = VerboseObjectBase::getDefaultOStream(); - int M = 4; + int M = 3; My_CLP.setOption("M",&M,"H / h."); int Dimension = 2; My_CLP.setOption("DIM",&Dimension,"Dimension."); From c68613e15ec119f5368a95286a612241e7cffd91 Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Sun, 28 Feb 2021 21:18:36 +0100 Subject: [PATCH 06/15] MueLu & FROSch --- .../src/Adapters/Thyra_FROSchFactory_def.hpp | 12 +- .../shylu/shylu_dd/frosch/src/CMakeLists.txt | 10 + .../CoarseSpaces/FROSch_CoarseSpace_def.hpp | 36 ++-- .../FROSch_ConstantPartitionOfUnity_def.hpp | 6 +- ...OSch_GDSWInterfacePartitionOfUnity_def.hpp | 2 +- ..._GDSWStarInterfacePartitionOfUnity_def.hpp | 8 +- .../FROSch_InterfacePartitionOfUnity_def.hpp | 2 +- ...Sch_RGDSWInterfacePartitionOfUnity_def.hpp | 4 +- .../InterfaceSets/FROSch_DDInterface_def.hpp | 12 +- .../InterfaceSets/FROSch_EntitySet_def.hpp | 26 +-- .../FROSch_InterfaceEntity_def.hpp | 8 +- ...ROSch_AlgebraicOverlappingOperator_def.hpp | 12 +- .../FROSch_CoarseOperator_def.hpp | 10 +- .../FROSch_GDSWCoarseOperator_def.hpp | 4 +- .../FROSch_HarmonicCoarseOperator_def.hpp | 42 ++-- .../FROSch_IPOUHarmonicCoarseOperator_def.hpp | 2 +- .../FROSch_OverlappingOperator_def.hpp | 4 +- .../FROSch_RGDSWCoarseOperator_def.hpp | 4 +- ...FROSch_TwoLevelBlockPreconditioner_def.hpp | 27 ++- .../FROSch_Amesos2SolverEpetra_decl.hpp | 2 +- .../FROSch_Amesos2SolverEpetra_def.hpp | 14 +- .../FROSch_Amesos2SolverTpetra_decl.hpp | 2 +- .../FROSch_Amesos2SolverTpetra_def.hpp | 14 +- .../FROSch_AmesosSolverEpetra_decl.hpp | 4 +- .../FROSch_AmesosSolverEpetra_def.hpp | 16 +- .../FROSch_BelosSolverEpetra_decl.hpp | 4 +- .../FROSch_BelosSolverEpetra_def.hpp | 16 +- .../FROSch_BelosSolverTpetra_decl.hpp | 4 +- .../FROSch_BelosSolverTpetra_def.hpp | 16 +- .../FROSch_FROSchPreconditioner_decl.hpp | 130 ++++++++++++ .../FROSch_FROSchPreconditioner_def.hpp | 199 ++++++++++++++++++ ...ROSch_Ifpack2PreconditionerTpetra_decl.hpp | 2 +- ...FROSch_Ifpack2PreconditionerTpetra_def.hpp | 12 +- .../FROSch_MueLuPreconditioner_decl.hpp | 129 ++++++++++++ .../FROSch_MueLuPreconditioner_def.hpp | 129 ++++++++++++ .../FROSch_SolverFactory_decl.hpp | 8 + .../FROSch_SolverFactory_def.hpp | 20 +- .../FROSch_ThyraPreconditioner_decl.hpp | 3 +- .../FROSch_ThyraPreconditioner_def.hpp | 10 +- .../FROSch_ThyraSolver_decl.hpp | 3 +- .../FROSch_ThyraSolver_def.hpp | 10 +- .../shylu_dd/frosch/src/Tools/FROSch_Output.h | 22 +- .../src/Tools/FROSch_SubdomainSolver_def.hpp | 100 ++++----- .../shylu_dd/frosch/src/Tools/FROSch_Timers.h | 12 +- .../frosch/src/Tools/FROSch_Tools_def.hpp | 20 +- .../frosch/test/SolverFactory/CMakeLists.txt | 129 +++++++++++- .../ParameterLists/CMakeLists.txt | 3 + ...onditioner_TwoLevelBlockPreconditioner.xml | 4 + ...hPreconditioner_TwoLevelPreconditioner.xml | 4 + .../ParameterLists/ParameterList_MueLu.xml | 3 + .../ParameterList_ThyraSolver_Belos_GMRES.xml | 10 - .../frosch/test/SolverFactory/main.cpp | 47 +++-- 52 files changed, 1047 insertions(+), 285 deletions(-) create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_decl.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_def.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_MueLuPreconditioner_decl.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_MueLuPreconditioner_def.hpp create mode 100644 packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelBlockPreconditioner.xml create mode 100644 packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelPreconditioner.xml create mode 100644 packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_MueLu.xml diff --git a/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchFactory_def.hpp b/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchFactory_def.hpp index eabdbfb8f29c..a224a59d70ad 100644 --- a/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchFactory_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchFactory_def.hpp @@ -272,7 +272,7 @@ namespace Thyra { } } - FROSCH_ASSERT(!repeatedMaps.is_null(),"FROSch::FROSchFactory : ERROR: repeatedMaps.is_null()"); + FROSCH_ASSERT(!repeatedMaps.is_null(),"FROSch::FROSchFactory: repeatedMaps.is_null()"); // Extract the DofsPerNode vector dofsPerNodeVector = ExtractVectorFromParameterList(*paramList_,"DofsPerNode Vector"); // Extract the DofOrdering vector @@ -295,7 +295,7 @@ namespace Thyra { SchwarzPreconditioner = TLBP; } else { - FROSCH_ASSERT(false,"Thyra::FROSchFactory : ERROR: Preconditioner Type is unknown."); + FROSCH_ASSERT(false,"Thyra::FROSchFactory: Preconditioner Type is unknown."); } SchwarzPreconditioner->compute(); @@ -344,7 +344,7 @@ namespace Thyra { TLBP->resetMatrix(A); SchwarzPreconditioner = TLBP; } else { - FROSCH_ASSERT(false,"Thyra::FROSchFactory : ERROR: Preconditioner Type is unknown."); + FROSCH_ASSERT(false,"Thyra::FROSchFactory: Preconditioner Type is unknown."); } // recompute SchwarzPreconditioner SchwarzPreconditioner->compute(); @@ -441,7 +441,7 @@ namespace Thyra { #endif } } - FROSCH_ASSERT(!repeatedMap.is_null(),"FROSch::FROSchFactory : ERROR: repeatedMap.is_null()"); + FROSCH_ASSERT(!repeatedMap.is_null(),"FROSch::FROSchFactory: repeatedMap.is_null()"); } return repeatedMap; } @@ -465,7 +465,7 @@ namespace Thyra { #endif } } - FROSCH_ASSERT(!coordinatesList.is_null(),"FROSch::FROSchFactory : ERROR: coordinatesList.is_null()"); + FROSCH_ASSERT(!coordinatesList.is_null(),"FROSch::FROSchFactory: coordinatesList.is_null()"); } return coordinatesList; } @@ -489,7 +489,7 @@ namespace Thyra { #endif } } - FROSCH_ASSERT(!nullSpaceBasis.is_null(),"FROSch::FROSchFactory : ERROR: nullSpaceBasis.is_null()"); + FROSCH_ASSERT(!nullSpaceBasis.is_null(),"FROSch::FROSchFactory: nullSpaceBasis.is_null()"); } return nullSpaceBasis; } diff --git a/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt b/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt index afc918414a63..3124043e43d3 100644 --- a/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt +++ b/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt @@ -116,12 +116,22 @@ APPEND_SET(HEADERS SchwarzPreconditioners/FROSch_TwoLevelBlockPreconditioner_def.hpp SchwarzPreconditioners/FROSch_TwoLevelPreconditioner_decl.hpp SchwarzPreconditioners/FROSch_TwoLevelPreconditioner_def.hpp + SolverInterfaces/FROSch_AmesosSolverEpetra_decl.hpp + SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp SolverInterfaces/FROSch_Amesos2SolverTpetra_decl.hpp SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp SolverInterfaces/FROSch_BelosSolverEpetra_decl.hpp SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp + SolverInterfaces/FROSch_BelosSolverTpetra_decl.hpp + SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp + SolverInterfaces/FROSch_FROSchPreconditioner_decl.hpp + SolverInterfaces/FROSch_FROSchPreconditioner_def.hpp + SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_decl.hpp + SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp + SolverInterfaces/FROSch_MueLuPreconditioner_decl.hpp + SolverInterfaces/FROSch_MueLuPreconditioner_def.hpp SolverInterfaces/FROSch_Solver_decl.hpp SolverInterfaces/FROSch_Solver_def.hpp SolverInterfaces/FROSch_SolverFactory_decl.hpp diff --git a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_CoarseSpace_def.hpp b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_CoarseSpace_def.hpp index fc6aa938f807..2b594688ee1c 100644 --- a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_CoarseSpace_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_CoarseSpace_def.hpp @@ -67,11 +67,11 @@ namespace FROSch { ConstXMultiVectorPtr subspaceBasis, UN offset) { - FROSCH_ASSERT(!subspaceBasisMap.is_null(),"FROSch::CoarseSpace : ERROR: subspaceBasisMap.is_null()"); + FROSCH_ASSERT(!subspaceBasisMap.is_null(),"FROSch::CoarseSpace: subspaceBasisMap.is_null()"); if (!subspaceBasis.is_null()) { - FROSCH_ASSERT(subspaceBasis->getNumVectors()==subspaceBasisMap->getNodeNumElements(),"FROSch::CoarseSpace : ERROR: subspaceBasis->getNumVectors()!=subspaceBasisMap->getNodeNumElements()"); + FROSCH_ASSERT(subspaceBasis->getNumVectors()==subspaceBasisMap->getNodeNumElements(),"FROSch::CoarseSpace: subspaceBasis->getNumVectors()!=subspaceBasisMap->getNodeNumElements()"); } else { - FROSCH_ASSERT(subspaceBasisMap->getNodeNumElements()==0,"FROSch::CoarseSpace : ERROR: subspaceBasisMap->getNodeNumElements()!=0"); + FROSCH_ASSERT(subspaceBasisMap->getNodeNumElements()==0,"FROSch::CoarseSpace: subspaceBasisMap->getNodeNumElements()!=0"); } UnassembledBasesMaps_.push_back(subspaceBasisMap); @@ -86,9 +86,9 @@ namespace FROSch { template int CoarseSpace::assembleCoarseSpace() { - FROSCH_ASSERT(UnassembledBasesMaps_.size()>0,"FROSch::CoarseSpace : ERROR: UnassembledBasesMaps_.size()==0"); - FROSCH_ASSERT(UnassembledBasesMapsUnique_.size()>0,"FROSch::CoarseSpace : ERROR: UnassembledBasesMapsUnique_.size()==0"); - FROSCH_ASSERT(UnassembledSubspaceBases_.size()>0,"FROSch::CoarseSpace : ERROR: UnassembledSubspaceBases_.size()==0"); + FROSCH_ASSERT(UnassembledBasesMaps_.size()>0,"FROSch::CoarseSpace: UnassembledBasesMaps_.size()==0"); + FROSCH_ASSERT(UnassembledBasesMapsUnique_.size()>0,"FROSch::CoarseSpace: UnassembledBasesMapsUnique_.size()==0"); + FROSCH_ASSERT(UnassembledSubspaceBases_.size()>0,"FROSch::CoarseSpace: UnassembledSubspaceBases_.size()==0"); UN itmp = 0; LOVecPtr2D partMappings; @@ -112,9 +112,9 @@ namespace FROSch { } else { AssembledBasisMapUnique_ = AssembleMaps(UnassembledBasesMapsUnique_(),partMappings); } - FROSCH_ASSERT(AssembledBasisMap_->getMaxAllGlobalIndex()==AssembledBasisMapUnique_->getMaxAllGlobalIndex(),"FROSch::CoarseSpace : ERROR: AssembledBasisMap_->getMaxAllGlobalIndex()!=AssembledBasisMapUnique_->getMaxAllGlobalIndex()"); - FROSCH_ASSERT(AssembledBasisMap_->getMinAllGlobalIndex()==AssembledBasisMapUnique_->getMinAllGlobalIndex(),"FROSch::CoarseSpace : ERROR: AssembledBasisMap_->getMinAllGlobalIndex()!=AssembledBasisMapUnique_->getMinAllGlobalIndex()"); - FROSCH_ASSERT(GO(AssembledBasisMapUnique_->getGlobalNumElements())==GO(AssembledBasisMapUnique_->getMaxAllGlobalIndex()+1),"FROSch::CoarseSpace : ERROR: AssembledBasisMapUnique_->getGlobalNumElements()!=(AssembledBasisMapUnique_->getMaxAllGlobalIndex()+1)"); + FROSCH_ASSERT(AssembledBasisMap_->getMaxAllGlobalIndex()==AssembledBasisMapUnique_->getMaxAllGlobalIndex(),"FROSch::CoarseSpace: AssembledBasisMap_->getMaxAllGlobalIndex()!=AssembledBasisMapUnique_->getMaxAllGlobalIndex()"); + FROSCH_ASSERT(AssembledBasisMap_->getMinAllGlobalIndex()==AssembledBasisMapUnique_->getMinAllGlobalIndex(),"FROSch::CoarseSpace: AssembledBasisMap_->getMinAllGlobalIndex()!=AssembledBasisMapUnique_->getMinAllGlobalIndex()"); + FROSCH_ASSERT(GO(AssembledBasisMapUnique_->getGlobalNumElements())==GO(AssembledBasisMapUnique_->getMaxAllGlobalIndex()+1),"FROSch::CoarseSpace: AssembledBasisMapUnique_->getGlobalNumElements()!=(AssembledBasisMapUnique_->getMaxAllGlobalIndex()+1)"); // Basis if (!AssembledBasisMap_.is_null()) { @@ -131,8 +131,8 @@ namespace FROSch { for (UN j=0; jgetNumVectors(); j++) { ConstSCVecPtr unassembledSubspaceBasesData = UnassembledSubspaceBases_[i]->getData(j); for (UN k=0; kgetLocalLength(); k++) { - FROSCH_ASSERT(itmpgetNumVectors(),"FROSch::CoarseSpace : ERROR: itmp>=AssembledBasis_->getNumVectors()"); - FROSCH_ASSERT(k+Offsets_[i]getLocalLength(),"FROSch::CoarseSpace : ERROR: k+Offsets_[i]>=AssembledBasis_->getLocalLength()"); + FROSCH_ASSERT(itmpgetNumVectors(),"FROSch::CoarseSpace: itmp>=AssembledBasis_->getNumVectors()"); + FROSCH_ASSERT(k+Offsets_[i]getLocalLength(),"FROSch::CoarseSpace: k+Offsets_[i]>=AssembledBasis_->getLocalLength()"); AssembledBasis_->replaceLocalValue(k+Offsets_[i],itmp,unassembledSubspaceBasesData[k]); } itmp++; @@ -168,8 +168,8 @@ namespace FROSch { ConstXMapPtr repeatedMap, SC treshold) { - FROSCH_ASSERT(!AssembledBasisMap_.is_null(),"FROSch::CoarseSpace : ERROR: AssembledBasisMap_.is_null()."); - FROSCH_ASSERT(!AssembledBasis_.is_null(),"FROSch::CoarseSpace : ERROR: AssembledBasis_.is_null()."); + FROSCH_ASSERT(!AssembledBasisMap_.is_null(),"FROSch::CoarseSpace: AssembledBasisMap_.is_null()."); + FROSCH_ASSERT(!AssembledBasis_.is_null(),"FROSch::CoarseSpace: AssembledBasis_.is_null()."); GlobalBasisMatrix_ = MatrixFactory::Build(rowMap,AssembledBasisMap_->getNodeNumElements()); // Nonzeroes abhängig von dim/dofs!!! @@ -223,7 +223,7 @@ namespace FROSch { template int CoarseSpace::zeroOutBasisVectors(ConstLOVecView zeros) { - FROSCH_ASSERT(!AssembledBasis_.is_null(),"FROSch::CoarseSpace : ERROR: AssembledBasis_.is_null()."); + FROSCH_ASSERT(!AssembledBasis_.is_null(),"FROSch::CoarseSpace: AssembledBasis_.is_null()."); for (UN j=0; jgetVectorNonConst(zeros[j])->scale(ScalarTraits::zero()); } @@ -245,7 +245,7 @@ namespace FROSch { template typename CoarseSpace::ConstXMapPtr CoarseSpace::getBasisMap() const { - FROSCH_ASSERT(!AssembledBasisMap_.is_null(),"FROSch::CoarseSpace : ERROR: AssembledBasisMap_.is_null()."); + FROSCH_ASSERT(!AssembledBasisMap_.is_null(),"FROSch::CoarseSpace: AssembledBasisMap_.is_null()."); return AssembledBasisMap_; } @@ -258,7 +258,7 @@ namespace FROSch { template typename CoarseSpace::ConstXMapPtr CoarseSpace::getBasisMapUnique() const { - FROSCH_ASSERT(!AssembledBasisMapUnique_.is_null(),"FROSch::CoarseSpace : ERROR: AssembledBasisMapUnique_.is_null()."); + FROSCH_ASSERT(!AssembledBasisMapUnique_.is_null(),"FROSch::CoarseSpace: AssembledBasisMapUnique_.is_null()."); return AssembledBasisMapUnique_; } @@ -271,7 +271,7 @@ namespace FROSch { template typename CoarseSpace::ConstXMultiVectorPtr CoarseSpace::getAssembledBasis() const { - FROSCH_ASSERT(!AssembledBasis_.is_null(),"FROSch::CoarseSpace : ERROR: AssembledBasis_.is_null()."); + FROSCH_ASSERT(!AssembledBasis_.is_null(),"FROSch::CoarseSpace: AssembledBasis_.is_null()."); return AssembledBasis_; } @@ -290,7 +290,7 @@ namespace FROSch { template typename CoarseSpace::XMatrixPtr CoarseSpace::getGlobalBasisMatrix() const { - FROSCH_ASSERT(!GlobalBasisMatrix_.is_null(),"FROSch::CoarseSpace : ERROR: GlobalBasisMatrix_.is_null()."); + FROSCH_ASSERT(!GlobalBasisMatrix_.is_null(),"FROSch::CoarseSpace: GlobalBasisMatrix_.is_null()."); return GlobalBasisMatrix_; } } diff --git a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_ConstantPartitionOfUnity_def.hpp b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_ConstantPartitionOfUnity_def.hpp index 3c5442bb765b..399f36e8b6ca 100644 --- a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_ConstantPartitionOfUnity_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_ConstantPartitionOfUnity_def.hpp @@ -74,7 +74,7 @@ namespace FROSch { } else if (!this->ParameterList_->get("Type","Full").compare("Custom")) { UseVolumes_ = this->ParameterList_->sublist("Custom").get("Volumes",false); } else { - FROSCH_ASSERT(false,"FROSch::ConstantPartitionOfUnity : ERROR: Specify a valid Type."); + FROSCH_ASSERT(false,"FROSch::ConstantPartitionOfUnity: Specify a valid Type."); } CommunicationStrategy communicationStrategy = CreateOneToOneMap; @@ -85,11 +85,11 @@ namespace FROSch { } else if (!this->ParameterList_->get("Interface Communication Strategy","CreateOneToOneMap").compare("CreateOneToOneMap")) { communicationStrategy = CreateOneToOneMap; } else { - FROSCH_ASSERT(false,"FROSch::InterfacePartitionOfUnity : ERROR: Specify a valid communication strategy for the identification of the interface components."); + FROSCH_ASSERT(false,"FROSch::InterfacePartitionOfUnity: Specify a valid communication strategy for the identification of the interface components."); } if (DDInterface_.is_null()) DDInterface_.reset(new DDInterface(dimension,dofsPerNode,nodesMap.getConst(),this->Verbosity_,this->LevelID_,communicationStrategy)); - FROSCH_ASSERT(DDInterface_->getInterface()->getEntity(0)->getNumNodes()==0,"FROSch::ConstantPartitionOfUnity : ERROR: Is only reasonable if there is no interface."); + FROSCH_ASSERT(DDInterface_->getInterface()->getEntity(0)->getNumNodes()==0,"FROSch::ConstantPartitionOfUnity: Is only reasonable if there is no interface."); DDInterface_->resetGlobalDofs(dofsMaps); Volumes_ = DDInterface_->getInterior()->deepCopy(); diff --git a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_GDSWInterfacePartitionOfUnity_def.hpp b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_GDSWInterfacePartitionOfUnity_def.hpp index d1fef98a8aeb..7fbd923498f0 100644 --- a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_GDSWInterfacePartitionOfUnity_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_GDSWInterfacePartitionOfUnity_def.hpp @@ -114,7 +114,7 @@ namespace FROSch { UseEdges_ = this->ParameterList_->sublist("Custom").get("Vertices",false); UseFaces_ = this->ParameterList_->sublist("Custom").get("Vertices",false); } else { - FROSCH_ASSERT(false,"FROSch::GDSWInterfacePartitionOfUnity : ERROR: Specify a valid Type."); + FROSCH_ASSERT(false,"FROSch::GDSWInterfacePartitionOfUnity: Specify a valid Type."); } this->LocalPartitionOfUnity_ = ConstXMultiVectorPtrVecPtr(5); this->PartitionOfUnityMaps_ = ConstXMapPtrVecPtr(5); diff --git a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_GDSWStarInterfacePartitionOfUnity_def.hpp b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_GDSWStarInterfacePartitionOfUnity_def.hpp index cb86bb31ea3f..47261f837c3a 100644 --- a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_GDSWStarInterfacePartitionOfUnity_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_GDSWStarInterfacePartitionOfUnity_def.hpp @@ -83,7 +83,7 @@ namespace FROSch { UseRoots_ = this->ParameterList_->sublist("Custom").get("Roots",false); UseLeafs_ = this->ParameterList_->sublist("Custom").get("Leafs",false); } else { - FROSCH_ASSERT(false,"FROSch::GDSWStarInterfacePartitionOfUnity : ERROR: Specify a valid Type."); + FROSCH_ASSERT(false,"FROSch::GDSWStarInterfacePartitionOfUnity: Specify a valid Type."); } if (!this->ParameterList_->get("Distance Function","Constant").compare("Constant")) { @@ -91,7 +91,7 @@ namespace FROSch { } else if (!this->ParameterList_->get("Distance Function","Constant").compare("Inverse Euclidean")) { DistanceFunction_ = InverseEuclideanDistanceFunction; } else { - FROSCH_ASSERT(false,"FROSch::GDSWStarInterfacePartitionOfUnity : ERROR: Specify a valid Distance Function."); + FROSCH_ASSERT(false,"FROSch::GDSWStarInterfacePartitionOfUnity: Specify a valid Distance Function."); } this->LocalPartitionOfUnity_ = ConstXMultiVectorPtrVecPtr(2); this->PartitionOfUnityMaps_ = ConstXMapPtrVecPtr(2); @@ -169,7 +169,7 @@ namespace FROSch { LO rootID = tmpEntity->getRootID(); UN numRoots = tmpEntity->getRoots()->getNumEntities(); if (rootID==-1) { - FROSCH_ASSERT(numRoots!=0,"FROSch::GDSWStarInterfacePartitionOfUnity : ERROR: rootID==-1 but numRoots==0!"); + FROSCH_ASSERT(numRoots!=0,"FROSch::GDSWStarInterfacePartitionOfUnity: rootID==-1 but numRoots==0!"); for (UN m=0; mgetRoots()->getEntity(m); LO index = tmpRoot->getRootID(); @@ -201,7 +201,7 @@ namespace FROSch { for (UN i=0; igetNumEntities(); i++) { InterfaceEntityPtr tmpEntity = Leafs_->getEntity(i); LO leafID = tmpEntity->getLeafID(); - FROSCH_ASSERT(leafID==LO(i),"FROSch::GDSWStarInterfacePartitionOfUnity : ERROR: leafID!=i!"); + FROSCH_ASSERT(leafID==LO(i),"FROSch::GDSWStarInterfacePartitionOfUnity: leafID!=i!"); for (UN j=0; jgetEntity(i)->getNumNodes(); j++) { for (UN k=0; kreplaceLocalValue(Leafs_->getEntity(i)->getGammaDofID(j,k),leafID,ScalarTraits::one()); diff --git a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_InterfacePartitionOfUnity_def.hpp b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_InterfacePartitionOfUnity_def.hpp index a5d2da8daa43..386bd78d0903 100644 --- a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_InterfacePartitionOfUnity_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_InterfacePartitionOfUnity_def.hpp @@ -71,7 +71,7 @@ namespace FROSch { } else if (!this->ParameterList_->get("Interface Communication Strategy","CreateOneToOneMap").compare("CreateOneToOneMap")) { communicationStrategy = CreateOneToOneMap; } else { - FROSCH_ASSERT(false,"FROSch::InterfacePartitionOfUnity : ERROR: Specify a valid communication strategy for the identification of the interface components."); + FROSCH_ASSERT(false,"FROSch::InterfacePartitionOfUnity: Specify a valid communication strategy for the identification of the interface components."); } DDInterface_.reset(new DDInterface(dimension,dofsPerNode,nodesMap.getConst(),this->Verbosity_,this->LevelID_,communicationStrategy)); diff --git a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_RGDSWInterfacePartitionOfUnity_def.hpp b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_RGDSWInterfacePartitionOfUnity_def.hpp index 848baf10533c..dd49079abc46 100644 --- a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_RGDSWInterfacePartitionOfUnity_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_RGDSWInterfacePartitionOfUnity_def.hpp @@ -77,7 +77,7 @@ namespace FROSch { } else if (!this->ParameterList_->get("Type","Full").compare("Custom")) { UseRoots_ = this->ParameterList_->sublist("Custom").get("Roots",false); } else { - FROSCH_ASSERT(false,"FROSch::RGDSWInterfacePartitionOfUnity : ERROR: Specify a valid Type."); + FROSCH_ASSERT(false,"FROSch::RGDSWInterfacePartitionOfUnity: Specify a valid Type."); } if (!this->ParameterList_->get("Distance Function","Constant").compare("Constant")) { @@ -85,7 +85,7 @@ namespace FROSch { } else if (!this->ParameterList_->get("Distance Function","Constant").compare("Inverse Euclidean")) { DistanceFunction_ = InverseEuclideanDistanceFunction; } else { - FROSCH_ASSERT(false,"FROSch::RGDSWInterfacePartitionOfUnity : ERROR: Specify a valid Distance Function."); + FROSCH_ASSERT(false,"FROSch::RGDSWInterfacePartitionOfUnity: Specify a valid Distance Function."); } this->LocalPartitionOfUnity_ = ConstXMultiVectorPtrVecPtr(1); this->PartitionOfUnityMaps_ = ConstXMapPtrVecPtr(1); diff --git a/packages/shylu/shylu_dd/frosch/src/InterfaceSets/FROSch_DDInterface_def.hpp b/packages/shylu/shylu_dd/frosch/src/InterfaceSets/FROSch_DDInterface_def.hpp index 5ac824fc6642..767ec0b9dab4 100644 --- a/packages/shylu/shylu_dd/frosch/src/InterfaceSets/FROSch_DDInterface_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/InterfaceSets/FROSch_DDInterface_def.hpp @@ -69,7 +69,7 @@ namespace FROSch { LevelID_ (levelID) { FROSCH_DETAILTIMER_START_LEVELID(dDInterfaceTime,"DDInterface::DDInterface"); - FROSCH_ASSERT(((Dimension_==2)||(Dimension_==3)),"FROSch::DDInterface : ERROR: Only dimension 2 and 3 are available"); + FROSCH_ASSERT(((Dimension_==2)||(Dimension_==3)),"FROSch::DDInterface: Only dimension 2 and 3 are available"); //if (Verbose_ && Verbosity_==All) cout << "FROSch::DDInterface" << endl; @@ -248,10 +248,10 @@ namespace FROSch { for (UN l=0; lgetNumEntities()==0,"FROSch::DDInterface : ERROR: This case is impossible."); + FROSCH_ASSERT(EntitySetVector_[l]->getNumEntities()==0,"FROSch::DDInterface: This case is impossible."); break; case 1: - FROSCH_ASSERT(EntitySetVector_[l]->getNumEntities()==0,"FROSch::DDInterface : ERROR: In this case, the entity is interior to the subdomain."); + FROSCH_ASSERT(EntitySetVector_[l]->getNumEntities()==0,"FROSch::DDInterface: In this case, the entity is interior to the subdomain."); break; case 2: for (UN i=0; igetNumEntities(); i++) { @@ -829,7 +829,7 @@ namespace FROSch { break; default: - FROSCH_ASSERT(false,"FROSch::DDInterface : ERROR: Specify a valid communication strategy."); + FROSCH_ASSERT(false,"FROSch::DDInterface: Specify a valid communication strategy."); break; } @@ -892,7 +892,7 @@ namespace FROSch { } interior->addNode(nodeIDI,nodeIDLocal,nodeIDGlobal,DofsPerNode_,dofsI,dofsLocal,dofsGlobal); } else { - FROSCH_ASSERT(componentsMultiplicity[localComponentIndices[i]]>1,"FROSch::DDInterface : ERROR: There cannot be any nodes with multiplicity 0."); + FROSCH_ASSERT(componentsMultiplicity[localComponentIndices[i]]>1,"FROSch::DDInterface: There cannot be any nodes with multiplicity 0."); LO nodeIDGamma = interface->getNumNodes(); LO nodeIDLocal = i; GO nodeIDGlobal = NodesMap_->getGlobalElement(nodeIDLocal); @@ -914,7 +914,7 @@ namespace FROSch { Interface_->addEntity(interface); for (UN i=0; i0,"FROSch::DDInterface : ERROR: There cannot be any component with multiplicity 0."); + FROSCH_ASSERT(componentsMultiplicity[i]>0,"FROSch::DDInterface: There cannot be any component with multiplicity 0."); RCP > tmpEntity(new InterfaceEntity(VertexType,DofsPerNode_,componentsMultiplicity[i],&(componentsSubdomainsUnique[i][0]))); LO nodeIDGamma; LO nodeIDLocal; diff --git a/packages/shylu/shylu_dd/frosch/src/InterfaceSets/FROSch_EntitySet_def.hpp b/packages/shylu/shylu_dd/frosch/src/InterfaceSets/FROSch_EntitySet_def.hpp index 94fb21c29de1..0f2049757827 100644 --- a/packages/shylu/shylu_dd/frosch/src/InterfaceSets/FROSch_EntitySet_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/InterfaceSets/FROSch_EntitySet_def.hpp @@ -75,7 +75,7 @@ namespace FROSch { template int EntitySet::addEntity(InterfaceEntityPtr entity) { - FROSCH_ASSERT(Type_==DefaultType||entity->getEntityType()==Type_,"FROSch::EntitySet : ERROR: Entity to add is of wrong type."); + FROSCH_ASSERT(Type_==DefaultType||entity->getEntityType()==Type_,"FROSch::EntitySet: Entity to add is of wrong type."); EntityVector_.push_back(entity); EntityMapIsUpToDate_ = false; return 0; @@ -175,11 +175,11 @@ namespace FROSch { for (UN i=0; ifindRoots(); if (tmpRoots.is_null()) { - FROSCH_ASSERT(getEntity(i)->getAncestors()->getNumEntities()==0,"FROSch::EntitySet : ERROR: getEntity(i)->getAncestors()->getNumEntities()!=0"); + FROSCH_ASSERT(getEntity(i)->getAncestors()->getNumEntities()==0,"FROSch::EntitySet: getEntity(i)->getAncestors()->getNumEntities()!=0"); Roots->addEntity(getEntity(i)); } else { - FROSCH_ASSERT(getEntity(i)->getAncestors()->getNumEntities()!=0,"FROSch::EntitySet : ERROR: getEntity(i)->getAncestors()->getNumEntities()==0"); - FROSCH_ASSERT(tmpRoots->getNumEntities()>0,"FROSch::EntitySet : ERROR: tmpRoots->getNumEntities()<=0"); + FROSCH_ASSERT(getEntity(i)->getAncestors()->getNumEntities()!=0,"FROSch::EntitySet: getEntity(i)->getAncestors()->getNumEntities()==0"); + FROSCH_ASSERT(tmpRoots->getNumEntities()>0,"FROSch::EntitySet: tmpRoots->getNumEntities()<=0"); Roots->addEntitySet(tmpRoots); } } @@ -290,7 +290,7 @@ namespace FROSch { int EntitySet::flagStraightEntities(UN dimension, ConstXMultiVectorPtr &nodeList) { - FROSCH_ASSERT(dimension==nodeList->getNumVectors(),"FROSch::EntitySet : ERROR: Inconsistent Dimension."); + FROSCH_ASSERT(dimension==nodeList->getNumVectors(),"FROSch::EntitySet: Inconsistent Dimension."); bool straight; LO length,j; @@ -353,7 +353,7 @@ namespace FROSch { template int EntitySet::removeEntity(UN iD) { - FROSCH_ASSERT(iD=getNumEntities()."); + FROSCH_ASSERT(iD=getNumEntities()."); EntityVector_.erase(EntityVector_.begin()+iD); EntityMapIsUpToDate_ = false; return 0; @@ -437,7 +437,7 @@ namespace FROSch { bool EntitySet::checkForStraightEdges(UN dimension, ConstXMultiVectorPtr &nodeList) { - FROSCH_ASSERT(dimension==nodeList->getNumVectors(),"FROSch::EntitySet : ERROR: Inconsistent Dimension."); + FROSCH_ASSERT(dimension==nodeList->getNumVectors(),"FROSch::EntitySet: Inconsistent Dimension."); bool straight; LO length,j; @@ -557,14 +557,14 @@ namespace FROSch { template const typename EntitySet::InterfaceEntityPtr EntitySet::getEntity(UN iD) const { - FROSCH_ASSERT(iD=getNumEntities()."); + FROSCH_ASSERT(iD=getNumEntities()."); return EntityVector_[iD]; } template const typename EntitySet::XMapPtr EntitySet::getEntityMap() const { - FROSCH_ASSERT(EntityMapIsUpToDate_,"FROSch::EntitySet : ERROR: the entity map has not been built or is not up to date."); + FROSCH_ASSERT(EntityMapIsUpToDate_,"FROSch::EntitySet: the entity map has not been built or is not up to date."); return EntityMap_; } @@ -573,7 +573,7 @@ namespace FROSch { ConstXMultiVectorPtr &nodeList, UN iD) const { - FROSCH_ASSERT(iD=getNumEntities()."); + FROSCH_ASSERT(iD=getNumEntities()."); if (getEntity(iD)->getEntityFlag()==StraightFlag) { @@ -608,7 +608,7 @@ namespace FROSch { j++; } - FROSCH_ASSERT(straight,"FROSch::EntitySet : ERROR: Edge is not straight!"); + FROSCH_ASSERT(straight,"FROSch::EntitySet: Edge is not straight!"); return dir1; @@ -616,7 +616,7 @@ namespace FROSch { int length = getEntity(iD)->getNumNodes(); - FROSCH_ASSERT(length==2,"FROSch::EntitySet : ERROR: Edge is not a short edge!"); + FROSCH_ASSERT(length==2,"FROSch::EntitySet: Edge is not a short edge!"); SCVec pt1(dimension); SCVecPtr dir1(dimension); @@ -632,7 +632,7 @@ namespace FROSch { return dir1; } else { - FROSCH_ASSERT(false,"FROSch::EntitySet : ERROR: There is a problem while computing the direction of an edge!"); + FROSCH_ASSERT(false,"FROSch::EntitySet: There is a problem while computing the direction of an edge!"); } } } diff --git a/packages/shylu/shylu_dd/frosch/src/InterfaceSets/FROSch_InterfaceEntity_def.hpp b/packages/shylu/shylu_dd/frosch/src/InterfaceSets/FROSch_InterfaceEntity_def.hpp index 1f6f6406bf91..b698ddc9fb0e 100644 --- a/packages/shylu/shylu_dd/frosch/src/InterfaceSets/FROSch_InterfaceEntity_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/InterfaceSets/FROSch_InterfaceEntity_def.hpp @@ -246,7 +246,7 @@ namespace FROSch { // this is offspring of each ancestor for (UN i=0; igetNumEntities(); i++) { InterfaceEntityPtr thisEntity = rcpFromRef(*this); - FROSCH_ASSERT(!thisEntity.is_null(),"FROSch::InterfaceEntity : ERROR: thisEntity.is_null()"); + FROSCH_ASSERT(!thisEntity.is_null(),"FROSch::InterfaceEntity: thisEntity.is_null()"); Ancestors_->getEntity(i)->addOffspring(thisEntity); } return 0; @@ -328,8 +328,8 @@ namespace FROSch { } break; case InverseEuclideanDistanceFunction: - FROSCH_ASSERT(!nodeList.is_null(),"FROSch::InterfaceEntity : ERROR: The inverse euclidean distance cannot be calculated without coordinates of the nodes!"); - FROSCH_ASSERT(dimension==nodeList->getNumVectors(),"FROSch::InterfaceEntity : ERROR: Inconsistent Dimension."); + FROSCH_ASSERT(!nodeList.is_null(),"FROSch::InterfaceEntity: The inverse euclidean distance cannot be calculated without coordinates of the nodes!"); + FROSCH_ASSERT(dimension==nodeList->getNumVectors(),"FROSch::InterfaceEntity: Inconsistent Dimension."); for (UN i=0; igetNumEntities(); i++) { for (UN j=0; jgetEntity(i)->getNumNodes(); j++) { // Coordinates of the nodes of the coarse node @@ -358,7 +358,7 @@ namespace FROSch { } break; default: - FROSCH_ASSERT(false,"FROSch::InterfaceEntity : ERROR: Specify a valid Distance Function."); + FROSCH_ASSERT(false,"FROSch::InterfaceEntity: Specify a valid Distance Function."); break; } diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_AlgebraicOverlappingOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_AlgebraicOverlappingOperator_def.hpp index c9728f62a135..b8fb721c5c76 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_AlgebraicOverlappingOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_AlgebraicOverlappingOperator_def.hpp @@ -64,7 +64,7 @@ namespace FROSch { } else if (!this->ParameterList_->get("Adding Layers Strategy","CrsGraph").compare("Old")) { AddingLayersStrategy_ = LayersOld; } else { - FROSCH_ASSERT(false,"FROSch::AlgebraicOverlappingOperator : ERROR: Specify a valid strategy for adding layers."); + FROSCH_ASSERT(false,"FROSch::AlgebraicOverlappingOperator: Specify a valid strategy for adding layers."); } } @@ -94,11 +94,11 @@ namespace FROSch { << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " << left << setw(41) << "Solver type" << right - << " | " << setw(41) << this->ParameterList_->sublist("Solver").get("SolverType","Amesos") + << " | " << setw(41) << this->ParameterList_->sublist("Solver").get("SolverType","Amesos2") << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " << left << setw(41) << "Solver" << right - << " | " << setw(41) << this->ParameterList_->sublist("Solver").get("Solver","Mumps") + << " | " << setw(41) << this->ParameterList_->sublist("Solver").get("Solver","Klu") << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " << left << setw(41) << "Reuse symbolic factorization" << right @@ -153,7 +153,7 @@ namespace FROSch { } else if (!this->ParameterList_->get("Verbosity","All").compare("All")) { verbosity = All; } else { - FROSCH_ASSERT(false,"FROSch::AlgebraicOverlappingOperator : ERROR: Specify a valid verbosity level."); + FROSCH_ASSERT(false,"FROSch::AlgebraicOverlappingOperator: Specify a valid verbosity level."); } // ==================================================================================== @@ -225,7 +225,7 @@ namespace FROSch { break; default: - FROSCH_ASSERT(false,"FROSch::AlgebraicOverlappingOperator : ERROR: Specify a valid strategy for adding layers."); + FROSCH_ASSERT(false,"FROSch::AlgebraicOverlappingOperator: Specify a valid strategy for adding layers."); break; } if (verbosity==All) { @@ -276,7 +276,7 @@ namespace FROSch { break; default: - FROSCH_ASSERT(false,"FROSch::AlgebraicOverlappingOperator : ERROR: Specify a valid strategy for adding layers."); + FROSCH_ASSERT(false,"FROSch::AlgebraicOverlappingOperator: Specify a valid strategy for adding layers."); break; } } diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_def.hpp index 5ff20dfd1fc8..92ad91eba4e3 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_def.hpp @@ -71,7 +71,7 @@ namespace FROSch { int CoarseOperator::compute() { FROSCH_TIMER_START_LEVELID(computeTime,"CoarseOperator::compute"); - FROSCH_ASSERT(this->IsInitialized_,"FROSch::CoarseOperator : ERROR: CoarseOperator has to be initialized before calling compute()"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::CoarseOperator: CoarseOperator has to be initialized before calling compute()"); // This is not optimal yet... Some work could be moved to Initialize //if (this->Verbose_) cout << "FROSch::CoarseOperator : WARNING: Some of the operations could probably be moved from initialize() to Compute().\n"; @@ -457,11 +457,11 @@ namespace FROSch { << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " << left << setw(41) << "Solver type" << right - << " | " << setw(41) << this->ParameterList_->sublist("CoarseSolver").get("SolverType","Amesos") + << " | " << setw(41) << this->ParameterList_->sublist("CoarseSolver").get("SolverType","Amesos2") << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " << left << setw(41) << "Solver" << right - << " | " << setw(41) << this->ParameterList_->sublist("CoarseSolver").get("Solver","Mumps") + << " | " << setw(41) << this->ParameterList_->sublist("CoarseSolver").get("Solver","Klu") << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " << left << setw(41) << "Reuse symbolic factorization" << right @@ -544,7 +544,7 @@ namespace FROSch { string("CoarseSolver (Level ") + to_string(this->LevelID_) + string(")"))); CoarseSolver_->initialize(); } else { - FROSCH_ASSERT(!CoarseSolver_.is_null(),"FROSch::CoarseOperator : ERROR: CoarseSolver_.is_null()"); + FROSCH_ASSERT(!CoarseSolver_.is_null(),"FROSch::CoarseOperator: CoarseSolver_.is_null()"); CoarseSolver_->resetMatrix(CoarseMatrix_.getConst(),true); } CoarseSolver_->compute(); @@ -865,7 +865,7 @@ namespace FROSch { ThrowErrorMissingPackage("FROSch::CoarseOperator","Zoltan2"); #endif } else { - FROSCH_ASSERT(false,"FROSch::CoarseOperator : ERROR: Distribution type unknown."); + FROSCH_ASSERT(false,"FROSch::CoarseOperator: Distribution type unknown."); } return 0; diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_GDSWCoarseOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_GDSWCoarseOperator_def.hpp index 85a62d9da395..c0bb5c01d11c 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_GDSWCoarseOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_GDSWCoarseOperator_def.hpp @@ -347,7 +347,7 @@ namespace FROSch { } else if (!coarseSpaceList->get("Interface Communication Strategy","CreateOneToOneMap").compare("CreateOneToOneMap")) { communicationStrategy = CreateOneToOneMap; } else { - FROSCH_ASSERT(false,"FROSch::GDSWCoarseOperator : ERROR: Specify a valid communication strategy for the identification of the interface components."); + FROSCH_ASSERT(false,"FROSch::GDSWCoarseOperator: Specify a valid communication strategy for the identification of the interface components."); } Verbosity verbosity = All; @@ -356,7 +356,7 @@ namespace FROSch { } else if (!coarseSpaceList->get("Verbosity","All").compare("All")) { verbosity = All; } else { - FROSCH_ASSERT(false,"FROSch::GDSWCoarseOperator : ERROR: Specify a valid verbosity level."); + FROSCH_ASSERT(false,"FROSch::GDSWCoarseOperator: Specify a valid verbosity level."); } bool useForCoarseSpace = coarseSpaceList->get("Use For Coarse Space",true); diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp index c5fcde5b184a..8a913f48043f 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp @@ -71,8 +71,8 @@ namespace FROSch { // Remove coupling blocks if (this->ParameterList_->get("Extensions: Remove Coupling",false)) { - FROSCH_ASSERT(this->ParameterList_->isParameter("Extensions: Coupling IDs to Remove"),"FROSch::HarmonicCoarseOperator : ERROR: Coupling IDs to remove are not specified (\"Extensions: Coupling IDs to Remove\")."); - //FROSCH_ASSERT(this->ParameterList_->isType("Extensions: Coupling IDs to Remove"),"FROSch::HarmonicCoarseOperator : ERROR: \"Extensions: Coupling IDs to Remove\" is not of type Teuchos::TwoDArray."); + FROSCH_ASSERT(this->ParameterList_->isParameter("Extensions: Coupling IDs to Remove"),"FROSch::HarmonicCoarseOperator: Coupling IDs to remove are not specified (\"Extensions: Coupling IDs to Remove\")."); + //FROSCH_ASSERT(this->ParameterList_->isType("Extensions: Coupling IDs to Remove"),"FROSch::HarmonicCoarseOperator: \"Extensions: Coupling IDs to Remove\" is not of type Teuchos::TwoDArray."); TwoDArray couplingIDsToRemove = this->ParameterList_->get("Extensions: Coupling IDs to Remove",TwoDArray(0,0,0)); repeatedMatrix = removeCouplingBetweenDofs(repeatedMatrix,repeatedMap,couplingIDsToRemove); @@ -128,7 +128,7 @@ namespace FROSch { for (UN i=0; ihasBasisMap()) { - FROSCH_ASSERT(InterfaceCoarseSpaces_[i]->hasBasisMapUnique(),"FROSch::HarmonicCoarseOperator : ERROR: !InterfaceCoarseSpaces_[i]->hasAssembledBasis()"); + FROSCH_ASSERT(InterfaceCoarseSpaces_[i]->hasBasisMapUnique(),"FROSch::HarmonicCoarseOperator: !InterfaceCoarseSpaces_[i]->hasAssembledBasis()"); this->AssembledInterfaceCoarseSpace_->addSubspace(InterfaceCoarseSpaces_[i]->getBasisMap(),InterfaceCoarseSpaces_[i]->getBasisMapUnique(),InterfaceCoarseSpaces_[i]->getAssembledBasis(),ii); } } @@ -332,8 +332,8 @@ namespace FROSch { UN discardRotations) { FROSCH_DETAILTIMER_START_LEVELID(computeRotationsTime,"HarmonicCoarseOperator::computeRotations"); - FROSCH_ASSERT(nodeList->getNumVectors()==dimension,"FROSch::HarmonicCoarseOperator : ERROR: Dimension of the nodeList is wrong."); - FROSCH_ASSERT(dimension==this->DofsPerNode_[blockId],"FROSch::HarmonicCoarseOperator : ERROR: Dimension!=this->DofsPerNode_[blockId]"); + FROSCH_ASSERT(nodeList->getNumVectors()==dimension,"FROSch::HarmonicCoarseOperator: Dimension of the nodeList is wrong."); + FROSCH_ASSERT(dimension==this->DofsPerNode_[blockId],"FROSch::HarmonicCoarseOperator: Dimension!=this->DofsPerNode_[blockId]"); UN rotationsPerEntity = 0; switch (dimension) { @@ -347,7 +347,7 @@ namespace FROSch { rotationsPerEntity = 3; break; default: - FROSCH_ASSERT(false,"FROSch::HarmonicCoarseOperator : ERROR: The dimension is neither 2 nor 3!"); + FROSCH_ASSERT(false,"FROSch::HarmonicCoarseOperator: The dimension is neither 2 nor 3!"); break; } @@ -448,7 +448,7 @@ namespace FROSch { err = errx[0]+erry[0]; err = ScalarTraits::squareroot(err); if (fabs(err)<1.0e-12) { - FROSCH_ASSERT(false,"FROSch::HarmonicCoarseOperator : ERROR: In 2D, no rotation can be constant!"); + FROSCH_ASSERT(false,"FROSch::HarmonicCoarseOperator: In 2D, no rotation can be constant!"); rotations[0]->getVectorNonConst(i)->scale(ScalarTraits::zero()); numZeroRotations++; } @@ -464,7 +464,7 @@ namespace FROSch { } break; default: - FROSCH_ASSERT(false,"FROSch::HarmonicCoarseOperator : ERROR: The dimension is neither 1 nor 2 nor 3!"); + FROSCH_ASSERT(false,"FROSch::HarmonicCoarseOperator: The dimension is neither 1 nor 2 nor 3!"); break; } // If necessary, discard additional rotations @@ -678,11 +678,11 @@ namespace FROSch { << setw(89) << "=========================================================================================" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " << left << setw(41) << "Solver type" << right - << " | " << setw(41) << this->ParameterList_->sublist("ExtensionSolver").get("SolverType","Amesos") + << " | " << setw(41) << this->ParameterList_->sublist("ExtensionSolver").get("SolverType","Amesos2") << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " << left << setw(41) << "Solver" << right - << " | " << setw(41) << this->ParameterList_->sublist("ExtensionSolver").get("Solver","Mumps") + << " | " << setw(41) << this->ParameterList_->sublist("ExtensionSolver").get("Solver","Klu") << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << setw(89) << "-----------------------------------------------------------------------------------------" @@ -750,7 +750,7 @@ namespace FROSch { LO itmp = 0; ConstUNVecView numLocalBlockColumns = AssembledInterfaceCoarseSpace_->getLocalSubspaceSizes(); - FROSCH_ASSERT(numLocalBlockColumns.size()==NumberOfBlocks_,"FROSch::HarmonicCoarseOperator : ERROR: numLocalBlockColumns.size()!=NumberOfBlocks_"); + FROSCH_ASSERT(numLocalBlockColumns.size()==NumberOfBlocks_,"FROSch::HarmonicCoarseOperator: numLocalBlockColumns.size()!=NumberOfBlocks_"); for (UN i=0; igetLocalSubspaceSizes(); - FROSCH_ASSERT(numLocalBlockRows.size()==NumberOfBlocks_,"FROSch::HarmonicCoarseOperator : ERROR: numLocalBlockRows.size()!=NumberOfBlocks_"); + FROSCH_ASSERT(numLocalBlockRows.size()==NumberOfBlocks_,"FROSch::HarmonicCoarseOperator: numLocalBlockRows.size()!=NumberOfBlocks_"); // Array > > mask(NumberOfBlocks_); // for (UN i=0; i(DofsPerNode_[i]*map->getNodeNumElements(),false); } - FROSCH_ASSERT(couplingIDsToRemove.getNumCols()==4,"FROSch::HarmonicCoarseOperator : ERROR: couplingIDsToRemove.getNumCols()!=4"); + FROSCH_ASSERT(couplingIDsToRemove.getNumCols()==4,"FROSch::HarmonicCoarseOperator: couplingIDsToRemove.getNumCols()!=4"); for (UN i=0; i=0,"FROSch::HarmonicCoarseOperator : ERROR: couplingIDsToRemove[i][0]<0"); - FROSCH_ASSERT(couplingIDsToRemove[i][1]>=0,"FROSch::HarmonicCoarseOperator : ERROR: couplingIDsToRemove[i][1]<0"); - FROSCH_ASSERT(couplingIDsToRemove[i][2]>=0,"FROSch::HarmonicCoarseOperator : ERROR: couplingIDsToRemove[i][2]<0"); - FROSCH_ASSERT(couplingIDsToRemove[i][3]>=0,"FROSch::HarmonicCoarseOperator : ERROR: couplingIDsToRemove[i][3]<0"); + FROSCH_ASSERT(couplingIDsToRemove[i][0]>=0,"FROSch::HarmonicCoarseOperator: couplingIDsToRemove[i][0]<0"); + FROSCH_ASSERT(couplingIDsToRemove[i][1]>=0,"FROSch::HarmonicCoarseOperator: couplingIDsToRemove[i][1]<0"); + FROSCH_ASSERT(couplingIDsToRemove[i][2]>=0,"FROSch::HarmonicCoarseOperator: couplingIDsToRemove[i][2]<0"); + FROSCH_ASSERT(couplingIDsToRemove[i][3]>=0,"FROSch::HarmonicCoarseOperator: couplingIDsToRemove[i][3]<0"); int blockID1 = couplingIDsToRemove[i][0]; int dofID1 = couplingIDsToRemove[i][1]; @@ -820,9 +820,9 @@ namespace FROSch { Array& tmpMask = mask[blockID1]; for (UN j=0; jgetNodeNumElements(); j++) { GO globalIndex = DofsMaps_[blockID2][dofID2]->getGlobalElement(j); - FROSCH_ASSERT(globalIndex>=0,"FROSch::HarmonicCoarseOperator : ERROR: globalIndex<0"); + FROSCH_ASSERT(globalIndex>=0,"FROSch::HarmonicCoarseOperator: globalIndex<0"); LO localIndex = map->getLocalElement(globalIndex); - FROSCH_ASSERT(localIndex>=0,"FROSch::HarmonicCoarseOperator : ERROR: localIndex<0"); + FROSCH_ASSERT(localIndex>=0,"FROSch::HarmonicCoarseOperator: localIndex<0"); //mask[blockID1]->replaceLocalValue(localIndex,dofID1,true); tmpMask[dofID1*map->getNodeNumElements()+localIndex] = true; } @@ -835,9 +835,9 @@ namespace FROSch { //ConstBoolVecPtr maskData = mask[i]->getData(j); for (UN k=0; kgetNodeNumElements(); k++) { GO globalIndex = DofsMaps_[i][j]->getGlobalElement(k); - FROSCH_ASSERT(globalIndex>=0,"FROSch::HarmonicCoarseOperator : ERROR: globalIndex<0"); + FROSCH_ASSERT(globalIndex>=0,"FROSch::HarmonicCoarseOperator: globalIndex<0"); LO localIndex = map->getLocalElement(globalIndex); - FROSCH_ASSERT(localIndex>=0,"FROSch::HarmonicCoarseOperator : ERROR: localIndex<0"); + FROSCH_ASSERT(localIndex>=0,"FROSch::HarmonicCoarseOperator: localIndex<0"); ArrayView indices; ArrayView values; diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_IPOUHarmonicCoarseOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_IPOUHarmonicCoarseOperator_def.hpp index c32d6a649454..62356b9bf772 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_IPOUHarmonicCoarseOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_IPOUHarmonicCoarseOperator_def.hpp @@ -259,7 +259,7 @@ namespace FROSch { } else if (!coarseSpaceList->get("Verbosity","All").compare("All")) { verbosity = All; } else { - FROSCH_ASSERT(false,"FROSch::IPOUHarmonicCoarseOperator : ERROR: Specify a valid verbosity level."); + FROSCH_ASSERT(false,"FROSch::IPOUHarmonicCoarseOperator: Specify a valid verbosity level."); } bool useForCoarseSpace = coarseSpaceList->get("Use For Coarse Space",true); diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_OverlappingOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_OverlappingOperator_def.hpp index f934cccc4e30..aeaf2129cf8f 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_OverlappingOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_OverlappingOperator_def.hpp @@ -82,7 +82,7 @@ namespace FROSch { SC beta) const { FROSCH_TIMER_START_LEVELID(applyTime,"OverlappingOperator::apply"); - FROSCH_ASSERT(this->IsComputed_,"FROSch::OverlappingOperator : ERROR: OverlappingOperator has to be computed before calling apply()"); + FROSCH_ASSERT(this->IsComputed_,"FROSch::OverlappingOperator: OverlappingOperator has to be computed before calling apply()"); if (XTmp_.is_null()) XTmp_ = MultiVectorFactory::Build(x.getMap(),x.getNumVectors()); *XTmp_ = x; if (!usePreconditionerOnly && mode == NO_TRANS) { @@ -216,7 +216,7 @@ namespace FROSch { string("Solver (Level ") + to_string(this->LevelID_) + string(")"))); SubdomainSolver_->initialize(); } else { - FROSCH_ASSERT(!SubdomainSolver_.is_null(),"FROSch::OverlappingOperator : ERROR: SubdomainSolver_.is_null()"); + FROSCH_ASSERT(!SubdomainSolver_.is_null(),"FROSch::OverlappingOperator: SubdomainSolver_.is_null()"); SubdomainSolver_->resetMatrix(OverlappingMatrix_,true); } this->IsComputed_ = true; diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_RGDSWCoarseOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_RGDSWCoarseOperator_def.hpp index 6f4b796fd19b..6752e5eb2dea 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_RGDSWCoarseOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_RGDSWCoarseOperator_def.hpp @@ -90,7 +90,7 @@ namespace FROSch { } else if (!coarseSpaceList->get("Interface Communication Strategy","CreateOneToOneMap").compare("CreateOneToOneMap")) { communicationStrategy = CreateOneToOneMap; } else { - FROSCH_ASSERT(false,"FROSch::RGDSWCoarseOperator : ERROR: Specify a valid communication strategy for the identification of the interface components."); + FROSCH_ASSERT(false,"FROSch::RGDSWCoarseOperator: Specify a valid communication strategy for the identification of the interface components."); } Verbosity verbosity = All; @@ -99,7 +99,7 @@ namespace FROSch { } else if (!coarseSpaceList->get("Verbosity","All").compare("All")) { verbosity = All; } else { - FROSCH_ASSERT(false,"FROSch::RGDSWCoarseOperator : ERROR: Specify a valid verbosity level."); + FROSCH_ASSERT(false,"FROSch::RGDSWCoarseOperator: Specify a valid verbosity level."); } bool useForCoarseSpace = coarseSpaceList->get("Use For Coarse Space",false); diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_TwoLevelBlockPreconditioner_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_TwoLevelBlockPreconditioner_def.hpp index f87853cfac4d..75e09abc6c24 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_TwoLevelBlockPreconditioner_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_TwoLevelBlockPreconditioner_def.hpp @@ -204,21 +204,20 @@ namespace FROSch { // Initialize CoarseOperator // /////////////////////////////// if (!this->ParameterList_->get("CoarseOperator Type","IPOUHarmonicCoarseOperator").compare("IPOUHarmonicCoarseOperator")) { - this->ParameterList_->sublist("IPOUHarmonicCoarseOperator").sublist("CoarseSolver").sublist("MueLu").set("Dimension",(int)dimension); // Build Null Space - if (!this->ParameterList_->get("Null Space Type","Stokes").compare("Stokes")) { + if (!this->ParameterList_->get("Null Space Type","Laplace").compare("Laplace")) { + nullSpaceBasisVec.resize(1); + nullSpaceBasisVec[0] = BuildNullSpace(dimension,LaplaceNullSpace,repeatedMapVec[0],dofsPerNodeVec[0],dofsMapsVec[0]); + } else if (!this->ParameterList_->get("Null Space Type","Laplace").compare("Stokes")) { nullSpaceBasisVec.resize(2); nullSpaceBasisVec[0] = BuildNullSpace(dimension,LaplaceNullSpace,repeatedMapVec[0],dofsPerNodeVec[0],dofsMapsVec[0]); nullSpaceBasisVec[1] = BuildNullSpace(dimension,LaplaceNullSpace,repeatedMapVec[1],dofsPerNodeVec[1],dofsMapsVec[1]); - } if (!this->ParameterList_->get("Null Space Type","Stokes").compare("Linear Elasticity")) { - nullSpaceBasisVec.resize(repeatedMapVec.size()); - for (int i = 0;iParameterList_->get("Null Space Type","Stokes").compare("Laplace")) { - nullSpaceBasisVec.resize(1); - nullSpaceBasisVec[0] = BuildNullSpace(dimension,LaplaceNullSpace,repeatedMapVec[0],dofsPerNodeVec[0],dofsMapsVec[0]); - }else if (!this->ParameterList_->get("Null Space Type","Stokes").compare("Input")) { + } else if (!this->ParameterList_->get("Null Space Type","Laplace").compare("Linear Elasticity")) { + nullSpaceBasisVec.resize(repeatedMapVec.size()); + for (int i = 0;iParameterList_->get("Null Space Type","Laplace").compare("Input")) { FROSCH_ASSERT(!nullSpaceBasisVec.is_null(),"Null Space Type is 'Input', but nullSpaceBasis.is_null()."); } else { FROSCH_ASSERT(false,"Null Space Type unknown."); @@ -230,13 +229,11 @@ namespace FROSch { this->ParameterList_->sublist("GDSWCoarseOperator").sublist("CoarseSolver").sublist("MueLu").set("Dimension",(int)dimension); GDSWCoarseOperatorPtr gDSWCoarseOperator = rcp_static_cast >(CoarseOperator_); if (0>gDSWCoarseOperator->initialize(dimension,dofsPerNodeVec,repeatedNodesMapVec,dofsMapsVec,dirichletBoundaryDofsVec,nodeListVec)) ret -=10; - } - else if (!this->ParameterList_->get("CoarseOperator Type","IPOUHarmonicCoarseOperator").compare("RGDSWCoarseOperator")) { + } else if (!this->ParameterList_->get("CoarseOperator Type","IPOUHarmonicCoarseOperator").compare("RGDSWCoarseOperator")) { this->ParameterList_->sublist("RGDSWCoarseOperator").sublist("CoarseSolver").sublist("MueLu").set("Dimension",(int)dimension); RGDSWCoarseOperatorPtr rGDSWCoarseOperator = rcp_static_cast >(CoarseOperator_); if (0>rGDSWCoarseOperator->initialize(dimension,dofsPerNodeVec,repeatedNodesMapVec,dofsMapsVec,dirichletBoundaryDofsVec,nodeListVec)) ret -=10; - } - else { + } else { FROSCH_ASSERT(false,"CoarseOperator Type unkown."); } return ret; diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp index 88a4905288bc..2f7293ac9e64 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_decl.hpp @@ -123,7 +123,7 @@ namespace FROSch { mutable XMultiVectorPtr Y_ = null; - Amesos2SolverEpetraPtr Amesos2Solver_; + Amesos2SolverEpetraPtr Amesos2Solver_ = null; friend class SolverFactory; }; diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp index 805c102d6de0..59c284156a37 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp @@ -71,7 +71,7 @@ namespace FROSch { int Amesos2SolverEpetra::compute() { FROSCH_TIMER_START_SOLVER(computeTime,"Amesos2SolverEpetra::compute"); - FROSCH_ASSERT(this->IsInitialized_,"FROSch::Amesos2SolverEpetra : ERROR: !this->IsInitialized_"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::Amesos2SolverEpetra: !this->IsInitialized_"); this->IsComputed_ = true; Amesos2Solver_->numericFactorization(); return 0; @@ -85,7 +85,7 @@ namespace FROSch { SC beta) const { FROSCH_TIMER_START_SOLVER(applyTime,"Amesos2SolverEpetra::apply"); - FROSCH_ASSERT(this->IsComputed_,"FROSch::Amesos2SolverEpetra : ERROR: !this->IsComputed_."); + FROSCH_ASSERT(this->IsComputed_,"FROSch::Amesos2SolverEpetra: !this->IsComputed_."); const EpetraMultiVectorT * xEpetraMultiVectorX = dynamic_cast *>(&x); RCP epetraMultiVectorX = xEpetraMultiVectorX->getEpetra_MultiVector(); @@ -97,7 +97,7 @@ namespace FROSch { Amesos2Solver_->setX(epetraMultiVectorY); Amesos2Solver_->setB(epetraMultiVectorX); - FROSCH_ASSERT(mode==NO_TRANS,"FROSch::Amesos2SolverEpetra : ERROR: mode!=NO_TRANS"); + FROSCH_ASSERT(mode==NO_TRANS,"FROSch::Amesos2SolverEpetra: mode!=NO_TRANS"); Amesos2Solver_->solve(); // Was ist, wenn man mit der transponierten Matrix lösen will y.update(alpha,*Y_,beta); @@ -109,7 +109,7 @@ namespace FROSch { { FROSCH_TIMER_START_SOLVER(updateMatrixTime,"Amesos2SolverEpetra::updateMatrix"); this->K_ = k; - FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverEpetra : ERROR: K_ is null."); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverEpetra: K_ is null."); const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); const EpetraCrsMatrixT& xEpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); @@ -131,8 +131,8 @@ namespace FROSch { Solver (k,parameterList,description) { FROSCH_TIMER_START_SOLVER(Amesos2SolverEpetraTime,"Amesos2SolverEpetra::Amesos2SolverEpetra"); - FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseEpetra,"FROSch::Amesos2SolverEpetra : ERROR: Not compatible with Tpetra.") - FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverEpetra : ERROR: K_ is null."); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverEpetra: K_ is null."); + FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseEpetra,"FROSch::Amesos2SolverEpetra: Not compatible with Tpetra.") const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); const EpetraCrsMatrixT& xEpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); @@ -143,7 +143,7 @@ namespace FROSch { EMultiVectorPtr bTmp; Amesos2Solver_ = Amesos2::create(this->ParameterList_->get("Solver","Klu"),epetraMat,xTmp,bTmp); - ParameterListPtr amesos2ParameterList = sublist(this->ParameterList_,"Amesos2"); + ParameterListPtr amesos2ParameterList = sublist(sublist(this->ParameterList_,"Amesos2"),this->ParameterList_->get("Solver","Klu")); amesos2ParameterList->setName("Amesos2"); Amesos2Solver_->setParameters(amesos2ParameterList); } diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_decl.hpp index 4a3d96f939bc..7bfb1fe39b6e 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_decl.hpp @@ -121,7 +121,7 @@ namespace FROSch { mutable XMultiVectorPtr Y_ = null; - Amesos2SolverTpetraPtr Amesos2Solver_; + Amesos2SolverTpetraPtr Amesos2Solver_ = null; friend class SolverFactory; }; diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp index 9c3081d32aaa..bbd6dd671150 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp @@ -71,7 +71,7 @@ namespace FROSch { int Amesos2SolverTpetra::compute() { FROSCH_TIMER_START_SOLVER(computeTime,"Amesos2SolverTpetra::compute"); - FROSCH_ASSERT(this->IsInitialized_,"FROSch::Amesos2SolverTpetra : ERROR: !this->IsInitialized_"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::Amesos2SolverTpetra: !this->IsInitialized_"); this->IsComputed_ = true; Amesos2Solver_->numericFactorization(); return 0; @@ -85,7 +85,7 @@ namespace FROSch { SC beta) const { FROSCH_TIMER_START_SOLVER(applyTime,"Amesos2SolverTpetra::apply"); - FROSCH_ASSERT(this->IsComputed_,"FROSch::Amesos2SolverTpetra : ERROR: !this->IsComputed_."); + FROSCH_ASSERT(this->IsComputed_,"FROSch::Amesos2SolverTpetra: !this->IsComputed_."); const TpetraMultiVector * xTpetraMultiVectorX = dynamic_cast *>(&x); TMultiVectorPtr tpetraMultiVectorX = xTpetraMultiVectorX->getTpetra_MultiVector(); @@ -97,7 +97,7 @@ namespace FROSch { Amesos2Solver_->setX(tpetraMultiVectorY); Amesos2Solver_->setB(tpetraMultiVectorX); - FROSCH_ASSERT(mode==NO_TRANS,"FROSch::Amesos2SolverTpetra : ERROR: mode!=NO_TRANS"); + FROSCH_ASSERT(mode==NO_TRANS,"FROSch::Amesos2SolverTpetra: mode!=NO_TRANS"); Amesos2Solver_->solve(); // Was ist, wenn man mit der transponierten Matrix lösen will y.update(alpha,*Y_,beta); @@ -109,7 +109,7 @@ namespace FROSch { { FROSCH_TIMER_START_SOLVER(updateMatrixTime,"Amesos2SolverTpetra::updateMatrix"); this->K_ = k; - FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverTpetra : ERROR: K_ is null."); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverTpetra: K_ is null."); const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); const TpetraCrsMatrix& xTpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); @@ -131,8 +131,8 @@ namespace FROSch { Solver (k,parameterList,description) { FROSCH_TIMER_START_SOLVER(Amesos2SolverTpetraTime,"Amesos2SolverTpetra::Amesos2SolverTpetra"); - FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseTpetra,"FROSch::Amesos2SolverTpetra : ERROR: Not compatible with Epetra.") - FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverTpetra : ERROR: K_ is null."); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverTpetra: K_ is null."); + FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseTpetra,"FROSch::Amesos2SolverTpetra: Not compatible with Epetra.") const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); const TpetraCrsMatrix& xTpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); @@ -143,7 +143,7 @@ namespace FROSch { TMultiVectorPtr bTmp; Amesos2Solver_ = Amesos2::create(this->ParameterList_->get("Solver","Klu"),tpetraMat,xTmp,bTmp); - ParameterListPtr amesos2ParameterList = sublist(this->ParameterList_,"Amesos2"); + ParameterListPtr amesos2ParameterList = sublist(sublist(this->ParameterList_,"Amesos2"),this->ParameterList_->get("Solver","Klu")); amesos2ParameterList->setName("Amesos2"); Amesos2Solver_->setParameters(amesos2ParameterList); } diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_decl.hpp index d4765adcbbb9..293daf9ba164 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_decl.hpp @@ -128,9 +128,9 @@ namespace FROSch { mutable XMultiVectorPtr Y_ = null; - AmesosSolverPtr AmesosSolver_; + AmesosSolverPtr AmesosSolver_ = null; - ELinearProblemPtr EpetraLinearProblem_; + ELinearProblemPtr EpetraLinearProblem_ = null; friend class SolverFactory; }; diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp index 0079308695f2..79ef54f60c37 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp @@ -72,7 +72,7 @@ namespace FROSch { int AmesosSolverEpetra::compute() { FROSCH_TIMER_START_SOLVER(computeTime,"AmesosSolverEpetra::compute"); - FROSCH_ASSERT(this->IsInitialized_,"FROSch::AmesosSolverEpetra : ERROR: !this->IsInitialized_"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::AmesosSolverEpetra: !this->IsInitialized_"); this->IsComputed_ = true; AMESOS_CHK_ERR(AmesosSolver_->NumericFactorization()); return 0; @@ -86,7 +86,7 @@ namespace FROSch { SC beta) const { FROSCH_TIMER_START_SOLVER(applyTime,"AmesosSolverEpetra::apply"); - FROSCH_ASSERT(this->IsComputed_,"FROSch::AmesosSolverEpetra : ERROR: !this->IsComputed_."); + FROSCH_ASSERT(this->IsComputed_,"FROSch::AmesosSolverEpetra: !this->IsComputed_."); const EpetraMultiVectorT * xEpetraMultiVectorX = dynamic_cast *>(&x); RCP epetraMultiVectorX = xEpetraMultiVectorX->getEpetra_MultiVector(); @@ -98,7 +98,7 @@ namespace FROSch { EpetraLinearProblem_->SetLHS(epetraMultiVectorY.get()); EpetraLinearProblem_->SetRHS(epetraMultiVectorX.get()); - FROSCH_ASSERT(mode==NO_TRANS,"FROSch::AmesosSolverEpetra : ERROR: mode!=NO_TRANS"); + FROSCH_ASSERT(mode==NO_TRANS,"FROSch::AmesosSolverEpetra: mode!=NO_TRANS"); EpetraLinearProblem_->GetMatrix()->SetUseTranspose(mode==TRANS); AmesosSolver_->Solve(); @@ -109,7 +109,7 @@ namespace FROSch { int AmesosSolverEpetra::updateMatrix(ConstXMatrixPtr k, bool reuseInitialize) { - FROSCH_ASSERT(false,"FROSch::AmesosSolverEpetra : ERROR: updateMatrix() is not implemented for the AmesosSolverEpetra yet."); + FROSCH_ASSERT(false,"FROSch::AmesosSolverEpetra: updateMatrix() is not implemented for the AmesosSolverEpetra yet."); return 0; } @@ -120,8 +120,8 @@ namespace FROSch { Solver (k,parameterList,description) { FROSCH_TIMER_START_SOLVER(AmesosSolverEpetraTime,"AmesosSolverEpetra::AmesosSolverEpetra"); - FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseEpetra,"FROSch::AmesosSolverEpetra : ERROR: Not compatible with Tpetra.") - FROSCH_ASSERT(!this->K_.is_null(),"FROSch::AmesosSolverEpetra : ERROR: K_ is null."); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::AmesosSolverEpetra: K_ is null."); + FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseEpetra,"FROSch::AmesosSolverEpetra: Not compatible with Tpetra.") const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); const EpetraCrsMatrixT& xEpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); @@ -135,7 +135,9 @@ namespace FROSch { Amesos amesosFactory; AmesosSolver_.reset(amesosFactory.Create(this->ParameterList_->get("Solver","Klu"),*EpetraLinearProblem_)); - AmesosSolver_->SetParameters(this->ParameterList_->sublist("Amesos")); + + ParameterListPtr amesosParameterList = sublist(sublist(this->ParameterList_,"Amesos"),this->ParameterList_->get("Solver","Klu")); + AmesosSolver_->SetParameters(*amesosParameterList); } } diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_decl.hpp index 292b1b1221e9..1d0cf08ae0ba 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_decl.hpp @@ -131,9 +131,9 @@ namespace FROSch { mutable XMultiVectorPtr Y_ = null; - BelosLinearProblemPtr BelosLinearProblem_; + BelosLinearProblemPtr BelosLinearProblem_ = null; - BelosSolverManagerPtr BelosSolver_; + BelosSolverManagerPtr BelosSolver_ = null; friend class SolverFactory; }; diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp index 3495870c0aff..5bcb93453d43 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp @@ -64,7 +64,7 @@ namespace FROSch { int BelosSolverEpetra::compute() { FROSCH_TIMER_START_SOLVER(computeTime,"BelosSolverEpetra::compute"); - FROSCH_ASSERT(this->IsInitialized_,"FROSch::BelosSolverEpetra : ERROR: !this->IsInitialized_"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::BelosSolverEpetra: !this->IsInitialized_"); this->IsComputed_ = true; return 0; } @@ -77,7 +77,7 @@ namespace FROSch { SC beta) const { FROSCH_TIMER_START_SOLVER(applyTime,"BelosSolverEpetra::apply"); - FROSCH_ASSERT(this->IsComputed_,"FROSch::BelosSolverEpetra : ERROR: !this->IsComputed_."); + FROSCH_ASSERT(this->IsComputed_,"FROSch::BelosSolverEpetra: !this->IsComputed_."); const EpetraMultiVectorT * xEpetraMultiVectorX = dynamic_cast *>(&x); RCP epetraMultiVectorX = xEpetraMultiVectorX->getEpetra_MultiVector(); @@ -98,7 +98,7 @@ namespace FROSch { { FROSCH_TIMER_START_SOLVER(updateMatrixTime,"BelosSolverEpetra::updateMatrix"); this->K_ = k; - FROSCH_ASSERT(!this->K_.is_null(),"FROSch::BelosSolverEpetra : ERROR: K_ is null."); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::BelosSolverEpetra: K_ is null."); const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); const EpetraCrsMatrixT& xEpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); @@ -117,8 +117,8 @@ namespace FROSch { Solver (k,parameterList,description) { FROSCH_TIMER_START_SOLVER(BelosSolverEpetraTime,"BelosSolverEpetra::BelosSolverEpetra"); - FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseEpetra,"FROSch::BelosSolverEpetra : ERROR: Not compatible with Tpetra.") - FROSCH_ASSERT(!this->K_.is_null(),"FROSch::BelosSolverEpetra : ERROR: K_ is null."); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::BelosSolverEpetra: K_ is null."); + FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseEpetra,"FROSch::BelosSolverEpetra: Not compatible with Tpetra.") const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); const EpetraCrsMatrixT& xEpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); @@ -131,10 +131,8 @@ namespace FROSch { BelosLinearProblem_.reset(new BelosLinearProblem(epetraMat,xTmp,bTmp)); BelosSolverFactory belosFactory; - ParameterListPtr solverParameterList = sublist(this->ParameterList_,"Belos"); - - BelosSolver_ = belosFactory.create(solverParameterList->get("Solver","GMRES"),sublist(solverParameterList,solverParameterList->get("Solver","GMRES"))); - + ParameterListPtr belosParameterList = sublist(sublist(this->ParameterList_,"Belos"),this->ParameterList_->get("Solver","GMRES")); + BelosSolver_ = belosFactory.create(this->ParameterList_->get("Solver","GMRES"),belosParameterList); BelosSolver_->setProblem(BelosLinearProblem_); } diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_decl.hpp index 191ef55f3ad1..67b989fd8864 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_decl.hpp @@ -129,9 +129,9 @@ namespace FROSch { mutable XMultiVectorPtr Y_ = null; - BelosLinearProblemPtr BelosLinearProblem_; + BelosLinearProblemPtr BelosLinearProblem_ = null; - BelosSolverManagerPtr BelosSolver_; + BelosSolverManagerPtr BelosSolver_ = null; friend class SolverFactory; }; diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp index a2fcca011b58..ebc496481518 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp @@ -64,7 +64,7 @@ namespace FROSch { int BelosSolverTpetra::compute() { FROSCH_TIMER_START_SOLVER(computeTime,"BelosSolverTpetra::compute"); - FROSCH_ASSERT(this->IsInitialized_,"FROSch::BelosSolverTpetra : ERROR: !this->IsInitialized_"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::BelosSolverTpetra: !this->IsInitialized_"); this->IsComputed_ = true; return 0; } @@ -77,7 +77,7 @@ namespace FROSch { SC beta) const { FROSCH_TIMER_START_SOLVER(applyTime,"BelosSolverTpetra::apply"); - FROSCH_ASSERT(this->IsComputed_,"FROSch::BelosSolverTpetra : ERROR: !this->IsComputed_."); + FROSCH_ASSERT(this->IsComputed_,"FROSch::BelosSolverTpetra: !this->IsComputed_."); const TpetraMultiVector * xTpetraMultiVectorX = dynamic_cast *>(&x); TMultiVectorPtr tpetraMultiVectorX = xTpetraMultiVectorX->getTpetra_MultiVector(); @@ -98,7 +98,7 @@ namespace FROSch { { FROSCH_TIMER_START_SOLVER(updateMatrixTime,"BelosSolverTpetra::updateMatrix"); this->K_ = k; - FROSCH_ASSERT(!this->K_.is_null(),"FROSch::BelosSolverTpetra : ERROR: K_ is null."); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::BelosSolverTpetra: K_ is null."); const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); const TpetraCrsMatrix& xTpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); @@ -117,8 +117,8 @@ namespace FROSch { Solver (k,parameterList,description) { FROSCH_TIMER_START_SOLVER(BelosSolverTpetraTime,"BelosSolverTpetra::BelosSolverTpetra"); - FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseTpetra,"FROSch::BelosSolverTpetra : ERROR: Not compatible with Epetra.") - FROSCH_ASSERT(!this->K_.is_null(),"FROSch::BelosSolverTpetra : ERROR: K_ is null."); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::BelosSolverTpetra: K_ is null."); + FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseTpetra,"FROSch::BelosSolverTpetra: Not compatible with Epetra.") const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); const TpetraCrsMatrix& xTpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); @@ -131,10 +131,8 @@ namespace FROSch { BelosLinearProblem_.reset(new BelosLinearProblem(tpetraMat,xTmp,bTmp)); BelosSolverFactory belosFactory; - ParameterListPtr solverParameterList = sublist(this->ParameterList_,"Belos"); - - BelosSolver_ = belosFactory.create(solverParameterList->get("Solver","GMRES"),sublist(solverParameterList,solverParameterList->get("Solver","GMRES"))); - + ParameterListPtr belosParameterList = sublist(sublist(this->ParameterList_,"Belos"),this->ParameterList_->get("Solver","GMRES")); + BelosSolver_ = belosFactory.create(this->ParameterList_->get("Solver","GMRES"),belosParameterList); BelosSolver_->setProblem(BelosLinearProblem_); } diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_decl.hpp new file mode 100644 index 000000000000..6ffa4b0cbd4d --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_decl.hpp @@ -0,0 +1,130 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_FROSCHPRECONDITIONER_DECL_HPP +#define _FROSCH_FROSCHPRECONDITIONER_DECL_HPP + +#include + +// FROSch +#include +#include +#include + + +namespace FROSch { + + using namespace Teuchos; + using namespace Xpetra; + + template + class FROSchPreconditioner : public Solver { + + protected: + + // Xpetra + using ConstXMatrixPtr = typename Solver::ConstXMatrixPtr; + + using XMultiVector = MultiVector; + using ConstXMultiVector = const MultiVector; + using XMultiVectorPtr = RCP; + using ConstXMultiVectorPtr = RCP; + using ConstXMultiVectorPtrVecPtr = ArrayRCP; + + using XMultiVectorFactory = typename Solver::XMultiVectorFactory; + + // Teuchos + using ParameterListPtr = typename Solver::ParameterListPtr; + + // FROSch + using SchwarzPreconditionerPtr = RCP >; + using TwoLevelBlockPreconditionerPtr = RCP >; + using TwoLevelPreconditionerPtr = RCP >; + + using UN = unsigned; + using UNVec = Array; + using UNVecPtr = ArrayRCP; + + using GOVecPtr = ArrayRCP; + + public: + + //! Initialize the internal solver + virtual int initialize(); + + //! Compute the internal solver + virtual int compute(); + + /*! + \brief Computes the operator-multivector application. + + Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + \beta \cdot Y\f$. However, the details of operation + vary according to the values of \c alpha and \c beta. Specifically + - if beta == 0, apply() must overwrite \c Y, so that any values in \c Y (including NaNs) are ignored. + - if alpha == 0, apply() may short-circuit the operator, so that any values in \c X (including NaNs) are ignored. + */ + void apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode=NO_TRANS, + SC alpha=ScalarTraits::one(), + SC beta=ScalarTraits::zero()) const; + + int updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize=false); + + protected: + + //! Constructor + FROSchPreconditioner(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description); + + SchwarzPreconditionerPtr FROSchPreconditioner_ = null; + + friend class SolverFactory; + }; + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_def.hpp new file mode 100644 index 000000000000..549aa75c07c2 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_def.hpp @@ -0,0 +1,199 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_FROSCHPRECONDITIONER_DEF_HPP +#define _FROSCH_FROSCHPRECONDITIONER_DEF_HPP + +#include + + +namespace FROSch { + + using namespace std; + using namespace Teuchos; + using namespace Xpetra; + + template + int FROSchPreconditioner::initialize() + { + FROSCH_TIMER_START_SOLVER(initializeTime,"FROSchPreconditioner::initialize"); + this->IsInitialized_ = true; + this->IsComputed_ = false; + return 0; + } + + template + int FROSchPreconditioner::compute() + { + FROSCH_TIMER_START_SOLVER(computeTime,"FROSchPreconditioner::compute"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::FROSchPreconditioner: !this->IsInitialized_"); + this->IsComputed_ = true; + FROSchPreconditioner_->compute(); + return 0; + } + + template + void FROSchPreconditioner::apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode, + SC alpha, + SC beta) const + { + FROSCH_TIMER_START_SOLVER(applyTime,"FROSchPreconditioner::apply"); + FROSCH_ASSERT(this->IsComputed_,"FROSch::FROSchPreconditioner: !this->IsComputed_."); + + FROSchPreconditioner_->apply(x,y,mode,alpha,beta); + } + + template + int FROSchPreconditioner::updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize) + { + FROSCH_ASSERT(false,"FROSch::FROSchPreconditioner: updateMatrix() is not implemented for the FROSchPreconditioner yet."); + return 0; + } + + template + FROSchPreconditioner::FROSchPreconditioner(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description) : + Solver (k,parameterList,description) + { + FROSCH_TIMER_START_SOLVER(FROSchPreconditionerTime,"FROSchPreconditioner::FROSchPreconditioner"); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::FROSchPreconditioner: K_ is null."); + + if (!this->ParameterList_->get("Solver","TwoLevelPreconditioner").compare("TwoLevelPreconditioner")) { + ParameterListPtr froschParameterList = sublist(sublist(this->ParameterList_,"FROSchPreconditioner"),this->ParameterList_->get("Solver","TwoLevelPreconditioner")); + // if (this->K_->getMap()->getComm()->getRank() == 0) froschParameterList->print(cout); + + ArrayRCP > > RepeatedMaps(1); + ArrayRCP > > NodesMaps(1); + + UNVecPtr dofsPerNodeVector(1); + ArrayRCP dofOrderings(1); + ArrayRCP > > > dofsMapsVec(1); + ArrayRCP > > MainCoarseMapVector(1); + + if (froschParameterList->isParameter("Repeated Map Vector")) { + RepeatedMaps = ExtractVectorFromParameterList > >(*froschParameterList,"Repeated Map Vector"); + } + + if (froschParameterList->isParameter("Nodes Map Vector")) { + NodesMaps = ExtractVectorFromParameterList > >(*froschParameterList,"Nodes Map Vector"); + } + + if (froschParameterList->isParameter("DofsPerNode Vector")) { + dofsPerNodeVector = ExtractVectorFromParameterList(*froschParameterList,"DofsPerNode Vector"); + } + + if (froschParameterList->isParameter("DofOrdering Vector")) { + dofOrderings = ExtractVectorFromParameterList(*froschParameterList,"DofOrdering Vector"); + } + + if (froschParameterList->isParameter("Main Map Vector")) { + MainCoarseMapVector = ExtractVectorFromParameterList > >(*froschParameterList,"Main Map Vector"); + } + if (froschParameterList->isParameter("Dofs Maps Vector")) { + dofsMapsVec = ExtractVectorFromParameterList > >>(*froschParameterList,"Dofs Maps Vector"); + } + + ConstXMultiVectorPtr nodeList = null; + GOVecPtr dirichletBoundaryDofs = null; + ConstXMultiVectorPtr nullSpaceBasisVec = null; + + TwoLevelPreconditionerPtr twoLevelPreconditioner = rcp(new TwoLevelPreconditioner(this->K_,froschParameterList)); + twoLevelPreconditioner->initialize(froschParameterList->get("Dimension",3), + dofsPerNodeVector[0], + froschParameterList->get("Overlap",1), + nullSpaceBasisVec, + nodeList, + dofOrderings[0], + RepeatedMaps[0], + dofsMapsVec[0], + dirichletBoundaryDofs); + + FROSchPreconditioner_ = twoLevelPreconditioner; + } else if (!this->ParameterList_->get("Solver","TwoLevelPreconditioner").compare("TwoLevelBlockPreconditioner")) { + ParameterListPtr froschParameterList = sublist(sublist(this->ParameterList_,"FROSchPreconditioner"),this->ParameterList_->get("Solver","TwoLevelPreconditioner")); + // if (this->K_->getMap()->getComm()->getRank() == 0) froschParameterList->print(cout); + + ArrayRCP > > RepeatedMaps(1); + UNVecPtr dofsPerNodeVector; + ConstXMultiVectorPtrVecPtr nullSpaceBasisVec = null; + ArrayRCP dofOrderings = null; + ArrayRCP > > > dofsMapsVec = null; + + FROSCH_ASSERT(froschParameterList->isParameter("Repeated Map Vector"),"FROSch::FROSchPreconditioner: Currently TwoLevelBlockPreconditioner cannot be constructed without Repeated Maps Vector "); + FROSCH_ASSERT(froschParameterList->isParameter("DofsPerNode Vector"),"FROSch::FROSchPreconditioner: Currently, TwoLevelBlockPreconditioner cannot be constructed without DofsPerNode Vector."); + FROSCH_ASSERT(froschParameterList->isParameter("DofOrdering Vector"),"FROSch::FROSchPreconditioner: Currently, TwoLevelBlockPreconditioner cannot be constructed without DofOrdering Vector."); + + if (froschParameterList->isParameter("Repeated Map Vector")) { + RepeatedMaps = ExtractVectorFromParameterList > >(*froschParameterList,"Repeated Map Vector"); + } + if (froschParameterList->isParameter("DofsPerNode Vector")) { + dofsPerNodeVector = ExtractVectorFromParameterList(*froschParameterList,"DofsPerNode Vector"); + } + if (froschParameterList->isParameter("DofOrdering Vector")) { + dofOrderings = ExtractVectorFromParameterList(*froschParameterList,"DofOrdering Vector"); + } + if (froschParameterList->isParameter("Dofs Maps Vector")) { + dofsMapsVec = ExtractVectorFromParameterList > >>(*froschParameterList,"Dofs Maps Vector"); + } + + FROSCH_ASSERT(RepeatedMaps.size()==dofsPerNodeVector.size(),"FROSch::FROSchPreconditioner: RepeatedMaps.size()!=dofsPerNodeVector.size()"); + FROSCH_ASSERT(RepeatedMaps.size()==dofOrderings.size(),"FROSch::FROSchPreconditioner: RepeatedMaps.size()!=dofOrderings.size()"); + TwoLevelBlockPreconditionerPtr twoLevelBlockPreconditioner = rcp(new TwoLevelBlockPreconditioner(this->K_,froschParameterList)); + twoLevelBlockPreconditioner->initialize(froschParameterList->get("Dimension",3), + dofsPerNodeVector, + dofOrderings, + froschParameterList->get("Overlap",1), + RepeatedMaps, + nullSpaceBasisVec); + + FROSchPreconditioner_ = twoLevelBlockPreconditioner; + } else { + FROSCH_ASSERT(false,"FROSch::FROSchPreconditioner: Solver unkown."); + } + } + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_decl.hpp index be40af9492d4..2f0e8de33d0f 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_decl.hpp @@ -121,7 +121,7 @@ namespace FROSch { ParameterListPtr parameterList, string description); - Ifpack2PreconditionerPtr Ifpack2Preconditioner_; + Ifpack2PreconditionerPtr Ifpack2Preconditioner_ = null; friend class SolverFactory; }; diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp index c3b251aa5732..8bf8f4c24002 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp @@ -65,7 +65,7 @@ namespace FROSch { int Ifpack2PreconditionerTpetra::compute() { FROSCH_TIMER_START_SOLVER(computeTime,"Ifpack2PreconditionerTpetra::compute"); - FROSCH_ASSERT(this->IsInitialized_,"FROSch::Ifpack2PreconditionerTpetra : ERROR: !this->IsInitialized_"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::Ifpack2PreconditionerTpetra: !this->IsInitialized_"); this->IsComputed_ = true; Ifpack2Preconditioner_->compute(); return 0; @@ -79,7 +79,7 @@ namespace FROSch { SC beta) const { FROSCH_TIMER_START_SOLVER(applyTime,"Ifpack2PreconditionerTpetra::apply"); - FROSCH_ASSERT(this->IsComputed_,"FROSch::Ifpack2PreconditionerTpetra : ERROR: !this->IsComputed_."); + FROSCH_ASSERT(this->IsComputed_,"FROSch::Ifpack2PreconditionerTpetra: !this->IsComputed_."); const TpetraMultiVector * xTpetraMultiVectorX = dynamic_cast *>(&x); TMultiVectorPtr tpetraMultiVectorX = xTpetraMultiVectorX->getTpetra_MultiVector(); @@ -94,7 +94,7 @@ namespace FROSch { int Ifpack2PreconditionerTpetra::updateMatrix(ConstXMatrixPtr k, bool reuseInitialize) { - FROSCH_ASSERT(false,"FROSch::Ifpack2PreconditionerTpetra : ERROR: updateMatrix() is not implemented for the Ifpack2PreconditionerTpetra yet."); + FROSCH_ASSERT(false,"FROSch::Ifpack2PreconditionerTpetra: updateMatrix() is not implemented for the Ifpack2PreconditionerTpetra yet."); return 0; } @@ -105,8 +105,8 @@ namespace FROSch { Solver (k,parameterList,description) { FROSCH_TIMER_START_SOLVER(Ifpack2PreconditionerTpetraTime,"Ifpack2PreconditionerTpetra::Ifpack2PreconditionerTpetra"); - FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseTpetra,"FROSch::Ifpack2PreconditionerTpetra : ERROR: Not compatible with Epetra.") - FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Ifpack2PreconditionerTpetra : ERROR: K_ is null."); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Ifpack2PreconditionerTpetra: K_ is null."); + FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseTpetra,"FROSch::Ifpack2PreconditionerTpetra: Not compatible with Epetra.") const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); const TpetraCrsMatrix& xTpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); @@ -116,7 +116,7 @@ namespace FROSch { Ifpack2::Details::OneLevelFactory ifpack2Factory; Ifpack2Preconditioner_ = ifpack2Factory.create(this->ParameterList_->get("Solver","RILUK"),tpetraMat); - ParameterListPtr ifpack2ParameterList = sublist(this->ParameterList_,"Ifpack2"); + ParameterListPtr ifpack2ParameterList = sublist(sublist(this->ParameterList_,"Ifpack2"),this->ParameterList_->get("Solver","RILUK")); ifpack2ParameterList->setName("Ifpack2"); Ifpack2Preconditioner_->setParameters(*ifpack2ParameterList); } diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_MueLuPreconditioner_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_MueLuPreconditioner_decl.hpp new file mode 100644 index 000000000000..968f2cca9ab8 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_MueLuPreconditioner_decl.hpp @@ -0,0 +1,129 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_MUELUPRECONDITIONER_DECL_HPP +#define _FROSCH_MUELUPRECONDITIONER_DECL_HPP + +#include + +#include +#include +#include + +// FROSch +#include + + +namespace FROSch { + + using namespace Teuchos; + using namespace Xpetra; + + template + class MueLuPreconditioner : public Solver { + + protected: + + // Xpetra + using XMatrix = typename Solver::XMatrix; + using XMatrixPtr = typename Solver::XMatrixPtr; + using ConstXMatrixPtr = typename Solver::ConstXMatrixPtr; + + using XMultiVector = typename Solver::XMultiVector; + using XMultiVectorPtr = typename Solver::XMultiVectorPtr; + using ConstXMultiVectorPtr = typename Solver::ConstXMultiVectorPtr; + + using XMultiVectorFactory = typename Solver::XMultiVectorFactory; + + // Teuchos + using ParameterListPtr = typename Solver::ParameterListPtr; + + // MueLu + using MueLuFactoryPtr = RCP >; + using MueLuHierarchyPtr = RCP >; + + public: + + //! Initialize the internal solver + virtual int initialize(); + + //! Compute the internal solver + virtual int compute(); + + /*! + \brief Computes the operator-multivector application. + + Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + \beta \cdot Y\f$. However, the details of operation + vary according to the values of \c alpha and \c beta. Specifically + - if beta == 0, apply() must overwrite \c Y, so that any values in \c Y (including NaNs) are ignored. + - if alpha == 0, apply() may short-circuit the operator, so that any values in \c X (including NaNs) are ignored. + */ + void apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode=NO_TRANS, + SC alpha=ScalarTraits::one(), + SC beta=ScalarTraits::zero()) const; + + int updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize=false); + + protected: + + //! Constructor + MueLuPreconditioner(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description); + + mutable XMultiVectorPtr Y_ = null; + + MueLuFactoryPtr MueLuFactory_ = null; + + MueLuHierarchyPtr MueLuHierarchy_ = null; + + friend class SolverFactory; + }; + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_MueLuPreconditioner_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_MueLuPreconditioner_def.hpp new file mode 100644 index 000000000000..88e8fda3dff7 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_MueLuPreconditioner_def.hpp @@ -0,0 +1,129 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_MUELUPRECONDITIONER_DEF_HPP +#define _FROSCH_MUELUPRECONDITIONER_DEF_HPP + +#include + + +namespace FROSch { + + using namespace Teuchos; + using namespace Xpetra; + + template + int MueLuPreconditioner::initialize() + { + FROSCH_TIMER_START_SOLVER(initializeTime,"MueLuPreconditioner::initialize"); + this->IsInitialized_ = true; + this->IsComputed_ = false; + return 0; + } + + template + int MueLuPreconditioner::compute() + { + FROSCH_TIMER_START_SOLVER(computeTime,"MueLuPreconditioner::compute"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::MueLuPreconditioner: !this->IsInitialized_"); + MueLuFactory_->SetupHierarchy(*MueLuHierarchy_); + MueLuHierarchy_->IsPreconditioner(false); + this->IsComputed_ = true; + return 0; + } + + template + void MueLuPreconditioner::apply(const XMultiVector &x, + XMultiVector &y, + ETransp mode, + SC alpha, + SC beta) const + { + FROSCH_TIMER_START_SOLVER(applyTime,"MueLuPreconditioner::apply"); + FROSCH_ASSERT(this->IsComputed_,"FROSch::MueLuPreconditioner: !this->IsComputed_."); + + if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),y.getNumVectors()); + + int mgridSweeps = this->ParameterList_->sublist("MueLu").get("mgridSweeps",-1); + if (mgridSweeps>0) { + MueLuHierarchy_->Iterate(x,*Y_,mgridSweeps); + } + else{ + typename ScalarTraits::magnitudeType tol = this->ParameterList_->sublist("MueLu").get("tol",1.e-6); + MueLuHierarchy_->Iterate(x,*Y_,tol); + } + y.update(alpha,*Y_,beta); + } + + template + int MueLuPreconditioner::updateMatrix(ConstXMatrixPtr k, + bool reuseInitialize) + { + FROSCH_ASSERT(false,"FROSch::MueLuPreconditioner: updateMatrix() is not implemented for the MueLuPreconditioner yet."); + return 0; + } + + template + MueLuPreconditioner::MueLuPreconditioner(ConstXMatrixPtr k, + ParameterListPtr parameterList, + string description) : + Solver (k,parameterList,description) + { + FROSCH_TIMER_START_SOLVER(MueLuPreconditionerTime,"MueLuPreconditioner::MueLuPreconditioner"); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::MueLuPreconditioner: K_ is null."); + + MueLuFactory_ = rcp(new MueLu::ParameterListInterpreter(this->ParameterList_->sublist("MueLu").sublist("MueLu Parameter"))); + RCP nullspace; + + if (!this->ParameterList_->sublist("MueLu").get("NullSpace","Laplace").compare("Laplace")) { + nullspace = XMultiVectorFactory::Build(this->K_->getRowMap(), 1); + nullspace->putScalar(1.); + } else { + FROSCH_ASSERT(false,"FROSch::MueLuPreconditioner: Only Laplacian null space is supported so far."); + } + MueLuHierarchy_ = MueLuFactory_->CreateHierarchy(); // Das vor den if block + MueLuHierarchy_->GetLevel(0)->Set("A", Teuchos::rcp_const_cast(this->K_)); // Das in den if block + MueLuHierarchy_->GetLevel(0)->Set("Nullspace", nullspace); + } + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp index 496faef6889e..a45139eb2c46 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_decl.hpp @@ -59,9 +59,13 @@ #endif #include #endif +#include #ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 #include #endif +#ifdef HAVE_SHYLU_DDFROSCH_MUELU +#include +#endif #if defined(HAVE_SHYLU_DDFROSCH_THYRA) && defined(HAVE_SHYLU_DDFROSCH_STRATIMIKOS) #include #include @@ -100,9 +104,13 @@ namespace FROSch { #endif using BelosSolverTpetraPtr = RCP >; #endif + using FROSchPreconditionerPtr = RCP >; #ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 using Ifpack2PreconditionerTpetraPtr = RCP >; #endif +#ifdef HAVE_SHYLU_DDFROSCH_MUELU + using MueLuPreconditionerPtr = RCP >; +#endif #if defined(HAVE_SHYLU_DDFROSCH_THYRA) && defined(HAVE_SHYLU_DDFROSCH_STRATIMIKOS) using ThyraPreconditionerPtr = RCP >; using ThyraSolverPtr = RCP >; diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp index 5a019f8beaf6..1bd96e3f670f 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp @@ -57,7 +57,7 @@ namespace FROSch { { if (!parameterList->get("SolverType","Amesos2").compare("Amesos")) { #ifdef HAVE_SHYLU_DDFROSCH_AMESOS - FROSCH_ASSERT(k->getRowMap()->lib()==UseEpetra,"FROSch::SolverFactory : ERROR: Amesos is not compatible with Tpetra."); + FROSCH_ASSERT(k->getRowMap()->lib()==UseEpetra,"FROSch::SolverFactory: Amesos is not compatible with Tpetra."); #ifdef HAVE_SHYLU_DDFROSCH_EPETRA return AmesosSolverEpetraPtr(new AmesosSolverEpetra(k,parameterList,description)); #else @@ -76,7 +76,7 @@ namespace FROSch { } else if (k->getRowMap()->lib()==UseTpetra) { return Amesos2SolverTpetraPtr(new Amesos2SolverTpetra(k,parameterList,description)); } else { - FROSCH_ASSERT(false, "FROSch::SolverFactory : ERROR: This can't happen. Either use Epetra or Tetra linear algebra stack."); + FROSCH_ASSERT(false, "FROSch::SolverFactory: This can't happen. Either use Epetra or Tetra linear algebra stack."); } } else if (!parameterList->get("SolverType","Amesos2").compare("Belos")) { #ifdef HAVE_SHYLU_DDFROSCH_BELOS @@ -89,20 +89,24 @@ namespace FROSch { } else if (k->getRowMap()->lib()==UseTpetra) { return BelosSolverTpetraPtr(new BelosSolverTpetra(k,parameterList,description)); } else { - FROSCH_ASSERT(false, "FROSch::SolverFactory : ERROR: This can't happen. Either use Epetra or Tetra linear algebra stack."); + FROSCH_ASSERT(false, "FROSch::SolverFactory: This can't happen. Either use Epetra or Tetra linear algebra stack."); } #else ThrowErrorMissingPackage("FROSch::SolverFactory","Belos"); #endif } else if (!parameterList->get("SolverType","Amesos2").compare("Ifpack2")) { #ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 - FROSCH_ASSERT(k->getRowMap()->lib()==UseTpetra,"FROSch::SolverFactory : ERROR: Ifpack2 is not compatible with Epetra."); + FROSCH_ASSERT(k->getRowMap()->lib()==UseTpetra,"FROSch::SolverFactory: Ifpack2 is not compatible with Epetra."); return Ifpack2PreconditionerTpetraPtr(new Ifpack2PreconditionerTpetra(k,parameterList,description)); #else ThrowErrorMissingPackage("FROSch::SolverFactory","Ifpack2"); #endif } else if (!parameterList->get("SolverType","Amesos2").compare("MueLu")) { - //return MueLuSolverPtr(new MueLuSolver(k,parameterList,description)); +#ifdef HAVE_SHYLU_DDFROSCH_MUELU + return MueLuPreconditionerPtr(new MueLuPreconditioner(k,parameterList,description)); +#else + ThrowErrorMissingPackage("FROSch::SolverFactory","Ifpack2"); +#endif } else if (!parameterList->get("SolverType","Amesos2").compare("ThyraPreconditioner")) { #ifdef HAVE_SHYLU_DDFROSCH_THYRA #ifdef HAVE_SHYLU_DDFROSCH_STRATIMIKOS @@ -123,10 +127,8 @@ namespace FROSch { #else ThrowErrorMissingPackage("FROSch::SolverFactory","Thyra"); #endif - } else if (!parameterList->get("SolverType","Amesos2").compare("TwoLevelBlockPreconditioner")) { - //return TwoLevelBlockPreconditionerSolverPtr(new TwoLevelBlockPreconditionerSolver(k,parameterList,description)); - } else if (!parameterList->get("SolverType","Amesos2").compare("TwoLevelPreconditioner")) { - //return TwoLevelPreconditionerSolverPtr(new TwoLevelPreconditionerSolver(k,parameterList,description)); + } else if (!parameterList->get("SolverType","Amesos2").compare("FROSchPreconditioner")) { + return FROSchPreconditionerPtr(new FROSchPreconditioner(k,parameterList,description)); } else { FROSCH_ASSERT(false,"SolverType unknown..."); } diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_decl.hpp index 1ca7eccbf093..6d4780fb1176 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_decl.hpp @@ -45,6 +45,7 @@ #include #include "Stratimikos_DefaultLinearSolverBuilder.hpp" +#include "Stratimikos_FROSchXpetra.hpp" // FROSch #include @@ -126,7 +127,7 @@ namespace FROSch { // mutable MultiVectorBasePtr Y_ = null; - PreconditionerBasePtr ThyraPreconditioner_; + PreconditionerBasePtr ThyraPreconditioner_ = null; friend class SolverFactory; }; diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_def.hpp index 511aca474669..5cbff313c2bd 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_def.hpp @@ -65,7 +65,7 @@ namespace FROSch { int ThyraPreconditioner::compute() { FROSCH_TIMER_START_SOLVER(computeTime,"ThyraPreconditioner::compute"); - FROSCH_ASSERT(this->IsInitialized_,"FROSch::ThyraPreconditioner : ERROR: !this->IsInitialized_"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::ThyraPreconditioner: !this->IsInitialized_"); this->IsComputed_ = true; return 0; } @@ -78,7 +78,7 @@ namespace FROSch { SC beta) const { FROSCH_TIMER_START_SOLVER(applyTime,"ThyraPreconditioner::apply"); - FROSCH_ASSERT(this->IsComputed_,"FROSch::ThyraPreconditioner : ERROR: !this->IsComputed_."); + FROSCH_ASSERT(this->IsComputed_,"FROSch::ThyraPreconditioner: !this->IsComputed_."); ConstMultiVectorBasePtr xThyra = ThyraUtils::toThyraMultiVector(rcpFromRef(x)); MultiVectorBasePtr yThyra = rcp_const_cast >(ThyraUtils::toThyraMultiVector(rcpFromRef(y))); @@ -88,7 +88,7 @@ namespace FROSch { case Teuchos::NO_TRANS: tMode = Thyra::NOTRANS; break; case Teuchos::TRANS: tMode = Thyra::TRANS; break; case Teuchos::CONJ_TRANS: tMode = Thyra::CONJTRANS; break; - default: FROSCH_ASSERT(false,"FROSch::ThyraPreconditioner : ERROR: mode unknown."); + default: FROSCH_ASSERT(false,"FROSch::ThyraPreconditioner: mode unknown."); } ThyraPreconditioner_->getUnspecifiedPrecOp()->apply(tMode,*xThyra,yThyra.ptr(),alpha,beta); @@ -98,7 +98,7 @@ namespace FROSch { int ThyraPreconditioner::updateMatrix(ConstXMatrixPtr k, bool reuseInitialize) { - FROSCH_ASSERT(false,"FROSch::ThyraPreconditioner : ERROR: updateMatrix() is not implemented for the ThyraPreconditioner yet."); + FROSCH_ASSERT(false,"FROSch::ThyraPreconditioner: updateMatrix() is not implemented for the ThyraPreconditioner yet."); return 0; } @@ -109,7 +109,7 @@ namespace FROSch { Solver (k,parameterList,description) { FROSCH_TIMER_START_SOLVER(ThyraPreconditionerTime,"ThyraPreconditioner::ThyraPreconditioner"); - FROSCH_ASSERT(!this->K_.is_null(),"FROSch::ThyraPreconditioner : ERROR: K_ is null."); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::ThyraPreconditioner: K_ is null."); const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); RCP > thyraOp = ThyraUtils::toThyra(crsOp.getCrsMatrix()); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_decl.hpp index 5e4d19b37ac9..9f15bd5d2101 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_decl.hpp @@ -45,6 +45,7 @@ #include #include "Stratimikos_DefaultLinearSolverBuilder.hpp" +#include "Stratimikos_FROSchXpetra.hpp" // FROSch #include @@ -119,7 +120,7 @@ namespace FROSch { mutable XMultiVectorPtr YX_ = null; mutable MultiVectorBasePtr YT_ = null; - LinearOpWithSolveBasePtr ThyraSolver_; + LinearOpWithSolveBasePtr ThyraSolver_ = null; friend class SolverFactory; }; diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_def.hpp index ad0356095c7f..060a6b35f76e 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_def.hpp @@ -65,7 +65,7 @@ namespace FROSch { int ThyraSolver::compute() { FROSCH_TIMER_START_SOLVER(computeTime,"ThyraSolver::compute"); - FROSCH_ASSERT(this->IsInitialized_,"FROSch::ThyraSolver : ERROR: !this->IsInitialized_"); + FROSCH_ASSERT(this->IsInitialized_,"FROSch::ThyraSolver: !this->IsInitialized_"); this->IsComputed_ = true; return 0; } @@ -78,7 +78,7 @@ namespace FROSch { SC beta) const { FROSCH_TIMER_START_SOLVER(applyTime,"ThyraSolver::apply"); - FROSCH_ASSERT(this->IsComputed_,"FROSch::ThyraSolver : ERROR: !this->IsComputed_."); + FROSCH_ASSERT(this->IsComputed_,"FROSch::ThyraSolver: !this->IsComputed_."); ConstMultiVectorBasePtr xThyra = ThyraUtils::toThyraMultiVector(rcpFromRef(x)); if (YX_.is_null()) YX_ = XMultiVectorFactory::Build(y.getMap(),y.getNumVectors()); @@ -89,7 +89,7 @@ namespace FROSch { case Teuchos::NO_TRANS: tMode = Thyra::NOTRANS; break; case Teuchos::TRANS: tMode = Thyra::TRANS; break; case Teuchos::CONJ_TRANS: tMode = Thyra::CONJTRANS; break; - default: FROSCH_ASSERT(false,"FROSch::ThyraPreconditionerTpetra : ERROR: mode unknown."); + default: FROSCH_ASSERT(false,"FROSch::ThyraPreconditionerTpetra: mode unknown."); } SolveStatus status = solve(*ThyraSolver_,tMode,*xThyra,YT_.ptr()); @@ -100,7 +100,7 @@ namespace FROSch { int ThyraSolver::updateMatrix(ConstXMatrixPtr k, bool reuseInitialize) { - FROSCH_ASSERT(false,"FROSch::ThyraSolver : ERROR: updateMatrix() is not implemented for the ThyraSolver yet."); + FROSCH_ASSERT(false,"FROSch::ThyraSolver: updateMatrix() is not implemented for the ThyraSolver yet."); return 0; } @@ -111,7 +111,7 @@ namespace FROSch { Solver (k,parameterList,description) { FROSCH_TIMER_START_SOLVER(ThyraSolverTime,"ThyraSolver::ThyraSolver"); - FROSCH_ASSERT(!this->K_.is_null(),"FROSch::ThyraSolver : ERROR: K_ is null."); + FROSCH_ASSERT(!this->K_.is_null(),"FROSch::ThyraSolver: K_ is null."); const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); RCP > thyraOp = ThyraUtils::toThyra(crsOp.getCrsMatrix()); diff --git a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Output.h b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Output.h index c4e8d21425ff..95364b8a04c2 100644 --- a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Output.h +++ b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Output.h @@ -50,11 +50,29 @@ #endif #ifndef FROSCH_ASSERT - #define FROSCH_ASSERT(A,S) TEUCHOS_TEST_FOR_EXCEPTION(!(A),std::logic_error,S); + #define FROSCH_ASSERT(COND,MSG) \ + { \ + const bool throw_exception = !(COND); \ + if(throw_exception) { \ + Teuchos::TestForException_incrThrowNumber(); \ + std::ostringstream omsg; \ + omsg \ + << std::setw(FROSCH_OUTPUT_INDENT) << " " << __FILE__ << ":" << __LINE__ << ":\n\n" \ + << "Throw number = " << Teuchos::TestForException_getThrowNumber() \ + << "\n\n" \ + << std::setw(FROSCH_OUTPUT_INDENT) << " " << "Throw test that evaluated to true: "#COND \ + << "\n\n" \ + << std::setw(FROSCH_OUTPUT_INDENT) << " " << "[ERROR] " << MSG; \ + const std::string &omsgstr = omsg.str(); \ + TEUCHOS_STORE_STACKTRACE(); \ + Teuchos::TestForException_break(omsgstr); \ + throw std::logic_error(omsgstr); \ + } \ + } #endif #ifndef FROSCH_WARNING - #define FROSCH_WARNING(CLASS,VERBOSE,OUTPUT) if (VERBOSE) std::cerr << std::setw(FROSCH_OUTPUT_INDENT) << " " << CLASS << " : WARNING: " << OUTPUT << std::endl; + #define FROSCH_WARNING(CLASS,VERBOSE,OUTPUT) if (VERBOSE) std::cerr << std::setw(FROSCH_OUTPUT_INDENT) << " " << "[WARNING] " << CLASS << ": " << OUTPUT << std::endl; #endif #ifndef FROSCH_NOTIFICATION diff --git a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_def.hpp b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_def.hpp index d2934833e31b..aa49471eacc6 100644 --- a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_def.hpp @@ -62,8 +62,8 @@ namespace FROSch { IsComputed_ (false) { FROSCH_TIMER_START_SUBDOMAINSOLVER(subdomainSolverTime,"SubdomainSolver::SubdomainSolver"); - FROSCH_ASSERT(!K_.is_null(),"FROSch::SubdomainSolver : ERROR: K_ is null."); - if (!ParameterList_->get("SolverType","Amesos").compare("Amesos")) { + FROSCH_ASSERT(!K_.is_null(),"FROSch::SubdomainSolver: K_ is null."); + if (!ParameterList_->get("SolverType","Amesos2").compare("Amesos")) { #ifdef HAVE_SHYLU_DDFROSCH_AMESOS FROSCH_ASSERT(K_->getRowMap()->lib()==UseEpetra,"UnderlyingLib!=UseEpetra"); #ifdef HAVE_SHYLU_DDFROSCH_EPETRA @@ -80,14 +80,14 @@ namespace FROSch { Amesos amesosFactory; - AmesosSolver_.reset(amesosFactory.Create(ParameterList_->get("Solver","Mumps"),*EpetraLinearProblem_)); + AmesosSolver_.reset(amesosFactory.Create(ParameterList_->get("Solver","Klu"),*EpetraLinearProblem_)); AmesosSolver_->SetParameters(ParameterList_->sublist("Amesos")); #endif #else ThrowErrorMissingPackage("FROSch::SubdomainSolver", "Amesos"); #endif - } else if (!ParameterList_->get("SolverType","Amesos").compare("Amesos2")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Amesos2")) { if (K_->getRowMap()->lib()==UseEpetra) { #ifdef HAVE_SHYLU_DDFROSCH_EPETRA const CrsMatrixWrap& crsOp = dynamic_cast&>(*K_); @@ -98,7 +98,7 @@ namespace FROSch { EMultiVectorPtr xTmp; EMultiVectorPtr bTmp; - Amesos2SolverEpetra_ = Amesos2::create(ParameterList_->get("Solver","Mumps"),epetraMat,xTmp,bTmp); + Amesos2SolverEpetra_ = Amesos2::create(ParameterList_->get("Solver","Klu"),epetraMat,xTmp,bTmp); ParameterListPtr parameterList = sublist(ParameterList_,"Amesos2"); parameterList->setName("Amesos2"); Amesos2SolverEpetra_->setParameters(parameterList); @@ -114,14 +114,14 @@ namespace FROSch { TMultiVectorPtr xTmp; TMultiVectorPtr bTmp; - Amesos2SolverTpetra_ = Amesos2::create(ParameterList_->get("Solver","Mumps"),tpetraMat,xTmp,bTmp); + Amesos2SolverTpetra_ = Amesos2::create(ParameterList_->get("Solver","Klu"),tpetraMat,xTmp,bTmp); ParameterListPtr parameterList = sublist(ParameterList_,"Amesos2"); parameterList->setName("Amesos2"); Amesos2SolverTpetra_->setParameters(parameterList); } else { FROSCH_ASSERT(false, "This can't happen. Either use Epetra or Tetra linear algebra stack."); } - } else if (!ParameterList_->get("SolverType","Amesos").compare("MueLu")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("MueLu")) { #ifdef HAVE_SHYLU_DDFROSCH_MUELU MueLuFactory_ = rcp(new MueLu::ParameterListInterpreter(parameterList->sublist("MueLu").sublist("MueLu Parameter"))); RCP nullspace; @@ -152,9 +152,9 @@ namespace FROSch { #else ThrowErrorMissingPackage("FROSch::SubdomainSolver", "MueLu"); #endif - } else if (!ParameterList_->get("SolverType","Amesos").compare("Ifpack2")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Ifpack2")) { #ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 - FROSCH_ASSERT(K_->getRowMap()->lib()==UseTpetra,"FROSch::SubdomainSolver : ERROR: Ifpack2 is not compatible with Epetra.") + FROSCH_ASSERT(K_->getRowMap()->lib()==UseTpetra,"FROSch::SubdomainSolver: Ifpack2 is not compatible with Epetra.") // Convert matrix to Tpetra const CrsMatrixWrap& crsOp = dynamic_cast&>(*K_); @@ -171,7 +171,7 @@ namespace FROSch { #else ThrowErrorMissingPackage("FROSch::SubdomainSolver", "Ifpack2"); #endif - } else if (!ParameterList_->get("SolverType","Amesos").compare("Belos")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Belos")) { #ifdef HAVE_SHYLU_DDFROSCH_BELOS RCP xSolution;// = FROSch::ConvertToXpetra(UseTpetra,*this->solution_,TeuchosComm); RCP xRightHandSide;// = FROSch::ConvertToXpetra(UseTpetra,*residualVec_,TeuchosComm);//hier residualVec. Bei linProb rhs_ @@ -190,7 +190,7 @@ namespace FROSch { #else ThrowErrorMissingPackage("FROSch::SubdomainSolver", "Belos"); #endif - } else if (!ParameterList_->get("SolverType","Amesos").compare("Thyra")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Thyra")) { #ifdef HAVE_SHYLU_DDFROSCH_THYRA FROSCH_ASSERT(K_->getRowMap()->lib()==UseTpetra,"SubdomainSolver cannot use Epetra for Thyra solvers."); const CrsMatrixWrap& crsOp = dynamic_cast&>(*K_); @@ -216,7 +216,7 @@ namespace FROSch { #else ThrowErrorMissingPackage("FROSch::SubdomainSolver", "Thyra"); #endif - } else if (!ParameterList_->get("SolverType","Amesos").compare("TwoLevelBlockPreconditioner")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("TwoLevelBlockPreconditioner")) { Teuchos::RCP< const Teuchos::Comm< int > > TC = K_->getMap()->getComm(); Teuchos::ArrayRCP > > RepeatedMaps(1); @@ -252,7 +252,7 @@ namespace FROSch { RepeatedMaps, nullSpaceBasisVec); - } else if (!ParameterList_->get("SolverType","Amesos").compare("TwoLevelPreconditioner")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("TwoLevelPreconditioner")) { Teuchos::RCP< const Teuchos::Comm< int > > TC = K_->getMap()->getComm(); Teuchos::ArrayRCP > > RepeatedMaps(1); @@ -346,13 +346,13 @@ namespace FROSch { { FROSCH_TIMER_START_SUBDOMAINSOLVER(initializeTime,"SubdomainSolver::initialize"); #ifdef HAVE_SHYLU_DDFROSCH_AMESOS - if (!ParameterList_->get("SolverType","Amesos").compare("Amesos")) { + if (!ParameterList_->get("SolverType","Amesos2").compare("Amesos")) { IsInitialized_ = true; IsComputed_ = false; AMESOS_CHK_ERR(AmesosSolver_->SymbolicFactorization()); } else #endif - if (!ParameterList_->get("SolverType","Amesos").compare("Amesos2")) { + if (!ParameterList_->get("SolverType","Amesos2").compare("Amesos2")) { if (K_->getRowMap()->lib()==UseEpetra) { #ifdef HAVE_SHYLU_DDFROSCH_EPETRA IsInitialized_ = true; @@ -365,31 +365,31 @@ namespace FROSch { Amesos2SolverTpetra_->symbolicFactorization(); } #ifdef HAVE_SHYLU_DDFROSCH_MUELU - } else if (!ParameterList_->get("SolverType","Amesos").compare("MueLu")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("MueLu")) { IsInitialized_ = true; IsComputed_ = false; #endif #ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 - } else if (!ParameterList_->get("SolverType","Amesos").compare("Ifpack2")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Ifpack2")) { IsInitialized_ = true; IsComputed_ = false; Ifpack2Preconditioner_->initialize(); #endif #ifdef HAVE_SHYLU_DDFROSCH_BELOS - } else if (!ParameterList_->get("SolverType","Amesos").compare("Belos")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Belos")) { IsInitialized_ = true; IsComputed_ = false; #endif #ifdef HAVE_SHYLU_DDFROSCH_THYRA - } else if (!ParameterList_->get("SolverType","Amesos").compare("Thyra")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Thyra")) { // TODO: In the current implementation initialize() and compute() are part of apply() for Thyra. IsInitialized_ = true; IsComputed_ = false; #endif - } else if (!ParameterList_->get("SolverType","Amesos").compare("TwoLevelBlockPreconditioner")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("TwoLevelBlockPreconditioner")) { IsInitialized_ = true; IsComputed_ = false; - } else if (!ParameterList_->get("SolverType","Amesos").compare("TwoLevelPreconditioner")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("TwoLevelPreconditioner")) { IsInitialized_ = true; IsComputed_ = false; } else { @@ -404,12 +404,12 @@ namespace FROSch { FROSCH_TIMER_START_SUBDOMAINSOLVER(computeTime,"SubdomainSolver::compute"); FROSCH_ASSERT(this->IsInitialized_,"ERROR: SubdomainSolver has to be initialized before calling compute()"); #ifdef HAVE_SHYLU_DDFROSCH_AMESOS - if (!ParameterList_->get("SolverType","Amesos").compare("Amesos")) { + if (!ParameterList_->get("SolverType","Amesos2").compare("Amesos")) { IsComputed_ = true; AMESOS_CHK_ERR(AmesosSolver_->NumericFactorization()); } else #endif - if (!ParameterList_->get("SolverType","Amesos").compare("Amesos2")) { + if (!ParameterList_->get("SolverType","Amesos2").compare("Amesos2")) { if (K_->getRowMap()->lib()==UseEpetra) { #ifdef HAVE_SHYLU_DDFROSCH_EPETRA IsComputed_ = true; @@ -420,18 +420,18 @@ namespace FROSch { Amesos2SolverTpetra_->numericFactorization(); } #ifdef HAVE_SHYLU_DDFROSCH_MUELU - } else if (!ParameterList_->get("SolverType","Amesos").compare("MueLu")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("MueLu")) { MueLuFactory_->SetupHierarchy(*MueLuHierarchy_); MueLuHierarchy_->IsPreconditioner(false); IsComputed_ = true; #endif #ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 - } else if (!ParameterList_->get("SolverType","Amesos").compare("Ifpack2")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Ifpack2")) { Ifpack2Preconditioner_->compute(); IsComputed_ = true; #endif #ifdef HAVE_SHYLU_DDFROSCH_BELOS - } else if (!ParameterList_->get("SolverType","Amesos").compare("Belos")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Belos")) { ParameterListPtr solverParameterList = sublist(ParameterList_,"Belos"); if (solverParameterList->get("OneLevelPreconditioner",false)) { @@ -455,13 +455,13 @@ namespace FROSch { IsComputed_ = true; #endif #ifdef HAVE_SHYLU_DDFROSCH_THYRA - } else if (!ParameterList_->get("SolverType","Amesos").compare("Thyra")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Thyra")) { IsComputed_ = true; #endif - } else if (!ParameterList_->get("SolverType","Amesos").compare("TwoLevelBlockPreconditioner")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("TwoLevelBlockPreconditioner")) { TLBP->compute(); IsComputed_ = true; - } else if (!ParameterList_->get("SolverType","Amesos").compare("TwoLevelPreconditioner")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("TwoLevelPreconditioner")) { TLP->compute(); IsComputed_ = true; } else { @@ -482,7 +482,7 @@ namespace FROSch { FROSCH_ASSERT(IsComputed_,"!IsComputed_."); #if defined(HAVE_SHYLU_DDFROSCH_AMESOS) && defined(HAVE_SHYLU_DDFROSCH_EPETRA) - if (!ParameterList_->get("SolverType","Amesos").compare("Amesos")) { + if (!ParameterList_->get("SolverType","Amesos2").compare("Amesos")) { #ifdef HAVE_SHYLU_DDFROSCH_EPETRA const EpetraMultiVectorT * xEpetraMultiVectorX = dynamic_cast *>(&x); RCP epetraMultiVectorX = xEpetraMultiVectorX->getEpetra_MultiVector(); @@ -500,7 +500,7 @@ namespace FROSch { #endif } else #endif - if (!ParameterList_->get("SolverType","Amesos").compare("Amesos2")) { + if (!ParameterList_->get("SolverType","Amesos2").compare("Amesos2")) { if (K_->getRowMap()->lib()==UseEpetra) { #ifdef HAVE_SHYLU_DDFROSCH_EPETRA const EpetraMultiVectorT * xEpetraMultiVectorX = dynamic_cast *>(&x); @@ -531,7 +531,7 @@ namespace FROSch { Amesos2SolverTpetra_->solve(); // Was ist, wenn man mit der transponierten Matrix lösen will } #ifdef HAVE_SHYLU_DDFROSCH_MUELU - } else if (!ParameterList_->get("SolverType","Amesos").compare("MueLu")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("MueLu")) { if (YTmp_.is_null()) YTmp_ = XMultiVectorFactory::Build(y.getMap(),x.getNumVectors()); int mgridSweeps = ParameterList_->sublist("MueLu").get("mgridSweeps",-1); @@ -545,7 +545,7 @@ namespace FROSch { y = *YTmp_; #endif #ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 - } else if (!ParameterList_->get("SolverType","Amesos").compare("Ifpack2")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Ifpack2")) { const TpetraMultiVector * xTpetraMultiVectorX = dynamic_cast *>(&x); TMultiVectorPtr tpetraMultiVectorX = xTpetraMultiVectorX->getTpetra_MultiVector(); @@ -557,7 +557,7 @@ namespace FROSch { Ifpack2Preconditioner_->apply(*tpetraMultiVectorX,*tpetraMultiVectorY,mode,alpha,beta); #endif #ifdef HAVE_SHYLU_DDFROSCH_BELOS - } else if (!ParameterList_->get("SolverType","Amesos").compare("Belos")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Belos")) { ConstXMultiVectorPtr xPtr = rcpFromRef(x); if (YTmp_.is_null()) YTmp_ = XMultiVectorFactory::Build(y.getMap(),x.getNumVectors()); @@ -566,7 +566,7 @@ namespace FROSch { y = *YTmp_; #endif #ifdef HAVE_SHYLU_DDFROSCH_THYRA - } else if (!ParameterList_->get("SolverType","Amesos").compare("Thyra")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Thyra")) { ConstXMultiVectorPtr xPtr = rcpFromRef(x); RCP > thyraX = ThyraUtils::toThyraMultiVector(xPtr); @@ -590,11 +590,11 @@ namespace FROSch { TEUCHOS_TEST_FOR_EXCEPT(is_null(xY)); */ #endif - } else if (!ParameterList_->get("SolverType","Amesos").compare("TwoLevelBlockPreconditioner")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("TwoLevelBlockPreconditioner")) { if (YTmp_.is_null()) YTmp_ = Xpetra::MultiVectorFactory::Build(y.getMap(),x.getNumVectors()); TLBP->apply(x,*YTmp_,Teuchos::NO_TRANS); y = *YTmp_; - } else if (!ParameterList_->get("SolverType","Amesos").compare("TwoLevelPreconditioner")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("TwoLevelPreconditioner")) { if (YTmp_.is_null()) YTmp_ = Xpetra::MultiVectorFactory::Build(y.getMap(),x.getNumVectors()); TLP->apply(x,*YTmp_,Teuchos::NO_TRANS); y = *YTmp_; @@ -647,8 +647,8 @@ namespace FROSch { { FROSCH_TIMER_START_SUBDOMAINSOLVER(resetMatrixTime,"SubdomainSolver::resetMatrix"); K_ = k; - FROSCH_ASSERT(!K_.is_null(),"FROSch::SubdomainSolver : ERROR: K_ is null."); - if (!ParameterList_->get("SolverType","Amesos").compare("Amesos")) { + FROSCH_ASSERT(!K_.is_null(),"FROSch::SubdomainSolver: K_ is null."); + if (!ParameterList_->get("SolverType","Amesos2").compare("Amesos")) { #ifdef HAVE_SHYLU_DDFROSCH_AMESOS FROSCH_ASSERT(K_->getRowMap()->lib()==UseEpetra,"UnderlyingLib!=UseEpetra"); #ifdef HAVE_SHYLU_DDFROSCH_EPETRA @@ -658,12 +658,12 @@ namespace FROSch { ECrsMatrixPtr epetraMat = xEpetraMat.getEpetra_CrsMatrixNonConst(); TEUCHOS_TEST_FOR_EXCEPT(epetraMat.is_null()); - FROSCH_ASSERT(false,"FROSch::SubdomainSolver : ERROR: resetMatrix() is not implemented for Amesos yet."); + FROSCH_ASSERT(false,"FROSch::SubdomainSolver: resetMatrix() is not implemented for Amesos yet."); #endif #else ThrowErrorMissingPackage("FROSch::SubdomainSolver", "Amesos"); #endif - } else if (!ParameterList_->get("SolverType","Amesos").compare("Amesos2")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Amesos2")) { if (K_->getRowMap()->lib()==UseEpetra) { #ifdef HAVE_SHYLU_DDFROSCH_EPETRA const CrsMatrixWrap& crsOp = dynamic_cast&>(*K_); @@ -695,15 +695,15 @@ namespace FROSch { } else { FROSCH_ASSERT(false, "This can't happen. Either use Epetra or Tetra linear algebra stack."); } - } else if (!ParameterList_->get("SolverType","Amesos").compare("MueLu")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("MueLu")) { #ifdef HAVE_SHYLU_DDFROSCH_MUELU - FROSCH_ASSERT(false,"FROSch::SubdomainSolver : ERROR: resetMatrix() is not implemented for MueLu yet."); + FROSCH_ASSERT(false,"FROSch::SubdomainSolver: resetMatrix() is not implemented for MueLu yet."); #else ThrowErrorMissingPackage("FROSch::SubdomainSolver", "MueLu"); #endif - } else if (!ParameterList_->get("SolverType","Amesos").compare("Ifpack2")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Ifpack2")) { #ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 - FROSCH_ASSERT(K_->getRowMap()->lib()==UseTpetra,"FROSch::SubdomainSolver : ERROR: Ifpack2 is not compatible with Epetra.") + FROSCH_ASSERT(K_->getRowMap()->lib()==UseTpetra,"FROSch::SubdomainSolver: Ifpack2 is not compatible with Epetra.") // Convert matrix to Tpetra const CrsMatrixWrap& crsOp = dynamic_cast&>(*K_); @@ -711,19 +711,19 @@ namespace FROSch { ConstTCrsMatrixPtr tpetraMat = xTpetraMat.getTpetra_CrsMatrix(); TEUCHOS_TEST_FOR_EXCEPT(tpetraMat.is_null()); - FROSCH_ASSERT(false,"FROSch::SubdomainSolver : ERROR: resetMatrix() is not implemented for Ifpack2 yet."); + FROSCH_ASSERT(false,"FROSch::SubdomainSolver: resetMatrix() is not implemented for Ifpack2 yet."); #else ThrowErrorMissingPackage("FROSch::SubdomainSolver", "Ifpack2"); #endif - } else if (!ParameterList_->get("SolverType","Amesos").compare("Belos")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Belos")) { #ifdef HAVE_SHYLU_DDFROSCH_BELOS - FROSCH_ASSERT(false,"FROSch::SubdomainSolver : ERROR: resetMatrix() is not implemented for Belos yet."); + FROSCH_ASSERT(false,"FROSch::SubdomainSolver: resetMatrix() is not implemented for Belos yet."); #else ThrowErrorMissingPackage("FROSch::SubdomainSolver", "Belos"); #endif - } else if (!ParameterList_->get("SolverType","Amesos").compare("Belos")) { + } else if (!ParameterList_->get("SolverType","Amesos2").compare("Belos")) { #ifdef HAVE_SHYLU_DDFROSCH_THYRA - FROSCH_ASSERT(false,"FROSch::SubdomainSolver : ERROR: resetMatrix() is not implemented for Thyra yet."); + FROSCH_ASSERT(false,"FROSch::SubdomainSolver: resetMatrix() is not implemented for Thyra yet."); #else ThrowErrorMissingPackage("FROSch::SubdomainSolver", "Thyra"); #endif diff --git a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Timers.h b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Timers.h index 0b7a5b92e34e..9837a9ac4afb 100644 --- a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Timers.h +++ b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Timers.h @@ -52,11 +52,11 @@ #if FROSCH_TIMER_DETAILS > 1 #ifndef FROSCH_TIMER_START - #define FROSCH_TIMER_START(A,S) RCP A = rcp(new TimeMonitor(*TimeMonitor::getNewTimer(std::string("FROSch: ") + std::string(S)))); + #define FROSCH_TIMER_START(A,S) Teuchos::RCP A = rcp(new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string("FROSch: ") + std::string(S)))); #endif #ifndef FROSCH_TIMER_START_LEVELID - #define FROSCH_TIMER_START_LEVELID(A,S) RCP A = rcp(new TimeMonitor(*TimeMonitor::getNewTimer(std::string("FROSch: ") + std::string(S) + " (Level " + std::to_string(this->LevelID_) + std::string(")")))); + #define FROSCH_TIMER_START_LEVELID(A,S) Teuchos::RCP A = rcp(new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string("FROSch: ") + std::string(S) + " (Level " + std::to_string(this->LevelID_) + std::string(")")))); #endif #ifndef FROSCH_TIMER_STOP @@ -76,19 +76,19 @@ #endif #ifndef FROSCH_TIMER_START_SOLVER - #define FROSCH_TIMER_START_SOLVER(A,S) RCP A = rcp(new TimeMonitor(*TimeMonitor::getNewTimer(std::string("FROSch: ") + std::string(S) + " (" + this->Description_ + std::string(")")))); + #define FROSCH_TIMER_START_SOLVER(A,S) Teuchos::RCP A = rcp(new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string("FROSch: ") + std::string(S) + " (" + this->Description_ + std::string(")")))); #endif #ifndef FROSCH_TIMER_START_SUBDOMAINSOLVER - #define FROSCH_TIMER_START_SUBDOMAINSOLVER(A,S) RCP A = rcp(new TimeMonitor(*TimeMonitor::getNewTimer(std::string("FROSch: ") + std::string(S) + " (" + this->Description_ + std::string(")")))); + #define FROSCH_TIMER_START_SUBDOMAINSOLVER(A,S) Teuchos::RCP A = rcp(new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string("FROSch: ") + std::string(S) + " (" + this->Description_ + std::string(")")))); #endif #elif FROSCH_TIMER_DETAILS == 1 #ifndef FROSCH_TIMER_START - #define FROSCH_TIMER_START(A,S) RCP A = rcp(new TimeMonitor(*TimeMonitor::getNewTimer(std::string("FROSch: ") + std::string(S)))); + #define FROSCH_TIMER_START(A,S) Teuchos::RCP A = rcp(new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string("FROSch: ") + std::string(S)))); #endif #ifndef FROSCH_TIMER_START_LEVELID - #define FROSCH_TIMER_START_LEVELID(A,S) RCP A = rcp(new TimeMonitor(*TimeMonitor::getNewTimer(std::string("FROSch: ") + std::string(S) + " (Level " + std::to_string(this->LevelID_) + std::string(")")))); + #define FROSCH_TIMER_START_LEVELID(A,S) Teuchos::RCP A = rcp(new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(std::string("FROSch: ") + std::string(S) + " (Level " + std::to_string(this->LevelID_) + std::string(")")))); #endif #ifndef FROSCH_TIMER_STOP diff --git a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Tools_def.hpp b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Tools_def.hpp index 07d29ee13416..7249e9c79b08 100644 --- a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Tools_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Tools_def.hpp @@ -69,7 +69,7 @@ namespace FROSch { template int OverlappingData::Merge(const RCP > od) const { - FROSCH_ASSERT(GID_ == od->GID_,"FROSch::OverlappingData : ERROR: GID_ != od->GID_"); + FROSCH_ASSERT(GID_ == od->GID_,"FROSch::OverlappingData: GID_ != od->GID_"); for (typename IntVec::iterator it = od->PIDs_.begin(); it != od->PIDs_.end(); it++) { PIDs_.push_back(*it); } @@ -850,17 +850,17 @@ namespace FROSch { ArrayRCP dofsPerNode) { FROSCH_DETAILTIMER_START(assembleSubdomainMapTime,"AssembleSubdomainMap"); - FROSCH_ASSERT(numberOfBlocks>0,"FROSch : ERROR: numberOfBlocks==0"); - FROSCH_ASSERT(dofsMaps.size()==numberOfBlocks,"FROSch : ERROR: dofsMaps.size()!=NumberOfBlocks_"); - FROSCH_ASSERT(dofsPerNode.size()==numberOfBlocks,"FROSch : ERROR: dofsPerNode.size()!=NumberOfBlocks_"); + FROSCH_ASSERT(numberOfBlocks>0,"FROSch: numberOfBlocks==0"); + FROSCH_ASSERT(dofsMaps.size()==numberOfBlocks,"FROSch: dofsMaps.size()!=NumberOfBlocks_"); + FROSCH_ASSERT(dofsPerNode.size()==numberOfBlocks,"FROSch: dofsPerNode.size()!=NumberOfBlocks_"); Array mapVector(0); for (unsigned i=0; igetNodeNumElements(); for (unsigned j=1; jgetNodeNumElements()==(unsigned) numMyElements,"FROSch : ERROR: dofsMaps[i][j]->getNodeNumElements()==numMyElements"); + FROSCH_ASSERT(dofsMaps[i][j]->getNodeNumElements()==(unsigned) numMyElements,"FROSch: dofsMaps[i][j]->getNodeNumElements()==numMyElements"); } for (unsigned j=0; j::Build(dofsMaps[0][0]->lib(),-1,mapVector(),0,dofsMaps[0][0]->getComm()); } @@ -1388,7 +1388,7 @@ namespace FROSch { const Epetra_BlockMap &map, RCP > comm) { - FROSCH_ASSERT(false,"FROSch::ConvertToXpetra : ERROR: Needs specialization."); + FROSCH_ASSERT(false,"FROSch::ConvertToXpetra: Needs specialization."); return null; } @@ -1397,7 +1397,7 @@ namespace FROSch { Epetra_CrsMatrix &matrix, RCP > comm) { - FROSCH_ASSERT(false,"FROSch::ConvertToXpetra : ERROR: Needs specialization."); + FROSCH_ASSERT(false,"FROSch::ConvertToXpetra: Needs specialization."); return null; } diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt b/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt index c0fa5d6ba861..df1e64f81b15 100644 --- a/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/CMakeLists.txt @@ -10,6 +10,7 @@ ParameterLists ############## # Amesos Klu # ############## +IF(HAVE_SHYLU_DDFROSCH_AMESOS) ## Epetra IF(HAVE_SHYLU_DDFROSCH_EPETRA AND NOT Tpetra_DefaultNode STREQUAL "Kokkos::Compat::KokkosCudaWrapperNode") TRIBITS_ADD_TEST( @@ -27,6 +28,7 @@ COMM mpi NUM_MPI_PROCS 1 ) ENDIF() +ENDIF() ############### # Amesos2 Klu # @@ -67,6 +69,7 @@ NUM_MPI_PROCS 1 ############### # Belos GMRES # ############### +IF(HAVE_SHYLU_DDFROSCH_BELOS) ## Epetra IF(HAVE_SHYLU_DDFROSCH_EPETRA AND NOT Tpetra_DefaultNode STREQUAL "Kokkos::Compat::KokkosCudaWrapperNode") TRIBITS_ADD_TEST( @@ -99,10 +102,12 @@ ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_Belos_GMRES.xml --USETPETRA" COMM mpi NUM_MPI_PROCS 8 ) +ENDIF() ################# # Ifpack2 RILUK # ################# +IF(HAVE_SHYLU_DDFROSCH_IFPACK2) ##Tpetra TRIBITS_ADD_TEST( solverfactory @@ -118,22 +123,134 @@ ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_Ifpack2_RILUK.xml --USETPETRA COMM mpi NUM_MPI_PROCS 8 ) +ENDIF() + +#################################################### +# FROSchPreconditioner TwoLevelBlockPreconditioner # +#################################################### +## Epetra +IF(HAVE_SHYLU_DDFROSCH_EPETRA) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_froschpreconditioner_twolevelblockpreconditioner_DIM2_EPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelBlockPreconditioner.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 4 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_froschpreconditioner_twolevelblockpreconditioner_DIM3_EPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelBlockPreconditioner.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 8 +) +ENDIF() +##Tpetra +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_froschpreconditioner_twolevelblockpreconditioner_DIM2_TPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelBlockPreconditioner.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 4 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_froschpreconditioner_twolevelblockpreconditioner_DIM3_TPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelBlockPreconditioner.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 8 +) + +############################################### +# FROSchPreconditioner TwoLevelPreconditioner # +############################################### +## Epetra +IF(HAVE_SHYLU_DDFROSCH_EPETRA) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_froschpreconditioner_twolevelpreconditioner_DIM2_EPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelPreconditioner.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 4 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_froschpreconditioner_twolevelpreconditioner_DIM3_EPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelPreconditioner.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 8 +) +ENDIF() +##Tpetra +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_froschpreconditioner_twolevelpreconditioner_DIM2_TPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelPreconditioner.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 4 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_froschpreconditioner_twolevelpreconditioner_DIM3_TPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelPreconditioner.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 8 +) + +######### +# MueLu # +######### +IF(HAVE_SHYLU_DDFROSCH_MUELU) +## Epetra +IF(HAVE_SHYLU_DDFROSCH_EPETRA) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_muelu_DIM2_EPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_MueLu.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 4 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_muelu_DIM3_EPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_MueLu.xml --USEEPETRA" +COMM mpi +NUM_MPI_PROCS 8 +) +ENDIF() +##Tpetra +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_muelu_DIM2_TPETRA +ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_MueLu.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 4 +) +TRIBITS_ADD_TEST( +solverfactory +NAME test_solverfactory_muelu_DIM3_TPETRA +ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_MueLu.xml --USETPETRA" +COMM mpi +NUM_MPI_PROCS 8 +) +ENDIF() ##################################################### # ThyraPreconditioner FROSch OneLevelPreconditioner # ##################################################### +IF(HAVE_SHYLU_DDFROSCH_THYRA AND HAVE_SHYLU_DDFROSCH_STRATIMIKOS) ## Epetra IF(HAVE_SHYLU_DDFROSCH_EPETRA AND NOT Tpetra_DefaultNode STREQUAL "Kokkos::Compat::KokkosCudaWrapperNode") TRIBITS_ADD_TEST( solverfactory -NAME test_solverfactory_thyrapreconditioner_frosch_onelevelpreconditionerDIM2_EPETRA +NAME test_solverfactory_thyrapreconditioner_frosch_onelevelpreconditioner_DIM2_EPETRA ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml --USEEPETRA" COMM mpi NUM_MPI_PROCS 4 ) TRIBITS_ADD_TEST( solverfactory -NAME test_solverfactory_thyrapreconditioner_frosch_onelevelpreconditionerDIM3_EPETRA +NAME test_solverfactory_thyrapreconditioner_frosch_onelevelpreconditioner_DIM3_EPETRA ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml --USEEPETRA" COMM mpi NUM_MPI_PROCS 8 @@ -142,23 +259,24 @@ ENDIF() ##Tpetra TRIBITS_ADD_TEST( solverfactory -NAME test_solverfactory_thyrapreconditioner_frosch_onelevelpreconditionerDIM2_TPETRA +NAME test_solverfactory_thyrapreconditioner_frosch_onelevelpreconditioner_DIM2_TPETRA ARGS "--DIM=2 --PLIST=ParameterLists/ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml --USETPETRA" COMM mpi NUM_MPI_PROCS 4 ) TRIBITS_ADD_TEST( solverfactory -NAME test_solverfactory_thyrapreconditioner_frosch_onelevelpreconditionerDIM3_TPETRA +NAME test_solverfactory_thyrapreconditioner_frosch_onelevelpreconditioner_DIM3_TPETRA ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml --USETPETRA" COMM mpi NUM_MPI_PROCS 8 ) - +ENDIF() ########################### # ThyraSolver Belos GMRES # ########################### +IF(HAVE_SHYLU_DDFROSCH_THYRA AND HAVE_SHYLU_DDFROSCH_STRATIMIKOS AND HAVE_SHYLU_DDFROSCH_BELOS) ## Epetra IF(HAVE_SHYLU_DDFROSCH_EPETRA AND NOT Tpetra_DefaultNode STREQUAL "Kokkos::Compat::KokkosCudaWrapperNode") TRIBITS_ADD_TEST( @@ -191,3 +309,4 @@ ARGS "--DIM=3 --PLIST=ParameterLists/ParameterList_ThyraSolver_Belos_GMRES.xml - COMM mpi NUM_MPI_PROCS 8 ) +ENDIF() diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/CMakeLists.txt b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/CMakeLists.txt index 7b12dd5020f8..e17261a80206 100644 --- a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/CMakeLists.txt +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/CMakeLists.txt @@ -2,7 +2,10 @@ TRIBITS_COPY_FILES_TO_BINARY_DIR(SolverFactoryCopyFiles DEST_FILES ParameterList_Amesos_Klu.xml ParameterList_Amesos2_Klu.xml ParameterList_Belos_GMRES.xml + ParameterList_FROSchPreconditioner_TwoLevelBlockPreconditioner.xml + ParameterList_FROSchPreconditioner_TwoLevelPreconditioner.xml ParameterList_Ifpack2_RILUK.xml + ParameterList_MueLu.xml ParameterList_ThyraPreconditioner_FROSch_OneLevelPreconditioner.xml ParameterList_ThyraSolver_Belos_GMRES.xml SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelBlockPreconditioner.xml b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelBlockPreconditioner.xml new file mode 100644 index 000000000000..81ac72552b5b --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelBlockPreconditioner.xml @@ -0,0 +1,4 @@ + + + + diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelPreconditioner.xml b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelPreconditioner.xml new file mode 100644 index 000000000000..c6b2c58a37e1 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_FROSchPreconditioner_TwoLevelPreconditioner.xml @@ -0,0 +1,4 @@ + + + + diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_MueLu.xml b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_MueLu.xml new file mode 100644 index 000000000000..33079cf388d8 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_MueLu.xml @@ -0,0 +1,3 @@ + + + diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_ThyraSolver_Belos_GMRES.xml b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_ThyraSolver_Belos_GMRES.xml index 019dc03e7331..357fd05c03ac 100644 --- a/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_ThyraSolver_Belos_GMRES.xml +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/ParameterLists/ParameterList_ThyraSolver_Belos_GMRES.xml @@ -5,16 +5,6 @@ - - - - - - - - - - diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp b/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp index fc30c5321ba7..21ce3936ca00 100644 --- a/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp @@ -164,13 +164,6 @@ int main(int argc, char *argv[]) RCP parameterList = getParametersFromXmlFile(xmlFile); - Comm->barrier(); - if (Comm->getRank()==0) { - cout << "##################\n# Parameter List #\n##################" << endl; - parameterList->print(cout); - cout << endl; - } - Comm->barrier(); if (Comm->getRank()==0) cout << "######################\n# Assembly Laplacian #\n######################\n" << endl; ParameterList GaleriList; @@ -181,23 +174,21 @@ int main(int argc, char *argv[]) GaleriList.set("my", GO(N)); GaleriList.set("mz", GO(N)); - RCP > UniqueNodeMap; RCP > UniqueMap; RCP > Coordinates; RCP > K; if (Dimension==2) { - UniqueNodeMap = Galeri::Xpetra::CreateMap(xpetraLib,"Cartesian2D",Comm,GaleriList); // RCP fancy = fancyOStream(rcpFromRef(cout)); nodeMap->describe(*fancy,VERB_EXTREME); - UniqueMap = Xpetra::MapFactory::Build(UniqueNodeMap,2); + UniqueMap = Galeri::Xpetra::CreateMap(xpetraLib,"Cartesian2D",Comm,GaleriList); // RCP fancy = fancyOStream(rcpFromRef(cout)); nodeMap->describe(*fancy,VERB_EXTREME); Coordinates = Galeri::Xpetra::Utils::CreateCartesianCoordinates,MultiVector >("2D",UniqueMap,GaleriList); - RCP,CrsMatrixWrap,MultiVector > > Problem = Galeri::Xpetra::BuildProblem,CrsMatrixWrap,MultiVector >("Elasticity2D",UniqueMap,GaleriList); + RCP,CrsMatrixWrap,MultiVector > > Problem = Galeri::Xpetra::BuildProblem,CrsMatrixWrap,MultiVector >("Laplace2D",UniqueMap,GaleriList); K = Problem->BuildMatrix(); } else if (Dimension==3) { - UniqueNodeMap = Galeri::Xpetra::CreateMap(xpetraLib,"Cartesian3D",Comm,GaleriList); // RCP fancy = fancyOStream(rcpFromRef(cout)); nodeMap->describe(*fancy,VERB_EXTREME); - UniqueMap = Xpetra::MapFactory::Build(UniqueNodeMap,3); + UniqueMap = Galeri::Xpetra::CreateMap(xpetraLib,"Cartesian3D",Comm,GaleriList); // RCP fancy = fancyOStream(rcpFromRef(cout)); nodeMap->describe(*fancy,VERB_EXTREME); Coordinates = Galeri::Xpetra::Utils::CreateCartesianCoordinates,MultiVector >("3D",UniqueMap,GaleriList); - RCP,CrsMatrixWrap,MultiVector > > Problem = Galeri::Xpetra::BuildProblem,CrsMatrixWrap,MultiVector >("Elasticity3D",UniqueMap,GaleriList); + RCP,CrsMatrixWrap,MultiVector > > Problem = Galeri::Xpetra::BuildProblem,CrsMatrixWrap,MultiVector >("Laplace3D",UniqueMap,GaleriList); K = Problem->BuildMatrix(); } + RCP > RepeatedMap = BuildRepeatedMap(K->getCrsGraph()); RCP > xSolution = MultiVectorFactory::Build(UniqueMap,1); RCP > xRightHandSide = MultiVectorFactory::Build(UniqueMap,1); @@ -205,8 +196,34 @@ int main(int argc, char *argv[]) xSolution->putScalar(ScalarTraits::zero()); xRightHandSide->putScalar(ScalarTraits::one()); - Comm->barrier(); if (Comm->getRank()==0) cout << "####################\n# Construct Solver #\n####################" << endl; + RCP twoLevelBlockPreconditionerList = sublist(sublist(parameterList,"FROSchPreconditioner"),"TwoLevelBlockPreconditioner"); + twoLevelBlockPreconditionerList->set("Dimension",Dimension); + twoLevelBlockPreconditionerList->set("Overlap",Overlap); + ArrayRCP dofOrderings(1); + dofOrderings[0] = NodeWise; + twoLevelBlockPreconditionerList->set("DofOrdering Vector",dofOrderings); + ArrayRCP dofsPerNodeVector(1); + dofsPerNodeVector[0] = 1; + twoLevelBlockPreconditionerList->set("DofsPerNode Vector",dofsPerNodeVector); + ArrayRCP > > RepeatedMaps(1); + RepeatedMaps[0] = RepeatedMap; + twoLevelBlockPreconditionerList->set("Repeated Map Vector",RepeatedMaps); + + RCP twoLevelPreconditionerList = sublist(sublist(parameterList,"FROSchPreconditioner"),"TwoLevelPreconditioner"); + twoLevelPreconditionerList->set("Dimension",Dimension); + twoLevelPreconditionerList->set("Overlap",Overlap); + twoLevelPreconditionerList->set("DofOrdering Vector",dofOrderings); + twoLevelPreconditionerList->set("DofsPerNode Vector",dofsPerNodeVector); + twoLevelPreconditionerList->set("Repeated Map Vector",RepeatedMaps); + Comm->barrier(); + if (Comm->getRank()==0) { + cout << "##################\n# Parameter List #\n##################" << endl; + parameterList->print(cout); + cout << endl; + } + + Comm->barrier(); if (Comm->getRank()==0) cout << "####################\n# Construct Solver #\n####################" << endl; RCP > FROSchSolverInterface = SolverFactory::Build(K,parameterList,"Solver Tester"); FROSchSolverInterface->initialize(); From 9571957e784b7d45e6c6efc60ecd71680b0c9e63 Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Mon, 1 Mar 2021 11:21:58 +0100 Subject: [PATCH 07/15] Enabling SolverInterfaces for FROSch preconditioners. --- .../src/Adapters/Stratimikos_FROSch_decl.hpp | 80 +++++++++++++ ...hXpetra.hpp => Stratimikos_FROSch_def.hpp} | 26 ++--- .../src/Adapters/Thyra_FROSchFactory_decl.hpp | 12 +- .../src/Adapters/Thyra_FROSchFactory_def.hpp | 12 +- .../Adapters/Thyra_FROSchLinearOp_decl.hpp | 76 ++++++------ .../src/Adapters/Thyra_FROSchLinearOp_def.hpp | 4 +- .../shylu/shylu_dd/frosch/src/CMakeLists.txt | 5 +- .../FROSch_CoarseOperator_decl.hpp | 5 +- .../FROSch_CoarseOperator_def.hpp | 10 +- .../FROSch_GDSWCoarseOperator_decl.hpp | 3 +- .../FROSch_HarmonicCoarseOperator_decl.hpp | 5 +- .../FROSch_HarmonicCoarseOperator_def.hpp | 6 +- ...FROSch_IPOUHarmonicCoarseOperator_decl.hpp | 3 +- .../FROSch_OverlappingOperator_decl.hpp | 9 +- .../FROSch_OverlappingOperator_def.hpp | 8 +- .../FROSch_SchwarzOperator_decl.hpp | 7 +- .../FROSch_SchwarzOperators_fwd.hpp | 109 ++++++++++++++++++ ...lgebraicOverlappingPreconditioner_decl.hpp | 1 - .../FROSch_OneLevelPreconditioner_decl.hpp | 6 +- .../FROSch_SchwarzPreconditioner_decl.hpp | 7 +- .../FROSch_SchwarzPreconditioner_def.hpp | 9 +- .../FROSch_SchwarzPreconditioners_fwd.hpp | 91 +++++++++++++++ .../FROSch_Amesos2SolverEpetra_def.hpp | 6 +- .../FROSch_Amesos2SolverTpetra_def.hpp | 16 +-- .../FROSch_AmesosSolverEpetra_decl.hpp | 4 +- .../FROSch_AmesosSolverEpetra_def.hpp | 11 +- .../FROSch_BelosSolverEpetra_def.hpp | 4 +- .../FROSch_BelosSolverTpetra_def.hpp | 4 +- .../FROSch_FROSchPreconditioner_decl.hpp | 6 +- .../FROSch_FROSchPreconditioner_def.hpp | 23 ++-- ...ROSch_Ifpack2PreconditionerTpetra_decl.hpp | 6 +- ...FROSch_Ifpack2PreconditionerTpetra_def.hpp | 5 +- .../FROSch_SolverFactory_def.hpp | 6 +- .../SolverInterfaces/FROSch_Solver_def.hpp | 4 +- .../FROSch_ThyraPreconditioner_decl.hpp | 5 +- .../FROSch_ThyraPreconditioner_def.hpp | 12 +- .../FROSch_ThyraSolver_decl.hpp | 3 +- .../src/Tools/FROSch_SubdomainSolver_decl.hpp | 18 +-- .../shylu_dd/frosch/test/Gathering/main.cpp | 2 +- .../shylu_dd/frosch/test/Overlap/main.cpp | 2 +- .../frosch/test/SolverFactory/main.cpp | 23 ---- .../test/Thyra_Xpetra_Elasticity/main.cpp | 2 +- .../frosch/test/Thyra_Xpetra_Laplace/main.cpp | 2 +- .../test/Thyra_Xpetra_Stokes_HDF5/main.cpp | 2 +- 44 files changed, 467 insertions(+), 193 deletions(-) create mode 100644 packages/shylu/shylu_dd/frosch/src/Adapters/Stratimikos_FROSch_decl.hpp rename packages/shylu/shylu_dd/frosch/src/Adapters/{Stratimikos_FROSchXpetra.hpp => Stratimikos_FROSch_def.hpp} (80%) create mode 100644 packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_SchwarzOperators_fwd.hpp create mode 100644 packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_SchwarzPreconditioners_fwd.hpp diff --git a/packages/shylu/shylu_dd/frosch/src/Adapters/Stratimikos_FROSch_decl.hpp b/packages/shylu/shylu_dd/frosch/src/Adapters/Stratimikos_FROSch_decl.hpp new file mode 100644 index 000000000000..2cf8aa65a978 --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/Adapters/Stratimikos_FROSch_decl.hpp @@ -0,0 +1,80 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _STRATIMIKOS_FROSCH_DECL_HPP +#define _STRATIMIKOS_FROSCH_DECL_HPP + +#include + +#ifdef HAVE_SHYLU_DDFROSCH_STRATIMIKOS +#include "Stratimikos_DefaultLinearSolverBuilder.hpp" + +#include "Teuchos_RCP.hpp" +#include "Teuchos_ParameterList.hpp" +#include "Teuchos_TestForException.hpp" +#include "Teuchos_AbstractFactoryStd.hpp" + + +namespace Thyra { + + template + class FROSchFactory; +} + +namespace Stratimikos { + + using namespace std; + using namespace Teuchos; + using namespace Thyra; + + template + void enableFROSch(DefaultLinearSolverBuilder& builder, + const string& stratName = "FROSch"); +} // namespace Stratimikos + +#endif + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/Adapters/Stratimikos_FROSchXpetra.hpp b/packages/shylu/shylu_dd/frosch/src/Adapters/Stratimikos_FROSch_def.hpp similarity index 80% rename from packages/shylu/shylu_dd/frosch/src/Adapters/Stratimikos_FROSchXpetra.hpp rename to packages/shylu/shylu_dd/frosch/src/Adapters/Stratimikos_FROSch_def.hpp index 7be7cadae31d..f2895339d605 100644 --- a/packages/shylu/shylu_dd/frosch/src/Adapters/Stratimikos_FROSchXpetra.hpp +++ b/packages/shylu/shylu_dd/frosch/src/Adapters/Stratimikos_FROSch_def.hpp @@ -39,23 +39,13 @@ // ************************************************************************ //@HEADER -#ifndef THYRA_FROSCH_XPETRA_FACTORY_HPP -#define THYRA_FROSCH_XPETRA_FACTORY_HPP +#ifndef _STRATIMIKOS_FROSCH_DEF_HPP +#define _STRATIMIKOS_FROSCH_DEF_HPP -#include - -#ifdef HAVE_SHYLU_DDFROSCH_STRATIMIKOS -#include "Stratimikos_DefaultLinearSolverBuilder.hpp" +#include "Stratimikos_FROSch_decl.hpp" #include "Thyra_FROSchFactory_def.hpp" -#include "Teuchos_RCP.hpp" -#include "Teuchos_ParameterList.hpp" -#include "Teuchos_TestForException.hpp" -#include "Teuchos_AbstractFactoryStd.hpp" - -#include - namespace Stratimikos { @@ -63,18 +53,18 @@ namespace Stratimikos { using namespace Teuchos; using namespace Thyra; - template + template void enableFROSch (DefaultLinearSolverBuilder& builder, - const string& stratName = "FROSch") + const string& stratName) { const RCP precValidParams = sublist(builder.getValidParameters(), "Preconditioner Types"); TEUCHOS_TEST_FOR_EXCEPTION(precValidParams->isParameter(stratName), logic_error, "Stratimikos::enableFROSch cannot add \"" + stratName +"\" because it is already included in builder!"); - using Base = PreconditionerFactoryBase; + using Base = PreconditionerFactoryBase; if (!stratName.compare("FROSch")) { - using Impl = FROSchFactory ; + using Impl = FROSchFactory; builder.setPreconditioningStrategyFactory(abstractFactoryStd(), stratName); } } @@ -82,5 +72,3 @@ namespace Stratimikos { } // namespace Stratimikos #endif - -#endif diff --git a/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchFactory_decl.hpp b/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchFactory_decl.hpp index b1c176bcbf30..6154684d97d9 100644 --- a/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchFactory_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchFactory_decl.hpp @@ -39,8 +39,8 @@ // ************************************************************************ //@HEADER -#ifndef THYRA_FROSCH_XPETRA_FACTORY_DECL_HPP -#define THYRA_FROSCH_XPETRA_FACTORY_DECL_HPP +#ifndef _THYRA_FROSCH_FACTORY_DECL_HPP +#define _THYRA_FROSCH_FACTORY_DECL_HPP #include @@ -83,15 +83,11 @@ #endif //FROSch -#include -#include -#include -#include -#include -#include #include #include +#include + namespace Thyra { diff --git a/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchFactory_def.hpp b/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchFactory_def.hpp index a224a59d70ad..81a25d39ea37 100644 --- a/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchFactory_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchFactory_def.hpp @@ -39,18 +39,24 @@ // ************************************************************************ //@HEADER -#ifndef THYRA_FROSCH_XPETRA_FACTORY_DEF_HPP -#define THYRA_FROSCH_XPETRA_FACTORY_DEF_HPP +#ifndef _THYRA_FROSCH_FACTORY_DEF_HPP +#define _THYRA_FROSCH_FACTORY_DEF_HPP #include "Thyra_FROSchFactory_decl.hpp" +#include +#include +#include +#include +#include +#include + namespace Thyra { using namespace FROSch; using namespace std; using namespace Teuchos; - using namespace Thyra; using namespace Xpetra; //Constructor diff --git a/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchLinearOp_decl.hpp b/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchLinearOp_decl.hpp index f877b5ad0844..c12a43e46755 100644 --- a/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchLinearOp_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchLinearOp_decl.hpp @@ -39,8 +39,8 @@ // ************************************************************************ //@HEADER -#ifndef THYRA_FROSCH_LINEAR_OP_DECL_HPP -#define THYRA_FROSCH_LINEAR_OP_DECL_HPP +#ifndef _THYRA_FROSCH_LINEAR_OP_DECL_HPP +#define _THYRA_FROSCH_LINEAR_OP_DECL_HPP #include @@ -98,14 +98,17 @@ namespace Thyra { + using namespace FROSch; using namespace Teuchos; using namespace Thyra; using namespace Xpetra; /** \brief Concrete Thyra::LinearOpBase subclass for Operator.**/ - template - class FROSchLinearOp : virtual public LinearOpDefaultBase { + template + class FROSchLinearOp : virtual public LinearOpDefaultBase { public: /** \name Constructors/initializers. */ @@ -115,24 +118,24 @@ namespace Thyra { FROSchLinearOp(); /** \brief Initialize. */ - void initialize(const RCP > &rangeSpace, - const RCP > &domainSpace, - const RCP > &xpetraOperator, + void initialize(const RCP > &rangeSpace, + const RCP > &domainSpace, + const RCP > &xpetraOperator, bool bIsEpetra, bool bIsTpetra); /** \brief Initialize. */ - void constInitialize(const RCP > &rangeSpace, - const RCP > &domainSpace, - const RCP > &xpetraOperator, + void constInitialize(const RCP > &rangeSpace, + const RCP > &domainSpace, + const RCP > &xpetraOperator, bool bIsEpetra, bool bIsTpetra); /** \brief Get embedded non-const Operator. */ - RCP > getXpetraOperator(); + RCP > getXpetraOperator(); /** \brief Get embedded const Operator. */ - RCP > getConstXpetraOperator() const; + RCP > getConstXpetraOperator() const; //@} @@ -140,10 +143,10 @@ namespace Thyra { //@{ /** \brief . */ - RCP > range() const; + RCP > range() const; /** \brief . */ - RCP > domain() const; + RCP > domain() const; //@} @@ -157,31 +160,31 @@ namespace Thyra { /** \brief . */ void applyImpl(const EOpTransp M_trans, - const MultiVectorBase &X_in, - const Ptr > &Y_inout, - const Scalar alpha, - const Scalar beta + const MultiVectorBase &X_in, + const Ptr > &Y_inout, + const SC alpha, + const SC beta ) const; //@} private: - RCP > + RCP > rangeSpace_; - RCP > + RCP > domainSpace_; bool bIsEpetra_; bool bIsTpetra_; - ConstNonconstObjectContainer > + ConstNonconstObjectContainer > xpetraOperator_; template - void initializeImpl(const RCP > &rangeSpace, - const RCP > &domainSpace, + void initializeImpl(const RCP > &rangeSpace, + const RCP > &domainSpace, const RCP &xpetraOperator, bool bIsEpetra, bool bIsTpetra); @@ -192,15 +195,15 @@ namespace Thyra { * * \relates XpetraLinearOp */ - template - RCP > fROSchLinearOp(const RCP > &rangeSpace, - const RCP > &domainSpace, - const RCP > &xpetraOperator, + template + RCP > fROSchLinearOp(const RCP > &rangeSpace, + const RCP > &domainSpace, + const RCP > &xpetraOperator, bool bIsEpetra, bool bIsTpetra) { - const RCP > op = - rcp(new FROSchLinearOp); + const RCP > op = + rcp(new FROSchLinearOp); op->initialize(rangeSpace,domainSpace,xpetraOperator,bIsEpetra,bIsTpetra); return op; } @@ -210,15 +213,15 @@ namespace Thyra { * * \relates XpetraLinearOp */ - template - RCP > constFROSchLinearOp(const RCP > &rangeSpace, - const RCP > &domainSpace, - const RCP > &xpetraOperator, + template + RCP > constFROSchLinearOp(const RCP > &rangeSpace, + const RCP > &domainSpace, + const RCP > &xpetraOperator, bool bIsEpetra, bool bIsTpetra) { - const RCP > op = - rcp(new FROSchLinearOp); + const RCP > op = + rcp(new FROSchLinearOp); op->constInitialize(rangeSpace, domainSpace, xpetraOperator,bIsEpetra,bIsTpetra); return op; } @@ -228,4 +231,3 @@ namespace Thyra { #endif #endif // THYRA_XPETRA_LINEAR_OP_DECL_HPP - diff --git a/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchLinearOp_def.hpp b/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchLinearOp_def.hpp index add180124cc3..9167f998c349 100644 --- a/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchLinearOp_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/Adapters/Thyra_FROSchLinearOp_def.hpp @@ -39,8 +39,8 @@ // ************************************************************************ //@HEADER -#ifndef THYRA_FROSCH_LINEAR_OP_DEF_HPP -#define THYRA_FROSCH_LINEAR_OP_DEF_HPP +#ifndef _THYRA_FROSCH_LINEAR_OP_DEF_HPP +#define _THYRA_FROSCH_LINEAR_OP_DEF_HPP #include "Thyra_FROSchLinearOp_decl.hpp" diff --git a/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt b/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt index 3124043e43d3..1efe138e94cb 100644 --- a/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt +++ b/packages/shylu/shylu_dd/frosch/src/CMakeLists.txt @@ -55,7 +55,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) #INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/packages/muelu/adapters/belos) APPEND_SET(HEADERS - Adapters/Stratimikos_FROSchXpetra.hpp + Adapters/Stratimikos_FROSch_decl.hpp + Adapters/Stratimikos_FROSch_def.hpp Adapters/Thyra_FROSchFactory_decl.hpp Adapters/Thyra_FROSchFactory_def.hpp Adapters/Thyra_FROSchLinearOp_decl.hpp @@ -100,6 +101,7 @@ APPEND_SET(HEADERS SchwarzOperators/FROSch_RGDSWCoarseOperator_def.hpp SchwarzOperators/FROSch_SchwarzOperator_decl.hpp SchwarzOperators/FROSch_SchwarzOperator_def.hpp + SchwarzOperators/FROSch_SchwarzOperators_fwd.hpp SchwarzOperators/FROSch_SumOperator_decl.hpp SchwarzOperators/FROSch_SumOperator_def.hpp SchwarzPreconditioners/FROSch_AlgebraicOverlappingPreconditioner_decl.hpp @@ -112,6 +114,7 @@ APPEND_SET(HEADERS SchwarzPreconditioners/FROSch_RGDSWPreconditioner_def.hpp SchwarzPreconditioners/FROSch_SchwarzPreconditioner_decl.hpp SchwarzPreconditioners/FROSch_SchwarzPreconditioner_def.hpp + SchwarzPreconditioners/FROSch_SchwarzPreconditioners_fwd.hpp SchwarzPreconditioners/FROSch_TwoLevelBlockPreconditioner_decl.hpp SchwarzPreconditioners/FROSch_TwoLevelBlockPreconditioner_def.hpp SchwarzPreconditioners/FROSch_TwoLevelPreconditioner_decl.hpp diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_decl.hpp index d92f62375495..c918a11b3060 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_decl.hpp @@ -110,7 +110,8 @@ namespace FROSch { using CoarseSpacePtr = typename SchwarzOperator::CoarseSpacePtr; - using SubdomainSolverPtr = typename SchwarzOperator::SubdomainSolverPtr; + using SolverPtr = typename SchwarzOperator::SolverPtr; + using SolverFactoryPtr = typename SchwarzOperator::SolverFactoryPtr; using UN = typename SchwarzOperator::UN; @@ -226,7 +227,7 @@ namespace FROSch { UN PartitionType_; - SubdomainSolverPtr CoarseSolver_; + SolverPtr CoarseSolver_; ParameterListPtr DistributionList_; diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_def.hpp index 92ad91eba4e3..8c0fa48f4d2d 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_def.hpp @@ -162,7 +162,7 @@ namespace FROSch { #ifdef FROSCH_COARSEOPERATOR_DETAIL_TIMERS FROSCH_DETAILTIMER_START_LEVELID(applyTime,"apply"); #endif - Phi_->apply(x,*XCoarse_,TRANS); + Phi_->apply(x,*XCoarse_,Teuchos::TRANS); } for (UN j=0; j::Build(GatheringMaps_[j],x.getNumVectors()); // AH 08/22/2019 TODO: Can we get rid of this? If possible, we should remove the whole GatheringMaps idea and replace it by some smart all-to-all MPI communication @@ -539,13 +539,13 @@ namespace FROSch { } if (!reuseCoarseMatrixSymbolicFactorization) { if (this->IsComputed_ && this->Verbose_) cout << "FROSch::CoarseOperator : Recomputing the Symbolic Factorization of the coarse matrix" << endl; - CoarseSolver_.reset(new SubdomainSolver(CoarseMatrix_, - sublist(this->ParameterList_,"CoarseSolver"), - string("CoarseSolver (Level ") + to_string(this->LevelID_) + string(")"))); + CoarseSolver_ = SolverFactory::Build(CoarseMatrix_, + sublist(this->ParameterList_,"CoarseSolver"), + string("CoarseSolver (Level ") + to_string(this->LevelID_) + string(")")); CoarseSolver_->initialize(); } else { FROSCH_ASSERT(!CoarseSolver_.is_null(),"FROSch::CoarseOperator: CoarseSolver_.is_null()"); - CoarseSolver_->resetMatrix(CoarseMatrix_.getConst(),true); + CoarseSolver_->updateMatrix(CoarseMatrix_.getConst(),true); } CoarseSolver_->compute(); } diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_GDSWCoarseOperator_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_GDSWCoarseOperator_decl.hpp index 575937f17632..6e0e9b8fb403 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_GDSWCoarseOperator_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_GDSWCoarseOperator_decl.hpp @@ -82,7 +82,8 @@ namespace FROSch { using EntitySetPtr = typename SchwarzOperator::EntitySetPtr; - using SubdomainSolverPtr = typename SchwarzOperator::SubdomainSolverPtr; + using SolverPtr = typename SchwarzOperator::SolverPtr; + using SolverFactoryPtr = typename SchwarzOperator::SolverFactoryPtr; using UN = typename SchwarzOperator::UN; using UNVecPtr = typename SchwarzOperator::UNVecPtr; diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_decl.hpp index a88bda540fe9..f3a9ec92bbfc 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_decl.hpp @@ -93,7 +93,8 @@ namespace FROSch { using InterfaceEntityPtrVec = typename SchwarzOperator::InterfaceEntityPtrVec; using InterfaceEntityPtrVecPtr = typename SchwarzOperator::InterfaceEntityPtrVecPtr; - using SubdomainSolverPtr = typename SchwarzOperator::SubdomainSolverPtr; + using SolverPtr = typename SchwarzOperator::SolverPtr; + using SolverFactoryPtr = typename SchwarzOperator::SolverFactoryPtr; using UN = typename SchwarzOperator::UN; using UNVec = typename SchwarzOperator::UNVec; @@ -176,7 +177,7 @@ namespace FROSch { virtual int buildCoarseGraph(); - SubdomainSolverPtr ExtensionSolver_; + SolverPtr ExtensionSolver_; CoarseSpacePtrVecPtr InterfaceCoarseSpaces_ = CoarseSpacePtrVecPtr(0); CoarseSpacePtr AssembledInterfaceCoarseSpace_; diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp index 8a913f48043f..72abcad0a1ae 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp @@ -733,9 +733,9 @@ namespace FROSch { // Jetzt der solver für kII if (indicesIDofsAll.size()>0) { - ExtensionSolver_.reset(new SubdomainSolver(kII, - sublist(this->ParameterList_,"ExtensionSolver"), - string("ExtensionSolver (Level ") + to_string(this->LevelID_) + string(")"))); + ExtensionSolver_ = SolverFactory::Build(kII, + sublist(this->ParameterList_,"ExtensionSolver"), + string("ExtensionSolver (Level ") + to_string(this->LevelID_) + string(")")); ExtensionSolver_->initialize(); ExtensionSolver_->compute(); ExtensionSolver_->apply(*mVtmp,*mVPhiI); diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_IPOUHarmonicCoarseOperator_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_IPOUHarmonicCoarseOperator_decl.hpp index a6f54092af4e..d7ee14e6d062 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_IPOUHarmonicCoarseOperator_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_IPOUHarmonicCoarseOperator_decl.hpp @@ -99,7 +99,8 @@ namespace FROSch { using LocalPartitionOfUnityBasisPtr = typename SchwarzOperator::LocalPartitionOfUnityBasisPtr; - using SubdomainSolverPtr = typename SchwarzOperator::SubdomainSolverPtr; + using SolverPtr = typename SchwarzOperator::SolverPtr; + using SolverFactoryPtr = typename SchwarzOperator::SolverFactoryPtr; using UN = typename SchwarzOperator::UN; using UNVecPtr = typename SchwarzOperator::UNVecPtr; diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_OverlappingOperator_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_OverlappingOperator_decl.hpp index ab5abd78ee8e..8000fb2c080c 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_OverlappingOperator_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_OverlappingOperator_decl.hpp @@ -74,7 +74,8 @@ namespace FROSch { using ParameterListPtr = typename SchwarzOperator::ParameterListPtr; - using SubdomainSolverPtr = typename SchwarzOperator::SubdomainSolverPtr; + using SolverPtr = typename SchwarzOperator::SolverPtr; + using SolverFactoryPtr = typename SchwarzOperator::SolverFactoryPtr; using SCVecPtr = typename SchwarzOperator::SCVecPtr; using ConstSCVecPtr = typename SchwarzOperator::ConstSCVecPtr; @@ -108,8 +109,8 @@ namespace FROSch { virtual int computeOverlappingOperator(); virtual int updateLocalOverlappingMatrices() = 0; - - + + ConstXMatrixPtr OverlappingMatrix_; ConstXMapPtr OverlappingMap_; @@ -122,7 +123,7 @@ namespace FROSch { XImportPtr Scatter_; - SubdomainSolverPtr SubdomainSolver_; + SolverPtr SubdomainSolver_; XMultiVectorPtr Multiplicity_; diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_OverlappingOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_OverlappingOperator_def.hpp index aeaf2129cf8f..65753d1fb285 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_OverlappingOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_OverlappingOperator_def.hpp @@ -211,13 +211,13 @@ namespace FROSch { if (!reuseSymbolicFactorization) { if (this->IsComputed_ && this->Verbose_) cout << "FROSch::OverlappingOperator : Recomputing the Symbolic Factorization" << endl; - SubdomainSolver_.reset(new SubdomainSolver(OverlappingMatrix_, - sublist(this->ParameterList_,"Solver"), - string("Solver (Level ") + to_string(this->LevelID_) + string(")"))); + SubdomainSolver_ = SolverFactory::Build(OverlappingMatrix_, + sublist(this->ParameterList_,"Solver"), + string("Solver (Level ") + to_string(this->LevelID_) + string(")")); SubdomainSolver_->initialize(); } else { FROSCH_ASSERT(!SubdomainSolver_.is_null(),"FROSch::OverlappingOperator: SubdomainSolver_.is_null()"); - SubdomainSolver_->resetMatrix(OverlappingMatrix_,true); + SubdomainSolver_->updateMatrix(OverlappingMatrix_,true); } this->IsComputed_ = true; return SubdomainSolver_->compute(); diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_SchwarzOperator_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_SchwarzOperator_decl.hpp index 921d59a6c3dd..dc953563acec 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_SchwarzOperator_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_SchwarzOperator_decl.hpp @@ -59,7 +59,7 @@ #include #include -#include +#include // TODO: Auf const überprüfen // TODO: #ifndef überprüfen ?????? @@ -71,8 +71,6 @@ namespace FROSch { using namespace Teuchos; using namespace Xpetra; - class Solver; - template ; using SchwarzOperatorPtrVecPtr = ArrayRCP; - using SubdomainSolverPtr = RCP >; + using SolverPtr = RCP >; + using SolverFactoryPtr = RCP >; using DofOrderingVecPtr = ArrayRCP; diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_SchwarzOperators_fwd.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_SchwarzOperators_fwd.hpp new file mode 100644 index 000000000000..c1844c8b100e --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_SchwarzOperators_fwd.hpp @@ -0,0 +1,109 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_SCHWARZOPERATORS_FWD_HPP +#define _FROSCH_SCHWARZOPERATORS_FWD_HPP + +namespace FROSch { + + template + class AlgebraicOverlappingOperator; + + template + class CoarseOperator; + + template + class GDSWCoarseOperator; + + template + class HarmonicCoarseOperator; + + template + class IPOUHarmonicCoarseOperator; + + template + class MultiplicativeOperator; + + template + class OverlappingOperator; + + template + class RGDSWCoarseOperator; + + template + class SchwarzOperator; + + template + class SumOperator; + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_AlgebraicOverlappingPreconditioner_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_AlgebraicOverlappingPreconditioner_decl.hpp index 6098f7820458..c6cbd08716db 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_AlgebraicOverlappingPreconditioner_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_AlgebraicOverlappingPreconditioner_decl.hpp @@ -107,7 +107,6 @@ namespace FROSch { SumOperatorPtr SumOperator_; AlgebraicOverlappingOperatorPtr OverlappingOperator_; - }; } diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_OneLevelPreconditioner_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_OneLevelPreconditioner_decl.hpp index 4765e5641f81..0244814d33f4 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_OneLevelPreconditioner_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_OneLevelPreconditioner_decl.hpp @@ -39,8 +39,8 @@ // ************************************************************************ //@HEADER -#ifndef _FROSCH_ONELEVELPRECONDITIONER__DECL_HPP -#define _FROSCH_ONELEVELPRECONDITIONER__DECL_HPP +#ifndef _FROSCH_ONELEVELPRECONDITIONER_DECL_HPP +#define _FROSCH_ONELEVELPRECONDITIONER_DECL_HPP #include @@ -49,7 +49,7 @@ namespace FROSch { using namespace std; using namespace Teuchos; - using namespace Xpetra; + using namespace Xpetra; template #include -#include -#include -#include -#include -#include -#include +#include namespace FROSch { diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_SchwarzPreconditioner_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_SchwarzPreconditioner_def.hpp index 0e825af73ea9..ed21bbb5a0d1 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_SchwarzPreconditioner_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_SchwarzPreconditioner_def.hpp @@ -44,6 +44,13 @@ #include +#include +#include +#include +#include +#include +#include + namespace FROSch { @@ -82,7 +89,7 @@ namespace FROSch { template void SchwarzPreconditioner::residual(const XMultiVector & X, const XMultiVector & B, - XMultiVector& R) const + XMultiVector& R) const { SC one = Teuchos::ScalarTraits::one(), negone = -one; apply(X,R); diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_SchwarzPreconditioners_fwd.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_SchwarzPreconditioners_fwd.hpp new file mode 100644 index 000000000000..48099d3e90fe --- /dev/null +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzPreconditioners/FROSch_SchwarzPreconditioners_fwd.hpp @@ -0,0 +1,91 @@ +//@HEADER +// ************************************************************************ +// +// ShyLU: Hybrid preconditioner package +// 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 Alexander Heinlein (alexander.heinlein@uni-koeln.de) +// +// ************************************************************************ +//@HEADER + +#ifndef _FROSCH_SCHWARZPRECONDITIONERS_FWD_HPP +#define _FROSCH_SCHWARZPRECONDITIONERS_FWD_HPP + +namespace FROSch { + + template + class AlgebraicOverlappingPreconditioner; + + template + class GDSWPreconditioner; + + template + class OneLevelPreconditioner; + + template + class RGDSWPreconditioner; + + template + class SchwarzPreconditioner; + + template + class TwoLevelBlockPreconditioner; + + template + class TwoLevelPreconditioner; + +} + +#endif diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp index 59c284156a37..8ee2a7a423c6 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp @@ -142,9 +142,11 @@ namespace FROSch { EMultiVectorPtr xTmp; EMultiVectorPtr bTmp; - Amesos2Solver_ = Amesos2::create(this->ParameterList_->get("Solver","Klu"),epetraMat,xTmp,bTmp); - ParameterListPtr amesos2ParameterList = sublist(sublist(this->ParameterList_,"Amesos2"),this->ParameterList_->get("Solver","Klu")); + ParameterListPtr amesos2ParameterList = sublist(this->ParameterList_,"Amesos2"); + if (amesos2ParameterList->isSublist(this->ParameterList_->get("Solver","Klu"))) amesos2ParameterList = sublist(amesos2ParameterList,this->ParameterList_->get("Solver","Klu")); amesos2ParameterList->setName("Amesos2"); + + Amesos2Solver_ = Amesos2::create(this->ParameterList_->get("Solver","Klu"),epetraMat,xTmp,bTmp); Amesos2Solver_->setParameters(amesos2ParameterList); } diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp index bbd6dd671150..47fc302b692d 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp @@ -79,10 +79,10 @@ namespace FROSch { template void Amesos2SolverTpetra::apply(const XMultiVector &x, - XMultiVector &y, - ETransp mode, - SC alpha, - SC beta) const + XMultiVector &y, + ETransp mode, + SC alpha, + SC beta) const { FROSCH_TIMER_START_SOLVER(applyTime,"Amesos2SolverTpetra::apply"); FROSCH_ASSERT(this->IsComputed_,"FROSch::Amesos2SolverTpetra: !this->IsComputed_."); @@ -105,7 +105,7 @@ namespace FROSch { template int Amesos2SolverTpetra::updateMatrix(ConstXMatrixPtr k, - bool reuseInitialize) + bool reuseInitialize) { FROSCH_TIMER_START_SOLVER(updateMatrixTime,"Amesos2SolverTpetra::updateMatrix"); this->K_ = k; @@ -142,9 +142,11 @@ namespace FROSch { TMultiVectorPtr xTmp; TMultiVectorPtr bTmp; - Amesos2Solver_ = Amesos2::create(this->ParameterList_->get("Solver","Klu"),tpetraMat,xTmp,bTmp); - ParameterListPtr amesos2ParameterList = sublist(sublist(this->ParameterList_,"Amesos2"),this->ParameterList_->get("Solver","Klu")); + ParameterListPtr amesos2ParameterList = sublist(this->ParameterList_,"Amesos2"); + if (amesos2ParameterList->isSublist(this->ParameterList_->get("Solver","Klu"))) amesos2ParameterList = sublist(amesos2ParameterList,this->ParameterList_->get("Solver","Klu")); amesos2ParameterList->setName("Amesos2"); + + Amesos2Solver_ = Amesos2::create(this->ParameterList_->get("Solver","Klu"),tpetraMat,xTmp,bTmp); Amesos2Solver_->setParameters(amesos2ParameterList); } diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_decl.hpp index 293daf9ba164..8139461f4ff3 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_decl.hpp @@ -123,8 +123,8 @@ namespace FROSch { //! Constructor AmesosSolverEpetra(ConstXMatrixPtr k, - ParameterListPtr parameterList, - string description); + ParameterListPtr parameterList, + string description); mutable XMultiVectorPtr Y_ = null; diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp index 79ef54f60c37..30624a03d861 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp @@ -80,10 +80,10 @@ namespace FROSch { template void AmesosSolverEpetra::apply(const XMultiVector &x, - XMultiVector &y, - ETransp mode, - SC alpha, - SC beta) const + XMultiVector &y, + ETransp mode, + SC alpha, + SC beta) const { FROSCH_TIMER_START_SOLVER(applyTime,"AmesosSolverEpetra::apply"); FROSCH_ASSERT(this->IsComputed_,"FROSch::AmesosSolverEpetra: !this->IsComputed_."); @@ -136,7 +136,8 @@ namespace FROSch { Amesos amesosFactory; AmesosSolver_.reset(amesosFactory.Create(this->ParameterList_->get("Solver","Klu"),*EpetraLinearProblem_)); - ParameterListPtr amesosParameterList = sublist(sublist(this->ParameterList_,"Amesos"),this->ParameterList_->get("Solver","Klu")); + ParameterListPtr amesosParameterList = sublist(this->ParameterList_,"Amesos"); + if (amesosParameterList->isSublist(this->ParameterList_->get("Solver","Klu"))) amesosParameterList = sublist(amesosParameterList,this->ParameterList_->get("Solver","Klu")); AmesosSolver_->SetParameters(*amesosParameterList); } diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp index 5bcb93453d43..b4914489871c 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp @@ -130,8 +130,10 @@ namespace FROSch { BelosLinearProblem_.reset(new BelosLinearProblem(epetraMat,xTmp,bTmp)); + ParameterListPtr belosParameterList = sublist(this->ParameterList_,"Belos"); + if (belosParameterList->isSublist(this->ParameterList_->get("Solver","GMRES"))) belosParameterList = sublist(belosParameterList,this->ParameterList_->get("Solver","GMRES")); + BelosSolverFactory belosFactory; - ParameterListPtr belosParameterList = sublist(sublist(this->ParameterList_,"Belos"),this->ParameterList_->get("Solver","GMRES")); BelosSolver_ = belosFactory.create(this->ParameterList_->get("Solver","GMRES"),belosParameterList); BelosSolver_->setProblem(BelosLinearProblem_); } diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp index ebc496481518..4485750b495e 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp @@ -130,8 +130,10 @@ namespace FROSch { BelosLinearProblem_.reset(new BelosLinearProblem(tpetraMat,xTmp,bTmp)); + ParameterListPtr belosParameterList = sublist(this->ParameterList_,"Belos"); + if (belosParameterList->isSublist(this->ParameterList_->get("Solver","GMRES"))) belosParameterList = sublist(belosParameterList,this->ParameterList_->get("Solver","GMRES")); + BelosSolverFactory belosFactory; - ParameterListPtr belosParameterList = sublist(sublist(this->ParameterList_,"Belos"),this->ParameterList_->get("Solver","GMRES")); BelosSolver_ = belosFactory.create(this->ParameterList_->get("Solver","GMRES"),belosParameterList); BelosSolver_->setProblem(BelosLinearProblem_); } diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_decl.hpp index 6ffa4b0cbd4d..6104f7575514 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_decl.hpp @@ -45,10 +45,10 @@ #include // FROSch -#include -#include #include +#include + namespace FROSch { @@ -111,7 +111,7 @@ namespace FROSch { SC beta=ScalarTraits::zero()) const; int updateMatrix(ConstXMatrixPtr k, - bool reuseInitialize=false); + bool reuseInitialize=false); protected: diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_def.hpp index 549aa75c07c2..80f0590da3eb 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_FROSchPreconditioner_def.hpp @@ -43,7 +43,8 @@ #define _FROSCH_FROSCHPRECONDITIONER_DEF_HPP #include - +#include +#include namespace FROSch { @@ -72,10 +73,10 @@ namespace FROSch { template void FROSchPreconditioner::apply(const XMultiVector &x, - XMultiVector &y, - ETransp mode, - SC alpha, - SC beta) const + XMultiVector &y, + ETransp mode, + SC alpha, + SC beta) const { FROSCH_TIMER_START_SOLVER(applyTime,"FROSchPreconditioner::apply"); FROSCH_ASSERT(this->IsComputed_,"FROSch::FROSchPreconditioner: !this->IsComputed_."); @@ -85,7 +86,7 @@ namespace FROSch { template int FROSchPreconditioner::updateMatrix(ConstXMatrixPtr k, - bool reuseInitialize) + bool reuseInitialize) { FROSCH_ASSERT(false,"FROSch::FROSchPreconditioner: updateMatrix() is not implemented for the FROSchPreconditioner yet."); return 0; @@ -93,15 +94,16 @@ namespace FROSch { template FROSchPreconditioner::FROSchPreconditioner(ConstXMatrixPtr k, - ParameterListPtr parameterList, - string description) : + ParameterListPtr parameterList, + string description) : Solver (k,parameterList,description) { FROSCH_TIMER_START_SOLVER(FROSchPreconditionerTime,"FROSchPreconditioner::FROSchPreconditioner"); FROSCH_ASSERT(!this->K_.is_null(),"FROSch::FROSchPreconditioner: K_ is null."); if (!this->ParameterList_->get("Solver","TwoLevelPreconditioner").compare("TwoLevelPreconditioner")) { - ParameterListPtr froschParameterList = sublist(sublist(this->ParameterList_,"FROSchPreconditioner"),this->ParameterList_->get("Solver","TwoLevelPreconditioner")); + ParameterListPtr froschParameterList = sublist(this->ParameterList_,"FROSchPreconditioner"); + if (froschParameterList->isSublist(this->ParameterList_->get("Solver","TwoLevelPreconditioner"))) froschParameterList = sublist(froschParameterList,this->ParameterList_->get("Solver","TwoLevelPreconditioner")); // if (this->K_->getMap()->getComm()->getRank() == 0) froschParameterList->print(cout); ArrayRCP > > RepeatedMaps(1); @@ -152,7 +154,8 @@ namespace FROSch { FROSchPreconditioner_ = twoLevelPreconditioner; } else if (!this->ParameterList_->get("Solver","TwoLevelPreconditioner").compare("TwoLevelBlockPreconditioner")) { - ParameterListPtr froschParameterList = sublist(sublist(this->ParameterList_,"FROSchPreconditioner"),this->ParameterList_->get("Solver","TwoLevelPreconditioner")); + ParameterListPtr froschParameterList = sublist(this->ParameterList_,"FROSchPreconditioner"); + if (froschParameterList->isSublist(this->ParameterList_->get("Solver","TwoLevelPreconditioner"))) froschParameterList = sublist(froschParameterList,this->ParameterList_->get("Solver","TwoLevelPreconditioner")); // if (this->K_->getMap()->getComm()->getRank() == 0) froschParameterList->print(cout); ArrayRCP > > RepeatedMaps(1); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_decl.hpp index 2f0e8de33d0f..907b6336064b 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_decl.hpp @@ -44,6 +44,8 @@ #include +#include + // FROSch #include @@ -118,8 +120,8 @@ namespace FROSch { //! Constructor Ifpack2PreconditionerTpetra(ConstXMatrixPtr k, - ParameterListPtr parameterList, - string description); + ParameterListPtr parameterList, + string description); Ifpack2PreconditionerPtr Ifpack2Preconditioner_ = null; diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp index 8bf8f4c24002..5d8cc2cbf4df 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp @@ -92,7 +92,7 @@ namespace FROSch { template int Ifpack2PreconditionerTpetra::updateMatrix(ConstXMatrixPtr k, - bool reuseInitialize) + bool reuseInitialize) { FROSCH_ASSERT(false,"FROSch::Ifpack2PreconditionerTpetra: updateMatrix() is not implemented for the Ifpack2PreconditionerTpetra yet."); return 0; @@ -116,7 +116,8 @@ namespace FROSch { Ifpack2::Details::OneLevelFactory ifpack2Factory; Ifpack2Preconditioner_ = ifpack2Factory.create(this->ParameterList_->get("Solver","RILUK"),tpetraMat); - ParameterListPtr ifpack2ParameterList = sublist(sublist(this->ParameterList_,"Ifpack2"),this->ParameterList_->get("Solver","RILUK")); + ParameterListPtr ifpack2ParameterList = sublist(this->ParameterList_,"Ifpack2"); + if (ifpack2ParameterList->isSublist(this->ParameterList_->get("Solver","RILUK"))) ifpack2ParameterList = sublist(ifpack2ParameterList,this->ParameterList_->get("Solver","RILUK")); ifpack2ParameterList->setName("Ifpack2"); Ifpack2Preconditioner_->setParameters(*ifpack2ParameterList); } diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp index 1bd96e3f670f..0de39139dc0b 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp @@ -44,6 +44,8 @@ #include "FROSch_SolverFactory_decl.hpp" +#include "Stratimikos_FROSch_def.hpp" + namespace FROSch { @@ -94,6 +96,8 @@ namespace FROSch { #else ThrowErrorMissingPackage("FROSch::SolverFactory","Belos"); #endif + } else if (!parameterList->get("SolverType","Amesos2").compare("FROSchPreconditioner")) { + return FROSchPreconditionerPtr(new FROSchPreconditioner(k,parameterList,description)); } else if (!parameterList->get("SolverType","Amesos2").compare("Ifpack2")) { #ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 FROSCH_ASSERT(k->getRowMap()->lib()==UseTpetra,"FROSch::SolverFactory: Ifpack2 is not compatible with Epetra."); @@ -127,8 +131,6 @@ namespace FROSch { #else ThrowErrorMissingPackage("FROSch::SolverFactory","Thyra"); #endif - } else if (!parameterList->get("SolverType","Amesos2").compare("FROSchPreconditioner")) { - return FROSchPreconditionerPtr(new FROSchPreconditioner(k,parameterList,description)); } else { FROSCH_ASSERT(false,"SolverType unknown..."); } diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_def.hpp index 4f148c849842..88268a2b4589 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_def.hpp @@ -76,8 +76,8 @@ namespace FROSch { template void Solver::residual(const XMultiVector & x, - const XMultiVector & b, - XMultiVector& r) const + const XMultiVector & b, + XMultiVector& r) const { apply(x,r); r.update(ScalarTraits::one(),b,-ScalarTraits::one()); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_decl.hpp index 6d4780fb1176..4f72f86dd08c 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_decl.hpp @@ -44,8 +44,9 @@ #include -#include "Stratimikos_DefaultLinearSolverBuilder.hpp" -#include "Stratimikos_FROSchXpetra.hpp" +#include "Stratimikos_FROSch_decl.hpp" + +#include // FROSch #include diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_def.hpp index 5cbff313c2bd..ea897ab9361f 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraPreconditioner_def.hpp @@ -72,10 +72,10 @@ namespace FROSch { template void ThyraPreconditioner::apply(const XMultiVector &x, - XMultiVector &y, - ETransp mode, - SC alpha, - SC beta) const + XMultiVector &y, + ETransp mode, + SC alpha, + SC beta) const { FROSCH_TIMER_START_SOLVER(applyTime,"ThyraPreconditioner::apply"); FROSCH_ASSERT(this->IsComputed_,"FROSch::ThyraPreconditioner: !this->IsComputed_."); @@ -104,8 +104,8 @@ namespace FROSch { template ThyraPreconditioner::ThyraPreconditioner(ConstXMatrixPtr k, - ParameterListPtr parameterList, - string description) : + ParameterListPtr parameterList, + string description) : Solver (k,parameterList,description) { FROSCH_TIMER_START_SOLVER(ThyraPreconditionerTime,"ThyraPreconditioner::ThyraPreconditioner"); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_decl.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_decl.hpp index 9f15bd5d2101..94de6d95446a 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_ThyraSolver_decl.hpp @@ -44,8 +44,7 @@ #include -#include "Stratimikos_DefaultLinearSolverBuilder.hpp" -#include "Stratimikos_FROSchXpetra.hpp" +#include "Stratimikos_FROSch_decl.hpp" // FROSch #include diff --git a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_decl.hpp b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_decl.hpp index 7f726e7c282b..46d0c62cf896 100644 --- a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_decl.hpp +++ b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_SubdomainSolver_decl.hpp @@ -95,21 +95,21 @@ namespace FROSch { using namespace Xpetra; template + class LO, + class GO, + class NO> class OneLevelPreconditioner; template + class LO, + class GO, + class NO> class TwoLevelPreconditioner; template + class LO, + class GO, + class NO> class TwoLevelBlockPreconditioner; template // Stratimikos includes -#include +#include #include diff --git a/packages/shylu/shylu_dd/frosch/test/Overlap/main.cpp b/packages/shylu/shylu_dd/frosch/test/Overlap/main.cpp index 527b36bd1540..a525c24429d2 100644 --- a/packages/shylu/shylu_dd/frosch/test/Overlap/main.cpp +++ b/packages/shylu/shylu_dd/frosch/test/Overlap/main.cpp @@ -74,7 +74,7 @@ #include // Stratimikos includes -#include +#include #include diff --git a/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp b/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp index 21ce3936ca00..87d48f84c218 100644 --- a/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp +++ b/packages/shylu/shylu_dd/frosch/test/SolverFactory/main.cpp @@ -55,29 +55,6 @@ #include "Galeri_XpetraUtils.hpp" #include "Galeri_XpetraMaps.hpp" -// Thyra includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_SHYLU_DDFROSCH_EPETRA -#include -#endif -#include -#include - -// Stratimikos includes -#include - -#include - // Xpetra include #include #include diff --git a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/main.cpp b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/main.cpp index 1811cdd3c9f9..10bd24bfd97f 100644 --- a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/main.cpp +++ b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/main.cpp @@ -74,7 +74,7 @@ #include // Stratimikos includes -#include +#include #include diff --git a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/main.cpp b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/main.cpp index d05ebaf770d2..53f934b98974 100644 --- a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/main.cpp +++ b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/main.cpp @@ -74,7 +74,7 @@ #include // Stratimikos includes -#include +#include #include diff --git a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Stokes_HDF5/main.cpp b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Stokes_HDF5/main.cpp index 48fcee1275e9..ae7a0c7580d7 100644 --- a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Stokes_HDF5/main.cpp +++ b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Stokes_HDF5/main.cpp @@ -80,7 +80,7 @@ // Stratimikos includes //#include -#include +#include #include From 280d5e48f23879a181af2fbdb721f85174044812 Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Mon, 1 Mar 2021 12:13:16 +0100 Subject: [PATCH 08/15] Update parameter lists. --- .../FROSch_CoarseOperator_def.hpp | 10 +- ...reconditioner_IPOUHarmonic_GDSW_Klu_ML.xml | 184 +++++++++--------- ...econditioner_IPOUHarmonic_RGDSW_Klu_ML.xml | 184 +++++++++--------- ...velPreconditioner_IPOUHarmonic_GDSW_ML.xml | 183 ++++++++--------- 4 files changed, 286 insertions(+), 275 deletions(-) diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_def.hpp index 8c0fa48f4d2d..243d8e90b1d9 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_CoarseOperator_def.hpp @@ -831,11 +831,11 @@ namespace FROSch { dofsPerNodeVector[0] = CoarseDofsPerNode_; CoarseDofsMaps[0] = DMapRep; - sublist(this->ParameterList_,"CoarseSolver")->set("Repeated Map Vector",RepMapVector); - sublist(this->ParameterList_,"CoarseSolver")->set("Dofs Maps Vector",CoarseDofsMaps); - sublist(this->ParameterList_,"CoarseSolver")->set("DofOrdering Vector",dofOrderings); - sublist(this->ParameterList_,"CoarseSolver")->set("DofsPerNode Vector",dofsPerNodeVector); - sublist(this->ParameterList_,"CoarseSolver")->set("Nodes Map Vector",NodesMapVector); + sublist(sublist(sublist(this->ParameterList_,"CoarseSolver"),"FROSchPreconditioner"),"TwoLevelPreconditioner")->set("Repeated Map Vector",RepMapVector); + sublist(sublist(sublist(this->ParameterList_,"CoarseSolver"),"FROSchPreconditioner"),"TwoLevelPreconditioner")->set("Dofs Maps Vector",CoarseDofsMaps); + sublist(sublist(sublist(this->ParameterList_,"CoarseSolver"),"FROSchPreconditioner"),"TwoLevelPreconditioner")->set("DofOrdering Vector",dofOrderings); + sublist(sublist(sublist(this->ParameterList_,"CoarseSolver"),"FROSchPreconditioner"),"TwoLevelPreconditioner")->set("DofsPerNode Vector",dofsPerNodeVector); + sublist(sublist(sublist(this->ParameterList_,"CoarseSolver"),"FROSchPreconditioner"),"TwoLevelPreconditioner")->set("Nodes Map Vector",NodesMapVector); } Teuchos::RCP > tmpMap = Xpetra::MapFactory::Build(CoarseMap_->lib(),-1,uniEle,0,this->MpiComm_); diff --git a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/ParameterLists/ParameterList_TwoLevelPreconditioner_IPOUHarmonic_GDSW_Klu_ML.xml b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/ParameterLists/ParameterList_TwoLevelPreconditioner_IPOUHarmonic_GDSW_Klu_ML.xml index e77022f042ff..dd71e408fe3f 100644 --- a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/ParameterLists/ParameterList_TwoLevelPreconditioner_IPOUHarmonic_GDSW_Klu_ML.xml +++ b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/ParameterLists/ParameterList_TwoLevelPreconditioner_IPOUHarmonic_GDSW_Klu_ML.xml @@ -1,136 +1,140 @@ - + - + - - - - - - + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - + - - + + - + - + - + - + - - + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - + + + + - - - + + + + + + + + + + + + + + + + + + - - - - - + + + diff --git a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/ParameterLists/ParameterList_TwoLevelPreconditioner_IPOUHarmonic_RGDSW_Klu_ML.xml b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/ParameterLists/ParameterList_TwoLevelPreconditioner_IPOUHarmonic_RGDSW_Klu_ML.xml index 8bee2e5b3cc6..9faea7ed9047 100644 --- a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/ParameterLists/ParameterList_TwoLevelPreconditioner_IPOUHarmonic_RGDSW_Klu_ML.xml +++ b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Elasticity/ParameterLists/ParameterList_TwoLevelPreconditioner_IPOUHarmonic_RGDSW_Klu_ML.xml @@ -1,136 +1,140 @@ - + - + - - - - - - + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - + - - + + - + - + - + - + - - + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - + + + + - - - + + + + + + + + + + + + + + + + + + - - - - - + + + diff --git a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/ParameterLists/ParameterList_TwoLevelPreconditioner_IPOUHarmonic_GDSW_ML.xml b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/ParameterLists/ParameterList_TwoLevelPreconditioner_IPOUHarmonic_GDSW_ML.xml index 0bd9de13b64d..c99311848c83 100644 --- a/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/ParameterLists/ParameterList_TwoLevelPreconditioner_IPOUHarmonic_GDSW_ML.xml +++ b/packages/shylu/shylu_dd/frosch/test/Thyra_Xpetra_Laplace/ParameterLists/ParameterList_TwoLevelPreconditioner_IPOUHarmonic_GDSW_ML.xml @@ -1,16 +1,16 @@ - + - + - - - - - - + + + + + + @@ -18,119 +18,122 @@ - - - - - - - - - - - + + + + + + + + + + + - + - - + + - - + + - + - + - + - - + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - + + + + - - - + + + + + + + + + + + + + + + + + - - - - - + + + From ec61cfc05046e4eb9716dee5ee8164b5be76f616 Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Tue, 2 Mar 2021 08:16:02 +0100 Subject: [PATCH 09/15] Construct GlobalBasisMatrix_ with row map. --- .../CoarseSpaces/FROSch_CoarseSpace_def.hpp | 52 +++++++++++++------ .../shylu_dd/frosch/src/Tools/FROSch_Output.h | 2 +- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_CoarseSpace_def.hpp b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_CoarseSpace_def.hpp index 2b594688ee1c..eca5bfb35e9e 100644 --- a/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_CoarseSpace_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_CoarseSpace_def.hpp @@ -171,25 +171,45 @@ namespace FROSch { FROSCH_ASSERT(!AssembledBasisMap_.is_null(),"FROSch::CoarseSpace: AssembledBasisMap_.is_null()."); FROSCH_ASSERT(!AssembledBasis_.is_null(),"FROSch::CoarseSpace: AssembledBasis_.is_null()."); - GlobalBasisMatrix_ = MatrixFactory::Build(rowMap,AssembledBasisMap_->getNodeNumElements()); // Nonzeroes abhängig von dim/dofs!!! - - LO iD; - SC valueTmp; - - for (UN i=0; igetLocalLength(); i++) { - GOVec indices; - SCVec values; - for (UN j=0; jgetNumVectors(); j++) { - valueTmp=AssembledBasis_->getData(j)[i]; - if (fabs(valueTmp)>treshold) { - indices.push_back(AssembledBasisMap_->getGlobalElement(j)); - values.push_back(valueTmp); + if (rowMap->lib()==UseEpetra) { + GlobalBasisMatrix_ = MatrixFactory::Build(rowMap,AssembledBasisMap_->getNodeNumElements()); // Nonzeroes abhängig von dim/dofs!!! + LO iD; + SC valueTmp; + for (UN i=0; igetLocalLength(); i++) { + GOVec indices; + SCVec values; + for (UN j=0; jgetNumVectors(); j++) { + valueTmp=AssembledBasis_->getData(j)[i]; + if (fabs(valueTmp)>treshold) { + indices.push_back(AssembledBasisMap_->getGlobalElement(j)); + values.push_back(valueTmp); + } + } + iD = repeatedMap->getGlobalElement(i); + + if (rowMap->getLocalElement(iD)!=-1) { // This should prevent duplicate entries on the interface + GlobalBasisMatrix_->insertGlobalValues(iD,indices(),values()); } } - iD = repeatedMap->getGlobalElement(i); + } else { + GlobalBasisMatrix_ = MatrixFactory::Build(rowMap,AssembledBasisMap_,AssembledBasisMap_->getNodeNumElements()); // Nonzeroes abhängig von dim/dofs!!! + LO iD; + SC valueTmp; + for (UN i=0; igetLocalLength(); i++) { + LOVec indices; + SCVec values; + for (UN j=0; jgetNumVectors(); j++) { + valueTmp=AssembledBasis_->getData(j)[i]; + if (fabs(valueTmp)>treshold) { + indices.push_back(j); + values.push_back(valueTmp); + } + } + iD = rowMap->getLocalElement(repeatedMap->getGlobalElement(i)); - if (rowMap->getLocalElement(iD)!=-1) { // This should prevent duplicate entries on the interface - GlobalBasisMatrix_->insertGlobalValues(iD,indices(),values()); + if (iD!=-1) { // This should prevent duplicate entries on the interface + GlobalBasisMatrix_->insertLocalValues(iD,indices(),values()); + } } } GlobalBasisMatrix_->fillComplete(AssembledBasisMapUnique_,rangeMap); //RCP fancy = fancyOStream(rcpFromRef(cout)); GlobalBasisMatrix_->describe(*fancy,VERB_EXTREME); diff --git a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Output.h b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Output.h index 95364b8a04c2..f5f61805487d 100644 --- a/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Output.h +++ b/packages/shylu/shylu_dd/frosch/src/Tools/FROSch_Output.h @@ -76,7 +76,7 @@ #endif #ifndef FROSCH_NOTIFICATION - #define FROSCH_NOTIFICATION(CLASS,VERBOSE,OUTPUT) if (VERBOSE) std::cout << std::setw(FROSCH_OUTPUT_INDENT) << " " << CLASS << " : NOTIFICATION: " << OUTPUT << std::endl; + #define FROSCH_NOTIFICATION(CLASS,VERBOSE,OUTPUT) if (VERBOSE) std::cout << std::setw(FROSCH_OUTPUT_INDENT) << " " << "[NOTIFICATION] " << CLASS << ": " << OUTPUT << std::endl; #endif #ifndef FROSCH_TEST_OUTPUT From 8861a048039cb78dfcb75f2178d930de77a15121 Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Sun, 7 Mar 2021 14:18:31 +0100 Subject: [PATCH 10/15] Update packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp Co-authored-by: Matthias Mayr --- .../src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp index 8ee2a7a423c6..f788299d7ecd 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp @@ -98,7 +98,7 @@ namespace FROSch { Amesos2Solver_->setB(epetraMultiVectorX); FROSCH_ASSERT(mode==NO_TRANS,"FROSch::Amesos2SolverEpetra: mode!=NO_TRANS"); - Amesos2Solver_->solve(); // Was ist, wenn man mit der transponierten Matrix lösen will + Amesos2Solver_->solve(); // What about solving with transposed matrices? y.update(alpha,*Y_,beta); } From 8aa69a09c99aff03baf721559865be0c2de9d4bb Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Sun, 7 Mar 2021 14:20:15 +0100 Subject: [PATCH 11/15] Update packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp Co-authored-by: Matthias Mayr --- .../src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp index 47fc302b692d..badfbe4683e3 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp @@ -98,7 +98,7 @@ namespace FROSch { Amesos2Solver_->setB(tpetraMultiVectorX); FROSCH_ASSERT(mode==NO_TRANS,"FROSch::Amesos2SolverTpetra: mode!=NO_TRANS"); - Amesos2Solver_->solve(); // Was ist, wenn man mit der transponierten Matrix lösen will + Amesos2Solver_->solve(); // What about solving with transposed matrices? y.update(alpha,*Y_,beta); } From 19b52ef044f453915970278b03a6b584abef6d66 Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Sun, 7 Mar 2021 14:32:58 +0100 Subject: [PATCH 12/15] Update packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp Co-authored-by: Matthias Mayr --- .../src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp index 4485750b495e..0db97a93f1d5 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp @@ -79,7 +79,7 @@ namespace FROSch { FROSCH_TIMER_START_SOLVER(applyTime,"BelosSolverTpetra::apply"); FROSCH_ASSERT(this->IsComputed_,"FROSch::BelosSolverTpetra: !this->IsComputed_."); - const TpetraMultiVector * xTpetraMultiVectorX = dynamic_cast *>(&x); + const TpetraMultiVector * xTpetraMultiVectorX = dynamic_cast *>(&x, true); TMultiVectorPtr tpetraMultiVectorX = xTpetraMultiVectorX->getTpetra_MultiVector(); if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),y.getNumVectors()); From 989715d4b30dc2aa4de1f05cd2789d4cabde317f Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Sun, 7 Mar 2021 14:59:18 +0100 Subject: [PATCH 13/15] Update packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp Co-authored-by: Matthias Mayr --- .../frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp index 0de39139dc0b..5c30885d91b0 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp @@ -109,7 +109,7 @@ namespace FROSch { #ifdef HAVE_SHYLU_DDFROSCH_MUELU return MueLuPreconditionerPtr(new MueLuPreconditioner(k,parameterList,description)); #else - ThrowErrorMissingPackage("FROSch::SolverFactory","Ifpack2"); + ThrowErrorMissingPackage("FROSch::SolverFactory","MueLu"); #endif } else if (!parameterList->get("SolverType","Amesos2").compare("ThyraPreconditioner")) { #ifdef HAVE_SHYLU_DDFROSCH_THYRA From 0cca976c60821323530647e506a8191a9ae6f621 Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Sun, 7 Mar 2021 16:05:16 +0100 Subject: [PATCH 14/15] Further corrections --- .../FROSch_Amesos2SolverEpetra_def.hpp | 6 ++++++ .../FROSch_Amesos2SolverTpetra_def.hpp | 2 ++ .../FROSch_AmesosSolverEpetra_def.hpp | 2 ++ .../FROSch_BelosSolverEpetra_def.hpp | 2 ++ .../FROSch_BelosSolverTpetra_def.hpp | 4 +++- .../FROSch_Ifpack2PreconditionerTpetra_def.hpp | 2 ++ .../FROSch_SolverFactory_def.hpp | 18 ++++++++++-------- .../src/SolverInterfaces/FROSch_Solver_def.hpp | 4 ++-- 8 files changed, 29 insertions(+), 11 deletions(-) diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp index f788299d7ecd..023357b5e9a7 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp @@ -88,10 +88,12 @@ namespace FROSch { FROSCH_ASSERT(this->IsComputed_,"FROSch::Amesos2SolverEpetra: !this->IsComputed_."); const EpetraMultiVectorT * xEpetraMultiVectorX = dynamic_cast *>(&x); + FROSCH_ASSERT(xEpetraMultiVectorX,"FROSch::Amesos2SolverEpetra: dynamic_cast failed."); RCP epetraMultiVectorX = xEpetraMultiVectorX->getEpetra_MultiVector(); if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),x.getNumVectors()); EpetraMultiVectorT * xEpetraMultiVectorY = dynamic_cast *>(Y_.get()); + FROSCH_ASSERT(xEpetraMultiVectorY,"FROSch::Amesos2SolverEpetra: dynamic_cast failed."); RCP epetraMultiVectorY = xEpetraMultiVectorY->getEpetra_MultiVector(); Amesos2Solver_->setX(epetraMultiVectorY); @@ -112,7 +114,9 @@ namespace FROSch { FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverEpetra: K_ is null."); const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); + FROSCH_ASSERT(crsOp,"FROSch::Amesos2SolverEpetra: dynamic_cast failed."); const EpetraCrsMatrixT& xEpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); + FROSCH_ASSERT(xEpetraMat,"FROSch::Amesos2SolverEpetra: dynamic_cast failed."); ECrsMatrixPtr epetraMat = xEpetraMat.getEpetra_CrsMatrixNonConst(); TEUCHOS_TEST_FOR_EXCEPT(epetraMat.is_null()); @@ -135,7 +139,9 @@ namespace FROSch { FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseEpetra,"FROSch::Amesos2SolverEpetra: Not compatible with Tpetra.") const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); + FROSCH_ASSERT(crsOp,"FROSch::Amesos2SolverEpetra: dynamic_cast failed."); const EpetraCrsMatrixT& xEpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); + FROSCH_ASSERT(xEpetraMat,"FROSch::Amesos2SolverEpetra: dynamic_cast failed."); ECrsMatrixPtr epetraMat = xEpetraMat.getEpetra_CrsMatrixNonConst(); TEUCHOS_TEST_FOR_EXCEPT(epetraMat.is_null()); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp index badfbe4683e3..925865f8d8c2 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverTpetra_def.hpp @@ -88,10 +88,12 @@ namespace FROSch { FROSCH_ASSERT(this->IsComputed_,"FROSch::Amesos2SolverTpetra: !this->IsComputed_."); const TpetraMultiVector * xTpetraMultiVectorX = dynamic_cast *>(&x); + FROSCH_ASSERT(xTpetraMultiVectorX,"FROSch::Amesos2SolverTpetra: dynamic_cast failed."); TMultiVectorPtr tpetraMultiVectorX = xTpetraMultiVectorX->getTpetra_MultiVector(); if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),x.getNumVectors()); const TpetraMultiVector * xTpetraMultiVectorY = dynamic_cast *>(Y_.get()); + FROSCH_ASSERT(xTpetraMultiVectorY,"FROSch::Amesos2SolverTpetra: dynamic_cast failed."); TMultiVectorPtr tpetraMultiVectorY = xTpetraMultiVectorY->getTpetra_MultiVector(); Amesos2Solver_->setX(tpetraMultiVectorY); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp index 30624a03d861..cb69181becf9 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_AmesosSolverEpetra_def.hpp @@ -89,10 +89,12 @@ namespace FROSch { FROSCH_ASSERT(this->IsComputed_,"FROSch::AmesosSolverEpetra: !this->IsComputed_."); const EpetraMultiVectorT * xEpetraMultiVectorX = dynamic_cast *>(&x); + FROSCH_ASSERT(xEpetraMultiVectorX,"FROSch::AmesosSolverEpetra: dynamic_cast failed."); RCP epetraMultiVectorX = xEpetraMultiVectorX->getEpetra_MultiVector(); if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),x.getNumVectors()); EpetraMultiVectorT * xEpetraMultiVectorY = dynamic_cast *>(Y_.get()); + FROSCH_ASSERT(xEpetraMultiVectorY,"FROSch::AmesosSolverEpetra: dynamic_cast failed."); RCP epetraMultiVectorY = xEpetraMultiVectorY->getEpetra_MultiVector(); EpetraLinearProblem_->SetLHS(epetraMultiVectorY.get()); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp index b4914489871c..828f43a2c31f 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverEpetra_def.hpp @@ -80,10 +80,12 @@ namespace FROSch { FROSCH_ASSERT(this->IsComputed_,"FROSch::BelosSolverEpetra: !this->IsComputed_."); const EpetraMultiVectorT * xEpetraMultiVectorX = dynamic_cast *>(&x); + FROSCH_ASSERT(xEpetraMultiVectorX,"FROSch::BelosSolverEpetra: dynamic_cast failed."); RCP epetraMultiVectorX = xEpetraMultiVectorX->getEpetra_MultiVector(); if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),y.getNumVectors()); EpetraMultiVectorT * xEpetraMultiVectorY = dynamic_cast *>(Y_.get()); + FROSCH_ASSERT(xEpetraMultiVectorY,"FROSch::BelosSolverEpetra: dynamic_cast failed."); RCP epetraMultiVectorY = xEpetraMultiVectorY->getEpetra_MultiVector(); BelosLinearProblem_->setProblem(epetraMultiVectorY,epetraMultiVectorX); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp index 0db97a93f1d5..8a952c20f18e 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_BelosSolverTpetra_def.hpp @@ -79,11 +79,13 @@ namespace FROSch { FROSCH_TIMER_START_SOLVER(applyTime,"BelosSolverTpetra::apply"); FROSCH_ASSERT(this->IsComputed_,"FROSch::BelosSolverTpetra: !this->IsComputed_."); - const TpetraMultiVector * xTpetraMultiVectorX = dynamic_cast *>(&x, true); + const TpetraMultiVector * xTpetraMultiVectorX = dynamic_cast *>(&x); + FROSCH_ASSERT(xTpetraMultiVectorX,"FROSch::BelosSolverTpetra: dynamic_cast failed."); TMultiVectorPtr tpetraMultiVectorX = xTpetraMultiVectorX->getTpetra_MultiVector(); if (Y_.is_null()) Y_ = XMultiVectorFactory::Build(y.getMap(),y.getNumVectors()); const TpetraMultiVector * xTpetraMultiVectorY = dynamic_cast *>(Y_.get()); + FROSCH_ASSERT(xTpetraMultiVectorY,"FROSch::BelosSolverTpetra: dynamic_cast failed."); TMultiVectorPtr tpetraMultiVectorY = xTpetraMultiVectorY->getTpetra_MultiVector(); BelosLinearProblem_->setProblem(tpetraMultiVectorY,tpetraMultiVectorX); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp index 5d8cc2cbf4df..302f35309d64 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Ifpack2PreconditionerTpetra_def.hpp @@ -82,9 +82,11 @@ namespace FROSch { FROSCH_ASSERT(this->IsComputed_,"FROSch::Ifpack2PreconditionerTpetra: !this->IsComputed_."); const TpetraMultiVector * xTpetraMultiVectorX = dynamic_cast *>(&x); + FROSCH_ASSERT(xTpetraMultiVectorX,"FROSch::Ifpack2PreconditionerTpetra: dynamic_cast failed."); TMultiVectorPtr tpetraMultiVectorX = xTpetraMultiVectorX->getTpetra_MultiVector(); const TpetraMultiVector * xTpetraMultiVectorY = dynamic_cast *>(&y); + FROSCH_ASSERT(xTpetraMultiVectorY,"FROSch::Ifpack2PreconditionerTpetra: dynamic_cast failed."); TMultiVectorPtr tpetraMultiVectorY = xTpetraMultiVectorY->getTpetra_MultiVector(); Ifpack2Preconditioner_->apply(*tpetraMultiVectorX,*tpetraMultiVectorY,mode,alpha,beta); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp index 0de39139dc0b..a4413f3b93ca 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_SolverFactory_def.hpp @@ -49,6 +49,7 @@ namespace FROSch { + using namespace std; using namespace Teuchos; using namespace Xpetra; @@ -57,7 +58,8 @@ namespace FROSch { ParameterListPtr parameterList, string description) { - if (!parameterList->get("SolverType","Amesos2").compare("Amesos")) { + const string solverType = parameterList->get("SolverType","Amesos2"); + if (!solverType.compare("Amesos")) { #ifdef HAVE_SHYLU_DDFROSCH_AMESOS FROSCH_ASSERT(k->getRowMap()->lib()==UseEpetra,"FROSch::SolverFactory: Amesos is not compatible with Tpetra."); #ifdef HAVE_SHYLU_DDFROSCH_EPETRA @@ -68,7 +70,7 @@ namespace FROSch { #else ThrowErrorMissingPackage("FROSch::SolverFactory","Amesos"); #endif - } else if (!parameterList->get("SolverType","Amesos2").compare("Amesos2")) { + } else if (!solverType.compare("Amesos2")) { if (k->getRowMap()->lib()==UseEpetra) { #ifdef HAVE_SHYLU_DDFROSCH_EPETRA return Amesos2SolverEpetraPtr(new Amesos2SolverEpetra(k,parameterList,description)); @@ -80,7 +82,7 @@ namespace FROSch { } else { FROSCH_ASSERT(false, "FROSch::SolverFactory: This can't happen. Either use Epetra or Tetra linear algebra stack."); } - } else if (!parameterList->get("SolverType","Amesos2").compare("Belos")) { + } else if (!solverType.compare("Belos")) { #ifdef HAVE_SHYLU_DDFROSCH_BELOS if (k->getRowMap()->lib()==UseEpetra) { #ifdef HAVE_SHYLU_DDFROSCH_EPETRA @@ -96,22 +98,22 @@ namespace FROSch { #else ThrowErrorMissingPackage("FROSch::SolverFactory","Belos"); #endif - } else if (!parameterList->get("SolverType","Amesos2").compare("FROSchPreconditioner")) { + } else if (!solverType.compare("FROSchPreconditioner")) { return FROSchPreconditionerPtr(new FROSchPreconditioner(k,parameterList,description)); - } else if (!parameterList->get("SolverType","Amesos2").compare("Ifpack2")) { + } else if (!solverType.compare("Ifpack2")) { #ifdef HAVE_SHYLU_DDFROSCH_IFPACK2 FROSCH_ASSERT(k->getRowMap()->lib()==UseTpetra,"FROSch::SolverFactory: Ifpack2 is not compatible with Epetra."); return Ifpack2PreconditionerTpetraPtr(new Ifpack2PreconditionerTpetra(k,parameterList,description)); #else ThrowErrorMissingPackage("FROSch::SolverFactory","Ifpack2"); #endif - } else if (!parameterList->get("SolverType","Amesos2").compare("MueLu")) { + } else if (!solverType.compare("MueLu")) { #ifdef HAVE_SHYLU_DDFROSCH_MUELU return MueLuPreconditionerPtr(new MueLuPreconditioner(k,parameterList,description)); #else ThrowErrorMissingPackage("FROSch::SolverFactory","Ifpack2"); #endif - } else if (!parameterList->get("SolverType","Amesos2").compare("ThyraPreconditioner")) { + } else if (!solverType.compare("ThyraPreconditioner")) { #ifdef HAVE_SHYLU_DDFROSCH_THYRA #ifdef HAVE_SHYLU_DDFROSCH_STRATIMIKOS return ThyraPreconditionerPtr(new ThyraPreconditioner(k,parameterList,description)); @@ -121,7 +123,7 @@ namespace FROSch { #else ThrowErrorMissingPackage("FROSch::SolverFactory","Thyra"); #endif - } else if (!parameterList->get("SolverType","Amesos2").compare("ThyraSolver")) { + } else if (!solverType.compare("ThyraSolver")) { #ifdef HAVE_SHYLU_DDFROSCH_THYRA #ifdef HAVE_SHYLU_DDFROSCH_STRATIMIKOS return ThyraSolverPtr(new ThyraSolver(k,parameterList,description)); diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_def.hpp index 88268a2b4589..345f07e71053 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Solver_def.hpp @@ -53,13 +53,13 @@ namespace FROSch { template typename Solver::ConstXMapPtr Solver::getDomainMap() const { - return K_->getRangeMap(); + return K_->getDomainMap(); } template typename Solver::ConstXMapPtr Solver::getRangeMap() const { - return K_->getDomainMap(); + return K_->getRangeMap(); } template From 519376d069b0de8c49be93c09f4dea1ac2be0536 Mon Sep 17 00:00:00 2001 From: Alexander Heinlein Date: Mon, 8 Mar 2021 12:14:02 +0100 Subject: [PATCH 15/15] Update FROSch_Amesos2SolverEpetra_def.hpp --- .../src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp index 023357b5e9a7..84ef9bf0d1f9 100644 --- a/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SolverInterfaces/FROSch_Amesos2SolverEpetra_def.hpp @@ -114,9 +114,7 @@ namespace FROSch { FROSCH_ASSERT(!this->K_.is_null(),"FROSch::Amesos2SolverEpetra: K_ is null."); const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); - FROSCH_ASSERT(crsOp,"FROSch::Amesos2SolverEpetra: dynamic_cast failed."); const EpetraCrsMatrixT& xEpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); - FROSCH_ASSERT(xEpetraMat,"FROSch::Amesos2SolverEpetra: dynamic_cast failed."); ECrsMatrixPtr epetraMat = xEpetraMat.getEpetra_CrsMatrixNonConst(); TEUCHOS_TEST_FOR_EXCEPT(epetraMat.is_null()); @@ -139,9 +137,7 @@ namespace FROSch { FROSCH_ASSERT(this->K_->getRowMap()->lib()==UseEpetra,"FROSch::Amesos2SolverEpetra: Not compatible with Tpetra.") const CrsMatrixWrap& crsOp = dynamic_cast&>(*this->K_); - FROSCH_ASSERT(crsOp,"FROSch::Amesos2SolverEpetra: dynamic_cast failed."); const EpetraCrsMatrixT& xEpetraMat = dynamic_cast&>(*crsOp.getCrsMatrix()); - FROSCH_ASSERT(xEpetraMat,"FROSch::Amesos2SolverEpetra: dynamic_cast failed."); ECrsMatrixPtr epetraMat = xEpetraMat.getEpetra_CrsMatrixNonConst(); TEUCHOS_TEST_FOR_EXCEPT(epetraMat.is_null());