Skip to content
Snippets Groups Projects
Commit f55a1fb6 authored by Johannes Boog's avatar Johannes Boog
Browse files

Merge branch '42-bugfixes' into 'master'

Resolve "bugfixes"

Closes #42

See merge request !24
parents e5763b1e 488fbb0e
No related branches found
No related tags found
1 merge request!24Resolve "bugfixes"
...@@ -232,8 +232,7 @@ OGS6_vtu <- R6::R6Class( ...@@ -232,8 +232,7 @@ OGS6_vtu <- R6::R6Class(
}else{ }else{
# Check class # Check class
private$.vtkUnstructuredGrid <- value private$.vtkUnstructuredGrid <- value
private$.dsa_vtkUnstructuredGrid <- private$.dsa_vtkUnstructuredGrid <- dsa$WrapDataObject(value)
vtk$numpy_interface$dataset_adapter$WrapDataObject(value)
} }
}, },
......
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
#' @noRd #' @noRd
read_in_points <- function(xml_doc) { read_in_points <- function(xml_doc) {
points_tibble <- tibble::tibble(x = c(), points_tibble <- tibble::tibble(x = numeric(),
y = c(), y = numeric(),
z = c(), z = numeric(),
name = c()) name = character())
points_nodeset <- xml2::xml_find_all(xml_doc, "//points/*") points_nodeset <- xml2::xml_find_all(xml_doc, "//points/*")
......
...@@ -133,6 +133,9 @@ ogs6_call_ogs6 <- function(ogs6_obj, ...@@ -133,6 +133,9 @@ ogs6_call_ogs6 <- function(ogs6_obj,
if(missing(ogs6_bin_path)){ if(missing(ogs6_bin_path)){
ogs6_bin_path <- unlist(options("r2ogs6.default_ogs6_bin_path")) ogs6_bin_path <- unlist(options("r2ogs6.default_ogs6_bin_path"))
} }
else if(is.null(ogs6_bin_path)){
ogs6_bin_path <- unlist(options("r2ogs6.default_ogs6_bin_path"))
}
assertthat::assert_that(assertthat::is.string(ogs6_bin_path)) assertthat::assert_that(assertthat::is.string(ogs6_bin_path))
assertthat::assert_that(assertthat::is.flag(verbose)) assertthat::assert_that(assertthat::is.flag(verbose))
...@@ -244,10 +247,7 @@ ogs6_read_output_files <- function(ogs6_obj){ ...@@ -244,10 +247,7 @@ ogs6_read_output_files <- function(ogs6_obj){
"\\.pvd$", "\\.pvd$",
full.names = TRUE) full.names = TRUE)
for(i in seq_len(length(pvd_paths))){ ogs6_obj$pvds <- lapply(pvd_paths, function(x){OGS6_pvd$new(pvd_path = x)})
ogs6_obj$pvds <- c(ogs6_obj$pvds,
list(OGS6_pvd$new(pvd_path = pvd_paths[[i]])))
}
return(invisible()) return(invisible())
} }
...@@ -285,8 +285,14 @@ run_benchmark <- function(prj_path, ...@@ -285,8 +285,14 @@ run_benchmark <- function(prj_path,
ogs6_obj <- OGS6$new(sim_name = sim_name, ogs6_obj <- OGS6$new(sim_name = sim_name,
sim_path = sim_path) sim_path = sim_path)
# check if *.gml file is present
read_gml <- ifelse(
any(sapply(list.files(), function(x) grepl(".gml", x))),
T, F)
read_in_prj(ogs6_obj = ogs6_obj, read_in_prj(ogs6_obj = ogs6_obj,
prj_path = prj_path) prj_path = prj_path,
read_in_gml = read_gml)
return(invisible(ogs6_run_simulation(ogs6_obj, return(invisible(ogs6_run_simulation(ogs6_obj,
ogs6_bin_path = ogs6_bin_path))) ogs6_bin_path = ogs6_bin_path)))
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# Python vtk library reference # Python vtk library reference
vtk <- NULL vtk <- NULL
dsa <- NULL
.onLoad <- function(libname, pkgname){ .onLoad <- function(libname, pkgname){
...@@ -30,6 +31,8 @@ vtk <- NULL ...@@ -30,6 +31,8 @@ vtk <- NULL
# use superassignments to update global Python references # use superassignments to update global Python references
vtk <<- reticulate::import("vtk", delay_load = TRUE) vtk <<- reticulate::import("vtk", delay_load = TRUE)
dsa <<- reticulate::import("vtk.numpy_interface.dataset_adapter",
delay_load = TRUE)
return(invisible()) return(invisible())
} }
......
...@@ -15,7 +15,6 @@ library(r2ogs6) ...@@ -15,7 +15,6 @@ library(r2ogs6)
# Then we can create a simulation object. # Then we can create a simulation object.
ogs6_obj <- OGS6$new(sim_name = "axisym_theis", ogs6_obj <- OGS6$new(sim_name = "axisym_theis",
sim_id = 1,
sim_path = "D:/OGS_Sim/") sim_path = "D:/OGS_Sim/")
...@@ -25,7 +24,7 @@ ogs6_obj <- OGS6$new(sim_name = "axisym_theis", ...@@ -25,7 +24,7 @@ ogs6_obj <- OGS6$new(sim_name = "axisym_theis",
prj_path <- "inst/extdata/benchmarks/AxiSymTheis/axisym_theis.prj" prj_path <- "inst/extdata/benchmarks/AxiSymTheis/axisym_theis.prj"
# Read in the benchmark into our simulation object # Read in the benchmark into our simulation object
read_in_prj(ogs6_obj, prj_path) read_in_prj(ogs6_obj, prj_path, T)
#===== Run simulation ===== #===== Run simulation =====
......
# setup for tests
tmp_dir <- tempdir()
\ No newline at end of file
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
test_that("export_gml works", { test_that("export_gml works", {
# Get extdata directory and create folder for the test # Get extdata directory and create folder for the test
extdata_path <- system.file("extdata/test_tempdirs/", package = "r2ogs6") test_path <- paste0(tmp_dir, "/export_gml_test")
test_path <- paste0(extdata_path, "/export_gml_test")
dir.create(test_path) dir.create(test_path)
# Define gml object # Define gml object
......
...@@ -14,7 +14,7 @@ test_that("export_prj works", { ...@@ -14,7 +14,7 @@ test_that("export_prj works", {
prj_path <- (system.file("extdata/benchmarks/flow_free_expansion", prj_path <- (system.file("extdata/benchmarks/flow_free_expansion",
"flow_free_expansion.prj", package = "r2ogs6")) "flow_free_expansion.prj", package = "r2ogs6"))
read_in_prj(ogs6_obj, prj_path) read_in_prj(ogs6_obj, prj_path, read_in_gml = T)
# Now export it # Now export it
export_prj(ogs6_obj) export_prj(ogs6_obj)
......
...@@ -24,8 +24,9 @@ test_that("OGS6_vtu initialization works", { ...@@ -24,8 +24,9 @@ test_that("OGS6_vtu initialization works", {
vtu_obj <- OGS6_vtu$new(vtu_path = vtu_path) vtu_obj <- OGS6_vtu$new(vtu_path = vtu_path)
expect_equal("vtkmodules.vtkCommonDataModel.vtkUnstructuredGrid" %in% classes <- c("vtkCommonDataModelPython.vtkUnstructuredGrid",
class(vtu_obj$vtkUnstructuredGrid), TRUE) "vtkmodules.vtkCommonDataModel.vtkUnstructuredGrid")
expect_equal(any(classes %in% class(vtu_obj$vtkUnstructuredGrid)), TRUE)
expect_equal(vtu_obj$number_of_points, 8) expect_equal(vtu_obj$number_of_points, 8)
expect_equal(vtu_obj$number_of_cells, 1) expect_equal(vtu_obj$number_of_cells, 1)
......
...@@ -190,7 +190,8 @@ test_that("read_in_prj works for processes/include tags", { ...@@ -190,7 +190,8 @@ test_that("read_in_prj works for processes/include tags", {
sim_path = "sim_path") sim_path = "sim_path")
read_in_prj(ogs6_obj, read_in_prj(ogs6_obj,
prj_path) prj_path,
read_in_gml = T)
expect_equal(length(ogs6_obj$processes), 1) expect_equal(length(ogs6_obj$processes), 1)
expect_equal(names(ogs6_obj$processes)[[1]], "include") expect_equal(names(ogs6_obj$processes)[[1]], "include")
...@@ -207,7 +208,8 @@ test_that("read_in_prj works for EmbeddedFracturePermeability/cube.prj", { ...@@ -207,7 +208,8 @@ test_that("read_in_prj works for EmbeddedFracturePermeability/cube.prj", {
sim_path = "sim_path") sim_path = "sim_path")
read_in_prj(ogs6_obj, read_in_prj(ogs6_obj,
prj_path) prj_path,
read_in_gml = T)
expect_equal(ogs6_obj$processes[[1]]$name, "HM") expect_equal(ogs6_obj$processes[[1]]$name, "HM")
}) })
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
skip_if_ogs6_missing <- function() { skip_if_ogs6_missing <- function() {
ogs6_path <- unlist(options("r2ogs6.default_ogs6_bin_path")) ogs6_path <- unlist(options("r2ogs6.default_ogs6_bin_path"))
print(ogs6_path)
if(is.null(ogs6_path) || !file.exists(ogs6_path)){ if(is.null(ogs6_path) || !file.exists(ogs6_path)){
skip("ogs executable not available for testing") skip("ogs executable not available for testing")
} }
skip("Skipping tests that call ogs6_run_simulation()") #skip("Skipping tests that call ogs6_run_simulation()")
} }
...@@ -16,8 +16,8 @@ test_that("ogs6_run_simulation works for flow_no_strain.prj", { ...@@ -16,8 +16,8 @@ test_that("ogs6_run_simulation works for flow_no_strain.prj", {
skip_if_ogs6_missing() skip_if_ogs6_missing()
extdata_path <- system.file("extdata/test_tempdirs/", package = "r2ogs6") #extdata_path <- system.file("extdata/test_tempdirs/", package = "r2ogs6")
sim_path <- paste0(extdata_path, "/run_simulation_test") sim_path <- paste0(tmp_dir, "/run_simulation_test")
dir.create(sim_path) dir.create(sim_path)
prj_path <- system.file("extdata/benchmarks/flow_no_strain/", prj_path <- system.file("extdata/benchmarks/flow_no_strain/",
...@@ -25,12 +25,10 @@ test_that("ogs6_run_simulation works for flow_no_strain.prj", { ...@@ -25,12 +25,10 @@ test_that("ogs6_run_simulation works for flow_no_strain.prj", {
package = "r2ogs6") package = "r2ogs6")
# Define OGS6 object # Define OGS6 object
ogs6_obj <- OGS6$new(sim_name = "sim", ogs6_obj <- OGS6$new(sim_name = "sim", sim_path = sim_path)
sim_id = 1,
sim_path = sim_path)
# Read in .prj data # Read in .prj data
read_in_prj(ogs6_obj, prj_path) read_in_prj(ogs6_obj, prj_path, read_in_gml = T)
# Run simulation # Run simulation
e <- ogs6_run_simulation(ogs6_obj) e <- ogs6_run_simulation(ogs6_obj)
...@@ -53,8 +51,7 @@ test_that("ogs6_run_simulation works for flow_no_strain.prj", { ...@@ -53,8 +51,7 @@ test_that("ogs6_run_simulation works for flow_no_strain.prj", {
test_that("ogs6_export_sim_files works", { test_that("ogs6_export_sim_files works", {
extdata_path <- system.file("extdata/test_tempdirs/", package = "r2ogs6") test_path <- paste0(tmp_dir, "/export_all_sim_files_test")
test_path <- paste0(extdata_path, "/export_all_sim_files_test")
dir.create(test_path) dir.create(test_path)
prj_path <- (system.file("extdata/benchmarks/Elliptic/circle_radius_1", prj_path <- (system.file("extdata/benchmarks/Elliptic/circle_radius_1",
...@@ -64,7 +61,8 @@ test_that("ogs6_export_sim_files works", { ...@@ -64,7 +61,8 @@ test_that("ogs6_export_sim_files works", {
sim_path = test_path) sim_path = test_path)
read_in_prj(ogs6_obj, read_in_prj(ogs6_obj,
prj_path) prj_path,
read_in_gml = T)
# Now export all files # Now export all files
ogs6_export_sim_files(ogs6_obj) ogs6_export_sim_files(ogs6_obj)
...@@ -91,8 +89,8 @@ test_that("run_benchmark works for flow_free_expansion.prj", { ...@@ -91,8 +89,8 @@ test_that("run_benchmark works for flow_free_expansion.prj", {
skip_if_ogs6_missing() skip_if_ogs6_missing()
extdata_path <- system.file("extdata/test_tempdirs/", package = "r2ogs6") #extdata_path <- system.file("extdata/test_tempdirs/", package = "r2ogs6")
sim_path <- paste0(extdata_path, "/run_benchmark_test") sim_path <- paste0(tmp_dir, "/run_benchmark_test")
dir.create(sim_path) dir.create(sim_path)
prj_path <- system.file("extdata/benchmarks/flow_free_expansion/", prj_path <- system.file("extdata/benchmarks/flow_free_expansion/",
......
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