From c443a606fbcbde491062fc50762d1dbd4627c66a Mon Sep 17 00:00:00 2001 From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be> Date: Wed, 9 Dec 2009 15:13:26 +0000 Subject: [PATCH] Lua input files for gmshlua --- Solver/TESTCASES/WavePulse.lua | 58 ++++++++++++++++++++++++++++++++++ Solver/TESTCASES/square.geo | 12 +++++++ 2 files changed, 70 insertions(+) create mode 100644 Solver/TESTCASES/WavePulse.lua create mode 100644 Solver/TESTCASES/square.geo diff --git a/Solver/TESTCASES/WavePulse.lua b/Solver/TESTCASES/WavePulse.lua new file mode 100644 index 0000000000..74f2c2f70e --- /dev/null +++ b/Solver/TESTCASES/WavePulse.lua @@ -0,0 +1,58 @@ +--[[ + Function for initial conditions +--]] +function initial_condition( x , f ) + XYZ = fullMatrix(x) + FCT = fullMatrix(f) + for i=0,XYZ:size1()-1 do + X = XYZ:get(i,0) - .5 + Y = XYZ:get(i,1) - .5 + Z = XYZ:get(i,2) + VALUE = math.exp(-40*(X*X+Y*Y+Z*Z)); + FCT:set(i,0,VALUE) + FCT:set(i,1,0.0) + FCT:set(i,2,0.0) + end +end + +--[[ + Example of a lua program driving the DG code +--]] + +order = 1 +print'*** Loading the mesh and the model ***' +myModel = GModel () +myModel:load ('square.geo') +myModel:load ('square.msh') +print'*** Create a dg solver ***' +DG = dgSystemOfEquations (myModel) +DG:setOrder(order) +DG:setConservationLaw('WaveEquation') +DG:addBoundaryCondition('Border','Wall') +DG:setup() + +initialCondition = createFunction.lua(3,'initial_condition','XYZ') + +print'*** setting the initial solution ***' + +DG:L2Projection(initialCondition) + +print'*** export ***' + +DG:exportSolution('solution_0') + +print'*** solve ***' + +dt = 0.005; +for i=1,1000 do + norm = DG:RK44(dt) + print('*** ITER ***',i,norm) + if (i % 10 == 0) then + AA = string.format("solution-%03d", i) + DG:exportSolution(AA) + end +end + +print'*** done ***' + + diff --git a/Solver/TESTCASES/square.geo b/Solver/TESTCASES/square.geo new file mode 100644 index 0000000000..4eb2bc249f --- /dev/null +++ b/Solver/TESTCASES/square.geo @@ -0,0 +1,12 @@ +Point(1) = {0.0, 0.0, 0, .03}; +Point(2) = {1, 0.0, 0, .03}; +Point(3) = {1, 1, 0, .03}; +Point(4) = {0, 1, 0, .03}; +Line(1) = {4, 3}; +Line(2) = {3, 2}; +Line(3) = {2, 1}; +Line(4) = {1, 4}; +Line Loop(5) = {2, 3, 4, 1}; +Plane Surface(6) = {5}; +Physical Line("Border") = {1, 2, 3, 4}; +Physical Surface("Inside") = {6}; -- GitLab