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
65f5969a
Commit
65f5969a
authored
4 years ago
by
Ruben Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
[base] WIP: Added optional R6 class for .vtu data
parent
6bff60f9
No related branches found
No related tags found
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/vtu.R
+261
-38
261 additions, 38 deletions
R/vtu.R
with
261 additions
and
38 deletions
R/vtu.R
+
261
−
38
View file @
65f5969a
# Functions for adding .vtu data to a OGS6 simulation object
#===== OGS6_mesh =====
#'r2ogs6_mesh
#'
@description Wrapper class, so far only has a reference to a .vtu file
#'
OGS6_mesh
#'@
param mesh_ref A reference to a .vtu file
#'@
description Constructor for the OGS6_mesh base class
#'@export
#'@export
r2ogs6_mesh
<-
function
(
mesh_ref
){
OGS6_mesh
<-
R6
::
R6Class
(
new_r2ogs6_mesh
(
mesh_ref
)
"OGS6_mesh"
,
}
public
=
list
(
#'@description
#'Creates new OGS6_mesh object
#'@param mesh_path string:
initialize
=
function
(
mesh_path
)
{
self
$
mesh_path
<-
mesh_path
}
),
active
=
list
(
#'@field mesh_path
#'Access to private parameter '.mesh_path'
mesh_path
=
function
(
value
)
{
if
(
missing
(
value
))
{
private
$
.mesh_path
}
else
{
assertthat
::
assert_that
(
assertthat
::
is.string
(
value
))
private
$
.mesh_path
<-
value
private
$
.mesh_filename
<-
basename
(
value
)
}
},
#'@field mesh_filename
#'Access to private parameter '.mesh_filename'
mesh_filename
=
function
()
{
private
$
.mesh_filename
},
#'@field is_subclass
#'Access to private parameter '.is_subclass'
is_subclass
=
function
()
{
private
$
.is_subclass
},
new_r2ogs6_mesh
<-
function
(
mesh_ref
){
#'@field subclasses_names
#'Access to private parameter '.subclasses_names'
subclasses_names
=
function
()
{
private
$
.subclasses_names
},
assertthat
::
assert_that
(
assertthat
::
is.string
(
mesh_ref
))
#'@field attr_names
#'Access to private parameter '.attr_names'
attr_names
=
function
()
{
private
$
.attr_names
}
),
structure
(
private
=
list
(
list
(
.mesh_path
=
NULL
,
mesh_ref
=
mesh_ref
,
.mesh_filename
=
NULL
,
tag_name
=
"mesh"
,
.is_subclass
=
FALSE
,
is_subclass
=
FALSE
,
.subclasses_names
=
character
(),
attr_names
=
character
(),
.attr_names
=
character
()
flatten_on_exp
=
character
()
),
class
=
"r2ogs6_mesh"
)
)
}
)
#===== OGS6_UnstructuredGrid =====
#'OGS6_UnstructuredGrid
#'@description Constructor for the OGS6_UnstructuredGrid base class
#'@export
OGS6_UnstructuredGrid
<-
R6
::
R6Class
(
"OGS6_UnstructuredGrid"
,
public
=
list
(
#'@description
#'Creates new OGS6_UnstructuredGrid object
#'@param Piece OGS6_Piece:
#'@param FieldData character, length == 2:
initialize
=
function
(
Piece
,
FieldData
=
NULL
)
{
self
$
Piece
<-
Piece
self
$
FieldData
<-
FieldData
}
),
active
=
list
(
#'@field Piece
#'Access to private parameter '.Piece'
Piece
=
function
(
value
)
{
if
(
missing
(
value
))
{
private
$
.Piece
}
else
{
private
$
.Piece
<-
value
}
},
#'@field FieldData
#'Access to private parameter '.FieldData'
FieldData
=
function
(
value
)
{
if
(
missing
(
value
))
{
private
$
.FieldData
}
else
{
private
$
.FieldData
<-
value
}
},
#'@field is_subclass
#'Access to private parameter '.is_subclass'
is_subclass
=
function
()
{
private
$
.is_subclass
},
#'@field subclasses_names
#'Access to private parameter '.subclasses_names'
subclasses_names
=
function
()
{
private
$
.subclasses_names
},
#'@field attr_names
#'Access to private parameter '.attr_names'
attr_names
=
function
()
{
private
$
.attr_names
}
),
private
=
list
(
.Piece
=
NULL
,
.FieldData
=
NULL
,
.is_subclass
=
TRUE
,
.subclasses_names
=
character
(),
.attr_names
=
character
()
)
)
#'as_node.r2ogs6_curve
#'@description Implementation of generic function as_node for S3 class r2ogs6_mesh
#===== OGS6_Piece =====
#'@param x A r2ogs6_mesh class object
as_node.r2ogs6_mesh
<-
function
(
x
){
node
<-
list
(
mesh
=
structure
(
list
(
x
$
mesh_ref
)))
OGS6_Piece
<-
R6
::
R6Class
(
return
(
node
)
"OGS6_Piece"
,
}
public
=
list
(
initialize
=
function
(
NumberOfPoints
,
NumberOfCells
,
PointData
,
Points
,
Cells
,
CellData
=
NULL
)
{
self
$
NumberOfPoints
<-
NumberOfPoints
self
$
NumberOfCells
<-
NumberOfCells
self
$
PointData
<-
PointData
self
$
Points
<-
Points
self
$
Cells
<-
Cells
self
$
CellData
<-
CellData
}
),
active
=
list
(
#'@field NumberOfPoints
#'Access to private parameter '.NumberOfPoints'
NumberOfPoints
=
function
(
value
)
{
if
(
missing
(
value
))
{
private
$
.NumberOfPoints
}
else
{
private
$
.NumberOfPoints
<-
value
}
},
#'@field NumberOfCells
#'Access to private parameter '.NumberOfCells'
NumberOfCells
=
function
(
value
)
{
if
(
missing
(
value
))
{
private
$
.NumberOfCells
}
else
{
private
$
.NumberOfCells
<-
value
}
},
#'@field PointData
#'Access to private parameter '.PointData'
PointData
=
function
(
value
)
{
if
(
missing
(
value
))
{
private
$
.PointData
}
else
{
private
$
.PointData
<-
value
}
},
#'@field Points
#'Access to private parameter '.Points'
Points
=
function
(
value
)
{
if
(
missing
(
value
))
{
private
$
.Points
}
else
{
private
$
.Points
<-
value
}
},
#'@field Cells
#'Access to private parameter '.Cells'
Cells
=
function
(
value
)
{
if
(
missing
(
value
))
{
private
$
.Cells
}
else
{
private
$
.Cells
<-
value
}
},
#'@field CellData
#'Access to private parameter '.CellData'
CellData
=
function
(
value
)
{
if
(
missing
(
value
))
{
private
$
.CellData
}
else
{
private
$
.CellData
<-
value
}
},
#'@field is_subclass
#'Access to private parameter '.is_subclass'
is_subclass
=
function
()
{
private
$
.is_subclass
},
#'@field subclasses_names
#'Access to private parameter '.subclasses_names'
subclasses_names
=
function
()
{
private
$
.subclasses_names
},
#'@field attr_names
#'Access to private parameter '.attr_names'
attr_names
=
function
()
{
private
$
.attr_names
}
),
private
=
list
(
.NumberOfPoints
=
NULL
,
.NumberOfCells
=
NULL
,
.PointData
=
NULL
,
.Points
=
NULL
,
.Cells
=
NULL
,
.CellData
=
NULL
,
.is_subclass
=
TRUE
,
.subclasses_names
=
character
(),
.attr_names
=
c
(
"NumberOfPoints"
,
"NumberOfCells"
)
)
)
#===== generate_structured_mesh =====
#'generate_structured_mesh
#'generate_structured_mesh
#'@description Wrapper function to call generateStructuredMesh.exe (VTK mesh generator).
#'@description Wrapper function to call generateStructuredMesh.exe
#'For full documentation see https://www.opengeosys.org/docs/tools/meshing/structured-mesh-generation/
#' (VTK mesh generator). For full documentation see
#'@param ogs6_obj A OGS6 class object (containing the path to the ogs6 bin/ folder)
#'https://www.opengeosys.org/docs/tools/meshing/structured-mesh-generation/
#'@param call_str The arguments the script will be called with (EXCEPT -o output_file_name, this will
#'@param ogs6_obj OGS6: Simulation object
#' be generated automatically!)
#'@param call_str The arguments the script will be called with
#' (EXCEPT -o output_file_name, this will be generated automatically!)
#'@return The newly generated .vtu file path
#'@return The newly generated .vtu file path
#'@export
#'@export
generate_structured_mesh
=
function
(
ogs6_obj
,
call_str
)
{
generate_structured_mesh
=
function
(
ogs6_obj
,
call_str
)
{
...
@@ -55,15 +279,14 @@ generate_structured_mesh = function(ogs6_obj, call_str) {
...
@@ -55,15 +279,14 @@ generate_structured_mesh = function(ogs6_obj, call_str) {
mesh_number
<-
length
(
ogs6_obj
$
meshes
)
+
1
mesh_number
<-
length
(
ogs6_obj
$
meshes
)
+
1
}
}
mesh_dir_path
<-
tempdir
()
mesh_output_file_name
<-
paste0
(
ogs6_obj
$
sim_name
,
"_"
,
mesh_number
,
".vtu"
)
mesh_output_file_name
<-
paste0
(
ogs6_obj
$
sim_name
,
"_"
,
mesh_number
,
".vtu"
)
mesh_output_file
<-
paste0
(
ogs6_obj
$
sim_path
,
mesh_output_file_name
)
mesh_path
<-
paste0
(
mesh_dir_path
,
mesh_output_file_name
)
#sysname <- Sys.info()[['sysname']]
system
(
command
=
paste0
(
ogs6_obj
$
ogs_bin_path
,
"generateStructuredMesh.exe"
,
system
(
command
=
paste0
(
ogs6_obj
$
ogs_bin_path
,
"generateStructuredMesh.exe"
,
" -o "
,
mesh_
output_file
,
" "
,
call_str
))
" -o "
,
mesh_
path
,
" "
,
call_str
))
ogs6_obj
$
add_mesh
(
r2ogs
6_mesh
(
mesh_
output_file_name
))
ogs6_obj
$
add_mesh
(
OGS
6_mesh
$
new
(
mesh_
path
))
return
(
invisible
(
mesh_output_file_name
))
return
(
invisible
(
mesh_path
))
}
}
\ No newline at end of file
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