diff --git a/R/sim_utils.R b/R/sim_utils.R index a28368ebfda577c4adbcb8d3797a5f3f3236176f..c3e644aaa994b8024826a380a8c3a9964d457abe 100644 --- a/R/sim_utils.R +++ b/R/sim_utils.R @@ -40,6 +40,9 @@ run_simulation <- function(ogs6_obj, iter_n = 1, output_to_log_file = TRUE) { } +#============================== VALIDATION UTILITY ================================ + + #'validate_all #'@description Validates all necessary parameters #'@param ogs6_obj A OGS6 class object @@ -62,6 +65,28 @@ validate_all <- function(ogs6_obj) { } +#'validate_paths +#'@description Helper function to pull path validation out of already large class OGS6 +#'@param sim_path The path where all relevant files for the simulation will be saved +#'@param ogs_bin_path Path to OpenGeoSys6 /bin directory +validate_paths <- function(sim_path, ogs_bin_path){ + if(!dir.exists(sim_path)){ + dir.create(sim_path) + }else{ + if(length(dir(sim_path, all.files = TRUE)) != 0){ + warning(paste0("The sim_path directory you defined ('", sim_path, + "') already exists (that is ok). However, ", + "it is not empty. Files may be overwritten."), call. = FALSE) + } + } + + if(!file.exists(paste0(ogs_bin_path, "generateStructuredMesh.exe"))) { + stop(paste("Could not find executable file generateStructuredMesh.exe at location", + ogs_bin_path), call. = FALSE) + } +} + + #'read_in_output #'@description After a OGS6 simulation was run, reads in the generated .vtu files as new input for #' the .prj file