Solver for linear system of a VectorTensorProductSpace
thoeschler opened this issue · comments
Dear Mikael,
I would like to solve a vector Poisson problem in 2D. For now, I am solving the vector Poisson problem as a test case, where the spatial components do not couple. Later, I would like to move on to other problems, in which the spatial components are coupled.
I am using Legendre polynomials and I have created the standard weak form using integration by parts: inner(grad(u), grad(v))
where the functions u
and v
are elements of a VectorTensorProductSpace
. As far as I understand, the function inner
is used to compute the components of the linear system. In some of the demos, specialized classes like BlockMatrix
are used to create the linear system which is finally solved. However, the BlockMatrix
class only seems to work for a MixedTensorProductSpace
. In my case, the inner function returns a list of TPMatrix
objects and I am not sure what exactly they represent. Moreover, it is not clear how to compose a linear system from them. I hope my code below shows the problem.
Best regards,
Thilo
from mpi4py import MPI
from sympy import symbols
from shenfun import inner, grad, TestFunction, TrialFunction, Array, \
Basis, TensorProductSpace, VectorTensorProductSpace
from mpi4py_fft.pencil import Subcomm
comm = MPI.COMM_WORLD
family = 'legendre'
# define rhs
x, y = symbols("x,y")
f = (x**2, y)
# Size of discretization
n = 25
N = [n, n+1]
# Create bases and spaces
BX = Basis(N[0], family=family, bc=(0, 0))
BY = Basis(N[1], family=family, bc=(0, 0))
subcomms = Subcomm(MPI.COMM_WORLD, [0, 1])
T = TensorProductSpace(subcomms, (BX, BY), axes=(1, 0))
V = VectorTensorProductSpace([T, T])
u = TrialFunction(V)
v = TestFunction(V)
# get f on quad points
fj = Array(V, buffer=f)
# compute matrices and rhs
matrices = inner(grad(v), grad(u))
b = inner(v, fj)
Hi Thilo,
The VectorTensorProductSpace
is a MixedTensorProductSpace
, so BlockMatrix
should work for you I think?
BTW, to understand what the TPMatrix
is (tensor product matrix) you should look at some of the extended demos. It's not so easy to explain here in just a few lines:-)
Hi Mikael,
thank you for the immediate response.
I tried using BlockMatrix
once again and this time it worked perfectly. I don't know why it didn't in the first place.
Best regards,
Thilo