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
477d6f1f
Commit
477d6f1f
authored
4 years ago
by
Ruben Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
[base] preparing simulation class for .vtu read-in
parent
339fa29c
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
+117
-19
117 additions, 19 deletions
R/ogs6.R
with
117 additions
and
19 deletions
R/ogs6.R
+
117
−
19
View file @
477d6f1f
...
@@ -46,12 +46,64 @@ OGS6 <- R6::R6Class("OGS6",
...
@@ -46,12 +46,64 @@ OGS6 <- R6::R6Class("OGS6",
#===== ADDING COMPONENTS =====
#===== ADDING COMPONENTS =====
#'@description
#'Adds a simulation component (WIP)
#'@param x OGS6_*: An object of a class listed in get_implemented_classes()
add_component
=
function
(
x
){
class_prefix
<-
"r2ogs6_"
# Assert that x is OGS6 class object
assertthat
::
assert_that
(
any
(
grepl
(
class_prefix
,
class
(
x
),
fixed
=
TRUE
)))
# Get exact class name of x
x_class_name
<-
grep
(
class_prefix
,
class
(
x
),
fixed
=
TRUE
,
value
=
TRUE
)
assertthat
::
assert_that
(
length
(
x_class_name
)
==
1
)
# Assert that class name is in implemented classes for OGS6
impl_classes
<-
get_implemented_classes
()
assertthat
::
assert_that
(
x_class_name
%in%
impl_classes
)
# Get name of corresponding OGS6 parameter
variable_name
<-
""
for
(
i
in
seq_len
(
length
(
impl_classes
))){
if
(
impl_classes
[[
i
]]
==
x_class_name
){
variable_name
<-
names
(
impl_classes
)[[
i
]]
break
}
}
af_call
<-
""
if
(
is_wrapper
(
variable_name
))
{
af_call
<-
paste0
(
"self$"
,
variable_name
,
" <- c(self$"
,
variable_name
,
", list(x))"
)
}
else
{
af_call
<-
paste0
(
"self$"
,
variable_name
,
" <- x"
)
}
eval
(
parse
(
text
=
af_call
))
# If class has `name` variable, make it accessable by name
if
(
"name"
%in%
names
(
as.list
(
formals
(
x_class_name
)))){
name_call
<-
paste0
(
"names(self$"
,
variable_name
,
")[[length(self$"
,
variable_name
,
")]] <- x$name"
)
eval
(
parse
(
text
=
name_call
))
}
},
#'@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
){
self
$
meshes
<-
c
(
self
$
mesh
es
,
assertthat
::
assert_that
(
assertthat
::
is.string
(
mesh
))
list
(
mesh
)
)
self
$
meshes
<-
c
(
self
$
meshes
,
mesh
=
mesh
)
},
},
#'@description
#'@description
...
@@ -64,6 +116,17 @@ OGS6 <- R6::R6Class("OGS6",
...
@@ -64,6 +116,17 @@ OGS6 <- R6::R6Class("OGS6",
private
$
.geometry
<-
paste0
(
gml
$
name
,
".gml"
)
private
$
.geometry
<-
paste0
(
gml
$
name
,
".gml"
)
},
},
#'@description
#'Adds a r2ogs6_gml object
#'@param vtu r2ogs6_vtu
#'@param filename string:
add_vtu
=
function
(
vtu
,
filename
){
assertthat
::
assert_that
(
class
(
vtu
)
==
"r2ogs6_vtu"
)
private
$
.vtus
<-
c
(
private
$
.vtus
,
list
(
vtu
))
self
$
meshes
<-
c
(
self
$
meshes
,
mesh
=
filename
)
},
#'@description
#'@description
#'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
...
@@ -175,24 +238,37 @@ OGS6 <- R6::R6Class("OGS6",
...
@@ -175,24 +238,37 @@ OGS6 <- R6::R6Class("OGS6",
#'@description
#'@description
#'Checks if the OGS6 object has all necessary parameters for
#'Checks if the OGS6 object has all necessary parameters for
#' starting a simulation
#' starting a simulation
get_status
=
function
(){
#'@param print_status flag: Should the status be printed to the console?
get_status
=
function
(
print_status
=
TRUE
){
assertthat
::
assert_that
(
assertthat
::
is.flag
(
print_status
))
flag
<-
TRUE
flag
<-
TRUE
impl_classes
<-
get_implemented_classes
()
impl_classes
<-
get_implemented_classes
()
status_strs
<-
character
()
for
(
i
in
seq_len
(
length
(
impl_classes
))){
for
(
i
in
seq_len
(
length
(
impl_classes
))){
status_call
<-
paste0
(
"get_obj_status(flag, private$."
,
status_call
<-
paste0
(
"get_obj_status(flag, private$."
,
names
(
impl_classes
)[[
i
]],
")"
)
names
(
impl_classes
)[[
i
]],
")"
)
flag
<-
eval
(
parse
(
text
=
status_call
))
status
<-
eval
(
parse
(
text
=
status_call
))
flag
<-
status
[[
1
]]
status_strs
<-
c
(
status_strs
,
status
[[
2
]])
}
}
if
(
flag
){
status_str
<-
paste0
(
paste
(
status_strs
,
collapse
=
""
),
"\n"
)
cat
(
paste0
(
"Your simulation object has all necessary components.\n"
,
"You can try to start the simulation by calling run_simulation() "
,
if
(
print_status
){
"on your OGS6 object.\n"
,
"Note that this will call more validation functions, "
,
cat
(
status_str
)
"so you may not be done just yet.\n"
))
if
(
flag
){
cat
(
paste0
(
"Your OGS6 object has all necessary components.\n"
,
"You can try calling run_simulation()."
,
"Note that this calls more validation functions, "
,
"so you may not be done just yet.\n"
))
}
}
}
return
(
invisible
(
flag
))
return
(
invisible
(
flag
))
...
@@ -293,30 +369,44 @@ OGS6 <- R6::R6Class("OGS6",
...
@@ -293,30 +369,44 @@ 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
()
{
private
$
.gml
private
$
.gml
},
},
#'@field geometry
#'Getter for OGS6 private parameter '.geometry'
geometry
=
function
()
{
private
$
.geometry
},
#'@field meshes
#'@field meshes
#'Access to private parameter '.meshes'
#'Access to private parameter '.meshes'
meshes
=
function
(
value
)
{
meshes
=
function
(
value
)
{
if
(
missing
(
value
))
{
if
(
missing
(
value
))
{
private
$
.meshes
private
$
.meshes
}
else
{
}
else
{
validate_wrapper_list
(
value
,
assertthat
::
assert_that
(
is.list
(
value
))
get_implemented_classes
()[[
"meshes"
]])
lapply
(
value
,
function
(
x
){
assertthat
::
assert_that
(
assertthat
::
is.string
(
x
))
})
private
$
.meshes
<-
value
private
$
.meshes
<-
value
}
}
},
},
#'@field vtus
#'Access to private parameter '.vtus'
vtus
=
function
(
value
)
{
if
(
missing
(
value
))
{
private
$
.vtus
}
else
{
validate_wrapper_list
(
value
,
get_implemented_classes
()[[
"vtus"
]])
private
$
.vtus
<-
value
}
},
#'@field python_script
#'@field python_script
#'Access to private parameter '.python_script'
#'Access to private parameter '.python_script'
python_script
=
function
(
value
)
{
python_script
=
function
(
value
)
{
...
@@ -478,9 +568,17 @@ OGS6 <- R6::R6Class("OGS6",
...
@@ -478,9 +568,17 @@ OGS6 <- R6::R6Class("OGS6",
#.gml parameters
#.gml parameters
.gml
=
NULL
,
.gml
=
NULL
,
#.vtu parameters
.vtus
=
NULL
,
#.prj parameters
#.prj parameters
.meshes
=
list
(),
#.gml reference
.geometry
=
NULL
,
.geometry
=
NULL
,
#.vtu reference(s)
.meshes
=
list
(),
.python_script
=
NULL
,
.python_script
=
NULL
,
.processes
=
list
(),
.processes
=
list
(),
.time_loop
=
NULL
,
.time_loop
=
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