Added logic to only run required field updates for 2D domains (slice of 3D). This avoids updating unused field components and should make the 2D updates faster.

这个提交包含在:
Craig Warren
2015-11-02 18:44:40 +00:00
父节点 2001925170
当前提交 d1c8b58033
共有 2 个文件被更改,包括 173 次插入218 次删除

查看文件

@@ -36,11 +36,14 @@ cpdef update_ex(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updateco
cdef int i, j, k, listIndex
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(1, nz):
listIndex = ID[0, i, j, k]
Ex[i, j, k] = updatecoeffsE[listIndex, 0] * Ex[i, j, k] + updatecoeffsE[listIndex, 2] * (Hz[i, j, k] - Hz[i, j - 1, k]) - updatecoeffsE[listIndex, 3] * (Hy[i, j, k] - Hy[i, j, k - 1])
if ny == 1 or nz == 1:
pass
else:
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(1, nz):
listIndex = ID[0, i, j, k]
Ex[i, j, k] = updatecoeffsE[listIndex, 0] * Ex[i, j, k] + updatecoeffsE[listIndex, 2] * (Hz[i, j, k] - Hz[i, j - 1, k]) - updatecoeffsE[listIndex, 3] * (Hy[i, j, k] - Hy[i, j, k - 1])
cpdef update_ex_dispersive_multipole_A(int nx, int ny, int nz, int nthreads, int maxpoles, floattype_t[:, :] updatecoeffsE, complextype_t[:, :] updatecoeffsdispersive, np.uint32_t[:, :, :, :] ID, complextype_t[:, :, :, :] Tx, floattype_t[:, :, :] Ex, floattype_t[:, :, :] Hy, floattype_t[:, :, :] Hz):
@@ -56,15 +59,18 @@ cpdef update_ex_dispersive_multipole_A(int nx, int ny, int nz, int nthreads, int
cdef int i, j, k, listIndex, p
cdef float phi = 0.0
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(1, nz):
listIndex = ID[0, i, j, k]
phi = 0.0
for p in range(0, maxpoles):
phi = phi + updatecoeffsdispersive[listIndex, p * 3].real * Tx[p, i, j, k].real
Tx[p, i, j, k] = updatecoeffsdispersive[listIndex, 1 + (p * 3)] * Tx[p, i, j, k] + updatecoeffsdispersive[listIndex, 2 + (p * 3)] * Ex[i, j, k]
Ex[i, j, k] = updatecoeffsE[listIndex, 0] * Ex[i, j, k] + updatecoeffsE[listIndex, 2] * (Hz[i, j, k] - Hz[i, j - 1, k]) - updatecoeffsE[listIndex, 3] * (Hy[i, j, k] - Hy[i, j, k - 1]) - updatecoeffsE[listIndex, 4] * phi
if ny == 1 or nz == 1:
pass
else:
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(1, nz):
listIndex = ID[0, i, j, k]
phi = 0.0
for p in range(0, maxpoles):
phi = phi + updatecoeffsdispersive[listIndex, p * 3].real * Tx[p, i, j, k].real
Tx[p, i, j, k] = updatecoeffsdispersive[listIndex, 1 + (p * 3)] * Tx[p, i, j, k] + updatecoeffsdispersive[listIndex, 2 + (p * 3)] * Ex[i, j, k]
Ex[i, j, k] = updatecoeffsE[listIndex, 0] * Ex[i, j, k] + updatecoeffsE[listIndex, 2] * (Hz[i, j, k] - Hz[i, j - 1, k]) - updatecoeffsE[listIndex, 3] * (Hy[i, j, k] - Hy[i, j, k - 1]) - updatecoeffsE[listIndex, 4] * phi
cpdef update_ex_dispersive_multipole_B(int nx, int ny, int nz, int nthreads, int maxpoles, complextype_t[:, :] updatecoeffsdispersive, np.uint32_t[:, :, :, :] ID, complextype_t[:, :, :, :] Tx, floattype_t[:, :, :] Ex):
"""This function updates the Ex field components when dispersive materials (with multiple poles) are present.
@@ -77,13 +83,16 @@ cpdef update_ex_dispersive_multipole_B(int nx, int ny, int nz, int nthreads, int
"""
cdef int i, j, k, listIndex, p
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(1, nz):
listIndex = ID[0, i, j, k]
for p in range(0, maxpoles):
Tx[p, i, j, k] = Tx[p, i, j, k] - updatecoeffsdispersive[listIndex, 2 + (p * 3)] * Ex[i, j, k]
if ny == 1 or nz == 1:
pass
else:
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(1, nz):
listIndex = ID[0, i, j, k]
for p in range(0, maxpoles):
Tx[p, i, j, k] = Tx[p, i, j, k] - updatecoeffsdispersive[listIndex, 2 + (p * 3)] * Ex[i, j, k]
cpdef update_ex_dispersive_1pole_A(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updatecoeffsE, complextype_t[:, :] updatecoeffsdispersive, np.uint32_t[:, :, :, :] ID, complextype_t[:, :, :, :] Tx, floattype_t[:, :, :] Ex, floattype_t[:, :, :] Hy, floattype_t[:, :, :] Hz):
@@ -98,13 +107,16 @@ cpdef update_ex_dispersive_1pole_A(int nx, int ny, int nz, int nthreads, floatty
cdef int i, j, k, listIndex
cdef float phi = 0.0
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(1, nz):
listIndex = ID[0, i, j, k]
phi = updatecoeffsdispersive[listIndex, 0].real * Tx[0, i, j, k].real
Tx[0, i, j, k] = updatecoeffsdispersive[listIndex, 1] * Tx[0, i, j, k] + updatecoeffsdispersive[listIndex, 2] * Ex[i, j, k]
Ex[i, j, k] = updatecoeffsE[listIndex, 0] * Ex[i, j, k] + updatecoeffsE[listIndex, 2] * (Hz[i, j, k] - Hz[i, j - 1, k]) - updatecoeffsE[listIndex, 3] * (Hy[i, j, k] - Hy[i, j, k - 1]) - updatecoeffsE[listIndex, 4] * phi
if ny == 1 or nz == 1:
pass
else:
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(1, nz):
listIndex = ID[0, i, j, k]
phi = updatecoeffsdispersive[listIndex, 0].real * Tx[0, i, j, k].real
Tx[0, i, j, k] = updatecoeffsdispersive[listIndex, 1] * Tx[0, i, j, k] + updatecoeffsdispersive[listIndex, 2] * Ex[i, j, k]
Ex[i, j, k] = updatecoeffsE[listIndex, 0] * Ex[i, j, k] + updatecoeffsE[listIndex, 2] * (Hz[i, j, k] - Hz[i, j - 1, k]) - updatecoeffsE[listIndex, 3] * (Hy[i, j, k] - Hy[i, j, k - 1]) - updatecoeffsE[listIndex, 4] * phi
cpdef update_ex_dispersive_1pole_B(int nx, int ny, int nz, int nthreads, complextype_t[:, :] updatecoeffsdispersive, np.uint32_t[:, :, :, :] ID, complextype_t[:, :, :, :] Tx, floattype_t[:, :, :] Ex):
@@ -117,12 +129,15 @@ cpdef update_ex_dispersive_1pole_B(int nx, int ny, int nz, int nthreads, complex
"""
cdef int i, j, k, listIndex
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(1, nz):
listIndex = ID[0, i, j, k]
Tx[0, i, j, k] = Tx[0, i, j, k] - updatecoeffsdispersive[listIndex, 2] * Ex[i, j, k]
if ny == 1 or nz == 1:
pass
else:
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(1, nz):
listIndex = ID[0, i, j, k]
Tx[0, i, j, k] = Tx[0, i, j, k] - updatecoeffsdispersive[listIndex, 2] * Ex[i, j, k]
#########################################
@@ -139,11 +154,14 @@ cpdef update_ey(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updateco
cdef int i, j, k, listIndex
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(0, ny):
for k in range(1, nz):
listIndex = ID[1, i, j, k]
Ey[i, j, k] = updatecoeffsE[listIndex, 0] * Ey[i, j, k] + updatecoeffsE[listIndex, 3] * (Hx[i, j, k] - Hx[i, j, k - 1]) - updatecoeffsE[listIndex, 1] * (Hz[i, j, k] - Hz[i - 1, j, k])
if nx == 1 or nz == 1:
pass
else:
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(0, ny):
for k in range(1, nz):
listIndex = ID[1, i, j, k]
Ey[i, j, k] = updatecoeffsE[listIndex, 0] * Ey[i, j, k] + updatecoeffsE[listIndex, 3] * (Hx[i, j, k] - Hx[i, j, k - 1]) - updatecoeffsE[listIndex, 1] * (Hz[i, j, k] - Hz[i - 1, j, k])
cpdef update_ey_dispersive_multipole_A(int nx, int ny, int nz, int nthreads, int maxpoles, floattype_t[:, :] updatecoeffsE, complextype_t[:, :] updatecoeffsdispersive, np.uint32_t[:, :, :, :] ID, complextype_t[:, :, :, :] Ty, floattype_t[:, :, :] Ey, floattype_t[:, :, :] Hx, floattype_t[:, :, :] Hz):
@@ -159,15 +177,18 @@ cpdef update_ey_dispersive_multipole_A(int nx, int ny, int nz, int nthreads, int
cdef int i, j, k, listIndex, p
cdef float phi = 0.0
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(0, ny):
for k in range(1, nz):
listIndex = ID[1, i, j, k]
phi = 0.0
for p in range(0, maxpoles):
phi = phi + updatecoeffsdispersive[listIndex, p * 3].real * Ty[p, i, j, k].real
Ty[p, i, j, k] = updatecoeffsdispersive[listIndex, 1 + (p * 3)] * Ty[p, i, j, k] + updatecoeffsdispersive[listIndex, 2 + (p * 3)] * Ey[i, j, k]
Ey[i, j, k] = updatecoeffsE[listIndex, 0] * Ey[i, j, k] + updatecoeffsE[listIndex, 3] * (Hx[i, j, k] - Hx[i, j, k - 1]) - updatecoeffsE[listIndex, 1] * (Hz[i, j, k] - Hz[i - 1, j, k]) - updatecoeffsE[listIndex, 4] * phi
if nx == 1 or nz == 1:
pass
else:
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(0, ny):
for k in range(1, nz):
listIndex = ID[1, i, j, k]
phi = 0.0
for p in range(0, maxpoles):
phi = phi + updatecoeffsdispersive[listIndex, p * 3].real * Ty[p, i, j, k].real
Ty[p, i, j, k] = updatecoeffsdispersive[listIndex, 1 + (p * 3)] * Ty[p, i, j, k] + updatecoeffsdispersive[listIndex, 2 + (p * 3)] * Ey[i, j, k]
Ey[i, j, k] = updatecoeffsE[listIndex, 0] * Ey[i, j, k] + updatecoeffsE[listIndex, 3] * (Hx[i, j, k] - Hx[i, j, k - 1]) - updatecoeffsE[listIndex, 1] * (Hz[i, j, k] - Hz[i - 1, j, k]) - updatecoeffsE[listIndex, 4] * phi
cpdef update_ey_dispersive_multipole_B(int nx, int ny, int nz, int nthreads, int maxpoles, complextype_t[:, :] updatecoeffsdispersive, np.uint32_t[:, :, :, :] ID, complextype_t[:, :, :, :] Ty, floattype_t[:, :, :] Ey):
@@ -181,13 +202,16 @@ cpdef update_ey_dispersive_multipole_B(int nx, int ny, int nz, int nthreads, int
"""
cdef int i, j, k, listIndex, p
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(0, ny):
for k in range(1, nz):
listIndex = ID[1, i, j, k]
for p in range(0, maxpoles):
Ty[p, i, j, k] = Ty[p, i, j, k] - updatecoeffsdispersive[listIndex, 2 + (p * 3)] * Ey[i, j, k]
if nx == 1 or nz == 1:
pass
else:
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(0, ny):
for k in range(1, nz):
listIndex = ID[1, i, j, k]
for p in range(0, maxpoles):
Ty[p, i, j, k] = Ty[p, i, j, k] - updatecoeffsdispersive[listIndex, 2 + (p * 3)] * Ey[i, j, k]
cpdef update_ey_dispersive_1pole_A(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updatecoeffsE, complextype_t[:, :] updatecoeffsdispersive, np.uint32_t[:, :, :, :] ID, complextype_t[:, :, :, :] Ty, floattype_t[:, :, :] Ey, floattype_t[:, :, :] Hx, floattype_t[:, :, :] Hz):
@@ -202,13 +226,16 @@ cpdef update_ey_dispersive_1pole_A(int nx, int ny, int nz, int nthreads, floatty
cdef int i, j, k, listIndex
cdef float phi = 0.0
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(0, ny):
for k in range(1, nz):
listIndex = ID[1, i, j, k]
phi = updatecoeffsdispersive[listIndex, 0].real * Ty[0, i, j, k].real
Ty[0, i, j, k] = updatecoeffsdispersive[listIndex, 1] * Ty[0, i, j, k] + updatecoeffsdispersive[listIndex, 2] * Ey[i, j, k]
Ey[i, j, k] = updatecoeffsE[listIndex, 0] * Ey[i, j, k] + updatecoeffsE[listIndex, 3] * (Hx[i, j, k] - Hx[i, j, k - 1]) - updatecoeffsE[listIndex, 1] * (Hz[i, j, k] - Hz[i - 1, j, k]) - updatecoeffsE[listIndex, 4] * phi
if nx == 1 or nz == 1:
pass
else:
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(0, ny):
for k in range(1, nz):
listIndex = ID[1, i, j, k]
phi = updatecoeffsdispersive[listIndex, 0].real * Ty[0, i, j, k].real
Ty[0, i, j, k] = updatecoeffsdispersive[listIndex, 1] * Ty[0, i, j, k] + updatecoeffsdispersive[listIndex, 2] * Ey[i, j, k]
Ey[i, j, k] = updatecoeffsE[listIndex, 0] * Ey[i, j, k] + updatecoeffsE[listIndex, 3] * (Hx[i, j, k] - Hx[i, j, k - 1]) - updatecoeffsE[listIndex, 1] * (Hz[i, j, k] - Hz[i - 1, j, k]) - updatecoeffsE[listIndex, 4] * phi
cpdef update_ey_dispersive_1pole_B(int nx, int ny, int nz, int nthreads, complextype_t[:, :] updatecoeffsdispersive, np.uint32_t[:, :, :, :] ID, complextype_t[:, :, :, :] Ty, floattype_t[:, :, :] Ey):
@@ -221,12 +248,15 @@ cpdef update_ey_dispersive_1pole_B(int nx, int ny, int nz, int nthreads, complex
"""
cdef int i, j, k, listIndex
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(0, ny):
for k in range(1, nz):
listIndex = ID[1, i, j, k]
Ty[0, i, j, k] = Ty[0, i, j, k] - updatecoeffsdispersive[listIndex, 2] * Ey[i, j, k]
if nx == 1 or nz == 1:
pass
else:
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(0, ny):
for k in range(1, nz):
listIndex = ID[1, i, j, k]
Ty[0, i, j, k] = Ty[0, i, j, k] - updatecoeffsdispersive[listIndex, 2] * Ey[i, j, k]
#########################################
@@ -243,11 +273,14 @@ cpdef update_ez(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updateco
cdef int i, j, k, listIndex
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(0, nz):
listIndex = ID[2, i, j, k]
Ez[i, j, k] = updatecoeffsE[listIndex, 0] * Ez[i, j, k] + updatecoeffsE[listIndex, 1] * (Hy[i, j, k] - Hy[i - 1, j, k]) - updatecoeffsE[listIndex, 2] * (Hx[i, j, k] - Hx[i, j - 1, k])
if nx == 1 or ny == 1:
pass
else:
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(0, nz):
listIndex = ID[2, i, j, k]
Ez[i, j, k] = updatecoeffsE[listIndex, 0] * Ez[i, j, k] + updatecoeffsE[listIndex, 1] * (Hy[i, j, k] - Hy[i - 1, j, k]) - updatecoeffsE[listIndex, 2] * (Hx[i, j, k] - Hx[i, j - 1, k])
cpdef update_ez_dispersive_multipole_A(int nx, int ny, int nz, int nthreads, int maxpoles, floattype_t[:, :] updatecoeffsE, complextype_t[:, :] updatecoeffsdispersive, np.uint32_t[:, :, :, :] ID, complextype_t[:, :, :, :] Tz, floattype_t[:, :, :] Ez, floattype_t[:, :, :] Hx, floattype_t[:, :, :] Hy):
@@ -262,16 +295,19 @@ cpdef update_ez_dispersive_multipole_A(int nx, int ny, int nz, int nthreads, int
cdef int i, j, k, listIndex, p
cdef float phi = 0.0
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(0, nz):
listIndex = ID[2, i, j, k]
phi = 0.0
for p in range(0, maxpoles):
phi = phi + updatecoeffsdispersive[listIndex, p * 3].real * Tz[p, i, j, k].real
Tz[p, i, j, k] = updatecoeffsdispersive[listIndex, 1 + (p * 3)] * Tz[p, i, j, k] + updatecoeffsdispersive[listIndex, 2 + (p * 3)] * Ez[i, j, k]
Ez[i, j, k] = updatecoeffsE[listIndex, 0] * Ez[i, j, k] + updatecoeffsE[listIndex, 1] * (Hy[i, j, k] - Hy[i - 1, j, k]) - updatecoeffsE[listIndex, 2] * (Hx[i, j, k] - Hx[i, j - 1, k]) - updatecoeffsE[listIndex, 4] * phi
if nx == 1 or ny == 1:
pass
else:
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(0, nz):
listIndex = ID[2, i, j, k]
phi = 0.0
for p in range(0, maxpoles):
phi = phi + updatecoeffsdispersive[listIndex, p * 3].real * Tz[p, i, j, k].real
Tz[p, i, j, k] = updatecoeffsdispersive[listIndex, 1 + (p * 3)] * Tz[p, i, j, k] + updatecoeffsdispersive[listIndex, 2 + (p * 3)] * Ez[i, j, k]
Ez[i, j, k] = updatecoeffsE[listIndex, 0] * Ez[i, j, k] + updatecoeffsE[listIndex, 1] * (Hy[i, j, k] - Hy[i - 1, j, k]) - updatecoeffsE[listIndex, 2] * (Hx[i, j, k] - Hx[i, j - 1, k]) - updatecoeffsE[listIndex, 4] * phi
cpdef update_ez_dispersive_multipole_B(int nx, int ny, int nz, int nthreads, int maxpoles, complextype_t[:, :] updatecoeffsdispersive, np.uint32_t[:, :, :, :] ID, complextype_t[:, :, :, :] Tz, floattype_t[:, :, :] Ez):
@@ -285,13 +321,16 @@ cpdef update_ez_dispersive_multipole_B(int nx, int ny, int nz, int nthreads, int
"""
cdef int i, j, k, listIndex, p
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(0, nz):
listIndex = ID[2, i, j, k]
for p in range(0, maxpoles):
Tz[p, i, j, k] = Tz[p, i, j, k] - updatecoeffsdispersive[listIndex, 2 + (p * 3)] * Ez[i, j, k]
if nx == 1 or ny == 1:
pass
else:
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(0, nz):
listIndex = ID[2, i, j, k]
for p in range(0, maxpoles):
Tz[p, i, j, k] = Tz[p, i, j, k] - updatecoeffsdispersive[listIndex, 2 + (p * 3)] * Ez[i, j, k]
cpdef update_ez_dispersive_1pole_A(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updatecoeffsE, complextype_t[:, :] updatecoeffsdispersive, np.uint32_t[:, :, :, :] ID, complextype_t[:, :, :, :] Tz, floattype_t[:, :, :] Ez, floattype_t[:, :, :] Hx, floattype_t[:, :, :] Hy):
@@ -305,14 +344,17 @@ cpdef update_ez_dispersive_1pole_A(int nx, int ny, int nz, int nthreads, floatty
cdef int i, j, k, listIndex
cdef float phi = 0.0
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(0, nz):
listIndex = ID[2, i, j, k]
phi = updatecoeffsdispersive[listIndex, 0].real * Tz[0, i, j, k].real
Tz[0, i, j, k] = updatecoeffsdispersive[listIndex, 1] * Tz[0, i, j, k] + updatecoeffsdispersive[listIndex, 2] * Ez[i, j, k]
Ez[i, j, k] = updatecoeffsE[listIndex, 0] * Ez[i, j, k] + updatecoeffsE[listIndex, 1] * (Hy[i, j, k] - Hy[i - 1, j, k]) - updatecoeffsE[listIndex, 2] * (Hx[i, j, k] - Hx[i, j - 1, k]) - updatecoeffsE[listIndex, 4] * phi
if nx == 1 or ny == 1:
pass
else:
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(0, nz):
listIndex = ID[2, i, j, k]
phi = updatecoeffsdispersive[listIndex, 0].real * Tz[0, i, j, k].real
Tz[0, i, j, k] = updatecoeffsdispersive[listIndex, 1] * Tz[0, i, j, k] + updatecoeffsdispersive[listIndex, 2] * Ez[i, j, k]
Ez[i, j, k] = updatecoeffsE[listIndex, 0] * Ez[i, j, k] + updatecoeffsE[listIndex, 1] * (Hy[i, j, k] - Hy[i - 1, j, k]) - updatecoeffsE[listIndex, 2] * (Hx[i, j, k] - Hx[i, j - 1, k]) - updatecoeffsE[listIndex, 4] * phi
cpdef update_ez_dispersive_1pole_B(int nx, int ny, int nz, int nthreads, complextype_t[:, :] updatecoeffsdispersive, np.uint32_t[:, :, :, :] ID, complextype_t[:, :, :, :] Tz, floattype_t[:, :, :] Ez):
@@ -325,12 +367,15 @@ cpdef update_ez_dispersive_1pole_B(int nx, int ny, int nz, int nthreads, complex
"""
cdef int i, j, k, listIndex
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(0, nz):
listIndex = ID[2, i, j, k]
Tz[0, i, j, k] = Tz[0, i, j, k] - updatecoeffsdispersive[listIndex, 2] * Ez[i, j, k]
if nx == 1 or ny == 1:
pass
else:
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(0, nz):
listIndex = ID[2, i, j, k]
Tz[0, i, j, k] = Tz[0, i, j, k] - updatecoeffsdispersive[listIndex, 2] * Ez[i, j, k]
#########################################
@@ -347,11 +392,14 @@ cpdef update_hx(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updateco
cdef int i, j, k, listIndex
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(0, ny):
for k in range(0, nz):
listIndex = ID[3, i, j, k]
Hx[i, j, k] = updatecoeffsH[listIndex, 0] * Hx[i, j, k] - updatecoeffsH[listIndex, 2] * (Ez[i, j + 1, k] - Ez[i, j, k]) + updatecoeffsH[listIndex, 3] * (Ey[i, j, k + 1] - Ey[i, j, k])
if nx == 1:
pass
else:
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(0, ny):
for k in range(0, nz):
listIndex = ID[3, i, j, k]
Hx[i, j, k] = updatecoeffsH[listIndex, 0] * Hx[i, j, k] - updatecoeffsH[listIndex, 2] * (Ez[i, j + 1, k] - Ez[i, j, k]) + updatecoeffsH[listIndex, 3] * (Ey[i, j, k + 1] - Ey[i, j, k])
#########################################
@@ -368,11 +416,14 @@ cpdef update_hy(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updateco
cdef int i, j, k, listIndex
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(0, nz):
listIndex = ID[4, i, j, k]
Hy[i, j, k] = updatecoeffsH[listIndex, 0] * Hy[i, j, k] - updatecoeffsH[listIndex, 3] * (Ex[i, j, k + 1] - Ex[i, j, k]) + updatecoeffsH[listIndex, 1] * (Ez[i + 1, j, k] - Ez[i, j, k])
if ny == 1:
pass
else:
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(1, ny):
for k in range(0, nz):
listIndex = ID[4, i, j, k]
Hy[i, j, k] = updatecoeffsH[listIndex, 0] * Hy[i, j, k] - updatecoeffsH[listIndex, 3] * (Ex[i, j, k + 1] - Ex[i, j, k]) + updatecoeffsH[listIndex, 1] * (Ez[i + 1, j, k] - Ez[i, j, k])
#########################################
@@ -389,9 +440,12 @@ cpdef update_hz(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updateco
cdef int i, j, k, listIndex
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(0, ny):
for k in range(1, nz):
listIndex = ID[5, i, j, k]
Hz[i, j, k] = updatecoeffsH[listIndex, 0] * Hz[i, j, k] - updatecoeffsH[listIndex, 1] * (Ey[i + 1, j, k] - Ey[i, j, k]) + updatecoeffsH[listIndex, 2] * (Ex[i, j + 1, k] - Ex[i, j, k])
if nz == 1:
pass
else:
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
for j in range(0, ny):
for k in range(1, nz):
listIndex = ID[5, i, j, k]
Hz[i, j, k] = updatecoeffsH[listIndex, 0] * Hz[i, j, k] - updatecoeffsH[listIndex, 1] * (Ey[i + 1, j, k] - Ey[i, j, k]) + updatecoeffsH[listIndex, 2] * (Ex[i, j + 1, k] - Ex[i, j, k])

查看文件

@@ -1,99 +0,0 @@
# Copyright (C) 2015: The University of Edinburgh
# Authors: Craig Warren and Antonis Giannopoulos
#
# This file is part of gprMax.
#
# gprMax is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# gprMax is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
from setuptools import setup, Extension
#import py2exe, os, sys, re
import os, sys, re
from cx_Freeze import setup, Executable
#sys.argv.append('py2exe')
# Main package name
packagename = 'gprMax'
# Read version number from gprMax/gprMax.py
version = re.search('^__version__\s*=\s*\'(.*)\'',
open(os.path.join(packagename, 'gprMax.py')).read(),
re.M).group(1)
includes = []
include_files = []
excludes = []
packages = ['gprMax']
options = {
'build_exe': {
'path': [],
'includes': includes,
'include_files': include_files,
'excludes': excludes,
'packages': packages,
'optimize': 2,
}
}
executables = [
Executable('gprMax/gprMax.py'),
]
setup(name=packagename,
version=version,
author='Craig Warren and Antonis Giannopoulos',
url='http://www.gprmax.com',
description='Electromagnetic Modelling Software based on the Finite-Difference Time-Domain (FDTD) method',
license='GPLv3+',
classifiers=[
'Environment :: Console',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows :: Windows 7',
'Operating System :: POSIX :: Linux',
'Programming Language :: Cython',
'Programming Language :: Python :: 3 :: Only'
],
options=options,
executables=executables
)
#setup(name=packagename,
# version=version,
# author='Craig Warren and Antonis Giannopoulos',
# url='http://www.gprmax.com',
# description='Electromagnetic Modelling Software based on the Finite-Difference Time-Domain (FDTD) method',
# license='GPLv3+',
# classifiers=[
# 'Environment :: Console',
# 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
# 'Operating System :: MacOS :: MacOS X',
# 'Operating System :: Microsoft :: Windows :: Windows 7',
# 'Operating System :: POSIX :: Linux',
# 'Programming Language :: Cython',
# 'Programming Language :: Python :: 3 :: Only'
# ],
# console=[{'script':'gprMax\gprMax.py'}],
# options = {"py2exe": {"compressed": False,
# "optimize": 2,
# "includes": includes,
# "excludes": excludes,
# "packages": packages,
# "dll_excludes": dll_excludes,
# "bundle_files": 1,
# }
# },
# zipfile = None,
# )