DG Balance Law Method
The balance law
ClimateMachine.DGmethods.BalanceLaw
— TypeBalanceLaw
An abstract type representing a PDE balance law of the form
elements for balance laws of the form
Subtypes L
should define the methods below
Continuous Balance Law Formulation
to be filled
Discontinuous Galerkin Method Formulation
to be filled
Examples
The style of examples we use here is heavily inspired by JuAFEM.jl
to be filled
Variable specification methods
ClimateMachine.DGmethods.vars_state_conservative
— Functionvars_state_conservative(::L, FT)
a tuple of symbols containing the state variables given a float type FT
.
ClimateMachine.DGmethods.vars_state_auxiliary
— Functionvars_state_auxiliary(::L, FT)
a tuple of symbols containing the auxiliary variables given a float type FT
.
ClimateMachine.DGmethods.vars_state_gradient
— Functionvars_state_gradient(::L, FT)
a tuple of symbols containing the transformed variables of which gradients are computed given a float type FT
.
ClimateMachine.DGmethods.vars_integrals
— Functionvars_integrals(::L, FT)
a tuple of symbols containing variables to be integrated along a vertical stack, given a float type FT
.
vars_integrals(m::AtmosModel, FT)
vars_integral(::HBModel)
location to store integrands for bottom up integrals ∇hu = the horizontal divegence of u, e.g. dw/dz
ClimateMachine.DGmethods.vars_reverse_integrals
— Functionvars_reverse_integrals(::L, FT)
a tuple of symbols containing variables to be integrated along a vertical stack, in reverse, given a float type FT
.
vars_reverse_integrals(m::AtmosModel, FT)
vars_reverse_integral(::HBModel)
location to store integrands for top down integrals αᵀθ = density perturbation
ClimateMachine.DGmethods.vars_state_gradient_flux
— Functionvars_state_gradient_flux(::L, FT)
a tuple of symbols containing the diffusive variables given a float type FT
.
Initial condition methods
ClimateMachine.DGmethods.init_state_conservative!
— Functioninit_state_conservative!(
::L,
state_conservative::Vars,
state_auxiliary::Vars,
coords,
args...)
Initialize the conservative state variables at $t = 0$
init_state_conservative!(
m::AtmosModel,
state::Vars,
aux::Vars,
coords,
t,
args...)
Initialise state variables. args...
provides an option to include configuration data (current use cases include problem constants, spline-interpolants)
ClimateMachine.DGmethods.init_state_auxiliary!
— Functioninit_state_auxiliary!(
::L,
state_auxiliary::Vars,
coords,
args...)
Initialize the auxiliary state, at $t = 0$
init_state_auxiliary!(
m::AtmosModel,
aux::Vars,
geom::LocalGeometry
)
Initialise auxiliary variables for each AtmosModel subcomponent. Store Cartesian coordinate information in aux.coord
.
No need to init, initialize by full model
Source term kernels
ClimateMachine.DGmethods.flux_first_order!
— Functionflux_first_order!(
::L,
flux::Grad,
state_conservative::Vars,
state_auxiliary::Vars,
t::Real
)
Compute first-order flux terms in balance law equation
flux_first_order!(
m::AtmosModel,
flux::Grad,
state::Vars,
aux::Vars,
t::Real
)
Computes and assembles non-diffusive fluxes in the model equations.
flux_first_order!(::HBModel)
calculates the hyperbolic flux contribution to state variables this computation is done pointwise at each nodal point
arguments:
m -> model in this case HBModel F -> array of fluxes for each state variable Q -> array of state variables A -> array of aux variables t -> time, not used
computations
∂ᵗu = ∇⋅(g*η + g∫αᵀθdz + v⋅u) ∂ᵗθ = ∇⋅(vθ) where v = (u,v,w)
ClimateMachine.DGmethods.flux_second_order!
— Functionflux_second_order!(
::L,
flux::Grad,
state_conservative::Vars,
state_gradient_flux::Vars,
hyperdiffusive::Vars,
state_auxiliary::Vars,
t::Real
)
Compute second-order flux terms in balance law equation
flux_second_order!(
atmos::AtmosModel,
flux::Grad,
state::Vars,
diffusive::Vars,
hyperdiffusive::Vars,
aux::Vars,
t::Real
)
Diffusive fluxes in AtmosModel. Viscosity, diffusivity are calculated in the turbulence subcomponent and accessed within the diffusive flux function. Contributions from subcomponents are then assembled (pointwise).
flux_second_order!(::HBModel)
calculates the parabolic flux contribution to state variables this computation is done pointwise at each nodal point
arguments:
m
: model in this case HBModelF
: array of fluxes for each state variableQ
: array of state variablesD
: array of diff variablesA
: array of aux variablest
: time, not used
computations
∂ᵗu = -∇⋅(ν∇u) ∂ᵗθ = -∇⋅(κ∇θ)
flux_second_order!(::HBModel)
calculates the parabolic flux contribution to state variables this computation is done pointwise at each nodal point
arguments:
m
: model in this case HBModelF
: array of fluxes for each state variableQ
: array of state variablesD
: array of diff variablesA
: array of aux variablest
: time, not used
computations
∂ᵗu = -∇⋅(ν∇u) ∂ᵗθ = -∇⋅(κ∇θ)
ClimateMachine.DGmethods.source!
— Functionsource!(
::L,
source::Vars,
state_conservative::Vars,
diffusive::Vars,
state_auxiliary::Vars,
t::Real
)
Compute non-conservative source terms in balance law equation
source!(
m::AtmosModel,
source::Vars,
state::Vars,
diffusive::Vars,
aux::Vars,
t::Real,
direction::Direction
)
Computes (and assembles) source terms S(Y)
in:
∂Y
-- = - ∇ • F + S(Y)
∂t
source!(::HBModel)
calculates the source term contribution to state variables
this computation is done pointwise at each nodal point
arguments:
m -> model in this case HBModel
F -> array of fluxes for each state variable
Q -> array of state variables
A -> array of aux variables
t -> time, not used
computations
∂ᵗu = -f×u
∂ᵗη = w|(z=0)
Integral kernels
ClimateMachine.DGmethods.integral_load_auxiliary_state!
— Functionintegral_load_auxiliary_state!
Specify how to compute integrands. Can be functions of the conservative state and auxiliary variables.
ClimateMachine.DGmethods.integral_set_auxiliary_state!
— Functionintegral_set_auxiliary_state!
Specify which auxiliary variables are used to store the output of the integrals.
ClimateMachine.DGmethods.reverse_integral_load_auxiliary_state!
— Functionreverse_integral_load_auxiliary_state!
Specify auxiliary variables need their integrals reversed.
ClimateMachine.DGmethods.reverse_integral_set_auxiliary_state!
— Functionreverse_integral_set_auxiliary_state!
Specify which auxiliary variables are used to store the output of the reversed integrals.
Gradient/Laplacian kernels
ClimateMachine.DGmethods.compute_gradient_flux!
— Functioncompute_gradient_flux!(
::L,
state_gradient_flux::Vars,
∇transformstate::Grad,
state_auxiliary::Vars,
t::Real
)
transformation of gradients to the diffusive variables
compute_gradient_flux!(::TurbulenceClosure, _...)
Post-gradient-transformed variables specific to turbulence models.
compute_gradient_flux!(::HBModel)
copy ∇u and ∇θ to var_diffusive this computation is done pointwise at each nodal point
arguments:
m
: model in this case HBModelD
: array of diffusive variablesG
: array of gradient variablesQ
: array of state variablesA
: array of aux variablest
: time, not used
compute_gradient_flux!(::LinearHBModel)
copy ν∇u and κ∇θ to var_diffusive this computation is done pointwise at each nodal point
arguments:
m
: model in this case HBModelD
: array of diffusive variablesG
: array of gradient variablesQ
: array of state variablesA
: array of aux variablest
: time, not used
ClimateMachine.DGmethods.compute_gradient_argument!
— Functioncompute_gradient_argument!(
::L,
transformstate::Vars,
state_conservative::Vars,
state_auxiliary::Vars,
t::Real
)
transformation of state variables to variables of which gradients are computed
compute_gradient_argument!
Assign pre-gradient-transform variables specific to turbulence models.
compute_gradient_argument!(::HBModel)
copy u and θ to var_gradient this computation is done pointwise at each nodal point
arguments:
m
: model in this case HBModelG
: array of gradient variablesQ
: array of state variablesA
: array of aux variablest
: time, not used
compute_gradient_argument!(::LinearHBModel)
copy u and θ to var_gradient this computation is done pointwise at each nodal point
arguments:
m
: model in this case HBModelG
: array of gradient variablesQ
: array of state variablesA
: array of aux variablest
: time, not used
ClimateMachine.DGmethods.transform_post_gradient_laplacian!
— Functiontransform_post_gradient_laplacian!(
::L,
Qhypervisc_div::Vars,
∇Δtransformstate::Grad,
state_auxiliary::Vars,
t::Real
)
transformation of laplacian gradients to the hyperdiffusive variables
Auxiliary kernels
ClimateMachine.DGmethods.wavespeed
— Functionwavespeed(
::L,
n⁻,
state_conservative::Vars,
state_auxiliary::Vars,
t::Real
)
wavespeed
ClimateMachine.DGmethods.boundary_state!
— Functionboundary_state!(
::NumericalFluxGradient,
::L,
state_conservative⁺::Vars,
state_auxiliary⁺::Vars,
normal⁻,
state_conservative⁻::Vars,
state_auxiliary⁻::Vars,
bctype,
t
)
boundary_state!(
::NumericalFluxFirstOrder,
::L,
state_conservative⁺::Vars,
state_auxiliary⁺::Vars,
normal⁻,
state_conservative⁻::Vars,
state_auxiliary⁻::Vars,
bctype,
t
)
boundary_state!(
::NumericalFluxSecondOrder,
::L,
state_conservative⁺::Vars,
state_gradient_flux⁺::Vars,
state_auxiliary⁺:
Vars, normal⁻,
state_conservative⁻::Vars,
state_gradient_flux⁻::Vars,
state_auxiliary⁻::Vars,
bctype,
t
)
Apply boundary conditions for
NumericalFluxGradient
numerical flux (internal method)NumericalFluxFirstOrder
first-order unknownsNumericalFluxSecondOrder
second-order unknowns
ClimateMachine.DGmethods.update_auxiliary_state!
— Functionupdate_auxiliary_state!(
dg::DGModel,
m::HBModel,
Q::MPIStateArray,
t::Real,
elems::UnitRange,
)
Update the auxiliary state variables
ClimateMachine.DGmethods.update_auxiliary_state_gradient!
— Functionupdate_auxiliary_state_gradient!
Update the auxiliary state gradient variables