From ee1e6923b3c5e73dbe2622107b3af8927a5a655c Mon Sep 17 00:00:00 2001
From: aheinri5 <Anna@netzkritzler.de>
Date: Tue, 24 Nov 2020 09:24:21 +0100
Subject: [PATCH] [structure] Moved examples folder to inst directory since
 it's not a standard top level directory

---
 inst/examples/read_from_benchmark_example.R |  32 +++
 inst/examples/square_1x1_quad8_1e2.vtu      |  33 +++
 inst/examples/user_input_example.R          | 235 ++++++++++++++++++++
 3 files changed, 300 insertions(+)
 create mode 100644 inst/examples/read_from_benchmark_example.R
 create mode 100644 inst/examples/square_1x1_quad8_1e2.vtu
 create mode 100644 inst/examples/user_input_example.R

diff --git a/inst/examples/read_from_benchmark_example.R b/inst/examples/read_from_benchmark_example.R
new file mode 100644
index 0000000..19bbc55
--- /dev/null
+++ b/inst/examples/read_from_benchmark_example.R
@@ -0,0 +1,32 @@
+detach("package:r2ogs6", unload=TRUE)
+library(r2ogs6)
+
+
+#This is where the user defines their data.
+
+#============================== SET UP SIMULATION OBJECT ================================
+
+#If you want to test this, don't forget to alter the ogs_bin_path to fit your installation location!
+
+#First, we need to create a simulation object.
+
+ogs6_obj <- OGS6$new(sim_name = "my_sim",
+                     sim_id = 1,
+                     sim_path = "D:\\OGS_Sim\\",
+                     ogs_bin_path = "D:\\Programme\\OpenGeoSys\\ogs-6.3.2-Windows-10.0.14393-x64-python-3.7.2-de-utils\\bin\\")
+
+#============================== READ IN .prj FILE ================================
+
+#This will only work if the working directory is r2ogs6, but is fine for testing purposes.
+prj_path <- paste0("inst/extdata/flow_free_expansion/flow_free_expansion.prj")
+
+#prj_path = paste0("D:\\Programme\\OpenGeoSys\\ogs-master-Tests-Data-HydroMechanics\\",
+#                                        "Tests\\Data\\HydroMechanics\\IdealGas\\flow_no_strain\\flow_no_strain.prj")
+
+read_in_prj(ogs6_obj, prj_path)
+
+#============================== Execution ================================
+
+#Calls ogs6 object validator functions, exports all necessary files and starts OpenGeoSys6
+
+run_simulation(ogs6_obj)
diff --git a/inst/examples/square_1x1_quad8_1e2.vtu b/inst/examples/square_1x1_quad8_1e2.vtu
new file mode 100644
index 0000000..32a0c26
--- /dev/null
+++ b/inst/examples/square_1x1_quad8_1e2.vtu
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
+  <UnstructuredGrid>
+    <Piece NumberOfPoints="341" NumberOfCells="100">
+      <PointData>
+      </PointData>
+      <CellData>
+      </CellData>
+      <Points>
+        <DataArray type="Float64" Name="Points" NumberOfComponents="3" format="binary" RangeMin="0" RangeMax="1.4142135624">
+          AQAAAACAAAD4HwAAAwQAAA==eJx1WEuK3TAQnDsl+9wmd0pu8I6Q9awEEzAEBgRZvEEhWDgYHSHMM81QP+1ULlqtakvq7qcnP75/ex8/vni8Cf7pMX4Ffhf8GvdgZwj+9TH+BvtT8J8v7+NfWHcFXPddc483wUsHz++CX+Me7AzBSwdvfwpeOvh1V8A1zqgD401w1IH5XXDUge0MwVEHtj8FRx143RVw/a9LB483wWvu+V3w0sHbGYKXDt7+FLx08OuugOs5xv+B8SY4/g/M74KXDt7OEBz/B7Y/Bcf/gdddAf/wi3XweBMc9WV+FxznbGcIjvck25+C4z3J666A6z2N54LxJjieC+Z3wcsPb2cIjueC7U/B8Vzwuivg+i6VDh5vgpcOnt8FLx28nSF4zb39KXjp4NddAdd3GO8HxpvgeD8wvwteOng7Q3C8H9j+FBzvB153BVzzjtLB403w0sHzu+Clg7czBC8dvP0peM39uivgH99ZB483wfGeZH4XvHTwdobg+B+z/Sk47pPXXcHOLeii3z8//HwO56rOEdvbYt7G/Gu/rzG/Yf61398xD2D+NX+L7yXzH+Zf/sR3xe93j/ev1/OI95TX54zn2fuzgg63mFdznGue6g7/X2yxHmF+xT3VKcyvuKf6hfkV91TXML/inuodv9891kFezyPWR16fM9ZN3p8VdKi4ax1xjS3EXess5tc81V/Mx7hrXcZ8jLvWa8zHuGsdx3yMu9Z3fr+78PHeZj2P4P8M+pzCx3ue/VlBh1usm/jerbgzH/NGvqe3WG8yv+bMxzzzVeLu7XfhV9z9fu/Cr7h7f0bY7x7rXK/nEetfr88Z62Lvzwo61HnXOpHfTzzvWkf793YL/CZ8PO9adzMfz7vW48zH8651OvPxvGv97ve7Cx/zVdbzCP7PoM8pfMxv2Z8VdKj3XutizoPwndC+gc+btsBvwsf/UvsMzMf9aP+B+TjXvgTzMa/TfoXf7y58zOtYzyP4P4M+p/Axr2N/VtDhFvsAnM/iPa99Ep//brF/wny857Wvwny857Xfwny857UPw3y857U/4/e7x76N1/OI/Ryvzxn7PN6fFXS4xb5H7QP9fA79lsrruI7ZYr+I+RV35uN7tkvcvf0u/Iq73+9d+KWX92eE/e6xT8X8irv3fwZ9ztjX8v6soEO979rn4foS33ftg/l6dAv8Jnx837Vvxnx837Wfxnx837XPxnx837X/5ve7C7/i5PU8gv8z6HMKH+s49mcFHW6xr4XvyUfcU9+P+dfYYj+Q+RX31CdkfsU99Q+ZX3FPfUXmV9xTv9Hvd499SK/nEfuTXp8z9i29PyvoUHndkvgyfo1N8IoX45h3cZ/wTXB8h3jdPfh5BH9Owf8Dtpa8yQ==
+        </DataArray>
+      </Points>
+      <Cells>
+        <DataArray type="Int64" Name="connectivity" format="binary" RangeMin="0" RangeMax="340">
+          AQAAAACAAAAAGQAAuwQAAA==eJxdl0XUkFUYBvno7s6f7u7+aUFsVGxssRW7JezuFluxMcDG7ha7G7u7Fj6z+OZuZvXMas57zq1S5f9XhPXDeuHB4WHhKeEh2lUNG8hzaHhEeJp87KqFDeU5PDwqPEM+dtXDRvIcGS4Mz5KPXY2wsTxHh4vDc+RjVzNsIs+i8JjwPPnY1QqbyrMkPC68QD52tcNm8hwbnhBeJB+7OmFzeY4PTwovkY9d3bCFPCeGJ4dL5aMzemkVtgzp7fTwivBU7eiltTz0dmZ4lXzs6KWNPPR2dniNfOzopa089HZueJ187OilnTz0dn54vXzs6KW9PPR2YXijfOzopYM89HZxeLN87O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Gc+/lozN62SvcM6S30dzbcGRR3tHL3vLQ29hwtnzs6GUfeehtPPdaPnb0sq889DaRey0fO3pZIA+9TeJey8eOXvaTh96mcK/lY0cv+8tDb9O41/Kxo5cD5KG3Gdxr+djRy4Hy0NtM7rV87OjuIHnobRb3Wr7/ABCELb4=
+        </DataArray>
+        <DataArray type="Int64" Name="offsets" format="binary" RangeMin="8" RangeMax="800">
+          AQAAAACAAAAgAwAApgAAAA==eJwtxRFghAAAAMC2SRiGYRg+huFjGIZhGIZh+BiGYRiGYfgYhoPu5MLgETl24tSZX85d+O3SlWs3bt259+DRH0+evXj15t2HT399+Xbw8xQ6cuzEqTO/nLvw26Ur127cunPvwaM/njx78erNuw+f/vry7eD3KXTk2IlTZ345d+G3S1eu3bh1596DR388efbi1Zt3Hz799eXbwd9T6MixE/8DLbMvQA==
+        </DataArray>
+        <DataArray type="UInt8" Name="types" format="binary" RangeMin="23" RangeMax="23">
+          AQAAAACAAABkAAAADAAAAA==eJwTF6c9AADGKQj9
+        </DataArray>
+        <DataArray type="Int64" Name="faces" format="binary" RangeMin="0" RangeMax="0">
+          AQAAAACAAAAgAwAAEAAAAA==eJxjYBgFo2AU4AIAAyAAAQ==
+        </DataArray>
+        <DataArray type="Int64" Name="faceoffsets" format="binary" RangeMin="1" RangeMax="100">
+          AQAAAACAAAAgAwAArwAAAA==eJwtxdciAgAAAEAjkYRskazskpUtFJGRUbYI//8NHrp7ueamhha3OuA2B93uDofc6bC7HHG3e9zrqPvc7wEPesjDHvGoYx7zuOOecMKTnvK0ZzzrpOc87wUvesnLXnHKaa864zWve8Ob3nLW297xrve87wMf+sg5H/vEp8674DOfu+gLX7rkK1/7xrcu+873fvCjK676yc9+8avf/O4Pf7rmL3+77h//+s//+ewTuw==
+        </DataArray>
+      </Cells>
+    </Piece>
+  </UnstructuredGrid>
+</VTKFile>
diff --git a/inst/examples/user_input_example.R b/inst/examples/user_input_example.R
new file mode 100644
index 0000000..89546b7
--- /dev/null
+++ b/inst/examples/user_input_example.R
@@ -0,0 +1,235 @@
+detach("package:r2ogs6", unload=TRUE)
+library(r2ogs6)
+
+
+#This is where the user defines their data.
+
+#============================== SET UP SIMULATION OBJECT ================================
+
+#If you want to test this, don't forget to alter the paths to fit your system!
+
+#First, we need to create a simulation object.
+
+ogs6_obj <- OGS6$new(sim_name = "my_sim",
+                     sim_id = 1,
+                     sim_path = "D:\\OGS_Sim\\",
+                     ogs_bin_path = "D:\\Programme\\OpenGeoSys\\ogs-6.3.2-Windows-10.0.14393-x64-python-3.7.2-de-utils\\bin\\")
+
+
+#============================== ADD .gml DATA ================================
+
+#(source: HydroComponent Benchmarks -> IdealGas -> flow_no_strain -> square_1x1.gml)
+
+#Add some geometry
+input_add(r2ogs6_gml(name = "square_1x1_geometry",
+                     points = tibble::tibble(x = c(0, 0, 1, 1),
+                                             y = c(0, 1, 0, 1),
+                                             z = c(0, 0, 0, 0),
+                                             name = c("origin", rep("", 3))),
+                     polylines = list(list(name = "left", c(0, 1)),
+                                      list(name = "right", c(2, 3)),
+                                      list(name = "bottom", c(0, 2)),
+                                      list(name = "top", c(1, 3)))),
+          ogs6_obj)
+
+#============================== ADD .vtu DATA ================================
+
+#Let's add our data for the .vtk file, which contains information about our mesh.
+
+# #This calls an external script (which is why we needed to specify some paths earlier)
+# generate_structured_mesh(ogs6_obj, "-e quad --lx 1 --ly 1 --lz 1")
+
+#To make sure our geometry is right, let's copy the .vtu from the benchmark
+# we're trying to reverse engineer...
+
+pick_vtu_file(ogs6_obj)
+
+
+#============================== ADD .prj DATA ================================
+
+#Let's add our data for the .prj file, arguably the most important file.
+#(source: HydroComponent Benchmarks -> IdealGas -> flow_no_strain -> flow_no_strain.prj)
+
+#We need:
+#1. Either one mesh and one geometry file OR multiple mesh files (for the latter case: Skip to
+# previous part and call generate_structured_mesh at least one more time)
+
+#2. One or more process elements:
+input_add(r2ogs6_process(name = "HM",
+                         type = "HYDRO_MECHANICS",
+                         integration_order = 3,
+                         dimension = 2,
+                         constitutive_relation = c(type = "LinearElasticIsotropic",
+                                                   youngs_modulus = "E",
+                                                   poissons_ratio = "nu"),
+                         process_variables = c(displacement = "displacement",
+                                               pressure = "pressure"),
+                         secondary_variables = list(c("sigma_xx", "sigma_xx"),
+                                                    c("sigma_yy", "sigma_yy"),
+                                                    c("sigma_zz", "sigma_zz"),
+                                                    c("sigma_xy", "sigma_xy"),
+                                                    c("epsilon_xx", "epsilon_xx"),
+                                                    c("epsilon_yy", "epsilon_yy"),
+                                                    c("epsilon_zz", "epsilon_zz"),
+                                                    c("epsilon_xy", "epsilon_xy"),
+                                                    c("velocity", "velocity")),
+                         specific_body_force = c(0, 0)),
+          ogs6_obj)
+
+#3. One time_loop element:
+input_add(r2ogs6_time_loop(processes = list(r2ogs6_tl_process(ref = "HM",
+                                                              nonlinear_solver = "basic_newton",
+                                                              convergence_criterion = list(type = "PerComponentDeltaX",
+                                                                                           norm_type = "NORM2",
+                                                                                           reltols = "5e-8 1e10 1e10"),
+                                                              time_discretization = list(type = "BackwardEuler"),
+                                                              time_stepping = list(type = "FixedTimeStepping",
+                                                                                   t_initial = 0,
+                                                                                   t_end = 100,
+                                                                                   timesteps = list(pair = list(rep = 1,
+                                                                                                                delta_t = 0.1))
+                                                                                   )
+                                                              )),
+                           output = r2ogs6_tl_output(type = "VTK",
+                                                     prefix = "flow_no_strain_pcs_{:process_id}",
+                                                     suffix = "_ts_{:timestep}_t_{:time}",
+                                                     timesteps = list(pair = list(rep = 1,
+                                                                              each_steps = 1000)),
+                                                     variables = list("displacement",
+                                                                      "pressure",
+                                                                      "sigma_xx",
+                                                                      "sigma_yy",
+                                                                      "sigma_zz",
+                                                                      "sigma_xy",
+                                                                      "epsilon_xx",
+                                                                      "epsilon_yy",
+                                                                      "epsilon_zz",
+                                                                      "epsilon_xy",
+                                                                      "velocity"))),
+          ogs6_obj)
+
+#4. One or more medium elements:
+input_add(r2ogs6_medium(phases = list(r2ogs6_medium_phase(type = "Gas",
+                                                          properties = list(r2ogs6_medium_property(name = "viscosity",
+                                                                                                   type = "Constant",
+                                                                                                   value = 1e-5),
+                                                                            r2ogs6_medium_property(name = "density",
+                                                                                                   type = "IdealGasLaw"),
+                                                                            r2ogs6_medium_property(name = "molar_mass",
+                                                                                                   type = "Constant",
+                                                                                                   value = 0.028964397787206768))),
+                                      r2ogs6_medium_phase(type = "Solid",
+                                                          properties = list(r2ogs6_medium_property(name = "porosity",
+                                                                                                   type = "Constant",
+                                                                                                   value = 0.03),
+                                                                            r2ogs6_medium_property(name = "density",
+                                                                                                   type = "Constant",
+                                                                                                   value = 2.17e3),
+                                                                            r2ogs6_medium_property(name = "biot_coefficient",
+                                                                                                   type = "Constant",
+                                                                                                   value = 0.6)))),
+                        properties = list(r2ogs6_medium_property(name = "reference_temperature",
+                                                                 type = "Constant",
+                                                                 value = 293.15),
+                                          r2ogs6_medium_property(name = "permeability",
+                                                                 type = "Constant",
+                                                                 value = 1e-4))),
+          ogs6_obj)
+
+#5. One or more parameters:
+input_add(r2ogs6_parameter(name = "E",
+                           type = "Constant",
+                           values = 1e9),
+          ogs6_obj)
+
+input_add(r2ogs6_parameter(name = "nu",
+                           type = "Constant",
+                           values = .3),
+          ogs6_obj)
+
+input_add(r2ogs6_parameter(name = "displacement0",
+                           type = "Constant",
+                           values = c(0, 0)),
+          ogs6_obj)
+
+input_add(r2ogs6_parameter(name = "pressure0",
+                           type = "Constant",
+                           values = 1e5),
+          ogs6_obj)
+
+input_add(r2ogs6_parameter(name = "zero",
+                           type = "Constant",
+                           values = 0),
+          ogs6_obj)
+
+input_add(r2ogs6_parameter(name = "flux",
+                           type = "Constant",
+                           values = 1e-3),
+          ogs6_obj)
+
+
+#6. One or more process variables
+input_add(r2ogs6_process_variable(name = "displacement",
+                                  components = 2,
+                                  order = 2,
+                                  initial_condition = "displacement0",
+                                  boundary_conditions = list(r2ogs6_boundary_condition(type = "Dirichlet",
+                                                                                       parameter = "zero",
+                                                                                       component = 0,
+                                                                                       geometrical_set = "square_1x1_geometry",
+                                                                                       geometry = "left"),
+                                                             r2ogs6_boundary_condition(type = "Dirichlet",
+                                                                                       parameter = "zero",
+                                                                                       component = 1,
+                                                                                       geometrical_set = "square_1x1_geometry",
+                                                                                       geometry = "bottom"),
+                                                             r2ogs6_boundary_condition(type = "Dirichlet",
+                                                                                       parameter = "zero",
+                                                                                       component = 0,
+                                                                                       geometrical_set = "square_1x1_geometry",
+                                                                                       geometry = "right"),
+                                                             r2ogs6_boundary_condition(type = "Dirichlet",
+                                                                                       parameter = "zero",
+                                                                                       component = 1,
+                                                                                       geometrical_set = "square_1x1_geometry",
+                                                                                       geometry = "top"))),
+          ogs6_obj)
+
+input_add(r2ogs6_process_variable(name = "pressure",
+                                  components = 1,
+                                  order = 1,
+                                  initial_condition = "pressure0",
+                                  boundary_conditions = list(r2ogs6_boundary_condition(type = "Neumann",
+                                                                                       parameter = "flux",
+                                                                                       component = 0,
+                                                                                       geometrical_set = "square_1x1_geometry",
+                                                                                       geometry = "left")
+                                                             )
+                                  ),
+          ogs6_obj)
+
+#7. One or more nonlinear solvers
+input_add(r2ogs6_nonlinear_solver(name = "basic_newton",
+                                  type = "Newton",
+                                  max_iter = 50,
+                                  linear_solver = "general_linear_solver"),
+          ogs6_obj)
+
+#8. One or more linear solvers
+input_add(r2ogs6_linear_solver(name = "general_linear_solver",
+                               eigen = list(solver_type = "BiCGSTAB",
+                                            precon_type = "ILUT",
+                                            max_iteration_step = 10000,
+                                            error_tolerance = 1e-16),
+                               lis = "-i bicgstab -p ilu -tol 1e-16 -maxiter 10000"),
+          ogs6_obj)
+
+
+#OPTIONAL: A test definition
+
+#============================== Execution ================================
+
+#Calls ogs6 object validator functions, exports all necessary files and starts OpenGeoSys6
+
+run_simulation(ogs6_obj)
+
-- 
GitLab