]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix bug in ParameterHandler::parse_input for .prm 12789/head
authorSebastian Proell <sebastian.proell@tum.de>
Mon, 4 Oct 2021 13:28:26 +0000 (15:28 +0200)
committerSebastian Proell <sebastian.proell@tum.de>
Mon, 4 Oct 2021 13:38:48 +0000 (15:38 +0200)
The entries_set_status was not updated when parsing from .prm files.

source/base/parameter_handler.cc
tests/parameter_handler/parameter_handler_26.cc
tests/parameter_handler/parameter_handler_26.output
tests/parameter_handler/prm/parameter_handler_26_fail.prm [new file with mode: 0644]
tests/parameter_handler/prm/parameter_handler_26_success.prm [new file with mode: 0644]

index 23ca017ce94c35a8857c907a3c5e83578c541b28..5245cf7f9b503c0770aef9d9cb6b96415fc823e3 100644 (file)
@@ -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
         {
index 51fc59d363d63a21ccfa6f5e611097f28510e088..9ba036b231d387d5dc88012fe99322437165867d 100644 (file)
@@ -20,7 +20,7 @@
 #include "../tests.h"
 
 void
-success()
+success(const std::string &filename)
 {
   unsigned int dim       = 2;
   std::string  precision = "double";
@@ -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)
@@ -55,7 +53,7 @@ success()
 }
 
 void
-fail()
+fail(const std::string &filename)
 {
   unsigned int dim       = 2;
   std::string  precision = "double";
@@ -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)
@@ -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)
     {
index 7ce64d469fa92049d127cc3620f945f159f510b8..ce3d2c506965e6b995e699ea11310c303356994a 100644 (file)
@@ -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.
+--------------------------------------------------------
+
diff --git a/tests/parameter_handler/prm/parameter_handler_26_fail.prm b/tests/parameter_handler/prm/parameter_handler_26_fail.prm
new file mode 100644 (file)
index 0000000..ecbda56
--- /dev/null
@@ -0,0 +1,3 @@
+subsection General
+  set Precison = float
+end
diff --git a/tests/parameter_handler/prm/parameter_handler_26_success.prm b/tests/parameter_handler/prm/parameter_handler_26_success.prm
new file mode 100644 (file)
index 0000000..6878b54
--- /dev/null
@@ -0,0 +1,3 @@
+subsection General
+  set Precision = float
+end

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.