fix hhd d_gpu bug if cuda=false
This commit is contained in:
+10
-6
@@ -75,7 +75,14 @@ except ImportError:
|
||||
class nHHD(object):
|
||||
|
||||
# constructor
|
||||
def __init__(self, **kwargs):
|
||||
def __init__(self, cuda=True, **kwargs):
|
||||
self.cuda = cuda
|
||||
if self.cuda and CUPY_AVAILABLE:
|
||||
self.stream1 = cp.cuda.Stream()
|
||||
self.stream2 = cp.cuda.Stream()
|
||||
else:
|
||||
self.stream1 = None
|
||||
self.stream2 = None
|
||||
|
||||
args = kwargs.keys()
|
||||
|
||||
@@ -104,9 +111,6 @@ class nHHD(object):
|
||||
raise ValueError("nHHD Solver works only for 2 and 3 dimensions")
|
||||
|
||||
self.psolver.prepare(False)
|
||||
if CUPY_AVAILABLE:
|
||||
self.stream1 = cp.cuda.Stream()
|
||||
self.stream2 = cp.cuda.Stream()
|
||||
|
||||
# create the 3-component decomposition
|
||||
def decompose(self, vfield, verbose=0):
|
||||
@@ -447,12 +451,12 @@ class nHHD(object):
|
||||
cp.get_default_memory_pool().free_all_blocks()
|
||||
|
||||
def get_shear(self):
|
||||
if not CUPY_AVAILABLE:
|
||||
if not self.cuda or not CUPY_AVAILABLE:
|
||||
return self.h
|
||||
return cp.asnumpy(self._h_gpu)
|
||||
|
||||
def get_normal(self):
|
||||
if not CUPY_AVAILABLE:
|
||||
if not self.cuda or not CUPY_AVAILABLE:
|
||||
return self.d
|
||||
return cp.asnumpy(self._d_gpu)
|
||||
|
||||
|
||||
@@ -228,7 +228,7 @@ class Sensor:
|
||||
|
||||
# Initialize HHD solver
|
||||
if self.__hhd is None:
|
||||
self.__hhd = nHHD(grid=flow.shape[:2], spacings=(18, 18))
|
||||
self.__hhd = nHHD(cuda=self.cuda, Qgrid=flow.shape[:2], spacings=(18, 18))
|
||||
|
||||
# Force computation
|
||||
if self.cuda and self.CUPY_AVAILABLE:
|
||||
|
||||
Reference in New Issue
Block a user