Skip to content

Commit

Permalink
Remove 3d unit tests (take too long), remove backend option (only 1d …
Browse files Browse the repository at this point in the history
…matrices)
camillo81 committed Oct 13, 2023
1 parent b59195a commit 803384a
Showing 2 changed files with 53 additions and 51 deletions.
3 changes: 1 addition & 2 deletions psydac/feec/global_projectors.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
from psydac.fem.vector import VectorFemSpace

from psydac.ddm.cart import DomainDecomposition, CartDecomposition
from psydac.api.settings import PSYDAC_BACKEND_GPYCCEL

from abc import ABCMeta, abstractmethod

@@ -148,7 +147,7 @@ def __init__(self, space, nquads = None):
domain_decomp = DomainDecomposition([ncells], [periodic])
cart_decomp = CartDecomposition(domain_decomp, [n], [[s]], [[e]], [p], [1])
V_cart = StencilVectorSpace(cart_decomp)
M = StencilMatrix(V_cart, V_cart, backend=PSYDAC_BACKEND_GPYCCEL)
M = StencilMatrix(V_cart, V_cart)

if cell == 'I':
# interpolation case
101 changes: 52 additions & 49 deletions psydac/feec/tests/test_commuting_projections.py
Original file line number Diff line number Diff line change
@@ -74,27 +74,28 @@ def test_3d_commuting_pro_1(Nel, Nq, p, bc):
error = abs((Dfun_proj.coeffs-Dfun_h.coeffs).toarray()).max()
assert error < 1e-9

# TODO: test takes too long in 3D
#--------------------------
# check BlockLinearOperator
#--------------------------
# build the solver from the LinearOperator
imat_kronecker_P0 = P0.imat_kronecker
imat_kronecker_P1 = P1.imat_kronecker
I0inv = Inverse(imat_kronecker_P0, verbose=True)
I1inv = Inverse(imat_kronecker_P1, verbose=True)
# imat_kronecker_P0 = P0.imat_kronecker
# imat_kronecker_P1 = P1.imat_kronecker
# I0inv = Inverse(imat_kronecker_P0, verbose=True)
# I1inv = Inverse(imat_kronecker_P1, verbose=True)

# build the rhs
P0.func(fun1)
P1.func(D1fun1, D2fun1, D3fun1)
# # build the rhs
# P0.func(fun1)
# P1.func(D1fun1, D2fun1, D3fun1)

# solve and compare
u0vec = u0.coeffs
u0vec_imat = I0inv.solve(P0._rhs)
assert np.allclose(u0vec.toarray(), u0vec_imat.toarray(), atol=1e-5)
# # solve and compare
# u0vec = u0.coeffs
# u0vec_imat = I0inv.solve(P0._rhs)
# assert np.allclose(u0vec.toarray(), u0vec_imat.toarray(), atol=1e-5)

u1vec = u1.coeffs
u1vec_imat = I1inv.solve(P1._rhs)
assert np.allclose(u1vec.toarray(), u1vec_imat.toarray(), atol=1e-5)
# u1vec = u1.coeffs
# u1vec_imat = I1inv.solve(P1._rhs)
# assert np.allclose(u1vec.toarray(), u1vec_imat.toarray(), atol=1e-5)

#==============================================================================
@pytest.mark.parametrize('Nel', [8, 12])
@@ -171,27 +172,28 @@ def test_3d_commuting_pro_2(Nel, Nq, p, bc):
error = abs((Dfun_proj.coeffs-Dfun_h.coeffs).toarray()).max()
assert error < 1e-9

# TODO: test takes too long in 3D
#--------------------------
# check BlockLinearOperator
#--------------------------
# build the solver from the LinearOperator
imat_kronecker_P1 = P1.imat_kronecker
imat_kronecker_P2 = P2.imat_kronecker
I1inv = Inverse(imat_kronecker_P1, verbose=True)
I2inv = Inverse(imat_kronecker_P2, verbose=True)
# imat_kronecker_P1 = P1.imat_kronecker
# imat_kronecker_P2 = P2.imat_kronecker
# I1inv = Inverse(imat_kronecker_P1, verbose=True)
# I2inv = Inverse(imat_kronecker_P2, verbose=True)

# build the rhs
P1.func(fun1, fun2, fun3)
P2.func(cf1, cf2, cf3)
# # build the rhs
# P1.func(fun1, fun2, fun3)
# P2.func(cf1, cf2, cf3)

