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

[tests] Modified some tests to fit new classes

parent 1f809676
No related branches found
No related tags found
4 merge requests!57 vtkdiff,!47 parameter,!37 process borehole heat exchanger,!2Basic import and export functionality
...@@ -94,26 +94,15 @@ test_that("to_node works for simple classes", { ...@@ -94,26 +94,15 @@ test_that("to_node works for simple classes", {
test_that("to_node works for classes that have lists as parameters", { test_that("to_node works for classes that have lists as parameters", {
linear_solver <- r2ogs6_linear_solver( insitu <- r2ogs6_insitu(c("script_1",
name = "general_linear_solver", "script_2",
eigen = list( "script_3"))
solver_type = "BiCGSTAB",
precon_type = "ILUT",
max_iteration_step = 10000,
error_tolerance = 1e-16
),
lis = "-i bicgstab -p ilu -tol 1e-16 -maxiter 10000"
)
linear_solver_node <- to_node(linear_solver) insitu_node <- to_node(insitu)
linear_solver_xml <- xml2::as_xml_document(linear_solver_node) insitu_xml <- xml2::as_xml_document(insitu_node)
expect_equal(length(xml2::xml_find_all(linear_solver_xml, expect_equal(length(xml2::xml_find_all(insitu_xml,
"/linear_solver/eigen/*")), 4) "/insitu/scripts/*")), 3)
expect_equal(xml2::xml_text(
xml2::xml_find_all(linear_solver_xml,
"/linear_solver/eigen/precon_type")),
"ILUT")
}) })
...@@ -155,7 +144,7 @@ test_that("to_node works for classes that have attributes", { ...@@ -155,7 +144,7 @@ test_that("to_node works for classes that have attributes", {
tl_process <- r2ogs6_tl_process( tl_process <- r2ogs6_tl_process(
ref = "HM", ref = "HM",
nonlinear_solver = "basic_newton", nonlinear_solver = "basic_newton",
convergence_criterion = list( convergence_criterion = r2ogs6_convergence_criterion(
type = "PerComponentDeltaX", type = "PerComponentDeltaX",
norm_type = "NORM2", norm_type = "NORM2",
reltols = "5e-8 1e10 1e10" reltols = "5e-8 1e10 1e10"
......
...@@ -24,7 +24,8 @@ test_that("construct_add_call works", { ...@@ -24,7 +24,8 @@ test_that("construct_add_call works", {
expect_equal(ogs_param_call, paste0("ogs6_obj$add_parameter(", expect_equal(ogs_param_call, paste0("ogs6_obj$add_parameter(",
"r2ogs6_parameter(name = \"a\",\n", "r2ogs6_parameter(name = \"a\",\n",
"type = \"t\",\n", "type = \"t\",\n",
"values = c(0, 1)))\n")) "values = c(0, 1),\n",
"value = NULL))\n"))
ogs_mesh <- r2ogs6_mesh("my_mesh") ogs_mesh <- r2ogs6_mesh("my_mesh")
ogs_mesh_call <- construct_add_call(ogs_mesh) ogs_mesh_call <- construct_add_call(ogs_mesh)
......
test_that("flags_to_str works", { test_that("flags_to_con_str works", {
flags <- c(a = TRUE, b = TRUE, c = FALSE) flags <- c(a = TRUE, b = TRUE, c = FALSE)
str <- flags_to_str(flags) str <- flags_to_con_str(flags)
expect_equal(str, "a, b, c = NULL") expect_equal(str, "a,\nb,\nc = NULL")
}) })
...@@ -37,19 +37,3 @@ test_that("new_r2ogs6_time_loop basic validation is working", { ...@@ -37,19 +37,3 @@ test_that("new_r2ogs6_time_loop basic validation is working", {
) )
}) })
test_that("new_r2ogs6_tl_process basic validation is working", {
})
test_that("new_r2ogs6_tl_output basic validation is working", {
})
#processes test_that("read_in works for process objects", {
prj_path <- (system.file("extdata/flow_free_expansion",
"flow_free_expansion.prj", package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "sim",
sim_id = 1,
sim_path = "sim_path",
ogs_bin_path = "ogs_bin_path",
test_mode = TRUE)
read_in(ogs6_obj,
prj_path,
"/OpenGeoSysProject/processes/process")
expect_equal(length(ogs6_obj$processes), 1)
})
...@@ -15,9 +31,9 @@ test_that("read_in works for medium objects", { ...@@ -15,9 +31,9 @@ test_that("read_in works for medium objects", {
ogs_bin_path = "ogs_bin_path", ogs_bin_path = "ogs_bin_path",
test_mode = TRUE) test_mode = TRUE)
read_in(ogs6_obj, prj_path, "media", "medium", read_in(ogs6_obj,
subclasses_names = c(phase = "r2ogs6_medium_phase", prj_path,
property = "r2ogs6_medium_property")) "/OpenGeoSysProject/media/medium")
expect_equal(length(ogs6_obj$media), 1) expect_equal(length(ogs6_obj$media), 1)
}) })
...@@ -34,12 +50,9 @@ test_that("read_in works for time_loop objects", { ...@@ -34,12 +50,9 @@ test_that("read_in works for time_loop objects", {
ogs_bin_path = "ogs_bin_path", ogs_bin_path = "ogs_bin_path",
test_mode = TRUE) test_mode = TRUE)
read_in(ogs6_obj, prj_path, "time_loop", "time_loop", read_in(ogs6_obj,
subclasses_names = prj_path,
c(process = "r2ogs6_tl_process", "/OpenGeoSysProject/time_loop")
output = "r2ogs6_tl_output",
global_processes_coupling =
"r2ogs6_global_processes_coupling"))
expect_equal(is.null(ogs6_obj$time_loop), FALSE) expect_equal(is.null(ogs6_obj$time_loop), FALSE)
}) })
...@@ -56,12 +69,14 @@ test_that("read_in works for parameter objects", { ...@@ -56,12 +69,14 @@ test_that("read_in works for parameter objects", {
ogs_bin_path = "ogs_bin_path", ogs_bin_path = "ogs_bin_path",
test_mode = TRUE) test_mode = TRUE)
read_in(ogs6_obj, prj_path, "parameters", "parameter") read_in(ogs6_obj,
prj_path,
"/OpenGeoSysProject/parameters/parameter")
expect_equal(length(ogs6_obj$parameters), 7) expect_equal(length(ogs6_obj$parameters), 7)
expect_equal(ogs6_obj$parameters[[1]]$name, "E") expect_equal(ogs6_obj$parameters[[1]]$name, "E")
expect_equal(ogs6_obj$parameters[[1]]$type, "Constant") expect_equal(ogs6_obj$parameters[[1]]$type, "Constant")
expect_equal(ogs6_obj$parameters[[1]]$values, 10e9) expect_equal(ogs6_obj$parameters[[1]]$value, 10e9)
}) })
test_that("read_in works for process_variable objects", { test_that("read_in works for process_variable objects", {
...@@ -75,9 +90,9 @@ test_that("read_in works for process_variable objects", { ...@@ -75,9 +90,9 @@ test_that("read_in works for process_variable objects", {
ogs_bin_path = "ogs_bin_path", ogs_bin_path = "ogs_bin_path",
test_mode = TRUE) test_mode = TRUE)
read_in(ogs6_obj, prj_path, "process_variables", "process_variable", read_in(ogs6_obj,
subclasses_names = c(boundary_condition = prj_path,
"r2ogs6_boundary_condition")) "/OpenGeoSysProject/process_variables/process_variable")
expect_equal(length(ogs6_obj$process_variables), 2) expect_equal(length(ogs6_obj$process_variables), 2)
}) })
...@@ -93,13 +108,16 @@ test_that("read_in works for nonlinear_solver objects", { ...@@ -93,13 +108,16 @@ test_that("read_in works for nonlinear_solver objects", {
ogs_bin_path = "ogs_bin_path", ogs_bin_path = "ogs_bin_path",
test_mode = TRUE) test_mode = TRUE)
read_in(ogs6_obj, prj_path, "nonlinear_solvers", "nonlinear_solver") read_in(ogs6_obj,
prj_path,
"/OpenGeoSysProject/nonlinear_solvers/nonlinear_solver")
expect_equal(length(ogs6_obj$nonlinear_solvers), 1) expect_equal(length(ogs6_obj$nonlinear_solvers), 1)
expect_equal(ogs6_obj$nonlinear_solvers[[1]]$name, "basic_newton") expect_equal(ogs6_obj$nonlinear_solvers[[1]]$name, "basic_newton")
expect_equal(ogs6_obj$nonlinear_solvers[[1]]$type, "Newton") expect_equal(ogs6_obj$nonlinear_solvers[[1]]$type, "Newton")
expect_equal(ogs6_obj$nonlinear_solvers[[1]]$max_iter, 50) expect_equal(ogs6_obj$nonlinear_solvers[[1]]$max_iter, 50)
expect_equal(ogs6_obj$nonlinear_solvers[[1]]$linear_solver, "general_linear_solver") expect_equal(ogs6_obj$nonlinear_solvers[[1]]$linear_solver,
"general_linear_solver")
}) })
...@@ -114,13 +132,13 @@ test_that("read_in works for linear_solver objects", { ...@@ -114,13 +132,13 @@ test_that("read_in works for linear_solver objects", {
ogs_bin_path = "ogs_bin_path", ogs_bin_path = "ogs_bin_path",
test_mode = TRUE) test_mode = TRUE)
read_in(ogs6_obj, prj_path, "linear_solvers", "linear_solver") read_in(ogs6_obj,
prj_path,
"/OpenGeoSysProject/linear_solvers/linear_solver")
expect_equal(length(ogs6_obj$linear_solvers), 1) expect_equal(length(ogs6_obj$linear_solvers), 1)
expect_equal(ogs6_obj$linear_solvers[[1]]$name, "general_linear_solver") expect_equal(ogs6_obj$linear_solvers[[1]]$name, "general_linear_solver")
expect_equal(ogs6_obj$linear_solvers[[1]]$lis, "-i bicgstab -p ilu -tol 1e-16 -maxiter 10000") expect_equal(ogs6_obj$linear_solvers[[1]]$lis,
expect_equal(ogs6_obj$linear_solvers[[1]]$eigen, list(solver_type = "BiCGSTAB", "-i bicgstab -p ilu -tol 1e-16 -maxiter 10000")
precon_type = "ILUT", expect_equal(ogs6_obj$linear_solvers[[1]]$eigen$error_tolerance, 1e-16)
max_iteration_step = 10000,
error_tolerance = 1e-16))
}) })
...@@ -18,12 +18,12 @@ test_that("guess_structure works", { ...@@ -18,12 +18,12 @@ test_that("guess_structure works", {
ogs_bin_path = "ogs_bin_path", ogs_bin_path = "ogs_bin_path",
test_mode = TRUE) test_mode = TRUE)
read_in(ogs6_obj, prj_path, "parameters", "parameter") read_in(ogs6_obj, prj_path, "/OpenGeoSysProject/parameters/parameter")
expect_equal(length(ogs6_obj$parameters), 7) expect_equal(length(ogs6_obj$parameters), 7)
expect_equal(ogs6_obj$parameters[[1]]$name, "E") expect_equal(ogs6_obj$parameters[[1]]$name, "E")
expect_equal(ogs6_obj$parameters[[1]]$type, "Constant") expect_equal(ogs6_obj$parameters[[1]]$type, "Constant")
expect_equal(ogs6_obj$parameters[[1]]$values, 10e9) expect_equal(ogs6_obj$parameters[[1]]$value, 10e9)
}) })
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
test_that("download_benchmark works", { test_that("download_benchmark works", {
path <- paste0(system.file("extdata/benchmarks/", package = "r2ogs6"), "/") path <- system.file("extdata/benchmarks/", package = "r2ogs6")
download_benchmark( download_benchmark(
prj_url = paste0("https://gitlab.opengeosys.org/ogs/ogs/-/raw/master/", prj_url = paste0("https://gitlab.opengeosys.org/ogs/ogs/-/raw/master/",
......
test_that("select_fitting_subclass works for medium objects", {
subclass_names <- get_subclass_names("r2ogs6_medium")
for(i in seq_len(length(subclass_names))){
names(subclass_names)[[i]] <-
get_class_tag_name(subclass_names[[i]])
}
subclass_name <-
select_fitting_subclass("phase/properties/property",
subclass_names)
expect_equal(subclass_name, "r2ogs6_ph_property")
})
test_that("select_fitting_subclass works for linear_solver objects", {
subclass_names <- get_subclass_names("r2ogs6_linear_solver")
for(i in seq_len(length(subclass_names))){
names(subclass_names)[[i]] <-
get_class_tag_name(subclass_names[[i]])
}
subclass_name <-
select_fitting_subclass("linear_solvers/linear_solver/eigen",
subclass_names)
expect_equal(subclass_name, "r2ogs6_eigen")
})
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