-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathengineBase.py
More file actions
94 lines (67 loc) · 1.7 KB
/
Copy pathengineBase.py
File metadata and controls
94 lines (67 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import numpy as np
import copy
global ErrorImportCL
try:
import pyopencl as cl
ErrorImportCL = False
except ImportError:
ErrorImportCL = True
from .infoCL import *
class EngineBase(object):
def __init__(self, _simPack, _Platform):
self.simPack = _simPack
self.Platform = _Platform
self.n = 0
Simulation = self.simPack.Simulation
self.dt = np.float32(Simulation.dt)
self.dx = np.float32(Simulation.dx)
self.dtx = np.float32(self.dt/self.dx)
self.ddx = np.float32(1.0/self.dx)
self.dtdxx = self.dtx * self.ddx
if self.Platform == "OpenCL":
self.initCL()
self.materialSetup()
self.initFields()
self.staggeredProp()
self.applyBoundaries()
self.sourceSetup()
self.receiverSetup()
self.simSetup()
def setup_CL(self):
pass
def initCL(self):
device = self.simPack.Simulation.Device
platform = self.simPack.Simulation.Platform
my_device = None
try:
for platforms in cl.get_platforms():
if platforms.name == platform:
for devices in platforms.get_devices():
if cl.device_type.to_string(devices.type)== device:
my_device = devices
except:
platforms = cl.get_platforms()[0]
my_device = platforms.get_devices()[0]
if my_device is None:
platforms = cl.get_platforms()[0]
my_device = platforms.get_devices()[0]
print(my_device)
self.ctx = cl.Context([my_device])
self.queue = cl.CommandQueue(self.ctx)
self.mf = cl.mem_flags
def materialSetup(self):
pass
def initFields(self):
pass
def receiverSetup(self):
pass
def staggeredProp(self):
pass
def applyBoundaries(self):
pass
def sourceSetup(self):
pass
def simSetup(self):
pass
def initFieldsCL(self):
pass