aboutsummaryrefslogtreecommitdiff
path: root/Python/pywarpx/timestepper.py
diff options
context:
space:
mode:
authorGravatar Grote <grote1@n9459722.llnl.gov> 2017-03-23 14:06:34 -0700
committerGravatar Grote <grote1@n9459722.llnl.gov> 2017-03-23 14:20:03 -0700
commit68ea3081598a0c8dd0e99c5069c63559fdd59f5c (patch)
tree9364caf91293dd9da260d24d49045338738eacc4 /Python/pywarpx/timestepper.py
parent2398659ecc197c69641923e816b3b312d287adf1 (diff)
downloadWarpX-68ea3081598a0c8dd0e99c5069c63559fdd59f5c.tar.gz
WarpX-68ea3081598a0c8dd0e99c5069c63559fdd59f5c.tar.zst
WarpX-68ea3081598a0c8dd0e99c5069c63559fdd59f5c.zip
Switched high level Python wrapper to ctypes
Diffstat (limited to 'Python/pywarpx/timestepper.py')
-rw-r--r--Python/pywarpx/timestepper.py52
1 files changed, 26 insertions, 26 deletions
diff --git a/Python/pywarpx/timestepper.py b/Python/pywarpx/timestepper.py
index 71787c7a4..1e3519dcc 100644
--- a/Python/pywarpx/timestepper.py
+++ b/Python/pywarpx/timestepper.py
@@ -2,18 +2,18 @@ import warp
from warp import top
from warp import w3d
-from . import WarpX
+from ._libwarpx import libwarpx
class TimeStepper(object):
+ def step(self, nsteps=1):
+ for i in range(nsteps):
+ self.onestep()
def onestep(self):
- # --- A reference to the instance of the WarpX class
- warpx = WarpX.warpx.warpx
- mypc = warpx.GetPartContainer()
- self.cur_time = warpx.gett_new(0)
- self.istep = warpx.getistep(0)
+ self.cur_time = libwarpx.warpx_gett_new(0)
+ self.istep = libwarpx.warpx_getistep(0)
#if mpi.rank == 0:
print "\nSTEP %d starts ..."%(self.istep + 1)
@@ -21,53 +21,52 @@ class TimeStepper(object):
#if (ParallelDescriptor::NProcs() > 1)
# if (okToRegrid(step)) RegridBaseLevel();
- warpx.ComputeDt()
- dt = warpx.getdt(0)
+ libwarpx.warpx_ComputeDt()
+ dt = libwarpx.warpx_getdt(0)
# --- Advance level 0 by dt
lev = 0
# --- At the beginning, we have B^{n-1/2} and E^{n}.
# --- Particles have p^{n-1/2} and x^{n}.
- warpx.EvolveB(lev, 0.5*dt) # We now B^{n}
+ libwarpx.warpx_EvolveB(lev, 0.5*dt) # We now B^{n}
- warpx.FillBoundaryE(lev, False)
- warpx.FillBoundaryB(lev, False)
+ libwarpx.warpx_FillBoundaryE(lev, False)
+ libwarpx.warpx_FillBoundaryB(lev, False)
# --- Evolve particles to p^{n+1/2} and x^{n+1}
# --- Depose current, j^{n+1/2}
- warpx.PushParticlesandDepose(lev, self.cur_time)
+ libwarpx.warpx_PushParticlesandDepose(lev, self.cur_time)
- mypc.Redistribute() # Redistribute particles
+ libwarpx.mypc_Redistribute() # Redistribute particles
- warpx.EvolveB(lev, 0.5*dt) # We now B^{n+1/2}
+ libwarpx.warpx_EvolveB(lev, 0.5*dt) # We now B^{n+1/2}
- warpx.FillBoundaryB(lev, True)
+ libwarpx.warpx_FillBoundaryB(lev, True)
- warpx.EvolveE(lev, dt) # We now have E^{n+1}
+ libwarpx.warpx_EvolveE(lev, dt) # We now have E^{n+1}
self.istep += 1
self.cur_time += dt
- warpx.MoveWindow();
+ libwarpx.warpx_MoveWindow();
#if mpi.rank == 0:
print "STEP %d ends. TIME = %e DT = %e"%(self.istep, self.cur_time, dt)
# --- Sync up time
- for i in range(warpx.finestLevel()+1):
- warpx.sett_new(i, self.cur_time)
- warpx.setistep(i, self.istep)
+ for i in range(libwarpx.warpx_finestLevel()+1):
+ libwarpx.warpx_sett_new(i, self.cur_time)
+ libwarpx.warpx_setistep(i, self.istep)
- max_time_reached = ((self.cur_time >= warpx.stopTime() - 1.e-6*dt) or (self.istep >= warpx.maxStep()))
+ max_time_reached = ((self.cur_time >= libwarpx.warpx_stopTime() - 1.e-6*dt) or (self.istep >= libwarpx.warpx_maxStep()))
- if warpx.plotInt() > 0 and (self.istep+1)%warpx.plotInt() == 0 or max_time_reached:
- warpx.WritePlotFile()
-
- if warpx.checkInt() > 0 and (self.istep+1)%warpx.plotInt() == 0 or max_time_reached:
- warpx.WriteCheckPointFile()
+ if libwarpx.warpx_plotInt() > 0 and (self.istep+1)%libwarpx.warpx_plotInt() == 0 or max_time_reached:
+ libwarpx.warpx_WritePlotFile()
+ if libwarpx.warpx_checkInt() > 0 and (self.istep+1)%libwarpx.warpx_plotInt() == 0 or max_time_reached:
+ libwarpx.warpx_WriteCheckPointFile()
@@ -80,6 +79,7 @@ class TimeStepper(object):
+# --- This is not used
class TimeStepperFromPICSAR(object):
def __init__(self, package=None, solver=None, l_debug=False):