flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
spectrum_generator_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
27Spectrum_generator_problems::Spectrum_generator_problems(const std::vector<Problems>& problems_)
28 : problems(problems_)
29{
30}
31
33 : problems(std::move(problems_))
34{
35}
36
37Spectrum_generator_problems::Spectrum_generator_problems(const std::vector<BVP_solver_problems>& solver_problems_)
38 : solver_problems(solver_problems_)
39{
40}
41
42Spectrum_generator_problems::Spectrum_generator_problems(std::vector<BVP_solver_problems>&& solver_problems_)
43 : solver_problems(std::move(solver_problems_))
44{
45}
46
47void Spectrum_generator_problems::set_model_problems(const std::vector<Problems>& p)
48{
49 problems = p;
50}
51
53{
54 problems = std::move(p);
55}
56
57void Spectrum_generator_problems::set_bvp_solver_problems(const std::vector<BVP_solver_problems>& p)
58{
60}
61
62void Spectrum_generator_problems::set_bvp_solver_problems(std::vector<BVP_solver_problems>&& p)
63{
64 solver_problems = std::move(p);
65}
66
68{
69 for (auto& p: problems)
70 p.clear();
71 for (auto& p: solver_problems)
72 p.clear();
73}
74
76{
77 return
78 std::any_of(problems.cbegin(), problems.cend(),
79 [] (const Problems& p) { return p.have_problem(); }) ||
80 std::any_of(solver_problems.cbegin(), solver_problems.cend(),
81 [] (const BVP_solver_problems& p) { return p.have_problem(); });
82}
83
85{
86 return
87 std::any_of(problems.cbegin(), problems.cend(),
88 [] (const Problems& p) { return p.have_warning(); }) ||
89 std::any_of(solver_problems.cbegin(), solver_problems.cend(),
90 [] (const BVP_solver_problems& p) { return p.have_warning(); });
91}
92
94{
95 std::vector<std::string> result;
96
97 for (const auto& p: problems) {
98 const auto strings = p.get_problem_strings();
99 result.insert(result.end(), strings.cbegin(), strings.cend());
100 }
101
102 for (const auto& p: solver_problems) {
103 const auto strings = p.get_problem_strings();
104 result.insert(result.end(), strings.cbegin(), strings.cend());
105 }
106
107 return result;
108}
109
111{
112 std::vector<std::string> result;
113
114 for (const auto& p: problems) {
115 const auto strings = p.get_warning_strings();
116 result.insert(result.end(), strings.cbegin(), strings.cend());
117 }
118
119 for (const auto& p: solver_problems) {
120 const auto strings = p.get_warning_strings();
121 result.insert(result.end(), strings.cbegin(), strings.cend());
122 }
123
124 return result;
125}
126
127std::string Spectrum_generator_problems::get_problem_string(const std::string& sep) const
128{
129 return concat(get_problem_strings(), sep);
130}
131
132std::string Spectrum_generator_problems::get_warning_string(const std::string& sep) const
133{
134 return concat(get_warning_strings(), sep);
135}
136
138{
139 print_problems(std::cerr);
140}
141
143{
144 if (!have_problem())
145 return;
146
147 ostr << get_problem_string();
148}
149
151{
152 print_warnings(std::cerr);
153}
154
156{
157 if (!have_warning())
158 return;
159
160 ostr << get_warning_string();
161}
162
163const std::vector<Problems>& Spectrum_generator_problems::get_model_problems() const
164{
165 return problems;
166}
167
169{
170 return problems;
171}
172
173const std::vector<BVP_solver_problems>& Spectrum_generator_problems::get_bvp_solver_problems() const
174{
175 return solver_problems;
176}
177
179{
180 return solver_problems;
181}
182
184{
185 for (auto& p: solver_problems)
186 p.flag_no_convergence();
187}
188
190{
191 for (auto& p: solver_problems)
192 p.unflag_no_convergence();
193}
194
196{
197 return std::any_of(solver_problems.cbegin(), solver_problems.cend(),
198 [] (const BVP_solver_problems& p) { return p.no_convergence(); });
199}
200
201std::ostream& operator<<(std::ostream& ostr, const Spectrum_generator_problems& problems)
202{
203 problems.print_problems(ostr);
204 problems.print_warnings(ostr);
205 return ostr;
206}
207
208} // namespace flexiblesusy
stores problem flags for the spectrum generator
Definition: problems.hpp:35
std::vector< std::string > get_problem_strings() const
bool have_problem() const
problems which yield invalid spectrum
void set_model_problems(const std::vector< Problems > &)
(re)set all model problems
const std::vector< BVP_solver_problems > & get_bvp_solver_problems() const
std::vector< BVP_solver_problems > solver_problems
BVP solver problems.
const std::vector< Problems > & get_model_problems() const
std::string get_warning_string(const std::string &sep="\n") const
void set_bvp_solver_problems(const std::vector< BVP_solver_problems > &)
(re)set all BVP solver problems
std::string get_problem_string(const std::string &sep="\n") const
std::vector< Problems > problems
model problems
std::vector< std::string > get_warning_strings() const
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