Skip to content

Instantly share code, notes, and snippets.

@liangwang0734
Created October 6, 2018 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liangwang0734/5d89de05028c1133c77ef96081821bbb to your computer and use it in GitHub Desktop.
Save liangwang0734/5d89de05028c1133c77ef96081821bbb to your computer and use it in GitHub Desktop.
gkeyll_v1_test_src
----------------------
-- HELPER FUNCTIONS --
----------------------
function writeData(myQ, frame, tCurr, tag)
myQ:write(string.format("%s_%d.h5", tag, frame), tCurr)
end
----------------
-- PARAMETERS --
----------------
epsilon0 = 1.
mi = 1.
me = 0.25
q = 1.
linearSolver = "partialPivLu"
elcErrorSpeedFactor = 1.
mgnErrorSpeedFactor = 1.
dt = 0.1
mass = {me, mi}
charge = {-q, q}
numFluids = #mass
lower = {0.}
upper = {1.}
cells = {1}
----------------------
-- INITAL CONDITION --
----------------------
function init(x,y,z)
return 0.275, 0.3025, 0.5775, 0.8525,
1.43275, 2.31275, 3.74275, 0.63525, 0.93775, 1.79025,
1.2, 1.44, 2.64, 3.84,
11.712, 7.008, 13.488, 3.168, 4.608, 8.448,
1.3, 2.3, 3.3,
1.4, 2.4, 3.4,
3.33, 4.56
end
----------
-- GRID --
----------
decomposition = DecompRegionCalc1D.CartGeneral {}
grid = Grid.RectCart1D {
lower = lower,
upper = upper,
cells = cells,
decomposition = decomposition,
}
----------
-- DATA --
----------
createData = function(numComponents)
if not numComponents then
numComponents = 28
end
return DataStruct.Field1D {
onGrid = grid,
numComponents = numComponents,
}
end
q = createData()
getFields = function(myQ)
return myQ:alias(0, 10), myQ:alias(10, 20), myQ:alias(20, 28)
end
elc,ion,emf = getFields(q)
--------------------
-- SOURCE UPDATER --
--------------------
srcSlvr = Updater.ImplicitTenMomentSrc1D {
onGrid = grid,
numFluids = numFluids,
mass = mass,
charge = charge,
epsilon0 = epsilon0,
linearSolver = linearSolver,
elcErrorSpeedFactor = elcErrorSpeedFactor,
mgnErrorSpeedFactor = mgnErrorSpeedFactor,
}
function updateSource(elcIn, ionIn, emfIn, tCurr, tEnd)
srcSlvr:setOut( {elcIn, ionIn, emfIn} )
srcSlvr:setCurrTime(tCurr)
srcSlvr:advance(tEnd)
end
q:set(init)
q:write("before.h5")
updateSource(elc, ion, emf, 0, dt)
q:write("after.h5")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment