trixi-framework / Trixi.jl

Trixi.jl: Adaptive high-order numerical simulations of conservation laws in Julia
https://trixi-framework.github.io/Trixi.jl
MIT License
537 stars 109 forks source link

MethodError when using flux tuple in combination with `BoundaryConditionDirichlet` and `TreeMesh` #1243

Closed JoshuaLampert closed 1 year ago

JoshuaLampert commented 2 years ago

It seems like there is a problem with the BoundaryConditionDirichlet when using a TreeMesh and a tuple of surface flux functions. The following Code, e.g., gives the error message LoadError: MethodError: objects of type Tuple{FluxHLL{typeof(min_max_speed_naive)}, typeof(flux_nonconservative_fjordholm_etal)} are not callable:

using OrdinaryDiffEq
using Trixi

equations = ShallowWaterEquations2D(gravity_constant=1.0, H0=3.0)

function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations2D)
  H = equations.H0
  v1 = 0.0
  v2 = 0.0
  x1, x2 = x
  b = (  1.5 / exp( 0.5 * ((x1 - 1.0)^2 + (x2 - 1.0)^2) )
       + 0.75 / exp( 0.5 * ((x1 + 1.0)^2 + (x2 + 1.0)^2) ) )
  return prim2cons(SVector(H, v1, v2, b), equations)
end

initial_condition = initial_condition_well_balancedness
boundary_condition = BoundaryConditionDirichlet(initial_condition)

volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal)
solver = DGSEM(polydeg=4, surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal),
               volume_integral=VolumeIntegralFluxDifferencing(volume_flux))
L = 4
coordinates_min = (-L, -L)
coordinates_max = (L, L)
mesh = TreeMesh(coordinates_min, coordinates_max,
                initial_refinement_level=3,
                n_cells_max=10_000,
                periodicity=false)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
                                    boundary_conditions=boundary_condition)

tspan = (0.0, 5.0)
ode = semidiscretize(semi, tspan)

sol = solve(ode, RDPK3SpFSAL49(), abstol=1.0e-8, reltol=1.0e-8,
            save_everystep=false);
sloede commented 2 years ago

Without having looked at the code yet, is it possible that this is due to the fact that non-cons systems of equations pass a tuple of surface flux functions instead of a single surface flux function and that BoundaryConditionDirichlet does not know about this and does not try to peel off the correct one, instead trying to call the tuple?

cc @andrewwinters5000

andrewwinters5000 commented 2 years ago

The routines for computing the physical boundary fluxes on TreeMesh need modified in order to handle the nonconservative terms. Specifically, one needs to modify the existing calc_boundary_flux_by_direction! to dispatch on nonconservative_terms::Val{false} and a new routine needs written that dispatches on nonconservative_terms::Val{true}.

maxbertrand1996 commented 1 year ago

I think I fixed this. Please have a look at my PR.