Skip to content
Snippets Groups Projects
Commit b324a876 authored by Florian Atteneder's avatar Florian Atteneder
Browse files

add dispatch for av regularization in rhs!; wip implementation of new regularizations

parent c1d0a1a2
No related branches found
No related tags found
1 merge request!71Implement regularizations for Euler eq
This commit is part of merge request !71. Comments created here will be created in the context of that merge request.
......@@ -448,3 +448,71 @@ end
@returns nflx_rho, nflx_qx, nflx_qy, nflx_E
end
# TODO Rename all methods accordingly
const mono_ldg_nflux = ldg_nflux
const mono_ldg_bdryllf = ldg_bdryllf
const mono_av_flux = av_flux
const mono_av_nflux = av_nflux
const mono_bdryllf = bdryllf
#######################################################################
# Navier-Stokes regularization #
#######################################################################
@with_signature [legacy=false] function navierstokes_u(equation::EulerEquation)
@accepts rho, q
u = q/rho
@returns u
end
@with_signature [legacy=false] function navierstokes_ldg_nflux(eq::EulerEquation)
@accepts u
@accepts [bdry] bdry_u
@accepts [bdry] nx
nflx_u = 0.5 * nx * (u + bdry_u)
@returns [bdry] nflx_u
end
@with_signature [legacy=false] function navierstokes_ldg_bdryllf(eq::EulerEquation)
@accepts u
@accepts [bdry] nx
# set exterior state to 0 according to stability analysis
# see dg-notes/tex/evm.pdf for reasoning
nflx_u = nx * u
@returns [bdry] nflx_u
end
@with_signature [legacy=false] function navierstokes_av_flux(eq::EulerEquation)
@accepts flx_q, flx_E, ldg_u, u, smoothed_mu
# μ = λ, κ = 0
G = 4 * smoothed_mu * ldg_u + smoothed_mu * ldg_u
flx_q += G
flx_E += G * u
@returns flx_q, flx_E
end
@with_signature [legacy=false] function navierstokes_av_nflux(eq::EulerEquation)
@accepts ldg_u, u, smoothed_mu
@accepts [bdry] bdry_ldg_u, bdry_u, bdry_smoothed_mu
@accepts [bdry] nflx_q, nflx_E, nx
G = 4 * smoothed_mu * ldg_u + smoothed_mu * ldg_u
bdry_G = 4 * bdry_smoothed_mu * bdry_ldg_u + bdry_smoothed_mu * bdry_ldg_u
nflx = nx*G
bdry_nflx = nx*bdry_G
nflx_q += 0.5 * (nflx + bdry_nflx)
nflx = nx*G*u
bdry_nflx = nx*bdry_G*bdry_u
nflx_E += 0.5 * (nflx + bdry_nflx)
@returns [bdry] nflx_q, nflx_E
end
......@@ -213,20 +213,33 @@ function rhs!(env, P::Project, hrsc::HRSC.AbstractArtificialViscosity, ::Mesh1d,
bdryconds, ldg_bdryconds, av_bdryconds)
@unpack cache, mesh = env
@unpack equation = P
@unpack equation, prms = P
reg = prms.av_regularization
if reg === :mono
rhs_mono!(cache, mesh, equation)
elseif reg === :navierstokes
rhs_navierstokes!(cache, mesh, equation)
elseif reg === :general
rhs_general!(cache, mesh, equation)
else
TODO(reg)
end
end
@unpack rho, q, E = get_dynamic_variables(cache)
function rhs_mono!(cache, mesh, equation)
@unpack rho, q, E = get_dynamic_variables(cache)
@unpack flx_rho, flx_q, flx_E, p, eps,
ldg_rho, ldg_q, ldg_E,
flx_ldg_rho, flx_ldg_q, flx_ldg_E = get_static_variables(cache)
@unpack rhs_rho, rhs_q, rhs_E = get_rhs_variables(cache)
@unpack nflx_rho, nflx_q, nflx_E,
nflx_ldg_rho, nflx_ldg_q, nflx_ldg_E = get_bdry_variables(cache)
ldg_rho, ldg_q, ldg_E = get_static_variables(cache)
@unpack rhs_rho, rhs_q, rhs_E = get_rhs_variables(cache)
@unpack nflx_rho, nflx_q, nflx_E = get_bdry_variables(cache)
@unpack bdry_rho, bdry_q, bdry_E,
bdry_v,
bdry_ldg_rho, bdry_ldg_q, bdry_ldg_E,
bdry_smoothed_mu = get_bdry_variables(mesh.cache)
@unpack v, smoothed_mu = get_static_variables(mesh.cache)
bdry_smoothed_mu = get_bdry_variables(mesh.cache)
@unpack v, smoothed_mu = get_static_variables(mesh.cache)
dg1d.interpolate_face_data!(mesh, rho, bdry_rho)
dg1d.interpolate_face_data!(mesh, q, bdry_q)
......@@ -234,8 +247,8 @@ function rhs!(env, P::Project, hrsc::HRSC.AbstractArtificialViscosity, ::Mesh1d,
dg1d.interpolate_face_data!(mesh, v, bdry_v)
## solve auxiliary equation: q + ∂x u = 0
dg1d.new_broadcast_faces!(ldg_nflux, equation, mesh)
dg1d.new_broadcast_bdry!(ldg_bdryllf, equation, mesh)
dg1d.new_broadcast_faces!(mono_ldg_nflux, equation, mesh)
dg1d.new_broadcast_bdry!(mono_ldg_bdryllf, equation, mesh)
compute_rhs_weak_form!(ldg_rho, rho, nflx_rho, mesh)
compute_rhs_weak_form!(ldg_q, q, nflx_q, mesh)
compute_rhs_weak_form!(ldg_E, E, nflx_E, mesh)
......@@ -249,8 +262,51 @@ function rhs!(env, P::Project, hrsc::HRSC.AbstractArtificialViscosity, ::Mesh1d,
dg1d.interpolate_face_data!(mesh, ldg_E, bdry_ldg_E)
dg1d.interpolate_face_data!(mesh, smoothed_mu, bdry_smoothed_mu)
dg1d.new_broadcast_volume!(av_flux, equation, mesh)
dg1d.new_broadcast_faces!(av_nflux, equation, mesh)
dg1d.new_broadcast_volume!(mono_av_flux, equation, mesh)
dg1d.new_broadcast_faces!(mono_av_nflux, equation, mesh)
dg1d.new_broadcast_bdry!(mono_bdryllf, equation, mesh)
# TODO don't we also need av_bdrylff here?
compute_rhs_weak_form!(rhs_rho, flx_rho, nflx_rho, mesh)
compute_rhs_weak_form!(rhs_q, flx_q, nflx_q, mesh)
compute_rhs_weak_form!(rhs_E, flx_E, nflx_E, mesh)
return
end
function rhs_navierstokes!(cache, mesh, equation)
@unpack rho, q, E = get_dynamic_variables(cache)
@unpack flx_rho, flx_q, flx_E, u,
ldg_u = get_static_variables(cache)
@unpack rhs_rho, rhs_q, rhs_E = get_rhs_variables(cache)
@unpack nflx_rho, nflx_q, nflx_E, nflx_u = get_bdry_variables(cache)
@unpack bdry_rho, bdry_q, bdry_E,
bdry_v, bdry_u,
bdry_ldg_u,
bdry_smoothed_mu = get_bdry_variables(mesh.cache)
@unpack v, smoothed_mu = get_static_variables(mesh.cache)
dg1d.new_broadcast_volume!(navierstokes_u, equation, mesh)
dg1d.interpolate_face_data!(mesh, rho, bdry_rho)
dg1d.interpolate_face_data!(mesh, q, bdry_q)
dg1d.interpolate_face_data!(mesh, E, bdry_E)
dg1d.interpolate_face_data!(mesh, v, bdry_v)
dg1d.interpolate_face_data!(mesh, u, bdry_u)
## solve auxiliary equation: q + ∂x u = 0
dg1d.new_broadcast_faces!(navierstokes_ldg_nflux, equation, mesh)
dg1d.new_broadcast_bdry!(navierstokes_ldg_bdryllf, equation, mesh)
compute_rhs_weak_form!(ldg_u, u, nflx_u, mesh)
## compute rhs of regularized equation: ∂t u + ∂x f + ∂x μ q = 0
dg1d.new_broadcast_volume!(flux, equation, mesh)
dg1d.new_broadcast_faces!(llf, equation, mesh)
dg1d.interpolate_face_data!(mesh, ldg_u, bdry_ldg_u)
dg1d.interpolate_face_data!(mesh, smoothed_mu, bdry_smoothed_mu)
dg1d.new_broadcast_volume!(navierstokes_av_flux, equation, mesh)
dg1d.new_broadcast_faces!(navierstokes_av_nflux, equation, mesh)
dg1d.new_broadcast_bdry!(bdryllf, equation, mesh)
# TODO don't we also need av_bdrylff here?
......@@ -260,6 +316,56 @@ function rhs!(env, P::Project, hrsc::HRSC.AbstractArtificialViscosity, ::Mesh1d,
return
end
function rhs_general!(cache, mesh, equation)
TODO()
@unpack rho, q, E = get_dynamic_variables(cache)
@unpack flx_rho, flx_q, flx_E, p, eps,
ldg_rho, ldg_rhoe, ldg_u,
flx_ldg_rho, flx_ldg_q, flx_ldg_E = get_static_variables(cache)
@unpack rhs_rho, rhs_q, rhs_E = get_rhs_variables(cache)
@unpack nflx_rho, nflx_q, nflx_E,
nflx_ldg_rho, nflx_ldg_q, nflx_ldg_E = get_bdry_variables(cache)
@unpack bdry_rho, bdry_q, bdry_E,
bdry_v,
bdry_ldg_rho, bdry_ldg_rhoe, bdry_ldg_u,
bdry_smoothed_mu = get_bdry_variables(mesh.cache)
@unpack v, smoothed_mu = get_static_variables(mesh.cache)
dg1d.new_broadcast_volume!(mono_rhoeps, equation, mesh)
dg1d.interpolate_face_data!(mesh, rho, bdry_rho)
dg1d.interpolate_face_data!(mesh, rhoeps, bdry_rhoeps)
dg1d.interpolate_face_data!(mesh, u, bdry_u)
dg1d.interpolate_face_data!(mesh, v, bdry_v)
## solve auxiliary equation: q + ∂x u = 0
dg1d.new_broadcast_faces!(general_ldg_nflux, equation, mesh)
dg1d.new_broadcast_bdry!(general_ldg_bdryllf, equation, mesh)
compute_rhs_weak_form!(ldg_rho, rho, nflx_rho, mesh)
compute_rhs_weak_form!(ldg_q, rhoeps, nflx_rhoeps, mesh)
compute_rhs_weak_form!(ldg_E, u, nflx_u, mesh)
## compute rhs of regularized equation: ∂t u + ∂x f + ∂x μ q = 0
dg1d.new_broadcast_volume!(flux, equation, mesh)
dg1d.new_broadcast_faces!(llf, equation, mesh)
dg1d.interpolate_face_data!(mesh, ldg_rho, bdry_ldg_rho)
dg1d.interpolate_face_data!(mesh, ldg_rhoeps, bdry_ldg_rhoeps)
dg1d.interpolate_face_data!(mesh, ldg_u, bdry_ldg_u)
dg1d.interpolate_face_data!(mesh, smoothed_mu, bdry_smoothed_mu)
dg1d.new_broadcast_volume!(general_av_flux, equation, mesh)
dg1d.new_broadcast_faces!(general_av_nflux, equation, mesh)
dg1d.new_broadcast_bdry!(general_bdryllf, equation, mesh)
# TODO don't we also need av_bdrylff here?
compute_rhs_weak_form!(rhs_rho, flx_rho, nflx_rho, mesh)
compute_rhs_weak_form!(rhs_q, flx_q, nflx_q, mesh)
compute_rhs_weak_form!(rhs_E, flx_E, nflx_E, mesh)
return
end
function rhs!(env, P::Project2d, hrsc::HRSC.AbstractArtificialViscosity, mesh::Mesh2d,
......
......@@ -19,6 +19,8 @@ function Project(env::Environment, mesh::Mesh1d, prms)
@unpack cache = env
_register_variables!(mesh, P)
_register_variables!(mesh, bdrycond)
_register_variables!(mesh, P.hrsc, prms["EulerEq"]["av_regularization"])
_register_variables!(mesh, P.tci)
display(cache)
# setup initial data
......@@ -100,32 +102,45 @@ function _register_variables!(mesh, P::Project)
:bdry_rho, :bdry_q, :bdry_E, :bdry_v),
global_variablenames = (:t, :tm1) # recent time stamps
)
_register_variables!(mesh, P.hrsc)
_register_variables!(mesh, P.tci)
end
_register_variables!(mesh, tci_or_hrsc::Nothing) = nothing
_register_variables!(mesh, tci_or_hrsc::Nothing, args...) = nothing
_register_variables!(mesh, hrsc::AbstractReconstruction) = nothing
function _register_variables!(mesh, hrsc::HRSC.AbstractArtificialViscosity)
function _register_variables!(mesh, hrsc::HRSC.AbstractArtificialViscosity, regularization)
register_variables!(mesh.cache,
static_variablenames = (:ldg_rho, :ldg_q, :ldg_E, # local DG variable
:flx_ldg_rho, :flx_ldg_q, :flx_ldg_E), # local DG flux
bdry_variablenames = (:nflx_ldg_rho, :nflx_ldg_q, :nflx_ldg_E), # local DG flux
cell_variablenames = (:mu,) # 'one viscosity to rule them all'
cell_variablenames = (:mu,) # 'one viscosity to rule them all'
)
if regularization == "mono"
register_variables!(mesh.cache,
static_variablenames = (:ldg_rho, :ldg_q, :ldg_E,),
bdry_variablenames = (:nflx_ldg_rho, :nflx_ldg_q, :nflx_ldg_E,
:bdry_ldg_rho, :bdry_ldg_q, :bdry_ldg_E),
)
elseif regularization == "navierstokes"
register_variables!(mesh.cache,
static_variablenames = (:ldg_u, :u),
bdry_variablenames = (:bdry_ldg_u, :bdry_u, :nflx_u),
)
elseif regularization == "general"
TODO()
register_variables!(mesh.cache,
static_variablenames = (:ldg_rho, :ldg_q, :ldg_E, # local DG variable
:flx_ldg_rho, :flx_ldg_q, :flx_ldg_E), # local DG flux
bdry_variablenames = (:nflx_ldg_rho, :nflx_ldg_q, :nflx_ldg_E), # local DG flux
)
end
end
function _register_variables!(mesh::Mesh, hrsc::HRSC.SmoothedArtificialViscosity)
_register_variables!(mesh, hrsc.av)
function _register_variables!(mesh::Mesh, hrsc::HRSC.SmoothedArtificialViscosity, regularization)
_register_variables!(mesh, hrsc.av, regularization)
register_variables!(mesh.cache,
static_variablenames = (:smoothed_mu,),
bdry_variablenames = (:bdry_smoothed_mu,
:bdry_ldg_rho, :bdry_ldg_q, :bdry_ldg_E),
bdry_variablenames = (:bdry_smoothed_mu,)
)
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment