Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
r2ogs6
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ogs
OpenGeoSys Tools
r2ogs6
Commits
ce149b15
Commit
ce149b15
authored
4 years ago
by
Ruben Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
[base] Better utilization of active fields
parent
fa745695
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!6
Merge branch 7 fixed functionality into master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/ogs6.R
+174
-135
174 additions, 135 deletions
R/ogs6.R
with
174 additions
and
135 deletions
R/ogs6.R
+
174
−
135
View file @
ce149b15
...
@@ -15,8 +15,8 @@ OGS6 <- R6::R6Class("OGS6",
...
@@ -15,8 +15,8 @@ OGS6 <- R6::R6Class("OGS6",
#'@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
#'@param ogs_bin_path string: Path to OpenGeoSys6 /bin directory
#'@param ogs_bin_path string: Path to OpenGeoSys6 /bin directory
#'@param test_mode In test mode,
sim_path and
ogs_bin_path will not be
#'@param test_mode In test mode, ogs_bin_path will not be
#' validated.
If
you're
not
a dev
eloper
, please
leave this as it is :)
#' validated.
Unless
you're a dev, please
don't touch.
initialize
=
function
(
sim_name
,
initialize
=
function
(
sim_name
,
sim_id
,
sim_id
,
sim_path
,
sim_path
,
...
@@ -26,24 +26,10 @@ OGS6 <- R6::R6Class("OGS6",
...
@@ -26,24 +26,10 @@ OGS6 <- R6::R6Class("OGS6",
# Basic validation
# Basic validation
assertthat
::
assert_that
(
assertthat
::
is.string
(
sim_name
))
assertthat
::
assert_that
(
assertthat
::
is.string
(
sim_name
))
assertthat
::
assert_that
(
assertthat
::
is.number
(
sim_id
))
assertthat
::
assert_that
(
assertthat
::
is.number
(
sim_id
))
assertthat
::
assert_that
(
assertthat
::
is.string
(
sim_path
))
assertthat
::
assert_that
(
assertthat
::
is.string
(
ogs_bin_path
))
sim_path
<-
validate_is_dir_path
(
sim_path
)
self
$
sim_path
<-
sim_path
ogs_bin_path
<-
validate_is_dir_path
(
ogs_bin_path
)
if
(
!
test_mode
){
if
(
!
test_mode
){
if
(
!
dir.exists
(
sim_path
)){
dir.create
(
sim_path
)
}
else
{
if
(
length
(
dir
(
sim_path
,
all.files
=
TRUE
))
!=
0
){
warning
(
paste0
(
"The defined sim_path directory '"
,
sim_path
,
"' is not empty. Files may be overwritten."
),
call.
=
FALSE
)
}
}
if
(
!
file.exists
(
paste0
(
ogs_bin_path
,
"generateStructuredMesh.exe"
)))
{
if
(
!
file.exists
(
paste0
(
ogs_bin_path
,
"generateStructuredMesh.exe"
)))
{
stop
(
paste
(
"Could not find executable file"
,
stop
(
paste
(
"Could not find executable file"
,
"generateStructuredMesh.exe at location"
,
"generateStructuredMesh.exe at location"
,
...
@@ -51,32 +37,21 @@ OGS6 <- R6::R6Class("OGS6",
...
@@ -51,32 +37,21 @@ OGS6 <- R6::R6Class("OGS6",
}
}
}
}
private
$
.sim_output
<-
list
()
private
$
.sim_name
<-
sim_name
private
$
.sim_name
<-
sim_name
private
$
.sim_id
<-
sim_id
private
$
.sim_id
<-
sim_id
private
$
.sim_path
<-
sim_path
private
$
.ogs_bin_path
<-
validate_is_dir_path
(
ogs_bin_path
)
private
$
.ogs_bin_path
<-
ogs_bin_path
},
},
#===== ADDING COMPONENTS =====
#===== ADDING COMPONENTS =====
#'@description
#'... (WIP)
#'@param name ...
#'@param value ...
add_sim_output
=
function
(
name
,
value
)
{
private
$
.sim_output
[[
name
]]
<-
value
},
#'@description
#'@description
#'Adds a r2ogs6_mesh object
#'Adds a r2ogs6_mesh object
#'@param mesh r2ogs6_mesh
#'@param mesh r2ogs6_mesh
add_mesh
=
function
(
mesh
){
add_mesh
=
function
(
mesh
){
assertthat
::
assert_that
(
class
(
mesh
)
==
"r2ogs6_
mesh
"
)
self
$
meshes
<-
c
(
self
$
mesh
es
,
private
$
.meshes
<-
c
(
private
$
.meshes
,
list
(
mesh
))
list
(
mesh
))
},
},
#'@description
#'@description
...
@@ -84,10 +59,7 @@ OGS6 <- R6::R6Class("OGS6",
...
@@ -84,10 +59,7 @@ OGS6 <- R6::R6Class("OGS6",
#'@param gml r2ogs6_gml
#'@param gml r2ogs6_gml
add_gml
=
function
(
gml
){
add_gml
=
function
(
gml
){
assertthat
::
assert_that
(
class
(
gml
)
==
"r2ogs6_gml"
)
assertthat
::
assert_that
(
class
(
gml
)
==
"r2ogs6_gml"
)
if
(
!
is.null
(
private
$
.gml
)){
warning
(
"Overwriting gml and geometry variable of OGS6 object"
,
call.
=
FALSE
)
}
private
$
.gml
<-
gml
private
$
.gml
<-
gml
private
$
.geometry
<-
paste0
(
gml
$
name
,
".gml"
)
private
$
.geometry
<-
paste0
(
gml
$
name
,
".gml"
)
},
},
...
@@ -96,117 +68,104 @@ OGS6 <- R6::R6Class("OGS6",
...
@@ -96,117 +68,104 @@ OGS6 <- R6::R6Class("OGS6",
#'Adds a python script
#'Adds a python script
#'@param python_script string: File name of python script
#'@param python_script string: File name of python script
add_python_script
=
function
(
python_script
){
add_python_script
=
function
(
python_script
){
assertthat
::
assert_that
(
assertthat
::
is.string
(
python_script
))
self
$
python_script
<-
python_script
if
(
!
is.null
(
private
$
.python_script
)){
warning
(
"Overwriting python_script variable of OGS6 object"
,
call.
=
FALSE
)
}
private
$
.python_script
<-
python_script
},
},
#'@description
#'@description
#'Adds a r2ogs6_process object
#'Adds a r2ogs6_process object
#'@param process r2ogs6_process
#'@param process r2ogs6_process
add_process
=
function
(
process
){
add_process
=
function
(
process
){
assertthat
::
assert_that
(
class
(
process
)
==
"r2ogs6_process"
)
self
$
processes
<-
c
(
self
$
processes
,
private
$
.processes
<-
c
(
private
$
.processes
,
list
(
process
))
list
(
process
))
names
(
self
$
processes
)[[
length
(
self
$
processes
)]]
<-
process
$
name
},
},
#'@description
#'@description
#'Adds a r2ogs6_time_loop object
#'Adds a r2ogs6_time_loop object
#'@param time_loop r2ogs6_time_loop
#'@param time_loop r2ogs6_time_loop
add_time_loop
=
function
(
time_loop
){
add_time_loop
=
function
(
time_loop
){
assertthat
::
assert_that
(
class
(
time_loop
)
==
"r2ogs6_time_loop"
)
self
$
time_loop
<-
time_loop
if
(
!
is.null
(
private
$
.time_loop
)){
warning
(
"Overwriting time_loop variable of OGS6 object"
,
call.
=
FALSE
)
}
private
$
.time_loop
<-
time_loop
},
},
#'@description
#'@description
#'Adds a r2ogs6_local_coordinate_system object
#'Adds a r2ogs6_local_coordinate_system object
#'@param local_coordinate_system r2ogs6_local_coordinate_system
#'@param local_coordinate_system r2ogs6_local_coordinate_system
add_local_coordinate_system
=
function
(
local_coordinate_system
){
add_local_coordinate_system
=
function
(
local_coordinate_system
){
assertthat
::
assert_that
(
class
(
local_coordinate_system
)
==
self
$
local_coordinate_system
<-
local_coordinate_system
"r2ogs6_local_coordinate_system"
)
if
(
!
is.null
(
private
$
.local_coordinate_system
)){
warning
(
"Overwriting local_coordinate_system variable of OGS6 object"
,
call.
=
FALSE
)
}
private
$
.local_coordinate_system
<-
local_coordinate_system
},
},
#'@description
#'@description
#'Adds a r2ogs6_medium object
#'Adds a r2ogs6_medium object
#'@param medium r2ogs6_medium
#'@param medium r2ogs6_medium
add_medium
=
function
(
medium
){
add_medium
=
function
(
medium
){
assertthat
::
assert_that
(
class
(
medium
)
==
"r2ogs6_medium"
)
self
$
media
<-
c
(
self
$
media
,
private
$
.media
<-
c
(
private
$
.media
,
list
(
medium
))
list
(
medium
))
},
},
#'@description
#'@description
#'Adds a r2ogs6_parameter object
#'Adds a r2ogs6_parameter object
#'@param parameter r2ogs6_parameter
#'@param parameter r2ogs6_parameter
add_parameter
=
function
(
parameter
){
add_parameter
=
function
(
parameter
){
assertthat
::
assert_that
(
class
(
parameter
)
==
"r2ogs6_parameter"
)
self
$
parameters
<-
c
(
self
$
parameters
,
private
$
.parameters
<-
c
(
private
$
.parameters
,
list
(
parameter
))
list
(
parameter
))
names
(
self
$
parameters
)[[
length
(
self
$
parameters
)]]
<-
parameter
$
name
},
},
#'@description
#'@description
#'Adds a r2ogs6_curve object
#'Adds a r2ogs6_curve object
#'@param curve r2ogs6_curve
#'@param curve r2ogs6_curve
add_curve
=
function
(
curve
){
add_curve
=
function
(
curve
){
assertthat
::
assert_that
(
class
(
curve
)
==
"r2ogs6_
curve
"
)
self
$
curves
<-
c
(
self
$
curve
s
,
private
$
.curves
<-
c
(
private
$
.curves
,
list
(
curve
))
list
(
curve
))
},
},
#'@description
#'@description
#'Adds a r2ogs6_process_variable object
#'Adds a r2ogs6_process_variable object
#'@param process_variable r2ogs6_process_variable
#'@param process_variable r2ogs6_process_variable
add_process_variable
=
function
(
process_variable
){
add_process_variable
=
function
(
process_variable
){
assertthat
::
assert_that
(
class
(
process_variable
)
==
self
$
process_variables
<-
c
(
self
$
process_variables
,
"r2ogs6_process_variable"
)
list
(
process_variable
))
private
$
.process_variables
<-
c
(
private
$
.process_variables
,
list
(
process_variable
))
names
(
self
$
process_variables
)[[
length
(
self
$
process_variables
)]]
<-
process_variable
$
name
},
},
#'@description
#'@description
#'Adds a r2ogs6_nonlinear_solver object
#'Adds a r2ogs6_nonlinear_solver object
#'@param nonlinear_solver r2ogs6_nonlinear_solver
#'@param nonlinear_solver r2ogs6_nonlinear_solver
add_nonlinear_solver
=
function
(
nonlinear_solver
){
add_nonlinear_solver
=
function
(
nonlinear_solver
){
assertthat
::
assert_that
(
class
(
nonlinear_solver
)
==
self
$
nonlinear_solvers
<-
c
(
self
$
nonlinear_solvers
,
"r2ogs6_nonlinear_solver"
)
list
(
nonlinear_solver
))
private
$
.nonlinear_solvers
<-
c
(
private
$
.nonlinear_solvers
,
list
(
nonlinear_solver
))
names
(
self
$
nonlinear_solvers
)[[
length
(
self
$
nonlinear_solvers
)]]
<-
nonlinear_solver
$
name
},
},
#'@description
#'@description
#'Adds a r2ogs6_linear_solver object
#'Adds a r2ogs6_linear_solver object
#'@param linear_solver r2ogs6_linear_solver
#'@param linear_solver r2ogs6_linear_solver
add_linear_solver
=
function
(
linear_solver
){
add_linear_solver
=
function
(
linear_solver
){
assertthat
::
assert_that
(
class
(
linear_solver
)
==
"r2ogs6_linear_solver"
)
self
$
linear_solvers
<-
c
(
self
$
linear_solvers
,
private
$
.linear_solvers
<-
c
(
private
$
.linear_solvers
,
list
(
linear_solver
))
list
(
linear_solver
))
names
(
self
$
linear_solvers
)[[
length
(
self
$
linear_solvers
)]]
<-
linear_solver
$
name
},
},
#'@description
#'@description
#'Adds a r2ogs6_vtkdiff object
#'Adds a r2ogs6_vtkdiff object
#'@param vtkdiff r2ogs6_vtkdiff
#'@param vtkdiff r2ogs6_vtkdiff
add_vtkdiff
=
function
(
vtkdiff
){
add_vtkdiff
=
function
(
vtkdiff
){
assertthat
::
assert_that
(
class
(
vtkdiff
)
==
"r2ogs6_vtkdiff"
)
self
$
test_definition
<-
c
(
self
$
test_definition
,
list
(
vtkdiff
))
private
$
.test_definition
<-
c
(
private
$
.test_definition
,
list
(
vtkdiff
))
},
},
#'@description
#'@description
#'Adds a r2ogs6_insitu object
#'Adds a r2ogs6_insitu object
#'@param insitu r2ogs6_insitu
#'@param insitu r2ogs6_insitu
add_insitu
=
function
(
insitu
){
add_insitu
=
function
(
insitu
){
assertthat
::
assert_that
(
class
(
insitu
)
==
"r2ogs6_insitu"
)
self
$
insitu
<-
insitu
if
(
!
is.null
(
private
$
.insitu
)){
warning
(
"Overwriting insitu variable of OGS6 object"
,
call.
=
FALSE
)
}
private
$
.insitu
<-
insitu
},
},
...
@@ -280,12 +239,6 @@ OGS6 <- R6::R6Class("OGS6",
...
@@ -280,12 +239,6 @@ OGS6 <- R6::R6Class("OGS6",
active
=
list
(
active
=
list
(
#'@field sim_output
#'Getter for OGS6 private parameter '.sim_output'
sim_output
=
function
(
value
)
{
private
$
.sim_output
},
#'@field sim_name
#'@field sim_name
#'Getter for OGS6 private parameter '.sim_name'
#'Getter for OGS6 private parameter '.sim_name'
sim_name
=
function
()
{
sim_name
=
function
()
{
...
@@ -299,9 +252,14 @@ OGS6 <- R6::R6Class("OGS6",
...
@@ -299,9 +252,14 @@ OGS6 <- R6::R6Class("OGS6",
},
},
#'@field sim_path
#'@field sim_path
#'Getter for OGS6 private parameter '.sim_path'
#'Access to private parameter '.sim_path'
sim_path
=
function
()
{
sim_path
=
function
(
value
)
{
private
$
.sim_path
if
(
missing
(
value
))
{
private
$
.sim_path
}
else
{
value
<-
validate_is_dir_path
(
value
)
private
$
.sim_path
<-
value
}
},
},
#'@field ogs_bin_path
#'@field ogs_bin_path
...
@@ -310,6 +268,12 @@ OGS6 <- R6::R6Class("OGS6",
...
@@ -310,6 +268,12 @@ OGS6 <- R6::R6Class("OGS6",
private
$
.ogs_bin_path
private
$
.ogs_bin_path
},
},
#'@field geometry
#'Getter for OGS6 private parameter '.geometry'
geometry
=
function
()
{
private
$
.geometry
},
#'@field gml
#'@field gml
#'Getter for OGS6 private parameter '.gml'
#'Getter for OGS6 private parameter '.gml'
gml
=
function
()
{
gml
=
function
()
{
...
@@ -317,93 +281,168 @@ OGS6 <- R6::R6Class("OGS6",
...
@@ -317,93 +281,168 @@ OGS6 <- R6::R6Class("OGS6",
},
},
#'@field meshes
#'@field meshes
#'
Getter for OGS6
private parameter '.meshes'
#'
Access to
private parameter '.meshes'
meshes
=
function
()
{
meshes
=
function
(
value
)
{
private
$
.meshes
if
(
missing
(
value
))
{
},
private
$
.meshes
}
else
{
#'@field geometry
validate_wrapper_list
(
value
,
#'Getter for OGS6 private para
mete
r '.geometry'
get_imple
me
n
te
d_classes
()[[
"meshes"
]])
geometry
=
function
()
{
private
$
.meshes
<-
value
private
$
.geometry
}
},
},
#'@field python_script
#'@field python_script
#'Getter for OGS6 private parameter '.python_script'
#'Access to private parameter '.python_script'
python_script
=
function
()
{
python_script
=
function
(
value
)
{
private
$
.python_script
if
(
missing
(
value
))
{
private
$
.python_script
}
else
{
assertthat
::
assert_that
(
assertthat
::
is.string
(
value
))
private
$
.python_script
<-
value
}
},
},
#'@field processes
#'@field processes
#'Getter for OGS6 private parameter '.processes'
#'Access to private parameter '.processes'
processes
=
function
()
{
processes
=
function
(
value
)
{
private
$
.processes
if
(
missing
(
value
))
{
private
$
.processes
}
else
{
validate_wrapper_list
(
value
,
get_implemented_classes
()[[
"processes"
]])
private
$
.processes
<-
value
}
},
},
#'@field time_loop
#'@field time_loop
#'Getter for OGS6 private parameter '.time_loop'
#'Access to private parameter '.time_loop'
time_loop
=
function
()
{
time_loop
=
function
(
value
)
{
private
$
.time_loop
if
(
missing
(
value
))
{
private
$
.time_loop
}
else
{
assertthat
::
assert_that
(
get_implemented_classes
()[[
"time_loop"
]]
%in%
class
(
value
))
private
$
.time_loop
<-
value
}
},
},
#'@field local_coordinate_system
#'@field local_coordinate_system
#'Getter for OGS6 private parameter '.local_coordinate_system'
#'Access to private parameter '.local_coordinate_system'
local_coordinate_system
=
function
()
{
local_coordinate_system
=
function
(
value
)
{
private
$
.local_coordinate_system
if
(
missing
(
value
))
{
private
$
.local_coordinate_system
}
else
{
assertthat
::
assert_that
(
get_implemented_classes
()[[
"local_coordinate_system"
]]
%in%
class
(
value
))
private
$
.local_coordinate_system
<-
value
}
},
},
#'@field media
#'@field media
#'Getter for OGS6 private parameter '.media'
#'Access to private parameter '.media'
media
=
function
()
{
media
=
function
(
value
)
{
private
$
.media
if
(
missing
(
value
))
{
private
$
.media
}
else
{
validate_wrapper_list
(
value
,
get_implemented_classes
()[[
"media"
]])
private
$
.media
<-
value
}
},
},
#'@field parameters
#'@field parameters
#'Getter for OGS6 private parameter '.parameters'
#'Access to private parameter '.parameters'
parameters
=
function
()
{
parameters
=
function
(
value
)
{
private
$
.parameters
if
(
missing
(
value
))
{
private
$
.parameters
}
else
{
validate_wrapper_list
(
value
,
get_implemented_classes
()[[
"parameters"
]])
private
$
.parameters
<-
value
}
},
},
#'@field curves
#'@field curves
#'Getter for OGS6 private parameter '.curves'
#'Access to private parameter '.curves'
curves
=
function
()
{
curves
=
function
(
value
)
{
private
$
.curves
if
(
missing
(
value
))
{
private
$
.curves
}
else
{
validate_wrapper_list
(
value
,
get_implemented_classes
()[[
"curves"
]])
private
$
.curves
<-
value
}
},
},
#'@field process_variables
#'@field process_variables
#'Getter for OGS6 private parameter '.process_variables'
#'Access to private parameter '.process_variables'
process_variables
=
function
()
{
process_variables
=
function
(
value
)
{
private
$
.process_variables
if
(
missing
(
value
))
{
private
$
.process_variables
}
else
{
validate_wrapper_list
(
value
,
get_implemented_classes
()[[
"process_variables"
]])
private
$
.process_variables
<-
value
}
},
},
#'@field nonlinear_solvers
#'@field nonlinear_solvers
#'Getter for OGS6 private parameter '.nonlinear_solvers'
#'Access to private parameter '.nonlinear_solvers'
nonlinear_solvers
=
function
()
{
nonlinear_solvers
=
function
(
value
)
{
private
$
.nonlinear_solvers
if
(
missing
(
value
))
{
private
$
.nonlinear_solvers
}
else
{
validate_wrapper_list
(
value
,
get_implemented_classes
()[[
"nonlinear_solvers"
]])
private
$
.nonlinear_solvers
<-
value
}
},
},
#'@field linear_solvers
#'@field linear_solvers
#'Getter for OGS6 private parameter '.linear_solvers'
#'Access to private parameter '.linear_solvers'
linear_solvers
=
function
()
{
linear_solvers
=
function
(
value
)
{
private
$
.linear_solvers
if
(
missing
(
value
))
{
private
$
.linear_solvers
}
else
{
validate_wrapper_list
(
value
,
get_implemented_classes
()[[
"linear_solvers"
]])
private
$
.linear_solvers
<-
value
}
},
},
#'@field test_definition
#'@field test_definition
#'Getter for OGS6 private parameter '.test_definition'
#'Access to private parameter '.test_definition'
test_definition
=
function
()
{
test_definition
=
function
(
value
)
{
private
$
.test_definition
if
(
missing
(
value
))
{
private
$
.test_definition
}
else
{
validate_wrapper_list
(
value
,
get_implemented_classes
()[[
"test_definition"
]])
private
$
.test_definition
<-
value
}
},
},
#'@field insitu
#'@field insitu
#'Getter for OGS6 private parameter '.insitu'
#'Access to private parameter '.insitu'
insitu
=
function
()
{
insitu
=
function
(
value
)
{
private
$
.insitu
if
(
missing
(
value
))
{
private
$
.insitu
}
else
{
assertthat
::
assert_that
(
get_implemented_classes
()[[
"insitu"
]]
%in%
class
(
value
))
private
$
.insitu
<-
value
}
}
}
),
),
private
=
list
(
private
=
list
(
#general parameters
#general parameters
.sim_output
=
NULL
,
.sim_name
=
NULL
,
.sim_name
=
NULL
,
.sim_id
=
NULL
,
.sim_id
=
NULL
,
.sim_path
=
NULL
,
.sim_path
=
NULL
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment