This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
/
LandModel.jl
222 lines (190 loc) · 4.23 KB
/
LandModel.jl
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
module Land
using DocStringExtensions
using LinearAlgebra, StaticArrays
using CLIMAParameters
using CLIMAParameters.Planet: ρ_cloud_liq, ρ_cloud_ice, cp_l, cp_i, T_0, LH_f0
using ..VariableTemplates
using ..MPIStateArrays
using ..BalanceLaws
import ..BalanceLaws:
BalanceLaw,
vars_state,
flux_first_order!,
flux_second_order!,
source!,
boundary_state!,
compute_gradient_argument!,
compute_gradient_flux!,
nodal_init_state_auxiliary!,
init_state_prognostic!,
nodal_update_auxiliary_state!
using ..DGMethods: LocalGeometry, DGModel
export LandModel
"""
LandModel{PS, S, SRC, IS} <: BalanceLaw
A BalanceLaw for land modeling.
Users may over-ride prescribed default values for each field.
# Usage
LandModel(
param_set,
soil,
source
init_state_prognostic
)
# Fields
$(DocStringExtensions.FIELDS)
"""
struct LandModel{PS, S, SRC, IS} <: BalanceLaw
"Parameter set"
param_set::PS
"Soil model"
soil::S
"Source Terms (Problem specific source terms)"
source::SRC
"Initial Condition (Function to assign initial values of state variables)"
init_state_prognostic::IS
end
"""
LandModel(
param_set::AbstractParameterSet,
soil::BalanceLaw;
source::SRC = (),
init_state_prognostic::IS = nothing
) where {SRC, IS}
Constructor for the LandModel structure.
"""
function LandModel(
param_set::AbstractParameterSet,
soil::BalanceLaw;
source::SRC = (),
init_state_prognostic::IS = nothing,
) where {SRC, IS}
@assert init_state_prognostic ≠ nothing
land = (param_set, soil, source, init_state_prognostic)
return LandModel{typeof.(land)...}(land...)
end
function vars_state(land::LandModel, st::Prognostic, FT)
@vars begin
soil::vars_state(land.soil, st, FT)
end
end
function vars_state(land::LandModel, st::Auxiliary, FT)
@vars begin
z::FT
soil::vars_state(land.soil, st, FT)
end
end
function vars_state(land::LandModel, st::Gradient, FT)
@vars begin
soil::vars_state(land.soil, st, FT)
end
end
function vars_state(land::LandModel, st::GradientFlux, FT)
@vars begin
soil::vars_state(land.soil, st, FT)
end
end
function nodal_init_state_auxiliary!(
land::LandModel,
aux::Vars,
tmp::Vars,
geom::LocalGeometry,
)
aux.z = geom.coord[3]
land_init_aux!(land, land.soil, aux, geom)
end
function flux_first_order!(
land::LandModel,
flux::Grad,
state::Vars,
aux::Vars,
t::Real,
directions,
) end
function compute_gradient_argument!(
land::LandModel,
transform::Vars,
state::Vars,
aux::Vars,
t::Real,
)
compute_gradient_argument!(land, land.soil, transform, state, aux, t)
end
function compute_gradient_flux!(
land::LandModel,
diffusive::Vars,
∇transform::Grad,
state::Vars,
aux::Vars,
t::Real,
)
compute_gradient_flux!(
land,
land.soil,
diffusive,
∇transform,
state,
aux,
t,
)
end
function flux_second_order!(
land::LandModel,
flux::Grad,
state::Vars,
diffusive::Vars,
hyperdiffusive::Vars,
aux::Vars,
t::Real,
)
flux_second_order!(
land,
land.soil,
flux,
state,
diffusive,
hyperdiffusive,
aux,
t,
)
end
function nodal_update_auxiliary_state!(
land::LandModel,
state::Vars,
aux::Vars,
t::Real,
)
land_nodal_update_auxiliary_state!(land, land.soil, state, aux, t)
end
function source!(
land::LandModel,
source::Vars,
state::Vars,
diffusive::Vars,
aux::Vars,
t::Real,
direction,
)
land_source!(land.source, land, source, state, diffusive, aux, t, direction)
end
function init_state_prognostic!(
land::LandModel,
state::Vars,
aux::Vars,
coords,
t,
args...,
)
land.init_state_prognostic(land, state, aux, coords, t, args...)
end
include("land_bc.jl")
include("SoilWaterParameterizations.jl")
using .SoilWaterParameterizations
include("SoilHeatParameterizations.jl")
using .SoilHeatParameterizations
include("soil_model.jl")
include("soil_water.jl")
include("soil_heat.jl")
include("soil_bc.jl")
include("source.jl")
end # Module