From 52e76619195ddf5abfe6a881f9a103bc25401740 Mon Sep 17 00:00:00 2001 From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de> Date: Wed, 9 Aug 2017 18:13:42 +0200 Subject: [PATCH] Add a 1D dambreak shallow water example --- test/hyperbolic/CMakeLists.txt | 5 ++++ test/hyperbolic/shallowwater_1d.mini | 18 ++++++++++++++ test/hyperbolic/shallowwater_1d.ufl | 36 ++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 test/hyperbolic/shallowwater_1d.mini create mode 100644 test/hyperbolic/shallowwater_1d.ufl diff --git a/test/hyperbolic/CMakeLists.txt b/test/hyperbolic/CMakeLists.txt index 2b00da61..92e4e885 100644 --- a/test/hyperbolic/CMakeLists.txt +++ b/test/hyperbolic/CMakeLists.txt @@ -12,3 +12,8 @@ dune_add_formcompiler_system_test(UFLFILE shallowwater.ufl BASENAME shallowwater INIFILE shallowwater.mini ) + +dune_add_formcompiler_system_test(UFLFILE shallowwater_1d.ufl + BASENAME shallowwater_1d + INIFILE shallowwater_1d.mini + ) diff --git a/test/hyperbolic/shallowwater_1d.mini b/test/hyperbolic/shallowwater_1d.mini new file mode 100644 index 00000000..8283dfee --- /dev/null +++ b/test/hyperbolic/shallowwater_1d.mini @@ -0,0 +1,18 @@ +__name = shallowwater_1d + +extension = 10.0 +upperright = 10.0 +cells = 500 +elementType = hexahedral + +[instat] +T = 6.0 +dt = 0.001 + +[wrapper.vtkcompare] +name = {__name} +extension = vtu + +[formcompiler] +numerical_jacobian = 1 +explicit_time_stepping = 1 diff --git a/test/hyperbolic/shallowwater_1d.ufl b/test/hyperbolic/shallowwater_1d.ufl new file mode 100644 index 00000000..8737b285 --- /dev/null +++ b/test/hyperbolic/shallowwater_1d.ufl @@ -0,0 +1,36 @@ +cell = interval +x = SpatialCoordinate(cell) + +f = conditional(x[0] <= 5., 0.005, 0.001) + +V = FiniteElement("DG", cell, 1) +MV = MixedElement(V, V) + +g = 10.0 + +n = FacetNormal(cell)('+') + +u = TrialFunction(MV) +v = TestFunction(MV) + +mass = inner(u, v)*dx + +h, q = split(u) + +flux = as_matrix([[q], [q*q/h + 0.5*g*h*h]]) + +b_flux = as_matrix([[-1.* q], [q*q/h + 0.5*g*h*h]]) + +# Define numerical fluxes to choose from +alpha = Max(abs(n[0]*q('+')) / h('+') + sqrt(g*h('+')), abs(n[0]*q('-')) / h('-') + sqrt(g*h('-'))) +llf_flux = dot(avg(flux), n) - 0.5*alpha*jump(u) +alpha_b = abs(n[0]*q) / h + sqrt(g*h) +boundary_flux = 0.5*dot(flux + b_flux, n) + alpha_b * as_vector([0., q]) +numerical_flux = llf_flux + +r = -1. * inner(flux, grad(v))*dx \ + - inner(numerical_flux, jump(v))*dS \ + + inner(boundary_flux, v)*ds + +forms = [mass, r] +dirichlet_expression = f, 0.0 -- GitLab