Mercurial > repos > public > sbplib_julia
comparison test/BoundaryConditions/sat_test.jl @ 1217:ea2e8254820a feature/boundary_conditions
Update docstrings and start implementing tests
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Tue, 07 Feb 2023 21:55:07 +0100 |
parents | |
children | bdcdbd4ea9cd |
comparison
equal
deleted
inserted
replaced
1167:fd80e9a0ef99 | 1217:ea2e8254820a |
---|---|
1 using Test | |
2 | |
3 | |
4 using Sbplib.BoundaryConditions | |
5 using Sbplib.Grids | |
6 using Sbplib.RegionIndices | |
7 using Sbplib.LazyTensors | |
8 | |
9 grid = EquidistantGrid(11, 0.0, 1.0) | |
10 (id_l,id_r) = boundary_identifiers(grid) | |
11 struct MockOp | |
12 end | |
13 | |
14 function BoundaryConditions.sat_tensors(op::MockOp, grid, bc::DirichletCondition) | |
15 sz = size(grid) | |
16 m = sz[1] | |
17 ind = (region(bc.id) == Lower()) ? 1 : m | |
18 e = zeros(m); | |
19 e[ind] = 1. | |
20 eᵀ = ones(Float64,m,0); | |
21 e[ind] = 1. | |
22 c_tensor = LazyTensors.DiagonalTensor(e) | |
23 p_tensor = DenseTensor(eᵀ, (1,), (2,)) | |
24 closure(u) = c_tensor*u | |
25 function penalty(g) | |
26 @show g | |
27 return p_tensor*g | |
28 end | |
29 return closure, penalty | |
30 end | |
31 | |
32 | |
33 @testset "sat" begin | |
34 g = ConstantBoundaryData(2.0) | |
35 dc = DirichletCondition(g,id_l) | |
36 op = MockOp() | |
37 f = sat(op, grid, dc) | |
38 u = evalOn(grid, x-> -1/2 + x^2) | |
39 @show f(0.,u) | |
40 end |