Skip to content
Snippets Groups Projects
Commit 44299077 authored by Emilie Marchandise's avatar Emilie Marchandise
Browse files

No commit message

No commit message
parent 7fc3ba2d
No related branches found
No related tags found
No related merge requests found
--[[
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.3 and x<0.3) then
f:set (i, 0, 1)
else
f:set (i, 0, 0)
end
end
end
--[[
Example of a lua program driving the DG code
--]]
model = GModel () model = GModel ()
model:load ('edge.geo')
-- model:mesh (1)
-- model:save ('edge.msh')
model:load ('edge.msh') model:load ('edge.msh')
dg = dgSystemOfEquations (model) order=1
dg:setOrder(1) dimension=1
-- conservation law -- conservation law
-- advection speed -- advection speed
...@@ -17,9 +36,6 @@ nu=fullMatrix(1,1); ...@@ -17,9 +36,6 @@ nu=fullMatrix(1,1);
nu:set(0,0,0) nu:set(0,0,0)
law = dgConservationLawAdvectionDiffusion(functionConstant(v):getName(), '') law = dgConservationLawAdvectionDiffusion(functionConstant(v):getName(), '')
--FunctionConstant(nu):getName())
dg:setConservationLaw(law)
-- boundary condition -- boundary condition
outside=fullMatrix(1,1) outside=fullMatrix(1,1)
...@@ -28,35 +44,31 @@ bndcondition=law:newOutsideValueBoundary(functionConstant(outside):getName()) ...@@ -28,35 +44,31 @@ bndcondition=law:newOutsideValueBoundary(functionConstant(outside):getName())
law:addBoundaryCondition('Left',bndcondition) law:addBoundaryCondition('Left',bndcondition)
law:addBoundaryCondition('Right',bndcondition) law:addBoundaryCondition('Right',bndcondition)
dg:setup() groups = dgGroupCollection(model, dimension, order)
groups:buildGroupsOfInterfaces()
-- initial condition -- build Runge Kutta and limiter
function initial_condition( xyz , f ) rk=dgRungeKutta()
for i=0,xyz:size1()-1 do limiter = dgSlopeLimiter(law)
x = xyz:get(i,0) rk:setLimiter(limiter)
y = xyz:get(i,1)
z = xyz:get(i,2)
if (x>-0.3 and x<0.3) then
f:set (i, 0, 1)
else
f:set (i, 0, 0)
end
end
end
dg:L2Projection(functionLua(1,'initial_condition',{'XYZ'}):getName())
print'***exporting init solution ***'
dg:exportSolution('output/Adv1D_unlimited') -- build solution vector
dg:limitSolution() FS = functionLua(1, 'initial_condition', {'XYZ'}):getName()
dg:exportSolution('output/Adv1D-00000') solution = dgDofContainer(groups, law:getNbFields())
solution:L2Projection(FS)
solution:exportMsh('output/init')
limiter:apply(solution)
solution:exportMsh('output/init_limit')
-- main loop print'*** solve ***'
local x = os.clock()
n = 5 n = 5
dt = 0.03
for i=1,100*n do for i=1,100*n do
norm = dg:RK44_limiter(0.03) norm = rk:iterate44(law,dt,solution)
if (i % n == 0) then if (i % n == 0) then
print('iter',i,norm) print('|ITER|',i,'|NORM|',norm,'|DT|',dt,'|CPU|',os.clock() - x)
dg:exportSolution(string.format("output/Adv1D-%05d", i)) solution:exportMsh(string.format('output/solution-%06d',i))
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment