-
Notifications
You must be signed in to change notification settings - Fork 707
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16704 from peterrum/parameterhandler_create_path_…
…if_needed Don't create new sections during parsing
- Loading branch information
Showing
6 changed files
with
102 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Improved: The parse functions of ParameterHandler used to add subsections | ||
if subsections/parameters have not been defined. This led to an output | ||
of ParameterHandler::print_parameters() that also contained these subsections. | ||
This is not the case anymore. | ||
<br> | ||
(Peter Munch, Magdalena Schreter-Fleischhacker, 2024/02/12) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// ------------------------------------------------------------------------ | ||
// | ||
// SPDX-License-Identifier: LGPL-2.1-or-later | ||
// Copyright (C) 2020 by the deal.II authors | ||
// | ||
// This file is part of the deal.II library. | ||
// | ||
// Part of the source code is dual licensed under Apache-2.0 WITH | ||
// LLVM-exception OR LGPL-2.1-or-later. Detailed license information | ||
// governing the source code and code contributions can be found in | ||
// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. | ||
// | ||
// ------------------------------------------------------------------------ | ||
|
||
|
||
|
||
// check ParameterHandler::parse_input() for json file | ||
|
||
#include <deal.II/base/parameter_handler.h> | ||
|
||
#include "../tests.h" | ||
|
||
|
||
int | ||
main() | ||
{ | ||
initlog(); | ||
|
||
ParameterHandler prm; | ||
|
||
double test_0 = 0; | ||
double test_1 = 0; | ||
|
||
// test if underscore can be parsed | ||
prm.add_parameter("test 0", test_0); | ||
prm.add_parameter("test 1", test_1); | ||
|
||
std::string source = SOURCE_DIR; | ||
std::string filename = source + "/prm/parameter_handler_read_json_04.json"; | ||
|
||
std::ifstream file; | ||
file.open(filename); | ||
prm.parse_input_from_json(file, true); | ||
|
||
prm.print_parameters(deallog.get_file_stream(), | ||
ParameterHandler::OutputStyle::ShortJSON); | ||
|
||
return 0; | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/parameter_handler/parameter_handler_read_json_04.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
{ | ||
"test 0": "1", | ||
"test 1": "1" | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/parameter_handler/prm/parameter_handler_read_json_04.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"test 0": "1", | ||
"test 1": "1", | ||
"test 2": "1", | ||
"test 3": { | ||
"test 4" : "1" | ||
} | ||
} |