Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/src/equations/equations.jl
5586 views
1
# By default, Julia/LLVM does not use fused multiply-add operations (FMAs).
2
# Since these FMAs can increase the performance of many numerical algorithms,
3
# we need to opt-in explicitly.
4
# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details.
5
@muladd begin
6
#! format: noindent
7
8
# Retrieve number of variables from equation instance
9
@inline nvariables(::AbstractEquations{NDIMS, NVARS}) where {NDIMS, NVARS} = NVARS
10
11
# TODO: Taal performance, 1:NVARS vs. Base.OneTo(NVARS) vs. SOneTo(NVARS)
12
"""
13
eachvariable(equations::AbstractEquations)
14
15
Return an iterator over the indices that specify the location in relevant data structures
16
for the variables in `equations`. In particular, not the variables themselves are returned.
17
"""
18
@inline eachvariable(equations::AbstractEquations) = Base.OneTo(nvariables(equations))
19
20
"""
21
get_name(equations::AbstractEquations)
22
23
Returns the canonical, human-readable name for the given system of equations.
24
25
# Examples
26
```jldoctest
27
julia> Trixi.get_name(CompressibleEulerEquations1D(1.4))
28
"CompressibleEulerEquations1D"
29
```
30
"""
31
get_name(equations::AbstractEquations) = equations |> typeof |> nameof |> string
32
33
"""
34
varnames(conversion_function, equations)
35
36
Return the list of variable names when applying `conversion_function` to the
37
conserved variables associated to `equations`. This function is mainly used
38
internally to determine output to screen and for IO, e.g., for the
39
[`AnalysisCallback`](@ref) and the [`SaveSolutionCallback`](@ref).
40
Common choices of the `conversion_function` are [`cons2cons`](@ref) and
41
[`cons2prim`](@ref).
42
"""
43
function varnames end
44
45
# Return the index of `varname` in `varnames(solution_variables, equations)` if available.
46
# Otherwise, throw an error.
47
function get_variable_index(varname, equations;
48
solution_variables = cons2cons)
49
index = findfirst(==(varname), varnames(solution_variables, equations))
50
if isnothing(index)
51
throw(ArgumentError("$varname is no valid variable."))
52
end
53
54
return index
55
end
56
57
# Add methods to show some information on systems of equations.
58
function Base.show(io::IO, equations::AbstractEquations)
59
# Since this is not performance-critical, we can use `@nospecialize` to reduce latency.
60
@nospecialize equations # reduce precompilation time
61
62
print(io, get_name(equations), " with ")
63
if nvariables(equations) == 1
64
print(io, "one variable")
65
else
66
print(io, nvariables(equations), " variables")
67
end
68
end
69
70
function Base.show(io::IO, ::MIME"text/plain", equations::AbstractEquations)
71
# Since this is not performance-critical, we can use `@nospecialize` to reduce latency.
72
@nospecialize equations # reduce precompilation time
73
74
if get(io, :compact, false)
75
show(io, equations)
76
else
77
summary_header(io, get_name(equations))
78
summary_line(io, "#variables", nvariables(equations))
79
for variable in eachvariable(equations)
80
summary_line(increment_indent(io),
81
"variable " * string(variable),
82
varnames(cons2cons, equations)[variable])
83
end
84
summary_footer(io)
85
end
86
end
87
88
@inline Base.ndims(::AbstractEquations{NDIMS}) where {NDIMS} = NDIMS
89
90
# Equations act like scalars in broadcasting.
91
# The manual recommends `Ref`, but a single-argument tuple is morally equivalent.
92
# For code that is allocation sensitive tuple is preferable, since `Ref` relies on the optimizer
93
# to prove it non-escaping which is more precarious than just using an immutable tuple.
94
Base.broadcastable(equations::AbstractEquations) = (equations,)
95
96
"""
97
flux(u, orientation_or_normal, equations)
98
99
Given the conservative variables `u`, calculate the (physical) flux in Cartesian
100
direction `orientation::Integer` or in arbitrary direction `normal::AbstractVector`
101
for the corresponding set of governing `equations`.
102
`orientation` is `1`, `2`, and `3` for the x-, y-, and z-directions, respectively.
103
"""
104
function flux end
105
106
"""
107
flux(u, normal_direction::AbstractVector, equations::AbstractEquations{1})
108
109
Enables calling `flux` with a non-integer argument `normal_direction` for one-dimensional
110
equations. Returns the value of `flux(u, 1, equations)` scaled by `normal_direction[1]`.
111
"""
112
@inline function flux(u, normal_direction::AbstractVector,
113
equations::AbstractEquations{1})
114
# Call `flux` with `orientation::Int = 1` for dispatch. Note that the actual
115
# `orientation` argument is ignored.
116
return normal_direction[1] * flux(u, 1, equations)
117
end
118
119
"""
120
rotate_to_x(u, normal, equations)
121
122
Apply the rotation that maps `normal` onto the x-axis to the convservative variables `u`.
123
This is used by [`FluxRotated`](@ref) to calculate the numerical flux of rotationally
124
invariant equations in arbitrary normal directions.
125
126
See also: [`rotate_from_x`](@ref)
127
"""
128
function rotate_to_x end
129
130
"""
131
rotate_from_x(u, normal, equations)
132
133
Apply the rotation that maps the x-axis onto `normal` to the convservative variables `u`.
134
This is used by [`FluxRotated`](@ref) to calculate the numerical flux of rotationally
135
invariant equations in arbitrary normal directions.
136
137
See also: [`rotate_to_x`](@ref)
138
"""
139
function rotate_from_x end
140
141
"""
142
BoundaryConditionDirichlet(boundary_value_function)
143
144
Create a Dirichlet boundary condition that uses the function `boundary_value_function`
145
to specify the values at the boundary.
146
This can be used to create a boundary condition that specifies exact boundary values
147
by passing the exact solution of the equation.
148
The passed boundary value function will be called with the same arguments as an initial condition function is called, i.e., as
149
```julia
150
boundary_value_function(x, t, equations)
151
```
152
where `x` specifies the coordinates, `t` is the current time, and `equation` is the corresponding system of equations.
153
154
# Examples
155
```julia
156
julia> BoundaryConditionDirichlet(initial_condition_convergence_test)
157
```
158
"""
159
struct BoundaryConditionDirichlet{B}
160
boundary_value_function::B
161
end
162
163
# Dirichlet-type boundary condition for use with TreeMesh or StructuredMesh
164
@inline function (boundary_condition::BoundaryConditionDirichlet)(u_inner,
165
orientation_or_normal,
166
direction,
167
x, t,
168
surface_flux_function,
169
equations)
170
u_boundary = boundary_condition.boundary_value_function(x, t, equations)
171
172
# Calculate boundary flux
173
if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary
174
flux = surface_flux_function(u_inner, u_boundary, orientation_or_normal,
175
equations)
176
else # u_boundary is "left" of boundary, u_inner is "right" of boundary
177
flux = surface_flux_function(u_boundary, u_inner, orientation_or_normal,
178
equations)
179
end
180
181
return flux
182
end
183
184
# Dirichlet-type boundary condition for use with TreeMesh or StructuredMesh
185
# passing a tuple of surface flux functions for nonconservative terms
186
@inline function (boundary_condition::BoundaryConditionDirichlet)(u_inner,
187
orientation_or_normal,
188
direction,
189
x, t,
190
surface_flux_functions::Tuple,
191
equations)
192
surface_flux_function, nonconservative_flux_function = surface_flux_functions
193
194
u_boundary = boundary_condition.boundary_value_function(x, t, equations)
195
196
# Calculate boundary flux
197
if iseven(direction) # u_inner is "left" of boundary, u_boundary is "right" of boundary
198
flux = surface_flux_function(u_inner, u_boundary, orientation_or_normal,
199
equations)
200
noncons_flux = nonconservative_flux_function(u_inner, u_boundary,
201
orientation_or_normal,
202
equations)
203
else # u_boundary is "left" of boundary, u_inner is "right" of boundary
204
flux = surface_flux_function(u_boundary, u_inner, orientation_or_normal,
205
equations)
206
noncons_flux = nonconservative_flux_function(u_inner, u_boundary,
207
orientation_or_normal,
208
equations)
209
end
210
211
return flux, noncons_flux
212
end
213
214
# Dirichlet-type boundary condition for use with UnstructuredMesh2D
215
# Note: For unstructured we lose the concept of an "absolute direction"
216
@inline function (boundary_condition::BoundaryConditionDirichlet)(u_inner,
217
normal_direction::AbstractVector,
218
x, t,
219
surface_flux_function,
220
equations)
221
# get the external value of the solution
222
u_boundary = boundary_condition.boundary_value_function(x, t, equations)
223
224
# Calculate boundary flux
225
flux = surface_flux_function(u_inner, u_boundary, normal_direction, equations)
226
227
return flux
228
end
229
230
# Dirichlet-type boundary condition for equations with non-conservative terms for use with UnstructuredMesh2D
231
# passing a tuple of surface flux functions for nonconservative terms
232
# Note: For unstructured we lose the concept of an "absolute direction"
233
@inline function (boundary_condition::BoundaryConditionDirichlet)(u_inner,
234
normal_direction::AbstractVector,
235
x, t,
236
surface_flux_functions::Tuple,
237
equations)
238
surface_flux_function, nonconservative_flux_function = surface_flux_functions
239
240
# get the external value of the solution
241
u_boundary = boundary_condition.boundary_value_function(x, t, equations)
242
243
# Calculate boundary flux
244
flux = surface_flux_function(u_inner, u_boundary, normal_direction, equations)
245
noncons_flux = nonconservative_flux_function(u_inner, u_boundary, normal_direction,
246
equations)
247
return flux, noncons_flux
248
end
249
250
# operator types used for dispatch on parabolic boundary fluxes
251
struct Gradient end
252
struct Divergence end
253
254
"""
255
BoundaryConditionNeumann(boundary_normal_flux_function)
256
257
Similar to `BoundaryConditionDirichlet`, but creates a Neumann boundary condition for parabolic
258
equations that uses the function `boundary_normal_flux_function` to specify the values of the normal
259
flux at the boundary.
260
The passed boundary value function will be called with the same arguments as an initial condition function is called, i.e., as
261
```julia
262
boundary_normal_flux_function(x, t, equations)
263
```
264
where `x` specifies the coordinates, `t` is the current time, and `equation` is the corresponding system of equations.
265
"""
266
struct BoundaryConditionNeumann{B}
267
boundary_normal_flux_function::B
268
end
269
270
"""
271
NonConservativeLocal()
272
273
Struct used for multiple dispatch on non-conservative flux functions in the format of "local * symmetric".
274
When the argument `nonconservative_type` is of type `NonConservativeLocal`,
275
the function returns the local part of the non-conservative term.
276
"""
277
struct NonConservativeLocal end
278
279
"""
280
NonConservativeSymmetric()
281
282
Struct used for multiple dispatch on non-conservative flux functions in the format of "local * symmetric".
283
When the argument `nonconservative_type` is of type `NonConservativeSymmetric`,
284
the function returns the symmetric part of the non-conservative term.
285
"""
286
struct NonConservativeSymmetric end
287
288
"""
289
NonConservativeJump()
290
291
Struct used for multiple dispatch on non-conservative flux functions in the format of "local * jump".
292
When the argument `nonconservative_type` is of type `NonConservativeJump`,
293
the function returns the jump part of the non-conservative term.
294
"""
295
struct NonConservativeJump end
296
297
"""
298
FluxNonConservative{STRUCTURE}
299
300
Abstract type for non-conservative fluxes that are composed of a local term and a structured two-point
301
term. The `STRUCTURE` type parameter should be set to [`NonConservativeSymmetric`](@ref) or
302
[`NonConservativeJump`](@ref), depending on the structure of the non-conservative term.
303
The abstract type is required for dispatch on the non-conservative type (symmetric / jump)
304
for the staggered volume flux computation in `calcflux_fhat!`.
305
"""
306
abstract type FluxNonConservative{STRUCTURE} end
307
308
# set sensible default values that may be overwritten by specific equations
309
"""
310
have_nonconservative_terms(equations)
311
312
Trait function determining whether `equations` represent a conservation law
313
with or without nonconservative terms. Classical conservation laws such as the
314
[`CompressibleEulerEquations2D`](@ref) do not have nonconservative terms. The
315
[`IdealGlmMhdEquations2D`](@ref) are an example of equations with nonconservative terms.
316
The return value will be `True()` or `False()` to allow dispatching on the return type.
317
"""
318
have_nonconservative_terms(::AbstractEquations) = False()
319
"""
320
n_nonconservative_terms(volume_flux_noncons)
321
322
Number of nonconservative terms for a particular nonconservative flux. Even for a specific equation,
323
this number may vary between different nonconservative fluxes.
324
This function needs to be specialized only if equations with nonconservative terms are
325
combined with certain solvers (e.g., subcell limiting).
326
"""
327
function n_nonconservative_terms end
328
329
"""
330
Trixi.combine_conservative_and_nonconservative_fluxes(flux, equations)
331
332
Trait function indicating whether the given `flux` and `equations` support
333
fusing the computation of conservative fluxes with nonconservative fluxes.
334
This is purely a performance optimization for equations with nonconservative
335
terms (i.e., where `have_nonconservative_terms(equations)` is `Trixi.True()`).
336
The default value is `Trixi.False()`, i.e., you have to pass a tuple of
337
numerical fluxes for the conservative and the nonconservative terms, e.g.,
338
to compute surface terms or the [`VolumeIntegralFluxDifferencing`](@ref).
339
340
For some systems and flux implementations, it is cheaper to compute
341
342
flux_noncons(u_ll, u_rr, orientation_or_normal_direction, equations)
343
344
and
345
346
flux_noncons(u_rr, u_ll, orientation_or_normal_direction, equations)
347
348
together, or to compute conservative and nonconservative flux contributions in
349
a single fused kernel. In this case, you should set this trait to be `Trixi.True()`
350
to take advantage of a more efficient implementation. In this case, you have to
351
define a single method that computes
352
353
flux_cons(u_ll, u_rr, n, equations) + 0.5f0 * flux_noncons(u_ll, u_rr, n, equations)
354
355
and
356
357
flux_cons(u_ll, u_rr, n, equations) + 0.5f0 * flux_noncons(u_rr, u_ll, n, equations)
358
359
together and returns them as a tuple.
360
See also the test section P4estMesh2D with combine_conservative_and_nonconservative_fluxes in
361
[Test Performance](https://github.com/trixi-framework/Trixi.jl/blob/main/test/test_performance_specializations_2d.jl).
362
"""
363
combine_conservative_and_nonconservative_fluxes(flux, ::AbstractEquations) = False()
364
365
"""
366
have_constant_speed(::AbstractEquations)
367
368
Indicates whether the characteristic speeds are constant, i.e., independent of the solution.
369
Queried in the timestep computation [`StepsizeCallback`](@ref).
370
371
This is the default fallback for nonlinear equations.
372
373
# Returns
374
- `False()`
375
"""
376
have_constant_speed(::AbstractEquations) = False()
377
378
"""
379
default_analysis_errors(equations)
380
381
Default analysis errors (`:l2_error` and `:linf_error`) used by the
382
[`AnalysisCallback`](@ref).
383
"""
384
default_analysis_errors(::AbstractEquations) = (:l2_error, :linf_error)
385
386
"""
387
default_analysis_integrals(equations)
388
389
Default analysis integrals used by the [`AnalysisCallback`](@ref).
390
"""
391
default_analysis_integrals(::AbstractEquations) = (entropy_timederivative,)
392
393
"""
394
cons2cons(u, equations)
395
396
Return the conserved variables `u`. While this function is as trivial as `identity`,
397
it is also as useful.
398
"""
399
@inline cons2cons(u, ::AbstractEquations) = u
400
401
@inline Base.first(u, ::AbstractEquations) = first(u)
402
403
"""
404
cons2prim(u, equations)
405
406
Convert the conserved variables `u` to the primitive variables for a given set of
407
`equations`. `u` is a vector type of the correct length `nvariables(equations)`.
408
Notice the function doesn't include any error checks for the purpose of efficiency,
409
so please make sure your input is correct.
410
The inverse conversion is performed by [`prim2cons`](@ref).
411
"""
412
function cons2prim end
413
414
"""
415
prim2cons(u, equations)
416
417
Convert the primitive variables `u` to the conserved variables for a given set of
418
`equations`. `u` is a vector type of the correct length `nvariables(equations)`.
419
Notice the function doesn't include any error checks for the purpose of efficiency,
420
so please make sure your input is correct.
421
The inverse conversion is performed by [`cons2prim`](@ref).
422
"""
423
function prim2cons end
424
425
"""
426
velocity(u, equations)
427
428
Return the velocity vector corresponding to the equations, e.g., fluid velocity for
429
Euler's equations. The velocity in certain orientation or normal direction (scalar) can be computed
430
with `velocity(u, orientation, equations)` or `velocity(u, normal_direction, equations)`
431
respectively. The `velocity(u, normal_direction, equations)` function calls
432
`velocity(u, equations)` to compute the velocity vector and then normal vector, thus allowing
433
a general function to be written for the AbstractEquations type. However, the
434
`velocity(u, orientation, equations)` is written for each equation separately to ensure
435
only the velocity in the desired direction (orientation) is computed.
436
`u` is a vector of the conserved variables at a single node, i.e., a vector
437
of the correct length `nvariables(equations)`.
438
"""
439
function velocity end
440
441
@inline function velocity(u, normal_direction::AbstractVector,
442
equations::AbstractEquations{2})
443
vel = velocity(u, equations)
444
v = vel[1] * normal_direction[1] + vel[2] * normal_direction[2]
445
return v
446
end
447
448
@inline function velocity(u, normal_direction::AbstractVector,
449
equations::AbstractEquations{3})
450
vel = velocity(u, equations)
451
v = vel[1] * normal_direction[1] + vel[2] * normal_direction[2] +
452
vel[3] * normal_direction[3]
453
return v
454
end
455
456
"""
457
entropy(u, equations)
458
459
Return the chosen entropy of the conserved variables `u` for a given set of
460
`equations`.
461
462
`u` is a vector of the conserved variables at a single node, i.e., a vector
463
of the correct length `nvariables(equations)`.
464
"""
465
function entropy end
466
467
"""
468
cons2entropy(u, equations)
469
470
Convert the conserved variables `u` to the entropy variables for a given set of
471
`equations` with chosen standard [`entropy`](@ref).
472
473
`u` is a vector type of the correct length `nvariables(equations)`.
474
Notice the function doesn't include any error checks for the purpose of efficiency,
475
so please make sure your input is correct.
476
The inverse conversion is performed by [`entropy2cons`](@ref).
477
"""
478
function cons2entropy end
479
480
"""
481
entropy2cons(w, equations)
482
483
Convert the entropy variables `w` based on a standard [`entropy`](@ref) to the
484
conserved variables for a given set of `equations`.
485
`u` is a vector type of the correct length `nvariables(equations)`.
486
Notice the function doesn't include any error checks for the purpose of efficiency,
487
so please make sure your input is correct.
488
The inverse conversion is performed by [`cons2entropy`](@ref).
489
"""
490
function entropy2cons end
491
492
"""
493
energy_total(u, equations)
494
495
Return the total energy of the conserved variables `u` for a given set of
496
`equations`, e.g., the [`CompressibleEulerEquations2D`](@ref).
497
498
`u` is a vector of the conserved variables at a single node, i.e., a vector
499
of the correct length `nvariables(equations)`.
500
"""
501
function energy_total end
502
503
"""
504
energy_kinetic(u, equations)
505
506
Return the kinetic energy of the conserved variables `u` for a given set of
507
`equations`, e.g., the [`CompressibleEulerEquations2D`](@ref).
508
509
`u` is a vector of the conserved variables at a single node, i.e., a vector
510
of the correct length `nvariables(equations)`.
511
"""
512
function energy_kinetic end
513
514
"""
515
energy_internal(u, equations)
516
517
Return the internal energy of the conserved variables `u` for a given set of
518
`equations`, e.g., the [`CompressibleEulerEquations2D`](@ref).
519
520
`u` is a vector of the conserved variables at a single node, i.e., a vector
521
of the correct length `nvariables(equations)`.
522
"""
523
function energy_internal end
524
525
"""
526
density(u, equations)
527
528
Return the density associated to the conserved variables `u` for a given set of
529
`equations`, e.g., the [`CompressibleEulerEquations2D`](@ref).
530
531
`u` is a vector of the conserved variables at a single node, i.e., a vector
532
of the correct length `nvariables(equations)`.
533
"""
534
function density end
535
536
"""
537
pressure(u, equations)
538
539
Return the pressure associated to the conserved variables `u` for a given set of
540
`equations`, e.g., the [`CompressibleEulerEquations2D`](@ref).
541
542
`u` is a vector of the conserved variables at a single node, i.e., a vector
543
of the correct length `nvariables(equations)`.
544
"""
545
function pressure end
546
547
"""
548
density_pressure(u, equations)
549
550
Return the product of the [`density`](@ref) and the [`pressure`](@ref)
551
associated to the conserved variables `u` for a given set of
552
`equations`, e.g., the [`CompressibleEulerEquations2D`](@ref).
553
This can be useful, e.g., as a variable for (shock-cappturing or AMR)
554
indicators as it combines two variables which must stay positive into one.
555
556
Furthermore, this implementation is for media which are described by an
557
ideal gas law alike equation of state more efficient than
558
computing [`pressure(u, equations)`](@ref) first and then multiplying with the density.
559
This is due to the fact that in computation of the pressure,
560
the kinetic energy needs to be computed, which usually involves
561
**division** of the squared momenta by the density.
562
This operation can be avoided!
563
564
`u` is a vector of the conserved variables at a single node, i.e., a vector
565
of the correct length `nvariables(equations)`.
566
"""
567
function density_pressure end
568
569
"""
570
waterheight(u, equations)
571
572
Return the water height associated to the conserved variables `u` for a given set of
573
`equations`.
574
575
`u` is a vector of the conserved variables at a single node, i.e., a vector
576
of the correct length `nvariables(equations)`.
577
578
!!! note
579
This function is defined in Trixi.jl to have a common interface for the
580
methods implemented in the subpackages [TrixiAtmo.jl](https://github.com/trixi-framework/TrixiAtmo.jl)
581
and [TrixiShallowWater.jl](https://github.com/trixi-framework/TrixiShallowWater.jl).
582
"""
583
function waterheight end
584
585
"""
586
waterheight_pressure(u, equations)
587
588
Return the product of the [`waterheight`](@ref) and the [`pressure`](@ref)
589
associated to the conserved variables `u` for a given set of
590
`equations`.
591
592
`u` is a vector of the conserved variables at a single node, i.e., a vector
593
of the correct length `nvariables(equations)`.
594
595
!!! note
596
This function is defined in Trixi.jl to have a common interface for the
597
methods implemented in the subpackages [TrixiAtmo.jl](https://github.com/trixi-framework/TrixiAtmo.jl)
598
and [TrixiShallowWater.jl](https://github.com/trixi-framework/TrixiShallowWater.jl).
599
"""
600
function waterheight_pressure end
601
602
"""
603
lake_at_rest_error(u, equations)
604
605
Calculate the point-wise error for the lake-at-rest steady state solution.
606
607
!!! note
608
This function is defined in Trixi.jl to have a common interface for the
609
methods implemented in the subpackages [TrixiAtmo.jl](https://github.com/trixi-framework/TrixiAtmo.jl)
610
and [TrixiShallowWater.jl](https://github.com/trixi-framework/TrixiShallowWater.jl).
611
"""
612
function lake_at_rest_error end
613
614
# Default implementation of gradient for `variable`. Used for subcell limiting.
615
# Implementing a gradient function for a specific variable improves the performance.
616
@inline function gradient_conservative(variable, u, equations)
617
return ForwardDiff.gradient(x -> variable(x, equations), u)
618
end
619
620
####################################################################################################
621
# Include files with actual implementations for different systems of equations.
622
623
# Numerical flux formulations that are independent of the specific system of equations
624
include("numerical_fluxes.jl")
625
626
# Linear scalar advection
627
abstract type AbstractLinearScalarAdvectionEquation{NDIMS} <:
628
AbstractEquations{NDIMS, 1} end
629
include("linear_scalar_advection_1d.jl")
630
include("linear_scalar_advection_2d.jl")
631
include("linear_scalar_advection_3d.jl")
632
633
# Inviscid Burgers
634
abstract type AbstractInviscidBurgersEquation{NDIMS, NVARS} <:
635
AbstractEquations{NDIMS, NVARS} end
636
include("inviscid_burgers_1d.jl")
637
638
# Shallow water equations
639
abstract type AbstractShallowWaterEquations{NDIMS, NVARS} <:
640
AbstractEquations{NDIMS, NVARS} end
641
642
# CompressibleEulerEquations
643
abstract type AbstractCompressibleEulerEquations{NDIMS, NVARS} <:
644
AbstractEquations{NDIMS, NVARS} end
645
include("compressible_euler_1d.jl")
646
include("compressible_euler_2d.jl")
647
include("compressible_euler_3d.jl")
648
include("compressible_euler_quasi_1d.jl")
649
650
# Non-ideal compressibleEulerEquations
651
abstract type AbstractNonIdealCompressibleEulerEquations{NDIMS, NVARS} <:
652
AbstractCompressibleEulerEquations{NDIMS, NVARS} end
653
include("equations_of_state.jl")
654
include("nonideal_compressible_euler.jl")
655
include("nonideal_compressible_euler_1d.jl")
656
include("nonideal_compressible_euler_2d.jl")
657
658
# CompressibleEulerMulticomponentEquations
659
abstract type AbstractCompressibleEulerMulticomponentEquations{NDIMS, NVARS, NCOMP} <:
660
AbstractEquations{NDIMS, NVARS} end
661
include("compressible_euler_multicomponent_1d.jl")
662
include("compressible_euler_multicomponent_2d.jl")
663
664
# PolytropicEulerEquations
665
abstract type AbstractPolytropicEulerEquations{NDIMS, NVARS} <:
666
AbstractEquations{NDIMS, NVARS} end
667
include("polytropic_euler_2d.jl")
668
669
# Passive tracer equations
670
include("passive_tracers.jl")
671
672
# Retrieve number of components from equation instance for the multicomponent case
673
@inline function ncomponents(::AbstractCompressibleEulerMulticomponentEquations{NDIMS,
674
NVARS,
675
NCOMP}) where {
676
NDIMS,
677
NVARS,
678
NCOMP
679
}
680
return NCOMP
681
end
682
"""
683
eachcomponent(equations::AbstractCompressibleEulerMulticomponentEquations)
684
685
Return an iterator over the indices that specify the location in relevant data structures
686
for the components in `AbstractCompressibleEulerMulticomponentEquations`.
687
In particular, not the components themselves are returned.
688
"""
689
@inline function eachcomponent(equations::AbstractCompressibleEulerMulticomponentEquations)
690
return Base.OneTo(ncomponents(equations))
691
end
692
693
# Ideal MHD
694
abstract type AbstractIdealGlmMhdEquations{NDIMS, NVARS} <:
695
AbstractEquations{NDIMS, NVARS} end
696
include("ideal_glm_mhd_1d.jl")
697
include("ideal_glm_mhd_2d.jl")
698
include("ideal_glm_mhd_3d.jl")
699
700
# IdealGlmMhdMulticomponentEquations
701
abstract type AbstractIdealGlmMhdMulticomponentEquations{NDIMS, NVARS, NCOMP} <:
702
AbstractEquations{NDIMS, NVARS} end
703
include("ideal_glm_mhd_multicomponent_1d.jl")
704
include("ideal_glm_mhd_multicomponent_2d.jl")
705
706
# IdealMhdMultiIonEquations
707
abstract type AbstractIdealGlmMhdMultiIonEquations{NDIMS, NVARS, NCOMP} <:
708
AbstractEquations{NDIMS, NVARS} end
709
include("ideal_glm_mhd_multiion.jl")
710
include("ideal_glm_mhd_multiion_2d.jl")
711
include("ideal_glm_mhd_multiion_3d.jl")
712
713
# Retrieve number of components from equation instance for the multicomponent case
714
@inline function ncomponents(::AbstractIdealGlmMhdMulticomponentEquations{NDIMS, NVARS,
715
NCOMP}) where {
716
NDIMS,
717
NVARS,
718
NCOMP
719
}
720
return NCOMP
721
end
722
"""
723
eachcomponent(equations::AbstractIdealGlmMhdMulticomponentEquations)
724
725
Return an iterator over the indices that specify the location in relevant data structures
726
for the components in `AbstractIdealGlmMhdMulticomponentEquations`.
727
In particular, not the components themselves are returned.
728
"""
729
@inline function eachcomponent(equations::AbstractIdealGlmMhdMulticomponentEquations)
730
return Base.OneTo(ncomponents(equations))
731
end
732
733
# Retrieve number of components from equation instance for the multi-ion case
734
@inline function ncomponents(::AbstractIdealGlmMhdMultiIonEquations{NDIMS, NVARS,
735
NCOMP}) where {
736
NDIMS,
737
NVARS,
738
NCOMP
739
}
740
return NCOMP
741
end
742
743
"""
744
eachcomponent(equations::AbstractIdealGlmMhdMultiIonEquations)
745
746
Return an iterator over the indices that specify the location in relevant data structures
747
for the components in `AbstractIdealGlmMhdMultiIonEquations`.
748
In particular, not the components themselves are returned.
749
"""
750
@inline function eachcomponent(equations::AbstractIdealGlmMhdMultiIonEquations)
751
return Base.OneTo(ncomponents(equations))
752
end
753
754
# Diffusion equation: first order hyperbolic system
755
abstract type AbstractHyperbolicDiffusionEquations{NDIMS, NVARS} <:
756
AbstractEquations{NDIMS, NVARS} end
757
include("hyperbolic_diffusion_1d.jl")
758
include("hyperbolic_diffusion_2d.jl")
759
include("hyperbolic_diffusion_3d.jl")
760
761
# Lattice-Boltzmann equation (advection part only)
762
abstract type AbstractLatticeBoltzmannEquations{NDIMS, NVARS} <:
763
AbstractEquations{NDIMS, NVARS} end
764
include("lattice_boltzmann_2d.jl")
765
include("lattice_boltzmann_3d.jl")
766
767
# Acoustic perturbation equations
768
abstract type AbstractAcousticPerturbationEquations{NDIMS, NVARS} <:
769
AbstractEquations{NDIMS, NVARS} end
770
include("acoustic_perturbation_2d.jl")
771
772
# Linearized Euler equations
773
abstract type AbstractLinearizedEulerEquations{NDIMS, NVARS} <:
774
AbstractEquations{NDIMS, NVARS} end
775
include("linearized_euler_1d.jl")
776
include("linearized_euler_2d.jl")
777
include("linearized_euler_3d.jl")
778
779
abstract type AbstractEquationsParabolic{NDIMS, NVARS, GradientVariables} <:
780
AbstractEquations{NDIMS, NVARS} end
781
782
# Lighthill-Witham-Richards (LWR) traffic flow model
783
abstract type AbstractTrafficFlowLWREquations{NDIMS, NVARS} <:
784
AbstractEquations{NDIMS, NVARS} end
785
include("traffic_flow_lwr_1d.jl")
786
787
abstract type AbstractMaxwellEquations{NDIMS, NVARS} <:
788
AbstractEquations{NDIMS, NVARS} end
789
include("maxwell_1d.jl")
790
791
abstract type AbstractLinearElasticityEquations{NDIMS, NVARS} <:
792
AbstractEquations{NDIMS, NVARS} end
793
include("linear_elasticity_1d.jl")
794
end # @muladd
795
796