Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-testing-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest, macos-latest] # , windows-latest due to TcK install errors
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
Expand Down
27 changes: 15 additions & 12 deletions bsplines2d/_class01_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ def _select_ind(
f"Provided: {ind.shape}"
)
raise Exception(msg)
# make sure R varies first
ind_tup = ind.T.nonzero()[::-1]
ind_tup = ind.nonzero()
ind_bool = ind

else:
Expand Down Expand Up @@ -197,18 +196,18 @@ def _select_ind(
ind_bool = ind_bool & cropiknots

# ind_tup is not 2d anymore
ind_tup = ind_bool.T.nonzero()[::-1] # R varies first
ind_tup = ind_bool.nonzero()
# warnings.warn("ind is not 2d anymore!")

elif ind_tup[0].shape == cropi.shape:
ind_bool = ind_bool & cropi
# ind_tup is not 2d anymore
ind_tup = ind_bool.T.nonzero()[::-1] # R varies first
ind_tup = ind_bool.nonzero()
# warnings.warn("ind is not 2d anymore!")

else:
ind_bool = ind_bool & cropi
ind_tup = ind_bool.T.nonzero()[::-1]
ind_tup = ind_bool.nonzero()
else:
ind_bool &= cropi

Expand All @@ -222,13 +221,14 @@ def _select_ind(
elif returnas is tuple:
out = ind_tup
elif returnas == 'tuple-flat':
# make sure R is varying first
out = (ind_tup[0].T.ravel(), ind_tup[1].T.ravel())
# make sure R is varying first => no!
out = (ind_tup[0].ravel(), ind_tup[1].ravel())
elif returnas is np.ndarray:
out = ind_tup[0] + ind_tup[1]*nR
# make sure R is varying first => no!
out = ind_tup[0]*nZ + ind_tup[1]
elif returnas == 'array-flat':
# make sure R is varying first
out = (ind_tup[0] + ind_tup[1]*nR).T.ravel()
# make sure R is varying first => no!
out = (ind_tup[0]*nZ + ind_tup[1]).ravel()
else:
out = ind_bool

Expand Down Expand Up @@ -763,6 +763,7 @@ def _mesh2DRect_bsplines_knotscents(
knots_per_bs_Z = knots_per_bs_Z[:, ind[1]]

nknots = knots_per_bs_R.shape[0]
# TBC: reverse repeat and tile ?
knots_per_bs_R = np.tile(knots_per_bs_R, (nknots, 1))
knots_per_bs_Z = np.repeat(knots_per_bs_Z, nknots, axis=0)

Expand All @@ -779,6 +780,7 @@ def _mesh2DRect_bsplines_knotscents(
cents_per_bs_Z = cents_per_bs_Z[:, ind[1]]

ncents = cents_per_bs_R.shape[0]
# TBC: reverse repeat and tile ?
cents_per_bs_R = np.tile(cents_per_bs_R, (ncents, 1))
cents_per_bs_Z = np.repeat(cents_per_bs_Z, ncents, axis=0)

Expand All @@ -787,10 +789,11 @@ def _mesh2DRect_bsplines_knotscents(

if return_knots is True and return_cents is True:
out = (
(knots_per_bs_R, knots_per_bs_Z), (cents_per_bs_R, cents_per_bs_Z)
(knots_per_bs_R, knots_per_bs_Z),
(cents_per_bs_R, cents_per_bs_Z)
)
elif return_knots is True:
out = (knots_per_bs_R, knots_per_bs_Z)
else:
out = (cents_per_bs_R, cents_per_bs_Z)
return out
return out
39 changes: 17 additions & 22 deletions bsplines2d/_class02_bsplines_operators_rect.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# Common
import numpy as np
import scipy.sparse as scpsp
import datastock as ds


from . import _utils_bsplines_operators as _operators
Expand Down Expand Up @@ -67,8 +66,8 @@ def get_mesh2dRect_operators(
# prepare

nx, ny = knotsx_per_bs.shape[1], knotsy_per_bs.shape[1]
kR = np.tile(knotsx_per_bs, ny)
kZ = np.repeat(knotsy_per_bs, nx, axis=1)
kR = np.repeat(knotsx_per_bs, ny, axis=1)
kZ = np.tile(knotsy_per_bs, nx)
nbs = nx*ny

if cropbs_flat is None:
Expand Down Expand Up @@ -219,7 +218,8 @@ def get_mesh2dRect_operators(
for ir in range(nx):
for iz in range(ny):

iflat = ir + iz*nx
# iflat = ir + iz*nx
iflat = iz + ir*ny
if cropbs_flat is not False and not cropbs_flat[iflat]:
continue

Expand All @@ -238,8 +238,8 @@ def get_mesh2dRect_operators(
if cropbs_flat is not False and not cropbs_flat[jflat]:
continue

jr = jflat % nx
jz = jflat // nx
jr = jflat // ny
jz = jflat % ny

# store (i, j) and (j, i) (symmetric matrix)
if jr >= ir:
Expand Down Expand Up @@ -277,17 +277,12 @@ def get_mesh2dRect_operators(
)

# surface elements
dZ = np.repeat(knotsy_mult[1:] - knotsy_mult[:-1], nx)
dZ = np.tile(knotsy_mult[1:] - knotsy_mult[:-1], nx)
if geometry == 'linear':
dR = np.tile(
knotsx_mult[1:] - knotsx_mult[:-1],
ny,
)
dR = knotsx_mult[1:] - knotsx_mult[:-1]
else:
dR = np.tile(
0.5*(knotsx_mult[1:]**2 - knotsx_mult[:-1]**2),
ny,
)
dR = 0.5*(knotsx_mult[1:]**2 - knotsx_mult[:-1]**2)
dR = np.repeat(dR, ny)

dS = dR*dZ
if cropbs_flat is not False:
Expand Down Expand Up @@ -328,7 +323,7 @@ def get_mesh2dRect_operators(
for ir in range(nx):
for iz in range(ny):

iflat = ir + iz*nx
iflat = iz + ir*ny
if cropbs_flat is not False and not cropbs_flat[iflat]:
continue

Expand All @@ -348,8 +343,8 @@ def get_mesh2dRect_operators(
if cropbs_flat is not False and not cropbs_flat[jflat]:
continue

jr = jflat % nx
jz = jflat // nx
jr = jflat // ny
jz = jflat % ny

# store (i, j) and (j, i) (symmetric matrix)
if jr >= ir:
Expand Down Expand Up @@ -401,7 +396,7 @@ def get_mesh2dRect_operators(
for ir in range(nx):
for iz in range(ny):

iflat = ir + iz*nx
iflat = iz + ir*ny
if cropbs_flat is not False and not cropbs_flat[iflat]:
continue

Expand All @@ -422,8 +417,8 @@ def get_mesh2dRect_operators(
if cropbs_flat is not False and not cropbs_flat[jflat]:
continue

jr = jflat % nx
jz = jflat // nx
jr = jflat // ny
jz = jflat % ny

# store (i, j) and (j, i) (symmetric matrix)
if jr >= ir:
Expand Down Expand Up @@ -463,4 +458,4 @@ def get_mesh2dRect_operators(

raise NotImplementedError("Integral D3N2 not implemented for deg=3!")

return opmat, operator, geometry
return opmat, operator, geometry
19 changes: 11 additions & 8 deletions bsplines2d/_class02_bsplines_rect.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ def evaluate_spline(t, c, k, xp, nu, extrapolate, out):
c1 = c.reshape(c.shape[:ndim] + (-1,))
num_c_tr = c1.shape[-1]
strides_c1 = [stride // c.dtype.itemsize for stride in c.strides]
indices_k1d = np.unravel_index(np.arange((k+1)**ndim), (k+1,)*ndim)[0][:, None]
indices_k1d = np.unravel_index(
np.arange((k+1)**ndim),
(k+1,)*ndim,
)[0][:, None]
return scpinterp._bspl.evaluate_ndbspline(
xp[:, None],
t[None, :],
Expand Down Expand Up @@ -255,7 +258,7 @@ def ev_details(
self,
x0=None,
x1=None,
#derivatives
# derivatives
deriv=None,
# others
indbs_tf=None,
Expand Down Expand Up @@ -394,20 +397,20 @@ def _get_overlap(
):
# nb of overlapping, inc. itself in 1d
nbs0, nbs1 = shapebs
ind00 = np.tile(np.arange(0, nbs0), nbs1)
ind10 = np.repeat(np.arange(0, nbs1), nbs0)
ind00 = np.repeat(np.arange(0, nbs0), nbs1)
ind10 = np.tile(np.arange(0, nbs1), nbs0)

# complete
ntot = 2*deg + 1

add0= np.tile(np.arange(-deg, deg+1), ntot)
add1 = np.repeat(np.arange(-deg, deg+1), ntot)
add0 = np.repeat(np.arange(-deg, deg+1), ntot)
add1 = np.tile(np.arange(-deg, deg+1), ntot)

inter0 = ind00[None, :] + add0[:, None]
inter1 = ind10[None, :] + add1[:, None]

# purge
inter = inter0 + inter1*nbs0
inter = inter1 + inter0*nbs1
indneg = (
(inter0 < 0) | (inter0 >= nbs0) | (inter1 < 0) | (inter1 >= nbs1)
)
Expand Down Expand Up @@ -469,4 +472,4 @@ def get_bs_class(
knots1=knots1,
deg=deg,
shapebs=shapebs,
)
)
Loading
Loading