Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toarray assumes a knot multiplicity of 1 #474

Open
jowezarek opened this issue Mar 17, 2025 · 0 comments
Open

toarray assumes a knot multiplicity of 1 #474

jowezarek opened this issue Mar 17, 2025 · 0 comments
Assignees
Labels
bug Something isn't working linalg Linear algebra Next Release Must be in next release

Comments

@jowezarek
Copy link
Contributor

jowezarek commented Mar 17, 2025

from    mpi4py              import MPI
import  numpy               as np
import  matplotlib.pyplot   as plt

from    sympde.expr                 import BilinearForm, integral
from    sympde.topology             import elements_of, Cube, Derham

from    psydac.api.discretization   import discretize
from    psydac.api.settings         import PSYDAC_BACKEND_GPYCCEL
from    psydac.linalg.basic         import LinearOperator
from    psydac.linalg.block         import BlockVectorSpace
from    psydac.linalg.stencil       import StencilVectorSpace

comm     = MPI.COMM_WORLD
backend  = PSYDAC_BACKEND_GPYCCEL

mult     = [2, 1, 1]

ncells   = [3, 2, 2]
degree   = [2, 1, 1]
periodic = [False]*3

domain   = Cube('C', bounds1=(0,1), bounds2=(0,1), bounds3=(0,1))
derham   = Derham(domain)

domain_h = discretize(domain, ncells=ncells, periodic=periodic, comm=comm)
derham_h = discretize(derham, domain_h, degree=degree, multiplicity=mult)

u0, v0   = elements_of(derham.V0, names='u0, v0')

a0       = BilinearForm((u0, v0), integral(domain, u0*v0))
a0_h     = discretize(a0, domain_h, (derham_h.V0, derham_h.V0), backend=backend)
M0       = a0_h.assemble()

plt.spy(M0.toarray())
plt.show()
#plt.spy(toarray(M0))
#plt.show()

This code assembles the mass matrix corresponding to the first function space of a 3D de Rham sequence, where the knot sequence in x-diretcion is of multiplicity 2 instead of the default 1.
plt.spy(M0.toarray()) plots a non-symmetric matrix:
Image
I wrote a custom (slow) toarray() function that recovers the (hopefully / probably) true symmetric structure:
Image

The issue is most probably related to the fact that the pads value should at some point be multiplied with the knot multiplicity.

@jowezarek jowezarek added the bug Something isn't working label Mar 17, 2025
@yguclu yguclu added linalg Linear algebra Next Release Must be in next release labels Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linalg Linear algebra Next Release Must be in next release
Projects
None yet
Development

No branches or pull requests

2 participants