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

ScalarEq: Implement modal Bspline1 DG evolution...

ScalarEq: Implement modal Bspline1 DG evolution (!216)

Similar to !213

Same caveats apply, e.g. no HRSC working etc.
parent cb7c756e
No related branches found
No related tags found
1 merge request!216ScalarEq: Implement modal Bspline1 DG evolution
Pipeline #7213 passed
...@@ -268,7 +268,7 @@ end ...@@ -268,7 +268,7 @@ end
function rhs!(env, mesh::Mesh1d, P::Project, hrsc::Nothing) function rhs!(env, mesh::Mesh1d, P::Project, hrsc::Nothing)
if mesh.element.kind === :modal_bspline2 if mesh.element.kind (:modal_bspline2, :modal_bspline1)
modal_rhs!(env, mesh, P, hrsc) modal_rhs!(env, mesh, P, hrsc)
else else
nodal_rhs!(env, mesh, P, hrsc) nodal_rhs!(env, mesh, P, hrsc)
......
...@@ -14,8 +14,12 @@ function Project(env::Environment, mesh::Mesh1d, prms) ...@@ -14,8 +14,12 @@ function Project(env::Environment, mesh::Mesh1d, prms)
analyze_error = prms["ScalarEq"]["analyze_error"] analyze_error = prms["ScalarEq"]["analyze_error"]
analyze_error_norm = prms["ScalarEq"]["analyze_error_norm"] analyze_error_norm = prms["ScalarEq"]["analyze_error_norm"]
V_bernstein = dg1d.Bernstein.vandermonde_matrix(mesh.element.z) V_bernstein = dg1d.Bernstein.vandermonde_matrix(mesh.element.z)
if mesh.element isa DGElement && mesh.element.kind === :modal_bspline2 if mesh.element isa DGElement && mesh.element.kind (:modal_bspline2, :modal_bspline1)
V_bspline = dg1d.Bspline.vandermonde_matrix(mesh.element.z, mesh.element.bs2) if mesh.element.kind === :modal_bspline2
V_bspline = dg1d.Bspline.vandermonde_matrix(mesh.element.z, mesh.element.bs2)
elseif mesh.element.kind === :modal_bspline1
V_bspline = dg1d.Bspline.vandermonde_matrix(mesh.element.z, mesh.element.bs1)
end
invV_bspline = pinv(V_bspline) invV_bspline = pinv(V_bspline)
else else
V_bspline, invV_bspline = nothing, nothing V_bspline, invV_bspline = nothing, nothing
...@@ -132,7 +136,7 @@ function register_equation!(mesh::Mesh1d, P::Project) ...@@ -132,7 +136,7 @@ function register_equation!(mesh::Mesh1d, P::Project)
TODO(P.prms.hrsc) TODO(P.prms.hrsc)
end end
end end
if mesh.element isa DGElement && mesh.element.kind === :modal_bspline2 if mesh.element isa DGElement && mesh.element.kind (:modal_bspline2, :modal_bspline1)
register_variables!(mesh.cache, static_variablenames=(:u_modal,:flx_u_modal,:src_u_modal)) register_variables!(mesh.cache, static_variablenames=(:u_modal,:flx_u_modal,:src_u_modal))
end end
end end
......
...@@ -362,7 +362,7 @@ function integrate(f::Function, idxs::AbstractVector{<:Integer}, bs::Bspline1) ...@@ -362,7 +362,7 @@ function integrate(f::Function, idxs::AbstractVector{<:Integer}, bs::Bspline1)
@toggled_assert length(idxs) == bs.Npts @toggled_assert length(idxs) == bs.Npts
sum = 0.0 sum = 0.0
@inbounds for i in bs.Npts @inbounds for i in bs.Npts
fi, xl, xr = f[idxs[i]], bs.xs[i], bs.xs[i+2] fi, xl, xr = f(idxs[i]), bs.xs[i], bs.xs[i+2]
sum += fi * (xr-xl)/2 sum += fi * (xr-xl)/2
end end
return sum return sum
......
...@@ -83,7 +83,7 @@ struct DGElement ...@@ -83,7 +83,7 @@ struct DGElement
purge_zeros!(quadr_z) purge_zeros!(quadr_z)
z = collect(range(-1.0,1.0,Npts)) z = collect(range(-1.0,1.0,Npts))
purge_zeros!(z) purge_zeros!(z)
D = [ Bernstein.derivative_bernstein_polynomial(z[i], j-1, N) for i in 1:Npts, j in 1:Npts ] D = [ Bernstein.derivative_bernstein_polynomial(z[i], j, N) for i in 1:Npts, j in 1:Npts ]
M = Bernstein.mass_matrix(Npts) M = Bernstein.mass_matrix(Npts)
S = Bernstein.stiffness_matrix(Npts) S = Bernstein.stiffness_matrix(Npts)
invM = inv(M) invM = inv(M)
...@@ -110,6 +110,7 @@ struct DGElement ...@@ -110,6 +110,7 @@ struct DGElement
# for which a 4th order accurate LG rule should suffice. # for which a 4th order accurate LG rule should suffice.
# We use a Gauss rule to avoid evaluating the Bspline on subcell interfaces and bdrys. # We use a Gauss rule to avoid evaluating the Bspline on subcell interfaces and bdrys.
quadr_z, quadr_w = LG.rule(3) quadr_z, quadr_w = LG.rule(3)
# TODO Derivatives at bspline control points is ill-defined, because the splines are C^0 there
D = [ Bspline.derivative_polynomial(z[i], j, bs1) for i in 1:Npts, j in 1:Npts ] D = [ Bspline.derivative_polynomial(z[i], j, bs1) for i in 1:Npts, j in 1:Npts ]
M = Bspline.mass_matrix(bs1) M = Bspline.mass_matrix(bs1)
S = Bspline.stiffness_matrix(bs1) S = Bspline.stiffness_matrix(bs1)
...@@ -210,8 +211,10 @@ end ...@@ -210,8 +211,10 @@ end
@inline function integrate(u::AbstractVector, el::DGElement) @inline function integrate(u::AbstractVector, el::DGElement)
if el.kind (:modal_bspline2, :modal_bspline1) if el.kind === :modal_bspline1
return Bspline.integrate(u, el.bs) return Bspline.integrate(u, el.bs1)
elseif el.kind === :modal_bspline2
return Bspline.integrate(u, el.bs2)
else else
if el.quadr === :lgl || el.quadr === :lgl_lumped if el.quadr === :lgl || el.quadr === :lgl_lumped
return LGL.integrate(u, el.quadr_z, el.quadr_w) return LGL.integrate(u, el.quadr_z, el.quadr_w)
...@@ -223,8 +226,10 @@ end ...@@ -223,8 +226,10 @@ end
@inline function integrate(fn::Function, idxs::AbstractVector{<:Integer}, el::DGElement) @inline function integrate(fn::Function, idxs::AbstractVector{<:Integer}, el::DGElement)
if el.kind (:modal_bspline2, :modal_bspline1) if el.kind === :modal_bspline1
return Bspline.integrate(fn, idxs, el.bs) return Bspline.integrate(fn, idxs, el.bs1)
elseif el.kind === :modal_bspline2
return Bspline.integrate(fn, idxs, el.bs2)
else else
if el.quadr === :lgl || el.quadr === :lgl_lumped if el.quadr === :lgl || el.quadr === :lgl_lumped
return LGL.integrate(fn, idxs, el.quadr_z, el.quadr_w) return LGL.integrate(fn, idxs, el.quadr_z, el.quadr_w)
......
[Evolution]
cfl = 0.5
tend = 2.2
[ScalarEq]
analyze_error = true
equation = "advection"
id = "sine"
[Output]
substep_every_iteration = 200
substep_variables = ["u", "u_err"]
aligned_ts = "$(collect(range(0.1,2.2,step=0.1)))"
variables1d = ["u", "u_err"]
[Mesh]
dg_kind = "modal_bspline1"
range = [0.0, 1.0]
k = 30
basis = "lgl"
n = 5
File added
File added
...@@ -10,6 +10,9 @@ variables1d = [ "u", "u_err" ] ...@@ -10,6 +10,9 @@ variables1d = [ "u", "u_err" ]
[modal_bernstein_advection_sine] [modal_bernstein_advection_sine]
variables1d = [ "u" ] variables1d = [ "u" ]
[modal_bspline1_advection_sine]
variables1d = [ "u", "u_err" ]
[modal_bspline2_advection_sine] [modal_bspline2_advection_sine]
variables1d = [ "u", "u_err" ] variables1d = [ "u", "u_err" ]
......
...@@ -529,7 +529,9 @@ function impl_runtests(tests::Vector{String}=String[]) ...@@ -529,7 +529,9 @@ function impl_runtests(tests::Vector{String}=String[])
(data, i, j) -> (j == 3 || j == 4) && !data[i,j], (data, i, j) -> (j == 3 || j == 4) && !data[i,j],
crayon"red" crayon"red"
) )
pretty_table(logs, hcat(1:length(tests), tests, isnothing.(runs_status), comparsion_success); test_ran = isnothing.(runs_status)
test_passed = map(s -> ismissing(s) ? false : s, comparsion_success)
pretty_table(logs, hcat(1:length(tests), tests, test_ran, test_passed);
tf = tf_unicode_rounded, tf = tf_unicode_rounded,
alignment = [ :l, :l, :r, :r ], alignment = [ :l, :l, :r, :r ],
highlighters = (hl_success,hl_fail), highlighters = (hl_success,hl_fail),
......
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