Skip to content
Snippets Groups Projects
Commit c91ffe7d authored by Johannes Boog's avatar Johannes Boog
Browse files

Merge branch '67-feat_msh-file-support' into 'master'

Add support for mesh files in MSH format

Closes #67

See merge request !50
parents 39cbc064 9258cae6
No related branches found
No related tags found
1 merge request!50Add support for mesh files in MSH format
......@@ -5,6 +5,7 @@ export(OGS6_Chain)
export(OGS6_Ensemble)
export(OGS6_gml)
export(OGS6_h5)
export(OGS6_msh)
export(OGS6_pvd)
export(OGS6_vtu)
export(ogs6_call_ogs6)
......
......@@ -219,7 +219,7 @@ ogs6_generate_benchmark_script <- function(prj_path,
for(i in seq_len(length(ogs6_obj$meshes))){
script_str <-
paste0(script_str,
"ogs6_obj$add_vtu(path = \"",
"ogs6_obj$add_mesh(path = \"",
ogs6_obj$meshes[[i]]$path, "\",\n",
"axisym = ", ogs6_obj$meshes[[i]]$axially_symmetric, ",\n",
"read_in_vtu = ", read_in_vtu, ")\n\n")
......
......@@ -103,13 +103,13 @@ OGS6 <- R6::R6Class("OGS6",
#' copied or read in too?
#' @examples
#' ogs6_obj <- OGS6$new(sim_name = "my_sim", sim_path = "my/path")
#' ogs6_obj$add_vtu("this_works.vtu")
#' \dontrun{ogs6_obj$add_vtu("this_doesnt.oops")}
add_vtu = function(path,
#' ogs6_obj$add_mesh("this_works.vtu")
#' \dontrun{ogs6_obj$add_mesh("this_doesnt.oops")}
add_mesh = function(path,
axisym = FALSE,
read_in_vtu = FALSE){
assertthat::assert_that(assertthat::is.string(path))
assertthat::assert_that(grepl("\\.vtu$", path))
assertthat::assert_that(grepl("\\.vtu$|\\.msh$", path))
assertthat::assert_that(assertthat::is.flag(axisym))
assertthat::assert_that(assertthat::is.flag(read_in_vtu))
......@@ -117,9 +117,12 @@ OGS6 <- R6::R6Class("OGS6",
list(mesh = list(path = path,
axially_symmetric = axisym)))
if(read_in_vtu){
if(grepl("\\.vtu$", path) & read_in_vtu){
private$.vtus <- c(private$.vtus, list(OGS6_vtu$new(path)))
}
if(grepl("\\.msh", path)){
private$.mshs <- c(private$.mshs, list(OGS6_msh$new(path)))
}
invisible(self)
},
......@@ -368,6 +371,7 @@ OGS6 <- R6::R6Class("OGS6",
lapply(value, function(x){
assertthat::assert_that(is.list(x), length(x) == 2)
assertthat::assert_that(assertthat::is.string(x[[1]]))
assertthat::assert_that(grepl("\\.vtu$|\\.msh$", x[[1]]))
assertthat::assert_that(assertthat::is.flag(x[[2]]))
})
private$.meshes <- value
......@@ -614,6 +618,18 @@ OGS6 <- R6::R6Class("OGS6",
private$.h5s <- value
}
},
#' @field mshs
#' \code{mshs} \code{value} must be an object of class \code{OGS6_msh}.
mshs = function(value) {
if(missing(value)) {
private$.mshs
}else{
is_wrapper_list(value, element_class = "OGS6_msh")
private$.mshs <- value
}
}
),
......@@ -657,7 +673,8 @@ OGS6 <- R6::R6Class("OGS6",
# .pvd objects (output)
.pvds = NULL,
.h5s = NULL
.h5s = NULL,
.mshs = NULL
)
)
......
#' OGS6_msh
#' @description Small class to support \code{MSH} mesh files. Note that
#' MSH files are a legacy format from OGS5. It is recommended to switch to VTU
#' files.
#' @export
OGS6_msh <- R6::R6Class("OGS6_msh",
public = list(
#' @description reates new OGS6_vtu object..
#' @param msh_path path to \code{*.msh} file.
initialize = function(msh_path) {
assertthat::is.string(msh_path)
assertthat::assert_that(file.exists(msh_path))
private$.msh_path <- msh_path
},
#' @description Overrides the default print method
print = function(){
cat("OGS6_msh\n")
cat("msh path:\n")
cat(private$.msh_path, "\n\n")
invisible(self)
}
),
# === active fields
active = list(
#' @field msh_path
#' Getter/setter for private parameter `.msh_path`
msh_path = function(value) {
if (missing(value)) {
private$.msh_path
} else {
assertthat::assert_that(assertthat::is.string(value))
private$.msh_path <- value
}
}
),
private = list(
.msh_path = NULL
)
)
\ No newline at end of file
......@@ -71,7 +71,7 @@ read_in_prj <- function(ogs6_obj,
}
# Read in .vtu file(s) or just save their path
ogs6_obj$add_vtu(path = vtu_path,
ogs6_obj$add_mesh(path = vtu_path,
axisym = axisym_val,
read_in_vtu = read_in_vtu)
}
......
......@@ -90,7 +90,7 @@ ogs6_obj$add_gml(
)
)
ogs6_obj$add_vtu("inst/extdata/benchmarks/flow_free_expansion/cube_1x1x1_quad.vtu",
ogs6_obj$add_mesh("inst/extdata/benchmarks/flow_free_expansion/cube_1x1x1_quad.vtu",
FALSE)
ogs6_obj$add(
......
<?xml version="1.0" encoding="utf-8"?>
<OpenGeoSysGLI>
<name>geometry</name>
<points>
<point id="0" x="100" y="0" z="0" name="POINT0"/>
<point id="1" x="100" y="10" z="0" name="POINT1"/>
<point id="2" x="100" y="10" z="10" name="POINT2"/>
<point id="3" x="100" y="0" z="10" name="POINT3"/>
<point id="4" x="0" y="0" z="0" name="POINT4"/>
<point id="5" x="0" y="10" z="0" name="POINT5"/>
<point id="6" x="0" y="10" z="10" name="POINT6"/>
<point id="7" x="0" y="0" z="10" name="POINT7"/>
</points>
<polylines>
<polyline id="0" name="POLYLINE1">
<pnt>0</pnt>
<pnt>1</pnt>
<pnt>2</pnt>
<pnt>3</pnt>
<pnt>0</pnt>
</polyline>
<polyline id="1" name="POLYLINE2">
<pnt>4</pnt>
<pnt>5</pnt>
<pnt>6</pnt>
<pnt>7</pnt>
<pnt>4</pnt>
</polyline>
</polylines>
<surfaces>
<surface id="0" name="SURFACE1">
<element p1="0" p2="2" p3="1"/>
<element p1="2" p2="0" p3="3"/>
</surface>
<surface id="1" name="SURFACE2">
<element p1="4" p2="6" p3="5"/>
<element p1="6" p2="4" p3="7"/>
</surface>
</surfaces>
</OpenGeoSysGLI>
#FEM_MSH
$PCS_TYPE
NO_PCS
$NODES
44
0 10 10 10
1 0 10 10
2 0 0 10
3 10 0 10
4 10 10 0
5 0 10 0
6 0 0 0
7 10 0 0
8 20 10 10
9 20 0 10
10 20 10 0
11 20 0 0
12 30 10 10
13 30 0 10
14 30 10 0
15 30 0 0
16 40 10 10
17 40 0 10
18 40 10 0
19 40 0 0
20 50 10 10
21 50 0 10
22 50 10 0
23 50 0 0
24 60 10 10
25 60 0 10
26 60 10 0
27 60 0 0
28 70 10 10
29 70 0 10
30 70 10 0
31 70 0 0
32 80 10 10
33 80 0 10
34 80 10 0
35 80 0 0
36 90 10 10
37 90 0 10
38 90 10 0
39 90 0 0
40 100 10 10
41 100 0 10
42 100 10 0
43 100 0 0
$ELEMENTS
10
0 0 hex 4 5 6 7 0 1 2 3
1 0 hex 10 4 7 11 8 0 3 9
2 0 hex 14 10 11 15 12 8 9 13
3 0 hex 18 14 15 19 16 12 13 17
4 1 hex 22 18 19 23 20 16 17 21
5 1 hex 26 22 23 27 24 20 21 25
6 1 hex 30 26 27 31 28 24 25 29
7 1 hex 34 30 31 35 32 28 29 33
8 1 hex 38 34 35 39 36 32 33 37
9 1 hex 42 38 39 43 40 36 37 41
#STOP
<?xml version="1.0" encoding="ISO-8859-1"?>
<OpenGeoSysProject>
<mesh>t1_1Dsource.msh</mesh>
<geometry>t1_1Dsource.gml</geometry>
<processes>
<process>
<name>HeatConduction</name>
<type>HEAT_CONDUCTION</type>
<integration_order>2</integration_order>
<process_variables>
<process_variable>temperature</process_variable>
</process_variables>
<secondary_variables>
</secondary_variables>
</process>
</processes>
<media>
<medium id="0">
<phases/>
<properties>
<property>
<name>density</name>
<type>Parameter</type>
<parameter_name>rho</parameter_name>
</property>
<property>
<name>heat_capacity</name>
<type>Parameter</type>
<parameter_name>c</parameter_name>
</property>
<property>
<name>thermal_conductivity</name>
<type>Parameter</type>
<parameter_name>lambda</parameter_name>
</property>
<property>
<name>reference_temperature</name>
<type>Constant</type>
<value>293.15</value>
</property>
</properties>
</medium>
<medium id="1">
<phases/>
<properties>
<property>
<name>density</name>
<type>Parameter</type>
<parameter_name>rho</parameter_name>
</property>
<property>
<name>heat_capacity</name>
<type>Parameter</type>
<parameter_name>c</parameter_name>
</property>
<property>
<name>thermal_conductivity</name>
<type>Parameter</type>
<parameter_name>lambda</parameter_name>
</property>
<property>
<name>reference_temperature</name>
<type>Constant</type>
<value>293.15</value>
</property>
</properties>
</medium>
</media>
<time_loop>
<processes>
<process ref="HeatConduction">
<nonlinear_solver>basic_picard</nonlinear_solver>
<convergence_criterion>
<type>DeltaX</type>
<norm_type>NORM2</norm_type>
<reltol>1.0e-9</reltol>
</convergence_criterion>
<time_discretization>
<type>BackwardEuler</type>
</time_discretization>
<time_stepping>
<type>FixedTimeStepping</type>
<t_initial> 0.0 </t_initial>
<t_end> 1 </t_end>
<timesteps>
<pair>
<repeat> 1 </repeat>
<delta_t> 1 </delta_t>
</pair>
</timesteps>
</time_stepping>
</process>
</processes>
<output>
<type>VTK</type>
<prefix>t1_1Dsource</prefix>
<data_mode>Ascii</data_mode>
<compress_output>false</compress_output>
<timesteps>
<pair>
<repeat> 1 </repeat>
<each_steps> 1 </each_steps>
</pair>
</timesteps>
<variables>
<variable> temperature </variable>
</variables>
<suffix>_ts_{:timestep}_t_{:time}</suffix>
</output>
</time_loop>
<parameters>
<parameter>
<name>lambda</name>
<type>Group</type>
<group_id_property>MaterialIDs</group_id_property>
<index_values>
<index>0</index>
<value>100</value>
</index_values>
<index_values>
<index>1</index>
<value>300</value>
</index_values>
</parameter>
<parameter>
<name>c</name>
<type>Group</type>
<group_id_property>MaterialIDs</group_id_property>
<index_values>
<index>0</index>
<value>0</value>
</index_values>
<index_values>
<index>1</index>
<value>0</value>
</index_values>
</parameter>
<parameter>
<name>rho</name>
<type>Group</type>
<group_id_property>MaterialIDs</group_id_property>
<index_values>
<index>0</index>
<value>0</value>
</index_values>
<index_values>
<index>1</index>
<value>0</value>
</index_values>
</parameter>
<parameter>
<name>initial_temperature</name>
<type>Constant</type>
<value>1.5</value>
</parameter>
<parameter>
<name>T0</name>
<type>Constant</type>
<value>1.0</value>
</parameter>
<parameter>
<name>h0</name>
<type>Constant</type>
<value>1.5</value>
</parameter>
</parameters>
<process_variables>
<process_variable>
<name>temperature</name>
<components>1</components>
<order>1</order>
<initial_condition>initial_temperature</initial_condition>
<boundary_conditions>
<boundary_condition>
<geometrical_set>geometry</geometrical_set>
<geometry>SURFACE1</geometry>
<type>Neumann</type>
<parameter>h0</parameter>
</boundary_condition>
<boundary_condition>
<geometrical_set>geometry</geometrical_set>
<geometry>SURFACE2</geometry>
<type>Dirichlet</type>
<parameter>T0</parameter>
</boundary_condition>
</boundary_conditions>
</process_variable>
</process_variables>
<nonlinear_solvers>
<nonlinear_solver>
<name>basic_picard</name>
<type>Picard</type>
<max_iter>10</max_iter>
<linear_solver>general_linear_solver</linear_solver>
</nonlinear_solver>
</nonlinear_solvers>
<linear_solvers>
<linear_solver>
<name>general_linear_solver</name>
<lis>-i cg -p jacobi -tol 1e-10 -maxiter 10000</lis>
<eigen>
<solver_type>CG</solver_type>
<precon_type>DIAGONAL</precon_type>
<max_iteration_step>10000</max_iteration_step>
<error_tolerance>1e-10</error_tolerance>
</eigen>
<petsc>
<prefix>T</prefix>
<parameters>-T_ksp_type cg -T_pc_type bjacobi -T_ksp_rtol 1e-10 -T_ksp_max_it 10000</parameters>
</petsc>
</linear_solver>
</linear_solvers>
</OpenGeoSysProject>
......@@ -30,12 +30,12 @@ ogs6_obj$add_gml("this_works.gml")
\dontrun{ogs6_obj$add_gml("this_doesnt.oops")}
## ------------------------------------------------
## Method `OGS6$add_vtu`
## Method `OGS6$add_mesh`
## ------------------------------------------------
ogs6_obj <- OGS6$new(sim_name = "my_sim", sim_path = "my/path")
ogs6_obj$add_vtu("this_works.vtu")
\dontrun{ogs6_obj$add_vtu("this_doesnt.oops")}
ogs6_obj$add_mesh("this_works.vtu")
\dontrun{ogs6_obj$add_mesh("this_doesnt.oops")}
## ------------------------------------------------
## Method `OGS6$update_component`
......@@ -115,27 +115,29 @@ ogs6_obj$get_status()
\item{\code{h5s}}{\code{h5s} \code{value} must be of class \code{H5IdComponent}
as returned by \code{rhdf5::h5read()}.}
\item{\code{mshs}}{\code{mshs} \code{value} must be an object of class \code{OGS6_msh}.}
}
\if{html}{\out{</div>}}
}
\section{Methods}{
\subsection{Public methods}{
\itemize{
\item \href{#method-new}{\code{OGS6$new()}}
\item \href{#method-add}{\code{OGS6$add()}}
\item \href{#method-add_gml}{\code{OGS6$add_gml()}}
\item \href{#method-add_vtu}{\code{OGS6$add_vtu()}}
\item \href{#method-update_component}{\code{OGS6$update_component()}}
\item \href{#method-get_status}{\code{OGS6$get_status()}}
\item \href{#method-print}{\code{OGS6$print()}}
\item \href{#method-print_log}{\code{OGS6$print_log()}}
\item \href{#method-clear}{\code{OGS6$clear()}}
\item \href{#method-clone}{\code{OGS6$clone()}}
\item \href{#method-OGS6-new}{\code{OGS6$new()}}
\item \href{#method-OGS6-add}{\code{OGS6$add()}}
\item \href{#method-OGS6-add_gml}{\code{OGS6$add_gml()}}
\item \href{#method-OGS6-add_mesh}{\code{OGS6$add_mesh()}}
\item \href{#method-OGS6-update_component}{\code{OGS6$update_component()}}
\item \href{#method-OGS6-get_status}{\code{OGS6$get_status()}}
\item \href{#method-OGS6-print}{\code{OGS6$print()}}
\item \href{#method-OGS6-print_log}{\code{OGS6$print_log()}}
\item \href{#method-OGS6-clear}{\code{OGS6$clear()}}
\item \href{#method-OGS6-clone}{\code{OGS6$clone()}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-new"></a>}}
\if{latex}{\out{\hypertarget{method-new}{}}}
\if{html}{\out{<a id="method-OGS6-new"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6-new}{}}}
\subsection{Method \code{new()}}{
Creates new OGS6 object
\subsection{Usage}{
......@@ -162,8 +164,8 @@ saved}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-add"></a>}}
\if{latex}{\out{\hypertarget{method-add}{}}}
\if{html}{\out{<a id="method-OGS6-add"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6-add}{}}}
\subsection{Method \code{add()}}{
Adds a .prj simulation component
\subsection{Usage}{
......@@ -188,8 +190,8 @@ ogs6_obj$add(prj_parameter(name = "foo", type = "bar"))
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-add_gml"></a>}}
\if{latex}{\out{\hypertarget{method-add_gml}{}}}
\if{html}{\out{<a id="method-OGS6-add_gml"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6-add_gml}{}}}
\subsection{Method \code{add_gml()}}{
Adds a reference to a file with ending .gml and optionally, a
\code{OGS6_gml} object
......@@ -217,13 +219,13 @@ ogs6_obj$add_gml("this_works.gml")
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-add_vtu"></a>}}
\if{latex}{\out{\hypertarget{method-add_vtu}{}}}
\subsection{Method \code{add_vtu()}}{
\if{html}{\out{<a id="method-OGS6-add_mesh"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6-add_mesh}{}}}
\subsection{Method \code{add_mesh()}}{
Adds a reference to a \code{.vtu} file and optionally, a \code{OGS6_vtu}
object
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{OGS6$add_vtu(path, axisym = FALSE, read_in_vtu = FALSE)}\if{html}{\out{</div>}}
\if{html}{\out{<div class="r">}}\preformatted{OGS6$add_mesh(path, axisym = FALSE, read_in_vtu = FALSE)}\if{html}{\out{</div>}}
}
\subsection{Arguments}{
......@@ -241,8 +243,8 @@ copied or read in too?}
\subsection{Examples}{
\if{html}{\out{<div class="r example copy">}}
\preformatted{ogs6_obj <- OGS6$new(sim_name = "my_sim", sim_path = "my/path")
ogs6_obj$add_vtu("this_works.vtu")
\dontrun{ogs6_obj$add_vtu("this_doesnt.oops")}
ogs6_obj$add_mesh("this_works.vtu")
\dontrun{ogs6_obj$add_mesh("this_doesnt.oops")}
}
\if{html}{\out{</div>}}
......@@ -250,8 +252,8 @@ ogs6_obj$add_vtu("this_works.vtu")
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-update_component"></a>}}
\if{latex}{\out{\hypertarget{method-update_component}{}}}
\if{html}{\out{<a id="method-OGS6-update_component"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6-update_component}{}}}
\subsection{Method \code{update_component()}}{
Update a component of the \code{OGS6} object.
\subsection{Usage}{
......@@ -280,8 +282,8 @@ second one is the corresponding value.}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-get_status"></a>}}
\if{latex}{\out{\hypertarget{method-get_status}{}}}
\if{html}{\out{<a id="method-OGS6-get_status"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6-get_status}{}}}
\subsection{Method \code{get_status()}}{
Checks if the \code{OGS6} object has all necessary parameters for
starting a simulation
......@@ -307,8 +309,8 @@ ogs6_obj$get_status()
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-print"></a>}}
\if{latex}{\out{\hypertarget{method-print}{}}}
\if{html}{\out{<a id="method-OGS6-print"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6-print}{}}}
\subsection{Method \code{print()}}{
Overrides default printing behaviour
print_log
......@@ -318,8 +320,8 @@ print_log
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-print_log"></a>}}
\if{latex}{\out{\hypertarget{method-print_log}{}}}
\if{html}{\out{<a id="method-OGS6-print_log"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6-print_log}{}}}
\subsection{Method \code{print_log()}}{
Prints logfile to console (if it exists)
\subsection{Usage}{
......@@ -328,8 +330,8 @@ Prints logfile to console (if it exists)
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-clear"></a>}}
\if{latex}{\out{\hypertarget{method-clear}{}}}
\if{html}{\out{<a id="method-OGS6-clear"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6-clear}{}}}
\subsection{Method \code{clear()}}{
Clears components from the \code{OGS6} object
\subsection{Usage}{
......@@ -347,8 +349,8 @@ If you want to delete only some components, run
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-clone"></a>}}
\if{latex}{\out{\hypertarget{method-clone}{}}}
\if{html}{\out{<a id="method-OGS6-clone"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6-clone}{}}}
\subsection{Method \code{clone()}}{
The objects of this class are cloneable with this method.
\subsection{Usage}{
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ogs6_msh.R
\name{OGS6_msh}
\alias{OGS6_msh}
\title{OGS6_msh}
\description{
Small class to support \code{MSH} mesh files. Note that
MSH files are a legacy format from OGS5. It is recommended to switch to VTU
files.
}
\section{Active bindings}{
\if{html}{\out{<div class="r6-active-bindings">}}
\describe{
\item{\code{msh_path}}{Getter/setter for private parameter `.msh_path`}
}
\if{html}{\out{</div>}}
}
\section{Methods}{
\subsection{Public methods}{
\itemize{
\item \href{#method-OGS6_msh-new}{\code{OGS6_msh$new()}}
\item \href{#method-OGS6_msh-print}{\code{OGS6_msh$print()}}
\item \href{#method-OGS6_msh-clone}{\code{OGS6_msh$clone()}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-OGS6_msh-new"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6_msh-new}{}}}
\subsection{Method \code{new()}}{
reates new OGS6_vtu object..
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{OGS6_msh$new(msh_path)}\if{html}{\out{</div>}}
}
\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{msh_path}}{path to \code{*.msh} file.}
}
\if{html}{\out{</div>}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-OGS6_msh-print"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6_msh-print}{}}}
\subsection{Method \code{print()}}{
Overrides the default print method
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{OGS6_msh$print()}\if{html}{\out{</div>}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-OGS6_msh-clone"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6_msh-clone}{}}}
\subsection{Method \code{clone()}}{
The objects of this class are cloneable with this method.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{OGS6_msh$clone(deep = FALSE)}\if{html}{\out{</div>}}
}
\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{deep}}{Whether to make a deep clone.}
}
\if{html}{\out{</div>}}
}
}
}
......@@ -36,19 +36,19 @@ Constructor for the `OGS6_vtu` base class
\section{Methods}{
\subsection{Public methods}{
\itemize{
\item \href{#method-new}{\code{OGS6_vtu$new()}}
\item \href{#method-print}{\code{OGS6_vtu$print()}}
\item \href{#method-get_field_data}{\code{OGS6_vtu$get_field_data()}}
\item \href{#method-get_point_coords}{\code{OGS6_vtu$get_point_coords()}}
\item \href{#method-get_point_data_at}{\code{OGS6_vtu$get_point_data_at()}}
\item \href{#method-get_point_data}{\code{OGS6_vtu$get_point_data()}}
\item \href{#method-get_cell_data}{\code{OGS6_vtu$get_cell_data()}}
\item \href{#method-clone}{\code{OGS6_vtu$clone()}}
\item \href{#method-OGS6_vtu-new}{\code{OGS6_vtu$new()}}
\item \href{#method-OGS6_vtu-print}{\code{OGS6_vtu$print()}}
\item \href{#method-OGS6_vtu-get_field_data}{\code{OGS6_vtu$get_field_data()}}
\item \href{#method-OGS6_vtu-get_point_coords}{\code{OGS6_vtu$get_point_coords()}}
\item \href{#method-OGS6_vtu-get_point_data_at}{\code{OGS6_vtu$get_point_data_at()}}
\item \href{#method-OGS6_vtu-get_point_data}{\code{OGS6_vtu$get_point_data()}}
\item \href{#method-OGS6_vtu-get_cell_data}{\code{OGS6_vtu$get_cell_data()}}
\item \href{#method-OGS6_vtu-clone}{\code{OGS6_vtu$clone()}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-new"></a>}}
\if{latex}{\out{\hypertarget{method-new}{}}}
\if{html}{\out{<a id="method-OGS6_vtu-new"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6_vtu-new}{}}}
\subsection{Method \code{new()}}{
Creates new OGS6_vtu object.
\subsection{Usage}{
......@@ -64,8 +64,8 @@ Creates new OGS6_vtu object.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-print"></a>}}
\if{latex}{\out{\hypertarget{method-print}{}}}
\if{html}{\out{<a id="method-OGS6_vtu-print"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6_vtu-print}{}}}
\subsection{Method \code{print()}}{
Overrides default printing behaviour.
\subsection{Usage}{
......@@ -74,8 +74,8 @@ Overrides default printing behaviour.
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-get_field_data"></a>}}
\if{latex}{\out{\hypertarget{method-get_field_data}{}}}
\if{html}{\out{<a id="method-OGS6_vtu-get_field_data"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6_vtu-get_field_data}{}}}
\subsection{Method \code{get_field_data()}}{
Gets FieldData.
\subsection{Usage}{
......@@ -97,8 +97,8 @@ elements.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-get_point_coords"></a>}}
\if{latex}{\out{\hypertarget{method-get_point_coords}{}}}
\if{html}{\out{<a id="method-OGS6_vtu-get_point_coords"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6_vtu-get_point_coords}{}}}
\subsection{Method \code{get_point_coords()}}{
Gets coordinates of specific points by their IDs.
\subsection{Usage}{
......@@ -119,8 +119,8 @@ arrays.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-get_point_data_at"></a>}}
\if{latex}{\out{\hypertarget{method-get_point_data_at}{}}}
\if{html}{\out{<a id="method-OGS6_vtu-get_point_data_at"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6_vtu-get_point_data_at}{}}}
\subsection{Method \code{get_point_data_at()}}{
Gets PointData at specified coordinates.
\subsection{Usage}{
......@@ -140,8 +140,8 @@ elements, defaults to all in `PointData`}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-get_point_data"></a>}}
\if{latex}{\out{\hypertarget{method-get_point_data}{}}}
\if{html}{\out{<a id="method-OGS6_vtu-get_point_data"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6_vtu-get_point_data}{}}}
\subsection{Method \code{get_point_data()}}{
Gets PointData for points with IDs in `point_ids`.
\subsection{Usage}{
......@@ -163,8 +163,8 @@ A tibble::tibble where each row represents a point.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-get_cell_data"></a>}}
\if{latex}{\out{\hypertarget{method-get_cell_data}{}}}
\if{html}{\out{<a id="method-OGS6_vtu-get_cell_data"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6_vtu-get_cell_data}{}}}
\subsection{Method \code{get_cell_data()}}{
Gets CellData for cells with IDs in `cell_ids`.
\subsection{Usage}{
......@@ -186,8 +186,8 @@ A tibble::tibble where each row represents a cell.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-clone"></a>}}
\if{latex}{\out{\hypertarget{method-clone}{}}}
\if{html}{\out{<a id="method-OGS6_vtu-clone"></a>}}
\if{latex}{\out{\hypertarget{method-OGS6_vtu-clone}{}}}
\subsection{Method \code{clone()}}{
The objects of this class are cloneable with this method.
\subsection{Usage}{
......
......@@ -97,6 +97,32 @@ test_that("export_prj works for referenced *.dat files", {
unlink(test_path, recursive = TRUE)
})
test_that("export_prj works for referenced *.msh files", {
# Get extdata directory and create folder for the test
extdata_path <- system.file("extdata/", package = "r2ogs6")
test_path <- paste0(extdata_path, "/export_prj_test")
dir.create(test_path)
# Define prj_path and OGS6 object, then read in .prj file
ogs6_obj <- OGS6$new(sim_name = "t1_1Dsource",
sim_path = test_path)
prj_path <- system.file("extdata/benchmarks/t1_1Dsource",
"t1_1Dsource.prj", package = "r2ogs6")
suppressWarnings(read_in_prj(ogs6_obj, prj_path, read_in_gml = F))
# test with copying referenced files
export_prj(ogs6_obj, copy_ext_files = T)
expect_equal(sort(list.files(ogs6_obj$sim_path)),
sort(c("t1_1Dsource.gml", "t1_1Dsource.msh",
"t1_1Dsource.prj")))
# Tidy up by deleting the folder we created
unlink(test_path, recursive = TRUE)
})
test_that("export_prj works for process$include", {
......
test_that("OGS6_msh initialization works", {
msh_path <- system.file("extdata/benchmarks/t1_1Dsource",
"t1_1Dsource.msh",
package = "r2ogs6")
msh_obj <- OGS6_msh$new(msh_path = msh_path)
expect_equal(class(msh_obj)[1], "OGS6_msh")
expect_equal(class(msh_obj$msh_path), "character")
expect_true(grepl("\\.msh$", msh_obj$msh_path))
})
\ No newline at end of file
......@@ -275,7 +275,7 @@ test_that("read_in works for python_script objects", {
})
test_that("read_in works for geometry and vtu meshes", {
test_that("read_in works for geometry and meshes", {
# read gml, vtu
prj_base_path <- system.file(
......@@ -317,6 +317,23 @@ test_that("read_in works for geometry and vtu meshes", {
expect_equal(ogs6_obj$meshes[[2]]$path, vtu_path2)
expect_equal(ogs6_obj$meshes[[3]]$path, vtu_path3)
expect_equal(ogs6_obj$meshes[[4]]$path, vtu_path4)
# read msh
prj_base_path <- system.file("extdata/benchmarks/t1_1Dsource",
package = "r2ogs6")
prj_path <- paste0(prj_base_path, "/t1_1Dsource.prj")
gml_path <- paste0(prj_base_path, "/t1_1Dsource.gml")
msh_path <- paste0(prj_base_path, "/t1_1Dsource.msh")
ogs6_obj <- OGS6$new(sim_name = "sim",
sim_path = "sim_path")
suppressWarnings(read_in_prj(ogs6_obj, prj_path, read_in_gml = F))
expect_equal(ogs6_obj$geometry, gml_path)
expect_equal(ogs6_obj$meshes$mesh$path, msh_path)
rm(ogs6_obj)
})
test_that("read_in works for chemical_system objects", {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment