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

[docs] added examples for OGS6 class

parent 21ccc075
No related branches found
No related tags found
2 merge requests!12Resolve "format documentation",!11Resolve "Add examples to class and function documentation"
...@@ -2,17 +2,19 @@ ...@@ -2,17 +2,19 @@
#===== OGS6 ===== #===== OGS6 =====
#'OGS6 #' OGS6
#'@description Constructor for the OGS6 base class #' @description Constructor for the \code{OGS6} base class
#'@export #' @export
OGS6 <- R6::R6Class("OGS6", OGS6 <- R6::R6Class("OGS6",
public = list( public = list(
#'@description #' @description
#'Creates new OGS6 object #' Creates new OGS6 object
#'@param sim_name string: Simulation name #' @param sim_name string: Simulation name
#'@param sim_path string: Path where all files for the simulation will be #' @param sim_path string: Path where all files for the simulation will be
#' saved #' saved
#' @examples
#' ogs6_obj <- OGS6$new(sim_name = "my_sim", sim_path = "my/path")
initialize = function(sim_name, initialize = function(sim_name,
sim_path) { sim_path) {
...@@ -30,9 +32,12 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -30,9 +32,12 @@ OGS6 <- R6::R6Class("OGS6",
#===== Adding components ===== #===== Adding components =====
#'@description #' @description
#'Adds a .prj simulation component #' Adds a .prj simulation component
#'@param x An object of any .prj `r2ogs6` class #' @param x An object of any .prj `r2ogs6` class
#' @examples
#' ogs6_obj <- OGS6$new(sim_name = "my_sim", sim_path = "my/path")
#' ogs6_obj$add(r2ogs6_parameter$new(name = "foo", type = "bar"))
add = function(x){ add = function(x){
# Assert that class name is in implemented .prj classes for OGS6 # Assert that class name is in implemented .prj classes for OGS6
...@@ -66,11 +71,15 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -66,11 +71,15 @@ OGS6 <- R6::R6Class("OGS6",
invisible(self) invisible(self)
}, },
#'@description #' @description
#'Adds a reference to a .gml file and optionally, a OGS6_gml object #' Adds a reference to a file with ending .gml and optionally, a
#'@param gml string | r2ogs6_gml: Either a path to a file with extension #' \code{OGS6_gml} object
#' .gml or a r2ogs6_gml object. #' @param gml string | OGS6_gml: Either a path to a file with extension
#@examples #' .gml or a OGS6_gml object.
#' @examples
#' ogs6_obj <- OGS6$new(sim_name = "my_sim", sim_path = "my/path")
#' ogs6_obj$add_gml("this_works.gml")
#' \dontrun{ogs6_obj$add_gml("this_doesnt.oops")}
add_gml = function(gml){ add_gml = function(gml){
if(assertthat::is.string(gml)){ if(assertthat::is.string(gml)){
...@@ -85,11 +94,16 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -85,11 +94,16 @@ OGS6 <- R6::R6Class("OGS6",
invisible(self) invisible(self)
}, },
#'@description #' @description
#'Adds a reference to a .vtu file and optionally, a OGS6_vtu object #' Adds a reference to a \code{.vtu} file and optionally, a \code{OGS6_vtu}
#'@param path string: #' object
#'@param read_in_vtu flag: Optional: Should .vtu file just be copied or #' @param path string: A path
#' read in too? #' @param read_in_vtu flag: Optional: Should \code{.vtu} file just be
#' copied or read in too?
#' @examples
#' ogs6_obj <- OGS6$new(sim_name = "my_sim", sim_path = "my/path")
#' ogs6_obj$add_vtu("this_works.vtu")
#' \dontrun{ogs6_obj$add_vtu("this_doesnt.oops")}
add_vtu = function(path, add_vtu = function(path,
read_in_vtu = FALSE){ read_in_vtu = FALSE){
assertthat::assert_that(assertthat::is.string(path)) assertthat::assert_that(assertthat::is.string(path))
...@@ -109,10 +123,13 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -109,10 +123,13 @@ OGS6 <- R6::R6Class("OGS6",
#===== Utility ===== #===== Utility =====
#'@description #' @description
#'Checks if the OGS6 object has all necessary parameters for #' Checks if the \code{OGS6} object has all necessary parameters for
#' starting a simulation #' starting a simulation
#'@param print_status flag: Should the status be printed to the console? #' @param print_status flag: Should the status be printed to the console?
#' @examples
#' ogs6_obj <- OGS6$new(sim_name = "my_sim", sim_path = "my/path")
#' ogs6_obj$get_status()
get_status = function(print_status = TRUE){ get_status = function(print_status = TRUE){
assertthat::assert_that(assertthat::is.flag(print_status)) assertthat::assert_that(assertthat::is.flag(print_status))
...@@ -166,8 +183,8 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -166,8 +183,8 @@ OGS6 <- R6::R6Class("OGS6",
return(invisible(flag)) return(invisible(flag))
}, },
#'@description #' @description
#'Overrides default printing behaviour #' Overrides default printing behaviour
print = function(){ print = function(){
cat("OGS6\n") cat("OGS6\n")
cat("simulation name: ", self$sim_name, "\n", sep = "") cat("simulation name: ", self$sim_name, "\n", sep = "")
...@@ -197,8 +214,8 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -197,8 +214,8 @@ OGS6 <- R6::R6Class("OGS6",
invisible(self) invisible(self)
}, },
#'print_log #' print_log
#'@description Prints logfile to console (if it exists) #' @description Prints logfile to console (if it exists)
print_log = function(){ print_log = function(){
if(!is.null(self$logfile)){ if(!is.null(self$logfile)){
writeLines(readLines(self$logfile)) writeLines(readLines(self$logfile))
...@@ -209,11 +226,11 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -209,11 +226,11 @@ OGS6 <- R6::R6Class("OGS6",
invisible(self) invisible(self)
}, },
#'@description #' @description
#'Clears components from the OGS6 object #' Clears components from the \code{OGS6} object
#'@param which character: The names of the components (all by default). #' @param which character: The names of the components (all by default).
#' If you want to delete only some components, run #' If you want to delete only some components, run
#' names(prj_top_level_classes()) for the available options. #' \code{names(prj_top_level_classes())} for the available options.
clear = function(which){ clear = function(which){
if(missing(which)){ if(missing(which)){
...@@ -254,8 +271,8 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -254,8 +271,8 @@ OGS6 <- R6::R6Class("OGS6",
active = list( active = list(
#'@field sim_name #' @field sim_name
#'Simulation name. `value` must be string #' Simulation name. \code{value} must be string
sim_name = function(value) { sim_name = function(value) {
if(missing(value)) { if(missing(value)) {
private$.sim_name private$.sim_name
...@@ -265,8 +282,8 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -265,8 +282,8 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field sim_path #' @field sim_path
#'Simulation path. `value` must be string #' Simulation path. \code{value} must be string
sim_path = function(value) { sim_path = function(value) {
if(missing(value)) { if(missing(value)) {
private$.sim_path private$.sim_path
...@@ -275,8 +292,8 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -275,8 +292,8 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field logfile #' @field logfile
#'Logfile path. `value` must be string #' Logfile path. \code{value} must be string
logfile = function(value) { logfile = function(value) {
if(missing(value)) { if(missing(value)) {
private$.logfile private$.logfile
...@@ -286,14 +303,14 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -286,14 +303,14 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field gml #' @field gml
#'.gml. read-only #' \code{.gml}. read-only
gml = function() { gml = function() {
private$.gml private$.gml
}, },
#'@field geometry #' @field geometry
#'.prj `geometry` tag. `value` must be string #' \code{.prj} \code{geometry} tag. \code{value} must be string
geometry = function(value) { geometry = function(value) {
if(missing(value)) { if(missing(value)) {
private$.geometry private$.geometry
...@@ -303,8 +320,8 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -303,8 +320,8 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field meshes #' @field meshes
#'.prj `meshes` tag. `value` must be list of strings #' \code{.prj} \code{meshes} tag. \code{value} must be list of strings
meshes = function(value) { meshes = function(value) {
if(missing(value)) { if(missing(value)) {
private$.meshes private$.meshes
...@@ -317,8 +334,8 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -317,8 +334,8 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field vtus #' @field vtus
#'.vtus. `value` must be list of `OGS_vtu` objects #' \code{.vtu}s. \code{value} must be list of \code{OGS6_vtu} objects
vtus = function(value) { vtus = function(value) {
if(missing(value)) { if(missing(value)) {
private$.vtus private$.vtus
...@@ -329,8 +346,8 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -329,8 +346,8 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field python_script #' @field python_script
#'.prj `python_script` tag. `value` must be string #' \code{.prj} \code{python_script} tag. \code{value} must be string
python_script = function(value) { python_script = function(value) {
if(missing(value)) { if(missing(value)) {
private$.python_script private$.python_script
...@@ -340,9 +357,9 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -340,9 +357,9 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field search_length_algorithm #' @field search_length_algorithm
#'.prj `search_length_algorithm` tag. `value` must be #' \code{.prj} \code{search_length_algorithm} tag. \code{value} must be
#' `r2ogs6_search_length_algorithm` object #' \code{r2ogs6_search_length_algorithm} object
search_length_algorithm = function(value) { search_length_algorithm = function(value) {
if(missing(value)) { if(missing(value)) {
private$.search_length_algorithm private$.search_length_algorithm
...@@ -354,8 +371,9 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -354,8 +371,9 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field processes #' @field processes
#'.prj `processes` tag. `value` must be list of `r2ogs6_process` objects #' \code{.prj} \code{processes} tag. \code{value} must be list of
#' \code{r2ogs6_process} objects
processes = function(value) { processes = function(value) {
if(missing(value)) { if(missing(value)) {
private$.processes private$.processes
...@@ -384,8 +402,9 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -384,8 +402,9 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field time_loop #' @field time_loop
#'.prj `time_loop` tag. `value` must be `r2ogs6_time_loop` object #' \code{.prj} \code{time_loop} tag. \code{value} must be
#' \code{r2ogs6_time_loop} object
time_loop = function(value) { time_loop = function(value) {
if(missing(value)) { if(missing(value)) {
private$.time_loop private$.time_loop
...@@ -397,9 +416,9 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -397,9 +416,9 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field local_coordinate_system #' @field local_coordinate_system
#'.prj `local_coordinate_system` tag. `value` must be #' \code{.prj} \code{local_coordinate_system} tag. \code{value} must be
#' `r2ogs6_local_coordinate_system` object #' \code{r2ogs6_local_coordinate_system} object
local_coordinate_system = function(value) { local_coordinate_system = function(value) {
if(missing(value)) { if(missing(value)) {
private$.local_coordinate_system private$.local_coordinate_system
...@@ -411,8 +430,9 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -411,8 +430,9 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field media #' @field media
#'.prj `media` tag. `value` must be list of `r2ogs6_medium` objects #' \code{.prj} \code{media} tag. \code{value} must be list of
#' \code{r2ogs6_medium} objects
media = function(value) { media = function(value) {
if(missing(value)) { if(missing(value)) {
private$.media private$.media
...@@ -423,9 +443,9 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -423,9 +443,9 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field parameters #' @field parameters
#'.prj `parameters` tag. `value` must be list of `r2ogs6_parameter` #' \code{.prj} \code{parameters} tag. \code{value} must be list of
#' objects #' \code{r2ogs6_parameter} objects
parameters = function(value) { parameters = function(value) {
if(missing(value)) { if(missing(value)) {
private$.parameters private$.parameters
...@@ -436,9 +456,9 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -436,9 +456,9 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field chemical_system #' @field chemical_system
#'.prj `chemical_system` tag. `value` must be `r2ogs6_chemical_system` #' \code{.prj} \code{chemical_system} tag. \code{value} must be
#' object #' \code{r2ogs6_chemical_system} object
chemical_system = function(value) { chemical_system = function(value) {
if(missing(value)) { if(missing(value)) {
private$.chemical_system private$.chemical_system
...@@ -450,8 +470,9 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -450,8 +470,9 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field curves #' @field curves
#'.prj `curves` tag. `value` must be list of `r2ogs6_curve` objects #' \code{.prj} \code{curves} tag. \code{value} must be list of
#' \code{r2ogs6_curve} objects
curves = function(value) { curves = function(value) {
if(missing(value)) { if(missing(value)) {
private$.curves private$.curves
...@@ -462,9 +483,9 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -462,9 +483,9 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field process_variables #' @field process_variables
#'.prj `process_variables` tag. `value` must be list of #' \code{.prj} \code{process_variables} tag. \code{value} must be list of
#' `r2ogs6_process_variable` objects #' \code{r2ogs6_process_variable} objects
process_variables = function(value) { process_variables = function(value) {
if(missing(value)) { if(missing(value)) {
private$.process_variables private$.process_variables
...@@ -476,9 +497,9 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -476,9 +497,9 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field nonlinear_solvers #' @field nonlinear_solvers
#'.prj `nonlinear_solvers` tag. `value` must be list of #' \code{.prj} \code{nonlinear_solvers} tag. \code{value} must be list of
#' `r2ogs6_nonlinear_solver` objects #' \code{r2ogs6_nonlinear_solver} objects
nonlinear_solvers = function(value) { nonlinear_solvers = function(value) {
if(missing(value)) { if(missing(value)) {
private$.nonlinear_solvers private$.nonlinear_solvers
...@@ -490,9 +511,9 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -490,9 +511,9 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field linear_solvers #' @field linear_solvers
#'.prj `linear_solvers` tag. `value` must be list of #' \code{.prj} \code{linear_solvers} tag. \code{value} must be list of
#' `r2ogs6_linear_solver` objects #' \code{r2ogs6_linear_solver} objects
linear_solvers = function(value) { linear_solvers = function(value) {
if(missing(value)) { if(missing(value)) {
private$.linear_solvers private$.linear_solvers
...@@ -503,9 +524,9 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -503,9 +524,9 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field test_definition #' @field test_definition
#'.prj `test_definition` tag. `value` must be list of `r2ogs6_vtkdiff` #' \code{.prj} \code{test_definition} tag. \code{value} must be list of
#' objects #' \code{r2ogs6_vtkdiff} objects
test_definition = function(value) { test_definition = function(value) {
if(missing(value)) { if(missing(value)) {
private$.test_definition private$.test_definition
...@@ -516,8 +537,9 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -516,8 +537,9 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field insitu #' @field insitu
#'.prj `insitu` tag. `value` must be `r2ogs6_insitu` object #' \code{.prj} \code{insitu} tag. \code{value} must be
#' \code{r2ogs6_insitu} object
insitu = function(value) { insitu = function(value) {
if(missing(value)) { if(missing(value)) {
private$.insitu private$.insitu
...@@ -529,8 +551,8 @@ OGS6 <- R6::R6Class("OGS6", ...@@ -529,8 +551,8 @@ OGS6 <- R6::R6Class("OGS6",
} }
}, },
#'@field pvds #' @field pvds
#'.pvds. `value` must be list of `OGS6_pvd` objects #' \code{.pvd}s. \code{value} must be list of \code{OGS6_pvd} objects
pvds = function(value) { pvds = function(value) {
if(missing(value)) { if(missing(value)) {
private$.pvds private$.pvds
......
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