zoomy-core 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of zoomy-core might be problematic. Click here for more details.
- zoomy_core/__init__.py +7 -0
- zoomy_core/mesh/mesh.py +85 -43
- zoomy_core/misc/io.py +72 -35
- {zoomy_core-0.1.2.dist-info → zoomy_core-0.1.4.dist-info}/METADATA +2 -1
- {zoomy_core-0.1.2.dist-info → zoomy_core-0.1.4.dist-info}/RECORD +8 -11
- zoomy_core/mesh/gmsh_loader.py +0 -301
- zoomy_core/misc/gui.py +0 -61
- zoomy_core/model/models/old_smm copy.py +0 -867
- zoomy_core/model/models/swe_old.py +0 -1018
- {zoomy_core-0.1.2.dist-info → zoomy_core-0.1.4.dist-info}/WHEEL +0 -0
- {zoomy_core-0.1.2.dist-info → zoomy_core-0.1.4.dist-info}/licenses/LICENSE +0 -0
- {zoomy_core-0.1.2.dist-info → zoomy_core-0.1.4.dist-info}/top_level.txt +0 -0
|
@@ -1,867 +0,0 @@
|
|
|
1
|
-
# import numpy as np
|
|
2
|
-
# import os
|
|
3
|
-
# import logging
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# from library.solver.baseclass import BaseYaml
|
|
7
|
-
# from library.solver.models.base import *
|
|
8
|
-
# from library.solver.boundary_conditions import *
|
|
9
|
-
# import library.solver.initial_condition as initial_condition
|
|
10
|
-
# import library.solver.smm_model as smm
|
|
11
|
-
# import library.solver.smm_model_hyperbolic as smmh
|
|
12
|
-
# import library.solver.smm_model_exner as smm_exner
|
|
13
|
-
# import library.solver.smm_model_exner_hyperbolic as smm_exner_hyper
|
|
14
|
-
|
|
15
|
-
# import sympy
|
|
16
|
-
# from sympy import Symbol, Matrix, lambdify
|
|
17
|
-
# from sympy import *
|
|
18
|
-
# from sympy import zeros, ones
|
|
19
|
-
|
|
20
|
-
# main_dir = os.getenv("SMPYTHON")
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# class ShallowMomentReference2d(Model2d):
|
|
24
|
-
# yaml_tag = "!ShallowMomentReference2d"
|
|
25
|
-
|
|
26
|
-
# def set_default_default_parameters(self):
|
|
27
|
-
# super().set_default_default_parameters()
|
|
28
|
-
# self.n_variables = 2
|
|
29
|
-
|
|
30
|
-
# def set_runtime_variables(self):
|
|
31
|
-
# super().set_runtime_variables()
|
|
32
|
-
|
|
33
|
-
# def flux(self, Q, **kwargs):
|
|
34
|
-
# h = Q[0]
|
|
35
|
-
# hu = Q[1]
|
|
36
|
-
# u = hu / h
|
|
37
|
-
# hum = kwargs["aux_variables"]["hu_mean"]
|
|
38
|
-
# hvm = kwargs["aux_variables"]["hv_mean"]
|
|
39
|
-
# result = np.zeros((2, 2, h.shape[0]))
|
|
40
|
-
# result[0, 0] = hum
|
|
41
|
-
# result[0, 1] = hu * u + self.g * h * h / 2
|
|
42
|
-
# return result
|
|
43
|
-
|
|
44
|
-
# def flux_jacobian(self, Q):
|
|
45
|
-
# h = Q[0]
|
|
46
|
-
# hu = Q[1]
|
|
47
|
-
# hv = Q[2]
|
|
48
|
-
# u = hu / h
|
|
49
|
-
# v = hv / h
|
|
50
|
-
|
|
51
|
-
# result = np.zeros((2, 2, 2, h.shape[0]))
|
|
52
|
-
# result[0, 1, 0] = 1
|
|
53
|
-
# result[1, 0, 0] = -(u**2) + self.g * h
|
|
54
|
-
# result[1, 1, 0] = 2 * u
|
|
55
|
-
# return result
|
|
56
|
-
|
|
57
|
-
# def primitive_variables(self, Q):
|
|
58
|
-
# h = Q[0]
|
|
59
|
-
# hu = Q[1]
|
|
60
|
-
# u = hu / h
|
|
61
|
-
# return np.array([h, u])
|
|
62
|
-
|
|
63
|
-
# def conservative_variables(self, U):
|
|
64
|
-
# h = U[0]
|
|
65
|
-
# u = U[1]
|
|
66
|
-
# return np.array([h, h * u])
|
|
67
|
-
|
|
68
|
-
# def rhs(self, t, Q, **kwargs):
|
|
69
|
-
# output = np.zeros_like(Q)
|
|
70
|
-
|
|
71
|
-
# # vertical coupling
|
|
72
|
-
|
|
73
|
-
# # Topography
|
|
74
|
-
|
|
75
|
-
# # Friction
|
|
76
|
-
# for friction in self.friction_models:
|
|
77
|
-
# output += getattr(self, friction)(
|
|
78
|
-
# t,
|
|
79
|
-
# Q,
|
|
80
|
-
# **{**kwargs, "g": self.g, "ex": self.ex, "ey": self.ey, "ez": self.ez}
|
|
81
|
-
# )
|
|
82
|
-
|
|
83
|
-
# return output
|
|
84
|
-
|
|
85
|
-
# def update_hum_and_omega(self, Q, N, M, **kwargs):
|
|
86
|
-
# U = self.primitive_variables(Q)
|
|
87
|
-
# U_zz = np.zeros(U.shape[1])
|
|
88
|
-
# omega = np.zeros(U.shape[1])
|
|
89
|
-
# Umean = np.zeros(U.shape[1])
|
|
90
|
-
# Umean_dict = {}
|
|
91
|
-
# vol_dict = {}
|
|
92
|
-
|
|
93
|
-
# assert kwargs["mesh"]["type"] == "quad"
|
|
94
|
-
# for i_elem in range(kwargs_in["mesh"]["n_elements"]):
|
|
95
|
-
# Ui = np.array(U[:, i_elem])
|
|
96
|
-
# U_zz[i_elem] += Ui
|
|
97
|
-
# xpos = kwargs["mesh"]["element_centers"][i_elem][0]
|
|
98
|
-
# vol = kwargs["mesh"]["element_volume"][i_elem]
|
|
99
|
-
# Umean_dict[xpos] += Ui * vol
|
|
100
|
-
# vol_dict[xpos] += vol
|
|
101
|
-
# for i_edge, _ in enumerate(kwargs_in["mesh"]["element_neighbors"][i_elem]):
|
|
102
|
-
# i_neighbor = (kwargs_in["mesh"]["element_neighbors"][i_elem])[i_edge]
|
|
103
|
-
# n_ij = kwargs_in["mesh"]["element_edge_normal"][i_elem, i_edge, :][
|
|
104
|
-
# :, np.newaxis
|
|
105
|
-
# ][: kwargs_in["mesh"]["dim"]]
|
|
106
|
-
# # reshape to [dim,1]
|
|
107
|
-
# Uj = np.array(U[:, i_neighbor])
|
|
108
|
-
# Fn, step_failed = kwargs_in["flux"](Qi, Qj, n_ij, **kwargs)
|
|
109
|
-
# NCn = kwargs_in["nc"](Qi, Qj, n_ij, **kwargs)
|
|
110
|
-
# Qnew[:, i_elem] -= (
|
|
111
|
-
# dt
|
|
112
|
-
# / kwargs_in["mesh"]["element_volume"][i_elem]
|
|
113
|
-
# * kwargs_in["mesh"]["element_edge_length"][i_elem, i_edge]
|
|
114
|
-
# * (Fn + NCn).flatten()
|
|
115
|
-
# )
|
|
116
|
-
# S = kwargs_in["source"](kwargs_in["time"], Qi, **kwargs).flatten()
|
|
117
|
-
# Qnew[:, i_elem] += (
|
|
118
|
-
# dt * kwargs_in["mesh"]["element_volume"][i_elem] * S.flatten()
|
|
119
|
-
# )
|
|
120
|
-
|
|
121
|
-
# for i_bp, elem in enumerate(kwargs_in["mesh"]["boundary_edge_element"]):
|
|
122
|
-
# kwargs["aux_variables"] = elementwise_aux_variables(i_elem, **kwargs_in)
|
|
123
|
-
# kwargs["i_elem"] = elem
|
|
124
|
-
# # TODO WRONG!!
|
|
125
|
-
# kwargs["i_edge"] = i_bp
|
|
126
|
-
# n_ij = kwargs_in["mesh"]["boundary_edge_normal"][i_bp][
|
|
127
|
-
# : kwargs_in["mesh"]["dim"]
|
|
128
|
-
# ][:, np.newaxis]
|
|
129
|
-
# kwargs["i_neighbor"] = elem
|
|
130
|
-
|
|
131
|
-
# edge_length = kwargs_in["mesh"]["boundary_edge_length"][i_bp]
|
|
132
|
-
|
|
133
|
-
# Qi = np.array(Q[:, elem])[:, np.newaxis]
|
|
134
|
-
# Qj = kwargs_in["bc"](
|
|
135
|
-
# kwargs_in["model"].boundary_conditions,
|
|
136
|
-
# i_bp,
|
|
137
|
-
# Q,
|
|
138
|
-
# dim=kwargs_in["mesh"]["dim"],
|
|
139
|
-
# )[:, np.newaxis]
|
|
140
|
-
# Fn, step_failed = kwargs_in["flux"](Qi, Qj, n_ij, **kwargs)
|
|
141
|
-
# NCn = kwargs_in["nc"](Qi, Qj, n_ij, **kwargs)
|
|
142
|
-
# Qnew[:, elem] -= (
|
|
143
|
-
# dt
|
|
144
|
-
# / kwargs_in["mesh"]["element_volume"][elem]
|
|
145
|
-
# * edge_length
|
|
146
|
-
# * (Fn + NCn).flatten()
|
|
147
|
-
# )
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
# class ShallowMoments(Model):
|
|
151
|
-
# yaml_tag = "!ShallowMoments"
|
|
152
|
-
|
|
153
|
-
# def set_default_default_parameters(self):
|
|
154
|
-
# super().set_default_default_parameters()
|
|
155
|
-
# self.n_variables = 1 + 2 * self.dimension
|
|
156
|
-
# self.basis = "legendre"
|
|
157
|
-
# self.bc_coupling_type = "weak"
|
|
158
|
-
# self.nc_treatment = "flux_increment"
|
|
159
|
-
|
|
160
|
-
# def set_runtime_variables(self):
|
|
161
|
-
# super().set_runtime_variables()
|
|
162
|
-
# self.level = int((self.n_variables - 1) / self.dimension) - 1
|
|
163
|
-
# # TODO it is not nice that the parameters exist in both!
|
|
164
|
-
# self.matrices = smm.Matrices(level=self.level, basistype=self.basis)
|
|
165
|
-
# self.matrices.bc_type = self.bc_coupling_type
|
|
166
|
-
# self.matrices.basistype = self.basis
|
|
167
|
-
# self.matrices.set_runtime_variables()
|
|
168
|
-
|
|
169
|
-
# def flux(self, Q):
|
|
170
|
-
# kwargs = {"g": self.g, "ex": self.ex, "ey": self.ey, "ez": self.ez}
|
|
171
|
-
# return self.matrices.flux(Q, **kwargs)
|
|
172
|
-
|
|
173
|
-
# def flux_jacobian(self, Q):
|
|
174
|
-
# kwargs = {"g": self.g, "ex": self.ex, "ez": self.ez}
|
|
175
|
-
# return self.matrices.flux_jac(Q, **kwargs)
|
|
176
|
-
|
|
177
|
-
# # def eigenvalues(self, Q, nij):
|
|
178
|
-
# # assert (Q[0] > 0).all()
|
|
179
|
-
# # kwargs = {"g": self.g, "ez": self.ez}
|
|
180
|
-
# # return self.matrices.eigenvalues(Q, nij, **kwargs)
|
|
181
|
-
|
|
182
|
-
# def rhs(self, t, Q, **kwargs):
|
|
183
|
-
# output = np.zeros_like(Q)
|
|
184
|
-
# # Topography
|
|
185
|
-
# output += self.matrices.rhs_topo(
|
|
186
|
-
# Q, **{**kwargs, "g": self.g, "ex": self.ex, "ey": self.ey, "ez": self.ez}
|
|
187
|
-
# )
|
|
188
|
-
|
|
189
|
-
# # Friction
|
|
190
|
-
# for friction in self.friction_models:
|
|
191
|
-
# output += getattr(self, friction)(
|
|
192
|
-
# t,
|
|
193
|
-
# Q,
|
|
194
|
-
# **{
|
|
195
|
-
# **kwargs,
|
|
196
|
-
# "g": self.g,
|
|
197
|
-
# "ex": self.ex,
|
|
198
|
-
# "ey": self.ey,
|
|
199
|
-
# "ez": self.ez,
|
|
200
|
-
# **self.parameters,
|
|
201
|
-
# }
|
|
202
|
-
# )
|
|
203
|
-
|
|
204
|
-
# return output
|
|
205
|
-
|
|
206
|
-
# def rhs_jacobian(self, t, Q, **kwargs):
|
|
207
|
-
# output = np.zeros((Q.shape[0], Q.shape[0], Q.shape[1]))
|
|
208
|
-
|
|
209
|
-
# # Topography
|
|
210
|
-
# output += self.matrices.rhs_topo_jacobian(
|
|
211
|
-
# Q, **{**kwargs, "g": self.g, "ex": self.ex, "ey": self.ey, "ez": self.ez}
|
|
212
|
-
# )
|
|
213
|
-
|
|
214
|
-
# # Friction
|
|
215
|
-
# for friction in self.friction_models:
|
|
216
|
-
# # print(friction, getattr(self, friction + "_jacobian")(
|
|
217
|
-
# # t,
|
|
218
|
-
# # Q,
|
|
219
|
-
# # **{**kwargs, "g": self.g, "ex": self.ex, "ey": self.ey, "ez": self.ez}
|
|
220
|
-
# # ).shape)
|
|
221
|
-
# output += getattr(self, friction + "_jacobian")(
|
|
222
|
-
# t,
|
|
223
|
-
# Q,
|
|
224
|
-
# **{
|
|
225
|
-
# **kwargs,
|
|
226
|
-
# "g": self.g,
|
|
227
|
-
# "ex": self.ex,
|
|
228
|
-
# "ey": self.ey,
|
|
229
|
-
# "ez": self.ez,
|
|
230
|
-
# **self.parameters,
|
|
231
|
-
# }
|
|
232
|
-
# )
|
|
233
|
-
|
|
234
|
-
# return output
|
|
235
|
-
|
|
236
|
-
# def nonconservative_matrix(self, Q, **kwargs):
|
|
237
|
-
# kwargs_in = {"g": self.g, "ez": self.ez}
|
|
238
|
-
# return self.matrices.nonconservative_matrix(Q, **kwargs_in)
|
|
239
|
-
|
|
240
|
-
# def quasilinear_matrix(self, Q, **kwargs):
|
|
241
|
-
# return self.flux_jacobian(Q) - ShallowMoments.nonconservative_matrix(
|
|
242
|
-
# self, Q, **kwargs
|
|
243
|
-
# )
|
|
244
|
-
|
|
245
|
-
# def newtonian(self, t, Q, **kwargs):
|
|
246
|
-
# return self.matrices.rhs_newtonian(Q, **kwargs)
|
|
247
|
-
|
|
248
|
-
# def bingham(self, t, Q, **kwargs):
|
|
249
|
-
# return self.matrices.rhs_bingham(Q, **kwargs)
|
|
250
|
-
|
|
251
|
-
# def bingham_rowdependent(self, t, Q, **kwargs):
|
|
252
|
-
# return self.matrices.rhs_bingham_rowdependent(Q, **kwargs)
|
|
253
|
-
|
|
254
|
-
# def bingham_depthaveraged(self, t, Q, **kwargs):
|
|
255
|
-
# return self.matrices.rhs_bingham_depthaveraged(Q, **kwargs)
|
|
256
|
-
|
|
257
|
-
# def bingham_bottom(self, t, Q, **kwargs):
|
|
258
|
-
# return self.matrices.rhs_bingham_bottom(Q, **kwargs)
|
|
259
|
-
|
|
260
|
-
# def newtonian_jacobian(self, t, Q, **kwargs):
|
|
261
|
-
# return self.matrices.rhs_newtonian_jacobian(Q, **kwargs)
|
|
262
|
-
|
|
263
|
-
# def primitive_variables(self, Q):
|
|
264
|
-
# U = np.array(Q)
|
|
265
|
-
# U[1:] = np.where(U[0] > 0, U[1:] / U[0], 0.0)
|
|
266
|
-
# return U
|
|
267
|
-
|
|
268
|
-
# def conservative_variables(self, U):
|
|
269
|
-
# Q = np.array(U)
|
|
270
|
-
# Q[1:] *= Q[0]
|
|
271
|
-
# return Q
|
|
272
|
-
|
|
273
|
-
# def get_massmatrix(self):
|
|
274
|
-
# return self.matrices.MM
|
|
275
|
-
|
|
276
|
-
# def get_massmatrix_inverse(self):
|
|
277
|
-
# return self.matrices.Minv
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
# class ShallowMomentsHyperbolic(Model):
|
|
281
|
-
# yaml_tag = "!ShallowMomentsHyperbolic"
|
|
282
|
-
|
|
283
|
-
# def set_default_default_parameters(self):
|
|
284
|
-
# super().set_default_default_parameters()
|
|
285
|
-
# self.n_variables = 1 + 2 * self.dimension
|
|
286
|
-
# self.basis = "legendre"
|
|
287
|
-
# self.bc_coupling_type = "weak"
|
|
288
|
-
# self.nc_treatment = "flux_increment"
|
|
289
|
-
# self.friction_models = []
|
|
290
|
-
# self.parameters = {}
|
|
291
|
-
|
|
292
|
-
# def set_runtime_variables(self):
|
|
293
|
-
# super().set_runtime_variables()
|
|
294
|
-
# self.level = int((self.n_variables - 1) / self.dimension) - 1
|
|
295
|
-
# # TODO it is not nice that the parameters exist in both!
|
|
296
|
-
# self.matrices = smmh.Matrices(level=self.level, basistype=self.basis)
|
|
297
|
-
# self.matrices.bc_type = self.bc_coupling_type
|
|
298
|
-
# self.matrices.basistype = self.basis
|
|
299
|
-
# self.matrices.set_runtime_variables()
|
|
300
|
-
|
|
301
|
-
# def flux(self, Q):
|
|
302
|
-
# kwargs = {"g": self.g, "ex": self.ex, "ey": self.ey, "ez": self.ez}
|
|
303
|
-
# return self.matrices.flux(Q, **kwargs)
|
|
304
|
-
|
|
305
|
-
# def flux_jacobian(self, Q):
|
|
306
|
-
# kwargs = {"g": self.g, "ex": self.ex, "ez": self.ez}
|
|
307
|
-
# return self.matrices.flux_jac(Q, **kwargs)
|
|
308
|
-
|
|
309
|
-
# def eigenvalues(self, Q, nij):
|
|
310
|
-
# assert (Q[0] > 0).all()
|
|
311
|
-
# kwargs = {"g": self.g, "ez": self.ez}
|
|
312
|
-
# return self.matrices.eigenvalues_hyperbolic(Q, nij, **kwargs)
|
|
313
|
-
|
|
314
|
-
# def eigenvalues_analytical(self, Q, nij):
|
|
315
|
-
# assert (Q[0] > 0).all()
|
|
316
|
-
# kwargs = {"g": self.g, "ez": self.ez}
|
|
317
|
-
# return self.matrices.eigenvalues_hyperbolic_analytical(Q, nij, **kwargs)
|
|
318
|
-
|
|
319
|
-
# def rhs(self, t, Q, **kwargs):
|
|
320
|
-
# output = np.zeros_like(Q)
|
|
321
|
-
# # Topography
|
|
322
|
-
# output += self.matrices.rhs_topo(
|
|
323
|
-
# Q, **{**kwargs, "g": self.g, "ex": self.ex, "ey": self.ey, "ez": self.ez}
|
|
324
|
-
# )
|
|
325
|
-
|
|
326
|
-
# # Friction
|
|
327
|
-
# for friction in self.friction_models:
|
|
328
|
-
# output += getattr(self, friction)(
|
|
329
|
-
# t,
|
|
330
|
-
# Q,
|
|
331
|
-
# **{**kwargs, "g": self.g, "ex": self.ex, "ey": self.ey, "ez": self.ez}
|
|
332
|
-
# )
|
|
333
|
-
|
|
334
|
-
# return output
|
|
335
|
-
|
|
336
|
-
# def nonconservative_matrix(self, Q):
|
|
337
|
-
# kwargs = {"g": self.g, "ex": self.ex, "ey": self.ey, "ez": self.ez}
|
|
338
|
-
# return self.matrices.nonconservative_matrix_hyperbolic(Q, **kwargs)
|
|
339
|
-
|
|
340
|
-
# def quasilinear_matrix(self, Q):
|
|
341
|
-
# Q[3:, :] = 0.0
|
|
342
|
-
# return self.flux_jacobian(Q) - self.nonconservative_matrix(Q)
|
|
343
|
-
|
|
344
|
-
# def newtonian(self, t, Q, **kwargs):
|
|
345
|
-
# return self.matrices.rhs_newtonian(Q, **kwargs)
|
|
346
|
-
|
|
347
|
-
# def newtonian_jacobian(self, t, Q, **kwargs):
|
|
348
|
-
# return self.matrices.rhs_newtonian_jacobian(Q, **kwargs)
|
|
349
|
-
|
|
350
|
-
# def primitive_variables(self, Q):
|
|
351
|
-
# U = np.array(Q)
|
|
352
|
-
# U[1:] /= Q[0]
|
|
353
|
-
# return U
|
|
354
|
-
|
|
355
|
-
# def conservative_variables(self, U):
|
|
356
|
-
# Q = np.array(U)
|
|
357
|
-
# Q[1:] *= Q[0]
|
|
358
|
-
# return Q
|
|
359
|
-
|
|
360
|
-
# def get_massmatrix(self):
|
|
361
|
-
# return self.matrices.MM
|
|
362
|
-
|
|
363
|
-
# def get_massmatrix_inverse(self):
|
|
364
|
-
# return self.matrices.Minv
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
# class ShallowMomentsExner(Model):
|
|
368
|
-
# yaml_tag = "!ShallowMomentsExner"
|
|
369
|
-
|
|
370
|
-
# def set_default_default_parameters(self):
|
|
371
|
-
# super().set_default_default_parameters()
|
|
372
|
-
# self.n_variables = 3 + 2
|
|
373
|
-
# self.basis = "legendre"
|
|
374
|
-
# self.bc_coupling_type = "weak"
|
|
375
|
-
# self.nc_treatment = "flux_increment"
|
|
376
|
-
# self.friction_models = []
|
|
377
|
-
# self.friction_parameters = {}
|
|
378
|
-
|
|
379
|
-
# self.sediment_density = 1580
|
|
380
|
-
# self.water_density = 1000
|
|
381
|
-
# self.sediment_dia = 0.0039
|
|
382
|
-
# self.critical_shield = 0.047
|
|
383
|
-
# self.manning = 0.0365
|
|
384
|
-
# self.porosity = 0.47
|
|
385
|
-
|
|
386
|
-
# def set_runtime_variables(self):
|
|
387
|
-
# super().set_runtime_variables()
|
|
388
|
-
# self.level = int((self.n_variables - 1) / self.dimension) - 2
|
|
389
|
-
# # TODO it is not nice that the parameters exist in both!
|
|
390
|
-
# self.matrices = smm_exner.Matrices_exner(level=self.level, basistype=self.basis)
|
|
391
|
-
# self.matrices.bc_type = self.bc_coupling_type
|
|
392
|
-
# self.matrices.basistype = self.basis
|
|
393
|
-
# self.matrices.set_runtime_variables()
|
|
394
|
-
|
|
395
|
-
# def flux(self, Q):
|
|
396
|
-
# kwargs = {
|
|
397
|
-
# "g": self.g,
|
|
398
|
-
# "ex": self.ex,
|
|
399
|
-
# "ez": self.ez,
|
|
400
|
-
# "sediment_density": self.sediment_density,
|
|
401
|
-
# "water_density": self.water_density,
|
|
402
|
-
# "sediment_dia": self.sediment_dia,
|
|
403
|
-
# "critical_shield": self.critical_shield,
|
|
404
|
-
# "manning": self.manning,
|
|
405
|
-
# "porosity": self.porosity,
|
|
406
|
-
# }
|
|
407
|
-
# return self.matrices.flux(Q, **kwargs)
|
|
408
|
-
|
|
409
|
-
# def flux_jacobian(self, Q):
|
|
410
|
-
# kwargs = {
|
|
411
|
-
# "g": self.g,
|
|
412
|
-
# "ex": self.ex,
|
|
413
|
-
# "ez": self.ez,
|
|
414
|
-
# "sediment_density": self.sediment_density,
|
|
415
|
-
# "water_density": self.water_density,
|
|
416
|
-
# "sediment_dia": self.sediment_dia,
|
|
417
|
-
# "critical_shield": self.critical_shield,
|
|
418
|
-
# "manning": self.manning,
|
|
419
|
-
# "porosity": self.porosity,
|
|
420
|
-
# }
|
|
421
|
-
# return self.matrices.flux_jac(Q, **kwargs)
|
|
422
|
-
|
|
423
|
-
# def eigenvalues(self, Q, nij):
|
|
424
|
-
# assert (Q[0] > 0).all()
|
|
425
|
-
# kwargs = {
|
|
426
|
-
# "g": self.g,
|
|
427
|
-
# "ex": self.ex,
|
|
428
|
-
# "ez": self.ez,
|
|
429
|
-
# "sediment_density": self.sediment_density,
|
|
430
|
-
# "water_density": self.water_density,
|
|
431
|
-
# "sediment_dia": self.sediment_dia,
|
|
432
|
-
# "critical_shield": self.critical_shield,
|
|
433
|
-
# "manning": self.manning,
|
|
434
|
-
# "porosity": self.porosity,
|
|
435
|
-
# }
|
|
436
|
-
# return self.matrices.eigenvalues(Q, nij, **kwargs)
|
|
437
|
-
|
|
438
|
-
# def rhs(self, t, Q, **kwargs):
|
|
439
|
-
# output = np.zeros_like(Q)
|
|
440
|
-
# # Topography
|
|
441
|
-
# output += self.matrices.rhs_topo(
|
|
442
|
-
# Q, **{**kwargs, "g": self.g, "ex": self.ex, "ez": self.ez}
|
|
443
|
-
# )
|
|
444
|
-
|
|
445
|
-
# # Friction
|
|
446
|
-
# for friction in self.friction_models:
|
|
447
|
-
# output += getattr(self, friction)(
|
|
448
|
-
# t,
|
|
449
|
-
# Q,
|
|
450
|
-
# **{
|
|
451
|
-
# **kwargs,
|
|
452
|
-
# "g": self.g,
|
|
453
|
-
# "ex": self.ex,
|
|
454
|
-
# "ez": self.ez,
|
|
455
|
-
# "manning": self.manning,
|
|
456
|
-
# **self.friction_parameters,
|
|
457
|
-
# }
|
|
458
|
-
# )
|
|
459
|
-
|
|
460
|
-
# return output
|
|
461
|
-
|
|
462
|
-
# def rhs_jacobian(self, t, Q, **kwargs):
|
|
463
|
-
# if len(Q.shape) == 2:
|
|
464
|
-
# output = np.zeros((Q.shape[0], Q.shape[0], Q.shape[1]))
|
|
465
|
-
# else:
|
|
466
|
-
# output = np.zeros((Q.shape[0], Q.shape[0]))
|
|
467
|
-
|
|
468
|
-
# # Topography
|
|
469
|
-
# if "dHdx" in kwargs:
|
|
470
|
-
# output += self.matrices.rhs_topo_jacobian(
|
|
471
|
-
# Q, **{**kwargs, "g": self.g, "ex": self.ex, "ez": self.ez}
|
|
472
|
-
# )
|
|
473
|
-
|
|
474
|
-
# # Friction
|
|
475
|
-
# for friction in self.friction_models:
|
|
476
|
-
# output += getattr(self, friction + "_jacobian")(
|
|
477
|
-
# t,
|
|
478
|
-
# Q,
|
|
479
|
-
# **{
|
|
480
|
-
# **kwargs,
|
|
481
|
-
# "g": self.g,
|
|
482
|
-
# "ex": self.ex,
|
|
483
|
-
# "ez": self.ez,
|
|
484
|
-
# **self.friction_parameters,
|
|
485
|
-
# }
|
|
486
|
-
# )
|
|
487
|
-
|
|
488
|
-
# return output
|
|
489
|
-
|
|
490
|
-
# def nonconservative_matrix(self, Q):
|
|
491
|
-
# kwargs = {"g": self.g}
|
|
492
|
-
# return self.matrices.nonconservative_matrix(Q, **kwargs)
|
|
493
|
-
|
|
494
|
-
# def quasilinear_matrix(self, Q):
|
|
495
|
-
# return self.flux_jacobian(Q) - self.nonconservative_matrix(Q)
|
|
496
|
-
|
|
497
|
-
# def newtonian(self, t, Q, **kwargs):
|
|
498
|
-
# return self.matrices.rhs_newtonian(Q, **kwargs)
|
|
499
|
-
|
|
500
|
-
# def newtonian_jacobian(self, t, Q, **kwargs):
|
|
501
|
-
# return self.matrices.rhs_newtonian_jacobian(Q, **kwargs)
|
|
502
|
-
|
|
503
|
-
# def primitive_variables(self, Q):
|
|
504
|
-
# U = np.array(Q)
|
|
505
|
-
# U[1:-1] /= Q[0]
|
|
506
|
-
# return U
|
|
507
|
-
|
|
508
|
-
# def conservative_variables(self, U):
|
|
509
|
-
# Q = np.array(U)
|
|
510
|
-
# Q[1:-1] *= Q[0]
|
|
511
|
-
# return Q
|
|
512
|
-
|
|
513
|
-
# def get_default_parameters(self):
|
|
514
|
-
# return self.friction_parameters
|
|
515
|
-
|
|
516
|
-
# def get_massmatrix(self):
|
|
517
|
-
# return self.matrices.MM
|
|
518
|
-
|
|
519
|
-
# def get_massmatrix_inverse(self):
|
|
520
|
-
# return self.matrices.Minv
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
# class HyperbolicShallowMoments(ShallowMoments):
|
|
524
|
-
# yaml_tag = "!HyperbolicShallowMoments"
|
|
525
|
-
|
|
526
|
-
# def eigenvalues(self, Q, nij):
|
|
527
|
-
# assert (Q[0] > 0).all()
|
|
528
|
-
# kwargs = {"g": self.g, "ez": self.ez}
|
|
529
|
-
# Qhyp = np.array(Q)
|
|
530
|
-
# Qhyp[2:, :] = 0
|
|
531
|
-
# return self.matrices.eigenvalues_hyperbolic_analytical(Qhyp, nij, **kwargs)
|
|
532
|
-
|
|
533
|
-
# def quasilinear_matrix(self, Q, **kwargs):
|
|
534
|
-
# Qhyp = np.array(Q)
|
|
535
|
-
# Qhyp[2:, :] = 0
|
|
536
|
-
# return self.flux_jacobian(Qhyp) - super().nonconservative_matrix(Qhyp, **kwargs)
|
|
537
|
-
|
|
538
|
-
# def nonconservative_matrix(self, Q, **kwargs):
|
|
539
|
-
# Qhyp = np.array(Q)
|
|
540
|
-
# Qhyp[2:, :] = 0
|
|
541
|
-
# return -self.quasilinear_matrix(Qhyp, **kwargs) + self.flux_jacobian(Q)
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
# class ShallowMomentsWithBottom(ShallowMoments):
|
|
545
|
-
# yaml_tag = "!ShallowMomentsWithBottom"
|
|
546
|
-
# dimension = 1
|
|
547
|
-
|
|
548
|
-
# def set_default_default_parameters(self):
|
|
549
|
-
# super().set_default_default_parameters()
|
|
550
|
-
|
|
551
|
-
# def set_runtime_variables(self):
|
|
552
|
-
# # I need to run the parent.parent.set_runtime_variables, since I need to call a different smm.Matrices !!
|
|
553
|
-
# # since this is not possible? (super().super() does not exist), i call it call it directly
|
|
554
|
-
# self.compute_unit_vectors()
|
|
555
|
-
# self.level = int((self.n_variables - 2) / self.dimension) - 1
|
|
556
|
-
|
|
557
|
-
# self.matrices = smm.MatricesWithBottom(level=self.level, basistype=self.basis)
|
|
558
|
-
# self.matrices.bc_type = self.bc_coupling_type
|
|
559
|
-
# self.matrices.basistype = self.basis
|
|
560
|
-
# self.matrices.set_runtime_variables()
|
|
561
|
-
|
|
562
|
-
# def primitive_variables(self, Q):
|
|
563
|
-
# res = np.zeros_like(Q)
|
|
564
|
-
# res[:-1] = super().primitive_variables(Q[:-1])
|
|
565
|
-
# res[-1] = Q[-1]
|
|
566
|
-
# return res
|
|
567
|
-
|
|
568
|
-
# def conservative_variables(self, U):
|
|
569
|
-
# res = np.zeros_like(U)
|
|
570
|
-
# res[:-1] = super().conservative_variables(U[:-1])
|
|
571
|
-
# res[-1] = U[-1]
|
|
572
|
-
# return res
|
|
573
|
-
|
|
574
|
-
# # def eigenvalues(self, Q, nij):
|
|
575
|
-
# # kwargs = {"g": self.g, "ez": self.ez, "ex": self.ex}
|
|
576
|
-
# # return self.matrices.eigenvalues(Q, nij, **kwargs)
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
# class ShallowMoments2d(ShallowMoments):
|
|
580
|
-
# yaml_tag = "!ShallowMoments2d"
|
|
581
|
-
|
|
582
|
-
# dimension = 2
|
|
583
|
-
|
|
584
|
-
# def set_default_default_parameters(self):
|
|
585
|
-
# super().set_default_default_parameters()
|
|
586
|
-
|
|
587
|
-
# def set_runtime_variables(self):
|
|
588
|
-
# # I need to run the parent.parent.set_runtime_variables, since I need to call a different smm.Matrices !!
|
|
589
|
-
# # since this is not possible? (super().super() does not exist), i call it call it directly
|
|
590
|
-
# self.compute_unit_vectors()
|
|
591
|
-
# self.level = int((self.n_variables - 1) / self.dimension) - 1
|
|
592
|
-
|
|
593
|
-
# self.matrices = smm.Matrices2d(level=self.level, basistype=self.basis)
|
|
594
|
-
# self.matrices.bc_type = self.bc_coupling_type
|
|
595
|
-
# self.matrices.basistype = self.basis
|
|
596
|
-
# self.matrices.set_runtime_variables()
|
|
597
|
-
|
|
598
|
-
# def get_alpha_beta(Q):
|
|
599
|
-
# prim = self.primitive_variables(Q)
|
|
600
|
-
# alphabeta = prim[1:]
|
|
601
|
-
# alpha = alphabeta[: (self.level + 1) * self.dimension]
|
|
602
|
-
# beta = alphabeta[(self.level + 1) * self.dimension :]
|
|
603
|
-
# return alpha, beta
|
|
604
|
-
|
|
605
|
-
# def bc_slip(self, t, Q, **kwargs):
|
|
606
|
-
# return self.matrices.rhs_bc_slip(Q, **kwargs)
|
|
607
|
-
|
|
608
|
-
# def bc_slip_jacobian(self, t, Q, **kwargs):
|
|
609
|
-
# return self.matrices.rhs_bc_slip_jacobian(Q, **kwargs)
|
|
610
|
-
|
|
611
|
-
# def bc_newtonian(self, t, Q, **kwargs):
|
|
612
|
-
# return self.matrices.rhs_bc_newtonian(Q, **kwargs)
|
|
613
|
-
|
|
614
|
-
# def bc_newtonian_jacobian(self, t, Q, **kwargs):
|
|
615
|
-
# return self.matrices.rhs_bc_newtonian_jacobian(Q, **kwargs)
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
# class ShallowMomentsWithBottom2d(ShallowMoments2d):
|
|
619
|
-
# yaml_tag = "!ShallowMomentsWithBottom2d"
|
|
620
|
-
# dimension = 2
|
|
621
|
-
|
|
622
|
-
# def set_default_default_parameters(self):
|
|
623
|
-
# super().set_default_default_parameters()
|
|
624
|
-
|
|
625
|
-
# def set_runtime_variables(self):
|
|
626
|
-
# # I need to run the parent.parent.set_runtime_variables, since I need to call a different smm.Matrices !!
|
|
627
|
-
# # since this is not possible? (super().super() does not exist), i call it call it directly
|
|
628
|
-
# self.compute_unit_vectors()
|
|
629
|
-
# self.level = int((self.n_variables - 2) / self.dimension) - 1
|
|
630
|
-
|
|
631
|
-
# self.matrices = smm.MatricesWithBottom2d(level=self.level, basistype=self.basis)
|
|
632
|
-
# self.matrices.bc_type = self.bc_coupling_type
|
|
633
|
-
# self.matrices.basistype = self.basis
|
|
634
|
-
# self.matrices.set_runtime_variables()
|
|
635
|
-
|
|
636
|
-
# def get_alpha_beta(Q):
|
|
637
|
-
# return super().get_alpha_beta(Q[:-1])
|
|
638
|
-
|
|
639
|
-
# def primitive_variables(self, Q):
|
|
640
|
-
# res = np.zeros_like(Q)
|
|
641
|
-
# res[:-1] = super().primitive_variables(Q[:-1])
|
|
642
|
-
# res[-1] = Q[-1]
|
|
643
|
-
# return res
|
|
644
|
-
|
|
645
|
-
# def conservative_variables(self, U):
|
|
646
|
-
# res = np.zeros_like(U)
|
|
647
|
-
# res[:-1] = super().conservative_variables(U[:-1])
|
|
648
|
-
# res[-1] = U[-1]
|
|
649
|
-
# return res
|
|
650
|
-
|
|
651
|
-
# def flux(self, Q):
|
|
652
|
-
# res = np.zeros((Q.shape[0], self.dimension, Q.shape[1]))
|
|
653
|
-
# kwargs = {"g": self.g, "ez": self.ez}
|
|
654
|
-
# res = self.matrices.flux(Q, **kwargs)
|
|
655
|
-
# offset = 1 + self.level
|
|
656
|
-
# # h = np.where(Q[0] > 0, Q[0], 0)
|
|
657
|
-
# # res[1 : 1 + offset, 0] -= (
|
|
658
|
-
# # 1 / 2 * self.g * self.ez * np.einsum("k,...->k...", self.matrices.W, h**2)
|
|
659
|
-
# # )
|
|
660
|
-
# # res[1 + offset : 1 + 2 * offset, 1] -= (
|
|
661
|
-
# # 1 / 2 * self.g * self.ez * np.einsum("k,...->k...", self.matrices.W, h**2)
|
|
662
|
-
# # )
|
|
663
|
-
# return res
|
|
664
|
-
|
|
665
|
-
# def flux_jacobian(self, Q, **kwargs):
|
|
666
|
-
# out = np.zeros((Q.shape[0], Q.shape[0], self.dimension, Q.shape[1]))
|
|
667
|
-
# kwargs_in = {"g": self.g, "ez": self.ez}
|
|
668
|
-
# out = self.matrices.flux_jac(Q, **kwargs_in)
|
|
669
|
-
# # offset = 1 + self.level
|
|
670
|
-
# # h = np.where(Q[0] > 0, Q[0], 0)
|
|
671
|
-
# # out[1 : 1 + offset, -1, 0] -= (
|
|
672
|
-
# # h * self.g * self.ez * self.matrices.W[:]
|
|
673
|
-
# # ).reshape(out[1 : 1 + offset, -1, 0].shape)
|
|
674
|
-
# # out[1 + offset : 1 + 2 * offset, -1, 1] = (
|
|
675
|
-
# # h * self.g * self.ez * self.matrices.W[:]
|
|
676
|
-
# # ).reshape(out[1 : 1 + offset, -1, 0].shape)
|
|
677
|
-
# return out
|
|
678
|
-
|
|
679
|
-
# # # TODO HACK COMPATIBILITY
|
|
680
|
-
# # def nonconservative_matrix(self, Q, **kwargs):
|
|
681
|
-
# # result = np.zeros((Q.shape[0], Q.shape[0], self.dimension, Q.shape[1]))
|
|
682
|
-
# # h = Q[0]
|
|
683
|
-
# # h = np.where(h <= 0, 0.0, h)
|
|
684
|
-
# # result[1, 3, 0] = -h * self.g * self.ez
|
|
685
|
-
# # result[2, 3, 1] = -h * self.g * self.ez
|
|
686
|
-
# # return result
|
|
687
|
-
|
|
688
|
-
# def nonconservative_matrix(self, Q, **kwargs):
|
|
689
|
-
# out = super().nonconservative_matrix(Q, **kwargs)
|
|
690
|
-
# h = Q[0]
|
|
691
|
-
# offset = 1 + self.level
|
|
692
|
-
# # out[1 : 1 + offset, 0, 0] -= (
|
|
693
|
-
# # h * self.g * self.ez * self.matrices.W[:]
|
|
694
|
-
# # ).reshape(out[1 : 1 + offset, -1, 0].shape)
|
|
695
|
-
# # out[1 + offset : 1 + 2 * offset, 0, 1] -= (
|
|
696
|
-
# # h * self.g * self.ez * self.matrices.W[:]
|
|
697
|
-
# # ).reshape(out[1 : 1 + offset, -1, 0].shape)
|
|
698
|
-
# out[1 : 1 + offset, -1, 0, :] -= (
|
|
699
|
-
# self.g * self.ez * np.outer(self.matrices.W[:], h)
|
|
700
|
-
# ).reshape(out[1 : 1 + offset, -1, 0, :].shape)
|
|
701
|
-
# out[1 + offset : 1 + 2 * offset, -1, 1, :] -= (
|
|
702
|
-
# self.g * self.ez * np.outer(self.matrices.W[:], h)
|
|
703
|
-
# ).reshape(out[1 : 1 + offset, -1, 0, :].shape)
|
|
704
|
-
# return out
|
|
705
|
-
|
|
706
|
-
# def rhs(self, t, Q_, **kwargs):
|
|
707
|
-
# output = np.zeros_like(Q_)
|
|
708
|
-
# # Topography
|
|
709
|
-
# Q = np.array(Q_)
|
|
710
|
-
# Q[:-1] = np.where(Q_[0] <= 0, np.zeros_like(Q_[:-1]), Q_[:-1])
|
|
711
|
-
# h = Q[0]
|
|
712
|
-
# offset = 1 + self.level
|
|
713
|
-
# output[1 : 1 + offset] = (h * self.g * self.ex * self.matrices.W[:])[
|
|
714
|
-
# :, np.newaxis
|
|
715
|
-
# ]
|
|
716
|
-
# output[1 + offset : 1 + 2 * offset] = (
|
|
717
|
-
# h * self.g * self.ey * self.matrices.W[:]
|
|
718
|
-
# )[:, np.newaxis]
|
|
719
|
-
|
|
720
|
-
# # Friction
|
|
721
|
-
# for friction in self.friction_models:
|
|
722
|
-
# output += getattr(self, friction)(t, Q, **kwargs)
|
|
723
|
-
|
|
724
|
-
# return output
|
|
725
|
-
|
|
726
|
-
# def rhs_jacobian(self, t, Q, **kwargs):
|
|
727
|
-
# out = np.zeros((Q.shape[0], Q.shape[0], Q.shape[1]))
|
|
728
|
-
# # Topography
|
|
729
|
-
# offset = 1 + self.level
|
|
730
|
-
# out[1 : 1 + offset, 0] = (self.g * self.ex * self.matrices.W)[:, np.newaxis]
|
|
731
|
-
# out[1 + offset : 1 + 2 * offset, 0] = (self.g * self.ey * self.matrices.W)[
|
|
732
|
-
# :, np.newaxis
|
|
733
|
-
# ]
|
|
734
|
-
# # Friction
|
|
735
|
-
# for friction in self.friction_models:
|
|
736
|
-
# out += getattr(self, friction + "_jacobian")(t, Q, **kwargs)
|
|
737
|
-
# return out
|
|
738
|
-
|
|
739
|
-
# def bc_grad_slip(self, t, Q, **kwargs):
|
|
740
|
-
# return self.matrices.rhs_bc_grad_slip(Q, **kwargs)
|
|
741
|
-
|
|
742
|
-
# def bc_grad_slip_jacobian(self, t, Q, **kwargs):
|
|
743
|
-
# return self.matrices.rhs_bc_grad_slip_jacobian(Q, **kwargs)
|
|
744
|
-
|
|
745
|
-
# # # TODO HACK COMPATIBILITY
|
|
746
|
-
# # def bc_chezy(self, t, Q, **kwargs):
|
|
747
|
-
# # output = np.zeros_like(Q)
|
|
748
|
-
# # h = Q[0]
|
|
749
|
-
# # hu = Q[1]
|
|
750
|
-
# # hv = Q[2]
|
|
751
|
-
# # h = np.where(h <= 0.0, 0.0, h)
|
|
752
|
-
# # u = np.where(h <= 0.0, 0.0, hu / h)
|
|
753
|
-
# # v = np.where(h <= 0.0, 0.0, hv / h)
|
|
754
|
-
# # # C = kwargs["aux_variables"]["ChezyCoef"]
|
|
755
|
-
# # C = kwargs["model"].parameters["ChezyCoef"]
|
|
756
|
-
# # u_sq = np.sqrt(u**2 + v**2)
|
|
757
|
-
# # output[1] = -1.0 / C**2 * u * u_sq
|
|
758
|
-
# # output[2] = -1.0 / C**2 * v * u_sq
|
|
759
|
-
# # return output
|
|
760
|
-
|
|
761
|
-
# # TODO HACK COMPATIBILITY
|
|
762
|
-
# def bc_chezy_jacobian_swe(self, t, Q, **kwargs):
|
|
763
|
-
# out = np.zeros((Q.shape[0], Q.shape[0], Q.shape[1]))
|
|
764
|
-
# h = Q[0]
|
|
765
|
-
# hu = Q[1]
|
|
766
|
-
# hv = Q[2]
|
|
767
|
-
# h = np.where(h <= 0.0, 0.0, h)
|
|
768
|
-
# u = np.where(h <= 0.0, 0.0, hu / h)
|
|
769
|
-
# v = np.where(h <= 0.0, 0.0, hv / h)
|
|
770
|
-
# C = kwargs["model"].parameters["ChezyCoef"]
|
|
771
|
-
# # C = kwargs["aux_variables"]["ChezyCoef"]
|
|
772
|
-
# u_sq = np.sqrt(u**2 + v**2)
|
|
773
|
-
# eps = 10 ** (-10)
|
|
774
|
-
# out[1, 0] = +1.0 / C**2 * 2 * u * u_sq / h
|
|
775
|
-
# out[1, 1] = -1.0 / C**2 * (u / h / (u_sq + eps) * u + u_sq / h)
|
|
776
|
-
# out[1, 2] = -1.0 / C**2 * (u / h / (u_sq + eps) * v)
|
|
777
|
-
# out[2, 0] = +1.0 / C**2 * 2 * v * u_sq / h
|
|
778
|
-
# out[2, 1] = -1.0 / C**2 * (v / h / (u_sq + eps) * u)
|
|
779
|
-
# out[2, 2] = -1.0 / C**2 * (v / h / (u_sq + eps) * v + u_sq / h)
|
|
780
|
-
# return out
|
|
781
|
-
|
|
782
|
-
# def bc_chezy(self, t, Q, **kwargs):
|
|
783
|
-
# return self.matrices.rhs_bc_chezy(Q, **kwargs)
|
|
784
|
-
|
|
785
|
-
# def bc_chezy_jacobian(self, t, Q, **kwargs):
|
|
786
|
-
# return self.matrices.rhs_bc_chezy_jacobian(Q, **kwargs)
|
|
787
|
-
|
|
788
|
-
# def bc_slip(self, t, Q, **kwargs):
|
|
789
|
-
# return self.matrices.rhs_bc_slip(Q, **kwargs)
|
|
790
|
-
|
|
791
|
-
# def bc_slip_jacobian(self, t, Q, **kwargs):
|
|
792
|
-
# return self.matrices.rhs_bc_slip_jacobian(Q, **kwargs)
|
|
793
|
-
|
|
794
|
-
# def newtonian(self, t, Q, **kwargs):
|
|
795
|
-
# return self.matrices.rhs_newtonian(Q, **kwargs)
|
|
796
|
-
|
|
797
|
-
# def newtonian_jacobian(self, t, Q, **kwargs):
|
|
798
|
-
# return self.matrices.rhs_newtonian_jacobian(Q, **kwargs)
|
|
799
|
-
|
|
800
|
-
# def compute_Q_in_normal_transverse(self, Q_, n_, **kwargs):
|
|
801
|
-
# assert Q_.shape[1] == 1
|
|
802
|
-
# Q = np.array(Q_[:, 0])
|
|
803
|
-
# n = np.array(n_[:, 0])
|
|
804
|
-
# dim = self.dimension
|
|
805
|
-
# offset = self.level + 1
|
|
806
|
-
# assert dim == 2
|
|
807
|
-
# result = np.array(Q)
|
|
808
|
-
# mom = np.zeros((offset, dim))
|
|
809
|
-
# for d in range(dim):
|
|
810
|
-
# mom[:, d] = Q[1 + d * offset : 1 + (d + 1) * offset]
|
|
811
|
-
# mom_normal = np.einsum("ik... ,k... -> i...", mom, n[:dim])
|
|
812
|
-
# n_trans = np.cross(np.array([n[0], n[1], 0.0]), np.array([0.0, 0.0, 1.0]))
|
|
813
|
-
# mom_trans = np.einsum("ik... ,k... -> i...", mom, n_trans[:dim])
|
|
814
|
-
# result[1 : 1 + offset] = mom_normal
|
|
815
|
-
# result[1 + offset : 1 + 2 * offset] = mom_trans
|
|
816
|
-
# return result
|
|
817
|
-
|
|
818
|
-
# def compute_Q_in_x_y(self, Q_, n_, **kwargs):
|
|
819
|
-
# assert Q_.shape[1] == 1
|
|
820
|
-
# Q = np.array(Q_[:, 0])
|
|
821
|
-
# n = np.array(n_[:, 0])
|
|
822
|
-
# n = np.array([n[0], n[1], 0.0])
|
|
823
|
-
# dim = self.dimension
|
|
824
|
-
# offset = self.level + 1
|
|
825
|
-
# assert dim == 2
|
|
826
|
-
# result = np.array(Q)
|
|
827
|
-
# mom = np.zeros((offset, dim))
|
|
828
|
-
# mom_normal = Q[1 : 1 + offset]
|
|
829
|
-
# mom_trans = Q[1 + offset : 1 + 2 * offset]
|
|
830
|
-
# n_trans = np.cross(n, np.array([0.0, 0.0, 1.0]))
|
|
831
|
-
# nx = np.array([1.0, 0.0, 0.0])
|
|
832
|
-
# ny = np.array([0.0, 1.0, 0.0])
|
|
833
|
-
# result[1 : 1 + offset] = mom_normal * np.dot(n, nx)
|
|
834
|
-
# result[1 : 1 + offset] += mom_trans * np.dot(n_trans, nx)
|
|
835
|
-
# result[1 + offset : 1 + 2 * offset] = mom_normal * np.dot(n, ny)
|
|
836
|
-
# result[1 + offset : 1 + 2 * offset] += mom_trans * np.dot(n_trans, ny)
|
|
837
|
-
# return result
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
# class ShallowMomentsHyperbolicWithBottom2d(ShallowMomentsWithBottom2d):
|
|
841
|
-
# yaml_tag = "!ShallowMomentsHyperbolicWithBottom2d"
|
|
842
|
-
# dimension = 2
|
|
843
|
-
|
|
844
|
-
# def flux(self, Q):
|
|
845
|
-
# res = np.zeros((Q.shape[0], self.dimension, Q.shape[1]))
|
|
846
|
-
# kwargs = {"g": self.g, "ez": self.ez}
|
|
847
|
-
# offset = 1 + self.level
|
|
848
|
-
# res = self.matrices.flux(Q, **kwargs)
|
|
849
|
-
# return res
|
|
850
|
-
|
|
851
|
-
# def nonconservative_matrix(self, Q, **kwargs):
|
|
852
|
-
# offset = 1 + self.level
|
|
853
|
-
# Qlin = np.array(Q)
|
|
854
|
-
# Qlin[1 + 1 : 1 + offset] = 0.0
|
|
855
|
-
# Qlin[1 + 1 + offset : 1 + 2 * offset] = 0.0
|
|
856
|
-
# out = super().flux_jacobian(Q, **kwargs) - super().quasilinear_matrix(
|
|
857
|
-
# Qlin, **kwargs
|
|
858
|
-
# )
|
|
859
|
-
# return out
|
|
860
|
-
|
|
861
|
-
# def quasilinear_matrix(self, Q, **kwargs):
|
|
862
|
-
# offset = 1 + self.level
|
|
863
|
-
# Qlin = np.array(Q)
|
|
864
|
-
# Qlin[1 + 1 : 1 + offset] = 0.0
|
|
865
|
-
# Qlin[1 + 1 + offset : 1 + 2 * offset] = 0.0
|
|
866
|
-
# out = super().quasilinear_matrix(Qlin, **kwargs)
|
|
867
|
-
# return out
|