Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/volumeops/derivatives/dissipation.jl @ 1355:102ebdaf7c11 feature/variable_derivatives
Merge default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 08 Feb 2023 21:21:28 +0100 |
parents | d60a10ad6579 |
children | 356ec6a72974 |
comparison
equal
deleted
inserted
replaced
1210:fa0800591306 | 1355:102ebdaf7c11 |
---|---|
1 function undivided_dissipation(g::EquidistantGrid, p, direction) | 1 """ |
2 undivided_skewed04(g::EquidistantGrid, p, direction) | |
3 | |
4 Create undivided difference operators approximating the `p`th derivative. The | |
5 operators do not satisfy any SBP-property and are meant to be used for | |
6 building artificial dissipation terms. | |
7 | |
8 The operators and how they are used to create accurate artifical dissipation | |
9 is described in "K. Mattsson, M. Svärd, and J. Nordström, “Stable and Accurate | |
10 Artificial Dissipation,” Journal of Scientific Computing, vol. 21, no. 1, pp. | |
11 57–79, Aug. 2004" | |
12 """ | |
13 function undivided_skewed04(g::EquidistantGrid, p, direction) | |
2 T = eltype(g) | 14 T = eltype(g) |
3 interior_weights = T.(dissipation_interior_weights(p)) | 15 interior_weights = T.(dissipation_interior_weights(p)) |
4 | 16 |
5 D = stencil_operator_distinct_closures( | 17 D = stencil_operator_distinct_closures( |
6 g, | 18 g, |
18 ) | 30 ) |
19 | 31 |
20 return D, Dᵀ | 32 return D, Dᵀ |
21 end | 33 end |
22 | 34 |
23 undivided_dissipation(g::EquidistantGrid{1}, p) = undivided_dissipation(g, p, 1) | 35 undivided_skewed04(g::EquidistantGrid{1}, p) = undivided_skewed04(g, p, 1) |
24 | 36 |
25 function dissipation_interior_weights(p) | 37 function dissipation_interior_weights(p) |
26 if p == 0 | 38 if p == 0 |
27 return (1,) | 39 return (1,) |
28 end | 40 end |
45 end | 57 end |
46 | 58 |
47 dissipation_lower_closure_size(weights) = midpoint(weights) - 1 | 59 dissipation_lower_closure_size(weights) = midpoint(weights) - 1 |
48 dissipation_upper_closure_size(weights) = length(weights) - midpoint(weights) | 60 dissipation_upper_closure_size(weights) = length(weights) - midpoint(weights) |
49 | 61 |
50 dissipation_lower_closure_stencils(interior_weights) = ntuple(i->Stencil(interior_weights..., center=i ), dissipation_lower_closure_size(interior_weights)) | 62 function dissipation_lower_closure_stencils(interior_weights) |
51 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)) | 63 stencil(i) = Stencil(interior_weights..., center=i) |
64 return ntuple(i->stencil(i), dissipation_lower_closure_size(interior_weights)) | |
65 end | |
66 | |
67 function dissipation_upper_closure_stencils(interior_weights) | |
68 center(i) = length(interior_weights) - dissipation_upper_closure_size(interior_weights) + i | |
69 stencil(i) = Stencil(interior_weights..., center=center(i)) | |
70 return ntuple(i->stencil(i), dissipation_upper_closure_size(interior_weights)) | |
71 end | |
52 | 72 |
53 function dissipation_transpose_lower_closure_stencils(interior_weights) | 73 function dissipation_transpose_lower_closure_stencils(interior_weights) |
54 closure = ntuple(i->dissipation_transpose_lower_closure_stencil(interior_weights, i), length(interior_weights)) | 74 closure = ntuple(i->dissipation_transpose_lower_closure_stencil(interior_weights, i), length(interior_weights)) |
55 | 75 |
56 N = maximum(s->length(s.weights), closure) | 76 N = maximum(s->length(s.weights), closure) |