diff --git a/tests/testthat/test-export_prj.R b/tests/testthat/test-export_prj.R index c49bf688fd5cc421c028db0b7a2ed42c3d146789..51ee0905596aefa4e7791ee7181654d38847a902 100644 --- a/tests/testthat/test-export_prj.R +++ b/tests/testthat/test-export_prj.R @@ -8,7 +8,6 @@ test_that("export_prj works", { # Define prj_path and OGS6 object, then read in .prj file ogs6_obj <- OGS6$new(sim_name = "flow_free_expansion", - sim_id = 1, sim_path = test_path) diff --git a/tests/testthat/test-ogs6.R b/tests/testthat/test-ogs6.R index 9b1d820f55493d9bb55a959746d767fff6e7bb2a..d18113e9800fb184e3fe052ce7d525b3ad9e9902 100644 --- a/tests/testthat/test-ogs6.R +++ b/tests/testthat/test-ogs6.R @@ -5,7 +5,6 @@ test_that("OGS6$clear() works as expected", { ogs6_obj <- OGS6$new( sim_name = "sim", - sim_id = 1, sim_path = "sim_path") ogs6_obj$add(r2ogs6_parameter( @@ -24,7 +23,6 @@ test_that("OGS6$add() works", { ogs6_obj <- OGS6$new( sim_name = "sim", - sim_id = 1, sim_path = "sim_path") ogs6_obj$add(r2ogs6_parameter( diff --git a/tests/testthat/test-ogs6_ensemble.R b/tests/testthat/test-ogs6_ensemble.R index 9c90c510fa632a18809c5e9993a43d0ccd90f78a..304af142e39dc4e06b20cac82847b3c6d388c5f1 100644 --- a/tests/testthat/test-ogs6_ensemble.R +++ b/tests/testthat/test-ogs6_ensemble.R @@ -5,7 +5,6 @@ test_that("OGS6_Ensemble initialization works", { ogs6_obj <- OGS6$new( sim_name = "sim", - sim_id = 1, sim_path = "sim_path") ogs6_obj$add(r2ogs6_parameter( diff --git a/tests/testthat/test-gml.R b/tests/testthat/test-ogs6_gml.R similarity index 85% rename from tests/testthat/test-gml.R rename to tests/testthat/test-ogs6_gml.R index 1840cb0b4125175641693edeaa75d1efe25d4d05..e3536f7002fecb1f2dc0d8860ce230cecc306e83 100644 --- a/tests/testthat/test-gml.R +++ b/tests/testthat/test-ogs6_gml.R @@ -1,3 +1,17 @@ + + +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", { point_list <- list(x = c(0, 0), y = c(1, 1), z = c(0, 1)) @@ -66,4 +80,4 @@ test_that("validate_surfaces works", { expect_error(validate_surfaces(surface_tibble)) #...(WIP) -}) \ No newline at end of file +}) diff --git a/tests/testthat/test-ogs6_pvd.R b/tests/testthat/test-ogs6_pvd.R new file mode 100644 index 0000000000000000000000000000000000000000..8aa68814d6aac8fba51936700186d962bca4ad9d --- /dev/null +++ b/tests/testthat/test-ogs6_pvd.R @@ -0,0 +1,97 @@ + + +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) +}) diff --git a/tests/testthat/test-vtu.R b/tests/testthat/test-ogs6_vtu.R similarity index 54% rename from tests/testthat/test-vtu.R rename to tests/testthat/test-ogs6_vtu.R index 91326498dd6c9a0ff833ef5a1dd0738e1c9a8006..84e052081f2d1823bace1fc0df7ae6f124e5ec3c 100644 --- a/tests/testthat/test-vtu.R +++ b/tests/testthat/test-ogs6_vtu.R @@ -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 ===== @@ -169,13 +69,13 @@ test_that("OGS6_vtu$get_point_data_at() works", { vtu_obj <- OGS6_vtu$new(vtu_path = vtu_path) 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) bigger_tbl <- vtu_obj$get_point_data_at(list(c(0.01, 0, 0), c(0.42, 0, 0)), - Names = "epsilon_xx") + keys = "epsilon_xx") expect_equal(bigger_tbl$epsilon_xx[[2]], 1.233661e-16) }) diff --git a/tests/testthat/test-read_in_prj.R b/tests/testthat/test-read_in_prj.R index 8acb7b2315c417037d21b169513caba192676279..69613515b1e29f760443078a35aadee59eb2f9a2 100644 --- a/tests/testthat/test-read_in_prj.R +++ b/tests/testthat/test-read_in_prj.R @@ -6,7 +6,6 @@ test_that("read_in works for process objects", { "flow_free_expansion.prj", package = "r2ogs6")) ogs6_obj <- OGS6$new(sim_name = "sim", - sim_id = 1, sim_path = "sim_path") read_in(ogs6_obj, @@ -31,7 +30,6 @@ test_that("read_in works for medium objects", { "flow_free_expansion.prj", package = "r2ogs6")) ogs6_obj <- OGS6$new(sim_name = "sim", - sim_id = 1, sim_path = "sim_path") read_in(ogs6_obj, @@ -48,7 +46,6 @@ test_that("read_in works for time_loop objects", { "flow_free_expansion.prj", package = "r2ogs6")) ogs6_obj <- OGS6$new(sim_name = "sim", - sim_id = 1, sim_path = "sim_path") read_in(ogs6_obj, @@ -68,7 +65,6 @@ test_that("read_in works for parameter objects", { "flow_free_expansion.prj", package = "r2ogs6")) ogs6_obj <- OGS6$new(sim_name = "sim", - sim_id = 1, sim_path = "sim_path") read_in(ogs6_obj, @@ -87,7 +83,6 @@ test_that("read_in works for process_variable objects", { "flow_free_expansion.prj", package = "r2ogs6")) ogs6_obj <- OGS6$new(sim_name = "sim", - sim_id = 1, sim_path = "sim_path") read_in(ogs6_obj, @@ -103,7 +98,6 @@ test_that("read_in works for nonlinear_solver objects", { "flow_free_expansion.prj", package = "r2ogs6")) ogs6_obj <- OGS6$new(sim_name = "sim", - sim_id = 1, sim_path = "sim_path") read_in(ogs6_obj, @@ -125,7 +119,6 @@ test_that("read_in works for linear_solver objects", { "flow_free_expansion.prj", package = "r2ogs6")) ogs6_obj <- OGS6$new(sim_name = "sim", - sim_id = 1, sim_path = "sim_path") read_in(ogs6_obj, @@ -146,7 +139,6 @@ test_that("read_in works with newline value separation", { "liakopoulos.prj", package = "r2ogs6")) ogs6_obj <- OGS6$new(sim_name = "sim", - sim_id = 1, sim_path = "sim_path") read_in(ogs6_obj, @@ -167,7 +159,6 @@ test_that("read_in_prj works for processes/include tags", { "circle_1e1_axi.prj", package = "r2ogs6")) ogs6_obj <- OGS6$new(sim_name = "sim", - sim_id = 1, sim_path = "sim_path") read_in_prj(ogs6_obj, @@ -185,7 +176,6 @@ test_that("read_in_prj works for EmbeddedFracturePermeability/cube.prj", { "cube.prj", package = "r2ogs6")) ogs6_obj <- OGS6$new(sim_name = "sim", - sim_id = 1, sim_path = "sim_path") read_in_prj(ogs6_obj, diff --git a/tests/testthat/test-read_in_utils.R b/tests/testthat/test-read_in_utils.R index 699aef8faa322aeb97c7d5758fd755bce3adefd1..d0e8f4c5d3d64a6b2111bb51c98614bfdc410d58 100644 --- a/tests/testthat/test-read_in_utils.R +++ b/tests/testthat/test-read_in_utils.R @@ -6,7 +6,6 @@ test_that("node_to_object works for simple r2ogs6 classes", { "flow_free_expansion.prj", package = "r2ogs6")) ogs6_obj <- OGS6$new(sim_name = "sim", - sim_id = 1, sim_path = "sim_path") read_in(ogs6_obj, prj_path, "/OpenGeoSysProject/parameters/parameter") diff --git a/tests/testthat/test-sim_utils.R b/tests/testthat/test-sim_utils.R index 91741ee9a508604c23ff038e745dd8d9e32cdd17..32ce99f2ad8d227690a5f8b5d3ada08a0045c8ed 100644 --- a/tests/testthat/test-sim_utils.R +++ b/tests/testthat/test-sim_utils.R @@ -62,7 +62,6 @@ test_that("ogs_export_sim_files works", { "circle_1e1_axi.prj", package = "r2ogs6")) ogs6_obj <- OGS6$new(sim_name = "circle_1e1_axi", - sim_id = 1, sim_path = test_path) read_in_prj(ogs6_obj,