Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in ParameterHandler::parse_input for .prm #12789

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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