From 5babb4fcb7adaeeacf258811a97a35ff3c54f43c Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Fri, 12 Apr 2019 15:19:23 -0600 Subject: [PATCH] change parse_parameter logic --- examples/step-63/step-63.cc | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/examples/step-63/step-63.cc b/examples/step-63/step-63.cc index c23896f4f5..6bc23c5e79 100644 --- a/examples/step-63/step-63.cc +++ b/examples/step-63/step-63.cc @@ -122,7 +122,7 @@ namespace Step63 random }; - bool get_parameters(const std::string &prm_filename); + void get_parameters(const std::string &prm_filename); unsigned int fe_degree; std::string smoother_type; @@ -131,15 +131,8 @@ namespace Step63 bool output; }; - bool Settings::get_parameters(const std::string &prm_filename) + void Settings::get_parameters(const std::string &prm_filename) { - if (prm_filename.size() == 0) - { - std::cerr << "Usage: please pass a .prm file as the first argument" - << std::endl; - return false; - } - ParameterHandler prm; prm.declare_entry("Fe degree", @@ -163,19 +156,15 @@ namespace Step63 Patterns::Bool(), "Generate graphical output: true|false"); - try - { - prm.parse_input(prm_filename); - } - catch (const dealii::PathSearch::ExcFileNotFound &) + if (prm_filename.size() == 0) { - std::cerr << "ERROR: could not parse input from given .prm file" - << prm_filename << "'" << std::endl; - prm.print_parameters(std::cout, ParameterHandler::Text); - return false; + AssertThrow( + false, ExcMessage("please pass a .prm file as the first argument!")); } + prm.parse_input(prm_filename); + fe_degree = prm.get_integer("Fe degree"); smoother_type = prm.get("Smoother type"); @@ -191,8 +180,6 @@ namespace Step63 with_streamline_diffusion = prm.get_bool("With streamline diffusion"); output = prm.get_bool("Output"); - - return true; } @@ -1111,8 +1098,7 @@ int main(int argc, char *argv[]) try { Step63::Settings settings; - if (!settings.get_parameters((argc > 1) ? (argv[1]) : "")) - return 0; + settings.get_parameters((argc > 1) ? (argv[1]) : ""); Step63::AdvectionProblem<2> advection_problem_2d(settings); advection_problem_2d.run(); -- 2.39.5