Skip to content
Snippets Groups Projects
Commit 6fd777b8 authored by Ruben Heinrich's avatar Ruben Heinrich
Browse files

[feature] experimenting with writing log file

parent 0ea1ddfd
No related branches found
No related tags found
1 merge request!6Merge branch 7 fixed functionality into master
...@@ -14,6 +14,7 @@ run_simulation <- function(ogs6_obj, iter_n = 1, output_to_log_file = TRUE) { ...@@ -14,6 +14,7 @@ run_simulation <- function(ogs6_obj, iter_n = 1, output_to_log_file = TRUE) {
assertthat::assert_that(inherits(ogs6_obj, "OGS6")) assertthat::assert_that(inherits(ogs6_obj, "OGS6"))
assertthat::assert_that(assertthat::is.number(iter_n), assertthat::assert_that(assertthat::is.number(iter_n),
iter_n > 0, iter_n < 500) iter_n > 0, iter_n < 500)
assertthat::assert_that(assertthat::is.flag(output_to_log_file))
#Call all validators #Call all validators
validate_all(ogs6_obj) validate_all(ogs6_obj)
...@@ -22,9 +23,42 @@ run_simulation <- function(ogs6_obj, iter_n = 1, output_to_log_file = TRUE) { ...@@ -22,9 +23,42 @@ run_simulation <- function(ogs6_obj, iter_n = 1, output_to_log_file = TRUE) {
export_gml(ogs6_obj) export_gml(ogs6_obj)
export_prj(ogs6_obj) export_prj(ogs6_obj)
#Construct the system call
ogs6_call <- paste0(ogs6_obj$ogs_bin_path,
"ogs.exe ",
ogs6_obj$sim_path,
ogs6_obj$sim_name,
".prj -o ",
ogs6_obj$sim_path)
system_call <- ogs6_call
#Direct simulation output to log file #Direct simulation output to log file
if(output_to_log_file){ if(output_to_log_file){
log_file <- paste0(ogs6_obj$sim_path, ogs6_obj$sim_name, "_log.txt")
# Create logfile directory
logfile_dir <- paste0(ogs6$sim_path, "logfiles/")
if(!dir.exists(logfile_dir)){
dir.create(logfile_dir)
}else{
warning("Logfile directory already exists", call. = FALSE)
}
for(i in seq_len(iter_n)){
logfile_path <- paste0(logfile_dir,
ogs6_obj$sim_name,
"_log_", iter_n, ".txt")
#Call OGS6
system(command = paste("R CMD BATCH --no-echo",
script_path,
logfile_path))
# read_in_output(ogs6_obj)
}
#Write to file... #Write to file...
} }
...@@ -32,12 +66,7 @@ run_simulation <- function(ogs6_obj, iter_n = 1, output_to_log_file = TRUE) { ...@@ -32,12 +66,7 @@ run_simulation <- function(ogs6_obj, iter_n = 1, output_to_log_file = TRUE) {
for(i in seq_len(iter_n)){ for(i in seq_len(iter_n)){
#Call OGS6 #Call OGS6
system(command = paste0(ogs6_obj$ogs_bin_path, system(command = ogs6_call)
"ogs.exe ",
ogs6_obj$sim_path,
ogs6_obj$sim_name,
".prj -o ",
ogs6_obj$sim_path))
# read_in_output(ogs6_obj) # read_in_output(ogs6_obj)
} }
...@@ -74,6 +103,9 @@ validate_all <- function(ogs6_obj) { ...@@ -74,6 +103,9 @@ validate_all <- function(ogs6_obj) {
} }
#===== CHAINING UTILITY (WIP) =====
#'read_in_output #'read_in_output
#'@description After a OGS6 simulation was run, reads in the generated .vtu #'@description After a OGS6 simulation was run, reads in the generated .vtu
#' files as new input for #' files as new input for
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment