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
95452442
Commit
95452442
authored
4 years ago
by
Ruben Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
[feature] WIP: Simplified .vtu parameter access
parent
39bd9611
No related branches found
No related tags found
1 merge request
!6
Merge branch 7 fixed functionality into master
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
R/vtu.R
+20
-27
20 additions, 27 deletions
R/vtu.R
man/OGS6_vtu.Rd
+8
-25
8 additions, 25 deletions
man/OGS6_vtu.Rd
tests/testthat/test-vtu.R
+4
-6
4 additions, 6 deletions
tests/testthat/test-vtu.R
with
32 additions
and
58 deletions
R/vtu.R
+
20
−
27
View file @
95452442
...
@@ -111,14 +111,14 @@ OGS6_pvd <- R6::R6Class(
...
@@ -111,14 +111,14 @@ OGS6_pvd <- R6::R6Class(
# ... get all rows of PointData or get rows by Name
# ... get all rows of PointData or get rows by Name
if
(
missing
(
Names
)){
if
(
missing
(
Names
)){
Names
<-
names
(
relevant_vtus
[[
i
]]
$
get_P
oint
D
ata
()
)
Names
<-
names
(
relevant_vtus
[[
i
]]
$
p
oint
_d
ata
)
}
}
assertthat
::
assert_that
(
is.character
(
Names
))
assertthat
::
assert_that
(
is.character
(
Names
))
for
(
j
in
seq_len
(
length
(
point_ids
)))
{
for
(
j
in
seq_len
(
length
(
point_ids
)))
{
point_data
<-
point_data
<-
relevant_vtus
[[
i
]]
$
get_
PointD
ata_for_point
(
relevant_vtus
[[
i
]]
$
get_
d
ata_for_point
(
point_ids
[[
j
]],
point_ids
[[
j
]],
Names
)
Names
)
...
@@ -242,14 +242,15 @@ OGS6_vtu <- R6::R6Class(
...
@@ -242,14 +242,15 @@ OGS6_vtu <- R6::R6Class(
#'@param point_id number: Point ID
#'@param point_id number: Point ID
#'@param Names character: Optional: `Name` attributes of `DataArray`
#'@param Names character: Optional: `Name` attributes of `DataArray`
#' elements, defaults to all in `PointData`
#' elements, defaults to all in `PointData`
get_PointData_for_point
=
function
(
point_id
,
get_data_for_point
=
function
(
point_id
,
Names
){
Names
){
assertthat
::
assert_that
(
assertthat
::
is.number
(
point_id
))
if
(
missing
(
Names
)){
if
(
missing
(
Names
)){
Names
<-
names
(
self
$
get_P
oint
D
ata
()
)
Names
<-
names
(
self
$
p
oint
_d
ata
)
}
}
assertthat
::
assert_that
(
assertthat
::
is.number
(
point_id
))
assertthat
::
assert_that
(
is.character
(
Names
))
assertthat
::
assert_that
(
is.character
(
Names
))
point_data
<-
list
()
point_data
<-
list
()
...
@@ -257,27 +258,13 @@ OGS6_vtu <- R6::R6Class(
...
@@ -257,27 +258,13 @@ OGS6_vtu <- R6::R6Class(
for
(
i
in
seq_len
(
length
(
Names
))){
for
(
i
in
seq_len
(
length
(
Names
))){
point_data
<-
point_data
<-
c
(
point_data
,
c
(
point_data
,
list
(
self
$
get_P
oint
D
ata
(
Names
[[
i
]]
)
[[(
point_id
+
1
)]]))
list
(
self
$
p
oint
_d
ata
[[
Names
[[
i
]]
]]
[[(
point_id
+
1
)]]))
names
(
point_data
)[[
length
(
point_data
)]]
<-
Names
[[
i
]]
names
(
point_data
)[[
length
(
point_data
)]]
<-
Names
[[
i
]]
}
}
return
(
point_data
)
return
(
point_data
)
},
},
#'@description
#'Gets PointData of `DataArray` element with `Name` attribute
#'@param Name string: Optional: `Name` attribute of `DataArray`
#' elements, defaults to all in `PointData`
get_PointData
=
function
(
Name
){
if
(
missing
(
Name
)){
return
(
self
$
dsa_wrapped_vtkUnstructuredGrid
$
PointData
)
}
assertthat
::
assert_that
(
assertthat
::
is.string
(
Name
))
return
(
self
$
dsa_wrapped_vtkUnstructuredGrid
$
PointData
[[
Name
]])
},
#'@description
#'@description
#'Gets number of points
#'Gets number of points
#'@return number: The number of points
#'@return number: The number of points
...
@@ -294,6 +281,12 @@ OGS6_vtu <- R6::R6Class(
...
@@ -294,6 +281,12 @@ OGS6_vtu <- R6::R6Class(
private
$
.vtu_path
private
$
.vtu_path
},
},
#'@field point_data
#'Getter for PointData parameter of '.dsa_vtkUnstructuredGrid'
point_data
=
function
()
{
self
$
dsa_vtkUnstructuredGrid
$
PointData
},
#'@field vtkUnstructuredGrid
#'@field vtkUnstructuredGrid
#'Access to private parameter '.vtkUnstructuredGrid'
#'Access to private parameter '.vtkUnstructuredGrid'
vtkUnstructuredGrid
=
function
(
value
)
{
vtkUnstructuredGrid
=
function
(
value
)
{
...
@@ -302,22 +295,22 @@ OGS6_vtu <- R6::R6Class(
...
@@ -302,22 +295,22 @@ OGS6_vtu <- R6::R6Class(
}
else
{
}
else
{
# Check class
# Check class
private
$
.vtkUnstructuredGrid
<-
value
private
$
.vtkUnstructuredGrid
<-
value
private
$
.dsa_
wrapped_
vtkUnstructuredGrid
<-
private
$
.dsa_vtkUnstructuredGrid
<-
vtk_dsa
$
WrapDataObject
(
value
)
vtk_dsa
$
WrapDataObject
(
value
)
}
}
},
},
#'@field dsa_
wrapped_
vtkUnstructuredGrid
#'@field dsa_vtkUnstructuredGrid
#'Getter for private parameter '.dsa_
wrapped_
vtkUnstructuredGrid'
#'Getter for private parameter '.dsa_vtkUnstructuredGrid'
dsa_
wrapped_
vtkUnstructuredGrid
=
function
()
{
dsa_vtkUnstructuredGrid
=
function
()
{
private
$
.dsa_
wrapped_
vtkUnstructuredGrid
private
$
.dsa_vtkUnstructuredGrid
}
}
),
),
private
=
list
(
private
=
list
(
.vtu_path
=
NULL
,
.vtu_path
=
NULL
,
.vtkUnstructuredGrid
=
NULL
,
.vtkUnstructuredGrid
=
NULL
,
.dsa_
wrapped_
vtkUnstructuredGrid
=
NULL
.dsa_vtkUnstructuredGrid
=
NULL
)
)
)
)
...
...
This diff is collapsed.
Click to expand it.
man/OGS6_vtu.Rd
+
8
−
25
View file @
95452442
...
@@ -11,9 +11,11 @@ Constructor for the OGS6_vtu base class
...
@@ -11,9 +11,11 @@ Constructor for the OGS6_vtu base class
\describe{
\describe{
\item{\code{vtu_path}}{Getter for private parameter '.vtu_path'}
\item{\code{vtu_path}}{Getter for private parameter '.vtu_path'}
\item{\code{point_data}}{Getter for PointData parameter of '.dsa_vtkUnstructuredGrid'}
\item{\code{vtkUnstructuredGrid}}{Access to private parameter '.vtkUnstructuredGrid'}
\item{\code{vtkUnstructuredGrid}}{Access to private parameter '.vtkUnstructuredGrid'}
\item{\code{dsa_
wrapped_
vtkUnstructuredGrid}}{Getter for private parameter '.dsa_
wrapped_
vtkUnstructuredGrid'}
\item{\code{dsa_vtkUnstructuredGrid}}{Getter for private parameter '.dsa_vtkUnstructuredGrid'}
}
}
\if{html}{\out{</div>}}
\if{html}{\out{</div>}}
}
}
...
@@ -21,8 +23,7 @@ Constructor for the OGS6_vtu base class
...
@@ -21,8 +23,7 @@ Constructor for the OGS6_vtu base class
\subsection{Public methods}{
\subsection{Public methods}{
\itemize{
\itemize{
\item \href{#method-new}{\code{OGS6_vtu$new()}}
\item \href{#method-new}{\code{OGS6_vtu$new()}}
\item \href{#method-get_PointData_for_point}{\code{OGS6_vtu$get_PointData_for_point()}}
\item \href{#method-get_data_for_point}{\code{OGS6_vtu$get_data_for_point()}}
\item \href{#method-get_PointData}{\code{OGS6_vtu$get_PointData()}}
\item \href{#method-get_number_of_points}{\code{OGS6_vtu$get_number_of_points()}}
\item \href{#method-get_number_of_points}{\code{OGS6_vtu$get_number_of_points()}}
\item \href{#method-clone}{\code{OGS6_vtu$clone()}}
\item \href{#method-clone}{\code{OGS6_vtu$clone()}}
}
}
...
@@ -45,12 +46,12 @@ Creates new OGS6_vtu object
...
@@ -45,12 +46,12 @@ Creates new OGS6_vtu object
}
}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-get_
PointD
ata_for_point"></a>}}
\if{html}{\out{<a id="method-get_
d
ata_for_point"></a>}}
\if{latex}{\out{\hypertarget{method-get_
PointD
ata_for_point}{}}}
\if{latex}{\out{\hypertarget{method-get_
d
ata_for_point}{}}}
\subsection{Method \code{get_
PointD
ata_for_point()}}{
\subsection{Method \code{get_
d
ata_for_point()}}{
Gets PointData for point with ID `point_id`
Gets PointData for point with ID `point_id`
\subsection{Usage}{
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{OGS6_vtu$get_
PointD
ata_for_point(point_id, Names)}\if{html}{\out{</div>}}
\if{html}{\out{<div class="r">}}\preformatted{OGS6_vtu$get_
d
ata_for_point(point_id, Names)}\if{html}{\out{</div>}}
}
}
\subsection{Arguments}{
\subsection{Arguments}{
...
@@ -65,24 +66,6 @@ elements, defaults to all in `PointData`}
...
@@ -65,24 +66,6 @@ elements, defaults to all in `PointData`}
}
}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-get_PointData"></a>}}
\if{latex}{\out{\hypertarget{method-get_PointData}{}}}
\subsection{Method \code{get_PointData()}}{
Gets PointData of `DataArray` element with `Name` attribute
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{OGS6_vtu$get_PointData(Name)}\if{html}{\out{</div>}}
}
\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{Name}}{string: Optional: `Name` attribute of `DataArray`
elements, defaults to all in `PointData`}
}
\if{html}{\out{</div>}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-get_number_of_points"></a>}}
\if{html}{\out{<a id="method-get_number_of_points"></a>}}
\if{latex}{\out{\hypertarget{method-get_number_of_points}{}}}
\if{latex}{\out{\hypertarget{method-get_number_of_points}{}}}
\subsection{Method \code{get_number_of_points()}}{
\subsection{Method \code{get_number_of_points()}}{
...
...
This diff is collapsed.
Click to expand it.
tests/testthat/test-vtu.R
+
4
−
6
View file @
95452442
...
@@ -107,10 +107,10 @@ test_that("OGS6_vtu initialization works", {
...
@@ -107,10 +107,10 @@ test_that("OGS6_vtu initialization works", {
#Add test...
#Add test...
#=====
get_P
oint
D
ata =====
#=====
OGS6_vtu$p
oint
_d
ata
has expected format
=====
test_that
(
"
get_P
oint
D
ata works"
,
{
test_that
(
"
p
oint
_d
ata works"
,
{
skip_if_python_modules_missing
()
skip_if_python_modules_missing
()
...
@@ -119,8 +119,6 @@ test_that("get_PointData works", {
...
@@ -119,8 +119,6 @@ test_that("get_PointData works", {
package
=
"r2ogs6"
)
package
=
"r2ogs6"
)
vtu_obj
<-
OGS6_vtu
$
new
(
vtu_path
=
vtu_path
)
vtu_obj
<-
OGS6_vtu
$
new
(
vtu_path
=
vtu_path
)
point_data
<-
vtu_obj
$
point_data
[[
"HydraulicFlow"
]]
pd_data_array
<-
vtu_obj
$
get_PointData
(
Name
=
"HydraulicFlow"
)
expect_equal
(
class
(
point_data
),
"array"
)
expect_equal
(
class
(
pd_data_array
),
"array"
)
})
})
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