From e00396355911883b801cc827f2eae2aa8e7225d5 Mon Sep 17 00:00:00 2001 From: Emilie Marchandise <emilie.marchandise@uclouvain.be> Date: Sat, 6 Mar 2010 14:22:13 +0000 Subject: [PATCH] --- Solver/TESTCASES/DamBreak.lua | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Solver/TESTCASES/DamBreak.lua diff --git a/Solver/TESTCASES/DamBreak.lua b/Solver/TESTCASES/DamBreak.lua new file mode 100644 index 0000000000..8bb084ed05 --- /dev/null +++ b/Solver/TESTCASES/DamBreak.lua @@ -0,0 +1,67 @@ +--[[ + Function for initial conditions +--]] + +function initial_condition( xyz , f ) + for i=0,xyz:size1()-1 do + x = xyz:get(i,0) + y = xyz:get(i,1) + z = xyz:get(i,2) + if (x<0.0) then + f:set (i, 0, 40) + f:set (i, 1, 0) + else + f:set (i, 0, 5) + f:set (i, 1, 0) + end + end +end + +--[[ + Example of a lua program driving the DG code +--]] + +model = GModel() +model:load ('edge.msh') +order=1 +dimension=1 + +-- boundary condition +law = dgConservationLawShallowWater1d() +law:addBoundaryCondition('Left',law:newBoundaryWall()) +law:addBoundaryCondition('Right',law:newBoundaryWall()) + +groups = dgGroupCollection(model, dimension, order) +groups:buildGroupsOfInterfaces() + +claw = dgConservationLawShallowWater1d() +claw:addBoundaryCondition('Wall',law:newBoundaryWall()) + +rk=dgRungeKutta() +limiter = dgSlopeLimiter(law) +rk:setLimiter(limiter) + +-- build solution vector +FS = functionLua(1, 'initial_condition', {'XYZ'}):getName() +solution = dgDofContainer(groups, law:getNbFields()) +solution:L2Projection(FS) + +print'*** print initial sol ***' +solution:exportMsh('output/init') +limiter:apply(solution) +solution:exportMsh('output/init_limit') + +print'*** solve ***' +--dt = 0.00001; +CFL = 1; +for i=1,1000 do + dt = CFL * rk:computeInvSpectralRadius(law,solution); +-- norm = rk:iterate44(law,dt,solution) + norm = rk:iterateEuler(law,dt,solution) + if (i % 20 == 0) then + print('|ITER|',i,'|NORM|',norm,'|DT|',dt,'|CPU|',os.clock() - x) + end + if (i % 20 == 0) then + solution:exportMsh(string.format('output/solution-%06d', i)) + end +end -- GitLab