From b30417fbc51c67d07113e5d331f121c871c30213 Mon Sep 17 00:00:00 2001 From: Florian Atteneder <florian.atteneder@uni-jena.de> Date: Thu, 29 Aug 2024 19:56:52 +0000 Subject: [PATCH] A few random fixes (https://git.tpi.uni-jena.de/dg/dg1d.jl/-/merge_requests/218) The only notable change is the use use of the Lagrange derivative matrix for all DG kinds. That's done because not all DG kinds have the derivative defined on their nodal points (`:modal_bspline1`). --- src/bspline.jl | 2 +- src/callbacks.jl | 1 - src/dgelement.jl | 9 +++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bspline.jl b/src/bspline.jl index ba72694a..3919fd54 100644 --- a/src/bspline.jl +++ b/src/bspline.jl @@ -384,7 +384,7 @@ function integrate(f::Function, idxs::AbstractVector{<:Integer}, bs::Bspline2) @toggled_assert length(idxs) == bs.Npts+1 sum = 0.0 @inbounds for i in bs.Npts+1 - fi, xl, xr = f[idxs[i]], bs.xs[i], bs.xs[i+3] + fi, xl, xr = f(idxs[i]), bs.xs[i], bs.xs[i+3] sum += fi * (xr-xl)/3 end return sum diff --git a/src/callbacks.jl b/src/callbacks.jl index f1c99d86..ae191044 100644 --- a/src/callbacks.jl +++ b/src/callbacks.jl @@ -844,7 +844,6 @@ mutable struct ProgressCallback <: AbstractCallback prog_buffer = IOBuffer(; sizehint=2048) prog = Progress(100, # % dt=0.0, # always update - barglyphs=BarGlyphs('|','â–ˆ', ['â–' ,'â–‚' ,'â–ƒ' ,'â–„' ,'â–…' ,'â–†', 'â–‡'],' ','|',), showspeed=true, output=prog_buffer) # accumulate report here report_buffer = IOBuffer(; sizehint=2048) diff --git a/src/dgelement.jl b/src/dgelement.jl index e78129c0..8c540663 100644 --- a/src/dgelement.jl +++ b/src/dgelement.jl @@ -68,7 +68,6 @@ struct DGElement invM = inv(M) end z = quadr_z - D = first_derivative_matrix(z) V = vandermonde_matrix_legendre(z) l_lhs = zeros(Float64, Npts) l_rhs = zeros(Float64, Npts) @@ -83,7 +82,6 @@ struct DGElement purge_zeros!(quadr_z) z = collect(range(-1.0,1.0,Npts)) purge_zeros!(z) - D = [ Bernstein.derivative_bernstein_polynomial(z[i], j, N) for i in 1:Npts, j in 1:Npts ] M = Bernstein.mass_matrix(Npts) S = Bernstein.stiffness_matrix(Npts) invM = inv(M) @@ -111,7 +109,6 @@ struct DGElement # We use a Gauss rule to avoid evaluating the Bspline on subcell interfaces and bdrys. 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 ] M = Bspline.mass_matrix(bs1) S = Bspline.stiffness_matrix(bs1) invM = inv(M) @@ -143,7 +140,6 @@ struct DGElement # 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. quadr_z, quadr_w = LG.rule(3) - D = [ Bspline.derivative_polynomial(z[i], j, bs2) for i in 1:Npts, j in 1:Npts ] M = Bspline.mass_matrix(bs2) S = Bspline.stiffness_matrix(bs2) invM = inv(M) @@ -154,6 +150,11 @@ struct DGElement l_rhs[end] = 1.0 end + # differentiation is not defined for all dg kinds, e.g. modal_bspline1 + # we generally use the weak DG form, so its not needed for evolutions + # otherwise we should just use a Lagrange approximation + D = first_derivative_matrix(z) + # just set up something, its unused for the other kinds if kind !== :modal_bspline1 bs1 = Bspline.Bspline1(z) -- GitLab