diff options
-rwxr-xr-x | Python/pywarpx/_libwarpx.py | 108 | ||||
-rw-r--r-- | Python/pywarpx/timestepper.py | 21 | ||||
-rw-r--r-- | Source/WarpXEvolve.cpp | 3 | ||||
-rw-r--r-- | Source/WarpXWrappers.cpp | 29 | ||||
-rw-r--r-- | Source/WarpXWrappers.h | 12 |
5 files changed, 91 insertions, 82 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py index ec87386a0..e552a2f58 100755 --- a/Python/pywarpx/_libwarpx.py +++ b/Python/pywarpx/_libwarpx.py @@ -86,14 +86,14 @@ f.restype = LP_LP_c_double f = libwarpx.warpx_getCurrentDensity f.restype = LP_LP_c_double -f = libwarpx.warpx_getPMLSigma -f.restype = LP_c_double - -f = libwarpx.warpx_getPMLSigmaStar -f.restype = LP_c_double - -f = libwarpx.warpx_ComputePMLFactors -f.argtypes = (ctypes.c_int, ctypes.c_double) +#f = libwarpx.warpx_getPMLSigma +#f.restype = LP_c_double +# +#f = libwarpx.warpx_getPMLSigmaStar +#f.restype = LP_c_double +# +#f = libwarpx.warpx_ComputePMLFactors +#f.argtypes = (ctypes.c_int, ctypes.c_double) f = libwarpx.warpx_addNParticles f.argtypes = (ctypes.c_int, ctypes.c_int, @@ -116,11 +116,13 @@ libwarpx.warpx_checkInt.restype = ctypes.c_int libwarpx.warpx_plotInt.restype = ctypes.c_int libwarpx.warpx_finestLevel.restype = ctypes.c_int -libwarpx.warpx_EvolveE.argtypes = [ctypes.c_int, ctypes.c_double] -libwarpx.warpx_EvolveB.argtypes = [ctypes.c_int, ctypes.c_double] -libwarpx.warpx_FillBoundaryE.argtypes = [ctypes.c_int, ctypes.c_bool] -libwarpx.warpx_FillBoundaryB.argtypes = [ctypes.c_int, ctypes.c_bool] -libwarpx.warpx_PushParticlesandDepose.argtypes = [ctypes.c_int, ctypes.c_double] +libwarpx.warpx_EvolveE.argtypes = [ctypes.c_double] +libwarpx.warpx_EvolveB.argtypes = [ctypes.c_double] +libwarpx.warpx_FillBoundaryE.argtypes = [] +libwarpx.warpx_FillBoundaryB.argtypes = [] +libwarpx.warpx_UpdateAuxilaryData.argtypes = [] +libwarpx.warpx_SyncCurrent.argtypes = [] +libwarpx.warpx_PushParticlesandDepose.argtypes = [ctypes.c_double] libwarpx.warpx_getistep.argtypes = [ctypes.c_int] libwarpx.warpx_setistep.argtypes = [ctypes.c_int, ctypes.c_int] libwarpx.warpx_gett_new.argtypes = [ctypes.c_int] @@ -187,46 +189,46 @@ def evolve(num_steps=-1): libwarpx.warpx_evolve(num_steps); -def get_sigma(direction): - ''' - - Return the 'sigma' PML coefficients for the electric field - in a given direction. - - ''' - - size = ctypes.c_int(0) - data = libwarpx.warpx_getPMLSigma(direction, ctypes.byref(size)) - arr = np.ctypeslib.as_array(data, (size.value,)) - arr.setflags(write=1) - return arr - - -def get_sigma_star(direction): - ''' - - Return the 'sigma*' PML coefficients for the magnetic field - in the given direction. - - ''' - - size = ctypes.c_int(0) - data = libwarpx.warpx_getPMLSigmaStar(direction, ctypes.byref(size)) - arr = np.ctypeslib.as_array(data, (size.value,)) - arr.setflags(write=1) - return arr - - -def compute_pml_factors(lev, dt): - ''' - - This recomputes the PML coefficients for a given level, using the - time step dt. This needs to be called after modifying the coefficients - from Python. - - ''' - - libwarpx.warpx_ComputePMLFactors(lev, dt) +#def get_sigma(direction): +# ''' +# +# Return the 'sigma' PML coefficients for the electric field +# in a given direction. +# +# ''' +# +# size = ctypes.c_int(0) +# data = libwarpx.warpx_getPMLSigma(direction, ctypes.byref(size)) +# arr = np.ctypeslib.as_array(data, (size.value,)) +# arr.setflags(write=1) +# return arr +# +# +#def get_sigma_star(direction): +# ''' +# +# Return the 'sigma*' PML coefficients for the magnetic field +# in the given direction. +# +# ''' +# +# size = ctypes.c_int(0) +# data = libwarpx.warpx_getPMLSigmaStar(direction, ctypes.byref(size)) +# arr = np.ctypeslib.as_array(data, (size.value,)) +# arr.setflags(write=1) +# return arr +# +# +#def compute_pml_factors(lev, dt): +# ''' +# +# This recomputes the PML coefficients for a given level, using the +# time step dt. This needs to be called after modifying the coefficients +# from Python. +# +# ''' +# +# libwarpx.warpx_ComputePMLFactors(lev, dt) def add_particles(species_number=0, x=0., y=0., z=0., ux=0., uy=0., uz=0., attr=0., diff --git a/Python/pywarpx/timestepper.py b/Python/pywarpx/timestepper.py index ce0ed8c24..4f7e36209 100644 --- a/Python/pywarpx/timestepper.py +++ b/Python/pywarpx/timestepper.py @@ -21,30 +21,29 @@ class TimeStepper(object): #if (ParallelDescriptor::NProcs() > 1) # if (okToRegrid(step)) RegridBaseLevel(); - 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}. - libwarpx.warpx_EvolveB(lev, 0.5*dt) # We now B^{n} + libwarpx.warpx_FillBoundaryE() + libwarpx.warpx_EvolveB(0.5*dt) # We now B^{n} - libwarpx.warpx_FillBoundaryE(lev, False) - libwarpx.warpx_FillBoundaryB(lev, False) + libwarpx.warpx_FillBoundaryB() + libwarpx.warpx_UpdateAuxilaryData() # --- Evolve particles to p^{n+1/2} and x^{n+1} # --- Depose current, j^{n+1/2} - libwarpx.warpx_PushParticlesandDepose(lev, self.cur_time) + libwarpx.warpx_PushParticlesandDepose(self.cur_time) libwarpx.mypc_Redistribute() # Redistribute particles - libwarpx.warpx_EvolveB(lev, 0.5*dt) # We now B^{n+1/2} + libwarpx.warpx_FillBoundaryE() + libwarpx.warpx_EvolveB(0.5*dt) # We now B^{n+1/2} - libwarpx.warpx_FillBoundaryB(lev, True) + libwarpx.warpx_SyncCurrent() - libwarpx.warpx_EvolveE(lev, dt) # We now have E^{n+1} + libwarpx.warpx_FillBoundaryB() + libwarpx.warpx_EvolveE(dt) # We now have E^{n+1} self.istep += 1 diff --git a/Source/WarpXEvolve.cpp b/Source/WarpXEvolve.cpp index 794b5aa4c..97d0e49e0 100644 --- a/Source/WarpXEvolve.cpp +++ b/Source/WarpXEvolve.cpp @@ -42,10 +42,9 @@ WarpX::Evolve (int numsteps) // Beyond one step, we have B^{n-1/2} and E^{n}. // Particles have p^{n-1/2} and x^{n}. - FillBoundaryB(); - if (is_synchronized) { // on first step, push E and X by 0.5*dt + FillBoundaryB(); EvolveE(0.5*dt[0]); mypc->PushX(0.5*dt[0]); mypc->Redistribute(); // Redistribute particles diff --git a/Source/WarpXWrappers.cpp b/Source/WarpXWrappers.cpp index 337472fbb..a17721647 100644 --- a/Source/WarpXWrappers.cpp +++ b/Source/WarpXWrappers.cpp @@ -93,7 +93,6 @@ extern "C" auto & mypc = WarpX::GetInstance().GetPartContainer(); auto & myspc = mypc.GetParticleContainer(speciesnumber); const int lev = 0; - amrex::Abort("warpx_addNParticles needs to be updated to include lev argument"); myspc.AddNParticles(lev, lenx, x, y, z, vx, vy, vz, nattr, attr, uniqueparticles); } @@ -184,25 +183,33 @@ extern "C" warpx.MoveWindow (true); } - void warpx_EvolveE (int lev, double dt) { + void warpx_EvolveE (double dt) { WarpX& warpx = WarpX::GetInstance(); - warpx.EvolveE (lev, dt); + warpx.EvolveE (dt); } - void warpx_EvolveB (int lev, double dt) { + void warpx_EvolveB (double dt) { WarpX& warpx = WarpX::GetInstance(); - warpx.EvolveB (lev, dt); + warpx.EvolveB (dt); } - void warpx_FillBoundaryE (int lev) { + void warpx_FillBoundaryE () { WarpX& warpx = WarpX::GetInstance(); - warpx.FillBoundaryE (lev); + warpx.FillBoundaryE (); } - void warpx_FillBoundaryB (int lev) { + void warpx_FillBoundaryB () { WarpX& warpx = WarpX::GetInstance(); - warpx.FillBoundaryB (lev); + warpx.FillBoundaryB (); } - void warpx_PushParticlesandDepose (int lev, double cur_time) { + void warpx_SyncCurrent () { WarpX& warpx = WarpX::GetInstance(); - warpx.PushParticlesandDepose (lev, cur_time); + warpx.SyncCurrent (); + } + void warpx_UpdateAuxilaryData () { + WarpX& warpx = WarpX::GetInstance(); + warpx.UpdateAuxilaryData (); + } + void warpx_PushParticlesandDepose (double cur_time) { + WarpX& warpx = WarpX::GetInstance(); + warpx.PushParticlesandDepose (cur_time); } int warpx_getistep (int lev) { diff --git a/Source/WarpXWrappers.h b/Source/WarpXWrappers.h index baca16ec6..aeb5a00c1 100644 --- a/Source/WarpXWrappers.h +++ b/Source/WarpXWrappers.h @@ -61,11 +61,13 @@ extern "C" { void warpx_ComputeDt (); void warpx_MoveWindow (); - void warpx_EvolveE (int lev, double dt); - void warpx_EvolveB (int lev, double dt); - void warpx_FillBoundaryE (int lev); - void warpx_FillBoundaryB (int lev); - void warpx_PushParticlesandDepose (int lev, double cur_time); + void warpx_EvolveE (double dt); + void warpx_EvolveB (double dt); + void warpx_FillBoundaryE (); + void warpx_FillBoundaryB (); + void warpx_SyncCurrent (); + void warpx_UpdateAuxilaryData (); + void warpx_PushParticlesandDepose (double cur_time); int warpx_getistep (int lev); void warpx_setistep (int lev, int ii); |