comparison test/BoundaryConditions/sat_test.jl @ 1602:3e7438e2a033 feature/boundary_conditions

Address review comments (1 left to be discussed)
author Vidar Stiernström <vidar.stiernstrom@gmail.com>
date Sat, 01 Jun 2024 17:39:54 -0700
parents 330c39505a94
children
comparison
equal deleted inserted replaced
1601:fad18896d20a 1602:3e7438e2a033
8 8
9 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order = 4) 9 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order = 4)
10 10
11 struct MockOp end 11 struct MockOp end
12 12
13 function BoundaryConditions.sat_tensors(op::MockOp, g::Grid, bc::DirichletCondition) 13 function BoundaryConditions.sat_tensors(op::MockOp, g::Grid, bc::DirichletCondition; a = 1.)
14 e = boundary_restriction(g, stencil_set, id(bc)) 14 e = boundary_restriction(g, stencil_set, boundary(bc))
15 L = e 15 L = a*e
16 sat_op = e' 16 sat_op = e'
17 return sat_op, L 17 return sat_op, L
18 end 18 end
19 19
20 function BoundaryConditions.sat_tensors(op::MockOp, g::Grid, bc::NeumannCondition) 20 function BoundaryConditions.sat_tensors(op::MockOp, g::Grid, bc::NeumannCondition)
21 e = boundary_restriction(g, stencil_set, id(bc)) 21 e = boundary_restriction(g, stencil_set, boundary(bc))
22 d = normal_derivative(g, stencil_set, id(bc)) 22 d = normal_derivative(g, stencil_set, boundary(bc))
23 L = d 23 L = d
24 sat_op = e' 24 sat_op = e'
25 return sat_op, L 25 return sat_op, L
26 end 26 end
27 27
52 r_W = zeros(size(grid)) 52 r_W = zeros(size(grid))
53 r_W[1,:] .= map(y -> (y^2-1.), range(0., 1., length=13)) 53 r_W[1,:] .= map(y -> (y^2-1.), range(0., 1., length=13))
54 @test SAT_W(u, g_W) ≈ r_W atol = 1e-13 54 @test SAT_W(u, g_W) ≈ r_W atol = 1e-13
55 55
56 dc_E = DirichletCondition(2, E) 56 dc_E = DirichletCondition(2, E)
57 SAT_E = sat(op, grid, dc_E) 57 SAT_E = sat(op, grid, dc_E; a = 2.)
58 g_E = discretize_data(grid, dc_E) 58 g_E = discretize_data(grid, dc_E)
59 r_E = zeros(size(grid)) 59 r_E = zeros(size(grid))
60 r_E[end,:] .= map(y -> ((1. + y^2)-2.), range(0., 1., length=13)) 60 r_E[end,:] .= map(y -> (2*(1. + y^2)-2.), range(0., 1., length=13))
61 @test SAT_E(u, g_E) ≈ r_E atol = 1e-13 61 @test SAT_E(u, g_E) ≈ r_E atol = 1e-13
62 62
63 nc_S = NeumannCondition(.0, S) 63 nc_S = NeumannCondition(.0, S)
64 SAT_S = sat(op, grid, nc_S) 64 SAT_S = sat(op, grid, nc_S)
65 g_S = discretize_data(grid, nc_S) 65 g_S = discretize_data(grid, nc_S)