From d0c0a5ea2dab044cca823fca4e21e588803af40d Mon Sep 17 00:00:00 2001 From: Elias Pipping <elias.pipping@fu-berlin.de> Date: Wed, 6 Jul 2016 11:05:35 +0200 Subject: [PATCH] Move implementation to library --- dune/solvers/CMakeLists.txt | 1 + dune/solvers/iterationsteps/blockgssteps.cc | 41 +++++++++++++++++++++ dune/solvers/iterationsteps/blockgssteps.hh | 33 +---------------- 3 files changed, 44 insertions(+), 31 deletions(-) create mode 100644 dune/solvers/iterationsteps/blockgssteps.cc diff --git a/dune/solvers/CMakeLists.txt b/dune/solvers/CMakeLists.txt index ce9d0fe3..f79381dc 100644 --- a/dune/solvers/CMakeLists.txt +++ b/dune/solvers/CMakeLists.txt @@ -1,4 +1,5 @@ dune_add_library("dunesolvers" + iterationsteps/blockgssteps.cc solvers/criterion.cc) dune_register_package_flags(LIBRARIES dunesolvers) diff --git a/dune/solvers/iterationsteps/blockgssteps.cc b/dune/solvers/iterationsteps/blockgssteps.cc new file mode 100644 index 00000000..9a201584 --- /dev/null +++ b/dune/solvers/iterationsteps/blockgssteps.cc @@ -0,0 +1,41 @@ +#include <algorithm> + +#include "blockgssteps.hh" + +namespace Dune { +namespace Solvers { + namespace BlockGS { + std::istream& operator>>(std::istream& lhs, Direction& t) { + std::string s; + lhs >> s; + std::transform(s.begin(), s.end(), s.begin(), ::tolower); + + if (s == "forward") + t = Direction::FORWARD; + else if (s == "backward") + t = Direction::BACKWARD; + else if (s == "symmetric") + t = Direction::SYMMETRIC; + else + lhs.setstate(std::ios_base::failbit); + return lhs; + } + + std::istream& operator>>(std::istream& lhs, BlockGSType& t) { + std::string s; + lhs >> s; + std::transform(s.begin(), s.end(), s.begin(), ::tolower); + + if (s == "direct") + t = BlockGSType::Direct; + else if (s == "ldlt") + t = BlockGSType::LDLt; + else if (s == "cg") + t = BlockGSType::CG; + else + lhs.setstate(std::ios_base::failbit); + return lhs; + } + } +} +} diff --git a/dune/solvers/iterationsteps/blockgssteps.hh b/dune/solvers/iterationsteps/blockgssteps.hh index c5b3b02e..1b335877 100644 --- a/dune/solvers/iterationsteps/blockgssteps.hh +++ b/dune/solvers/iterationsteps/blockgssteps.hh @@ -1,7 +1,6 @@ #ifndef DUNE_SOLVERS_ITERATIONSTEPS_BLOCKGSSTEPS_HH #define DUNE_SOLVERS_ITERATIONSTEPS_BLOCKGSSTEPS_HH -#include <algorithm> #include <functional> #include <dune/common/parametertree.hh> @@ -20,21 +19,7 @@ enum class Direction { FORWARD, BACKWARD, SYMMETRIC }; /** * @brief Provides support to parse the @Direction enum. */ -std::istream& operator>>(std::istream& lhs, Direction& t) { - std::string s; - lhs >> s; - std::transform(s.begin(), s.end(), s.begin(), ::tolower); - - if (s == "forward") - t = Direction::FORWARD; - else if (s == "backward") - t = Direction::BACKWARD; - else if (s == "symmetric") - t = Direction::SYMMETRIC; - else - lhs.setstate(std::ios_base::failbit); - return lhs; -} +std::istream& operator>>(std::istream& lhs, Direction& t); /** * \brief Iterates over all rows i and updates the i-th component by solving @@ -293,21 +278,7 @@ enum class BlockGSType { Direct, LDLt, CG }; /** * @brief Provides support to parse the @BlockGSType enum. */ -std::istream& operator>>(std::istream& lhs, BlockGSType& t) { - std::string s; - lhs >> s; - std::transform(s.begin(), s.end(), s.begin(), ::tolower); - - if (s == "direct") - t = BlockGSType::Direct; - else if (s == "ldlt") - t = BlockGSType::LDLt; - else if (s == "cg") - t = BlockGSType::CG; - else - lhs.setstate(std::ios_base::failbit); - return lhs; -} +std::istream& operator>>(std::istream& lhs, BlockGSType& t); /** * @brief The BlockGSStepFactory struct allows to conveniently construct various -- GitLab