@@ -47,9 +47,14 @@ namespace partdiff {
4747 return static_cast <U>(v);
4848 }
4949
50- static constexpr bounds<uint64_t > interlines_bounds{0 , 10240 };
50+ static constexpr bounds<uint64_t > num_bounds{1 , 1024 };
51+ static constexpr bounds<calculation_method> method_bounds{calculation_method::gauss_seidel,
52+ calculation_method::jacobi};
53+ static constexpr bounds<uint64_t > lines_bounds{0 , 10240 };
54+ static constexpr bounds<perturbation_function> func_bounds{perturbation_function::f0, perturbation_function::fpisin};
55+ static constexpr bounds<termination_condition> term_bounds{termination_condition::accuracy,
56+ termination_condition::iterations};
5157 static constexpr bounds<uint64_t > iteration_bounds{1 , 200000 };
52- static constexpr bounds<uint64_t > thread_bounds{1 , 1024 };
5358 static constexpr bounds<double > accuracy_bounds{1e-20 , 1e-4 };
5459
5560 argument_parser::argument_parser (const int argc, char const *argv[])
@@ -120,47 +125,44 @@ namespace partdiff {
120125 constexpr int indent_width = 17 ;
121126 const std::string indent = std::format (" {:{}s}" , " " , indent_width);
122127
128+ auto display_enum = [indent]<typename T>(bounds<T> enum_bounds) -> std::string {
129+ std::string result = " " ;
130+ auto lower = to_underlying (enum_bounds.lower );
131+ auto upper = to_underlying (enum_bounds.upper );
132+ for (auto i = lower; i <= upper; i++) {
133+ if (i != lower) {
134+ result += " \n " ;
135+ }
136+ result += std::format (" {0}{1:d}: {1:s}" , indent, T (i));
137+ }
138+ return result;
139+ };
140+
123141 auto number = &(this ->options .number );
124- this ->add_argument_description (" num" , number, std::format (" number of threads ({:d})" , thread_bounds ),
125- [number] { return (thread_bounds .contains (*number) ); });
142+ this ->add_argument_description (" num" , number, std::format (" number of threads ({:d})" , num_bounds ),
143+ [number] { return num_bounds .contains (*number); });
126144
127145 auto method = &(this ->options .method );
128146 this ->add_argument_description (
129- " method" , method,
130- std::format (" calculation method (1 .. 2)\n "
131- " {0}{1:d}: {1:s}\n "
132- " {0}{2:d}: {2:s}" ,
133- indent, calculation_method::gauss_seidel, calculation_method::jacobi),
134- [method] { return (*method == calculation_method::gauss_seidel || *method == calculation_method::jacobi); });
147+ " method" , method, std::format (" calculation method ({:d})\n {}" , method_bounds, display_enum (method_bounds)),
148+ [method] { return method_bounds.contains (*method); });
135149
136150 auto interlines = &(this ->options .interlines );
137151 this ->add_argument_description (" lines" , interlines,
138152 std::format (" number of interlines ({1:d})\n "
139153 " {0}matrixsize = (interlines * 8) + 9" ,
140- indent, interlines_bounds ),
141- [interlines] { return (interlines_bounds .contains (*interlines) ); });
154+ indent, lines_bounds ),
155+ [interlines] { return lines_bounds .contains (*interlines); });
142156
143157 auto pert_func = &(this ->options .pert_func );
144- this ->add_argument_description (" func" , pert_func,
145- std::format (" perturbation function (1 .. 2)\n "
146- " {0}{1:d}: {1:s}\n "
147- " {0}{2:d}: {2:s}" ,
148- indent, perturbation_function::f0, perturbation_function::fpisin),
149- [pert_func] {
150- return (*pert_func == perturbation_function::f0 ||
151- *pert_func == perturbation_function::fpisin);
152- });
158+ this ->add_argument_description (
159+ " func" , pert_func, std::format (" perturbation function ({:d})\n {}" , func_bounds, display_enum (func_bounds)),
160+ [pert_func] { return func_bounds.contains (*pert_func); });
153161
154162 auto termination = &(this ->options .termination );
155163 this ->add_argument_description (
156- " term" , termination,
157- std::format (" termination condition ( 1.. 2)\n "
158- " {0}{1:d}: {1:s}\n "
159- " {0}{2:d}: {2:s}" ,
160- indent, termination_condition::accuracy, termination_condition::iterations),
161- [termination] {
162- return (*termination == termination_condition::accuracy || *termination == termination_condition::iterations);
163- });
164+ " term" , termination, std::format (" termination condition ({:d})\n {}" , term_bounds, display_enum (term_bounds)),
165+ [termination] { return term_bounds.contains (*termination); });
164166
165167 this ->add_argument_description (" acc/iter" , std::format (" depending on term:\n "
166168 " {0}accuracy: {1:.0e}\n "
@@ -169,11 +171,11 @@ namespace partdiff {
169171
170172 auto term_accuracy = &(this ->options .term_accuracy );
171173 this ->add_argument_description (" acc" , term_accuracy, std::nullopt ,
172- [term_accuracy] { return ( accuracy_bounds.contains (*term_accuracy) ); });
174+ [term_accuracy] { return accuracy_bounds.contains (*term_accuracy); });
173175
174176 auto term_iteration = &(this ->options .term_iteration );
175177 this ->add_argument_description (" iter" , term_iteration, std::nullopt ,
176- [term_iteration] { return ( iteration_bounds.contains (*term_iteration) ); });
178+ [term_iteration] { return iteration_bounds.contains (*term_iteration); });
177179 }
178180
179181 void argument_parser::add_argument_description (std::string name, std::optional<std::string> description_for_usage) {
0 commit comments