annotate src/SbpOperators/volumeops/laplace/laplace.jl @ 1619:1937be9502a7 feature/boundary_conditions

REVIEW: Minor fixes to doc strings in laplace.jl
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 11 Jun 2024 00:19:09 +0200
parents e41eddc640f3
children 707fc9761c2b f28c92ec843c 84aed3abab94
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
624
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
1 """
995
1ba8a398af9c Rename types
Jonatan Werpers <jonatan@werpers.com>
parents: 962
diff changeset
2 Laplace{T, Dim, TM} <: LazyTensor{T, Dim, Dim}
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
3
1329
e94ddef5e72f Clean up documentation for changed types in SbpOperatorClean up documentation for changed types in SbpOperatorss
Jonatan Werpers <jonatan@werpers.com>
parents: 1291
diff changeset
4 The Laplace operator, approximating ∑d²/xᵢ² , i = 1,...,`Dim` as a
e94ddef5e72f Clean up documentation for changed types in SbpOperatorClean up documentation for changed types in SbpOperatorss
Jonatan Werpers <jonatan@werpers.com>
parents: 1291
diff changeset
5 `LazyTensor`.
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
6 """
995
1ba8a398af9c Rename types
Jonatan Werpers <jonatan@werpers.com>
parents: 962
diff changeset
7 struct Laplace{T, Dim, TM<:LazyTensor{T, Dim, Dim}} <: LazyTensor{T, Dim, Dim}
951
66e8faf4bb4b Reviwe: Some more comments
Jonatan Werpers <jonatan@werpers.com>
parents: 948
diff changeset
8 D::TM # Difference operator
989
7bf3121c6864 Add type StencilSet
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 962
diff changeset
9 stencil_set::StencilSet # Stencil set of the operator
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
10 end
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
11
924
12e8e431b43c Start restructuring Laplace making it more minimal.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 922
diff changeset
12 """
1347
08f06bfacd5c Fix typos and formatting of documentation
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1329
diff changeset
13 Laplace(g::Grid, stencil_set::StencilSet)
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
14
1347
08f06bfacd5c Fix typos and formatting of documentation
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1329
diff changeset
15 Creates the `Laplace` operator `Δ` on `g` given `stencil_set`.
989
7bf3121c6864 Add type StencilSet
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 962
diff changeset
16
7bf3121c6864 Add type StencilSet
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 962
diff changeset
17 See also [`laplace`](@ref).
924
12e8e431b43c Start restructuring Laplace making it more minimal.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 922
diff changeset
18 """
1291
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
19 function Laplace(g::Grid, stencil_set::StencilSet)
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
20 Δ = laplace(g, stencil_set)
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
21 return Laplace(Δ, stencil_set)
667
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
22 end
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
23
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
24 LazyTensors.range_size(L::Laplace) = LazyTensors.range_size(L.D)
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
25 LazyTensors.domain_size(L::Laplace) = LazyTensors.domain_size(L.D)
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
26 LazyTensors.apply(L::Laplace, v::AbstractArray, I...) = LazyTensors.apply(L.D,v,I...)
f3a0d1f7d842 Make Laplace a type storing relevant operators used when writing a scheme, e.g. quadratures, normal derivatives etc.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 648
diff changeset
27
995
1ba8a398af9c Rename types
Jonatan Werpers <jonatan@werpers.com>
parents: 962
diff changeset
28 # TODO: Implement pretty printing of Laplace once pretty printing of LazyTensors is implemented.
924
12e8e431b43c Start restructuring Laplace making it more minimal.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 922
diff changeset
29 # Base.show(io::IO, L::Laplace) = ...
755
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
30
36adc15d3935 Reduce the number of type perameters used by Laplace.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 754
diff changeset
31 """
1291
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
32 laplace(g::Grid, stencil_set)
624
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
33
1347
08f06bfacd5c Fix typos and formatting of documentation
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1329
diff changeset
34 Creates the Laplace operator operator `Δ` as a `LazyTensor` on `g`.
624
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
35
1291
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
36 `Δ` approximates the Laplace operator ∑d²/xᵢ² , i = 1,...,`Dim` on `g`. The
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
37 approximation depends on the type of grid and the stencil set.
947
38d1752a9aff Reformat "See also:"
Jonatan Werpers <jonatan@werpers.com>
parents: 936
diff changeset
38
38d1752a9aff Reformat "See also:"
Jonatan Werpers <jonatan@werpers.com>
parents: 936
diff changeset
39 See also: [`second_derivative`](@ref).
624
a85db383484f Update documentation and remove some out-commented lines
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 618
diff changeset
40 """
1291
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
41 function laplace end
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
42 function laplace(g::TensorGrid, stencil_set)
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
43 # return mapreduce(+, enumerate(g.grids)) do (i, gᵢ)
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
44 # Δᵢ = laplace(gᵢ, stencil_set)
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
45 # LazyTensors.inflate(Δᵢ, size(g), i)
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
46 # end
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
47
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
48 Δ = LazyTensors.inflate(laplace(g.grids[1], stencil_set), size(g), 1)
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
49 for d = 2:ndims(g)
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
50 Δ += LazyTensors.inflate(laplace(g.grids[d], stencil_set), size(g), d)
356
0844069ab5ff Reinclude SbpOperators and fix most of the code and tests there.
Jonatan Werpers <jonatan@werpers.com>
parents: 333
diff changeset
51 end
611
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 542
diff changeset
52 return Δ
947
38d1752a9aff Reformat "See also:"
Jonatan Werpers <jonatan@werpers.com>
parents: 936
diff changeset
53 end
1291
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1128
diff changeset
54 laplace(g::EquidistantGrid, stencil_set) = second_derivative(g, stencil_set)
1395
bdcdbd4ea9cd Merge with default. Comment out broken tests for boundary_conditions at sat
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1136 1347
diff changeset
55
1598
19cdec9c21cb Implement and test sat_tensors for Dirichlet and Neumann conditions
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1484
diff changeset
56 """
1616
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1608
diff changeset
57 sat_tensors(Δ::Laplace, g::Grid, bc::DirichletCondition; H_tuning, R_tuning)
1598
19cdec9c21cb Implement and test sat_tensors for Dirichlet and Neumann conditions
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1484
diff changeset
58
1619
1937be9502a7 REVIEW: Minor fixes to doc strings in laplace.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
59 The operators required to construct the SAT for imposing a Dirichlet
1937be9502a7 REVIEW: Minor fixes to doc strings in laplace.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
60 condition. `H_tuning` and `R_tuning` are used to specify the strength of the
1937be9502a7 REVIEW: Minor fixes to doc strings in laplace.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
61 penalty.
1598
19cdec9c21cb Implement and test sat_tensors for Dirichlet and Neumann conditions
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1484
diff changeset
62
1619
1937be9502a7 REVIEW: Minor fixes to doc strings in laplace.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
63 See also: [`sat`](@ref),[`DirichletCondition`](@ref), [`positivity_decomposition`](@ref).
1598
19cdec9c21cb Implement and test sat_tensors for Dirichlet and Neumann conditions
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1484
diff changeset
64 """
1606
93b86625fcfd REVIEW: Suggest split of tuning tuple. Please help with names!
Jonatan Werpers <jonatan@werpers.com>
parents: 1603
diff changeset
65 function sat_tensors(Δ::Laplace, g::Grid, bc::DirichletCondition; H_tuning = 1., R_tuning = 1.)
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1600
diff changeset
66 id = boundary(bc)
1598
19cdec9c21cb Implement and test sat_tensors for Dirichlet and Neumann conditions
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1484
diff changeset
67 set = Δ.stencil_set
19cdec9c21cb Implement and test sat_tensors for Dirichlet and Neumann conditions
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1484
diff changeset
68 H⁻¹ = inverse_inner_product(g,set)
19cdec9c21cb Implement and test sat_tensors for Dirichlet and Neumann conditions
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1484
diff changeset
69 Hᵧ = inner_product(boundary_grid(g, id), set)
19cdec9c21cb Implement and test sat_tensors for Dirichlet and Neumann conditions
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1484
diff changeset
70 e = boundary_restriction(g, set, id)
19cdec9c21cb Implement and test sat_tensors for Dirichlet and Neumann conditions
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1484
diff changeset
71 d = normal_derivative(g, set, id)
1606
93b86625fcfd REVIEW: Suggest split of tuning tuple. Please help with names!
Jonatan Werpers <jonatan@werpers.com>
parents: 1603
diff changeset
72 B = positivity_decomposition(Δ, g, bc; H_tuning, R_tuning)
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1600
diff changeset
73 penalty_tensor = H⁻¹∘(d' - B*e')∘Hᵧ
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1600
diff changeset
74 return penalty_tensor, e
1598
19cdec9c21cb Implement and test sat_tensors for Dirichlet and Neumann conditions
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1484
diff changeset
75 end
1106
b4ee47f2aafb Start implementing functions for boundary conditions associated with Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1040
diff changeset
76
1136
470a70a6c1e6 Reformulate boundary routines (sat tensors) for Laplace and fix export
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1133
diff changeset
77 """
1616
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1608
diff changeset
78 sat_tensors(Δ::Laplace, g::Grid, bc::NeumannCondition)
1106
b4ee47f2aafb Start implementing functions for boundary conditions associated with Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1040
diff changeset
79
1619
1937be9502a7 REVIEW: Minor fixes to doc strings in laplace.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
80 The operators required to construct the SAT for imposing a Neumann condition.
1484
8d60d045c2a2 Add todo and minor edits to variable naming and docstring
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1396
diff changeset
81
1619
1937be9502a7 REVIEW: Minor fixes to doc strings in laplace.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
82 See also: [`sat`](@ref), [`NeumannCondition`](@ref).
1136
470a70a6c1e6 Reformulate boundary routines (sat tensors) for Laplace and fix export
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1133
diff changeset
83 """
1603
fca4a01d60c9 Remove module BoundaryConditions, moving its content to SbpOperators
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1602
diff changeset
84 function sat_tensors(Δ::Laplace, g::Grid, bc::NeumannCondition)
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1600
diff changeset
85 id = boundary(bc)
1106
b4ee47f2aafb Start implementing functions for boundary conditions associated with Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1040
diff changeset
86 set = Δ.stencil_set
b4ee47f2aafb Start implementing functions for boundary conditions associated with Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1040
diff changeset
87 H⁻¹ = inverse_inner_product(g,set)
1136
470a70a6c1e6 Reformulate boundary routines (sat tensors) for Laplace and fix export
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1133
diff changeset
88 Hᵧ = inner_product(boundary_grid(g, id), set)
1106
b4ee47f2aafb Start implementing functions for boundary conditions associated with Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1040
diff changeset
89 e = boundary_restriction(g, set, id)
b4ee47f2aafb Start implementing functions for boundary conditions associated with Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1040
diff changeset
90 d = normal_derivative(g, set, id)
1395
bdcdbd4ea9cd Merge with default. Comment out broken tests for boundary_conditions at sat
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1136 1347
diff changeset
91
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1600
diff changeset
92 penalty_tensor = -H⁻¹∘e'∘Hᵧ
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1600
diff changeset
93 return penalty_tensor, d
1106
b4ee47f2aafb Start implementing functions for boundary conditions associated with Laplace
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1040
diff changeset
94 end
1598
19cdec9c21cb Implement and test sat_tensors for Dirichlet and Neumann conditions
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1484
diff changeset
95
1616
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1608
diff changeset
96 """
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1608
diff changeset
97 positivity_decomposition(Δ::Laplace, g::Grid, bc::DirichletCondition; H_tuning, R_tuning)
1607
7216448d0c5a REVIEW: Suggest deduplication of positivity decompostion code
Jonatan Werpers <jonatan@werpers.com>
parents: 1606
diff changeset
98
1619
1937be9502a7 REVIEW: Minor fixes to doc strings in laplace.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
99 Constructs the scalar `B` such that `d' - 1/2*B*e'` is symmetric positive
1937be9502a7 REVIEW: Minor fixes to doc strings in laplace.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
100 definite with respect to the boundary quadrature. Here `d` is the normal
1937be9502a7 REVIEW: Minor fixes to doc strings in laplace.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
101 derivative and `e` is the boundary restriction operator. `B` can then be used
1937be9502a7 REVIEW: Minor fixes to doc strings in laplace.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
102 to form a symmetric and energy stable penalty for a Dirichlet condition. The
1937be9502a7 REVIEW: Minor fixes to doc strings in laplace.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
103 parameters `H_tuning` and `R_tuning` are used to specify the strength of the
1937be9502a7 REVIEW: Minor fixes to doc strings in laplace.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
104 penalty and must be greater than 1. For details we refer to
1937be9502a7 REVIEW: Minor fixes to doc strings in laplace.jl
Jonatan Werpers <jonatan@werpers.com>
parents: 1616
diff changeset
105 https://doi.org/10.1016/j.jcp.2020.109294
1616
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1608
diff changeset
106 """
1607
7216448d0c5a REVIEW: Suggest deduplication of positivity decompostion code
Jonatan Werpers <jonatan@werpers.com>
parents: 1606
diff changeset
107 function positivity_decomposition(Δ::Laplace, g::Grid, bc::DirichletCondition; H_tuning, R_tuning)
1616
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1608
diff changeset
108 @assert(H_tuning ≥ 1.)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1608
diff changeset
109 @assert(R_tuning ≥ 1.)
1607
7216448d0c5a REVIEW: Suggest deduplication of positivity decompostion code
Jonatan Werpers <jonatan@werpers.com>
parents: 1606
diff changeset
110 Nτ_H, τ_R = positivity_limits(Δ,g,bc)
7216448d0c5a REVIEW: Suggest deduplication of positivity decompostion code
Jonatan Werpers <jonatan@werpers.com>
parents: 1606
diff changeset
111 return H_tuning*Nτ_H + R_tuning*τ_R
7216448d0c5a REVIEW: Suggest deduplication of positivity decompostion code
Jonatan Werpers <jonatan@werpers.com>
parents: 1606
diff changeset
112 end
7216448d0c5a REVIEW: Suggest deduplication of positivity decompostion code
Jonatan Werpers <jonatan@werpers.com>
parents: 1606
diff changeset
113
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1600
diff changeset
114 # TODO: We should consider implementing a proper BoundaryIdentifier for EquidistantGrid and then
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1600
diff changeset
115 # change bc::BoundaryCondition to id::BoundaryIdentifier
1607
7216448d0c5a REVIEW: Suggest deduplication of positivity decompostion code
Jonatan Werpers <jonatan@werpers.com>
parents: 1606
diff changeset
116 function positivity_limits(Δ::Laplace, g::EquidistantGrid, bc::DirichletCondition)
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1600
diff changeset
117 h = spacing(g)
1608
8315c456e3b4 Simplify parsing of constants from stencil set
Jonatan Werpers <jonatan@werpers.com>
parents: 1607
diff changeset
118 θ_H = parse_scalar(Δ.stencil_set["H"]["closure"][1])
8315c456e3b4 Simplify parsing of constants from stencil set
Jonatan Werpers <jonatan@werpers.com>
parents: 1607
diff changeset
119 θ_R = parse_scalar(Δ.stencil_set["D2"]["positivity"]["theta_R"])
8315c456e3b4 Simplify parsing of constants from stencil set
Jonatan Werpers <jonatan@werpers.com>
parents: 1607
diff changeset
120
1607
7216448d0c5a REVIEW: Suggest deduplication of positivity decompostion code
Jonatan Werpers <jonatan@werpers.com>
parents: 1606
diff changeset
121 τ_H = 1/(h*θ_H)
7216448d0c5a REVIEW: Suggest deduplication of positivity decompostion code
Jonatan Werpers <jonatan@werpers.com>
parents: 1606
diff changeset
122 τ_R = 1/(h*θ_R)
7216448d0c5a REVIEW: Suggest deduplication of positivity decompostion code
Jonatan Werpers <jonatan@werpers.com>
parents: 1606
diff changeset
123 return τ_H, τ_R
1598
19cdec9c21cb Implement and test sat_tensors for Dirichlet and Neumann conditions
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1484
diff changeset
124 end
19cdec9c21cb Implement and test sat_tensors for Dirichlet and Neumann conditions
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1484
diff changeset
125
1607
7216448d0c5a REVIEW: Suggest deduplication of positivity decompostion code
Jonatan Werpers <jonatan@werpers.com>
parents: 1606
diff changeset
126 function positivity_limits(Δ::Laplace, g::TensorGrid, bc::DirichletCondition)
7216448d0c5a REVIEW: Suggest deduplication of positivity decompostion code
Jonatan Werpers <jonatan@werpers.com>
parents: 1606
diff changeset
127 τ_H, τ_R = positivity_limits(Δ, g.grids[grid_id(boundary(bc))], bc)
7216448d0c5a REVIEW: Suggest deduplication of positivity decompostion code
Jonatan Werpers <jonatan@werpers.com>
parents: 1606
diff changeset
128 return τ_H*ndims(g), τ_R
1602
3e7438e2a033 Address review comments (1 left to be discussed)
Vidar Stiernström <vidar.stiernstrom@gmail.com>
parents: 1600
diff changeset
129 end