BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
solution_base.hpp
1 // Copyright (C) 2011-2012 by the BEM++ Authors
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef bempp_solution_base_hpp
22 #define bempp_solution_base_hpp
23 
24 #include "bempp/common/config_trilinos.hpp"
25 #include "../common/common.hpp"
26 
27 #include "../common/scalar_traits.hpp"
28 
29 // TODO: support lack of trilinos
30 #ifdef WITH_TRILINOS
31 #include <Thyra_SolveSupportTypes.hpp>
32 #endif // WITH_TRILINOS
33 
34 #include <string>
35 
36 namespace Bempp
37 {
38 
40  enum Status {
41  CONVERGED,
42  UNCONVERGED,
43  UNKNOWN};
44 };
45 
58 template <typename BasisFunctionType, typename ResultType>
60 {
61 public:
62  typedef typename ScalarTraits<ResultType>::RealType MagnitudeType;
63 
64 #ifdef WITH_TRILINOS
65 
66  explicit SolutionBase(const Thyra::SolveStatus<MagnitudeType> status);
67 #endif // WITH_TRILINOS
68 
69  explicit SolutionBase(SolutionStatus::Status status,
70  MagnitudeType achievedTolerance = unknownTolerance(),
71  std::string message = "");
72 
73  static MagnitudeType unknownTolerance() { return MagnitudeType(-1.); }
74 
76  SolutionStatus::Status status() const;
77 
83  MagnitudeType achievedTolerance() const;
84 
88  int iterationCount() const;
89 
91  std::string solverMessage() const;
92 
93 #ifdef WITH_TRILINOS
94 
97  Teuchos::RCP<Teuchos::ParameterList> extraParameters() const;
98 #endif // WITH_TRILINOS
99 
100 private:
101  SolutionStatus::Status m_status;
102  MagnitudeType m_achievedTolerance;
103  std::string m_message;
104  int m_iterationCount;
105 #ifdef WITH_TRILINOS
106  Teuchos::RCP<Teuchos::ParameterList> m_extraParameters;
107 #endif // WITH_TRILINOS
108 };
109 
110 } // namespace Bempp
111 
112 #endif
Traits of scalar types.
Definition: scalar_traits.hpp:40
MagnitudeType achievedTolerance() const
Maximum final tolerance achieved by the linear solve.
Definition: solution_base.cpp:78
The base class for the Solution and BlockedSolution container classes.
Definition: solution_base.hpp:59
SolutionStatus::Status status() const
Return status of the linear solve.
Definition: solution_base.cpp:65
std::string solverMessage() const
Message returned by the solver.
Definition: solution_base.cpp:85
Teuchos::RCP< Teuchos::ParameterList > extraParameters() const
Extra status parameter returned by the solver.
Definition: solution_base.cpp:93
SolutionBase(const Thyra::SolveStatus< MagnitudeType > status)
Constructor.
Definition: solution_base.cpp:31
int iterationCount() const
Iteration count if iterative solver is used. If a direct solver is used, this defaults to -1...
Definition: solution_base.cpp:71
Definition: solution_base.hpp:39