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

[benchmark] add bm for testing prj_python_script

parent 47c8fec5
No related branches found
No related tags found
1 merge request!41standardize files references during prj import/export (new MR)
import OpenGeoSys
from math import pi, sin, cos, sinh, cosh
a = 2.0 * pi / 3.0
# analytical solution used to set the Dirichlet BCs
def solution(x, y):
return sin(a * x) * sinh(a * y)
# gradient of the analytical solution used to set the Neumann BCs
def grad_solution(x, y):
return a * cos(a * x) * sinh(a * y), a * sin(a * x) * cosh(a * y)
# Dirichlet BCs
class BCTop(OpenGeoSys.BoundaryCondition):
def getDirichletBCValue(self, t, coords, node_id, primary_vars):
x, y, z = coords
assert y == 1.0 and z == 0.0
value = solution(x, y)
return (True, value)
class BCLeft(OpenGeoSys.BoundaryCondition):
def getDirichletBCValue(self, t, coords, node_id, primary_vars):
x, y, z = coords
assert x == 0.0 and z == 0.0
value = solution(x, y)
return (True, value)
class BCBottom(OpenGeoSys.BoundaryCondition):
def getDirichletBCValue(self, t, coords, node_id, primary_vars):
x, y, z = coords
assert y == 0.0 and z == 0.0
value = solution(x, y)
return (True, value)
# Neumann BC
class BCRight(OpenGeoSys.BoundaryCondition):
def getFlux(self, t, coords, primary_vars):
x, y, z = coords
assert x == 1.0 and z == 0.0
value = grad_solution(x, y)[0]
Jac = [0.0] # value does not depend on primary variable
return (True, value, Jac)
# instantiate BC objects referenced in OpenGeoSys' prj file
bc_top = BCTop()
bc_right = BCRight()
bc_bottom = BCBottom()
bc_left = BCLeft()
<?xml version="1.0" encoding="ISO-8859-1"?>
<OpenGeoSysProject>
<mesh>square_1x1_quad_1e3.vtu</mesh>
<geometry>square_1x1.gml</geometry>
<python_script>bcs_laplace_eq.py</python_script>
<media>
<medium id="0">
<phases/>
<properties>
<property>
<name>diffusion</name>
<type>Constant</type>
<value>1</value>
</property>
<property>
<name>reference_temperature</name>
<type>Constant</type>
<value>293.15</value>
</property>
</properties>
</medium>
</media>
<processes>
<process>
<name>SteadyStateDiffusion</name>
<type>STEADY_STATE_DIFFUSION</type>
<integration_order>2</integration_order>
<process_variables>
<process_variable>pressure</process_variable>
</process_variables>
<secondary_variables>
<secondary_variable internal_name="darcy_velocity" output_name="v"/>
</secondary_variables>
<jacobian_assembler>
<type>CentralDifferences</type>
</jacobian_assembler>
</process>
</processes>
<time_loop>
<processes>
<process ref="SteadyStateDiffusion">
<nonlinear_solver>basic_newton</nonlinear_solver>
<convergence_criterion>
<type>DeltaX</type>
<norm_type>NORM2</norm_type>
<abstol>1.e-6</abstol>
</convergence_criterion>
<time_discretization>
<type>BackwardEuler</type>
</time_discretization>
<time_stepping>
<type>SingleStep</type>
</time_stepping>
</process>
</processes>
<output>
<type>VTK</type>
<prefix>square_1e3_neumann</prefix>
<variables>
<variable> pressure </variable>
<variable> v </variable>
</variables>
<suffix>_ts_{:timestep}_t_{:time}</suffix>
</output>
</time_loop>
<parameters>
<parameter>
<name>zero</name>
<type>Constant</type>
<value>0</value>
</parameter>
</parameters>
<process_variables>
<process_variable>
<name>pressure</name>
<components>1</components>
<order>1</order>
<initial_condition>zero</initial_condition>
<boundary_conditions>
<boundary_condition>
<geometrical_set>square_1x1_geometry</geometrical_set>
<geometry>left</geometry>
<type>Python</type>
<bc_object>bc_left</bc_object>
</boundary_condition>
<boundary_condition>
<geometrical_set>square_1x1_geometry</geometrical_set>
<geometry>right</geometry>
<type>Python</type>
<bc_object>bc_right</bc_object>
</boundary_condition>
<boundary_condition>
<geometrical_set>square_1x1_geometry</geometrical_set>
<geometry>top</geometry>
<type>Python</type>
<bc_object>bc_top</bc_object>
</boundary_condition>
<boundary_condition>
<geometrical_set>square_1x1_geometry</geometrical_set>
<geometry>bottom</geometry>
<type>Python</type>
<bc_object>bc_bottom</bc_object>
</boundary_condition>
</boundary_conditions>
</process_variable>
</process_variables>
<nonlinear_solvers>
<nonlinear_solver>
<name>basic_newton</name>
<type>Newton</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-16 -maxiter 10000</lis>
<eigen>
<solver_type>CG</solver_type>
<precon_type>DIAGONAL</precon_type>
<max_iteration_step>10000</max_iteration_step>
<error_tolerance>1e-16</error_tolerance>
</eigen>
<petsc>
<prefix>gw</prefix>
<parameters>-gw_ksp_type cg -gw_pc_type bjacobi -gw_ksp_rtol 1e-16 -gw_ksp_max_it 10000</parameters>
</petsc>
</linear_solver>
</linear_solvers>
</OpenGeoSysProject>
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="OpenGeoSysGLI.xsl"?>
<OpenGeoSysGLI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.opengeosys.org/images/xsd/OpenGeoSysGLI.xsd" xmlns:ogs="http://www.opengeosys.org">
<name>square_1x1_geometry</name>
<points>
<point id="0" x="0" y="0" z="0" name="ll"/>
<point id="1" x="0" y="1" z="0" name="lr"/>
<point id="2" x="1" y="0" z="0" name="ul"/>
<point id="3" x="1" y="1" z="0" name="ur"/>
<point id="4" x="0.5" y="0.5" z="0" name="middle_point"/>
</points>
<polylines>
<polyline id="0" name="left">
<pnt>0</pnt>
<pnt>1</pnt>
</polyline>
<polyline id="1" name="right">
<pnt>2</pnt>
<pnt>3</pnt>
</polyline>
<polyline id="2" name="bottom">
<pnt>0</pnt>
<pnt>2</pnt>
</polyline>
<polyline id="3" name="top">
<pnt>1</pnt>
<pnt>3</pnt>
</polyline>
</polylines>
</OpenGeoSysGLI>
File added
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