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
85e5c00e
Commit
85e5c00e
authored
4 years ago
by
Ruben Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
[base] Moved validation to OGS6
parent
4cbd6700
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Basic import and export functionality
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/sim_utils.R
+21
-33
21 additions, 33 deletions
R/sim_utils.R
with
21 additions
and
33 deletions
R/sim_utils.R
+
21
−
33
View file @
85e5c00e
#This script contains functions to start the simulation
#===== run_simulation =====
#'run_simulation
#'run_simulation
#'@description Calls OGS6 object validator functions, exports all necessary files and starts OpenGeoSys6
#'@description Calls OGS6 object validator functions, exports all necessary
#' files and starts OpenGeoSys6
#'@param ogs6_obj A OGS6 class object
#'@param ogs6_obj A OGS6 class object
#'@param iter_n The number of iterations (for simulation chains)
#'@param iter_n The number of iterations (for simulation chains)
#'@param output_to_log_file Should the output be written to a log file?
#'@param output_to_log_file Should the output be written to a log file?
...
@@ -10,7 +12,8 @@
...
@@ -10,7 +12,8 @@
run_simulation
<-
function
(
ogs6_obj
,
iter_n
=
1
,
output_to_log_file
=
TRUE
)
{
run_simulation
<-
function
(
ogs6_obj
,
iter_n
=
1
,
output_to_log_file
=
TRUE
)
{
assertthat
::
assert_that
(
inherits
(
ogs6_obj
,
"OGS6"
))
assertthat
::
assert_that
(
inherits
(
ogs6_obj
,
"OGS6"
))
assertthat
::
assert_that
(
is.numeric
(
iter_n
),
iter_n
>
0
,
iter_n
<
500
)
assertthat
::
assert_that
(
assertthat
::
is.number
(
iter_n
),
iter_n
>
0
,
iter_n
<
500
)
#Call all validators
#Call all validators
validate_all
(
ogs6_obj
)
validate_all
(
ogs6_obj
)
...
@@ -29,8 +32,11 @@ run_simulation <- function(ogs6_obj, iter_n = 1, output_to_log_file = TRUE) {
...
@@ -29,8 +32,11 @@ run_simulation <- function(ogs6_obj, iter_n = 1, output_to_log_file = TRUE) {
for
(
i
in
seq_len
(
iter_n
)){
for
(
i
in
seq_len
(
iter_n
)){
#Call OGS6
#Call OGS6
system
(
command
=
paste0
(
ogs6_obj
$
ogs_bin_path
,
"ogs.exe "
,
system
(
command
=
paste0
(
ogs6_obj
$
ogs_bin_path
,
ogs6_obj
$
sim_path
,
ogs6_obj
$
sim_name
,
".prj -o "
,
"ogs.exe "
,
ogs6_obj
$
sim_path
,
ogs6_obj
$
sim_name
,
".prj -o "
,
ogs6_obj
$
sim_path
))
ogs6_obj
$
sim_path
))
# read_in_output(ogs6_obj)
# read_in_output(ogs6_obj)
...
@@ -40,7 +46,7 @@ run_simulation <- function(ogs6_obj, iter_n = 1, output_to_log_file = TRUE) {
...
@@ -40,7 +46,7 @@ run_simulation <- function(ogs6_obj, iter_n = 1, output_to_log_file = TRUE) {
}
}
#=====
========================= VALIDATION UTILITY ===========================
=====
#=====
VALIDATION UTILITY
=====
#'validate_all
#'validate_all
...
@@ -49,46 +55,28 @@ run_simulation <- function(ogs6_obj, iter_n = 1, output_to_log_file = TRUE) {
...
@@ -49,46 +55,28 @@ run_simulation <- function(ogs6_obj, iter_n = 1, output_to_log_file = TRUE) {
validate_all
<-
function
(
ogs6_obj
)
{
validate_all
<-
function
(
ogs6_obj
)
{
if
(
!
ogs6_obj
$
get_status
()){
if
(
!
ogs6_obj
$
get_status
()){
stop
(
"There are some components missing from your OGS6 object."
,
call.
=
FALSE
)
stop
(
"There are some components missing from your OGS6 object."
,
call.
=
FALSE
)
}
}
if
(
is.null
(
ogs6_obj
$
gml
)){
if
(
is.null
(
ogs6_obj
$
gml
)){
if
(
length
(
ogs6_obj
$
meshes
)
<
2
){
if
(
length
(
ogs6_obj
$
meshes
)
<
2
){
stop
(
"If you don't want to specify a gml object, you must have multiple
stop
(
paste
(
"If you don't want to specify a gml object, you must"
,
meshes. You can define more by calling the function generate_structured_mesh."
,
call.
=
FALSE
)
"have multiple meshes. You can define more by calling"
,
"generate_structured_mesh()."
),
call.
=
FALSE
)
}
}
}
else
if
(
length
(
ogs6_obj
$
meshes
)
!=
1
){
}
else
if
(
length
(
ogs6_obj
$
meshes
)
!=
1
){
stop
(
"If you want to specify a gml object, there must be only one mesh (one vtk file)."
,
call.
=
FALSE
)
stop
(
paste
(
"If you want to specify a gml object, there may only be"
,
"one mesh (one vtk file)."
),
call.
=
FALSE
)
}
}
#...
#...
}
}
#'validate_paths
#'@description Helper function to pull path validation out of already large class OGS6
#'@param sim_path The path where all relevant files for the simulation will be saved
#'@param ogs_bin_path Path to OpenGeoSys6 /bin directory
validate_paths
<-
function
(
sim_path
,
ogs_bin_path
){
if
(
!
dir.exists
(
sim_path
)){
dir.create
(
sim_path
)
}
else
{
if
(
length
(
dir
(
sim_path
,
all.files
=
TRUE
))
!=
0
){
warning
(
paste0
(
"The sim_path directory you defined ('"
,
sim_path
,
"') already exists (that is ok). However, "
,
"it is not empty. Files may be overwritten."
),
call.
=
FALSE
)
}
}
if
(
!
file.exists
(
paste0
(
ogs_bin_path
,
"generateStructuredMesh.exe"
)))
{
stop
(
paste
(
"Could not find executable file generateStructuredMesh.exe at location"
,
ogs_bin_path
),
call.
=
FALSE
)
}
}
#'read_in_output
#'read_in_output
#'@description After a OGS6 simulation was run, reads in the generated .vtu files as new input for
#'@description After a OGS6 simulation was run, reads in the generated .vtu
#' files as new input for
#' the .prj file
#' the .prj file
#'@param ogs6_obj A OGS6 class object
#'@param ogs6_obj A OGS6 class object
read_in_output
<-
function
(
ogs6_obj
)
{
read_in_output
<-
function
(
ogs6_obj
)
{
...
...
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