-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathequations.jl
More file actions
101 lines (80 loc) · 4.06 KB
/
Copy pathequations.jl
File metadata and controls
101 lines (80 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# By default, Julia/LLVM does not use fused multiply-add operations (FMAs).
# Since these FMAs can increase the performance of many numerical algorithms,
# we need to opt-in explicitly.
# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details.
@muladd begin
#! format: noindent
# Struct used for multiple dispatch on boundary conditions that set the water height at the boundary.
struct BoundaryConditionWaterHeight{F <: Function}
h_boundary::F
end
# Struct used for multiple dispatch on boundary conditions that set the momentum at the boundary.
struct BoundaryConditionMomentum{F <: Function}
hv_boundary::F
end
####################################################################################################
# Include files with actual implementations for different systems of equations.
include("shallow_water_quasi_1d.jl")
include("shallow_water_1d.jl")
include("shallow_water_2d.jl")
include("shallow_water_exner_1d.jl")
include("shallow_water_two_layer_1d.jl")
include("shallow_water_two_layer_2d.jl")
abstract type AbstractShallowWaterMultiLayerEquations{NDIMS, NVARS, NLAYERS} <:
Trixi.AbstractEquations{NDIMS, NVARS} end
include("shallow_water_multilayer_1d.jl")
include("shallow_water_multilayer_2d.jl")
"""
eachlayer(equations::AbstractShallowWaterMultiLayerEquations)
Return an iterator over the indices that specify the location in relevant data structures
for the layers in `AbstractShallowWaterMultiLayerEquations`.
"""
@inline function eachlayer(equations::AbstractShallowWaterMultiLayerEquations)
Base.OneTo(nlayers(equations))
end
"""
nlayers(equations::AbstractShallowWaterMultiLayerEquations)
Retrieve the number of layers from an equation instance of the `AbstractShallowWaterMultiLayerEquations`.
"""
@inline function nlayers(::AbstractShallowWaterMultiLayerEquations{NDIMS, NVARS,
NLAYERS}) where {
NDIMS,
NVARS,
NLAYERS
}
NLAYERS
end
abstract type AbstractMomentEquations{NDIMS, NVARS, NMOMENTS} <:
Trixi.AbstractEquations{NDIMS, NVARS} end
# Include routines to compute the moment matrices
include("moment_matrices.jl")
include("shallow_water_linearized_moments_1d.jl")
include("shallow_water_moments_1d.jl")
"""
eachmoment(equations::AbstractMomentEquations)
Return an iterator over the indices that specify the location in relevant data structures
for the moments in `AbstractMomentEquations`.
"""
@inline function eachmoment(equations::AbstractMomentEquations)
Base.OneTo(nmoments(equations))
end
"""
nmoments(equations::AbstractMomentEquations)
Retrieve the number of moments from an equation instance of the `AbstractMomentEquations`.
"""
@inline function nmoments(::AbstractMomentEquations{NDIMS, NVARS, NMOMENTS}) where {
NDIMS,
NVARS,
NMOMENTS
}
NMOMENTS
end
include("hyperbolic_sainte_marie_1d.jl")
# TODO: Add suitable default thresholds for Float32
# Provide default thresholds dependent on number format (Currently default thresholds are only provided
# for Float64)
default_threshold_partially_wet(::Type{Float64}) = 1e-4
default_threshold_partially_wet(catchall) = throw(ArgumentError("threshold_partially_wet must be provided for non-Float64 types"))
default_threshold_desingularization(::Type{Float64}) = 1e-10
default_threshold_desingularization(catchall) = throw(ArgumentError("threshold_desingularization must be provided for non-Float64 types"))
end # @muladd