Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/src/equations/equations.jl
2055 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`] 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
have_constant_speed(::AbstractEquations) = False()
330
331
"""
332
default_analysis_errors(equations)
333
334
Default analysis errors (`:l2_error` and `:linf_error`) used by the
335
[`AnalysisCallback`](@ref).
336
"""
337
default_analysis_errors(::AbstractEquations) = (:l2_error, :linf_error)
338
339
"""
340
default_analysis_integrals(equations)
341
342
Default analysis integrals used by the [`AnalysisCallback`](@ref).
343
"""
344
default_analysis_integrals(::AbstractEquations) = (entropy_timederivative,)
345
346
"""
347
cons2cons(u, equations)
348
349
Return the conserved variables `u`. While this function is as trivial as `identity`,
350
it is also as useful.
351
"""
352
@inline cons2cons(u, ::AbstractEquations) = u
353
354
@inline Base.first(u, ::AbstractEquations) = first(u)
355
356
"""
357
cons2prim(u, equations)
358
359
Convert the conserved variables `u` to the primitive variables for a given set of
360
`equations`. `u` is a vector type of the correct length `nvariables(equations)`.
361
Notice the function doesn't include any error checks for the purpose of efficiency,
362
so please make sure your input is correct.
363
The inverse conversion is performed by [`prim2cons`](@ref).
364
"""
365
function cons2prim end
366
367
"""
368
prim2cons(u, equations)
369
370
Convert the primitive variables `u` to the conserved variables for a given set of
371
`equations`. `u` is a vector type of the correct length `nvariables(equations)`.
372
Notice the function doesn't include any error checks for the purpose of efficiency,
373
so please make sure your input is correct.
374
The inverse conversion is performed by [`cons2prim`](@ref).
375
"""
376
function prim2cons end
377
378
"""
379
velocity(u, equations)
380
381
Return the velocity vector corresponding to the equations, e.g., fluid velocity for
382
Euler's equations. The velocity in certain orientation or normal direction (scalar) can be computed
383
with `velocity(u, orientation, equations)` or `velocity(u, normal_direction, equations)`
384
respectively. The `velocity(u, normal_direction, equations)` function calls
385
`velocity(u, equations)` to compute the velocity vector and then normal vector, thus allowing
386
a general function to be written for the AbstractEquations type. However, the
387
`velocity(u, orientation, equations)` is written for each equation separately to ensure
388
only the velocity in the desired direction (orientation) is computed.
389
`u` is a vector of the conserved variables at a single node, i.e., a vector
390
of the correct length `nvariables(equations)`.
391
"""
392
function velocity end
393
394
@inline function velocity(u, normal_direction::AbstractVector,
395
equations::AbstractEquations{2})
396
vel = velocity(u, equations)
397
v = vel[1] * normal_direction[1] + vel[2] * normal_direction[2]
398
return v
399
end
400
401
@inline function velocity(u, normal_direction::AbstractVector,
402
equations::AbstractEquations{3})
403
vel = velocity(u, equations)
404
v = vel[1] * normal_direction[1] + vel[2] * normal_direction[2] +
405
vel[3] * normal_direction[3]
406
return v
407
end
408
409
"""
410
entropy(u, equations)
411
412
Return the chosen entropy of the conserved variables `u` for a given set of
413
`equations`.
414
415
`u` is a vector of the conserved variables at a single node, i.e., a vector
416
of the correct length `nvariables(equations)`.
417
"""
418
function entropy end
419
420
"""
421
cons2entropy(u, equations)
422
423
Convert the conserved variables `u` to the entropy variables for a given set of
424
`equations` with chosen standard [`entropy`](@ref).
425
426
`u` is a vector type of the correct length `nvariables(equations)`.
427
Notice the function doesn't include any error checks for the purpose of efficiency,
428
so please make sure your input is correct.
429
The inverse conversion is performed by [`entropy2cons`](@ref).
430
"""
431
function cons2entropy end
432
433
"""
434
entropy2cons(w, equations)
435
436
Convert the entropy variables `w` based on a standard [`entropy`](@ref) to the
437
conserved variables for a given set of `equations`.
438
`u` is a vector type of the correct length `nvariables(equations)`.
439
Notice the function doesn't include any error checks for the purpose of efficiency,
440
so please make sure your input is correct.
441
The inverse conversion is performed by [`cons2entropy`](@ref).
442
"""
443
function entropy2cons end
444
445
"""
446
energy_total(u, equations)
447
448
Return the total energy of the conserved variables `u` for a given set of
449
`equations`, e.g., the [`CompressibleEulerEquations2D`](@ref).
450
451
`u` is a vector of the conserved variables at a single node, i.e., a vector
452
of the correct length `nvariables(equations)`.
453
"""
454
function energy_total end
455
456
"""
457
energy_kinetic(u, equations)
458
459
Return the kinetic energy of the conserved variables `u` for a given set of
460
`equations`, e.g., the [`CompressibleEulerEquations2D`](@ref).
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 energy_kinetic end
466
467
"""
468
energy_internal(u, equations)
469
470
Return the internal energy of the conserved variables `u` for a given set of
471
`equations`, e.g., the [`CompressibleEulerEquations2D`](@ref).
472
473
`u` is a vector of the conserved variables at a single node, i.e., a vector
474
of the correct length `nvariables(equations)`.
475
"""
476
function energy_internal end
477
478
"""
479
density(u, equations)
480
481
Return the density associated to the conserved variables `u` for a given set of
482
`equations`, e.g., the [`CompressibleEulerEquations2D`](@ref).
483
484
`u` is a vector of the conserved variables at a single node, i.e., a vector
485
of the correct length `nvariables(equations)`.
486
"""
487
function density end
488
489
"""
490
pressure(u, equations)
491
492
Return the pressure associated to the conserved variables `u` for a given set of
493
`equations`, e.g., the [`CompressibleEulerEquations2D`](@ref).
494
495
`u` is a vector of the conserved variables at a single node, i.e., a vector
496
of the correct length `nvariables(equations)`.
497
"""
498
function pressure end
499
500
"""
501
density_pressure(u, equations)
502
503
Return the product of the [`density`](@ref) and the [`pressure`](@ref)
504
associated to the conserved variables `u` for a given set of
505
`equations`, e.g., the [`CompressibleEulerEquations2D`](@ref).
506
This can be useful, e.g., as a variable for (shock-cappturing or AMR)
507
indicators.
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 density_pressure end
513
514
"""
515
waterheight(u, equations)
516
517
Return the water height associated to the conserved variables `u` for a given set of
518
`equations`.
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
!!! note
524
This function is defined in Trixi.jl to have a common interface for the
525
methods implemented in the subpackages [TrixiAtmo.jl](https://github.com/trixi-framework/TrixiAtmo.jl)
526
and [TrixiShallowWater.jl](https://github.com/trixi-framework/TrixiShallowWater.jl).
527
"""
528
function waterheight end
529
530
"""
531
waterheight_pressure(u, equations)
532
533
Return the product of the [`waterheight`](@ref) and the [`pressure`](@ref)
534
associated to the conserved variables `u` for a given set of
535
`equations`.
536
537
`u` is a vector of the conserved variables at a single node, i.e., a vector
538
of the correct length `nvariables(equations)`.
539
540
!!! note
541
This function is defined in Trixi.jl to have a common interface for the
542
methods implemented in the subpackages [TrixiAtmo.jl](https://github.com/trixi-framework/TrixiAtmo.jl)
543
and [TrixiShallowWater.jl](https://github.com/trixi-framework/TrixiShallowWater.jl).
544
"""
545
function waterheight_pressure end
546
547
"""
548
lake_at_rest_error(u, equations)
549
550
Calculate the point-wise error for the lake-at-rest steady state solution.
551
552
!!! note
553
This function is defined in Trixi.jl to have a common interface for the
554
methods implemented in the subpackages [TrixiAtmo.jl](https://github.com/trixi-framework/TrixiAtmo.jl)
555
and [TrixiShallowWater.jl](https://github.com/trixi-framework/TrixiShallowWater.jl).
556
"""
557
function lake_at_rest_error end
558
559
# Default implementation of gradient for `variable`. Used for subcell limiting.
560
# Implementing a gradient function for a specific variable improves the performance.
561
@inline function gradient_conservative(variable, u, equations)
562
return ForwardDiff.gradient(x -> variable(x, equations), u)
563
end
564
565
####################################################################################################
566
# Include files with actual implementations for different systems of equations.
567
568
# Numerical flux formulations that are independent of the specific system of equations
569
include("numerical_fluxes.jl")
570
571
# Linear scalar advection
572
abstract type AbstractLinearScalarAdvectionEquation{NDIMS} <:
573
AbstractEquations{NDIMS, 1} end
574
include("linear_scalar_advection_1d.jl")
575
include("linear_scalar_advection_2d.jl")
576
include("linear_scalar_advection_3d.jl")
577
578
# Inviscid Burgers
579
abstract type AbstractInviscidBurgersEquation{NDIMS, NVARS} <:
580
AbstractEquations{NDIMS, NVARS} end
581
include("inviscid_burgers_1d.jl")
582
583
# Shallow water equations
584
abstract type AbstractShallowWaterEquations{NDIMS, NVARS} <:
585
AbstractEquations{NDIMS, NVARS} end
586
587
# CompressibleEulerEquations
588
abstract type AbstractCompressibleEulerEquations{NDIMS, NVARS} <:
589
AbstractEquations{NDIMS, NVARS} end
590
include("compressible_euler_1d.jl")
591
include("compressible_euler_2d.jl")
592
include("compressible_euler_3d.jl")
593
include("compressible_euler_quasi_1d.jl")
594
595
# CompressibleEulerMulticomponentEquations
596
abstract type AbstractCompressibleEulerMulticomponentEquations{NDIMS, NVARS, NCOMP} <:
597
AbstractEquations{NDIMS, NVARS} end
598
include("compressible_euler_multicomponent_1d.jl")
599
include("compressible_euler_multicomponent_2d.jl")
600
601
# PolytropicEulerEquations
602
abstract type AbstractPolytropicEulerEquations{NDIMS, NVARS} <:
603
AbstractEquations{NDIMS, NVARS} end
604
include("polytropic_euler_2d.jl")
605
606
# Passive tracer equations
607
include("passive_tracers.jl")
608
609
# Retrieve number of components from equation instance for the multicomponent case
610
@inline function ncomponents(::AbstractCompressibleEulerMulticomponentEquations{NDIMS,
611
NVARS,
612
NCOMP}) where {
613
NDIMS,
614
NVARS,
615
NCOMP
616
}
617
NCOMP
618
end
619
"""
620
eachcomponent(equations::AbstractCompressibleEulerMulticomponentEquations)
621
622
Return an iterator over the indices that specify the location in relevant data structures
623
for the components in `AbstractCompressibleEulerMulticomponentEquations`.
624
In particular, not the components themselves are returned.
625
"""
626
@inline function eachcomponent(equations::AbstractCompressibleEulerMulticomponentEquations)
627
Base.OneTo(ncomponents(equations))
628
end
629
630
# Ideal MHD
631
abstract type AbstractIdealGlmMhdEquations{NDIMS, NVARS} <:
632
AbstractEquations{NDIMS, NVARS} end
633
include("ideal_glm_mhd_1d.jl")
634
include("ideal_glm_mhd_2d.jl")
635
include("ideal_glm_mhd_3d.jl")
636
637
# IdealGlmMhdMulticomponentEquations
638
abstract type AbstractIdealGlmMhdMulticomponentEquations{NDIMS, NVARS, NCOMP} <:
639
AbstractEquations{NDIMS, NVARS} end
640
include("ideal_glm_mhd_multicomponent_1d.jl")
641
include("ideal_glm_mhd_multicomponent_2d.jl")
642
643
# IdealMhdMultiIonEquations
644
abstract type AbstractIdealGlmMhdMultiIonEquations{NDIMS, NVARS, NCOMP} <:
645
AbstractEquations{NDIMS, NVARS} end
646
include("ideal_glm_mhd_multiion.jl")
647
include("ideal_glm_mhd_multiion_2d.jl")
648
include("ideal_glm_mhd_multiion_3d.jl")
649
650
# Retrieve number of components from equation instance for the multicomponent case
651
@inline function ncomponents(::AbstractIdealGlmMhdMulticomponentEquations{NDIMS, NVARS,
652
NCOMP}) where {
653
NDIMS,
654
NVARS,
655
NCOMP
656
}
657
NCOMP
658
end
659
"""
660
eachcomponent(equations::AbstractIdealGlmMhdMulticomponentEquations)
661
662
Return an iterator over the indices that specify the location in relevant data structures
663
for the components in `AbstractIdealGlmMhdMulticomponentEquations`.
664
In particular, not the components themselves are returned.
665
"""
666
@inline function eachcomponent(equations::AbstractIdealGlmMhdMulticomponentEquations)
667
Base.OneTo(ncomponents(equations))
668
end
669
670
# Retrieve number of components from equation instance for the multi-ion case
671
@inline function ncomponents(::AbstractIdealGlmMhdMultiIonEquations{NDIMS, NVARS,
672
NCOMP}) where {
673
NDIMS,
674
NVARS,
675
NCOMP
676
}
677
NCOMP
678
end
679
680
"""
681
eachcomponent(equations::AbstractIdealGlmMhdMultiIonEquations)
682
683
Return an iterator over the indices that specify the location in relevant data structures
684
for the components in `AbstractIdealGlmMhdMultiIonEquations`.
685
In particular, not the components themselves are returned.
686
"""
687
@inline function eachcomponent(equations::AbstractIdealGlmMhdMultiIonEquations)
688
Base.OneTo(ncomponents(equations))
689
end
690
691
# Diffusion equation: first order hyperbolic system
692
abstract type AbstractHyperbolicDiffusionEquations{NDIMS, NVARS} <:
693
AbstractEquations{NDIMS, NVARS} end
694
include("hyperbolic_diffusion_1d.jl")
695
include("hyperbolic_diffusion_2d.jl")
696
include("hyperbolic_diffusion_3d.jl")
697
698
# Lattice-Boltzmann equation (advection part only)
699
abstract type AbstractLatticeBoltzmannEquations{NDIMS, NVARS} <:
700
AbstractEquations{NDIMS, NVARS} end
701
include("lattice_boltzmann_2d.jl")
702
include("lattice_boltzmann_3d.jl")
703
704
# Acoustic perturbation equations
705
abstract type AbstractAcousticPerturbationEquations{NDIMS, NVARS} <:
706
AbstractEquations{NDIMS, NVARS} end
707
include("acoustic_perturbation_2d.jl")
708
709
# Linearized Euler equations
710
abstract type AbstractLinearizedEulerEquations{NDIMS, NVARS} <:
711
AbstractEquations{NDIMS, NVARS} end
712
include("linearized_euler_1d.jl")
713
include("linearized_euler_2d.jl")
714
include("linearized_euler_3d.jl")
715
716
abstract type AbstractEquationsParabolic{NDIMS, NVARS, GradientVariables} <:
717
AbstractEquations{NDIMS, NVARS} end
718
719
# Lighthill-Witham-Richards (LWR) traffic flow model
720
abstract type AbstractTrafficFlowLWREquations{NDIMS, NVARS} <:
721
AbstractEquations{NDIMS, NVARS} end
722
include("traffic_flow_lwr_1d.jl")
723
724
abstract type AbstractMaxwellEquations{NDIMS, NVARS} <:
725
AbstractEquations{NDIMS, NVARS} end
726
include("maxwell_1d.jl")
727
end # @muladd
728
729