你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
Performance improvements to Cython code.
这个提交包含在:
@@ -25,7 +25,7 @@ from gprMax.constants cimport floattype_t, complextype_t
|
||||
#########################################
|
||||
# Electric field updates - Ex component #
|
||||
#########################################
|
||||
cpdef update_ex(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updatecoeffsE, np.uint32_t[:, :, :, :] ID, floattype_t[:, :, :] Ex, floattype_t[:, :, :] Hy, floattype_t[:, :, :] Hz):
|
||||
cpdef void update_ex(int nx, int ny, int nz, int nthreads, floattype_t[:, ::1] updatecoeffsE, np.uint32_t[:, :, :, ::1] ID, floattype_t[:, :, ::1] Ex, floattype_t[:, :, ::1] Hy, floattype_t[:, :, ::1] Hz):
|
||||
"""This function updates the Ex field components.
|
||||
|
||||
Args:
|
||||
@@ -34,19 +34,20 @@ cpdef update_ex(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updateco
|
||||
updatecoeffs, ID, E, H (memoryviews): Access to update coeffients, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex
|
||||
cdef Py_ssize_t i, j, k
|
||||
cdef int material
|
||||
|
||||
if ny == 1 or nz == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(0, nx, nogil=True, schedule='static', 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])
|
||||
material = ID[0, i, j, k]
|
||||
Ex[i, j, k] = updatecoeffsE[material, 0] * Ex[i, j, k] + updatecoeffsE[material, 2] * (Hz[i, j, k] - Hz[i, j - 1, k]) - updatecoeffsE[material, 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):
|
||||
cpdef void update_ex_dispersive_multipole_A(int nx, int ny, int nz, int nthreads, int maxpoles, floattype_t[:, ::1] updatecoeffsE, complextype_t[:, ::1] updatecoeffsdispersive, np.uint32_t[:, :, :, ::1] ID, complextype_t[:, :, :, ::1] Tx, floattype_t[:, :, ::1] Ex, floattype_t[:, :, ::1] Hy, floattype_t[:, :, ::1] Hz):
|
||||
"""This function updates the Ex field components when dispersive materials (with multiple poles) are present.
|
||||
|
||||
Args:
|
||||
@@ -56,23 +57,24 @@ cpdef update_ex_dispersive_multipole_A(int nx, int ny, int nz, int nthreads, int
|
||||
updatecoeffs, T, ID, E, H (memoryviews): Access to update coeffients, temporary, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex, p
|
||||
cdef Py_ssize_t i, j, k, p
|
||||
cdef int material
|
||||
cdef float phi = 0.0
|
||||
|
||||
if ny == 1 or nz == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(0, nx, nogil=True, schedule='static', num_threads=nthreads):
|
||||
for j in range(1, ny):
|
||||
for k in range(1, nz):
|
||||
listIndex = ID[0, i, j, k]
|
||||
material = 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
|
||||
phi = phi + updatecoeffsdispersive[material, p * 3].real * Tx[p, i, j, k].real
|
||||
Tx[p, i, j, k] = updatecoeffsdispersive[material, 1 + (p * 3)] * Tx[p, i, j, k] + updatecoeffsdispersive[material, 2 + (p * 3)] * Ex[i, j, k]
|
||||
Ex[i, j, k] = updatecoeffsE[material, 0] * Ex[i, j, k] + updatecoeffsE[material, 2] * (Hz[i, j, k] - Hz[i, j - 1, k]) - updatecoeffsE[material, 3] * (Hy[i, j, k] - Hy[i, j, k - 1]) - updatecoeffsE[material, 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):
|
||||
cpdef void update_ex_dispersive_multipole_B(int nx, int ny, int nz, int nthreads, int maxpoles, complextype_t[:, ::1] updatecoeffsdispersive, np.uint32_t[:, :, :, ::1] ID, complextype_t[:, :, :, ::1] Tx, floattype_t[:, :, ::1] Ex):
|
||||
"""This function updates the Ex field components when dispersive materials (with multiple poles) are present.
|
||||
|
||||
Args:
|
||||
@@ -82,20 +84,21 @@ cpdef update_ex_dispersive_multipole_B(int nx, int ny, int nz, int nthreads, int
|
||||
updatecoeffs, T, ID, E (memoryviews): Access to update coeffients, temporary, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex, p
|
||||
cdef Py_ssize_t i, j, k, p
|
||||
cdef int material
|
||||
|
||||
if ny == 1 or nz == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(0, nx, nogil=True, schedule='static', num_threads=nthreads):
|
||||
for j in range(1, ny):
|
||||
for k in range(1, nz):
|
||||
listIndex = ID[0, i, j, k]
|
||||
material = 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]
|
||||
Tx[p, i, j, k] = Tx[p, i, j, k] - updatecoeffsdispersive[material, 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):
|
||||
cpdef void update_ex_dispersive_1pole_A(int nx, int ny, int nz, int nthreads, floattype_t[:, ::1] updatecoeffsE, complextype_t[:, ::1] updatecoeffsdispersive, np.uint32_t[:, :, :, ::1] ID, complextype_t[:, :, :, ::1] Tx, floattype_t[:, :, ::1] Ex, floattype_t[:, :, ::1] Hy, floattype_t[:, :, ::1] Hz):
|
||||
"""This function updates the Ex field components when dispersive materials (with 1 pole) are present.
|
||||
|
||||
Args:
|
||||
@@ -104,22 +107,23 @@ cpdef update_ex_dispersive_1pole_A(int nx, int ny, int nz, int nthreads, floatty
|
||||
updatecoeffs, T, ID, E, H (memoryviews): Access to update coeffients, temporary, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex
|
||||
cdef Py_ssize_t i, j, k
|
||||
cdef int material
|
||||
cdef float phi = 0.0
|
||||
|
||||
if ny == 1 or nz == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(0, nx, nogil=True, schedule='static', 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
|
||||
material = ID[0, i, j, k]
|
||||
phi = updatecoeffsdispersive[material, 0].real * Tx[0, i, j, k].real
|
||||
Tx[0, i, j, k] = updatecoeffsdispersive[material, 1] * Tx[0, i, j, k] + updatecoeffsdispersive[material, 2] * Ex[i, j, k]
|
||||
Ex[i, j, k] = updatecoeffsE[material, 0] * Ex[i, j, k] + updatecoeffsE[material, 2] * (Hz[i, j, k] - Hz[i, j - 1, k]) - updatecoeffsE[material, 3] * (Hy[i, j, k] - Hy[i, j, k - 1]) - updatecoeffsE[material, 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):
|
||||
cpdef void update_ex_dispersive_1pole_B(int nx, int ny, int nz, int nthreads, complextype_t[:, ::1] updatecoeffsdispersive, np.uint32_t[:, :, :, ::1] ID, complextype_t[:, :, :, ::1] Tx, floattype_t[:, :, ::1] Ex):
|
||||
"""This function updates the Ex field components when dispersive materials (with 1 pole) are present.
|
||||
|
||||
Args:
|
||||
@@ -128,22 +132,23 @@ cpdef update_ex_dispersive_1pole_B(int nx, int ny, int nz, int nthreads, complex
|
||||
updatecoeffs, T, ID, E (memoryviews): Access to update coeffients, temporary, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex
|
||||
cdef Py_ssize_t i, j, k
|
||||
cdef int material
|
||||
|
||||
if ny == 1 or nz == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(0, nx, nogil=True, schedule='static', 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]
|
||||
material = ID[0, i, j, k]
|
||||
Tx[0, i, j, k] = Tx[0, i, j, k] - updatecoeffsdispersive[material, 2] * Ex[i, j, k]
|
||||
|
||||
|
||||
#########################################
|
||||
# Electric field updates - Ey component #
|
||||
#########################################
|
||||
cpdef update_ey(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updatecoeffsE, np.uint32_t[:, :, :, :] ID, floattype_t[:, :, :] Ey, floattype_t[:, :, :] Hx, floattype_t[:, :, :] Hz):
|
||||
cpdef void update_ey(int nx, int ny, int nz, int nthreads, floattype_t[:, ::1] updatecoeffsE, np.uint32_t[:, :, :, ::1] ID, floattype_t[:, :, ::1] Ey, floattype_t[:, :, ::1] Hx, floattype_t[:, :, ::1] Hz):
|
||||
"""This function updates the Ey field components.
|
||||
|
||||
Args:
|
||||
@@ -152,19 +157,20 @@ cpdef update_ey(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updateco
|
||||
updatecoeffs, ID, E, H (memoryviews): Access to update coeffients, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex
|
||||
cdef Py_ssize_t i, j, k
|
||||
cdef int material
|
||||
|
||||
if nx == 1 or nz == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(1, nx, nogil=True, schedule='static', 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])
|
||||
material = ID[1, i, j, k]
|
||||
Ey[i, j, k] = updatecoeffsE[material, 0] * Ey[i, j, k] + updatecoeffsE[material, 3] * (Hx[i, j, k] - Hx[i, j, k - 1]) - updatecoeffsE[material, 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):
|
||||
cpdef void update_ey_dispersive_multipole_A(int nx, int ny, int nz, int nthreads, int maxpoles, floattype_t[:, ::1] updatecoeffsE, complextype_t[:, ::1] updatecoeffsdispersive, np.uint32_t[:, :, :, ::1] ID, complextype_t[:, :, :, ::1] Ty, floattype_t[:, :, ::1] Ey, floattype_t[:, :, ::1] Hx, floattype_t[:, :, ::1] Hz):
|
||||
"""This function updates the Ey field components when dispersive materials (with multiple poles) are present.
|
||||
|
||||
Args:
|
||||
@@ -174,24 +180,25 @@ cpdef update_ey_dispersive_multipole_A(int nx, int ny, int nz, int nthreads, int
|
||||
updatecoeffs, T, ID, E, H (memoryviews): Access to update coeffients, temporary, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex, p
|
||||
cdef Py_ssize_t i, j, k, p
|
||||
cdef int material
|
||||
cdef float phi = 0.0
|
||||
|
||||
if nx == 1 or nz == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(1, nx, nogil=True, schedule='static', num_threads=nthreads):
|
||||
for j in range(0, ny):
|
||||
for k in range(1, nz):
|
||||
listIndex = ID[1, i, j, k]
|
||||
material = 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
|
||||
phi = phi + updatecoeffsdispersive[material, p * 3].real * Ty[p, i, j, k].real
|
||||
Ty[p, i, j, k] = updatecoeffsdispersive[material, 1 + (p * 3)] * Ty[p, i, j, k] + updatecoeffsdispersive[material, 2 + (p * 3)] * Ey[i, j, k]
|
||||
Ey[i, j, k] = updatecoeffsE[material, 0] * Ey[i, j, k] + updatecoeffsE[material, 3] * (Hx[i, j, k] - Hx[i, j, k - 1]) - updatecoeffsE[material, 1] * (Hz[i, j, k] - Hz[i - 1, j, k]) - updatecoeffsE[material, 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):
|
||||
cpdef void update_ey_dispersive_multipole_B(int nx, int ny, int nz, int nthreads, int maxpoles, complextype_t[:, ::1] updatecoeffsdispersive, np.uint32_t[:, :, :, ::1] ID, complextype_t[:, :, :, ::1] Ty, floattype_t[:, :, ::1] Ey):
|
||||
"""This function updates the Ey field components when dispersive materials (with multiple poles) are present.
|
||||
|
||||
Args:
|
||||
@@ -201,20 +208,21 @@ cpdef update_ey_dispersive_multipole_B(int nx, int ny, int nz, int nthreads, int
|
||||
updatecoeffs, T, ID, E, H (memoryviews): Access to update coeffients, temporary, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex, p
|
||||
cdef Py_ssize_t i, j, k, p
|
||||
cdef int material
|
||||
|
||||
if nx == 1 or nz == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(1, nx, nogil=True, schedule='static', num_threads=nthreads):
|
||||
for j in range(0, ny):
|
||||
for k in range(1, nz):
|
||||
listIndex = ID[1, i, j, k]
|
||||
material = 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]
|
||||
Ty[p, i, j, k] = Ty[p, i, j, k] - updatecoeffsdispersive[material, 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):
|
||||
cpdef void update_ey_dispersive_1pole_A(int nx, int ny, int nz, int nthreads, floattype_t[:, ::1] updatecoeffsE, complextype_t[:, ::1] updatecoeffsdispersive, np.uint32_t[:, :, :, ::1] ID, complextype_t[:, :, :, ::1] Ty, floattype_t[:, :, ::1] Ey, floattype_t[:, :, ::1] Hx, floattype_t[:, :, ::1] Hz):
|
||||
"""This function updates the Ey field components when dispersive materials (with 1 pole) are present.
|
||||
|
||||
Args:
|
||||
@@ -223,22 +231,23 @@ cpdef update_ey_dispersive_1pole_A(int nx, int ny, int nz, int nthreads, floatty
|
||||
updatecoeffs, T, ID, E, H (memoryviews): Access to update coeffients, temporary, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex
|
||||
cdef Py_ssize_t i, j, k
|
||||
cdef int material
|
||||
cdef float phi = 0.0
|
||||
|
||||
if nx == 1 or nz == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(1, nx, nogil=True, schedule='static', 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
|
||||
material = ID[1, i, j, k]
|
||||
phi = updatecoeffsdispersive[material, 0].real * Ty[0, i, j, k].real
|
||||
Ty[0, i, j, k] = updatecoeffsdispersive[material, 1] * Ty[0, i, j, k] + updatecoeffsdispersive[material, 2] * Ey[i, j, k]
|
||||
Ey[i, j, k] = updatecoeffsE[material, 0] * Ey[i, j, k] + updatecoeffsE[material, 3] * (Hx[i, j, k] - Hx[i, j, k - 1]) - updatecoeffsE[material, 1] * (Hz[i, j, k] - Hz[i - 1, j, k]) - updatecoeffsE[material, 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):
|
||||
cpdef void update_ey_dispersive_1pole_B(int nx, int ny, int nz, int nthreads, complextype_t[:, ::1] updatecoeffsdispersive, np.uint32_t[:, :, :, ::1] ID, complextype_t[:, :, :, ::1] Ty, floattype_t[:, :, ::1] Ey):
|
||||
"""This function updates the Ey field components when dispersive materials (with 1 pole) are present.
|
||||
|
||||
Args:
|
||||
@@ -247,22 +256,23 @@ cpdef update_ey_dispersive_1pole_B(int nx, int ny, int nz, int nthreads, complex
|
||||
updatecoeffs, T, ID, E (memoryviews): Access to update coeffients, temporary, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex
|
||||
cdef Py_ssize_t i, j, k
|
||||
cdef int material
|
||||
|
||||
if nx == 1 or nz == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(1, nx, nogil=True, schedule='static', 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]
|
||||
material = ID[1, i, j, k]
|
||||
Ty[0, i, j, k] = Ty[0, i, j, k] - updatecoeffsdispersive[material, 2] * Ey[i, j, k]
|
||||
|
||||
|
||||
#########################################
|
||||
# Electric field updates - Ez component #
|
||||
#########################################
|
||||
cpdef update_ez(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updatecoeffsE, np.uint32_t[:, :, :, :] ID, floattype_t[:, :, :] Ez, floattype_t[:, :, :] Hx, floattype_t[:, :, :] Hy):
|
||||
cpdef void update_ez(int nx, int ny, int nz, int nthreads, floattype_t[:, ::1] updatecoeffsE, np.uint32_t[:, :, :, ::1] ID, floattype_t[:, :, ::1] Ez, floattype_t[:, :, ::1] Hx, floattype_t[:, :, ::1] Hy):
|
||||
"""This function updates the Ez field components.
|
||||
|
||||
Args:
|
||||
@@ -271,19 +281,20 @@ cpdef update_ez(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updateco
|
||||
updatecoeffs, ID, E, H (memoryviews): Access to update coeffients, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex
|
||||
cdef Py_ssize_t i, j, k
|
||||
cdef int material
|
||||
|
||||
if nx == 1 or ny == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(1, nx, nogil=True, schedule='static', 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])
|
||||
material = ID[2, i, j, k]
|
||||
Ez[i, j, k] = updatecoeffsE[material, 0] * Ez[i, j, k] + updatecoeffsE[material, 1] * (Hy[i, j, k] - Hy[i - 1, j, k]) - updatecoeffsE[material, 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):
|
||||
cpdef void update_ez_dispersive_multipole_A(int nx, int ny, int nz, int nthreads, int maxpoles, floattype_t[:, ::1] updatecoeffsE, complextype_t[:, ::1] updatecoeffsdispersive, np.uint32_t[:, :, :, ::1] ID, complextype_t[:, :, :, ::1] Tz, floattype_t[:, :, ::1] Ez, floattype_t[:, :, ::1] Hx, floattype_t[:, :, ::1] Hy):
|
||||
"""This function updates the Ez field components when dispersive materials (with multiple poles) are present.
|
||||
|
||||
Args:
|
||||
@@ -293,24 +304,25 @@ cpdef update_ez_dispersive_multipole_A(int nx, int ny, int nz, int nthreads, int
|
||||
updatecoeffs, T, ID, E, H (memoryviews): Access to update coeffients, temporary, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex, p
|
||||
cdef Py_ssize_t i, j, k, p
|
||||
cdef int material
|
||||
cdef float phi = 0.0
|
||||
|
||||
if nx == 1 or ny == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(1, nx, nogil=True, schedule='static', num_threads=nthreads):
|
||||
for j in range(1, ny):
|
||||
for k in range(0, nz):
|
||||
listIndex = ID[2, i, j, k]
|
||||
material = 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
|
||||
phi = phi + updatecoeffsdispersive[material, p * 3].real * Tz[p, i, j, k].real
|
||||
Tz[p, i, j, k] = updatecoeffsdispersive[material, 1 + (p * 3)] * Tz[p, i, j, k] + updatecoeffsdispersive[material, 2 + (p * 3)] * Ez[i, j, k]
|
||||
Ez[i, j, k] = updatecoeffsE[material, 0] * Ez[i, j, k] + updatecoeffsE[material, 1] * (Hy[i, j, k] - Hy[i - 1, j, k]) - updatecoeffsE[material, 2] * (Hx[i, j, k] - Hx[i, j - 1, k]) - updatecoeffsE[material, 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):
|
||||
cpdef void update_ez_dispersive_multipole_B(int nx, int ny, int nz, int nthreads, int maxpoles, complextype_t[:, ::1] updatecoeffsdispersive, np.uint32_t[:, :, :, ::1] ID, complextype_t[:, :, :, ::1] Tz, floattype_t[:, :, ::1] Ez):
|
||||
"""This function updates the Ez field components when dispersive materials (with multiple poles) are present.
|
||||
|
||||
Args:
|
||||
@@ -320,20 +332,21 @@ cpdef update_ez_dispersive_multipole_B(int nx, int ny, int nz, int nthreads, int
|
||||
updatecoeffs, T, ID, E (memoryviews): Access to update coeffients, temporary, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex, p
|
||||
cdef Py_ssize_t i, j, k, p
|
||||
cdef int material
|
||||
|
||||
if nx == 1 or ny == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(1, nx, nogil=True, schedule='static', num_threads=nthreads):
|
||||
for j in range(1, ny):
|
||||
for k in range(0, nz):
|
||||
listIndex = ID[2, i, j, k]
|
||||
material = 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]
|
||||
Tz[p, i, j, k] = Tz[p, i, j, k] - updatecoeffsdispersive[material, 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):
|
||||
cpdef void update_ez_dispersive_1pole_A(int nx, int ny, int nz, int nthreads, floattype_t[:, ::1] updatecoeffsE, complextype_t[:, ::1] updatecoeffsdispersive, np.uint32_t[:, :, :, ::1] ID, complextype_t[:, :, :, ::1] Tz, floattype_t[:, :, ::1] Ez, floattype_t[:, :, ::1] Hx, floattype_t[:, :, ::1] Hy):
|
||||
"""This function updates the Ez field components when dispersive materials (with 1 pole) are present.
|
||||
|
||||
Args:
|
||||
@@ -342,22 +355,23 @@ cpdef update_ez_dispersive_1pole_A(int nx, int ny, int nz, int nthreads, floatty
|
||||
updatecoeffs, T, ID, E, H (memoryviews): Access to update coeffients, temporary, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex
|
||||
cdef Py_ssize_t i, j, k
|
||||
cdef int material
|
||||
cdef float phi = 0.0
|
||||
|
||||
if nx == 1 or ny == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(1, nx, nogil=True, schedule='static', 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
|
||||
material = ID[2, i, j, k]
|
||||
phi = updatecoeffsdispersive[material, 0].real * Tz[0, i, j, k].real
|
||||
Tz[0, i, j, k] = updatecoeffsdispersive[material, 1] * Tz[0, i, j, k] + updatecoeffsdispersive[material, 2] * Ez[i, j, k]
|
||||
Ez[i, j, k] = updatecoeffsE[material, 0] * Ez[i, j, k] + updatecoeffsE[material, 1] * (Hy[i, j, k] - Hy[i - 1, j, k]) - updatecoeffsE[material, 2] * (Hx[i, j, k] - Hx[i, j - 1, k]) - updatecoeffsE[material, 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):
|
||||
cpdef void update_ez_dispersive_1pole_B(int nx, int ny, int nz, int nthreads, complextype_t[:, ::1] updatecoeffsdispersive, np.uint32_t[:, :, :, ::1] ID, complextype_t[:, :, :, ::1] Tz, floattype_t[:, :, ::1] Ez):
|
||||
"""This function updates the Ez field components when dispersive materials (with 1 pole) are present.
|
||||
|
||||
Args:
|
||||
@@ -366,22 +380,23 @@ cpdef update_ez_dispersive_1pole_B(int nx, int ny, int nz, int nthreads, complex
|
||||
updatecoeffs, T, ID, E (memoryviews): Access to update coeffients, temporary, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex
|
||||
cdef Py_ssize_t i, j, k
|
||||
cdef int material
|
||||
|
||||
if nx == 1 or ny == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(1, nx, nogil=True, schedule='static', 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]
|
||||
material = ID[2, i, j, k]
|
||||
Tz[0, i, j, k] = Tz[0, i, j, k] - updatecoeffsdispersive[material, 2] * Ez[i, j, k]
|
||||
|
||||
|
||||
#########################################
|
||||
# Magnetic field updates - Hx component #
|
||||
#########################################
|
||||
cpdef update_hx(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updatecoeffsH, np.uint32_t[:, :, :, :] ID, floattype_t[:, :, :] Hx, floattype_t[:, :, :] Ey, floattype_t[:, :, :] Ez):
|
||||
cpdef void update_hx(int nx, int ny, int nz, int nthreads, floattype_t[:, ::1] updatecoeffsH, np.uint32_t[:, :, :, ::1] ID, floattype_t[:, :, ::1] Hx, floattype_t[:, :, ::1] Ey, floattype_t[:, :, ::1] Ez):
|
||||
"""This function updates the Hx field components.
|
||||
|
||||
Args:
|
||||
@@ -390,22 +405,23 @@ cpdef update_hx(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updateco
|
||||
updatecoeffs, ID, E, H (memoryviews): Access to update coeffients, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex
|
||||
cdef Py_ssize_t i, j, k
|
||||
cdef int material
|
||||
|
||||
if nx == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(1, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(1, nx, nogil=True, schedule='static', 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])
|
||||
material = ID[3, i, j, k]
|
||||
Hx[i, j, k] = updatecoeffsH[material, 0] * Hx[i, j, k] - updatecoeffsH[material, 2] * (Ez[i, j + 1, k] - Ez[i, j, k]) + updatecoeffsH[material, 3] * (Ey[i, j, k + 1] - Ey[i, j, k])
|
||||
|
||||
|
||||
#########################################
|
||||
# Magnetic field updates - Hy component #
|
||||
#########################################
|
||||
cpdef update_hy(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updatecoeffsH, np.uint32_t[:, :, :, :] ID, floattype_t[:, :, :] Hy, floattype_t[:, :, :] Ex, floattype_t[:, :, :] Ez):
|
||||
cpdef void update_hy(int nx, int ny, int nz, int nthreads, floattype_t[:, ::1] updatecoeffsH, np.uint32_t[:, :, :, ::1] ID, floattype_t[:, :, ::1] Hy, floattype_t[:, :, ::1] Ex, floattype_t[:, :, ::1] Ez):
|
||||
"""This function updates the Hy field components.
|
||||
|
||||
Args:
|
||||
@@ -414,22 +430,23 @@ cpdef update_hy(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updateco
|
||||
updatecoeffs, ID, E, H (memoryviews): Access to update coeffients, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex
|
||||
cdef Py_ssize_t i, j, k
|
||||
cdef int material
|
||||
|
||||
if ny == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(0, nx, nogil=True, schedule='static', 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])
|
||||
material = ID[4, i, j, k]
|
||||
Hy[i, j, k] = updatecoeffsH[material, 0] * Hy[i, j, k] - updatecoeffsH[material, 3] * (Ex[i, j, k + 1] - Ex[i, j, k]) + updatecoeffsH[material, 1] * (Ez[i + 1, j, k] - Ez[i, j, k])
|
||||
|
||||
|
||||
#########################################
|
||||
# Magnetic field updates - Hz component #
|
||||
#########################################
|
||||
cpdef update_hz(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updatecoeffsH, np.uint32_t[:, :, :, :] ID, floattype_t[:, :, :] Hz, floattype_t[:, :, :] Ex, floattype_t[:, :, :] Ey):
|
||||
cpdef void update_hz(int nx, int ny, int nz, int nthreads, floattype_t[:, ::1] updatecoeffsH, np.uint32_t[:, :, :, ::1] ID, floattype_t[:, :, ::1] Hz, floattype_t[:, :, ::1] Ex, floattype_t[:, :, ::1] Ey):
|
||||
"""This function updates the Hz field components.
|
||||
|
||||
Args:
|
||||
@@ -438,14 +455,15 @@ cpdef update_hz(int nx, int ny, int nz, int nthreads, floattype_t[:, :] updateco
|
||||
updatecoeffs, ID, E, H (memoryviews): Access to update coeffients, ID and field component arrays
|
||||
"""
|
||||
|
||||
cdef int i, j, k, listIndex
|
||||
cdef Py_ssize_t i, j, k
|
||||
cdef int material
|
||||
|
||||
if nz == 1:
|
||||
pass
|
||||
else:
|
||||
for i in prange(0, nx, nogil=True, schedule='static', chunksize=1, num_threads=nthreads):
|
||||
for i in prange(0, nx, nogil=True, schedule='static', 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])
|
||||
material = ID[5, i, j, k]
|
||||
Hz[i, j, k] = updatecoeffsH[material, 0] * Hz[i, j, k] - updatecoeffsH[material, 1] * (Ey[i + 1, j, k] - Ey[i, j, k]) + updatecoeffsH[material, 2] * (Ex[i, j + 1, k] - Ex[i, j, k])
|
||||
|
||||
|
在新工单中引用
屏蔽一个用户