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
df943d35
Commit
df943d35
authored
2 years ago
by
Johannes Boog
Browse files
Options
Downloads
Patches
Plain Diff
[base] add export routines for includes
parent
e11a5c01
No related branches found
No related tags found
1 merge request
!55
[base] update package to OGS6.4.2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/export_prj.R
+59
-33
59 additions, 33 deletions
R/export_prj.R
with
59 additions
and
33 deletions
R/export_prj.R
+
59
−
33
View file @
df943d35
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#' Wrapper function to create a \code{.prj} XML document based on the user
#' Wrapper function to create a \code{.prj} XML document based on the user
#' input data
#' input data
#' @param ogs6_obj OGS6: Simulation object
#' @param ogs6_obj OGS6: Simulation object
#' @param copy_ext_files flag: Wether referenced files are copied or not.
#' @noRd
#' @noRd
export_prj
<-
function
(
ogs6_obj
,
copy_ext_files
=
F
)
{
export_prj
<-
function
(
ogs6_obj
,
copy_ext_files
=
F
)
{
...
@@ -21,13 +22,23 @@ export_prj <- function(ogs6_obj, copy_ext_files = F) {
...
@@ -21,13 +22,23 @@ export_prj <- function(ogs6_obj, copy_ext_files = F) {
meshes
<-
ogs6_obj
$
meshes
meshes
<-
ogs6_obj
$
meshes
geometry
<-
ogs6_obj
$
geometry
geometry
<-
ogs6_obj
$
geometry
# copy meshes if required
# handle meshes
if
(
isTRUE
(
copy_ext_files
)){
if
(
!
is.null
(
meshes
)
&
length
(
meshes
)
!=
0
){
for
(
i
in
seq
(
meshes
)){
vtu_path
<-
meshes
[[
i
]][[
"path"
]]
# copy meshes if required
file.copy
(
vtu_path
,
ogs6_obj
$
sim_path
)
if
(
isTRUE
(
copy_ext_files
)){
meshes
[[
i
]][[
"path"
]]
<-
basename
(
vtu_path
)
for
(
i
in
seq
(
meshes
)){
}}
vtu_path
<-
meshes
[[
i
]][[
"path"
]]
file.copy
(
vtu_path
,
ogs6_obj
$
sim_path
)
meshes
[[
i
]][[
"path"
]]
<-
basename
(
vtu_path
)
}}
# export vtu
meshes_node
<-
meshes_to_xml
(
meshes
)
xml2
::
xml_add_child
(
prj_xml
,
meshes_node
)
}
# handle gml
# handle gml
if
(
!
is.null
(
ogs6_obj
$
gml
)){
if
(
!
is.null
(
ogs6_obj
$
gml
)){
...
@@ -46,29 +57,27 @@ export_prj <- function(ogs6_obj, copy_ext_files = F) {
...
@@ -46,29 +57,27 @@ export_prj <- function(ogs6_obj, copy_ext_files = F) {
xml2
::
as_xml_document
(
to_node
(
geometry
)))
xml2
::
as_xml_document
(
to_node
(
geometry
)))
}
}
# export vtu
meshes_node
<-
meshes_to_xml
(
meshes
)
xml2
::
xml_add_child
(
prj_xml
,
meshes_node
)
#Get implemented classes
#Get implemented classes
prj_components
<-
ogs6_prj_top_level_classes
()
prj_components
<-
ogs6_prj_top_level_classes
()
# handle include
s
# handle
to level
include
if
(
names
(
ogs6_obj
$
processes
)[[
1
]]
==
"
include
"
){
if
(
!
is.null
(
ogs6_obj
$
include
)
){
processes
<-
ogs6_obj
$
processes
include
<-
ogs6_obj
$
include
if
(
isTRUE
(
copy_ext_files
)){
if
(
isTRUE
(
copy_ext_files
)){
file.copy
(
processes
[[
1
]]
[[
"file"
]],
ogs6_obj
$
sim_path
)
file.copy
(
include
[[
"file"
]],
ogs6_obj
$
sim_path
)
processes
[[
1
]]
[[
"file"
]]
<-
basename
(
processes
[[
1
]]
[[
"file"
]])
include
[[
"file"
]]
<-
basename
(
include
[[
"file"
]])
}
}
include_list
<-
list
(
include
)
processes_node
<-
to_node
(
processes
,
attribute_names
=
"include"
)
names
(
include_list
)
<-
"include"
include_node
<-
to_node
(
include
,
attribute_names
=
"include"
)
xml2
::
xml_add_child
(
prj_xml
,
xml2
::
xml_add_child
(
prj_xml
,
xml2
::
as_xml_document
(
processes
_node
))
xml2
::
as_xml_document
(
include
_node
))
prj_components
<-
prj_components
[
names
(
prj_components
)
!=
"
processes
"
]
prj_components
<-
prj_components
[
names
(
prj_components
)
!=
"
include
"
]
}
}
#Add default cases
#Add default cases
for
(
i
in
seq_len
(
length
(
prj_components
))){
for
(
i
in
seq_len
(
length
(
prj_components
))){
param_name
<-
names
(
prj_components
)[[
i
]]
param_name
<-
names
(
prj_components
)[[
i
]]
...
@@ -83,22 +92,39 @@ export_prj <- function(ogs6_obj, copy_ext_files = F) {
...
@@ -83,22 +92,39 @@ export_prj <- function(ogs6_obj, copy_ext_files = F) {
next
next
}
}
# in case copy referenced files
# wether to handle include or prj class object
if
(
copy_ext_files
){
if
(
"include"
%in%
names
(
param
)[[
1
]]){
if
(
param_name
==
"chemical_system"
){
file.copy
(
param
$
database
,
ogs6_obj
$
sim_path
)
if
(
isTRUE
(
copy_ext_files
)){
param
$
database
<-
basename
(
param
$
database
)
file.copy
(
param
[[
1
]][[
"file"
]],
ogs6_obj
$
sim_path
)
param
[[
1
]][[
"file"
]]
<-
basename
(
param
[[
1
]][[
"file"
]])
}
}
if
(
param_name
==
"python_script"
){
file.copy
(
param
,
ogs6_obj
$
sim_path
)
param_node
<-
to_node
(
param
,
attribute_names
=
"include"
)
param
<-
basename
(
param
)
names
(
param_node
)
<-
param_name
xml2
::
xml_add_child
(
prj_xml
,
xml2
::
as_xml_document
(
param_node
))
# prj class param
}
else
{
# in case copy referenced files
if
(
copy_ext_files
){
if
(
param_name
==
"chemical_system"
){
file.copy
(
param
$
database
,
ogs6_obj
$
sim_path
)
param
$
database
<-
basename
(
param
$
database
)
}
if
(
param_name
==
"python_script"
){
file.copy
(
param
,
ogs6_obj
$
sim_path
)
param
<-
basename
(
param
)
}
}
}
}
# create xml node
# create xml node
param_node
<-
to_node
(
param
,
param_name
)
param_node
<-
to_node
(
param
,
param_name
)
xml2
::
xml_add_child
(
prj_xml
,
xml2
::
xml_add_child
(
prj_xml
,
xml2
::
as_xml_document
(
param_node
))
xml2
::
as_xml_document
(
param_node
))
}
}
}
file
<-
paste0
(
ogs6_obj
$
sim_path
,
ogs6_obj
$
sim_name
,
".prj"
)
file
<-
paste0
(
ogs6_obj
$
sim_path
,
ogs6_obj
$
sim_name
,
".prj"
)
...
...
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