Skip to content
Snippets Groups Projects
Verified Commit aa7080ce authored by Paul Dechamps's avatar Paul Dechamps :speech_balloon:
Browse files

(fix) If scipy does not have splrep, we cannot use it

parent 6e2e2c87
No related branches found
No related tags found
No related merge requests found
Pipeline #52697 passed
...@@ -5,8 +5,6 @@ default: ...@@ -5,8 +5,6 @@ default:
- source /opt/intel/oneapi/tbb/latest/env/vars.sh - source /opt/intel/oneapi/tbb/latest/env/vars.sh
- echo $(nproc) - echo $(nproc)
- printenv | sort - printenv | sort
- python3 -m pip install --upgrade pip
- python3 -m pip install scipy==1.15
.global_tag: &global_tag_def .global_tag: &global_tag_def
tags: tags:
......
...@@ -23,8 +23,6 @@ import blast ...@@ -23,8 +23,6 @@ import blast
import tbox import tbox
from blast.interfaces.blDataStructure import Group from blast.interfaces.blDataStructure import Group
from scipy.interpolate import make_splprep
from scipy.interpolate import griddata from scipy.interpolate import griddata
from scipy.interpolate import interp1d from scipy.interpolate import interp1d
...@@ -451,8 +449,15 @@ class SolversInterface: ...@@ -451,8 +449,15 @@ class SolversInterface:
Notes: Notes:
----- -----
The sections are created using the inviscid mesh and the
sections are created by interpolating the inviscid mesh using scipy griddata.
""" """
found_splprep = False
try:
from scipy.interpolate import make_splprep
found_splprep = True
except ImportError:
print('Warning: scipy not found. Cannot smooth leading edge.')
ndim = self.getnDim() ndim = self.getnDim()
sections = self.cfg['sections'] sections = self.cfg['sections']
...@@ -517,20 +522,21 @@ class SolversInterface: ...@@ -517,20 +522,21 @@ class SolversInterface:
data_up = np.delete(data_up, np.where(np.isnan(data_up[:, ndim-1])), axis=0) data_up = np.delete(data_up, np.where(np.isnan(data_up[:, ndim-1])), axis=0)
data_lw = np.delete(data_lw, np.where(np.isnan(data_lw[:, ndim-1])), axis=0) data_lw = np.delete(data_lw, np.where(np.isnan(data_lw[:, ndim-1])), axis=0)
dummy = np.row_stack((data_up, np.flip(data_lw, axis=0))) if found_splprep:
dummy = np.row_stack((data_up, np.flip(data_lw, axis=0)))
# Ensure that there is only one point at the leading edge
dummy[0,ndim-1] = 0.5*(dummy[0,ndim-1] + dummy[-1,ndim-1]) # Ensure that there is only one point at the leading edge
dummy[-1,ndim-1] = dummy[0, ndim-1] dummy[0,ndim-1] = 0.5*(dummy[0,ndim-1] + dummy[-1,ndim-1])
dummy[-1,ndim-1] = dummy[0, ndim-1]
# Smooth leading edge
mask = dummy[:,0] < (0.1*(np.max(dummy[:,0]) - np.min(dummy[:,0])) + np.min(dummy[:,0])) # Smooth leading edge
_s = self.cfg['smooth_sections'] if 'smooth_sections' in self.cfg else 0.0 mask = dummy[:,0] < (0.1*(np.max(dummy[:,0]) - np.min(dummy[:,0])) + np.min(dummy[:,0]))
spl_n, u_n = make_splprep([dummy[mask,0], dummy[mask,2]], s=_s) _s = self.cfg['smooth_sections'] if 'smooth_sections' in self.cfg else 0.0
dummy[mask, 0] = spl_n(u_n)[0] spl_n, u_n = make_splprep([dummy[mask,0], dummy[mask,2]], s=_s)
dummy[mask, 2] = spl_n(u_n)[1] dummy[mask, 0] = spl_n(u_n)[0]
data_up = dummy[:data_up.shape[0], :] dummy[mask, 2] = spl_n(u_n)[1]
data_lw = np.flip(dummy[data_up.shape[0]:], axis=0) data_up = dummy[:data_up.shape[0], :]
data_lw = np.flip(dummy[data_up.shape[0]:], axis=0)
interpolated_upper.append(data_up) interpolated_upper.append(data_up)
interpolated_lower.append(data_lw) interpolated_lower.append(data_lw)
......
This diff is collapsed.
...@@ -92,6 +92,7 @@ def cfgBlast(verb): ...@@ -92,6 +92,7 @@ def cfgBlast(verb):
'nPoints': 300, # Number of points on the section 'nPoints': 300, # Number of points on the section
# Each section will have nPoints+1 # Each section will have nPoints+1
# points because of the duplicate TE # points because of the duplicate TE
'smooth_sections': 1e-6,
# Solution interpolation # Solution interpolation
'interpolator': 'Rbf', # Interpolator type 'interpolator': 'Rbf', # Interpolator type
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment