Commit fa92caae by Lars Bilke

### Format python: Tests/.

parent 3a6977e0
 import OpenGeoSys from math import pi, sin, cos, sinh, cosh a = 2.0*pi/3.0 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) 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) return a * cos(a * x) * sinh(a * y), a * sin(a * x) * cosh(a * y) # Dirichlet BCs class BCTop(OpenGeoSys.BoundaryCondition): ... ... @@ -21,6 +21,7 @@ class BCTop(OpenGeoSys.BoundaryCondition): value = solution(x, y) return (True, value) class BCLeft(OpenGeoSys.BoundaryCondition): def getDirichletBCValue(self, t, coords, node_id, primary_vars): x, y, z = coords ... ... @@ -28,6 +29,7 @@ class BCLeft(OpenGeoSys.BoundaryCondition): value = solution(x, y) return (True, value) class BCBottom(OpenGeoSys.BoundaryCondition): def getDirichletBCValue(self, t, coords, node_id, primary_vars): x, y, z = coords ... ... @@ -35,13 +37,14 @@ class BCBottom(OpenGeoSys.BoundaryCondition): 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 Jac = [0.0] # value does not depend on primary variable return (True, value, Jac) ... ...
 import OpenGeoSys from math import pi, sin a = 2.0*pi b = 2.0*pi a = 2.0 * pi b = 2.0 * pi def solution(x, y): return sin(a*x-pi/2.0) * sin(b*y-pi/2.0) return sin(a * x - pi / 2.0) * sin(b * y - pi / 2.0) # - laplace(solution) = source term def laplace_solution(x, y): return a*a * sin(a*x-pi/2.0) * sin(b*y-pi/2.0) + b*b * sin(a*x-pi/2.0) * sin(b*y-pi/2.0) return a * a * sin(a * x - pi / 2.0) * sin(b * y - pi / 2.0) + b * b * sin( a * x - pi / 2.0 ) * sin(b * y - pi / 2.0) # source term for the benchmark class SinXSinYSourceTerm(OpenGeoSys.SourceTerm): def getFlux(self, t, coords, primary_vars): x, y, z = coords value = laplace_solution(x,y) Jac = [ 0.0 ] value = laplace_solution(x, y) Jac = [0.0] return (value, Jac) # instantiate source term object referenced in OpenGeoSys' prj file sinx_siny_source_term = SinXSinYSourceTerm()