Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/volumeops/derivatives/dissipation.jl @ 1020:3f5137ce3aa1 feature/dissipation_operators
Start adding helper functions for building dissipation operators
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 18 Mar 2022 12:24:10 +0100 |
parents | |
children | ee5a641a8277 |
comparison
equal
deleted
inserted
replaced
988:83046af6143a | 1020:3f5137ce3aa1 |
---|---|
1 function dissipation_interior_weights(p) | |
2 if p == 0 | |
3 return (1,) | |
4 end | |
5 | |
6 return (0, dissipation_interior_weights(p-1)...) .- (dissipation_interior_weights(p-1)..., 0) | |
7 end | |
8 | |
9 function dissipation_interior_stencil(p) | |
10 w = dissipation_interior_weights(p) | |
11 Stencil(w..., center=midpoint(w)) | |
12 end | |
13 | |
14 function dissipation_transpose_interior_stencil(p) | |
15 w = dissipation_interior_weights(p) | |
16 Stencil(w..., center=midpoint_transpose(w)) | |
17 end | |
18 | |
19 | |
20 midpoint(weights) = length(weights)÷2 + 1 | |
21 midpoint_transpose(weights) = length(weights)+1 - midpoint(weights) | |
22 | |
23 dissipation_lower_closure_size(weights) = midpoint(weights) - 1 | |
24 dissipation_upper_closure_size(weights) = length(weights) - midpoint(weights) | |
25 | |
26 dissipation_lower_closure_stencils(interior_weights) = ntuple(i->Stencil(interior_weights..., center=i ), dissipation_lower_closure_size(interior_weights)) | |
27 dissipation_upper_closure_stencils(interior_weights) = ntuple(i->Stencil(interior_weights..., center=length(interior_weights)-dissipation_upper_closure_size(interior_weights)+i), dissipation_upper_closure_size(interior_weights)) | |
28 | |
29 dissipation_transpose_lower_closure_stencils(interior_weights) = ntuple(i->dissipation_transpose_lower_closure_stencil(interior_weights, i), length(interior_weights)) | |
30 dissipation_transpose_upper_closure_stencils(interior_weights) = reverse(ntuple(i->dissipation_transpose_upper_closure_stencil(interior_weights, i), length(interior_weights))) | |
31 | |
32 | |
33 function dissipation_transpose_lower_closure_stencil(interior_weights, i) | |
34 w = ntuple(k->interior_weights[i], dissipation_lower_closure_size(interior_weights)) | |
35 | |
36 for k ∈ i:-1:1 | |
37 w = (w..., interior_weights[k]) | |
38 end | |
39 | |
40 return Stencil(w..., center = i) | |
41 end | |
42 | |
43 function dissipation_transpose_upper_closure_stencil(interior_weights, i) | |
44 j = length(interior_weights)+1-i | |
45 w = ntuple(k->interior_weights[j], dissipation_upper_closure_size(interior_weights)) | |
46 | |
47 for k ∈ j:1:length(interior_weights) | |
48 w = (interior_weights[k], w...) | |
49 end | |
50 | |
51 return Stencil(w..., center = length(interior_weights)-midpoint(interior_weights)+1) | |
52 end |