Skip to content

Commit

Permalink
Merge pull request #12789 from sebproell/prm-parse-mandatory
Browse files Browse the repository at this point in the history
Fix bug in ParameterHandler::parse_input for .prm
  • Loading branch information
drwells committed Oct 4, 2021
2 parents 8d89666 + 2fb68a9 commit f37e029
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 8 deletions.
9 changes: 9 additions & 0 deletions source/base/parameter_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1951,6 +1951,15 @@ ParameterHandler::scan_line(std::string line,

// finally write the new value into the database
entries->put(path + path_separator + "value", entry_value);

auto map_iter = entries_set_status.find(path);
if (map_iter != entries_set_status.end())
map_iter->second =
std::pair<bool, bool>(map_iter->second.first, true);
else
AssertThrow(false,
ExcMessage("Could not find parameter " + path +
" in map entries_set_status."));
}
else
{
Expand Down
15 changes: 7 additions & 8 deletions tests/parameter_handler/parameter_handler_26.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "../tests.h"

void
success()
success(const std::string &filename)
{
unsigned int dim = 2;
std::string precision = "double";
Expand All @@ -42,8 +42,6 @@ success()

try
{
std::string source = SOURCE_DIR;
std::string filename = source + "/prm/parameter_handler_26_success.json";
prm.parse_input(filename, "", true, true);
}
catch (std::exception &exc)
Expand All @@ -55,7 +53,7 @@ success()
}

void
fail()
fail(const std::string &filename)
{
unsigned int dim = 2;
std::string precision = "double";
Expand All @@ -74,8 +72,6 @@ fail()

try
{
std::string source = SOURCE_DIR;
std::string filename = source + "/prm/parameter_handler_26_fail.json";
prm.parse_input(filename, "", true, true);
}
catch (std::exception &exc)
Expand All @@ -91,10 +87,13 @@ main()
initlog();
deallog.get_file_stream().precision(3);

const std::string source = SOURCE_DIR;
try
{
success();
fail();
success(source + "/prm/parameter_handler_26_success.json");
fail(source + "/prm/parameter_handler_26_fail.json");
success(source + "/prm/parameter_handler_26_success.prm");
fail(source + "/prm/parameter_handler_26_fail.prm");
}
catch (std::exception &exc)
{
Expand Down
20 changes: 20 additions & 0 deletions tests/parameter_handler/parameter_handler_26.output
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,23 @@ Additional information:
correct.
--------------------------------------------------------

DEAL::
DEAL::successful
DEAL::
--------------------------------------------------------
An error occurred in file <parameter_handler.cc> in function
void dealii::ParameterHandler::assert_that_entries_have_been_set() const
The violated condition was:
entries_wrongly_not_set.size() == 0
Additional information:
Not all entries of the parameter handler that were declared with
`has_to_be_set = true` have been set. The following parameters

General.Precision
General.dim

have not been set. A possible reason might be that you did not add
these parameter to the input file or that their spelling is not
correct.
--------------------------------------------------------

3 changes: 3 additions & 0 deletions tests/parameter_handler/prm/parameter_handler_26_fail.prm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
subsection General
set Precison = float
end
3 changes: 3 additions & 0 deletions tests/parameter_handler/prm/parameter_handler_26_success.prm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
subsection General
set Precision = float
end

0 comments on commit f37e029

Please sign in to comment.