# solve and compare
u1vec = u1.coeffs
u1vec_imat = I1inv.solve(P1._rhs)
assert np.allclose(u1vec.toarray(), u1vec_imat.toarray(), atol=1e-5)
# # solve and compare
# u1vec = u1.coeffs
# u1vec_imat = I1inv.solve(P1._rhs)
# assert np.allclose(u1vec.toarray(), u1vec_imat.toarray(), atol=1e-5)

u2vec = u2.coeffs
u2vec_imat = I2inv.solve(P2._rhs)
assert np.allclose(u2vec.toarray(), u2vec_imat.toarray(), atol=1e-5)
# u2vec = u2.coeffs
# u2vec_imat = I2inv.solve(P2._rhs)
# assert np.allclose(u2vec.toarray(), u2vec_imat.toarray(), atol=1e-5)

#==============================================================================
@pytest.mark.parametrize('Nel', [8, 12])
@@ -259,27 +261,28 @@ def test_3d_commuting_pro_3(Nel, Nq, p, bc):
error = abs((Dfun_proj.coeffs-Dfun_h.coeffs).toarray()).max()
assert error < 1e-9

# TODO: test takes too long in 3D
#--------------------------
# check BlockLinearOperator
#--------------------------
# build the solver from the LinearOperator
imat_kronecker_P2 = P2.imat_kronecker
imat_kronecker_P3 = P3.imat_kronecker
I2inv = Inverse(imat_kronecker_P2, verbose=True)
I3inv = Inverse(imat_kronecker_P3, verbose=True)
# imat_kronecker_P2 = P2.imat_kronecker
# imat_kronecker_P3 = P3.imat_kronecker
# I2inv = Inverse(imat_kronecker_P2, verbose=True)
# I3inv = Inverse(imat_kronecker_P3, verbose=True)

# build the rhs
P2.func(fun1, fun2, fun3)
P3.func(difun)
# # build the rhs
# P2.func(fun1, fun2, fun3)
# P3.func(difun)

# solve and compare
u2vec = u2.coeffs
u2vec_imat = I2inv.solve(P2._rhs)
assert np.allclose(u2vec.toarray(), u2vec_imat.toarray(), atol=1e-5)
# # solve and compare
# u2vec = u2.coeffs
# u2vec_imat = I2inv.solve(P2._rhs)
# assert np.allclose(u2vec.toarray(), u2vec_imat.toarray(), atol=1e-5)

u3vec = u3.coeffs
u3vec_imat = I3inv.solve(P3._rhs)
assert np.allclose(u3vec.toarray(), u3vec_imat.toarray(), atol=1e-5)
# u3vec = u3.coeffs
# u3vec_imat = I3inv.solve(P3._rhs)
# assert np.allclose(u3vec.toarray(), u3vec_imat.toarray(), atol=1e-5)

@pytest.mark.parametrize('Nel', [8, 12])
@pytest.mark.parametrize('Nq', [5])
@@ -678,14 +681,14 @@ def test_1d_commuting_pro_1(Nel, Nq, p, bc):
p = 3
bc = False

test_1d_commuting_pro_1(20, Nq, p, bc)
test_1d_commuting_pro_1(Nel, Nq, p, bc)
test_2d_commuting_pro_1(Nel, Nq, p, bc)
test_2d_commuting_pro_2(Nel, Nq, p, bc)
# test_2d_commuting_pro_3(Nel, Nq, p, bc)
# test_2d_commuting_pro_4(Nel, Nq, p, bc)
# test_3d_commuting_pro_1(Nel, Nq, p, bc)
# test_3d_commuting_pro_2(Nel, Nq, p, bc)
# test_3d_commuting_pro_3(Nel, Nq, p, bc)
# test_2d_commuting_pro_4(Nel, Nq, p, bc)
test_2d_commuting_pro_3(Nel, Nq, p, bc)
test_2d_commuting_pro_4(Nel, Nq, p, bc)
test_3d_commuting_pro_1(Nel, Nq, p, bc)
test_3d_commuting_pro_2(Nel, Nq, p, bc)
test_3d_commuting_pro_3(Nel, Nq, p, bc)
test_2d_commuting_pro_4(Nel, Nq, p, bc)


0 comments on commit 803384a

Please sign in to comment.