flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
bvp_solver_problems.cpp
Go to the documentation of this file.
1// ====================================================================
2// This file is part of FlexibleSUSY.
3//
4// FlexibleSUSY is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published
6// by the Free Software Foundation, either version 3 of the License,
7// or (at your option) any later version.
8//
9// FlexibleSUSY is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with FlexibleSUSY. If not, see
16// <http://www.gnu.org/licenses/>.
17// ====================================================================
18
20#include "string_utils.hpp"
21
22#include <algorithm>
23#include <iostream>
24
25namespace flexiblesusy {
26
28 : name(name_)
29{
30}
31
33{
34 failed_convergence = false;
35}
36
38{
39 return no_convergence();
40}
41
43{
44 return number_of_warnings() > 0;
45}
46
48{
49 unsigned count = 0;
50 if (no_convergence()) count++;
51 return count;
52}
53
55{
56 return 0; // no warnings yet
57}
58
59std::vector<std::string> BVP_solver_problems::get_problem_strings() const
60{
61 std::vector<std::string> result;
62
63 if (no_convergence())
64 result.emplace_back(name + " no convergence");
65
66 result.shrink_to_fit();
67
68 return result;
69}
70
71std::vector<std::string> BVP_solver_problems::get_warning_strings() const
72{
73 return {};
74}
75
77{
78 return concat(get_problem_strings(), '\n');
79}
80
82{
83 return concat(get_warning_strings(), '\n');
84}
85
87{
88 print_problems(std::cerr);
89}
90
91void BVP_solver_problems::print_problems(std::ostream& ostr) const
92{
93 if (!have_problem())
94 return;
95
96 ostr << get_problem_string();
97}
98
100{
101 print_warnings(std::cerr);
102}
103
104void BVP_solver_problems::print_warnings(std::ostream& ostr) const
105{
106 if (!have_warning())
107 return;
108
109 ostr << get_warning_string();
110}
111
112const std::string& BVP_solver_problems::get_solver_name() const
113{
114 return name;
115}
116
118{
119 failed_convergence = true;
120}
121
123{
124 failed_convergence = false;
125}
126
128{
129 return failed_convergence;
130}
131
132std::ostream& operator<<(std::ostream& ostr, const BVP_solver_problems& problems)
133{
134 problems.print_problems(ostr);
135 problems.print_warnings(ostr);
136 return ostr;
137}
138
139} // namespace flexiblesusy
std::vector< std::string > get_warning_strings() const
std::vector< std::string > get_problem_strings() const
bool have_problem() const
problems which yield invalid spectrum
std::string name
BVP solver name.
unsigned number_of_warnings() const
returns number of warnings
const std::string & get_solver_name() const
unsigned number_of_problems() const
returns number of problems
std::ostream & operator<<(std::ostream &ostr, const Dynamic_array_view< ElementType > &av)
Definition: array_view.hpp:143
std::string concat(const std::vector< std::string > &strings)
concatenate strings