diff --git a/.Rbuildignore b/.Rbuildignore index 2b3cefdb354fa876267d1450bda440e250c96f42..77187af248b9c45aca63b68bc1a4746165da0d6a 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,6 +5,7 @@ ^inst/examples/Theis_problem ^inst/examples/Theis_well_pumping ^LICENSE.md +^config.yml ^doc$ ^Meta$ ^data-raw$ diff --git a/DESCRIPTION b/DESCRIPTION index 1e50751378bc7010f172c78c4f501efe10e4601a..00aee868dec700d47d7531ad8e66ba106dcfa8ff 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,13 +2,16 @@ Package: r2ogs6 Type: Package Title: An API to the multi-physics simulator OpenGeoSys-v6 Version: 0.1.0 -Author: person(given = "Johannes", - family = "Boog", - role = c("aut", "cre"), - email = "johannesboog@yahoo.de", - comment = structure("https://orcid.org/0000-0003-1094-9255", - .Names = "ORCID")) -Maintainer: Johannes Boog <johannesboog@yahoo.de> +Authors@R: c(person(given = "Anna", + family = "Heinrich", + role = c("aut"), + email = "aheinri5@web.de"), + person(given = "Johannes", + family = "Boog", + role = c("aut", "cre"), + email = "johannesboog@yahoo.de", + comment = structure("https://orcid.org/0000-0003-1094-9255", + .Names = "ORCID"))) Description: Define and manage simulations using OpenGeoSys-v6. License: file LICENSE Encoding: UTF-8 @@ -32,7 +35,9 @@ Imports: dplyr, rlang, doParallel, - reticulate + reticulate, + config, + sticky RoxygenNote: 7.1.1 VignetteBuilder: knitr Depends: diff --git a/NAMESPACE b/NAMESPACE index 503a2aae0cfcc7ce3d6581738b4b52c526e5f4b0..c832e9ff2dc63b61c7737e39002999319467ed5e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,11 +7,14 @@ export(OGS6_gml) export(OGS6_pvd) export(OGS6_vtu) export(ogs6_call_ogs6) +export(ogs6_download_ogs6) export(ogs6_export_sim_files) export(ogs6_generate_benchmark_script) +export(ogs6_generate_benchmark_scripts) export(ogs6_generate_structured_mesh) export(ogs6_get_combinations) export(ogs6_get_medium_property) +export(ogs6_prj_top_level_classes) export(ogs6_read_output_files) export(ogs6_run_simulation) export(prj_borehole_heat_exchanger) diff --git a/R/analyse_xml.R b/R/analyse_xml.R index 262304b0e21a1ac6f5f7749871f3cefa1ee1dede..80b4eeaa9ecd82e42333e82296e947e4f857c361 100644 --- a/R/analyse_xml.R +++ b/R/analyse_xml.R @@ -1,21 +1,20 @@ -#This is a helper function which can be used to combat missing documentation. -#Benchmark HydroMechanics: -# analyse_xml("D:\\Programme\\OpenGeoSys\\ogs-master-Tests-Data/", -# "\\.vtu$", -# "VTKFile") +#===== analyse_xml ===== -#'analyse_xml -#'@description This is a helper function which can be used to combat missing + +#' analyse_xml +#' @description +#' This is a helper function which can be used to combat missing #' documentation. It looks for files in a path which match the given pattern #' and then attempts to parse them as XML. For each occurence of the specified #' element, it documents its attributes and direct children and prints a little #' summary of its findings at the end. -#'@param path string: A path -#'@param pattern string: A regex pattern -#'@param xpath string: An XPath expression. WARNING: Only works for expressions -#' that return nodesets, use it to look up tag names. -#'@param print_findings Optional: Should the results be printed to the console? +#' @param path string: A path +#' @param pattern string: A regex pattern +#' @param xpath string: An XPath expression. WARNING: Only works for expressions +#' that return nodesets, use it to look up tag names. +#' @param print_findings Optional: Should the results be printed to the console? +#' @noRd analyse_xml <- function(path, pattern, xpath, @@ -259,11 +258,13 @@ print_analysis_findings <- function(invalid_files_count, #===== get_required ===== -#'get_required -#'@description Helper function to mark required attributes or children from a +#' get_required +#' @description +#' Helper function to mark required attributes or children from a #' vector of names and a vector of occurrence probabilities -#'@param names A vector of names -#'@param occurence_probabilities A vector of occurrence probabilities +#' @param names A vector of names +#' @param occurence_probabilities A vector of occurrence probabilities +#' @noRd get_required <- function(names, occurence_probabilities){ required <- logical() diff --git a/R/compare_xml.R b/R/compare_xml.R deleted file mode 100644 index 115a4be61eedce965d10ba9e36e70d7e25e2d9e1..0000000000000000000000000000000000000000 --- a/R/compare_xml.R +++ /dev/null @@ -1,122 +0,0 @@ - - -#'compare_xml -#'@description Helper function to check if 2 XML documents have the same -#' content. This is a recursive function. Strictly WIP! -#'@param xml_node_x xml2::xml_node: Node to compare -#'@param xml_node_y xml2::xml_node: Node to compare to -compare_xml <- function(xml_node_x, xml_node_y){ - - assertthat::assert_that("xml_node" %in% class(xml_node_x)) - assertthat::assert_that("xml_node" %in% class(xml_node_y)) - - x_node_name <- xml2::xml_name(xml_node_x) - y_node_name <- xml2::xml_name(xml_node_y) - - ret_str <- "" - - # Recursion stops here - if(length(xml2::xml_children(xml_node_x)) == 0 || - length(xml2::xml_children(xml_node_y)) == 0 ){ - - if(length(xml2::xml_children(xml_node_x)) != - length(xml2::xml_children(xml_node_y))){ - ret_str <- paste0("Child mismatch: <", - x_node_name, "> in x has ", - length(xml2::xml_children(xml_node_x)), - " children while <", - y_node_name, " in y has ", - length(xml2::xml_children(xml_node_y)), ".\n") - } - - if(x_node_name != y_node_name){ - ret_str <- paste0(ret_str, - "Name mismatch: <", x_node_name, "> in x, <", - y_node_name, " in y.\n") - } - - if(xml2::xml_text(xml_node_x) != xml2::xml_text(xml_node_y)){ - ret_str <- paste0(ret_str, - "Text mismatch: \"", xml2::xml_text(xml_node_x), - "\" in x, \"", - xml2::xml_text(xml_node_x), "\" in y.\n") - } - - if(xml2::xml_attrs(xml_node_x) != xml2::xml_attrs(xml_node_y)){ - - x_node_attrs <- paste(names(xml2::xml_attrs(xml_node_x)), - xml2::xml_attrs(xml_node_x), - sep = " = ", collapse = ",\n") - - y_node_attrs <- paste(names(xml2::xml_attrs(xml_node_y)), - xml2::xml_attrs(xml_node_y), - sep = " = ", collapse = ",\n") - - ret_str <- paste0(ret_str, - "Attribute mismatch: (", x_node_attrs, - ") in x, (", - y_node_attrs, ") in y.\n") - } - - return(invisible(ret_str)) - } - - y_children_ordered <- xml2::xml_children(xml_node_y) - y_child_names <- get_nodeset_names(y_children_ordered) - - x_children_ordered <- xml2::xml_children(xml_node_x) - - if(0){ - cat("Children of <", x_node_name, "> tags are not the same ", - "for x and y. compare_xml() may not yield all differences. ", - "Continuing iteration based on first parameter (x).", sep = "") - } - - for(i in seq_len(length(x_children_ordered))){ - - x_child <- x_children_ordered[[i]] - - # If x has a child y doesn't have - if(xml2::xml_name(x_child) %in% y_child_names){ - - - ret_str <- paste0(ret_str, compare_xml(x_child)) - - }else{ - ret_str <- paste0(ret_str, - "<", xml2::xml_name(x_child), - "> is a child of <", - x_node_name, - "> in x but not of <", - y_node_name, "> in y.") - } - } - - return(invisible(ret_str)) -} - - -# order_nodeset <- function(nodeset){ -# -# nodeset_names <- sort(get_nodeset_names(nodeset)) -# ordered_nodeset <- rep(NULL, length(nodeset_names)) -# -# for(){ -# -# } -# -# -# } - - -get_nodeset_names <- function(nodeset){ - - nodeset_names <- c() - - for(i in seq_along(nodeset)){ - nodeset_names <- c(nodeset_names, xml2::xml_name(nodeset[[i]])) - } - - return(invisible(nodeset_names)) -} - diff --git a/R/download_ogs6.R b/R/download_ogs6.R new file mode 100644 index 0000000000000000000000000000000000000000..019c5f8483da4ebe72b711459c6bd5a250adfa23 --- /dev/null +++ b/R/download_ogs6.R @@ -0,0 +1,93 @@ + + +#' Download OpenGeoSys 6 +#' +#' Downloads latest prebuilt OpenGeoSys 6 version +#' +#' @param path String: Download path. Defaults to ... +#' @param os String: Operating System. +#' @param set_as_default_bin_path flag: Defaults to `TRUE` +#' @export +ogs6_download_ogs6 <- function(path, + os, + set_as_default_bin_path = TRUE){ + + default_installation_paths <- + list( + Windows = c("C:/Program Files/", + "D:/Program Files/"), + Darwin = c("/Applications/"), + Linux = c("~/software/", + "~/opt/") + ) + + if(missing(os)){ + os <- Sys.info()["sysname"] + } + + assertthat::assert_that(assertthat::is.string(os)) + assertthat::assert_that(os %in% names(default_installation_paths)) + assertthat::assert_that(assertthat::is.flag(set_as_default_bin_path)) + + if(missing(path)){ + + path <- NULL + + for(i in default_installation_paths[[os]]){ + if(dir.exists(i)){ + path <- i + break + } + } + + if(is.null(path)){ + stop( + paste0( + "Did not find any default path for OpenGeoSys 6 ", + "on your System. I checked the following paths:\n", + paste(default_installation_paths[[os]], collapse = "\n"), + "\nPlease specify a path manually instead." + ), + call. = FALSE + ) + } + } + + path <- as_dir_path(path) + + if(os == "Windows"){ + + url_path <- + paste0( + "https://ogsstorage.blob.core.windows.net/binaries/ogs6/", + "6.3.3/ogs-6.3.3-Windows-10.0.14393-python-3.7.2-utils.zip" + ) + + ogs_zip_folder <- paste0(path, basename(url_path)) + utils::download.file(url_path, ogs_zip_folder) + + ogs_folder <- gsub("\\.zip$", "", ogs_zip_folder) + utils::unzip(ogs_zip_folder, exdir = ogs_folder) + unlink(ogs_zip_folder) + + }else{ + url_path <- + paste0( + "https://ogsstorage.blob.core.windows.net/binaries/ogs6/", + "6.3.3/ogs-6.3.3-Windows-10.0.14393-python-3.7.2-utils.zip" + ) + + ogs_folder <- "/scif/apps/ogs" + + sif_path <- paste0(path, "ogs-6.3.3-serial.sif") + utils::download.file(url_path, sif_path) + } + + bin_path <- paste0(ogs_folder, "/bin") + + if(set_as_default_bin_path){ + options(r2ogs6.default_ogs6_bin_path = bin_path) + } + + return(invisible()) +} diff --git a/R/export_gml.R b/R/export_gml.R index d758f2f4506c159d1f6fcab3e49d48ca1909b111..ac91882d6e3b79c67c74699e2ec4df59d8c43375 100644 --- a/R/export_gml.R +++ b/R/export_gml.R @@ -6,6 +6,7 @@ #' @description Creates a .gml XML document based on user input data #' @param gml OGS6_gml: #' @param path string: +#' @noRd export_gml <- function(gml, path) { assertthat::assert_that(assertthat::is.string(path)) diff --git a/R/export_prj.R b/R/export_prj.R index a9453d8882049e72265cd6be3145a9e07b19738c..8f3aa5969136c943d366926f8ba334574b90e3ca 100644 --- a/R/export_prj.R +++ b/R/export_prj.R @@ -3,9 +3,11 @@ #' export_prj -#' @description Wrapper function to create a \code{.prj} XML document based on -#' the user input data +#' @description +#' Wrapper function to create a \code{.prj} XML document based on the user +#' input data #' @param ogs6_obj OGS6: Simulation object +#' @noRd export_prj <- function(ogs6_obj) { prj_xml <- xml2::xml_new_root( @@ -18,20 +20,19 @@ export_prj <- function(ogs6_obj) { #If there is a .gml defined, add "mesh" node, else add "meshes" node if(is.null(ogs6_obj$geometry)) { - basenames <- lapply(ogs6_obj$meshes, function(x){basename(x)}) - meshes_node <- to_node(basenames, "meshes") + meshes_node <- meshes_to_xml(ogs6_obj$meshes) }else{ xml2::xml_add_child( prj_xml, xml2::as_xml_document(to_node(ogs6_obj$geometry))) - meshes_node <- to_node(basename(ogs6_obj$meshes[[1]]), "mesh") + meshes_node <- meshes_to_xml(ogs6_obj$meshes) } xml2::xml_add_child(prj_xml, - xml2::as_xml_document(meshes_node)) + meshes_node) #Get implemented classes - prj_components <- prj_top_level_classes() + prj_components <- ogs6_prj_top_level_classes() # Include file reference if(names(ogs6_obj$processes)[[1]] == "include"){ diff --git a/R/export_utils.R b/R/export_utils.R index b625847acb73a879493adf2b3b03470fbd86b31e..ef1d2c1ee8bc411051bd83cfe22202a7be9d956f 100644 --- a/R/export_utils.R +++ b/R/export_utils.R @@ -15,6 +15,7 @@ #' flattened to a string in XML #' @param unwrap_on_exp character: Optional: This is for lists which will not #' be exported to XML +#' @noRd to_node <- function(object, object_name = "", attribute_names = character(), flatten_on_exp = character(), @@ -173,3 +174,38 @@ to_node <- function(object, object_name = "", return(invisible(object_node)) } } + + +#===== meshes_to_xml ===== + + +#' meshes_to_xml +#' @description +#' Helper function for a mesh element of a .prj file. +#' @param meshes list: List of meshes +#' @noRd +meshes_to_xml <- function(meshes){ + + meshes_doc <- xml2::read_xml("<meshes/>") + + xml_children <- lapply(meshes, function(x){ + if(x[["axially_symmetric"]]){ + xml2::as_xml_document( + list(mesh = structure(list(basename(x[["path"]])), + axially_symmetric = "true"))) + }else{ + xml2::as_xml_document( + list(mesh = list(basename(x[["path"]])))) + } + }) + + if(length(meshes) == 1){ + return(xml_children[[1]]) + }else{ + for(i in seq_len(length(xml_children))){ + xml2::xml_add_child(meshes_doc, xml_children[[i]]) + } + return(meshes_doc) + } +} + diff --git a/R/generate_benchmark_script.R b/R/generate_benchmark_script.R index adbe432d8fea2c12880fbe4ed1d40ef5851f7186..e5538307297dfed92a57428252031ce1516c3baf 100644 --- a/R/generate_benchmark_script.R +++ b/R/generate_benchmark_script.R @@ -1,25 +1,22 @@ -#===== generate_all_benchmarks ===== +#===== ogs6_generate_benchmark_scripts ===== -#' generate_all_benchmark_scripts -#' @description Wrapper function to generate benchmark scripts from all -#' \code{.prj} files in a directory +#' Generate benchmark scripts +#' +#' This is a wrapper function for `ogs6_generate_benchmark_script()`. +#' #' @param path string: Path to a benchmark directory to generate scripts from -#' @param sim_path string: Path where all simulation files will be saved -#' @param scripts_path string: Path where benchmark scripts will be saved -#' @param read_in_gmls flag: Optional: Should \code{.gml} files just be copied -#' or read in too? -#' @param read_in_vtus flag: Optional: Should \code{.vtu} files just be copied -#' or read in too? -#' @param starting_from_prj_path string: Optional: -#' @param skip_prj_paths character: Optional: \code{.prj} paths to skip -generate_all_benchmark_scripts <- +#' @inheritParams ogs6_generate_benchmark_script +#' @param starting_from_prj_path string: Optional: `.prj` path to start from +#' @param skip_prj_paths character: Optional: `.prj` paths to skip +#' @export +ogs6_generate_benchmark_scripts <- function(path, sim_path, - scripts_path, - read_in_gmls, - read_in_vtus = FALSE, + script_path, + read_in_gml, + read_in_vtu = FALSE, starting_from_prj_path = "", skip_prj_paths = character()){ @@ -31,23 +28,32 @@ generate_all_benchmark_scripts <- sim_path <- unlist(options("r2ogs6.default_sim_path")) } - if(missing(scripts_path)){ - scripts_path <- unlist(options("r2ogs6.default_script_path")) + if(missing(script_path)){ + script_path <- unlist(options("r2ogs6.default_script_path")) } - missing_read_in_gmls <- missing(read_in_gmls) + if(missing(read_in_gml)){ + read_in_gml <- substitute() + } path <- as_dir_path(path) - scripts_path <- as_dir_path(scripts_path) + script_path <- as_dir_path(script_path) assertthat::assert_that(assertthat::is.string(starting_from_prj_path)) assertthat::assert_that(is.character(skip_prj_paths)) - assertthat::assert_that(assertthat::is.flag(read_in_vtus)) prj_paths <- list.files(path = path, pattern = "\\.prj$", recursive = TRUE, full.names = TRUE) + script_paths_rel <- lapply(list.files( + path = path, + pattern = "\\.prj$", + recursive = T, + full.names = F + ), + dirname) + # If we know the benchmarks up to a specific file are working, skip them if(starting_from_prj_path != ""){ @@ -75,26 +81,28 @@ generate_all_benchmark_scripts <- # cat("\nGenerating script from path", prj_paths[[i]]) # Put simulations in their own subfolders under sim_path - sim_subdir <- - paste0(sim_path, - basename(dirname(prj_paths[[i]])), "_", - tools::file_path_sans_ext(basename(prj_paths[[i]]))) + sim_subfolder_path <- paste0( + sim_path, + script_paths_rel[[i]], + "/", + tools::file_path_sans_ext(basename(prj_paths[[i]]))) + + script_subfolder_path <- paste0(script_path, script_paths_rel[[i]]) + + if(!dir.exists(script_subfolder_path)){ + dir.create(script_subfolder_path, + recursive = TRUE) + } out<- tryCatch( { - if(missing_read_in_gmls){ - ogs6_generate_benchmark_script(prj_path = prj_paths[[i]], - sim_path = sim_subdir, - script_path = scripts_path, - read_in_vtu = read_in_vtus) - }else{ - ogs6_generate_benchmark_script(prj_path = prj_paths[[i]], - sim_path = sim_subdir, - script_path = scripts_path, - read_in_gml = read_in_gmls, - read_in_vtu = read_in_vtus) - } - + ogs6_generate_benchmark_script( + prj_path = prj_paths[[i]], + sim_path = sim_subfolder_path, + script_path = script_subfolder_path, + read_in_gml = read_in_gml, + read_in_vtu = read_in_vtu + ) }, error = function(cond){ message(paste("\nogs6_generate_benchmark_script() failed for", @@ -113,16 +121,18 @@ generate_all_benchmark_scripts <- #===== ogs6_generate_benchmark_script ===== -#' ogs6_generate_benchmark_script -#' @description Generates a benchmark script from an existing \code{.prj} file. -#' @param prj_path string: \code{.prj} file the script will be based on +#' Generate benchmark script +#' +#' Generates an R script from an existing `.prj` benchmark file. +#' +#' @param prj_path string: `.prj` file the script will be based on #' @param sim_path string: Path where all simulation files will be saved #' @param ogs6_bin_path string: Path to OpenGeoSys executable. Defaults to #' options("r2ogs6.default_ogs6_bin_path"). #' @param script_path string: Path where benchmark script will be saved -#' @param read_in_gml flag: Optional: Should \code{.gml} file just be copied or +#' @param read_in_gml flag: Optional: Should `.gml` file just be copied or #' read in too? -#' @param read_in_vtu flag: Optional: Should \code{.vtu} file(s) just be copied +#' @param read_in_vtu flag: Optional: Should `.vtu` file(s) just be copied #' or read in too? #' @export ogs6_generate_benchmark_script <- function(prj_path, @@ -159,7 +169,7 @@ ogs6_generate_benchmark_script <- function(prj_path, read_in_vtu, read_in_gml = FALSE) - prj_components = prj_top_level_classes() + prj_components = ogs6_prj_top_level_classes() sim_name <- tools::file_path_sans_ext(basename(prj_path)) @@ -239,7 +249,7 @@ ogs6_generate_benchmark_script <- function(prj_path, dir.create(script_path, showWarnings = FALSE) } - filename <- paste0(script_path, sim_name, ".R") + filename <- paste0(script_path, "/", sim_name, ".R") if(file.exists(filename)){ filename <- paste0(script_path, @@ -263,15 +273,18 @@ ogs6_generate_benchmark_script <- function(prj_path, } -#' construct_add_call -#' @description Constructs a call based on an \code{OGS6} component. This is a -#' recursive function, handle with care. -#' @param object An object (numeric, character, list, NULL, \code{OGS6} or -#' \code{r2ogs6} class object) +#' Construct a call for `OGS6$add()` +#' +#' This is a recursive function. +#' +#' @param object An object (numeric, character, list, NULL, `OGS6` or +#' r2ogs6 class object) #' @param nested_call Optional: For recursion purposes, you should leave this as -#' it is. -#' @return A string representing the code with which the component would be -#' added to an \code{OGS6} object +#' it is. +#' @return +#' A string representing the code with which the component would be +#' added to an `OGS6` object +#' @noRd construct_add_call <- function(object, nested_call = FALSE) { #For values of type numeric or character, dput will give us usable output @@ -351,7 +364,7 @@ construct_add_call <- function(object, nested_call = FALSE) { regexp_2 <- "[\\w_]* = ((NULL)|(list\\(\\)))(,[:space:])" ret_str <- stringr::str_remove_all(ret_str, regexp_1) ret_str <- stringr::str_remove_all(ret_str, regexp_2) - ret_str <- delete_keywords_from_str(ret_str) + ret_str <- stringr::str_remove_all(ret_str, "repeat = ") ret_str <- stringr::str_replace_all(ret_str, " = [A-Za-z_]* = ", " = ") @@ -384,17 +397,3 @@ construct_add_call <- function(object, nested_call = FALSE) { return(invisible(ret_str)) } } - - -#' delete_keywords_from_str -#' @description Utility function to delete keywords from a string, -#' this is important because there is a <repeat> tag in <time_loop> and -#' "repeat" is a reserved word in R (extend this function if you find more -#' reserved words) -#' @param string string -delete_keywords_from_str <- function(string){ - - string <- stringr::str_remove_all(string, "repeat = ") - - return(invisible(string)) -} diff --git a/R/generate_class.R b/R/generate_class.R index 68a9d2769bc3b804a0d9af790ffb02cb4525ff12..0cf59a656de412cc757372019e4dfe4ac4277f5f 100644 --- a/R/generate_class.R +++ b/R/generate_class.R @@ -1,5 +1,4 @@ - #===== S3 class generation ===== #===== generate_constructor ===== @@ -13,6 +12,7 @@ #' the same tag name as an element for which a class was already specified, #' a prefix must be appended to the class name #' @param print_result flag: Should the result be printed to the console? +#' @noRd generate_constructor <- function(params, prefix = "", print_result = FALSE){ @@ -26,11 +26,16 @@ generate_constructor <- function(params, attr_flags <- params[[3]] param_flags <- params[[4]] + assertthat::assert_that(is.logical(param_flags)) class_name <- paste0("prj_", prefix, tag_name) param_str <- flags_to_con_str(param_flags) - assign_str <- flags_to_assign_str(param_flags) + + assign_str <- paste(names(param_flags), + names(param_flags), + sep = " = ", + collapse = ",\n") con_str <- paste0("new_", class_name, " <- function(", param_str, ") {\n") @@ -74,6 +79,7 @@ generate_constructor <- function(params, #' the same tag name as an element for which a class was already specified, #' a prefix must be appended to the class name #' @param print_result flag: Should the result be printed to the console? +#' @noRd generate_helper <- function(params, prefix = "", print_result = FALSE){ @@ -86,12 +92,12 @@ generate_helper <- function(params, tag_name <- get_tag_from_xpath(xpath) param_flags <- params[[4]] + assertthat::assert_that(is.logical(param_flags)) class_name <- paste0("prj_", prefix, tag_name) doc_str <- flags_to_doc_str(param_flags) con_str <- flags_to_con_str(param_flags) - con_call_str <- flags_to_con_call_str(param_flags) helper_str <- paste0("#'", class_name, "\n", "#'@description tag: ", tag_name, "\n", @@ -100,7 +106,9 @@ generate_helper <- function(params, "#'@export\n", class_name, " <- function(", con_str, ") {\n", "\n# Add coercing utility here\n\n", - "new_", class_name, "(", con_call_str, ")\n", + "new_", class_name, "(", + paste(names(param_flags), collapse = ",\n"), + ")\n", "}\n") if(print_result){ @@ -111,16 +119,14 @@ generate_helper <- function(params, } -#===== get parameter lists (for use in class constructor / helper) ===== +#===== flags_to_con_str ===== #' flags_to_con_str #' @description Helper function to generate a string out of a flag vector #' @param flags vector: Flags -#' @param print_result flag: Should the result be printed to the console? -flags_to_con_str <- function(flags, print_result = FALSE) { - - assertthat::assert_that(is.logical(flags)) +#' @noRd +flags_to_con_str <- function(flags) { flag_strs <- character() @@ -134,71 +140,7 @@ flags_to_con_str <- function(flags, print_result = FALSE) { flag_str <- paste(flag_strs, collapse = ",\n") - if(print_result){ - cat(flag_str, "\n") - } - - return(invisible(flag_str)) -} - - -#' flags_to_con_call_str -#' @description Helper function to generate a string out of a flag vector -#' @param flags vector: Flags -#' @param print_result flag: Should the result be printed to the console? -flags_to_con_call_str <- function(flags, print_result = FALSE) { - - assertthat::assert_that(is.logical(flags)) - - flag_str <- paste(names(flags), collapse = ",\n") - - if(print_result){ - cat(flag_str, "\n") - } - - return(invisible(flag_str)) -} - - -#' flags_to_name_str -#' @description Helper function to generate a name string out of a flag vector -#' @param flags vector: Flags -#' @param print_result flag: Should the result be printed to the console? -flags_to_name_str <- function(flags, print_result = FALSE) { - - assertthat::assert_that(is.logical(flags)) - - flag_str <- paste0("\"", paste(names(flags), collapse = "\",\n\""), "\"") - - if(print_result){ - cat(flag_str, "\n") - } - - return(invisible(flag_str)) -} - - -#===== get class parameter list (for use in class constructor) ===== - - -#' flags_to_assign_str -#' @description Helper function to generate a string out of a flag vector -#' @param flags vector: Flags -#' @param print_result flag: Should the result be printed to the console? -flags_to_assign_str <- function(flags, print_result = FALSE){ - - assertthat::assert_that(is.logical(flags)) - - flag_str <- paste(names(flags), - names(flags), - sep = " = ", - collapse = ",\n") - - if(print_result){ - cat(flag_str, "\n") - } - - return(invisible(flag_str)) + return(flag_str) } @@ -209,6 +151,7 @@ flags_to_assign_str <- function(flags, print_result = FALSE){ #' @description Helper function to generate a string out of a flag vector #' @param flags vector: Flags #' @param print_result flag: Should the result be printed to the console? +#' @noRd flags_to_doc_str <- function(flags, print_result = FALSE){ assertthat::assert_that(is.logical(flags)) @@ -250,6 +193,7 @@ flags_to_doc_str <- function(flags, print_result = FALSE){ #' the same tag name as an element for which a class was already specified, #' a prefix must be appended to the class name #' @param print_result flag: Should the result be printed to the console? +#' @noRd generate_R6 <- function(params, prefix = "", print_result = TRUE){ @@ -321,6 +265,7 @@ generate_R6 <- function(params, #' @description Helper function to generate a string out of a flag vector #' @param flags vector: Flags #' @param print_result flag: Should the result be printed to the console? +#' @noRd flags_to_r6_init_str <- function(flags, print_result = FALSE){ assertthat::assert_that(is.logical(flags)) @@ -352,6 +297,7 @@ flags_to_r6_init_str <- function(flags, print_result = FALSE){ #' @param flags vector: Flags #' @param mutable flag: On per default, turn off if parameters are static #' @param print_result flag: Should the result be printed to the console? +#' @noRd flags_to_r6_active_field_str <- function(flags, mutable = TRUE, print_result = FALSE){ @@ -402,6 +348,7 @@ flags_to_r6_active_field_str <- function(flags, #' @description Helper function to generate a string out of a flag vector #' @param flags vector: Flags #' @param print_result flag: Should the result be printed to the console? +#' @noRd flags_to_r6_private_str <- function(flags, print_result = FALSE){ assertthat::assert_that(is.logical(flags)) @@ -428,12 +375,14 @@ flags_to_r6_private_str <- function(flags, print_result = FALSE){ #' generate_add_method -#' @description Helper function to generate an R6 \code{add_*} method for a -#' r2ogs6 class object -#' @param tag_name The tag name of the XML element represented by the class +#' @description +#' Helper function to generate an R6 \code{add_*} method for a r2ogs6 class #' object -#' @param parent_tag_name The tag name of the parent of the XML element -#' represented by the class object +#' @param tag_name +#' The tag name of the XML element represented by the class object +#' @param parent_tag_name +#' The tag name of the parent of the XML element represented by the class object +#' @noRd generate_add_method <- function(tag_name, parent_tag_name) { has_wrapper <- (tag_name != parent_tag_name) @@ -462,9 +411,10 @@ generate_add_method <- function(tag_name, parent_tag_name) { #' generate_active_field -#' @description Helper function to generate an R6 active field for a OGS6 class -#' parameter +#' @description +#' Helper function to generate an R6 active field for a OGS6 class parameter #' @param parameter_name The name of the OGS6 class parameter +#' @noRd generate_active_field <- function(parameter_name){ af_str <- paste0(parameter_name, " = function(value) {\n", diff --git a/R/generate_xml.R b/R/generate_xml.R index 264f180feff7ad7626efce0f10cd7a3a31014242..2fa4f084a2c19c3bb1c38f50e0958cf0f41c8854 100644 --- a/R/generate_xml.R +++ b/R/generate_xml.R @@ -10,6 +10,7 @@ #' @param pattern string: See \code{?analyse_xml} #' @param xpath string: See \code{?analyse_xml} #' @param export_path string: Path to export the XML document to +#' @noRd build_redux_doc <- function(path, pattern, xpath, @@ -53,6 +54,7 @@ build_redux_doc <- function(path, #' @param pattern string: See \code{?analyse_xml} #' @param xpath string: See \code{?analyse_xml} #' @param required flag: Recursion utility +#' @noRd build_redux_tree <- function(path, pattern, xpath, diff --git a/R/ogs6.R b/R/ogs6.R index 9c0d9efd25f18e996462aed487de89a6aef5d3df..c053455f3be05662efc00e3d5c67f012161a0907 100644 --- a/R/ogs6.R +++ b/R/ogs6.R @@ -37,11 +37,11 @@ OGS6 <- R6::R6Class("OGS6", #' @param x An object of any .prj `prj` class #' @examples #' ogs6_obj <- OGS6$new(sim_name = "my_sim", sim_path = "my/path") - #' ogs6_obj$add(prj_parameter$new(name = "foo", type = "bar")) + #' ogs6_obj$add(prj_parameter(name = "foo", type = "bar")) add = function(x){ # Assert that class name is in implemented .prj classes for OGS6 - ogs6_prj_classes <- prj_top_level_classes() + ogs6_prj_classes <- ogs6_prj_top_level_classes() assertthat::assert_that(class(x) %in% ogs6_prj_classes) # Get name of corresponding OGS6 component @@ -98,6 +98,7 @@ OGS6 <- R6::R6Class("OGS6", #' Adds a reference to a \code{.vtu} file and optionally, a \code{OGS6_vtu} #' object #' @param path string: A path + #' @param axisym flag: Is the mesh axially symmetrical? #' @param read_in_vtu flag: Optional: Should \code{.vtu} file just be #' copied or read in too? #' @examples @@ -105,12 +106,16 @@ OGS6 <- R6::R6Class("OGS6", #' ogs6_obj$add_vtu("this_works.vtu") #' \dontrun{ogs6_obj$add_vtu("this_doesnt.oops")} add_vtu = function(path, + axisym = FALSE, read_in_vtu = FALSE){ assertthat::assert_that(assertthat::is.string(path)) assertthat::assert_that(grepl("\\.vtu$", path)) + assertthat::assert_that(assertthat::is.flag(axisym)) assertthat::assert_that(assertthat::is.flag(read_in_vtu)) - self$meshes <- c(self$meshes, mesh = path) + self$meshes <- c(self$meshes, + list(mesh = list(path = path, + axially_symmetric = axisym))) if(read_in_vtu){ private$.vtus <- c(private$.vtus, list(OGS6_vtu$new(path))) @@ -230,14 +235,14 @@ OGS6 <- R6::R6Class("OGS6", #' Clears components from the \code{OGS6} object #' @param which character: The names of the components (all by default). #' If you want to delete only some components, run - #' \code{names(prj_top_level_classes())} for the available options. + #' \code{names(ogs6_prj_top_level_classes())} for the available options. clear = function(which){ if(missing(which)){ - which <- names(prj_top_level_classes()) + which <- names(ogs6_prj_top_level_classes()) } - valid_input = names(prj_top_level_classes()) + valid_input = names(ogs6_prj_top_level_classes()) null_it <- c("geometry", "time_loop") @@ -328,12 +333,15 @@ OGS6 <- R6::R6Class("OGS6", }else{ assertthat::assert_that(is.list(value)) lapply(value, function(x){ - assertthat::assert_that(assertthat::is.string(x)) + assertthat::assert_that(is.list(x), length(x) == 2) + assertthat::assert_that(assertthat::is.string(x[[1]])) + assertthat::assert_that(assertthat::is.flag(x[[2]])) }) private$.meshes <- value } }, + #' @field vtus #' \code{.vtu}s. \code{value} must be list of \code{OGS6_vtu} objects vtus = function(value) { @@ -341,7 +349,7 @@ OGS6 <- R6::R6Class("OGS6", private$.vtus }else{ is_wrapper_list(value, - prj_top_level_classes()[["vtus"]]) + ogs6_prj_top_level_classes()[["vtus"]]) private$.vtus <- value } }, @@ -365,7 +373,7 @@ OGS6 <- R6::R6Class("OGS6", private$.search_length_algorithm }else{ assertthat::assert_that( - prj_top_level_classes()[["search_length_algorithm"]] %in% + ogs6_prj_top_level_classes()[["search_length_algorithm"]] %in% class(value)) private$.search_length_algorithm <- value } @@ -380,10 +388,10 @@ OGS6 <- R6::R6Class("OGS6", }else{ # If there already is a process element if(length(private$.processes) > 0){ - if(prj_top_level_classes()[["processes"]] %in% + if(ogs6_prj_top_level_classes()[["processes"]] %in% class(private$.processes[[1]])){ is_wrapper_list(value, - prj_top_level_classes()[["processes"]]) + ogs6_prj_top_level_classes()[["processes"]]) }else{ assertthat::assert_that(assertthat::is.string(value)) value <- list(include = c(file = value)) @@ -394,7 +402,7 @@ OGS6 <- R6::R6Class("OGS6", value <- list(include = c(file = value)) }else{ is_wrapper_list(value, - prj_top_level_classes()[["processes"]]) + ogs6_prj_top_level_classes()[["processes"]]) } } @@ -410,7 +418,7 @@ OGS6 <- R6::R6Class("OGS6", private$.time_loop }else{ assertthat::assert_that( - prj_top_level_classes()[["time_loop"]] %in% + ogs6_prj_top_level_classes()[["time_loop"]] %in% class(value)) private$.time_loop <- value } @@ -424,7 +432,7 @@ OGS6 <- R6::R6Class("OGS6", private$.local_coordinate_system }else{ assertthat::assert_that( - prj_top_level_classes()[["local_coordinate_system"]] %in% + ogs6_prj_top_level_classes()[["local_coordinate_system"]] %in% class(value)) private$.local_coordinate_system <- value } @@ -438,7 +446,7 @@ OGS6 <- R6::R6Class("OGS6", private$.media }else{ is_wrapper_list(value, - prj_top_level_classes()[["media"]]) + ogs6_prj_top_level_classes()[["media"]]) private$.media <- value } }, @@ -451,7 +459,7 @@ OGS6 <- R6::R6Class("OGS6", private$.parameters }else{ is_wrapper_list(value, - prj_top_level_classes()[["parameters"]]) + ogs6_prj_top_level_classes()[["parameters"]]) private$.parameters <- value } }, @@ -464,7 +472,7 @@ OGS6 <- R6::R6Class("OGS6", private$.chemical_system }else{ assertthat::assert_that( - prj_top_level_classes()[["chemical_system"]] %in% + ogs6_prj_top_level_classes()[["chemical_system"]] %in% class(value)) private$.chemical_system <- value } @@ -478,7 +486,7 @@ OGS6 <- R6::R6Class("OGS6", private$.curves }else{ is_wrapper_list(value, - prj_top_level_classes()[["curves"]]) + ogs6_prj_top_level_classes()[["curves"]]) private$.curves <- value } }, @@ -492,7 +500,7 @@ OGS6 <- R6::R6Class("OGS6", }else{ is_wrapper_list( value, - prj_top_level_classes()[["process_variables"]]) + ogs6_prj_top_level_classes()[["process_variables"]]) private$.process_variables <- value } }, @@ -506,7 +514,7 @@ OGS6 <- R6::R6Class("OGS6", }else{ is_wrapper_list( value, - prj_top_level_classes()[["nonlinear_solvers"]]) + ogs6_prj_top_level_classes()[["nonlinear_solvers"]]) private$.nonlinear_solvers <- value } }, @@ -519,7 +527,7 @@ OGS6 <- R6::R6Class("OGS6", private$.linear_solvers }else{ is_wrapper_list(value, - prj_top_level_classes()[["linear_solvers"]]) + ogs6_prj_top_level_classes()[["linear_solvers"]]) private$.linear_solvers <- value } }, @@ -532,7 +540,7 @@ OGS6 <- R6::R6Class("OGS6", private$.test_definition }else{ is_wrapper_list(value, - prj_top_level_classes()[["test_definition"]]) + ogs6_prj_top_level_classes()[["test_definition"]]) private$.test_definition <- value } }, @@ -545,7 +553,7 @@ OGS6 <- R6::R6Class("OGS6", private$.insitu }else{ assertthat::assert_that( - prj_top_level_classes()[["insitu"]] %in% + ogs6_prj_top_level_classes()[["insitu"]] %in% class(value)) private$.insitu <- value } @@ -605,3 +613,47 @@ OGS6 <- R6::R6Class("OGS6", .pvds = NULL ) ) + + +#===== ogs6_prj_top_level_classes ===== + + +#' ogs6_prj_top_level_classes +#' @description Returns named character vector of \code{OGS6} top level +#' \code{.prj} tags (names) represented by \code{r2ogs6} classes along with +#' their class names (values). +#' @return character +#' @export +ogs6_prj_top_level_classes <- function(){ + + xpaths_for_classes <- xpaths_for_classes + + flattened_xpaths <- unlist(xpaths_for_classes) + names(flattened_xpaths) <- NULL + + prj_components <- character() + seen <- character() + + for(i in seq_len(length(flattened_xpaths))){ + + split_xpath <- + unlist(strsplit(flattened_xpaths[[i]], "/", fixed = TRUE)) + + if(!split_xpath[[1]] %in% seen){ + if(!is.null(get_class_from_xpath(split_xpath[[1]]))){ + prj_components <- c(prj_components, + get_class_from_xpath(split_xpath[[1]])) + + }else{ + xpath <- paste(split_xpath[[1]], split_xpath[[2]], sep = "/") + prj_components <- c(prj_components, + get_class_from_xpath(xpath)) + } + + names(prj_components)[[length(prj_components)]] <- split_xpath[[1]] + seen <- c(seen, split_xpath[[1]]) + } + } + + return(prj_components) +} diff --git a/R/ogs6_ensemble.R b/R/ogs6_ensemble.R index 5bb6b2b32618b3a0eb65ef0bdb15636ce2494efb..ce51aad54355f68e470da513d008d59b53c29a94 100644 --- a/R/ogs6_ensemble.R +++ b/R/ogs6_ensemble.R @@ -34,13 +34,16 @@ OGS6_Ensemble <- R6::R6Class( dp_str <- stringr::str_remove_all( dp_str, - "(^list\\()|(\\)$)|[:space:]|([A-Za-z_]*\\s*=\\s*)") + "(^list\\()|(\\)$)|[:space:]|([A-Za-z_0-9]*\\s*=\\s*)") dp_strs <- unlist(strsplit(dp_str, "list\\(")) dp_strs <- dp_strs[dp_strs != ""] private$.dp_parameters <- lapply(dp_strs, function(x){ - unlist(strsplit(x, ","))[[1]] + dp_p <- unlist(strsplit(x, ","))[[1]] + dp_p <- gsub("^[A-Za-z_0-9]*\\$", "ogs6_obj$", dp_p) + #cat("after:", dp_p, "\n") + return(dp_p) }) assertthat::assert_that(is.list(parameters)) @@ -217,7 +220,7 @@ OGS6_Ensemble <- R6::R6Class( sim_tbls <- c(sim_tbls, list(sim_tbl)) } - return(bind_rows(sim_tbls)) + return(dplyr::bind_rows(sim_tbls)) } ), @@ -307,8 +310,7 @@ OGS6_Ensemble <- R6::R6Class( sequential_mode, percentages_mode) { - orig_sim_name <- ogs6_obj$sim_name - orig_sim_path <- ogs6_obj$sim_path + orig_ogs6 <- ogs6_obj$clone(deep = T) parameter_values <- self$parameter_values @@ -326,20 +328,23 @@ OGS6_Ensemble <- R6::R6Class( for(j in seq_len(length(parameter_values[[i]]))){ - # Modify parameter reference of original object + # Clone object + ogs6_obj <- private$copy_and_modify( + orig_ogs6, + orig_ogs6$sim_name, + sim_id, + orig_ogs6$sim_path) + + # Modify parameter set_param_call <- paste0(self$dp_parameters[[i]], " <- parameter_values[[i]][[j]]") eval(parse(text = set_param_call)) - # Clone object - new_ogs6_obj <- private$copy_and_modify(ogs6_obj, - orig_sim_name, - sim_id, - orig_sim_path) + private$.ensemble <- - c(private$.ensemble, list(new_ogs6_obj)) + c(private$.ensemble, list(ogs6_obj)) sim_id <- sim_id + 1 } @@ -357,7 +362,13 @@ OGS6_Ensemble <- R6::R6Class( # n iterations in first loop == n objects to create for (i in seq_len(length(parameter_values[[1]]))) { - # Modify parameter reference of original object + # Clone object + ogs6_obj <- private$copy_and_modify(orig_ogs6, + orig_ogs6$sim_name, + (i + 1), + orig_ogs6$sim_path) + + # Modify parameter for (j in seq_len(length(self$dp_parameters))) { set_param_call <- paste0(self$dp_parameters[[j]], @@ -365,15 +376,9 @@ OGS6_Ensemble <- R6::R6Class( eval(parse(text = set_param_call)) } - # Clone object - new_ogs6_obj <- private$copy_and_modify(ogs6_obj, - orig_sim_name, - i, - orig_sim_path) - # Add clone to list of simulation objects private$.ensemble <- c(private$.ensemble, - list(new_ogs6_obj)) + list(ogs6_obj)) } } }, diff --git a/R/ogs6_gml.R b/R/ogs6_gml.R index 1dd40a99dd11150e24945914286266f713c4cd5f..48ffb801170437a1ce91b989a753368ffb3b9a9a 100644 --- a/R/ogs6_gml.R +++ b/R/ogs6_gml.R @@ -146,12 +146,6 @@ OGS6_gml <- R6::R6Class( } }, - #'@field is_subclass - #'Getter for private parameter '.is_subclass' - is_subclass = function(value) { - private$.is_subclass - }, - #'@field attr_names #'Getter for private parameter '.attr_names' attr_names = function(value) { @@ -197,7 +191,6 @@ OGS6_gml <- R6::R6Class( .points = NULL, .polylines = NULL, .surfaces = NULL, - .is_subclass = TRUE, .attr_names = c("point", "name", "id", "element"), .flatten_on_exp = character() ) @@ -207,12 +200,14 @@ OGS6_gml <- R6::R6Class( #===== Validation utility ===== -#'validate_points -#'@description Checks if the input is a tibble, if this tibble has the right -#' number of elements, if those elements are named correctly and if there are +#' validate_points +#' @description +#' Checks if the input is a tibble, if this tibble has the right number of +#' elements, if those elements are named correctly and if there are #' any overlapping points or duplicate point names -#'@param points tibble: Must have 3 vectors named 'x', 'y' and 'z', may have -#' optional 'name' vector +#' @param points tibble: Must have 3 vectors named 'x', 'y' and 'z', may have +#' optional 'name' vector +#' @noRd validate_points <- function(points) { assertthat::assert_that(inherits(points, "tbl_df")) @@ -256,11 +251,13 @@ validate_points <- function(points) { } -#'validate_polylines -#'@description Checks if the input is a list, if this list consists of other +#' validate_polylines +#' @description +#' Checks if the input is a list, if this list consists of other #' lists and if those lists have the correct structure (length of 2, first #' element is a string named 'name', second element is a numeric vector) -#'@param polylines list(list("foo", c(1, 2))): +#' @param polylines list(list("foo", c(1, 2))): +#' @noRd validate_polylines <- function(polylines) { assertthat::assert_that(is.list(polylines)) @@ -280,12 +277,14 @@ validate_polylines <- function(polylines) { } -#'validate_surfaces -#'@description Checks if the input is a list, if this list consists of other +#' validate_surfaces +#' @description +#' Checks if the input is a list, if this list consists of other #' lists and if those lists have the correct structure (length of 2 or 3, first #' element is a string named 'name', second and third element are numeric #' vectors) -#'@param surfaces list(list("foo", c(1, 2, 3), c(2, 3, 4))): +#' @param surfaces list(list("foo", c(1, 2, 3), c(2, 3, 4))): +#' @noRd validate_surfaces <- function(surfaces) { assertthat::assert_that(is.list(surfaces)) @@ -320,13 +319,15 @@ validate_surfaces <- function(surfaces) { } -#'validate_pnt_values -#'@description Checks if two numerical vectors of length 3 +#' validate_pnt_values +#' @description +#' Checks if two numerical vectors of length 3 #' (two surface elements) each consist of 3 different elements and have #' exactly 2 matching elements between them. Think of the two vectors as #' triangles, and the triangles together form a square which is our surface. -#'@param element_1 numeric, length = 3 -#'@param element_2 numeric, length = 3 +#' @param element_1 numeric, length = 3 +#' @param element_2 numeric, length = 3 +#' @noRd validate_pnt_values = function (element_1, element_2) { if(element_1[[1]] == element_1[[2]] || diff --git a/R/prj_medium.R b/R/prj_medium.R index d7edbacebea1b2326b2cea1acfd616023b5381a3..8f8308a9e73667275166fb05bd72104e8dd8f02d 100644 --- a/R/prj_medium.R +++ b/R/prj_medium.R @@ -306,7 +306,7 @@ ogs6_get_medium_property <- function(medium, name){ assertthat::assert_that(assertthat::is.string(name)) properties_names <- lapply(medium$properties, `[[`, "name") - property <- properties[properties_names == name][[1]] + property <- medium$properties[properties_names == name][[1]] return(invisible(property)) } diff --git a/R/prj_vtkdiff.R b/R/prj_vtkdiff.R index 79c3b0d620291846e79643b51962258d57860e3d..e3986ea4c3bb6ecdba4ef7b220a0e3d846d76258 100644 --- a/R/prj_vtkdiff.R +++ b/R/prj_vtkdiff.R @@ -13,28 +13,28 @@ #' @example man/examples/ex_prj_vtkdiff.R #' @export prj_vtkdiff <- function(field, - absolute_tolerance, - relative_tolerance, - file = NULL, - regex = NULL) { + absolute_tolerance, + relative_tolerance, + file = NULL, + regex = NULL) { #Coerce input absolute_tolerance <- coerce_string_to_numeric(absolute_tolerance) relative_tolerance <- coerce_string_to_numeric(relative_tolerance) new_prj_vtkdiff(field, - absolute_tolerance, - relative_tolerance, - file, - regex) + absolute_tolerance, + relative_tolerance, + file, + regex) } new_prj_vtkdiff <- function(field, - absolute_tolerance, - relative_tolerance, - file = NULL, - regex = NULL) { + absolute_tolerance, + relative_tolerance, + file = NULL, + regex = NULL) { assertthat::assert_that(assertthat::is.string(field)) diff --git a/R/read_in_gml.R b/R/read_in_gml.R index f96eb2c4d59084c043a5b363744ffb9458f7ed07..ad04c8fc91c205bd9c0047f896f1d56f7b40bb7f 100644 --- a/R/read_in_gml.R +++ b/R/read_in_gml.R @@ -5,6 +5,7 @@ #' read_in_points #' @description Reads points from a \code{.gml} file #' @param xml_doc A parsed XML document (of class \code{xml2::xml_document}) +#' @noRd read_in_points <- function(xml_doc) { points_tibble <- tibble::tibble(x = c(), @@ -40,6 +41,7 @@ read_in_points <- function(xml_doc) { #' read_in_polylines #' @description Reads polylines from a \code{.gml} file #' @param xml_doc A parsed XML document (of class \code{xml2::xml_document}) +#' @noRd read_in_polylines <- function(xml_doc) { polylines_list <- list() @@ -74,6 +76,7 @@ read_in_polylines <- function(xml_doc) { #' read_in_surfaces #' @description Reads surfaces from a \code{.gml} file #' @param xml_doc A parsed XML document (of class \code{xml2::xml_document}) +#' @noRd read_in_surfaces <- function(xml_doc) { surfaces_list <- list() diff --git a/R/read_in_prj.R b/R/read_in_prj.R index 4fbaaf02cdfe90fbd9e6de5c86fdd24ec98ba64b..ed6b67af032a8776c319e75ed5ae951a6991c2f8 100644 --- a/R/read_in_prj.R +++ b/R/read_in_prj.R @@ -58,12 +58,21 @@ read_in_prj <- function(ogs6_obj, vtu_ref <- xml2::xml_text(vtu_ref_nodes[[i]]) vtu_path <- paste0(dirname(prj_path), "/", vtu_ref) + axisym_val <- xml2::xml_attr(vtu_ref_nodes[[i]], "axially_symmetric") + + if(!is.na(axisym_val) && axisym_val == "true"){ + axisym_val <- TRUE + }else{ + axisym_val <- FALSE + } + # Read in .vtu file(s) or just save their path ogs6_obj$add_vtu(path = vtu_path, + axisym = axisym_val, read_in_vtu = read_in_vtu) } - prj_components <- prj_top_level_classes() + prj_components <- ogs6_prj_top_level_classes() # Include file reference processes_include_node <- diff --git a/R/read_in_utils.R b/R/read_in_utils.R index 7263d8b75ecb7badff0d4813cc3534c71ce26b8d..11add850e852058ed7335a3ac1f2219b6a998792 100644 --- a/R/read_in_utils.R +++ b/R/read_in_utils.R @@ -8,6 +8,7 @@ #' @param path string: A file to be parsed as XML #' @return The parsed XML file (as class object of type #' \code{xml2::xml_document}) +#' @noRd validate_read_in_xml <- function(path){ assertthat::assert_that(assertthat::is.string(path)) @@ -34,6 +35,7 @@ validate_read_in_xml <- function(path){ #' @param ogs6_obj A OGS6 class object #' @param path string: Path to file XML elements should be read from #' @param xpath string: An XPath expression (should be absolute!) +#' @noRd read_in <- function(ogs6_obj, path, xpath){ @@ -75,6 +77,7 @@ read_in <- function(ogs6_obj, #' @description Takes an XML node and turns it into a class object #' @param xml_node xml2::xml_node: XML node #' @param xpath string: XPath expression (for subclass differentiation) +#' @noRd node_to_prj_class_object <- function(xml_node, xpath){ @@ -158,6 +161,7 @@ node_to_prj_class_object <- function(xml_node, #' 3) Parent nodes whose children have no children are represented as lists #' @param xml_node xml2::xml_node: XML node #' @param xpath string: XPath expression (for subclass differentiation) +#' @noRd node_to_object <- function(xml_node, xpath = ""){ @@ -225,6 +229,7 @@ node_to_object <- function(xml_node, #' @description Gets class arguments #' @param class_name string: The name of a class #' @return character: Named vector of class arguments +#' @noRd get_class_args <- function(class_name){ assertthat::assert_that(assertthat::is.string(class_name)) @@ -246,6 +251,7 @@ get_class_args <- function(class_name){ #' @param parameters list: Parameters #' @param class_name string: The name of a class #' @return list: Parameters ordered by argument order of class +#' @noRd order_parameters <- function(parameters, class_name){ assertthat::assert_that(is.list(parameters)) diff --git a/R/sim_utils.R b/R/sim_utils.R index d559ddf8307ebca1d06a8c28a3d0a817ca4af085..6e7e56a170368fbff610da3f09812ac6e2cf15b0 100644 --- a/R/sim_utils.R +++ b/R/sim_utils.R @@ -32,7 +32,7 @@ ogs6_run_simulation <- function(ogs6_obj, ogs6_read_output_files(ogs6_obj = ogs6_obj) - return(invisible(exit_code)) + return(exit_code) } @@ -96,7 +96,7 @@ ogs6_export_sim_files <- function(ogs6_obj, # Copy all referenced .vtu files to ogs6_obj$sim_path lapply(ogs6_obj$meshes, function(x){ - file.copy(x, ogs6_obj$sim_path) + file.copy(x[["path"]], ogs6_obj$sim_path) }) if(!is.null(ogs6_obj$python_script)){ @@ -187,7 +187,7 @@ ogs6_call_ogs6 <- function(ogs6_obj, args = ogs6_args) } - return(invisible(exit_code)) + return(exit_code) } @@ -256,11 +256,14 @@ ogs6_read_output_files <- function(ogs6_obj){ #===== Test benchmarks ===== -#' run_benchmark -#' @description Utility function for quick benchmark runs +#' Run benchmark +#' +#' Utility function for quick benchmark runs +#' #' @param prj_path string: #' @param ogs6_bin_path string: #' @param sim_path string: Path where simulation files will be saved +#' @noRd run_benchmark <- function(prj_path, ogs6_bin_path, sim_path){ @@ -280,7 +283,6 @@ run_benchmark <- function(prj_path, sim_name <- tools::file_path_sans_ext(basename(prj_path)) ogs6_obj <- OGS6$new(sim_name = sim_name, - sim_id = 1, sim_path = sim_path) read_in_prj(ogs6_obj = ogs6_obj, @@ -291,16 +293,18 @@ run_benchmark <- function(prj_path, } -#' run_all_benchmarks -#' @description Utility function, for quick benchmark runs. Calls -#' run_benchmark internally. +#' Run benchmarks +#' +#' This is a wrapper function for `run_benchmark()`. +#' #' @param path string: Path to benchmark folder #' @param ogs6_processlib_path string: Path to OpenGeoSys 6 ProcessLib folder #' which contains relevant Tests.cmake files #' @param ogs6_bin_path string: #' @param sim_path string: Path where simulation files will be saved -#' @param starting_from_prj_path string: \code{.prj} path to start from +#' @param starting_from_prj_path string: `.prj` path to start from #' @param print_results flag: Print results in the end? +#' @noRd run_all_benchmarks <- function(path, ogs6_processlib_path, ogs6_bin_path, @@ -449,10 +453,13 @@ print_run_all_benchmarks <- function(nonexisting_prj_paths, } -#' get_benchmark_paths -#' @description Gets paths to all benchmarks that should work +#' Get benchmark paths +#' +#' Gets paths to all benchmarks that should work from `Tests.cmake` files +#' #' @param ogs6_processlib_path string: Path to OpenGeoSys 6 ProcessLib folder -#' which contains relevant Tests.cmake files +#' which contains relevant `Tests.cmake` files +#' @noRd get_benchmark_paths <- function(ogs6_processlib_path){ tests_cmake_files <- list.files(path = ogs6_processlib_path, diff --git a/R/utils.R b/R/utils.R index 0b291685b0015ebfe7febac95c22055f43197b86..99ec0330358fbdf569585988ce818d5e04456750 100644 --- a/R/utils.R +++ b/R/utils.R @@ -6,8 +6,7 @@ #' @description Gets r2ogs6 class name from an xpath-like expression #' @param xpath string: An xpath expression. Works for path-like xpaths only #' @return string: The class name. -#' @examples -#' get_class_from_xpath("processes/process") +#' @noRd get_class_from_xpath <- function(xpath){ assertthat::assert_that(assertthat::is.string(xpath)) @@ -31,8 +30,7 @@ get_class_from_xpath <- function(xpath){ #' @description Utility function, returns the tag name of a r2ogs6 class #' @param class_name string: The name of a r2ogs6 class #' @return string: The tag name corresponding to \code{class_name} -#' @examples -#' get_tag_from_class("prj_process") +#' @noRd get_tag_from_class <- function(class_name) { assertthat::assert_that(assertthat::is.string(class_name)) @@ -51,8 +49,7 @@ get_tag_from_class <- function(class_name) { #' @description Gets the XML tag name from an xpath expression #' @param xpath string: An xpath expression. Works for path-like xpaths only #' @return string: The XML tag name -#' @examples -#' get_tag_from_xpath("processes/process") +#' @noRd get_tag_from_xpath <- function(xpath){ xpath_split <- unlist(strsplit(xpath, "/", fixed = TRUE)) @@ -65,6 +62,7 @@ get_tag_from_xpath <- function(xpath){ #' get_prj_top_level_tags #' @description Gets top level .prj tags along with info if they are required. #' @return list: List of lists. +#' @noRd get_prj_top_level_tags <- function(){ prj_reduxml <- system.file("extdata/xml_redux/", "prj_redu.xml", @@ -81,46 +79,6 @@ get_prj_top_level_tags <- function(){ } -#' prj_top_level_classes -#' @description Returns named character vector of \code{OGS6} top level -#' \code{.prj} tags (names) represented by \code{r2ogs6} classes along with their -#' class names (values). -#' @return character -prj_top_level_classes <- function(){ - - xpaths_for_classes <- xpaths_for_classes - - flattened_xpaths <- unlist(xpaths_for_classes) - names(flattened_xpaths) <- NULL - - prj_components <- character() - seen <- character() - - for(i in seq_len(length(flattened_xpaths))){ - - split_xpath <- - unlist(strsplit(flattened_xpaths[[i]], "/", fixed = TRUE)) - - if(!split_xpath[[1]] %in% seen){ - if(!is.null(get_class_from_xpath(split_xpath[[1]]))){ - prj_components <- c(prj_components, - get_class_from_xpath(split_xpath[[1]])) - - }else{ - xpath <- paste(split_xpath[[1]], split_xpath[[2]], sep = "/") - prj_components <- c(prj_components, - get_class_from_xpath(xpath)) - } - - names(prj_components)[[length(prj_components)]] <- split_xpath[[1]] - seen <- c(seen, split_xpath[[1]]) - } - } - - return(prj_components) -} - - #===== Coercion utility ===== @@ -128,8 +86,7 @@ prj_top_level_classes <- function(){ #' @description If an object is of type string, coerces it to a numeric type #' @param obj object: Any object #' @return numeric if \code{obj} was a string, else unchanged \code{obj} -#' @examples -#' coerce_string_to_numeric("12 54 2 \n 2") +#' @noRd coerce_string_to_numeric <- function(obj){ if(assertthat::is.string(obj)){ @@ -147,6 +104,7 @@ coerce_string_to_numeric <- function(obj){ #' @param names character: How the vector elements will be named as #' per default #' @return vector: Named vector where the names correspond to \code{names} +#' @noRd coerce_names <- function(vector, names) { assertthat::assert_that(is.vector(vector)) @@ -178,6 +136,7 @@ coerce_names <- function(vector, names) { #' @description Validator function for a parameter list or vector or \code{NULL} #' @param obj A list (or vector) of parameters #' @param names How the list elements will be named as per default +#' @noRd is_null_or_coerce_names <- function(obj, names){ if(!is.null(obj)){ @@ -192,6 +151,7 @@ is_null_or_coerce_names <- function(obj, names){ #' @description Cleans an imported list because sometimes strings containing #' only newline characters and spaces get imported in #' @param list list: A list +#' @noRd clean_imported_list <- function(list){ assertthat::assert_that(is.list(list)) @@ -214,6 +174,7 @@ clean_imported_list <- function(list){ #' as_dir_path #' @description Checks if a given path ends on \code{/} #' @param path string: A path +#' @noRd as_dir_path <- function(path){ assertthat::assert_that(assertthat::is.string(path)) @@ -237,6 +198,7 @@ as_dir_path <- function(path){ #' @param print_messages flag: Optional: Print error messages? Defaults to #' \code{TRUE} #' @return character: Vector of invalid XML paths +#' @noRd filter_invalid_xml <- function(paths, encoding = "ISO-8859-1", print_messages = TRUE){ @@ -270,6 +232,7 @@ filter_invalid_xml <- function(paths, #' are_numbers #' @description Checks if objects are numbers #' @param ... Ellipsis +#' @noRd are_numbers <- function(...){ lapply(list(...), function(x){ @@ -283,6 +246,7 @@ are_numbers <- function(...){ #' are_null_or_numbers #' @description Checks if objects are either \code{NULL} or numbers #' @param ... Ellipsis +#' @noRd are_null_or_numbers <- function(...){ lapply(list(...), function(x){ @@ -298,6 +262,7 @@ are_null_or_numbers <- function(...){ #' are_numeric #' @description Checks if objects are numeric #' @param ... Ellipsis +#' @noRd are_numeric <- function(...){ lapply(list(...), function(x){ @@ -311,6 +276,7 @@ are_numeric <- function(...){ #' are_null_or_numeric #' @description Checks if objects are either \code{NULL} or numeric #' @param ... Ellipsis +#' @noRd are_null_or_numeric <- function(...){ lapply(list(...), function(x){ @@ -326,6 +292,7 @@ are_null_or_numeric <- function(...){ #' are_strings #' @description Checks if objects are strings #' @param ... Ellipsis +#' @noRd are_strings <- function(...){ lapply(list(...), function(x){ @@ -339,6 +306,7 @@ are_strings <- function(...){ #' are_null_or_strings #' @description Checks if objects are either \code{NULL} or strings #' @param ... Ellipsis +#' @noRd are_null_or_strings <- function(...){ lapply(list(...), function(x){ @@ -354,6 +322,7 @@ are_null_or_strings <- function(...){ #' are_string_flags #' @description Checks if objects are strings reading either "true" or "false" #' @param ... Ellipsis +#' @noRd are_string_flags <- function(...){ lapply(list(...), function(x){ @@ -369,6 +338,7 @@ are_string_flags <- function(...){ #' @description Checks if objects are either \code{NULL} or strings reading #' either "true" or "false" #' @param ... Ellipsis +#' @noRd are_null_or_string_flags <- function(...){ lapply(list(...), function(x){ @@ -386,6 +356,7 @@ are_null_or_string_flags <- function(...){ #' \code{element_class} #' @param list list: List to check #' @param element_class string: Class each element of \code{list} should have +#' @noRd is_wrapper_list <- function(list, element_class) { assertthat::assert_that(is.list(list)) @@ -403,6 +374,7 @@ is_wrapper_list <- function(list, element_class) { #' of class \code{element_class} #' @param obj list | NULL: Object to check #' @param element_class string: Class each element of \code{obj} should have +#' @noRd is_null_or_wrapper_list <- function(obj, element_class) { if(!is.null(obj)){ @@ -422,6 +394,7 @@ is_null_or_wrapper_list <- function(obj, element_class) { #' class \code{class_name} #' @param obj The object to check #' @param class_name The name of the expected class +#' @noRd is_null_or_has_class <- function(obj, class_name){ if(!is.null(obj)){ diff --git a/R/zzz.R b/R/zzz.R index 3db11061130c50af8a88e7cb11b3b1a0313356b0..240be700d88b023dca18971f6a63065bb5529d9b 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -9,56 +9,29 @@ vtk <- NULL op <- options() op.r2ogs6 <- list( # Default paths - r2ogs6.default_sim_path = "", - r2ogs6.default_script_path = "", - r2ogs6.default_benchmark_path = "", - r2ogs6.default_ogs6_processlib_path = "", - r2ogs6.default_ogs6_utils_path = "", - r2ogs6.default_ogs6_bin_path = "", - r2ogs6.max_lines_gml = 300, - - # External file reference tags - - # Reticulate setting for reading in VTK - r2ogs6.use_python = "" + r2ogs6.default_sim_path = NULL, + r2ogs6.default_script_path = NULL, + r2ogs6.default_benchmark_path = NULL, + r2ogs6.default_ogs6_processlib_path = NULL, + r2ogs6.default_ogs6_bin_path = NULL, + r2ogs6.max_lines_gml = 300 ) toset <- !(names(op.r2ogs6) %in% names(op)) if (any(toset)) options(op.r2ogs6[toset]) - # use superassignments to update global Python references - vtk <<- reticulate::import("vtk", delay_load = TRUE) - - test_config <- TRUE + if(file.exists("config.yml")){ + cfg <- config::get() - if (test_config) { - options( - r2ogs6.default_sim_path = "D:/OGS_sims/", - r2ogs6.default_script_path = "D:/OGS_scripts/", - r2ogs6.default_benchmark_path = - "D:/Programme/OpenGeoSys/ogs-master/Tests/Data/", - r2ogs6.default_ogs6_processlib_path = - "D:/Programme/OpenGeoSys/ogs-master/ProcessLib/", - r2ogs6.default_ogs6_utils_path = - paste0( - "D:/Programme/OpenGeoSys/", - "ogs-6.3.2-Windows-10.0.14393-x64-python-3.7.2-de-utils", - "/bin/" - ), - r2ogs6.default_ogs6_bin_path = - paste0( - "D:/Programme/OpenGeoSys/", - "ogs-6.3.2-Windows-10.0.14393-x64-python-3.7.2-de-utils", - "/bin/ogs.exe" - ), - r2ogs6.max_lines_gml = 300, - r2ogs6.use_python = "D:/Programme/anaconda3/envs/rtest/python.exe" - ) - - reticulate::use_virtualenv(unlist(options("r2ogs6.use_python"))) + for(i in names(op.r2ogs6)){ + eval(parse(text = paste0("options(", i, " = cfg$", i, ")"))) + } } - invisible() + # use superassignments to update global Python references + vtk <<- reticulate::import("vtk", delay_load = TRUE) + + return(invisible()) } @@ -67,7 +40,7 @@ vtk <- NULL packageStartupMessage( paste("r2ogs6 works best with its options set :)\nFor", "an overview, use the command", - "'options()[grepl(\"r2ogs6.\",", - "names(options()), fixed = TRUE)]'\nTo set an option, use the", + "'options()[grepl(\"^r2ogs6\",", + "names(options()))]'\nTo set an option, use the", "command 'options(\"<option_name>\" = <option_value>)'\n")) } diff --git a/data/xpaths_for_classes.rda b/data/xpaths_for_classes.rda index 03d04f8f8f88fa252cdf6898aead797c96224390..2abd4f9f3ce8a1bd79cce42b6854a6bf9df5390b 100644 Binary files a/data/xpaths_for_classes.rda and b/data/xpaths_for_classes.rda differ diff --git a/man/OGS6.Rd b/man/OGS6.Rd index 02a07ae3388d40a4912cadccfbdc49ec5fd4abe6..8ef7607947e580f0909f57859b65a8a057b386ae 100644 --- a/man/OGS6.Rd +++ b/man/OGS6.Rd @@ -19,7 +19,7 @@ ogs6_obj <- OGS6$new(sim_name = "my_sim", sim_path = "my/path") ## ------------------------------------------------ ogs6_obj <- OGS6$new(sim_name = "my_sim", sim_path = "my/path") -ogs6_obj$add(prj_parameter$new(name = "foo", type = "bar")) +ogs6_obj$add(prj_parameter(name = "foo", type = "bar")) ## ------------------------------------------------ ## Method `OGS6$add_gml` @@ -167,7 +167,7 @@ Adds a .prj simulation component \subsection{Examples}{ \if{html}{\out{<div class="r example copy">}} \preformatted{ogs6_obj <- OGS6$new(sim_name = "my_sim", sim_path = "my/path") -ogs6_obj$add(prj_parameter$new(name = "foo", type = "bar")) +ogs6_obj$add(prj_parameter(name = "foo", type = "bar")) } \if{html}{\out{</div>}} @@ -210,7 +210,7 @@ ogs6_obj$add_gml("this_works.gml") Adds a reference to a \code{.vtu} file and optionally, a \code{OGS6_vtu} object \subsection{Usage}{ -\if{html}{\out{<div class="r">}}\preformatted{OGS6$add_vtu(path, read_in_vtu = FALSE)}\if{html}{\out{</div>}} +\if{html}{\out{<div class="r">}}\preformatted{OGS6$add_vtu(path, axisym = FALSE, read_in_vtu = FALSE)}\if{html}{\out{</div>}} } \subsection{Arguments}{ @@ -218,6 +218,8 @@ object \describe{ \item{\code{path}}{string: A path} +\item{\code{axisym}}{flag: Is the mesh axially symmetrical?} + \item{\code{read_in_vtu}}{flag: Optional: Should \code{.vtu} file just be copied or read in too?} } @@ -296,7 +298,7 @@ Clears components from the \code{OGS6} object \describe{ \item{\code{which}}{character: The names of the components (all by default). If you want to delete only some components, run -\code{names(prj_top_level_classes())} for the available options.} +\code{names(ogs6_prj_top_level_classes())} for the available options.} } \if{html}{\out{</div>}} } diff --git a/man/OGS6_gml.Rd b/man/OGS6_gml.Rd index 48aad92508f8439a3ce953d3e51b7147e639198d..a377808a6f5b6291ac3ace8e5845b75e5fc73059 100644 --- a/man/OGS6_gml.Rd +++ b/man/OGS6_gml.Rd @@ -39,8 +39,6 @@ OGS6_gml$new( \item{\code{surfaces}}{Access to private parameter '.surfaces'} -\item{\code{is_subclass}}{Getter for private parameter '.is_subclass'} - \item{\code{attr_names}}{Getter for private parameter '.attr_names'} \item{\code{flatten_on_exp}}{Getter for private parameter '.flatten_on_exp'} diff --git a/man/analyse_xml.Rd b/man/analyse_xml.Rd deleted file mode 100644 index 547750eb187f67c302eb30cfe5452094d7a0db50..0000000000000000000000000000000000000000 --- a/man/analyse_xml.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/analyse_xml.R -\name{analyse_xml} -\alias{analyse_xml} -\title{analyse_xml} -\usage{ -analyse_xml(path, pattern, xpath, print_findings = TRUE) -} -\arguments{ -\item{path}{string: A path} - -\item{pattern}{string: A regex pattern} - -\item{xpath}{string: An XPath expression. WARNING: Only works for expressions -that return nodesets, use it to look up tag names.} - -\item{print_findings}{Optional: Should the results be printed to the console?} -} -\description{ -This is a helper function which can be used to combat missing -documentation. It looks for files in a path which match the given pattern -and then attempts to parse them as XML. For each occurence of the specified -element, it documents its attributes and direct children and prints a little -summary of its findings at the end. -} diff --git a/man/are_null_or_numbers.Rd b/man/are_null_or_numbers.Rd deleted file mode 100644 index a646d8c38c459e29f8024965596693c5749d96d1..0000000000000000000000000000000000000000 --- a/man/are_null_or_numbers.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{are_null_or_numbers} -\alias{are_null_or_numbers} -\title{are_null_or_numbers} -\usage{ -are_null_or_numbers(...) -} -\arguments{ -\item{...}{Ellipsis} -} -\description{ -Checks if objects are either \code{NULL} or numbers -} diff --git a/man/are_null_or_numeric.Rd b/man/are_null_or_numeric.Rd deleted file mode 100644 index d6f3c7b7e0a3f9fc36d79d17343f747b4020b60f..0000000000000000000000000000000000000000 --- a/man/are_null_or_numeric.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{are_null_or_numeric} -\alias{are_null_or_numeric} -\title{are_null_or_numeric} -\usage{ -are_null_or_numeric(...) -} -\arguments{ -\item{...}{Ellipsis} -} -\description{ -Checks if objects are either \code{NULL} or numeric -} diff --git a/man/are_null_or_string_flags.Rd b/man/are_null_or_string_flags.Rd deleted file mode 100644 index 31b05fdeef2f14a2fdec1b9f5c0908a02931ccb2..0000000000000000000000000000000000000000 --- a/man/are_null_or_string_flags.Rd +++ /dev/null @@ -1,15 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{are_null_or_string_flags} -\alias{are_null_or_string_flags} -\title{are_null_or_string_flags} -\usage{ -are_null_or_string_flags(...) -} -\arguments{ -\item{...}{Ellipsis} -} -\description{ -Checks if objects are either \code{NULL} or strings reading -either "true" or "false" -} diff --git a/man/are_null_or_strings.Rd b/man/are_null_or_strings.Rd deleted file mode 100644 index c9c67f0df76c7a298fa01d1eb72530094be6df54..0000000000000000000000000000000000000000 --- a/man/are_null_or_strings.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{are_null_or_strings} -\alias{are_null_or_strings} -\title{are_null_or_strings} -\usage{ -are_null_or_strings(...) -} -\arguments{ -\item{...}{Ellipsis} -} -\description{ -Checks if objects are either \code{NULL} or strings -} diff --git a/man/are_numbers.Rd b/man/are_numbers.Rd deleted file mode 100644 index 680aee69d9a903518e408500e6233331dd25a742..0000000000000000000000000000000000000000 --- a/man/are_numbers.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{are_numbers} -\alias{are_numbers} -\title{are_numbers} -\usage{ -are_numbers(...) -} -\arguments{ -\item{...}{Ellipsis} -} -\description{ -Checks if objects are numbers -} diff --git a/man/are_numeric.Rd b/man/are_numeric.Rd deleted file mode 100644 index a9de7949a592be64a24aaf0983b1bdb19b2eaaaa..0000000000000000000000000000000000000000 --- a/man/are_numeric.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{are_numeric} -\alias{are_numeric} -\title{are_numeric} -\usage{ -are_numeric(...) -} -\arguments{ -\item{...}{Ellipsis} -} -\description{ -Checks if objects are numeric -} diff --git a/man/are_string_flags.Rd b/man/are_string_flags.Rd deleted file mode 100644 index cbcae8d8e4819cccdb31f50fa77eefa1b60cb6ef..0000000000000000000000000000000000000000 --- a/man/are_string_flags.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{are_string_flags} -\alias{are_string_flags} -\title{are_string_flags} -\usage{ -are_string_flags(...) -} -\arguments{ -\item{...}{Ellipsis} -} -\description{ -Checks if objects are strings reading either "true" or "false" -} diff --git a/man/are_strings.Rd b/man/are_strings.Rd deleted file mode 100644 index 0fe8bc5e80bea020a14944dbf7ebcf6984069393..0000000000000000000000000000000000000000 --- a/man/are_strings.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{are_strings} -\alias{are_strings} -\title{are_strings} -\usage{ -are_strings(...) -} -\arguments{ -\item{...}{Ellipsis} -} -\description{ -Checks if objects are strings -} diff --git a/man/as_dir_path.Rd b/man/as_dir_path.Rd deleted file mode 100644 index 47b0dc6ed94582cc19e38593865b065fca955df1..0000000000000000000000000000000000000000 --- a/man/as_dir_path.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{as_dir_path} -\alias{as_dir_path} -\title{as_dir_path} -\usage{ -as_dir_path(path) -} -\arguments{ -\item{path}{string: A path} -} -\description{ -Checks if a given path ends on \code{/} -} diff --git a/man/build_redux_doc.Rd b/man/build_redux_doc.Rd deleted file mode 100644 index 85e005c088c3eec2f9ad7a86291511eed47db4f4..0000000000000000000000000000000000000000 --- a/man/build_redux_doc.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_xml.R -\name{build_redux_doc} -\alias{build_redux_doc} -\title{build_redux_doc} -\usage{ -build_redux_doc(path, pattern, xpath, export_path) -} -\arguments{ -\item{path}{string: See \code{?analyse_xml}} - -\item{pattern}{string: See \code{?analyse_xml}} - -\item{xpath}{string: See \code{?analyse_xml}} - -\item{export_path}{string: Path to export the XML document to} -} -\description{ -Builds an XML document based on the findings of -\code{analyse_xml()}. Calls recursive function \code{build_redux_tree()} -internally. -} diff --git a/man/build_redux_tree.Rd b/man/build_redux_tree.Rd deleted file mode 100644 index 11f2cc7ecc0d692234617cb7530f8903431596f9..0000000000000000000000000000000000000000 --- a/man/build_redux_tree.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_xml.R -\name{build_redux_tree} -\alias{build_redux_tree} -\title{build_redux_tree} -\usage{ -build_redux_tree(path, pattern, xpath, required) -} -\arguments{ -\item{path}{string: See \code{?analyse_xml}} - -\item{pattern}{string: See \code{?analyse_xml}} - -\item{xpath}{string: See \code{?analyse_xml}} - -\item{required}{flag: Recursion utility} -} -\description{ -Builds an XML tree based on the findings of -\code{analyse_xml()}. This is a recursive function. -} diff --git a/man/clean_imported_list.Rd b/man/clean_imported_list.Rd deleted file mode 100644 index a8e0644c5d8a0240a81c9419caab37df98ce2677..0000000000000000000000000000000000000000 --- a/man/clean_imported_list.Rd +++ /dev/null @@ -1,15 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{clean_imported_list} -\alias{clean_imported_list} -\title{clean_imported_list} -\usage{ -clean_imported_list(list) -} -\arguments{ -\item{list}{list: A list} -} -\description{ -Cleans an imported list because sometimes strings containing -only newline characters and spaces get imported in -} diff --git a/man/coerce_names.Rd b/man/coerce_names.Rd deleted file mode 100644 index be60541341a4930832171abc851ac402db62b686..0000000000000000000000000000000000000000 --- a/man/coerce_names.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{coerce_names} -\alias{coerce_names} -\title{coerce_names} -\usage{ -coerce_names(vector, names) -} -\arguments{ -\item{vector}{vector: Vector of parameters} - -\item{names}{character: How the vector elements will be named as -per default} -} -\value{ -vector: Named vector where the names correspond to \code{names} -} -\description{ -Validator function for a parameter vector -} diff --git a/man/coerce_string_to_numeric.Rd b/man/coerce_string_to_numeric.Rd deleted file mode 100644 index 4061da8a4305c77485bf9295d927195a3545f2c4..0000000000000000000000000000000000000000 --- a/man/coerce_string_to_numeric.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{coerce_string_to_numeric} -\alias{coerce_string_to_numeric} -\title{coerce_string_to_numeric} -\usage{ -coerce_string_to_numeric(obj) -} -\arguments{ -\item{obj}{object: Any object} -} -\value{ -numeric if \code{obj} was a string, else unchanged \code{obj} -} -\description{ -If an object is of type string, coerces it to a numeric type -} -\examples{ - coerce_string_to_numeric("12 54 2 \n 2") -} diff --git a/man/compare_xml.Rd b/man/compare_xml.Rd deleted file mode 100644 index 205de120b9fd6d1529176311bb06211b3fe0b4b2..0000000000000000000000000000000000000000 --- a/man/compare_xml.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/compare_xml.R -\name{compare_xml} -\alias{compare_xml} -\title{compare_xml} -\usage{ -compare_xml(xml_node_x, xml_node_y) -} -\arguments{ -\item{xml_node_x}{xml2::xml_node: Node to compare} - -\item{xml_node_y}{xml2::xml_node: Node to compare to} -} -\description{ -Helper function to check if 2 XML documents have the same -content. This is a recursive function. Strictly WIP! -} diff --git a/man/construct_add_call.Rd b/man/construct_add_call.Rd deleted file mode 100644 index 3753914b929358ba876859776d1eac2790b9320b..0000000000000000000000000000000000000000 --- a/man/construct_add_call.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_benchmark_script.R -\name{construct_add_call} -\alias{construct_add_call} -\title{construct_add_call} -\usage{ -construct_add_call(object, nested_call = FALSE) -} -\arguments{ -\item{object}{An object (numeric, character, list, NULL, \code{OGS6} or -\code{r2ogs6} class object)} - -\item{nested_call}{Optional: For recursion purposes, you should leave this as -it is.} -} -\value{ -A string representing the code with which the component would be -added to an \code{OGS6} object -} -\description{ -Constructs a call based on an \code{OGS6} component. This is a -recursive function, handle with care. -} diff --git a/man/delete_keywords_from_str.Rd b/man/delete_keywords_from_str.Rd deleted file mode 100644 index 0da3be3be5cbab070dfef905baed9147cfc73afc..0000000000000000000000000000000000000000 --- a/man/delete_keywords_from_str.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_benchmark_script.R -\name{delete_keywords_from_str} -\alias{delete_keywords_from_str} -\title{delete_keywords_from_str} -\usage{ -delete_keywords_from_str(string) -} -\arguments{ -\item{string}{string} -} -\description{ -Utility function to delete keywords from a string, -this is important because there is a <repeat> tag in <time_loop> and -"repeat" is a reserved word in R (extend this function if you find more -reserved words) -} diff --git a/man/export_gml.Rd b/man/export_gml.Rd deleted file mode 100644 index b98610b8e14079f57ce3d444a43049f2e79faf8f..0000000000000000000000000000000000000000 --- a/man/export_gml.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/export_gml.R -\name{export_gml} -\alias{export_gml} -\title{export_gml} -\usage{ -export_gml(gml, path) -} -\arguments{ -\item{gml}{OGS6_gml:} - -\item{path}{string:} -} -\description{ -Creates a .gml XML document based on user input data -} diff --git a/man/export_prj.Rd b/man/export_prj.Rd deleted file mode 100644 index 6aabeb8da266cb9dc9b090a39dbecf7cea647a48..0000000000000000000000000000000000000000 --- a/man/export_prj.Rd +++ /dev/null @@ -1,15 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/export_prj.R -\name{export_prj} -\alias{export_prj} -\title{export_prj} -\usage{ -export_prj(ogs6_obj) -} -\arguments{ -\item{ogs6_obj}{OGS6: Simulation object} -} -\description{ -Wrapper function to create a \code{.prj} XML document based on -the user input data -} diff --git a/man/filter_invalid_xml.Rd b/man/filter_invalid_xml.Rd deleted file mode 100644 index 512b64458afecef2f05bac5407aced522c20ca1c..0000000000000000000000000000000000000000 --- a/man/filter_invalid_xml.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{filter_invalid_xml} -\alias{filter_invalid_xml} -\title{filter_invalid_xml} -\usage{ -filter_invalid_xml(paths, encoding = "ISO-8859-1", print_messages = TRUE) -} -\arguments{ -\item{paths}{character: Vector of (maybe-)XML paths} - -\item{encoding}{string: Optional: XML encoding. Defaults to ISO-8859-1} - -\item{print_messages}{flag: Optional: Print error messages? Defaults to -\code{TRUE}} -} -\value{ -character: Vector of invalid XML paths -} -\description{ -Filters invalid XML paths out of a vector -} diff --git a/man/flags_to_assign_str.Rd b/man/flags_to_assign_str.Rd deleted file mode 100644 index 80172d6355169dfba66a577308890ecc476b53e6..0000000000000000000000000000000000000000 --- a/man/flags_to_assign_str.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_class.R -\name{flags_to_assign_str} -\alias{flags_to_assign_str} -\title{flags_to_assign_str} -\usage{ -flags_to_assign_str(flags, print_result = FALSE) -} -\arguments{ -\item{flags}{vector: Flags} - -\item{print_result}{flag: Should the result be printed to the console?} -} -\description{ -Helper function to generate a string out of a flag vector -} diff --git a/man/flags_to_con_call_str.Rd b/man/flags_to_con_call_str.Rd deleted file mode 100644 index 42b7ae74e9c2574c448895e3cc95a62d26a13f2c..0000000000000000000000000000000000000000 --- a/man/flags_to_con_call_str.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_class.R -\name{flags_to_con_call_str} -\alias{flags_to_con_call_str} -\title{flags_to_con_call_str} -\usage{ -flags_to_con_call_str(flags, print_result = FALSE) -} -\arguments{ -\item{flags}{vector: Flags} - -\item{print_result}{flag: Should the result be printed to the console?} -} -\description{ -Helper function to generate a string out of a flag vector -} diff --git a/man/flags_to_con_str.Rd b/man/flags_to_con_str.Rd deleted file mode 100644 index 551edc77a45820f4db84f3c4b343b42ebf16baaa..0000000000000000000000000000000000000000 --- a/man/flags_to_con_str.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_class.R -\name{flags_to_con_str} -\alias{flags_to_con_str} -\title{flags_to_con_str} -\usage{ -flags_to_con_str(flags, print_result = FALSE) -} -\arguments{ -\item{flags}{vector: Flags} - -\item{print_result}{flag: Should the result be printed to the console?} -} -\description{ -Helper function to generate a string out of a flag vector -} diff --git a/man/flags_to_doc_str.Rd b/man/flags_to_doc_str.Rd deleted file mode 100644 index 99f41e18c7c5906ffe15dae81b7b56effe717fca..0000000000000000000000000000000000000000 --- a/man/flags_to_doc_str.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_class.R -\name{flags_to_doc_str} -\alias{flags_to_doc_str} -\title{flags_to_doc_str} -\usage{ -flags_to_doc_str(flags, print_result = FALSE) -} -\arguments{ -\item{flags}{vector: Flags} - -\item{print_result}{flag: Should the result be printed to the console?} -} -\description{ -Helper function to generate a string out of a flag vector -} diff --git a/man/flags_to_name_str.Rd b/man/flags_to_name_str.Rd deleted file mode 100644 index 87600c60789a5b8a026f87e13ee2c721495255d1..0000000000000000000000000000000000000000 --- a/man/flags_to_name_str.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_class.R -\name{flags_to_name_str} -\alias{flags_to_name_str} -\title{flags_to_name_str} -\usage{ -flags_to_name_str(flags, print_result = FALSE) -} -\arguments{ -\item{flags}{vector: Flags} - -\item{print_result}{flag: Should the result be printed to the console?} -} -\description{ -Helper function to generate a name string out of a flag vector -} diff --git a/man/flags_to_r6_active_field_str.Rd b/man/flags_to_r6_active_field_str.Rd deleted file mode 100644 index 86b1d4a897380586bb8cdf0626ed1ecb777bb001..0000000000000000000000000000000000000000 --- a/man/flags_to_r6_active_field_str.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_class.R -\name{flags_to_r6_active_field_str} -\alias{flags_to_r6_active_field_str} -\title{flags_to_r6_active_field_str} -\usage{ -flags_to_r6_active_field_str(flags, mutable = TRUE, print_result = FALSE) -} -\arguments{ -\item{flags}{vector: Flags} - -\item{mutable}{flag: On per default, turn off if parameters are static} - -\item{print_result}{flag: Should the result be printed to the console?} -} -\description{ -Helper function to generate a string out of a flag vector -} diff --git a/man/flags_to_r6_init_str.Rd b/man/flags_to_r6_init_str.Rd deleted file mode 100644 index ffe0431a1cc39d95543d8507541b5ed35e9a4b6b..0000000000000000000000000000000000000000 --- a/man/flags_to_r6_init_str.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_class.R -\name{flags_to_r6_init_str} -\alias{flags_to_r6_init_str} -\title{flags_to_r6_init_str} -\usage{ -flags_to_r6_init_str(flags, print_result = FALSE) -} -\arguments{ -\item{flags}{vector: Flags} - -\item{print_result}{flag: Should the result be printed to the console?} -} -\description{ -Helper function to generate a string out of a flag vector -} diff --git a/man/flags_to_r6_private_str.Rd b/man/flags_to_r6_private_str.Rd deleted file mode 100644 index bf76a854a5295b1ae6894cc7bace31b27501b10b..0000000000000000000000000000000000000000 --- a/man/flags_to_r6_private_str.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_class.R -\name{flags_to_r6_private_str} -\alias{flags_to_r6_private_str} -\title{flags_to_r6_private_str} -\usage{ -flags_to_r6_private_str(flags, print_result = FALSE) -} -\arguments{ -\item{flags}{vector: Flags} - -\item{print_result}{flag: Should the result be printed to the console?} -} -\description{ -Helper function to generate a string out of a flag vector -} diff --git a/man/generate_R6.Rd b/man/generate_R6.Rd deleted file mode 100644 index 664e8232b49d006d0eaa744d1cabc95340fc9a86..0000000000000000000000000000000000000000 --- a/man/generate_R6.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_class.R -\name{generate_R6} -\alias{generate_R6} -\title{generate_R6} -\usage{ -generate_R6(params, prefix = "", print_result = TRUE) -} -\arguments{ -\item{params}{list: (Return value of \code{analyse_xml()})} - -\item{prefix}{Optional: For subclasses whose represented elements have -the same tag name as an element for which a class was already specified, -a prefix must be appended to the class name} - -\item{print_result}{flag: Should the result be printed to the console?} -} -\description{ -Helper function to generate a R6 class out of a tag name -and a flag vector -} diff --git a/man/generate_active_field.Rd b/man/generate_active_field.Rd deleted file mode 100644 index b9603567c95fbd760018e806fc7e0fd6d4b3ab61..0000000000000000000000000000000000000000 --- a/man/generate_active_field.Rd +++ /dev/null @@ -1,15 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_class.R -\name{generate_active_field} -\alias{generate_active_field} -\title{generate_active_field} -\usage{ -generate_active_field(parameter_name) -} -\arguments{ -\item{parameter_name}{The name of the OGS6 class parameter} -} -\description{ -Helper function to generate an R6 active field for a OGS6 class -parameter -} diff --git a/man/generate_add_method.Rd b/man/generate_add_method.Rd deleted file mode 100644 index 9957c8e1f195b87069276ba371ed5c60eb5eb903..0000000000000000000000000000000000000000 --- a/man/generate_add_method.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_class.R -\name{generate_add_method} -\alias{generate_add_method} -\title{generate_add_method} -\usage{ -generate_add_method(tag_name, parent_tag_name) -} -\arguments{ -\item{tag_name}{The tag name of the XML element represented by the class -object} - -\item{parent_tag_name}{The tag name of the parent of the XML element -represented by the class object} -} -\description{ -Helper function to generate an R6 \code{add_*} method for a -r2ogs6 class object -} diff --git a/man/generate_all_benchmark_scripts.Rd b/man/generate_all_benchmark_scripts.Rd deleted file mode 100644 index 3832caf0aadc4f3b15b19e5db9e067e3709fe7e0..0000000000000000000000000000000000000000 --- a/man/generate_all_benchmark_scripts.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_benchmark_script.R -\name{generate_all_benchmark_scripts} -\alias{generate_all_benchmark_scripts} -\title{generate_all_benchmark_scripts} -\usage{ -generate_all_benchmark_scripts( - path, - sim_path, - scripts_path, - read_in_gmls, - read_in_vtus = FALSE, - starting_from_prj_path = "", - skip_prj_paths = character() -) -} -\arguments{ -\item{path}{string: Path to a benchmark directory to generate scripts from} - -\item{sim_path}{string: Path where all simulation files will be saved} - -\item{scripts_path}{string: Path where benchmark scripts will be saved} - -\item{read_in_gmls}{flag: Optional: Should \code{.gml} files just be copied -or read in too?} - -\item{read_in_vtus}{flag: Optional: Should \code{.vtu} files just be copied -or read in too?} - -\item{starting_from_prj_path}{string: Optional:} - -\item{skip_prj_paths}{character: Optional: \code{.prj} paths to skip} -} -\description{ -Wrapper function to generate benchmark scripts from all -\code{.prj} files in a directory -} diff --git a/man/generate_constructor.Rd b/man/generate_constructor.Rd deleted file mode 100644 index e4709eba899f055184af40317b1ec6da1cb6a239..0000000000000000000000000000000000000000 --- a/man/generate_constructor.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_class.R -\name{generate_constructor} -\alias{generate_constructor} -\title{generate_constructor} -\usage{ -generate_constructor(params, prefix = "", print_result = FALSE) -} -\arguments{ -\item{params}{list: (Return value of \code{analyse_xml()})} - -\item{prefix}{Optional: For subclasses whose represented elements have -the same tag name as an element for which a class was already specified, -a prefix must be appended to the class name} - -\item{print_result}{flag: Should the result be printed to the console?} -} -\description{ -Helper function to generate a constructor out of a tag name -and a flag vector -} diff --git a/man/generate_helper.Rd b/man/generate_helper.Rd deleted file mode 100644 index 92a6b422c229e57ef453cb2d24e5a2af0bc9c021..0000000000000000000000000000000000000000 --- a/man/generate_helper.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generate_class.R -\name{generate_helper} -\alias{generate_helper} -\title{generate_helper} -\usage{ -generate_helper(params, prefix = "", print_result = FALSE) -} -\arguments{ -\item{params}{list: (Return value of \code{analyse_xml()})} - -\item{prefix}{Optional: For subclasses whose represented elements have -the same tag name as an element for which a class was already specified, -a prefix must be appended to the class name} - -\item{print_result}{flag: Should the result be printed to the console?} -} -\description{ -Helper function to generate a helper out of a tag name -and a flag vector -} diff --git a/man/get_benchmark_paths.Rd b/man/get_benchmark_paths.Rd deleted file mode 100644 index 112419dbbc57ae8896ee43913fa0544a73c20d1b..0000000000000000000000000000000000000000 --- a/man/get_benchmark_paths.Rd +++ /dev/null @@ -1,15 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sim_utils.R -\name{get_benchmark_paths} -\alias{get_benchmark_paths} -\title{get_benchmark_paths} -\usage{ -get_benchmark_paths(ogs6_processlib_path) -} -\arguments{ -\item{ogs6_processlib_path}{string: Path to OpenGeoSys 6 ProcessLib folder -which contains relevant Tests.cmake files} -} -\description{ -Gets paths to all benchmarks that should work -} diff --git a/man/get_class_args.Rd b/man/get_class_args.Rd deleted file mode 100644 index 82debcba03ce2a6143a6185d2aa0bd3cec85e3e3..0000000000000000000000000000000000000000 --- a/man/get_class_args.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_utils.R -\name{get_class_args} -\alias{get_class_args} -\title{get_class_args} -\usage{ -get_class_args(class_name) -} -\arguments{ -\item{class_name}{string: The name of a class} -} -\value{ -character: Named vector of class arguments -} -\description{ -Gets class arguments -} diff --git a/man/get_class_from_xpath.Rd b/man/get_class_from_xpath.Rd deleted file mode 100644 index c064a55df381e43d94dfa61ae370864a402ee5d8..0000000000000000000000000000000000000000 --- a/man/get_class_from_xpath.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{get_class_from_xpath} -\alias{get_class_from_xpath} -\title{get_class_from_xpath} -\usage{ -get_class_from_xpath(xpath) -} -\arguments{ -\item{xpath}{string: An xpath expression. Works for path-like xpaths only} -} -\value{ -string: The class name. -} -\description{ -Gets r2ogs6 class name from an xpath-like expression -} -\examples{ - get_class_from_xpath("processes/process") -} diff --git a/man/get_prj_top_level_tags.Rd b/man/get_prj_top_level_tags.Rd deleted file mode 100644 index 4c8ea40df834abb6c6670a6d24014ad8877c6c0f..0000000000000000000000000000000000000000 --- a/man/get_prj_top_level_tags.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{get_prj_top_level_tags} -\alias{get_prj_top_level_tags} -\title{get_prj_top_level_tags} -\usage{ -get_prj_top_level_tags() -} -\value{ -list: List of lists. -} -\description{ -Gets top level .prj tags along with info if they are required. -} diff --git a/man/get_required.Rd b/man/get_required.Rd deleted file mode 100644 index 19c7a0fad47298a02a1bd0569d5fe27218d6d280..0000000000000000000000000000000000000000 --- a/man/get_required.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/analyse_xml.R -\name{get_required} -\alias{get_required} -\title{get_required} -\usage{ -get_required(names, occurence_probabilities) -} -\arguments{ -\item{names}{A vector of names} - -\item{occurence_probabilities}{A vector of occurrence probabilities} -} -\description{ -Helper function to mark required attributes or children from a -vector of names and a vector of occurrence probabilities -} diff --git a/man/get_tag_from_class.Rd b/man/get_tag_from_class.Rd deleted file mode 100644 index e546c8a586cb27e78839aed0a3b604b77e967fab..0000000000000000000000000000000000000000 --- a/man/get_tag_from_class.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{get_tag_from_class} -\alias{get_tag_from_class} -\title{get_tag_from_class} -\usage{ -get_tag_from_class(class_name) -} -\arguments{ -\item{class_name}{string: The name of a r2ogs6 class} -} -\value{ -string: The tag name corresponding to \code{class_name} -} -\description{ -Utility function, returns the tag name of a r2ogs6 class -} -\examples{ - get_tag_from_class("prj_process") -} diff --git a/man/get_tag_from_xpath.Rd b/man/get_tag_from_xpath.Rd deleted file mode 100644 index 116a8885697ac7bc9b364533db0bcb78dd084689..0000000000000000000000000000000000000000 --- a/man/get_tag_from_xpath.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{get_tag_from_xpath} -\alias{get_tag_from_xpath} -\title{get_tag_from_xpath} -\usage{ -get_tag_from_xpath(xpath) -} -\arguments{ -\item{xpath}{string: An xpath expression. Works for path-like xpaths only} -} -\value{ -string: The XML tag name -} -\description{ -Gets the XML tag name from an xpath expression -} -\examples{ - get_tag_from_xpath("processes/process") -} diff --git a/man/is_null_or_coerce_names.Rd b/man/is_null_or_coerce_names.Rd deleted file mode 100644 index 8b49faf8895e77f2e6031c5d7cf53258855635da..0000000000000000000000000000000000000000 --- a/man/is_null_or_coerce_names.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{is_null_or_coerce_names} -\alias{is_null_or_coerce_names} -\title{is_null_or_coerce_names} -\usage{ -is_null_or_coerce_names(obj, names) -} -\arguments{ -\item{obj}{A list (or vector) of parameters} - -\item{names}{How the list elements will be named as per default} -} -\description{ -Validator function for a parameter list or vector or \code{NULL} -} diff --git a/man/is_null_or_has_class.Rd b/man/is_null_or_has_class.Rd deleted file mode 100644 index 42fc9c114e745f265697bc2fb8c7b1a3e840ca14..0000000000000000000000000000000000000000 --- a/man/is_null_or_has_class.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{is_null_or_has_class} -\alias{is_null_or_has_class} -\title{is_null_or_has_class} -\usage{ -is_null_or_has_class(obj, class_name) -} -\arguments{ -\item{obj}{The object to check} - -\item{class_name}{The name of the expected class} -} -\description{ -Checks if an object is either \code{NULL} or a class object of -class \code{class_name} -} diff --git a/man/is_null_or_wrapper_list.Rd b/man/is_null_or_wrapper_list.Rd deleted file mode 100644 index 9c76eddf56a80ed99c153bea7b16c6cbfc9fef22..0000000000000000000000000000000000000000 --- a/man/is_null_or_wrapper_list.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{is_null_or_wrapper_list} -\alias{is_null_or_wrapper_list} -\title{is_null_or_wrapper_list} -\usage{ -is_null_or_wrapper_list(obj, element_class) -} -\arguments{ -\item{obj}{list | NULL: Object to check} - -\item{element_class}{string: Class each element of \code{obj} should have} -} -\description{ -Checks if an object is either \code{NULL} or a list of elements -of class \code{element_class} -} diff --git a/man/is_wrapper_list.Rd b/man/is_wrapper_list.Rd deleted file mode 100644 index 379ef3e83f77996962b0295484e523e1b3222391..0000000000000000000000000000000000000000 --- a/man/is_wrapper_list.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{is_wrapper_list} -\alias{is_wrapper_list} -\title{is_wrapper_list} -\usage{ -is_wrapper_list(list, element_class) -} -\arguments{ -\item{list}{list: List to check} - -\item{element_class}{string: Class each element of \code{list} should have} -} -\description{ -Checks if a list consists only of elements of class -\code{element_class} -} diff --git a/man/node_to_object.Rd b/man/node_to_object.Rd deleted file mode 100644 index 3a44763351b8dddc93369b23c11844d1c1f89635..0000000000000000000000000000000000000000 --- a/man/node_to_object.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_utils.R -\name{node_to_object} -\alias{node_to_object} -\title{node_to_object} -\usage{ -node_to_object(xml_node, xpath = "") -} -\arguments{ -\item{xml_node}{xml2::xml_node: XML node} - -\item{xpath}{string: XPath expression (for subclass differentiation)} -} -\description{ -Returns representation of an XML node. This is a recursive -function. -ASSUMPTIONS: -1) Leaf nodes will never be prj_* objects -2) Wrapper nodes are represented as lists -3) Parent nodes whose children have no children are represented as lists -} diff --git a/man/node_to_prj_class_object.Rd b/man/node_to_prj_class_object.Rd deleted file mode 100644 index 3e92a99094c6d3556d4c011fff7400a47a948a5b..0000000000000000000000000000000000000000 --- a/man/node_to_prj_class_object.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_utils.R -\name{node_to_prj_class_object} -\alias{node_to_prj_class_object} -\title{node_to_prj_class_object} -\usage{ -node_to_prj_class_object(xml_node, xpath) -} -\arguments{ -\item{xml_node}{xml2::xml_node: XML node} - -\item{xpath}{string: XPath expression (for subclass differentiation)} -} -\description{ -Takes an XML node and turns it into a class object -} diff --git a/man/ogs6_download_ogs6.Rd b/man/ogs6_download_ogs6.Rd new file mode 100644 index 0000000000000000000000000000000000000000..57c0017df17bfe5316175a16943326bc95a1d186 --- /dev/null +++ b/man/ogs6_download_ogs6.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/download_ogs6.R +\name{ogs6_download_ogs6} +\alias{ogs6_download_ogs6} +\title{Download OpenGeoSys 6} +\usage{ +ogs6_download_ogs6(path, os, set_as_default_bin_path = TRUE) +} +\arguments{ +\item{path}{String: Download path. Defaults to ...} + +\item{os}{String: Operating System.} + +\item{set_as_default_bin_path}{flag: Defaults to `TRUE`} +} +\description{ +Downloads latest prebuilt OpenGeoSys 6 version +} diff --git a/man/ogs6_generate_benchmark_script.Rd b/man/ogs6_generate_benchmark_script.Rd index 1f2ea5d9b6ce686689af39ab54c2379de07934aa..6edfb199fd11423329b06d928eb327265662cb01 100644 --- a/man/ogs6_generate_benchmark_script.Rd +++ b/man/ogs6_generate_benchmark_script.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/generate_benchmark_script.R \name{ogs6_generate_benchmark_script} \alias{ogs6_generate_benchmark_script} -\title{ogs6_generate_benchmark_script} +\title{Generate benchmark script} \usage{ ogs6_generate_benchmark_script( prj_path, @@ -14,7 +14,7 @@ ogs6_generate_benchmark_script( ) } \arguments{ -\item{prj_path}{string: \code{.prj} file the script will be based on} +\item{prj_path}{string: `.prj` file the script will be based on} \item{sim_path}{string: Path where all simulation files will be saved} @@ -22,12 +22,12 @@ ogs6_generate_benchmark_script( \item{script_path}{string: Path where benchmark script will be saved} -\item{read_in_gml}{flag: Optional: Should \code{.gml} file just be copied or +\item{read_in_gml}{flag: Optional: Should `.gml` file just be copied or read in too?} -\item{read_in_vtu}{flag: Optional: Should \code{.vtu} file(s) just be copied +\item{read_in_vtu}{flag: Optional: Should `.vtu` file(s) just be copied or read in too?} } \description{ -Generates a benchmark script from an existing \code{.prj} file. +Generates an R script from an existing `.prj` benchmark file. } diff --git a/man/ogs6_generate_benchmark_scripts.Rd b/man/ogs6_generate_benchmark_scripts.Rd new file mode 100644 index 0000000000000000000000000000000000000000..c6eaee766257eee0f1660f478bed6a15b8c623b7 --- /dev/null +++ b/man/ogs6_generate_benchmark_scripts.Rd @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/generate_benchmark_script.R +\name{ogs6_generate_benchmark_scripts} +\alias{ogs6_generate_benchmark_scripts} +\title{Generate benchmark scripts} +\usage{ +ogs6_generate_benchmark_scripts( + path, + sim_path, + script_path, + read_in_gml, + read_in_vtu = FALSE, + starting_from_prj_path = "", + skip_prj_paths = character() +) +} +\arguments{ +\item{path}{string: Path to a benchmark directory to generate scripts from} + +\item{sim_path}{string: Path where all simulation files will be saved} + +\item{script_path}{string: Path where benchmark script will be saved} + +\item{read_in_gml}{flag: Optional: Should `.gml` file just be copied or +read in too?} + +\item{read_in_vtu}{flag: Optional: Should `.vtu` file(s) just be copied +or read in too?} + +\item{starting_from_prj_path}{string: Optional: `.prj` path to start from} + +\item{skip_prj_paths}{character: Optional: `.prj` paths to skip} +} +\description{ +This is a wrapper function for `ogs6_generate_benchmark_script()`. +} diff --git a/man/prj_top_level_classes.Rd b/man/ogs6_prj_top_level_classes.Rd similarity index 50% rename from man/prj_top_level_classes.Rd rename to man/ogs6_prj_top_level_classes.Rd index e9e47962ceb633962bf1c1dd41f6b4f501965b2e..5a7e61c217860007fee8af7ddd25636b1beadbb4 100644 --- a/man/prj_top_level_classes.Rd +++ b/man/ogs6_prj_top_level_classes.Rd @@ -1,16 +1,16 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{prj_top_level_classes} -\alias{prj_top_level_classes} -\title{prj_top_level_classes} +% Please edit documentation in R/ogs6.R +\name{ogs6_prj_top_level_classes} +\alias{ogs6_prj_top_level_classes} +\title{ogs6_prj_top_level_classes} \usage{ -prj_top_level_classes() +ogs6_prj_top_level_classes() } \value{ character } \description{ Returns named character vector of \code{OGS6} top level -\code{.prj} tags (names) represented by \code{r2ogs6} classes along with their -class names (values). +\code{.prj} tags (names) represented by \code{r2ogs6} classes along with +their class names (values). } diff --git a/man/order_parameters.Rd b/man/order_parameters.Rd deleted file mode 100644 index 8d18945c48dc4266482d8e82045c9c0488830a50..0000000000000000000000000000000000000000 --- a/man/order_parameters.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_utils.R -\name{order_parameters} -\alias{order_parameters} -\title{order_parameters} -\usage{ -order_parameters(parameters, class_name) -} -\arguments{ -\item{parameters}{list: Parameters} - -\item{class_name}{string: The name of a class} -} -\value{ -list: Parameters ordered by argument order of class -} -\description{ -Orders a list of parameters corresponding to the argument order -of a class -} diff --git a/man/read_in.Rd b/man/read_in.Rd deleted file mode 100644 index 14272311f9afe0e181ba936484d78a35c139f253..0000000000000000000000000000000000000000 --- a/man/read_in.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_utils.R -\name{read_in} -\alias{read_in} -\title{read_in} -\usage{ -read_in(ogs6_obj, path, xpath) -} -\arguments{ -\item{ogs6_obj}{A OGS6 class object} - -\item{path}{string: Path to file XML elements should be read from} - -\item{xpath}{string: An XPath expression (should be absolute!)} -} -\description{ -Reads in elements from a file -} diff --git a/man/read_in_points.Rd b/man/read_in_points.Rd deleted file mode 100644 index 2b486cf2cf37efbdf536f7142640b60ba31ebc1b..0000000000000000000000000000000000000000 --- a/man/read_in_points.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_gml.R -\name{read_in_points} -\alias{read_in_points} -\title{read_in_points} -\usage{ -read_in_points(xml_doc) -} -\arguments{ -\item{xml_doc}{A parsed XML document (of class \code{xml2::xml_document})} -} -\description{ -Reads points from a \code{.gml} file -} diff --git a/man/read_in_polylines.Rd b/man/read_in_polylines.Rd deleted file mode 100644 index 69b60ffc3521c4ab8310c698dc0ce63578e77489..0000000000000000000000000000000000000000 --- a/man/read_in_polylines.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_gml.R -\name{read_in_polylines} -\alias{read_in_polylines} -\title{read_in_polylines} -\usage{ -read_in_polylines(xml_doc) -} -\arguments{ -\item{xml_doc}{A parsed XML document (of class \code{xml2::xml_document})} -} -\description{ -Reads polylines from a \code{.gml} file -} diff --git a/man/read_in_surfaces.Rd b/man/read_in_surfaces.Rd deleted file mode 100644 index ded5155738587b478b3c9f14a54a20fcc870fdcc..0000000000000000000000000000000000000000 --- a/man/read_in_surfaces.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_gml.R -\name{read_in_surfaces} -\alias{read_in_surfaces} -\title{read_in_surfaces} -\usage{ -read_in_surfaces(xml_doc) -} -\arguments{ -\item{xml_doc}{A parsed XML document (of class \code{xml2::xml_document})} -} -\description{ -Reads surfaces from a \code{.gml} file -} diff --git a/man/run_all_benchmarks.Rd b/man/run_all_benchmarks.Rd deleted file mode 100644 index 67d157b1e8e06ba414021c32b9a6a7d28831d3f7..0000000000000000000000000000000000000000 --- a/man/run_all_benchmarks.Rd +++ /dev/null @@ -1,33 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sim_utils.R -\name{run_all_benchmarks} -\alias{run_all_benchmarks} -\title{run_all_benchmarks} -\usage{ -run_all_benchmarks( - path, - ogs6_processlib_path, - ogs6_bin_path, - sim_path, - starting_from_prj_path = "", - print_results = TRUE -) -} -\arguments{ -\item{path}{string: Path to benchmark folder} - -\item{ogs6_processlib_path}{string: Path to OpenGeoSys 6 ProcessLib folder -which contains relevant Tests.cmake files} - -\item{ogs6_bin_path}{string:} - -\item{sim_path}{string: Path where simulation files will be saved} - -\item{starting_from_prj_path}{string: \code{.prj} path to start from} - -\item{print_results}{flag: Print results in the end?} -} -\description{ -Utility function, for quick benchmark runs. Calls - run_benchmark internally. -} diff --git a/man/run_benchmark.Rd b/man/run_benchmark.Rd deleted file mode 100644 index c05e53501806b0ec2f9bb5b32cbf0f836dce351d..0000000000000000000000000000000000000000 --- a/man/run_benchmark.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sim_utils.R -\name{run_benchmark} -\alias{run_benchmark} -\title{run_benchmark} -\usage{ -run_benchmark(prj_path, ogs6_bin_path, sim_path) -} -\arguments{ -\item{prj_path}{string:} - -\item{ogs6_bin_path}{string:} - -\item{sim_path}{string: Path where simulation files will be saved} -} -\description{ -Utility function for quick benchmark runs -} diff --git a/man/to_node.Rd b/man/to_node.Rd deleted file mode 100644 index 3c11db77bb07c3a84ea7a025c2f69231308effa3..0000000000000000000000000000000000000000 --- a/man/to_node.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/export_utils.R -\name{to_node} -\alias{to_node} -\title{to_node} -\usage{ -to_node( - object, - object_name = "", - attribute_names = character(), - flatten_on_exp = character(), - unwrap_on_exp = character() -) -} -\arguments{ -\item{object}{An object (so far works for r2ogs6 class objects, strings, -numbers, lists and vectors)} - -\item{object_name}{string: Optional: The object name. If not supplied, this -function tries to guess the tag name by deparsing the 'object' parameter} - -\item{attribute_names}{Optional: A character vector containing names of -attributes or attribute nodes} - -\item{flatten_on_exp}{character: Optional: This is for vectors which will be -flattened to a string in XML} - -\item{unwrap_on_exp}{character: Optional: This is for lists which will not -be exported to XML} -} -\description{ -Recursive function to restructure objects so -xml2::as_xml_document() function will convert them to the desired XML format -} diff --git a/man/validate_pnt_values.Rd b/man/validate_pnt_values.Rd deleted file mode 100644 index e87a3a53925b7fc5e26661e6a6d427182910a12a..0000000000000000000000000000000000000000 --- a/man/validate_pnt_values.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ogs6_gml.R -\name{validate_pnt_values} -\alias{validate_pnt_values} -\title{validate_pnt_values} -\usage{ -validate_pnt_values(element_1, element_2) -} -\arguments{ -\item{element_1}{numeric, length = 3} - -\item{element_2}{numeric, length = 3} -} -\description{ -Checks if two numerical vectors of length 3 -(two surface elements) each consist of 3 different elements and have -exactly 2 matching elements between them. Think of the two vectors as -triangles, and the triangles together form a square which is our surface. -} diff --git a/man/validate_points.Rd b/man/validate_points.Rd deleted file mode 100644 index 007e8df9f5271c11cfc0e2bba91e4d321da613f8..0000000000000000000000000000000000000000 --- a/man/validate_points.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ogs6_gml.R -\name{validate_points} -\alias{validate_points} -\title{validate_points} -\usage{ -validate_points(points) -} -\arguments{ -\item{points}{tibble: Must have 3 vectors named 'x', 'y' and 'z', may have -optional 'name' vector} -} -\description{ -Checks if the input is a tibble, if this tibble has the right -number of elements, if those elements are named correctly and if there are -any overlapping points or duplicate point names -} diff --git a/man/validate_polylines.Rd b/man/validate_polylines.Rd deleted file mode 100644 index 089d632ab373f05158b59ed8950c1b1cb607ad72..0000000000000000000000000000000000000000 --- a/man/validate_polylines.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ogs6_gml.R -\name{validate_polylines} -\alias{validate_polylines} -\title{validate_polylines} -\usage{ -validate_polylines(polylines) -} -\arguments{ -\item{polylines}{list(list("foo", c(1, 2))):} -} -\description{ -Checks if the input is a list, if this list consists of other -lists and if those lists have the correct structure (length of 2, first -element is a string named 'name', second element is a numeric vector) -} diff --git a/man/validate_read_in_xml.Rd b/man/validate_read_in_xml.Rd deleted file mode 100644 index c97deee00c15d2e2fc3886b7d052f38eff18c3ac..0000000000000000000000000000000000000000 --- a/man/validate_read_in_xml.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_utils.R -\name{validate_read_in_xml} -\alias{validate_read_in_xml} -\title{validate_read_in_xml} -\usage{ -validate_read_in_xml(path) -} -\arguments{ -\item{path}{string: A file to be parsed as XML} -} -\value{ -The parsed XML file (as class object of type -\code{xml2::xml_document}) -} -\description{ -Utility function, tries parsing the provided file as an XML -document -} diff --git a/man/validate_surfaces.Rd b/man/validate_surfaces.Rd deleted file mode 100644 index 22c00a163038f144e7648a82a095a0ef033d8816..0000000000000000000000000000000000000000 --- a/man/validate_surfaces.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ogs6_gml.R -\name{validate_surfaces} -\alias{validate_surfaces} -\title{validate_surfaces} -\usage{ -validate_surfaces(surfaces) -} -\arguments{ -\item{surfaces}{list(list("foo", c(1, 2, 3), c(2, 3, 4))):} -} -\description{ -Checks if the input is a list, if this list consists of other -lists and if those lists have the correct structure (length of 2 or 3, first -element is a string named 'name', second and third element are numeric -vectors) -} diff --git a/tests/testthat/test-export_utils.R b/tests/testthat/test-export_utils.R index 1c152a509fc525a6c093ade94d8466a4de1a4d33..2223f177dd0235b808fd642608a3670960dc75ba 100644 --- a/tests/testthat/test-export_utils.R +++ b/tests/testthat/test-export_utils.R @@ -220,3 +220,27 @@ test_that("to_node works for prj_process class", { expect_equal(attrs, c(internal_name = "sigma_xx", output_name = "sigma_xx")) }) + + + +test_that("meshes_to_node works for mesh / meshes elements", { + + meshes <- list(mesh = list(path = "a", axially_symmetric = TRUE), + mesh = list(path = "b", axially_symmetric = FALSE)) + + test_xml_1 <- meshes_to_xml(meshes) + + expect_equal(length(xml2::xml_find_all(test_xml_1,"/meshes/mesh")), 2) + expect_equal(xml2::xml_attrs(xml2::xml_find_first(test_xml_1, + "/meshes/mesh")), + c(axially_symmetric = "true")) + + + lone_mesh <- list(mesh = list(path = "a", axially_symmetric = TRUE)) + test_xml_2 <- meshes_to_xml(lone_mesh) + + expect_equal(length(xml2::xml_find_all(test_xml_2,"/mesh")), 1) + expect_equal(xml2::xml_attrs(xml2::xml_find_first(test_xml_2, + "/mesh")), + c(axially_symmetric = "true")) +}) diff --git a/tests/testthat/test-generate_benchmark_script.R b/tests/testthat/test-generate_benchmark_script.R index d5c6c126eb40816cae76517fac2aebae225d8702..4c40f5ec2d1c5370c360a5c1e519103e38d078d2 100644 --- a/tests/testthat/test-generate_benchmark_script.R +++ b/tests/testthat/test-generate_benchmark_script.R @@ -70,13 +70,3 @@ test_that("construct_add_call handles Ellipsis correctly", { "list(index = 1,\nvalues = c(1, 2)),\n", "index_values = list(index = 2,\nvalues = c(2, 3))))\n")) }) - - -test_that("delete_keywords_from_str works", { - - test_str <- "prj_object(a = \"foo\", repeat = \"bar\")" - - test_str <- delete_keywords_from_str(test_str) - expect_equal(test_str, "prj_object(a = \"foo\", \"bar\")") - -}) diff --git a/tests/testthat/test-ogs6_ensemble.R b/tests/testthat/test-ogs6_ensemble.R index f57e2b16973f4a1920e39f6d52d6a93124789544..00b18816a17219221a16b3d58976d9aaece696ed 100644 --- a/tests/testthat/test-ogs6_ensemble.R +++ b/tests/testthat/test-ogs6_ensemble.R @@ -44,9 +44,21 @@ test_that("OGS6_Ensemble initialization works", { ) expect_equal(length(ogs6_ens_seq_noper$ensemble), 4) + + expect_equal(ogs6_ens_seq_noper$ensemble[[1]]$parameters[[1]]$value, 2) + expect_equal(ogs6_ens_seq_noper$ensemble[[1]]$parameters[[2]]$value, 4) + + expect_equal(ogs6_ens_seq_noper$ensemble[[2]]$parameters[[1]]$value, 3) + expect_equal(ogs6_ens_seq_noper$ensemble[[2]]$parameters[[2]]$value, 4) + + expect_equal(ogs6_ens_seq_noper$ensemble[[3]]$parameters[[1]]$value, 1) + expect_equal(ogs6_ens_seq_noper$ensemble[[3]]$parameters[[2]]$value, 5) + + expect_equal(ogs6_ens_seq_noper$ensemble[[4]]$parameters[[1]]$value, 1) expect_equal(ogs6_ens_seq_noper$ensemble[[4]]$parameters[[2]]$value, 6) + # Test with sequential_mode off and percentages_mode on ogs6_ens_noseq_per <- OGS6_Ensemble$new( ogs6_obj = ogs6_obj, diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 1640ccc8a45132462cc2b0901703ea7411617161..2c179872d4d7a06a01a73c027bc98106060135a4 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -24,8 +24,8 @@ test_that("get_tag_from_xpath() works", { }) -test_that("prj_top_level_classes() works", { - expect_equal(prj_top_level_classes()[["processes"]], "prj_process") +test_that("ogs6_prj_top_level_classes() works", { + expect_equal(ogs6_prj_top_level_classes()[["processes"]], "prj_process") }) diff --git a/vignettes/ensemble_workflow_vignette.Rmd b/vignettes/ensemble_workflow_vignette.Rmd index 40ba70782e1919eef6a4bc3943428b1b46f3312f..261206cf7b9432b2e91f2d67c53c6f06b3d7309a 100644 --- a/vignettes/ensemble_workflow_vignette.Rmd +++ b/vignettes/ensemble_workflow_vignette.Rmd @@ -1,5 +1,6 @@ --- title: "r2ogs6 Ensemble Guide" +#output: pdf_document output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{r2ogs6 Ensemble Guide} @@ -58,7 +59,7 @@ testdir_path <- tempdir() sim_path <- paste0(testdir_path, "/axisym_theis_sim") ogs6_obj <- OGS6$new(sim_name = "axisym_theis", - sim_path = sim_path) + sim_path = "D:/ogs6_theis/axisym_theis_sim") # Change this to fit your system prj_path <- system.file("extdata/benchmarks/AxiSymTheis/", @@ -83,10 +84,16 @@ ogs6_ens <- parameters = list(list(ogs6_obj$media[[1]]$properties[[4]]$value, percentages)), percentages_mode = TRUE) +``` + +Now you can start the simulation. -# Now we run the simulations -exit_codes <- ogs6_ens$run_simulation() -paste(exit_codes, collapse = " ") +```{r, eval = FALSE} +ogs6_ens$run_simulation() +``` + +```{r, include = FALSE} +lapply(ogs6_ens$ensemble, ogs6_read_output_files) ``` #### Plot results for single simulation @@ -176,9 +183,16 @@ ogs6_ens_big <- sto = list(ogs6_obj$media[[1]]$properties[[4]]$value, values = percentages)), sequential_mode = TRUE) +``` + +Now you can start the simulation. + +```{r, eval = FALSE} +ogs6_ens_big$run_simulation() +``` -exit_codes <- ogs6_ens_big$run_simulation() -paste(exit_codes) +```{r, include = FALSE} +lapply(ogs6_ens_big$ensemble, ogs6_read_output_files) ``` This will take a short time. As soon as the simulations are done, we can extract the point data much like we did before. This time we want to plot the point x coodinates on the x axis so we're leaving out `point_ids` to get all points. Also we just want the data from the last timestep. @@ -197,16 +211,84 @@ Plotting time! Since we set `sequential_mode` to `TRUE`, the dataframe we just c # Make plot ggplot(per_por_sto_df, aes(x = x, - y = pressure, + y = -pressure, # Flip pressure because source term was positive group = perc)) + geom_point(aes(color = as.factor(perc))) + - xlab("x point coordinate") + + xlab("Radius (m)") + + ylab("Head (m)") + labs(color = "%") + - facet_grid(cols = vars(name)) + facet_grid(cols = vars(name), + labeller = as_labeller(c(per = "permeability", + por = "porosity", + sto = "storage"))) ``` -Ta-Daa! We can see `permeability` has the most influence on the pressure. Though they may seem suspicious, `porosity` and `storage` are being plotted correctly - the points are just being placed right on top of each other. Since `porosity` can't go over the value `1` which was the original value, our value vector only went from -50% to 0% which is why the line colors of `porosity` and `storage` differ. +Ta-Daa! We can see `permeability` has the most influence on the pressure. Though they may seem suspicious, `porosity` and `storage` are being plotted correctly - the points are just being placed right on top of each other. Since `porosity` can't go over the value `1` which was the original value, our value vector only went from -50% to 0% which is why the line colors of `porosity` and `storage` differ. Maybe we want to try and use a logarithmic approach for `storage`. This won't work with the built-in functionality of `OGS6_Ensemble` so we'll set up our Ensemble a little differently. +```{r} +# Calculate log value +log_val <- log(as.numeric( + ogs6_obj$media[[1]]$properties[[4]]$value), + base = 10) + +# Apply changes to log value +log_vals <- vapply(percentages, function(x){ + log_val + (log_val * (x / 100)) +}, FUN.VALUE = numeric(1)) + +# Transfer back to non-logarithmic scale +back_transf_vals <- 10^log_vals + +# Change sim_path to fit your system +ogs6_obj$sim_path <- "D:/ogs6_theis/axisym_theis_sim_log_storage" + +# Set up new ensemble +ogs6_ens_sto <- + OGS6_Ensemble$new( + ogs6_obj = ogs6_obj, + parameters = + list( + sto = list( + ogs6_obj$media[[1]]$properties[[4]]$value, + values = back_transf_vals) + ), + percentages_mode = FALSE, + sequential_mode = TRUE + ) +``` + +As before, we can run the simulation right away. + +```{r, eval = FALSE} +ogs6_ens_sto$run_simulation() +``` + +```{r, include = FALSE} +lapply(ogs6_ens_sto$ensemble, ogs6_read_output_files) +``` + +Let's check if we can observe any influence of `storage` on `pressure` now. + +```{r} +# Get combined dataframe +sto_df <- + ogs6_ens_sto$get_point_data( + keys = c("pressure"), + start_at_timestep = ogs6_ens_sto$ensemble[[1]]$pvds[[1]]$last_timestep) + +# Supply percentages manually since we couldn't use `percentages_mode` +percs <- vapply(sto_df$sim_id, + function(x){percentages[[x]]}, + FUN.VALUE = numeric(1)) + +ggplot(sto_df, + aes(x = x, + y = -pressure)) + + geom_point(aes(color = as.factor(percs))) + + xlab("Radius (m)") + + ylab("Head (m)") + + labs(color = "%") +``` ## Theis solution for well pumping @@ -228,7 +310,7 @@ First, we create a simulation object to base our ensemble on and read in the `.p sim_path <- paste0(testdir_path, "/theis_sim") ogs6_obj <- OGS6$new(sim_name = "theis", - sim_path = sim_path) + sim_path = "D:/ogs6_theis/theis_sim") # Change this to fit your system prj_path <- system.file("extdata/benchmarks/theis_well_pumping/", @@ -261,9 +343,16 @@ ogs6_ens_theis_2 <- ), sequential_mode = TRUE ) +``` + +Now you can start the simulation. -exit_codes <- ogs6_ens_theis_2$run_simulation() -paste(exit_codes) +```{r, eval = FALSE} +ogs6_ens_theis_2$run_simulation() +``` + +```{r, include = FALSE} +lapply(ogs6_ens_theis_2$ensemble, ogs6_read_output_files) ``` When the simulations have run, we can extract and plot the results like before. To avoid cluttering the plot, we only extract the `pressure` values for a single line. For this, we get the IDs of all points on the x axis. @@ -297,12 +386,17 @@ per_por_slo_df <- # Make plot ggplot(per_por_slo_df, aes(x = x, - y = pressure, + y = pressure / 9806.65, # 1mH2O = 9806.65 kPa group = perc)) + geom_point(aes(color = as.factor(perc))) + - xlab("x point coordinate") + + xlab("Radius (m)") + + ylab("Absenkung (m)") + labs(color = "%") + - facet_grid(cols = vars(name)) + facet_grid(cols = vars(name), + labeller = as_labeller(c(per = "permeability", + por = "porosity", + slo = "slope" + ))) ``` @@ -316,7 +410,8 @@ ggplot(per_df, aes(x = x, y = pressure)) + geom_point(aes(color = as.factor(perc))) + - xlab("x point coordinate") + + xlab("Radius (m)") + + ylab("Head (m)") + labs(color = "%") ``` @@ -336,6 +431,9 @@ log_vals <- vapply(percentages, function(x){ # Transfer back to non-logarithmic scale back_transf_vals <- 10^log_vals +# Change sim_path to fit your system +ogs6_obj$sim_path <- "D:/ogs6_theis/theis_sim_log_slope" + # Set up new ensemble ogs6_ens_slo <- OGS6_Ensemble$new( @@ -349,8 +447,16 @@ ogs6_ens_slo <- percentages_mode = FALSE, sequential_mode = TRUE ) +``` + +As before, we can run the simulation right away. + +```{r, eval = FALSE} +ogs6_ens_slo$run_simulation() +``` -exit_codes <- ogs6_ens_slo$run_simulation() +```{r, include = FALSE} +lapply(ogs6_ens_slo$ensemble, ogs6_read_output_files) ``` Let's check if we can observe any influence of `slope` on `pressure` now. @@ -374,9 +480,10 @@ percs <- vapply(slo_df$sim_id, ggplot(slo_df, aes(x = x, - y = pressure)) + + y = pressure / 9806.65)) + # 1mH2O = 9806.65 kPa geom_point(aes(color = as.factor(percs))) + - xlab("x point coordinate") + + xlab("Radius (m)") + + ylab("Head (m)") + labs(color = "%") ``` @@ -384,8 +491,3 @@ ggplot(slo_df, ## Summary The `OGS6_Ensemble` class is a useful tool to set up ensemble runs for sensitivity analyses. In this vignette, we learned how to create `OGS6_Ensemble` objects. We looked at how the parameters `sequential_mode` and `percentages_mode` influence how our ensemble object is initialised. We started simulations via `OGS6_Ensemble$run_simulation()` and extracted information from the output files to plot them. - -```{r, include = FALSE} -# Cleanup created folders -do.call(file.remove, list(list.files(testdir_path, full.names = TRUE))) -``` \ No newline at end of file diff --git a/vignettes/user_workflow_vignette.Rmd b/vignettes/user_workflow_vignette.Rmd index c441f380650ec2a7b52ccae1865d96f6c8903236..f88a809ce254e029d3fc20fa08b779bfb1f0347f 100644 --- a/vignettes/user_workflow_vignette.Rmd +++ b/vignettes/user_workflow_vignette.Rmd @@ -53,7 +53,6 @@ Usually, you will only ever define `sim_name`, `sim_path`. ```{r} ogs6_obj <- OGS6$new(sim_name = "my_simulation", - sim_id = 1, sim_path = "my_sim_path") ```