你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 23:14:03 +08:00
Merge branch 'master' into config
这个提交包含在:
@@ -209,7 +209,8 @@ class PML(object):
|
||||
|
||||
self.CFS = G.cfs
|
||||
|
||||
self.initialise_field_arrays()
|
||||
if G.gpu is None:
|
||||
self.initialise_field_arrays()
|
||||
|
||||
def initialise_field_arrays(self):
|
||||
"""Initialise arrays to store fields in PML."""
|
||||
@@ -343,29 +344,38 @@ class PML(object):
|
||||
G (class): Grid class instance - holds essential parameters describing the model.
|
||||
"""
|
||||
|
||||
config.cuda['gpus'].bpg = (int(np.ceil(((self.EPhi1.shape[1] + 1)
|
||||
* (self.EPhi1.shape[2] + 1)
|
||||
* (self.EPhi1.shape[3] + 1))
|
||||
/ config.cuda['gpus'].tpb[0])), 1, 1)
|
||||
self.bpg = (int(np.ceil(((self.EPhi1_gpu.shape[1] + 1) * (self.EPhi1_gpu.shape[2] + 1) * (self.EPhi1_gpu.shape[3] + 1)) / G.tpb[0])), 1, 1)
|
||||
|
||||
def gpu_initialise_arrays(self):
|
||||
"""Initialise PML field and coefficient arrays on GPU."""
|
||||
|
||||
import pycuda.gpuarray as gpuarray
|
||||
|
||||
self.EPhi1_gpu = gpuarray.to_gpu(self.EPhi1)
|
||||
self.EPhi2_gpu = gpuarray.to_gpu(self.EPhi2)
|
||||
self.ERA_gpu = gpuarray.to_gpu(self.ERA)
|
||||
self.ERB_gpu = gpuarray.to_gpu(self.ERB)
|
||||
self.ERE_gpu = gpuarray.to_gpu(self.ERE)
|
||||
self.ERF_gpu = gpuarray.to_gpu(self.ERF)
|
||||
self.HPhi1_gpu = gpuarray.to_gpu(self.HPhi1)
|
||||
self.HPhi2_gpu = gpuarray.to_gpu(self.HPhi2)
|
||||
self.HRA_gpu = gpuarray.to_gpu(self.HRA)
|
||||
self.HRB_gpu = gpuarray.to_gpu(self.HRB)
|
||||
self.HRE_gpu = gpuarray.to_gpu(self.HRE)
|
||||
self.HRF_gpu = gpuarray.to_gpu(self.HRF)
|
||||
|
||||
if self.direction[0] == 'x':
|
||||
self.EPhi1_gpu = gpuarray.to_gpu(np.zeros((len(self.CFS), self.nx + 1, self.ny, self.nz + 1), dtype=floattype))
|
||||
self.EPhi2_gpu = gpuarray.to_gpu(np.zeros((len(self.CFS), self.nx + 1, self.ny + 1, self.nz), dtype=floattype))
|
||||
self.HPhi1_gpu = gpuarray.to_gpu(np.zeros((len(self.CFS), self.nx, self.ny + 1, self.nz), dtype=floattype))
|
||||
self.HPhi2_gpu = gpuarray.to_gpu(np.zeros((len(self.CFS), self.nx, self.ny, self.nz + 1), dtype=floattype))
|
||||
elif self.direction[0] == 'y':
|
||||
self.EPhi1_gpu = gpuarray.to_gpu(np.zeros((len(self.CFS), self.nx, self.ny + 1, self.nz + 1), dtype=floattype))
|
||||
self.EPhi2_gpu = gpuarray.to_gpu(np.zeros((len(self.CFS), self.nx + 1, self.ny + 1, self.nz), dtype=floattype))
|
||||
self.HPhi1_gpu = gpuarray.to_gpu(np.zeros((len(self.CFS), self.nx + 1, self.ny, self.nz), dtype=floattype))
|
||||
self.HPhi2_gpu = gpuarray.to_gpu(np.zeros((len(self.CFS), self.nx, self.ny, self.nz + 1), dtype=floattype))
|
||||
elif self.direction[0] == 'z':
|
||||
self.EPhi1_gpu = gpuarray.to_gpu(np.zeros((len(self.CFS), self.nx, self.ny + 1, self.nz + 1), dtype=floattype))
|
||||
self.EPhi2_gpu = gpuarray.to_gpu(np.zeros((len(self.CFS), self.nx + 1, self.ny, self.nz + 1), dtype=floattype))
|
||||
self.HPhi1_gpu = gpuarray.to_gpu(np.zeros((len(self.CFS), self.nx + 1, self.ny, self.nz), dtype=floattype))
|
||||
self.HPhi2_gpu = gpuarray.to_gpu(np.zeros((len(self.CFS), self.nx, self.ny + 1, self.nz), dtype=floattype))
|
||||
|
||||
def gpu_get_update_funcs(self, kernelselectric, kernelsmagnetic):
|
||||
"""Get update functions from PML kernels.
|
||||
|
||||
@@ -376,12 +386,8 @@ class PML(object):
|
||||
magnetic updates.
|
||||
"""
|
||||
|
||||
from pycuda.compiler import SourceModule
|
||||
|
||||
self.update_electric = kernelselectric.get_function('order' + str(len(self.CFS))
|
||||
+ '_' + self.direction)
|
||||
self.update_magnetic = kernelsmagnetic.get_function('order' + str(len(self.CFS))
|
||||
+ '_' + self.direction)
|
||||
self.update_electric_gpu = kernelselectric.get_function('order' + str(len(self.CFS)) + '_' + self.direction)
|
||||
self.update_magnetic_gpu = kernelsmagnetic.get_function('order' + str(len(self.CFS)) + '_' + self.direction)
|
||||
|
||||
def gpu_update_electric(self, G):
|
||||
"""This functions updates electric field components with the PML
|
||||
@@ -392,20 +398,7 @@ class PML(object):
|
||||
describing the model.
|
||||
"""
|
||||
|
||||
self.update_electric(np.int32(self.xs), np.int32(self.xf),
|
||||
np.int32(self.ys), np.int32(self.yf),
|
||||
np.int32(self.zs), np.int32(self.zf),
|
||||
np.int32(self.EPhi1.shape[1]), np.int32(self.EPhi1.shape[2]),
|
||||
np.int32(self.EPhi1.shape[3]), np.int32(self.EPhi2.shape[1]),
|
||||
np.int32(self.EPhi2.shape[2]), np.int32(self.EPhi2.shape[3]),
|
||||
np.int32(self.thickness), G.ID_gpu.gpudata,
|
||||
G.Ex_gpu.gpudata, G.Ey_gpu.gpudata, G.Ez_gpu.gpudata,
|
||||
G.Hx_gpu.gpudata, G.Hy_gpu.gpudata, G.Hz_gpu.gpudata,
|
||||
self.EPhi1_gpu.gpudata, self.EPhi2_gpu.gpudata,
|
||||
self.ERA_gpu.gpudata, self.ERB_gpu.gpudata,
|
||||
self.ERE_gpu.gpudata, self.ERF_gpu.gpudata,
|
||||
config.dtypes['float_or_double'](self.d),
|
||||
block=config.cuda['gpus'].tpb, grid=config.cuda['gpus'].bpg)
|
||||
self.update_electric_gpu(np.int32(self.xs), np.int32(self.xf), np.int32(self.ys), np.int32(self.yf), np.int32(self.zs), np.int32(self.zf), np.int32(self.EPhi1_gpu.shape[1]), np.int32(self.EPhi1_gpu.shape[2]), np.int32(self.EPhi1_gpu.shape[3]), np.int32(self.EPhi2_gpu.shape[1]), np.int32(self.EPhi2_gpu.shape[2]), np.int32(self.EPhi2_gpu.shape[3]), np.int32(self.thickness), G.ID_gpu.gpudata, G.Ex_gpu.gpudata, G.Ey_gpu.gpudata, G.Ez_gpu.gpudata, G.Hx_gpu.gpudata, G.Hy_gpu.gpudata, G.Hz_gpu.gpudata, self.EPhi1_gpu.gpudata, self.EPhi2_gpu.gpudata, self.ERA_gpu.gpudata, self.ERB_gpu.gpudata, self.ERE_gpu.gpudata, self.ERF_gpu.gpudata, floattype(self.d), block=G.tpb, grid=self.bpg)
|
||||
|
||||
def gpu_update_magnetic(self, G):
|
||||
"""This functions updates magnetic field components with the PML
|
||||
@@ -415,21 +408,8 @@ class PML(object):
|
||||
G (class): Grid class instance - holds essential parameters
|
||||
describing the model.
|
||||
"""
|
||||
self.update_magnetic_gpu(np.int32(self.xs), np.int32(self.xf), np.int32(self.ys), np.int32(self.yf), np.int32(self.zs), np.int32(self.zf), np.int32(self.HPhi1_gpu.shape[1]), np.int32(self.HPhi1_gpu.shape[2]), np.int32(self.HPhi1_gpu.shape[3]), np.int32(self.HPhi2_gpu.shape[1]), np.int32(self.HPhi2_gpu.shape[2]), np.int32(self.HPhi2_gpu.shape[3]), np.int32(self.thickness), G.ID_gpu.gpudata, G.Ex_gpu.gpudata, G.Ey_gpu.gpudata, G.Ez_gpu.gpudata, G.Hx_gpu.gpudata, G.Hy_gpu.gpudata, G.Hz_gpu.gpudata, self.HPhi1_gpu.gpudata, self.HPhi2_gpu.gpudata, self.HRA_gpu.gpudata, self.HRB_gpu.gpudata, self.HRE_gpu.gpudata, self.HRF_gpu.gpudata, floattype(self.d), block=G.tpb, grid=self.bpg)
|
||||
|
||||
self.update_magnetic(np.int32(self.xs), np.int32(self.xf),
|
||||
np.int32(self.ys), np.int32(self.yf),
|
||||
np.int32(self.zs), np.int32(self.zf),
|
||||
np.int32(self.HPhi1.shape[1]), np.int32(self.HPhi1.shape[2]),
|
||||
np.int32(self.HPhi1.shape[3]), np.int32(self.HPhi2.shape[1]),
|
||||
np.int32(self.HPhi2.shape[2]), np.int32(self.HPhi2.shape[3]),
|
||||
np.int32(self.thickness), G.ID_gpu.gpudata,
|
||||
G.Ex_gpu.gpudata, G.Ey_gpu.gpudata, G.Ez_gpu.gpudata,
|
||||
G.Hx_gpu.gpudata, G.Hy_gpu.gpudata, G.Hz_gpu.gpudata,
|
||||
self.HPhi1_gpu.gpudata, self.HPhi2_gpu.gpudata,
|
||||
self.HRA_gpu.gpudata, self.HRB_gpu.gpudata,
|
||||
self.HRE_gpu.gpudata, self.HRF_gpu.gpudata,
|
||||
config.dtypes['float_or_double'](self.d),
|
||||
block=config.cuda['gpus'].tpb, grid=config.cuda['gpus'].bpg)
|
||||
|
||||
def pml_information(G):
|
||||
# no pml
|
||||
|
在新工单中引用
屏蔽一个用户