Skip to content

Commit 1dcc81f

Browse files
authored
Merge pull request #133 from ToFuProject/Issue131_OperatorD0N1
Issue131 operator `D0N1` fixed + removed all `order='F'` from `operators` and `cropbs_flat`
2 parents 82eae2e + 27540a5 commit 1dcc81f

File tree

6 files changed

+49
-1049
lines changed

6 files changed

+49
-1049
lines changed

bsplines2d/_class01_select.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ def _mesh2DRect_bsplines_knotscents(
763763
knots_per_bs_Z = knots_per_bs_Z[:, ind[1]]
764764

765765
nknots = knots_per_bs_R.shape[0]
766+
# TBC: reverse repeat and tile ?
766767
knots_per_bs_R = np.tile(knots_per_bs_R, (nknots, 1))
767768
knots_per_bs_Z = np.repeat(knots_per_bs_Z, nknots, axis=0)
768769

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

781782
ncents = cents_per_bs_R.shape[0]
783+
# TBC: reverse repeat and tile ?
782784
cents_per_bs_R = np.tile(cents_per_bs_R, (ncents, 1))
783785
cents_per_bs_Z = np.repeat(cents_per_bs_Z, ncents, axis=0)
784786

@@ -787,10 +789,11 @@ def _mesh2DRect_bsplines_knotscents(
787789

788790
if return_knots is True and return_cents is True:
789791
out = (
790-
(knots_per_bs_R, knots_per_bs_Z), (cents_per_bs_R, cents_per_bs_Z)
792+
(knots_per_bs_R, knots_per_bs_Z),
793+
(cents_per_bs_R, cents_per_bs_Z)
791794
)
792795
elif return_knots is True:
793796
out = (knots_per_bs_R, knots_per_bs_Z)
794797
else:
795798
out = (cents_per_bs_R, cents_per_bs_Z)
796-
return out
799+
return out

bsplines2d/_class02_bsplines_operators_rect.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# Common
88
import numpy as np
99
import scipy.sparse as scpsp
10-
import datastock as ds
1110

1211

1312
from . import _utils_bsplines_operators as _operators
@@ -67,8 +66,8 @@ def get_mesh2dRect_operators(
6766
# prepare
6867

6968
nx, ny = knotsx_per_bs.shape[1], knotsy_per_bs.shape[1]
70-
kR = np.tile(knotsx_per_bs, ny)
71-
kZ = np.repeat(knotsy_per_bs, nx, axis=1)
69+
kR = np.repeat(knotsx_per_bs, ny, axis=1)
70+
kZ = np.tile(knotsy_per_bs, nx)
7271
nbs = nx*ny
7372

7473
if cropbs_flat is None:
@@ -219,7 +218,8 @@ def get_mesh2dRect_operators(
219218
for ir in range(nx):
220219
for iz in range(ny):
221220

222-
iflat = ir + iz*nx
221+
# iflat = ir + iz*nx
222+
iflat = iz + ir*ny
223223
if cropbs_flat is not False and not cropbs_flat[iflat]:
224224
continue
225225

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

241-
jr = jflat % nx
242-
jz = jflat // nx
241+
jr = jflat // ny
242+
jz = jflat % ny
243243

244244
# store (i, j) and (j, i) (symmetric matrix)
245245
if jr >= ir:
@@ -277,17 +277,12 @@ def get_mesh2dRect_operators(
277277
)
278278

279279
# surface elements
280-
dZ = np.repeat(knotsy_mult[1:] - knotsy_mult[:-1], nx)
280+
dZ = np.tile(knotsy_mult[1:] - knotsy_mult[:-1], nx)
281281
if geometry == 'linear':
282-
dR = np.tile(
283-
knotsx_mult[1:] - knotsx_mult[:-1],
284-
ny,
285-
)
282+
dR = knotsx_mult[1:] - knotsx_mult[:-1]
286283
else:
287-
dR = np.tile(
288-
0.5*(knotsx_mult[1:]**2 - knotsx_mult[:-1]**2),
289-
ny,
290-
)
284+
dR = 0.5*(knotsx_mult[1:]**2 - knotsx_mult[:-1]**2)
285+
dR = np.repeat(dR, ny)
291286

292287
dS = dR*dZ
293288
if cropbs_flat is not False:
@@ -328,7 +323,7 @@ def get_mesh2dRect_operators(
328323
for ir in range(nx):
329324
for iz in range(ny):
330325

331-
iflat = ir + iz*nx
326+
iflat = iz + ir*ny
332327
if cropbs_flat is not False and not cropbs_flat[iflat]:
333328
continue
334329

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

351-
jr = jflat % nx
352-
jz = jflat // nx
346+
jr = jflat // ny
347+
jz = jflat % ny
353348

354349
# store (i, j) and (j, i) (symmetric matrix)
355350
if jr >= ir:
@@ -401,7 +396,7 @@ def get_mesh2dRect_operators(
401396
for ir in range(nx):
402397
for iz in range(ny):
403398

404-
iflat = ir + iz*nx
399+
iflat = iz + ir*ny
405400
if cropbs_flat is not False and not cropbs_flat[iflat]:
406401
continue
407402

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

425-
jr = jflat % nx
426-
jz = jflat // nx
420+
jr = jflat // ny
421+
jz = jflat % ny
427422

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

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

466-
return opmat, operator, geometry
461+
return opmat, operator, geometry

bsplines2d/_class02_bsplines_rect.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,20 +394,20 @@ def _get_overlap(
394394
):
395395
# nb of overlapping, inc. itself in 1d
396396
nbs0, nbs1 = shapebs
397-
ind00 = np.tile(np.arange(0, nbs0), nbs1)
398-
ind10 = np.repeat(np.arange(0, nbs1), nbs0)
397+
ind00 = np.repeat(np.arange(0, nbs0), nbs1)
398+
ind10 = np.tile(np.arange(0, nbs1), nbs0)
399399

400400
# complete
401401
ntot = 2*deg + 1
402402

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

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

409409
# purge
410-
inter = inter0 + inter1*nbs0
410+
inter = inter1 + inter0*nbs1
411411
indneg = (
412412
(inter0 < 0) | (inter0 >= nbs0) | (inter1 < 0) | (inter1 >= nbs1)
413413
)
@@ -469,4 +469,4 @@ def get_bs_class(
469469
knots1=knots1,
470470
deg=deg,
471471
shapebs=shapebs,
472-
)
472+
)

0 commit comments

Comments
 (0)