From 7d8fe81c1ce7963733f2684e10e31b9c0ae87f81 Mon Sep 17 00:00:00 2001 From: MFraters Date: Tue, 13 Feb 2024 18:33:33 -0500 Subject: [PATCH 1/7] Add option to gwb-dat to enable or disable writing out files. It is disabled by default. --- source/gwb-dat/main.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/gwb-dat/main.cc b/source/gwb-dat/main.cc index e8ed6cb5d..edfdae8a5 100644 --- a/source/gwb-dat/main.cc +++ b/source/gwb-dat/main.cc @@ -74,6 +74,7 @@ int main(int argc, char **argv) size_t n_grains = 0; bool convert_spherical = false; bool limit_debug_consistency_checks = true; + bool output_json_files = false; if (find_command_line_option(argv, argv+argc, "-h") || find_command_line_option(argv, argv+argc, "--help")) { @@ -87,6 +88,9 @@ int main(int argc, char **argv) if (find_command_line_option(argv, argv+argc, "-ldcc") || find_command_line_option(argv, argv+argc, "--limit-debug-consistency-checks")) limit_debug_consistency_checks = false; + if (find_command_line_option(argv, argv+argc, "--output-json-files")) + output_json_files = true; + if (argc == 1) { std::cout << "Error: There where no files passed to the World Builder, use --help for more " << std::endl @@ -102,11 +106,12 @@ int main(int argc, char **argv) return 0; } - if ((argc == 3 && !limit_debug_consistency_checks) || argc > 4) + if ((argc == 3 && (!limit_debug_consistency_checks || output_json_files)) || (argc == 3 && (!limit_debug_consistency_checks && output_json_files)) || argc > 5) { std::cout << "Only exactly two command line arguments may be given, which should be the world builder file location and the data file location (in that order) " - << "or exactly three command line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks (in that order). " - << ", argc = " << argc << ", limit_debug_consistency_checks = " << (limit_debug_consistency_checks ? "true" : "false") << std::endl; + << "or exactly three command line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks or --output-json-files (in that order)," + "or exactly four comman line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks and --output-json-files (in that order)," + << ", argc = " << argc << ", limit_debug_consistency_checks = " << (limit_debug_consistency_checks ? "true" : "false") << ", output_json_files = " << (output_json_files ? "true" : "false") << std::endl; return 0; } @@ -130,7 +135,7 @@ int main(int argc, char **argv) //try { const std::string output_dir = wb_file.substr(0,wb_file.find_last_of("/\\") + 1); - world = std::make_unique(wb_file, true, output_dir,1,limit_debug_consistency_checks); + world = std::make_unique(wb_file, output_json_files, output_dir,1,limit_debug_consistency_checks); } /*catch (std::exception &e) { From dd4ca145f2a8cf73d0366d916864dc9cc753b64e Mon Sep 17 00:00:00 2001 From: MFraters Date: Tue, 13 Feb 2024 18:34:35 -0500 Subject: [PATCH 2/7] Add new test to test/CMakeLists.txt to generate the declarations and schema output. --- doc/generate_decl_schema.wb | 4 ++++ tests/CMakeLists.txt | 14 ++++++++++++++ .../screen-output.log | 4 ++++ 3 files changed, 22 insertions(+) create mode 100644 doc/generate_decl_schema.wb create mode 100644 tests/gwb-dat/generate_declarations_and_schema/screen-output.log diff --git a/doc/generate_decl_schema.wb b/doc/generate_decl_schema.wb new file mode 100644 index 000000000..e5d14986a --- /dev/null +++ b/doc/generate_decl_schema.wb @@ -0,0 +1,4 @@ +{ + "version": "0.6", + "features": [] +} \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 068b347ec..afdf0fd91 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -143,6 +143,20 @@ IF(WB_RUN_APP_TESTS) -D TEST_DIFF=${TEST_DIFF} -P ${CMAKE_SOURCE_DIR}/tests/gwb-dat/run_gwb-dat_tests.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gwb-dat/) + + # Add tests which generates the declarations and schema files in the docs folder. Do not care about the output. + set(TEST_ARGUMENTS "${CMAKE_SOURCE_DIR}/doc/generate_decl_schema.wb\;${CMAKE_SOURCE_DIR}/tests/gwb-dat/app_wb2.dat\;--output-json-files") + add_test(generate_declarations_and_schema + ${CMAKE_COMMAND} + -D TEST_NAME=generate_declarations_and_schema + -D TEST_PROGRAM=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gwb-dat${CMAKE_EXECUTABLE_SUFFIX} + -D TEST_ARGS=${TEST_ARGUMENTS} + -D TEST_OUTPUT=${CMAKE_BINARY_DIR}/tests/gwb-dat/generate_declarations_and_schema/screen-output.log + -D TEST_REFERENCE=${CMAKE_CURRENT_SOURCE_DIR}/gwb-dat/generate_declarations_and_schema/screen-output.log + -D TEST_DIFF=${TEST_DIFF} + -P ${CMAKE_SOURCE_DIR}/tests/gwb-dat/run_gwb-dat_tests.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gwb-dat/) + #find all the integration test files file(GLOB_RECURSE APP_TEST_SOURCES "gwb-dat/*.wb") diff --git a/tests/gwb-dat/generate_declarations_and_schema/screen-output.log b/tests/gwb-dat/generate_declarations_and_schema/screen-output.log new file mode 100644 index 000000000..4b82221cf --- /dev/null +++ b/tests/gwb-dat/generate_declarations_and_schema/screen-output.log @@ -0,0 +1,4 @@ +# x y z d g T c0 c1 c2 c3 c4 +100e3 200e3 0 0 1600 0 0 0 0 0 +120e3 550e3 0 0 1600 0 0 0 0 0 +1500e3 1500e3 3 0 1600 0 0 0 0 0 From 502648827c083fdcfa1bc85e569cdcbac77308fa Mon Sep 17 00:00:00 2001 From: MFraters Date: Tue, 13 Feb 2024 18:38:11 -0500 Subject: [PATCH 3/7] Move world builder declarations files to doc folder. --- {tests/gwb-dat => doc}/world_builder_declarations.schema.json | 0 {tests/gwb-dat => doc}/world_builder_declarations_closed.md | 0 {tests/gwb-dat => doc}/world_builder_declarations_open.md | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {tests/gwb-dat => doc}/world_builder_declarations.schema.json (100%) rename {tests/gwb-dat => doc}/world_builder_declarations_closed.md (100%) rename {tests/gwb-dat => doc}/world_builder_declarations_open.md (100%) diff --git a/tests/gwb-dat/world_builder_declarations.schema.json b/doc/world_builder_declarations.schema.json similarity index 100% rename from tests/gwb-dat/world_builder_declarations.schema.json rename to doc/world_builder_declarations.schema.json diff --git a/tests/gwb-dat/world_builder_declarations_closed.md b/doc/world_builder_declarations_closed.md similarity index 100% rename from tests/gwb-dat/world_builder_declarations_closed.md rename to doc/world_builder_declarations_closed.md diff --git a/tests/gwb-dat/world_builder_declarations_open.md b/doc/world_builder_declarations_open.md similarity index 100% rename from tests/gwb-dat/world_builder_declarations_open.md rename to doc/world_builder_declarations_open.md From 86c073fba52f2eff638b6c059745bb44eb80158e Mon Sep 17 00:00:00 2001 From: MFraters Date: Tue, 13 Feb 2024 18:53:15 -0500 Subject: [PATCH 4/7] Update doc declarations location. --- doc/sphinx/GWB_parameter_listings/world_builder_file/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/sphinx/GWB_parameter_listings/world_builder_file/index.md b/doc/sphinx/GWB_parameter_listings/world_builder_file/index.md index 668f3f633..ce0d0d098 100644 --- a/doc/sphinx/GWB_parameter_listings/world_builder_file/index.md +++ b/doc/sphinx/GWB_parameter_listings/world_builder_file/index.md @@ -16,13 +16,13 @@ Explain how to use this page. Here is an example how to link to a specific item ::::{tab-item} All open :name: all_open -:::{include} ../../../../tests/gwb-dat/world_builder_declarations_open.md +:::{include} ../../../world_builder_declarations_open.md :::: ::::{tab-item} Only root open :name: root_open -:::{include} ../../../../tests/gwb-dat/world_builder_declarations_closed.md +:::{include} ../../../world_builder_declarations_closed.md :::: ::::: From fe7a0c90a2c8080b14b1b5261431f36f4b0027cd Mon Sep 17 00:00:00 2001 From: MFraters Date: Tue, 13 Feb 2024 18:55:44 -0500 Subject: [PATCH 5/7] Update declarations schema. --- doc/world_builder_declarations.schema.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/world_builder_declarations.schema.json b/doc/world_builder_declarations.schema.json index 0100a9c3f..2f5b5d5d6 100644 --- a/doc/world_builder_declarations.schema.json +++ b/doc/world_builder_declarations.schema.json @@ -6248,7 +6248,7 @@ "documentation": "The reference density of the subducting plate in $kg/m^3$" }, "plate velocity": { - "default value": NaN, + "default value": "NaN", "type": "number", "documentation": "The velocity in meters per year with which the plate subducts in meters per year." }, @@ -6939,7 +6939,7 @@ "documentation": "The reference density of the subducting plate in $kg/m^3$" }, "plate velocity": { - "default value": NaN, + "default value": "NaN", "type": "number", "documentation": "The velocity in meters per year with which the plate subducts in meters per year." }, @@ -7700,7 +7700,7 @@ "documentation": "The reference density of the subducting plate in $kg/m^3$" }, "plate velocity": { - "default value": NaN, + "default value": "NaN", "type": "number", "documentation": "The velocity in meters per year with which the plate subducts in meters per year." }, @@ -8391,7 +8391,7 @@ "documentation": "The reference density of the subducting plate in $kg/m^3$" }, "plate velocity": { - "default value": NaN, + "default value": "NaN", "type": "number", "documentation": "The velocity in meters per year with which the plate subducts in meters per year." }, From c5e8e181a3cb7906bc8e256ea2ea07aaaddc849b Mon Sep 17 00:00:00 2001 From: MFraters Date: Tue, 13 Feb 2024 19:05:04 -0500 Subject: [PATCH 6/7] Indent code. --- source/gwb-dat/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gwb-dat/main.cc b/source/gwb-dat/main.cc index edfdae8a5..1e997312c 100644 --- a/source/gwb-dat/main.cc +++ b/source/gwb-dat/main.cc @@ -110,7 +110,7 @@ int main(int argc, char **argv) { std::cout << "Only exactly two command line arguments may be given, which should be the world builder file location and the data file location (in that order) " << "or exactly three command line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks or --output-json-files (in that order)," - "or exactly four comman line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks and --output-json-files (in that order)," + "or exactly four comman line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks and --output-json-files (in that order)," << ", argc = " << argc << ", limit_debug_consistency_checks = " << (limit_debug_consistency_checks ? "true" : "false") << ", output_json_files = " << (output_json_files ? "true" : "false") << std::endl; return 0; } From 31492898049d416aed3b9f35d1787d74d099c113 Mon Sep 17 00:00:00 2001 From: MFraters Date: Tue, 13 Feb 2024 22:00:32 -0500 Subject: [PATCH 7/7] Change the meaning of bool limit-debug-consistency-checks to be more intuative. --- include/world_builder/world.h | 2 +- source/gwb-dat/main.cc | 6 +++--- source/world_builder/world.cc | 2 +- tests/gwb-dat/testing_too_many_arguments/screen-output.log | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/world_builder/world.h b/include/world_builder/world.h index 246ef2f91..fa0c41bfd 100644 --- a/include/world_builder/world.h +++ b/include/world_builder/world.h @@ -60,7 +60,7 @@ namespace WorldBuilder * documented algorithm), we can test the results and they should be the same even for different * compilers and machines. */ - World(std::string filename, bool has_output_dir = false, const std::string &output_dir = "", unsigned long random_number_seed = 1, const bool limit_debug_consistency_checks = false); + World(std::string filename, bool has_output_dir = false, const std::string &output_dir = "", unsigned long random_number_seed = 1, const bool limit_debug_consistency_checks = true); /** * Destructor diff --git a/source/gwb-dat/main.cc b/source/gwb-dat/main.cc index 1e997312c..c1a25ba85 100644 --- a/source/gwb-dat/main.cc +++ b/source/gwb-dat/main.cc @@ -73,7 +73,7 @@ int main(int argc, char **argv) unsigned int grain_compositions = 0; size_t n_grains = 0; bool convert_spherical = false; - bool limit_debug_consistency_checks = true; + bool limit_debug_consistency_checks = false; bool output_json_files = false; if (find_command_line_option(argv, argv+argc, "-h") || find_command_line_option(argv, argv+argc, "--help")) @@ -86,7 +86,7 @@ int main(int argc, char **argv) } if (find_command_line_option(argv, argv+argc, "-ldcc") || find_command_line_option(argv, argv+argc, "--limit-debug-consistency-checks")) - limit_debug_consistency_checks = false; + limit_debug_consistency_checks = true; if (find_command_line_option(argv, argv+argc, "--output-json-files")) output_json_files = true; @@ -106,7 +106,7 @@ int main(int argc, char **argv) return 0; } - if ((argc == 3 && (!limit_debug_consistency_checks || output_json_files)) || (argc == 3 && (!limit_debug_consistency_checks && output_json_files)) || argc > 5) + if ((argc == 3 && !(limit_debug_consistency_checks && output_json_files)) || (argc == 4 && !(!limit_debug_consistency_checks != !output_json_files)) || (argc == 5 && (!limit_debug_consistency_checks && !output_json_files)) || argc > 5) { std::cout << "Only exactly two command line arguments may be given, which should be the world builder file location and the data file location (in that order) " << "or exactly three command line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks or --output-json-files (in that order)," diff --git a/source/world_builder/world.cc b/source/world_builder/world.cc index 5794411e2..54a61af17 100644 --- a/source/world_builder/world.cc +++ b/source/world_builder/world.cc @@ -306,7 +306,7 @@ namespace WorldBuilder // We receive the cartesian points from the user. const Point<3> point(point_,cartesian); (void) this->limit_debug_consistency_checks; - WBAssert(!this->limit_debug_consistency_checks || this->parameters.coordinate_system->natural_coordinate_system() == cartesian + WBAssert(this->limit_debug_consistency_checks || this->parameters.coordinate_system->natural_coordinate_system() == cartesian || approx(depth, this->parameters.coordinate_system->max_model_depth()-sqrt(point_[0]*point_[0]+point_[1]*point_[1]+point_[2]*point_[2])), "Inconsistent input. Please check whether the radius in the sperhical coordinates is consistent with the radius of the planet as defined " << "in the program that uses the Geodynamic World Builder. " diff --git a/tests/gwb-dat/testing_too_many_arguments/screen-output.log b/tests/gwb-dat/testing_too_many_arguments/screen-output.log index 732f9115e..a7d3c9dd9 100644 --- a/tests/gwb-dat/testing_too_many_arguments/screen-output.log +++ b/tests/gwb-dat/testing_too_many_arguments/screen-output.log @@ -1 +1 @@ -Only exactly two command line arguments may be given, which should be the world builder file location and the data file location (in that order) or exactly three command line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks (in that order). , argc = 5, limit_debug_consistency_checks = true +Only exactly two command line arguments may be given, which should be the world builder file location and the data file location (in that order) or exactly three command line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks or --output-json-files (in that order),or exactly four comman line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks and --output-json-files (in that order),, argc = 5, limit_debug_consistency_checks = false, output_json_files = false