fix import

This commit is contained in:
bluepulsar
2026-02-16 17:02:58 +08:00
parent 46bf5bdd1c
commit 88d75f63a3
2 changed files with 29 additions and 28 deletions
+24 -23
View File
@@ -30,9 +30,9 @@ from scipy import signal, spatial
# from .UnstructuredGrid import UnstructuredGrid
# import matplotlib.pyplot as plt
# Try to import CuPy for GPU acceleration
try:
import cupy as cp
import cupyx.scipy.signal as cp_signal
CUPY_AVAILABLE = True
# Try to import CuPy streams for parallel execution
@@ -65,6 +65,7 @@ try:
except ImportError:
cp = None
cp_signal = None
CUPY_AVAILABLE = False
STREAMS_AVAILABLE = False
KERNEL_AVAILABLE = False
@@ -130,14 +131,14 @@ class nHHD(object):
print( 'div =', self.div.shape, self.div.min(), self.div.max())
print( 'curlw =', self.curlw.shape, self.curlw.min(), self.curlw.max())
# compute potentials
self.nD = self.psolver.solve_gpu(self.div, verbose > 0) #1)
if verbose > 0:
print( 'nD =', self.nD.shape, self.nD.min(), self.nD.max())
# # compute potentials
# self.nD = self.psolver.solve_gpu(self.div, verbose > 0) #1)
# if verbose > 0:
# print( 'nD =', self.nD.shape, self.nD.min(), self.nD.max())
self.nRu = self.psolver.solve_gpu(self.curlw, verbose > 0) #1)
if verbose > 0:
print( 'nR =', self.nRu.shape, self.nRu.min(), self.nRu.max())
# self.nRu = self.psolver.solve_gpu(self.curlw, verbose > 0) #1)
# if verbose > 0:
# print( 'nR =', self.nRu.shape, self.nRu.min(), self.nRu.max())
# compute fields as gradients of potentials
self.d = self.mesh.gradient(self.nD)
@@ -398,8 +399,8 @@ class nHHD(object):
nRu_gpu = self._nRu_gpu
# Use reduction kernels for better performance
# Compute Sn using L1 norm (sum of absolute values)
Sn = float(cp.linalg.norm(d_gpu.ravel(), ord=1))
# Compute Sn as L1 sum directly on GPU (faster than linalg.norm for this case)
Sn = float(cp.sum(cp.abs(d_gpu)))
# Compute Stx, Sty
Stx = float(cp.sum(h_gpu[:, :, 0]))
@@ -881,19 +882,19 @@ class StructuredGrid(object):
# --------------------------------------------------------------------------
import numpy
from scipy import signal, spatial
# from .timer import Timer
# import numpy
# from scipy import signal, spatial
# # from .timer import Timer
# Try to import CuPy for GPU acceleration
try:
import cupy as cp
import cupyx.scipy.signal as cp_signal
CUPY_AVAILABLE = True
except ImportError:
cp = None
cp_signal = None
CUPY_AVAILABLE = False
# # Try to import CuPy for GPU acceleration
# try:
# import cupy as cp
# import cupyx.scipy.signal as cp_signal
# CUPY_AVAILABLE = True
# except ImportError:
# cp = None
# cp_signal = None
# CUPY_AVAILABLE = False
'''
@@ -1322,7 +1323,7 @@ class PoissonSolver(object):
p_gpu *= self._gpu_cache['gdx_prod']
return p_gpu # Return CuPy array
# def solve_gpu_batch(self, f_list, verbose=False):
# """