Skip to content
Snippets Groups Projects
Commit c443a606 authored by Jean-François Remacle's avatar Jean-François Remacle
Browse files

Lua input files for gmshlua

parent c303cfb9
No related branches found
No related tags found
No related merge requests found
--[[
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 ***'
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};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment