diff --git a/DESCRIPTION b/DESCRIPTION index e025ca395c2b4aefbf6569a3c2be3268d98a6101..f005b065ef6d82ebc94504f9b64e641d0a20e2b4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -38,7 +38,8 @@ Imports: dplyr, rlang, doParallel, - stats + stats, + reticulate RoxygenNote: 7.1.1 VignetteBuilder: knitr Depends: diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000000000000000000000000000000000000..aa75c7c29e605ae7a889c9a8ded09cade07101c9 --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,54 @@ +# Generated by roxygen2: do not edit by hand + +export(OGS6) +export(OGS6_Chain) +export(OGS6_Ensemble) +export(OGS6_gml) +export(OGS6_pvd) +export(OGS6_vtu) +export(generate_benchmark_script) +export(generate_structured_mesh) +export(r2ogs6_borehole_heat_exchanger) +export(r2ogs6_boundary_condition) +export(r2ogs6_capillary_pressure) +export(r2ogs6_chemical_system) +export(r2ogs6_com_property) +export(r2ogs6_component) +export(r2ogs6_convergence_criterion) +export(r2ogs6_curve) +export(r2ogs6_deactivated_subdomain) +export(r2ogs6_eigen) +export(r2ogs6_flow_and_temperature_control) +export(r2ogs6_fluid) +export(r2ogs6_fracture_model) +export(r2ogs6_fracture_properties) +export(r2ogs6_global_process_coupling) +export(r2ogs6_insitu) +export(r2ogs6_jacobian_assembler) +export(r2ogs6_kinetic_reactant) +export(r2ogs6_linear_solver) +export(r2ogs6_local_coordinate_system) +export(r2ogs6_material_property) +export(r2ogs6_medium) +export(r2ogs6_nonlinear_solver) +export(r2ogs6_output) +export(r2ogs6_parameter) +export(r2ogs6_ph_property) +export(r2ogs6_phase) +export(r2ogs6_phase_component) +export(r2ogs6_phasefield_parameters) +export(r2ogs6_pipes) +export(r2ogs6_porous_medium) +export(r2ogs6_process) +export(r2ogs6_process_variable) +export(r2ogs6_rate) +export(r2ogs6_search_length_algorithm) +export(r2ogs6_solution) +export(r2ogs6_source_term) +export(r2ogs6_time_loop) +export(r2ogs6_time_stepping) +export(r2ogs6_tl_process) +export(r2ogs6_vtkdiff) +export(read_in_prj) +export(run_simulation) +importFrom(foreach,"%dopar%") diff --git a/R/utils.R b/R/utils.R index 70f719f485fcfe0721120bdd57ec269d882dff1e..290294861e8e82aa260d4fabc57c9603099618f2 100644 --- a/R/utils.R +++ b/R/utils.R @@ -205,18 +205,17 @@ get_nonstandard_tag_names <- function(){ } -#'get_implemented_classes -#'@description Returns class names (and variable names) of `OGS6` variables. -#' Change this if you implement new `OGS6` variables or delete old ones! -#' If you implement a new variable, you add the following the `class_names` -#' vector: `name_of_OGS6_variable = "name_of_your_class"` -#'@return character: Named vector containing class names of `OGS6` variables -#' and their corresponding variable name -get_implemented_classes <- function(){ - - class_names <- c(vtus = "OGS6_vtu", - gml = "r2ogs6_gml", - search_length_algorithm = "r2ogs6_search_length_algorithm", +#'addable_prj_components +#'@description Returns all possible `OGS6` top level .prj components (names) +#' along with their respective class names (values). +#' Change this if you implement new `OGS6` .prj components or delete old ones! +#' If you implement a new components, you add the following to the `class_names` +#' vector: `name_of_prj_component = "name_of_your_class"` +#'@return character: Named vector of `OGS6` top level .prj components (names) +#' along with their respective class names (values) +addable_prj_components <- function(){ + + class_names <- c(search_length_algorithm = "r2ogs6_search_length_algorithm", processes = "r2ogs6_process", media = "r2ogs6_medium", time_loop = "r2ogs6_time_loop", @@ -297,15 +296,15 @@ get_obj_status <- function(flag, obj){ #'@param ogs6_parameter_name string: Name of a OGS6 parameter is_optional_sim_component <- function(ogs6_parameter_name){ - optional_sim_components <- c("gml", - "vtus", - "local_coordinate_system", - "curves", - "search_length_algorithm", - "test_definition", - "insitu") + mandatory_components <- c("meshes", + "processes", + "time_loop", + "nonlinear_solvers", + "linear_solvers", + "parameters", + "process_variables") - return(invisible(ogs6_parameter_name %in% optional_sim_components)) + return(invisible(!ogs6_parameter_name %in% mandatory_components)) } @@ -313,23 +312,15 @@ is_optional_sim_component <- function(ogs6_parameter_name){ #'coerce_string_to_numeric -#'@description If an object is of type string, coerces it to a numeric type: -#' A double if 'split' is FALSE as per default, a numeric vector otherwise. -#' If 'split' is set to true the string will be split at ' ' (whitespace) -#' characters. +#'@description If an object is of type string, coerces it to a numeric type #'@param obj An object to check -#'@param split flag: Should object be split at ' ' (whitespace) if it is a -#' string? #'@return The object as a numeric type (if 'obj' was a string, else the #' unchanged 'obj') -coerce_string_to_numeric <- function(obj, split = FALSE){ +coerce_string_to_numeric <- function(obj){ if(assertthat::is.string(obj)){ - if(split){ - obj <- as.double(unlist(strsplit(obj, " "))) - }else{ - obj <- as.double(obj) - } + obj <- trimws(gsub("\r?\n|\r|\\s+", " ", obj)) + obj <- as.double(unlist(strsplit(obj, " "))) } return(invisible(obj)) diff --git a/man/OGS6_Piece.Rd b/man/OGS6_Piece.Rd deleted file mode 100644 index 1fd3722ad0c4ccfa9381d8a58e63890610a2a430..0000000000000000000000000000000000000000 --- a/man/OGS6_Piece.Rd +++ /dev/null @@ -1,90 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vtu.R -\name{OGS6_Piece} -\alias{OGS6_Piece} -\title{OGS6_Piece} -\description{ -Constructor for the OGS6_Piece base class -} -\section{Active bindings}{ -\if{html}{\out{<div class="r6-active-bindings">}} -\describe{ -\item{\code{NumberOfPoints}}{Access to private parameter '.NumberOfPoints'} - -\item{\code{NumberOfCells}}{Access to private parameter '.NumberOfCells'} - -\item{\code{PointData}}{Access to private parameter '.PointData'} - -\item{\code{Points}}{Access to private parameter '.Points'} - -\item{\code{Cells}}{Access to private parameter '.Cells'} - -\item{\code{CellData}}{Access to private parameter '.CellData'} - -\item{\code{is_subclass}}{Access to private parameter '.is_subclass'} - -\item{\code{subclasses_names}}{Access to private parameter '.subclasses_names'} - -\item{\code{attr_names}}{Access to private parameter '.attr_names'} -} -\if{html}{\out{</div>}} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-new}{\code{OGS6_Piece$new()}} -\item \href{#method-clone}{\code{OGS6_Piece$clone()}} -} -} -\if{html}{\out{<hr>}} -\if{html}{\out{<a id="method-new"></a>}} -\if{latex}{\out{\hypertarget{method-new}{}}} -\subsection{Method \code{new()}}{ -Creates new OGS6_Piece object -\subsection{Usage}{ -\if{html}{\out{<div class="r">}}\preformatted{OGS6_Piece$new( - NumberOfPoints, - NumberOfCells, - PointData, - Points, - Cells, - CellData = NULL -)}\if{html}{\out{</div>}} -} - -\subsection{Arguments}{ -\if{html}{\out{<div class="arguments">}} -\describe{ -\item{\code{NumberOfPoints}}{string | number:} - -\item{\code{NumberOfCells}}{string | number:} - -\item{\code{PointData}}{list, :} - -\item{\code{Points}}{list, :} - -\item{\code{Cells}}{list, :} - -\item{\code{CellData}}{list, : Optional:} -} -\if{html}{\out{</div>}} -} -} -\if{html}{\out{<hr>}} -\if{html}{\out{<a id="method-clone"></a>}} -\if{latex}{\out{\hypertarget{method-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{<div class="r">}}\preformatted{OGS6_Piece$clone(deep = FALSE)}\if{html}{\out{</div>}} -} - -\subsection{Arguments}{ -\if{html}{\out{<div class="arguments">}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{</div>}} -} -} -} diff --git a/man/OGS6_UnstructuredGrid.Rd b/man/OGS6_UnstructuredGrid.Rd deleted file mode 100644 index fb7689ffab2499427869d2bfc13df7b0806d49d1..0000000000000000000000000000000000000000 --- a/man/OGS6_UnstructuredGrid.Rd +++ /dev/null @@ -1,67 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vtu.R -\name{OGS6_UnstructuredGrid} -\alias{OGS6_UnstructuredGrid} -\title{OGS6_UnstructuredGrid} -\description{ -Constructor for the OGS6_UnstructuredGrid base class -} -\section{Active bindings}{ -\if{html}{\out{<div class="r6-active-bindings">}} -\describe{ -\item{\code{Piece}}{Access to private parameter '.Piece'} - -\item{\code{FieldData}}{Access to private parameter '.FieldData'} - -\item{\code{is_subclass}}{Access to private parameter '.is_subclass'} - -\item{\code{attr_names}}{Access to private parameter '.attr_names'} - -\item{\code{flatten_on_exp}}{Access to private parameter '.flatten_on_exp'} -} -\if{html}{\out{</div>}} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-new}{\code{OGS6_UnstructuredGrid$new()}} -\item \href{#method-clone}{\code{OGS6_UnstructuredGrid$clone()}} -} -} -\if{html}{\out{<hr>}} -\if{html}{\out{<a id="method-new"></a>}} -\if{latex}{\out{\hypertarget{method-new}{}}} -\subsection{Method \code{new()}}{ -Creates new OGS6_UnstructuredGrid object -\subsection{Usage}{ -\if{html}{\out{<div class="r">}}\preformatted{OGS6_UnstructuredGrid$new(Piece, FieldData = NULL)}\if{html}{\out{</div>}} -} - -\subsection{Arguments}{ -\if{html}{\out{<div class="arguments">}} -\describe{ -\item{\code{Piece}}{OGS6_Piece:} - -\item{\code{FieldData}}{character, length == 2: Optional:} -} -\if{html}{\out{</div>}} -} -} -\if{html}{\out{<hr>}} -\if{html}{\out{<a id="method-clone"></a>}} -\if{latex}{\out{\hypertarget{method-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{<div class="r">}}\preformatted{OGS6_UnstructuredGrid$clone(deep = FALSE)}\if{html}{\out{</div>}} -} - -\subsection{Arguments}{ -\if{html}{\out{<div class="arguments">}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{</div>}} -} -} -} diff --git a/man/check_file_extension.Rd b/man/check_file_extension.Rd deleted file mode 100644 index 81991257084f8c17f3cba2e98a950c4ccc0432b7..0000000000000000000000000000000000000000 --- a/man/check_file_extension.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_utils.R -\name{check_file_extension} -\alias{check_file_extension} -\title{check_file_extension} -\usage{ -check_file_extension(file, expected_extension) -} -\arguments{ -\item{file}{A file} - -\item{expected_extension}{The expected file extension} -} -\description{ -Helper function to check the extension of a file -} diff --git a/man/decode_appended_data.Rd b/man/decode_appended_data.Rd deleted file mode 100644 index 5b47001344f6bab47aebcf8eb7100fb3bc505f3c..0000000000000000000000000000000000000000 --- a/man/decode_appended_data.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_vtu.R -\name{decode_appended_data} -\alias{decode_appended_data} -\title{decode_appended_data} -\usage{ -decode_appended_data(appended_data, compressor = "") -} -\arguments{ -\item{appended_data}{character: AppendedData} - -\item{compressor}{string: Optional: How the data was compressed, this is the -`compressor` attribute of *VTKFile*} -} -\value{ -list: DataArrays with `data` element which is the decoded data -} -\description{ -Decodes AppendedData -} diff --git a/man/get_implemented_classes.Rd b/man/get_implemented_classes.Rd deleted file mode 100644 index 773b2a2dc43ff09d6ea69bdbbb937aa7a03d5a2d..0000000000000000000000000000000000000000 --- a/man/get_implemented_classes.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{get_implemented_classes} -\alias{get_implemented_classes} -\title{get_implemented_classes} -\usage{ -get_implemented_classes() -} -\description{ -Utility function, returns the names of all classes implemented -so far. Change this if you implement new classes or delete old ones! -If you implement a new class, you add the following to the character vector: -<name_of_corresponding_OGS6_parameter> = <name_of_your_class> -} diff --git a/man/get_valid_vtu_categories.Rd b/man/get_valid_vtu_categories.Rd deleted file mode 100644 index 9cda3000f81068d1d14f0eb103ce5da8da2219c7..0000000000000000000000000000000000000000 --- a/man/get_valid_vtu_categories.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{get_valid_vtu_categories} -\alias{get_valid_vtu_categories} -\title{get_valid_vtu_categories} -\usage{ -get_valid_vtu_categories() -} -\value{ -character: `OGS6_vtu` categories -} -\description{ -Returns all valid `OGS6_vtu` categories. -} diff --git a/man/get_vtu_data_arrays_from_file.Rd b/man/get_vtu_data_arrays_from_file.Rd deleted file mode 100644 index f812aaa72b0aa505b20057b61e024e57e0e8018a..0000000000000000000000000000000000000000 --- a/man/get_vtu_data_arrays_from_file.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_vtu.R -\name{get_vtu_data_arrays_from_file} -\alias{get_vtu_data_arrays_from_file} -\title{get_vtu_data_arrays_from_file} -\usage{ -get_vtu_data_arrays_from_file( - vtu_path, - Names = character(), - categories = character() -) -} -\arguments{ -\item{vtu_path}{string: .vtu file path} - -\item{Names}{character: Optional: Select `DataArray` elements by `Name` -attribute} - -\item{categories}{character: Optional: One or more of `FieldData`, `PointData`, -`CellData`, `Points` or `Cells`. If left empty, will get `DataArray` -elements from whole XML document.} -} -\description{ -Reads DataArray elements from a .vtu file -} diff --git a/man/guess_structure.Rd b/man/guess_structure.Rd deleted file mode 100644 index cd3ac7427c4f1671ba8a471393f28ba36c3abb67..0000000000000000000000000000000000000000 --- a/man/guess_structure.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_utils.R -\name{guess_structure} -\alias{guess_structure} -\title{guess_structure} -\usage{ -guess_structure(xml_node, xpath_expr, subclasses_names = character()) -} -\arguments{ -\item{xml_node}{xml2::xml_node: XML node} - -\item{xpath_expr}{string: XPath expression (for subclass differentiation)} - -\item{subclasses_names}{Optional: character: Names of r2ogs6 subclasses -(r2ogs6 classes without a OGS6$add method)} -} -\description{ -Guesses the R representation of an XML node and adds it to -parameter list. This is a recursive function. -ASSUMPTIONS: -1) Leaf nodes will have EITHER a value OR attributes (and will not be missing -both, e.g. '<a/>'). -2) Leaf nodes will never be r2ogs6_* objects -3) If there are multiple occurrences of r2ogs6_* class (and subclass) -elements on the same level, they have a wrapper node as their parent -(e.g. <processes>, <properties>) which will contain ONLY elements of this -type -4) Wrapper nodes are represented as lists -5) Parent nodes whose children have no children are represented as lists -} diff --git a/man/new_r2ogs6_gml.Rd b/man/new_r2ogs6_gml.Rd deleted file mode 100644 index b1f6c9d4da36c6721577fbcbe03d66255678d3c4..0000000000000000000000000000000000000000 --- a/man/new_r2ogs6_gml.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gml.R -\name{new_r2ogs6_gml} -\alias{new_r2ogs6_gml} -\title{new_r2ogs6_gml} -\usage{ -new_r2ogs6_gml(name, points, polylines = NULL, surfaces = NULL) -} -\arguments{ -\item{name}{The name of the geometry} - -\item{points}{A tibble of points} - -\item{polylines}{Optional: A list of polylines} - -\item{surfaces}{Optional: A list of surfaces} -} -\description{ -Constructor for S3 class new_r2ogs6_gml -} diff --git a/man/node_to_r2ogs6_obj.Rd b/man/node_to_r2ogs6_obj.Rd deleted file mode 100644 index 28de1eb9c003bb73fd0fa7471765d0cc8f876370..0000000000000000000000000000000000000000 --- a/man/node_to_r2ogs6_obj.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_utils.R -\name{node_to_r2ogs6_obj} -\alias{node_to_r2ogs6_obj} -\title{node_to_r2ogs6_obj} -\usage{ -node_to_r2ogs6_obj(xml_node, xpath_expr, subclasses_names = character()) -} -\arguments{ -\item{xml_node}{An XML node (of class xml2::xml_node)} - -\item{xpath_expr}{An XPath expression (for subclass differentiation)} - -\item{subclasses_names}{Optional: A character vector containing the names of -r2ogs6 subclasses (r2ogs6 classes without a method for input_add)} -} -\description{ -Takes an XML node and turns it into a class object -} diff --git a/man/r2ogs6_gml.Rd b/man/r2ogs6_gml.Rd deleted file mode 100644 index d76c3e92d8b2e8405f9ad54986825fcd31b99e17..0000000000000000000000000000000000000000 --- a/man/r2ogs6_gml.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gml.R -\name{r2ogs6_gml} -\alias{r2ogs6_gml} -\title{r2ogs6_gml} -\usage{ -r2ogs6_gml(name, points, polylines = NULL, surfaces = NULL) -} -\arguments{ -\item{name}{The name of the geometry} - -\item{points}{A tibble of points} - -\item{polylines}{Optional: A list of polylines} - -\item{surfaces}{Optional: A list of surfaces} -} -\description{ -S3 class describing the .gml file -} diff --git a/man/read_in_gml.Rd b/man/read_in_gml.Rd deleted file mode 100644 index 809f0a9d2cbd1d63b8d78d3e8b81b395a2ee7eb8..0000000000000000000000000000000000000000 --- a/man/read_in_gml.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_gml.R -\name{read_in_gml} -\alias{read_in_gml} -\title{read_in_gml} -\usage{ -read_in_gml(gml_path) -} -\arguments{ -\item{gml_path}{The path to the geometry file that should be read in} -} -\description{ -Wrapper function to read in a whole .gml file -} diff --git a/man/read_in_output.Rd b/man/read_in_output.Rd deleted file mode 100644 index 17d3f0ebd532fc01c3cf3b4ee686a5a1537fe50e..0000000000000000000000000000000000000000 --- a/man/read_in_output.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sim_utils.R -\name{read_in_output} -\alias{read_in_output} -\title{read_in_output} -\usage{ -read_in_output(ogs6_obj) -} -\arguments{ -\item{ogs6_obj}{OGS6: Simulation object} -} -\description{ -After a OGS6 simulation was run, reads in the generated .vtu -files as new input for -the .prj file -} diff --git a/man/read_in_pvd.Rd b/man/read_in_pvd.Rd deleted file mode 100644 index 4f17da094a440227d827623d3125b183914a8d32..0000000000000000000000000000000000000000 --- a/man/read_in_pvd.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_vtu.R -\name{read_in_pvd} -\alias{read_in_pvd} -\title{read_in_pvd} -\usage{ -read_in_pvd(pvd_path) -} -\arguments{ -\item{pvd_path}{string: Path to .pvd file that should be read in} -} -\value{ -character: Vector containing .vtu paths -} -\description{ -Function to read in a .pvd file -} diff --git a/man/read_in_vtu.Rd b/man/read_in_vtu.Rd deleted file mode 100644 index 1f2df677e1ac09aec76a07ff14035915c830c21a..0000000000000000000000000000000000000000 --- a/man/read_in_vtu.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_in_vtu.R -\name{read_in_vtu} -\alias{read_in_vtu} -\title{read_in_vtu} -\usage{ -read_in_vtu(vtu_path) -} -\arguments{ -\item{vtu_path}{string: Path to .vtu file that should be read in} -} -\value{ -OGS6_vtu: Mesh object -} -\description{ -Wrapper function to read in a whole .vtu file as a OGS6_vtu -class object -} diff --git a/man/validate_r2ogs6_gml.Rd b/man/validate_r2ogs6_gml.Rd deleted file mode 100644 index 8a227d560f135e2816a13d0f08a74309bc4396f1..0000000000000000000000000000000000000000 --- a/man/validate_r2ogs6_gml.Rd +++ /dev/null @@ -1,15 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gml.R -\name{validate_r2ogs6_gml} -\alias{validate_r2ogs6_gml} -\title{validate_r2ogs6_gml} -\usage{ -validate_r2ogs6_gml(r2ogs6_gml) -} -\arguments{ -\item{r2ogs6_gml}{r2ogs6_gml:} -} -\description{ -Validator for class r2ogs6_gml. Checks if the defined polylines -and surfaces reference existing points. -} diff --git a/man/validate_surface_elements.Rd b/man/validate_surface_elements.Rd deleted file mode 100644 index e9e42ecd94daceb95bdee283c036e154aaa4a1b5..0000000000000000000000000000000000000000 --- a/man/validate_surface_elements.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gml.R -\name{validate_surface_elements} -\alias{validate_surface_elements} -\title{validate_surface_elements} -\usage{ -validate_surface_elements(surface_element_1, surface_element_2) -} -\arguments{ -\item{surface_element_1}{numeric, length = 3} - -\item{surface_element_2}{numeric, length = 3} -} -\description{ -Helper function, checks if two numerical vectors of length 3 -(two surface elements) each consist of 3 different elements and also have -exactly 2 matching elements between them which means they describe a valid -surface. You can think of the two vectors as two triangles, and the two -triangles together form a square which is our surface. -} diff --git a/tests/testthat/test-export_gml.R b/tests/testthat/test-export_gml.R index e6bb3e3ebba0ffb479cc61b4734de5e0cdbecf74..07494e9706f240b94207a280cbbd820a60be5ad5 100644 --- a/tests/testthat/test-export_gml.R +++ b/tests/testthat/test-export_gml.R @@ -8,7 +8,7 @@ test_that("export_gml works", { dir.create(test_path) # Define gml object - test_gml <- r2ogs6_gml( + test_gml <- OGS6_gml$new( name = "test_geometry", points = tibble::tibble( x = c(0, 0, 0, 0, 1, 1, 1, 1), diff --git a/tests/testthat/test-vtu.R b/tests/testthat/test-vtu.R index 0b4e5ecc98b65d448f28dea8723a851e20965faa..c19a996e280bf3981ed18a3828f20f396fd9bc85 100644 --- a/tests/testthat/test-vtu.R +++ b/tests/testthat/test-vtu.R @@ -3,8 +3,7 @@ skip_if_python_modules_missing <- function() { used_modules <- c("vtk", - "vtk.numpy_interface.dataset_adapter", - "zlib") + "vtk.numpy_interface.dataset_adapter") lapply(used_modules, function(x){ if(!reticulate::py_module_available(x)){ @@ -45,7 +44,7 @@ test_that("OGS6_pvd$get_timestep_by_vtu_path works", { timestep <- ogs6_pvd$get_timestep_by_vtu_path(vtu_path = vtu_path) - expect_equal(timestep, "99.9999999999986") + expect_equal(timestep, 99.9999999999986) }) @@ -63,36 +62,55 @@ test_that("OGS6_pvd$get_PointData_time_tibble works", { "velocity") time_tibble <- ogs6_pvd$get_PointData_time_tibble(Names = Names) + expect_equal(length(time_tibble), 341) +}) + + +test_that("OGS6_pvd$get_PointData_at_timestep works", { + + skip_if_python_modules_missing() + + 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(time_tibble), 2) + point_data <- ogs6_pvd$get_PointData_at_timestep(point_ids = 0, + Names = "HydraulicFlow", + timestep = 0) + + expect_equal(length(point_data), 1) + expect_equal(names(point_data), "p0") }) #===== OGS6_vtu ===== -test_that("read_in_vtu works", { +test_that("OGS6_vtu initialization works", { vtu_path <- system.file("extdata/benchmarks/flow_free_expansion", "cube_1x1x1.vtu", package = "r2ogs6") - ogs6_vtu <- read_in_vtu(vtu_path = vtu_path) + vtu_obj <- OGS6_vtu$new(vtu_path = vtu_path) expect_equal("vtkmodules.vtkCommonDataModel.vtkUnstructuredGrid" %in% - class(ogs6_vtu$vtkUnstructuredGrid), TRUE) + class(vtu_obj$vtkUnstructuredGrid), TRUE) }) + #===== generate_structured_mesh ===== #Add test... -#===== read_in_PointData_DataArray ===== +#===== get_PointData ===== -test_that("read_in_PointData_DataArray works", { +test_that("get_PointData works", { skip_if_python_modules_missing() @@ -100,31 +118,9 @@ test_that("read_in_PointData_DataArray works", { "flow_free_expansion_ts_1000_t_10000.000000.vtu", package = "r2ogs6") - vtu_obj <- read_in_vtu(vtu_path) - pd_data_array <- vtu_obj$get_PointData_DataArray(Name = "HydraulicFlow") - - expect_equal(class(pd_data_array), "array") -}) - + vtu_obj <- OGS6_vtu$new(vtu_path = vtu_path) -#===== General .vtk library tests ===== + pd_data_array <- vtu_obj$get_PointData(Name = "HydraulicFlow") - -test_that("zlib decompressing works as expected", { - - skip_if_python_modules_missing() - - py_env <- reticulate::py_run_string( - paste( - "import zlib", - "test_data = bytearray('123', 'utf-8')", - "compr_data = zlib.compress(test_data)", - "decompr_data = zlib.decompress(compr_data)", - "check = test_data.decode('utf-8') == decompr_data.decode('utf-8')", - sep = "\n" - ), - convert = TRUE - ) - - expect_equal(py_env$check, TRUE) + expect_equal(class(pd_data_array), "array") })