Skip to content

Commit

Permalink
fix computation of multiplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
vcarlier committed Oct 23, 2023
1 parent f10d633 commit 083009a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions psydac/api/tests/test_api_feec_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,9 @@ def test_maxwell_2d_multiplicity():
mult = 2
)

TOL = 1e-6
ref = dict(error_l2_Ex = 4.35005708e-04,
error_l2_Ey = 4.35005708e-04,
TOL = 1e-5
ref = dict(error_l2_Ex = 4.350041934920621e-04,
error_l2_Ey = 4.350041934920621e-04,
error_l2_Bz = 3.76106860e-03)

assert abs(namespace['error_l2_Ex'] - ref['error_l2_Ex']) / ref['error_l2_Ex'] <= TOL
Expand Down
5 changes: 3 additions & 2 deletions psydac/feec/tests/test_differentiation_matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,10 +911,11 @@ def eval_div(fx, fy, fz, *eta):

#==============================================================================
if __name__ == '__main__':

test_Derivative_1D(domain=[0, 1], ncells=12, degree=3, periodic=False, seed=1, multiplicity=1)
test_Derivative_1D(domain=[0, 1], ncells=3, degree=3, periodic=False, seed=1, multiplicity=1)
test_Derivative_1D(domain=[0, 1], ncells=12, degree=3, periodic=True, seed=1, multiplicity=1)


test_Gradient_2D(
domain = ([0, 1], [0, 1]),
ncells = (10, 15),
Expand Down
12 changes: 5 additions & 7 deletions psydac/fem/splines.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,13 @@ def __init__( self, degree, knots=None, grid=None, multiplicity=None, parent_mul
if grid is None:
grid = breakpoints(knots, degree)

indices = np.where(np.diff(knots[degree+1:-degree-1])>1e-15)[0]
indices = np.where(np.diff(knots[degree:len(knots)-degree])>1e-15)[0]

if len(indices)>0:
multiplicity = np.diff(indices).max(initial=1)
else:
multiplicity = max(1,len(knots[degree+1:-degree-1]))

if multiplicity is None: #V.C 20/10/23 : why computing the multiplicity again?
if len(indices)>0:
multiplicity = np.diff(indices).max(initial=1)
else:
multiplicity = max(1,len(knots[degree+1:-degree-1]))

if parent_multiplicity is None:
parent_multiplicity = multiplicity

Expand Down

0 comments on commit 083009a

Please sign in to comment.