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

[tests] updated tests, removed sim_id

parent 51da592b
No related branches found
No related tags found
1 merge request!10Resolve "user-friendly print method for `OGS6` class and associated classes needed"
...@@ -8,7 +8,6 @@ test_that("export_prj works", { ...@@ -8,7 +8,6 @@ test_that("export_prj works", {
# Define prj_path and OGS6 object, then read in .prj file # Define prj_path and OGS6 object, then read in .prj file
ogs6_obj <- OGS6$new(sim_name = "flow_free_expansion", ogs6_obj <- OGS6$new(sim_name = "flow_free_expansion",
sim_id = 1,
sim_path = test_path) sim_path = test_path)
......
...@@ -5,7 +5,6 @@ test_that("OGS6$clear() works as expected", { ...@@ -5,7 +5,6 @@ test_that("OGS6$clear() works as expected", {
ogs6_obj <- OGS6$new( ogs6_obj <- OGS6$new(
sim_name = "sim", sim_name = "sim",
sim_id = 1,
sim_path = "sim_path") sim_path = "sim_path")
ogs6_obj$add(r2ogs6_parameter( ogs6_obj$add(r2ogs6_parameter(
...@@ -24,7 +23,6 @@ test_that("OGS6$add() works", { ...@@ -24,7 +23,6 @@ test_that("OGS6$add() works", {
ogs6_obj <- OGS6$new( ogs6_obj <- OGS6$new(
sim_name = "sim", sim_name = "sim",
sim_id = 1,
sim_path = "sim_path") sim_path = "sim_path")
ogs6_obj$add(r2ogs6_parameter( ogs6_obj$add(r2ogs6_parameter(
......
...@@ -5,7 +5,6 @@ test_that("OGS6_Ensemble initialization works", { ...@@ -5,7 +5,6 @@ test_that("OGS6_Ensemble initialization works", {
ogs6_obj <- OGS6$new( ogs6_obj <- OGS6$new(
sim_name = "sim", sim_name = "sim",
sim_id = 1,
sim_path = "sim_path") sim_path = "sim_path")
ogs6_obj$add(r2ogs6_parameter( ogs6_obj$add(r2ogs6_parameter(
......
test_that("OGS6_gml initialization works", {
gml <- OGS6_gml$new(name = "my_gml",
points = tibble::tibble(x = c(0, 0),
y = c(1, 1),
z = c(0, 1)),
polylines = list(list("my_line", c(1, 0, 1))))
expect_equal(length(gml$points), 3)
})
test_that("validate_points works", { test_that("validate_points works", {
point_list <- list(x = c(0, 0), y = c(1, 1), z = c(0, 1)) point_list <- list(x = c(0, 0), y = c(1, 1), z = c(0, 1))
...@@ -66,4 +80,4 @@ test_that("validate_surfaces works", { ...@@ -66,4 +80,4 @@ test_that("validate_surfaces works", {
expect_error(validate_surfaces(surface_tibble)) expect_error(validate_surfaces(surface_tibble))
#...(WIP) #...(WIP)
}) })
\ No newline at end of file
test_that("OGS6_pvd initialization works", {
pvd_path <- system.file("extdata/benchmarks/flow_no_strain",
"flow_no_strain.pvd",
package = "r2ogs6")
ogs6_pvd <- OGS6_pvd$new(pvd_path)
expect_equal(length(ogs6_pvd$vtu_paths), 2)
expect_equal(ogs6_pvd$vtu_paths[[1]],
"flow_no_strain_ts_0_t_0.000000.vtu")
expect_equal(ogs6_pvd$vtu_paths[[2]],
"flow_no_strain_ts_1000_t_100.000000.vtu")
})
test_that("OGS6_pvd$get_timestep_by_vtu_path works", {
pvd_path <- system.file("extdata/benchmarks/flow_no_strain",
"flow_no_strain.pvd",
package = "r2ogs6")
ogs6_pvd <- OGS6_pvd$new(pvd_path)
vtu_path <- "flow_no_strain_ts_1000_t_100.000000.vtu"
timestep <- ogs6_pvd$timestep_by_vtu(vtu_path = vtu_path)
expect_equal(timestep, 99.9999999999986)
})
test_that("OGS6_pvd$get_point_data_at works", {
pvd_path <- system.file("extdata/benchmarks/flow_no_strain",
"flow_no_strain.pvd",
package = "r2ogs6")
ogs6_pvd <- OGS6_pvd$new(pvd_path)
tbl_from_id <- ogs6_pvd$get_point_data(0,
keys = c("epsilon_xx",
"epsilon_xy"))
# Test for DataArray where NumberOfComponents == 1
tbl_from_coords <- ogs6_pvd$get_point_data_at(coordinates = c(0, 0, 0),
keys = c("epsilon_xx",
"epsilon_xy"))
expect_equal(tbl_from_coords$epsilon_xx, tbl_from_id$epsilon_xx)
expect_equal(tbl_from_coords$epsilon_xy, tbl_from_id$epsilon_xy)
})
test_that("OGS6_pvd$get_point_data works", {
pvd_path <- system.file("extdata/benchmarks/flow_no_strain",
"flow_no_strain.pvd",
package = "r2ogs6")
ogs6_pvd <- OGS6_pvd$new(pvd_path)
# Test for DataArray where NumberOfComponents == 1
tbl_simple <- ogs6_pvd$get_point_data(point_ids = c(0, 1, 2),
keys = c("epsilon_xx",
"epsilon_xy"))
expect_equal(nrow(tbl_simple), 6)
# Test for DataArray where NumberOfComponents(displacement) == 2
tbl_nocomp <- ogs6_pvd$get_point_data(point_ids = c(0, 1, 2),
keys = c("displacement",
"epsilon_xx"))
expect_equal(nrow(tbl_nocomp), 6)
})
test_that("OGS6_pvd$get_cell_data works", {
pvd_path <- system.file("extdata/benchmarks/flow_no_strain",
"flow_no_strain.pvd",
package = "r2ogs6")
ogs6_pvd <- OGS6_pvd$new(pvd_path)
# Test for DataArray where NumberOfComponents(displacement) == 2
tbl_nocomp <- ogs6_pvd$get_cell_data(
cell_ids = c(0, 1, 2),
keys = c("permeability",
"principal_stress_values"))
expect_equal(nrow(tbl_nocomp), 6)
})
...@@ -13,106 +13,6 @@ skip_if_python_modules_missing <- function() { ...@@ -13,106 +13,6 @@ skip_if_python_modules_missing <- function() {
} }
#===== OGS6_pvd =====
test_that("OGS6_pvd initialization works", {
pvd_path <- system.file("extdata/benchmarks/flow_no_strain",
"flow_no_strain.pvd",
package = "r2ogs6")
ogs6_pvd <- OGS6_pvd$new(pvd_path)
expect_equal(length(ogs6_pvd$vtu_paths), 2)
expect_equal(ogs6_pvd$vtu_paths[[1]],
"flow_no_strain_ts_0_t_0.000000.vtu")
expect_equal(ogs6_pvd$vtu_paths[[2]],
"flow_no_strain_ts_1000_t_100.000000.vtu")
})
test_that("OGS6_pvd$get_timestep_by_vtu_path works", {
pvd_path <- system.file("extdata/benchmarks/flow_no_strain",
"flow_no_strain.pvd",
package = "r2ogs6")
ogs6_pvd <- OGS6_pvd$new(pvd_path)
vtu_path <- "flow_no_strain_ts_1000_t_100.000000.vtu"
timestep <- ogs6_pvd$timestep_by_vtu(vtu_path = vtu_path)
expect_equal(timestep, 99.9999999999986)
})
test_that("OGS6_pvd$get_point_data_at works", {
pvd_path <- system.file("extdata/benchmarks/flow_no_strain",
"flow_no_strain.pvd",
package = "r2ogs6")
ogs6_pvd <- OGS6_pvd$new(pvd_path)
tbl_from_id <- ogs6_pvd$get_point_data(0,
Names = c("epsilon_xx",
"epsilon_xy"))
# Test for DataArray where NumberOfComponents == 1
tbl_from_coords <- ogs6_pvd$get_point_data_at(coordinates = c(0, 0, 0),
Names = c("epsilon_xx",
"epsilon_xy"))
expect_equal(tbl_from_coords$epsilon_xx, tbl_from_id$epsilon_xx)
expect_equal(tbl_from_coords$epsilon_xy, tbl_from_id$epsilon_xy)
})
test_that("OGS6_pvd$get_point_data works", {
pvd_path <- system.file("extdata/benchmarks/flow_no_strain",
"flow_no_strain.pvd",
package = "r2ogs6")
ogs6_pvd <- OGS6_pvd$new(pvd_path)
# Test for DataArray where NumberOfComponents == 1
tbl_simple <- ogs6_pvd$get_point_data(point_ids = c(0, 1, 2),
Names = c("epsilon_xx",
"epsilon_xy"))
expect_equal(nrow(tbl_simple), 6)
# Test for DataArray where NumberOfComponents(displacement) == 2
tbl_nocomp <- ogs6_pvd$get_point_data(point_ids = c(0, 1, 2),
Names = c("displacement",
"epsilon_xx"))
expect_equal(nrow(tbl_nocomp), 6)
})
test_that("OGS6_pvd$get_cell_data works", {
pvd_path <- system.file("extdata/benchmarks/flow_no_strain",
"flow_no_strain.pvd",
package = "r2ogs6")
ogs6_pvd <- OGS6_pvd$new(pvd_path)
# Test for DataArray where NumberOfComponents(displacement) == 2
tbl_nocomp <- ogs6_pvd$get_cell_data(
cell_ids = c(0, 1, 2),
Names = c("permeability",
"principal_stress_values"))
expect_equal(nrow(tbl_nocomp), 6)
})
#===== OGS6_vtu ===== #===== OGS6_vtu =====
...@@ -169,13 +69,13 @@ test_that("OGS6_vtu$get_point_data_at() works", { ...@@ -169,13 +69,13 @@ test_that("OGS6_vtu$get_point_data_at() works", {
vtu_obj <- OGS6_vtu$new(vtu_path = vtu_path) vtu_obj <- OGS6_vtu$new(vtu_path = vtu_path)
tbl <- vtu_obj$get_point_data_at(c(0.01, 0, 0), tbl <- vtu_obj$get_point_data_at(c(0.01, 0, 0),
Names = "epsilon_xx") keys = "epsilon_xx")
expect_equal(tbl$epsilon_xx, 3.282899e-15) expect_equal(tbl$epsilon_xx, 3.282899e-15)
bigger_tbl <- vtu_obj$get_point_data_at(list(c(0.01, 0, 0), bigger_tbl <- vtu_obj$get_point_data_at(list(c(0.01, 0, 0),
c(0.42, 0, 0)), c(0.42, 0, 0)),
Names = "epsilon_xx") keys = "epsilon_xx")
expect_equal(bigger_tbl$epsilon_xx[[2]], 1.233661e-16) expect_equal(bigger_tbl$epsilon_xx[[2]], 1.233661e-16)
}) })
......
...@@ -6,7 +6,6 @@ test_that("read_in works for process objects", { ...@@ -6,7 +6,6 @@ test_that("read_in works for process objects", {
"flow_free_expansion.prj", package = "r2ogs6")) "flow_free_expansion.prj", package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "sim", ogs6_obj <- OGS6$new(sim_name = "sim",
sim_id = 1,
sim_path = "sim_path") sim_path = "sim_path")
read_in(ogs6_obj, read_in(ogs6_obj,
...@@ -31,7 +30,6 @@ test_that("read_in works for medium objects", { ...@@ -31,7 +30,6 @@ test_that("read_in works for medium objects", {
"flow_free_expansion.prj", package = "r2ogs6")) "flow_free_expansion.prj", package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "sim", ogs6_obj <- OGS6$new(sim_name = "sim",
sim_id = 1,
sim_path = "sim_path") sim_path = "sim_path")
read_in(ogs6_obj, read_in(ogs6_obj,
...@@ -48,7 +46,6 @@ test_that("read_in works for time_loop objects", { ...@@ -48,7 +46,6 @@ test_that("read_in works for time_loop objects", {
"flow_free_expansion.prj", package = "r2ogs6")) "flow_free_expansion.prj", package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "sim", ogs6_obj <- OGS6$new(sim_name = "sim",
sim_id = 1,
sim_path = "sim_path") sim_path = "sim_path")
read_in(ogs6_obj, read_in(ogs6_obj,
...@@ -68,7 +65,6 @@ test_that("read_in works for parameter objects", { ...@@ -68,7 +65,6 @@ test_that("read_in works for parameter objects", {
"flow_free_expansion.prj", package = "r2ogs6")) "flow_free_expansion.prj", package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "sim", ogs6_obj <- OGS6$new(sim_name = "sim",
sim_id = 1,
sim_path = "sim_path") sim_path = "sim_path")
read_in(ogs6_obj, read_in(ogs6_obj,
...@@ -87,7 +83,6 @@ test_that("read_in works for process_variable objects", { ...@@ -87,7 +83,6 @@ test_that("read_in works for process_variable objects", {
"flow_free_expansion.prj", package = "r2ogs6")) "flow_free_expansion.prj", package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "sim", ogs6_obj <- OGS6$new(sim_name = "sim",
sim_id = 1,
sim_path = "sim_path") sim_path = "sim_path")
read_in(ogs6_obj, read_in(ogs6_obj,
...@@ -103,7 +98,6 @@ test_that("read_in works for nonlinear_solver objects", { ...@@ -103,7 +98,6 @@ test_that("read_in works for nonlinear_solver objects", {
"flow_free_expansion.prj", package = "r2ogs6")) "flow_free_expansion.prj", package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "sim", ogs6_obj <- OGS6$new(sim_name = "sim",
sim_id = 1,
sim_path = "sim_path") sim_path = "sim_path")
read_in(ogs6_obj, read_in(ogs6_obj,
...@@ -125,7 +119,6 @@ test_that("read_in works for linear_solver objects", { ...@@ -125,7 +119,6 @@ test_that("read_in works for linear_solver objects", {
"flow_free_expansion.prj", package = "r2ogs6")) "flow_free_expansion.prj", package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "sim", ogs6_obj <- OGS6$new(sim_name = "sim",
sim_id = 1,
sim_path = "sim_path") sim_path = "sim_path")
read_in(ogs6_obj, read_in(ogs6_obj,
...@@ -146,7 +139,6 @@ test_that("read_in works with newline value separation", { ...@@ -146,7 +139,6 @@ test_that("read_in works with newline value separation", {
"liakopoulos.prj", package = "r2ogs6")) "liakopoulos.prj", package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "sim", ogs6_obj <- OGS6$new(sim_name = "sim",
sim_id = 1,
sim_path = "sim_path") sim_path = "sim_path")
read_in(ogs6_obj, read_in(ogs6_obj,
...@@ -167,7 +159,6 @@ test_that("read_in_prj works for processes/include tags", { ...@@ -167,7 +159,6 @@ test_that("read_in_prj works for processes/include tags", {
"circle_1e1_axi.prj", package = "r2ogs6")) "circle_1e1_axi.prj", package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "sim", ogs6_obj <- OGS6$new(sim_name = "sim",
sim_id = 1,
sim_path = "sim_path") sim_path = "sim_path")
read_in_prj(ogs6_obj, read_in_prj(ogs6_obj,
...@@ -185,7 +176,6 @@ test_that("read_in_prj works for EmbeddedFracturePermeability/cube.prj", { ...@@ -185,7 +176,6 @@ test_that("read_in_prj works for EmbeddedFracturePermeability/cube.prj", {
"cube.prj", package = "r2ogs6")) "cube.prj", package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "sim", ogs6_obj <- OGS6$new(sim_name = "sim",
sim_id = 1,
sim_path = "sim_path") sim_path = "sim_path")
read_in_prj(ogs6_obj, read_in_prj(ogs6_obj,
......
...@@ -6,7 +6,6 @@ test_that("node_to_object works for simple r2ogs6 classes", { ...@@ -6,7 +6,6 @@ test_that("node_to_object works for simple r2ogs6 classes", {
"flow_free_expansion.prj", package = "r2ogs6")) "flow_free_expansion.prj", package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "sim", ogs6_obj <- OGS6$new(sim_name = "sim",
sim_id = 1,
sim_path = "sim_path") sim_path = "sim_path")
read_in(ogs6_obj, prj_path, "/OpenGeoSysProject/parameters/parameter") read_in(ogs6_obj, prj_path, "/OpenGeoSysProject/parameters/parameter")
......
...@@ -62,7 +62,6 @@ test_that("ogs_export_sim_files works", { ...@@ -62,7 +62,6 @@ test_that("ogs_export_sim_files works", {
"circle_1e1_axi.prj", package = "r2ogs6")) "circle_1e1_axi.prj", package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "circle_1e1_axi", ogs6_obj <- OGS6$new(sim_name = "circle_1e1_axi",
sim_id = 1,
sim_path = test_path) sim_path = test_path)
read_in_prj(ogs6_obj, read_in_prj(ogs6_obj,
......
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