# If I want use function space of tensor?

If I need the function space of vector, I can use VectorL2(mesh, order). But if I need the function space of tensor, what I should use?

Another question is that when we solve saddle point problem, like Stokes problem, the matrix is indefinite, how the solve it? what command can we use?

thanks

Hi yhhan,

there is currently no MatrixL2 space direktly available. However, you can “construct” it by

``````MatrixL2 = L2(mesh, order=order, dim=4)
u,v = MatrixL2.TnT()
u.dims = (2,2)
v.dims = (2,2)
gf = GridFunction(MatrixL2)
gf.dims = (2,2)``````

For a saddle point problem you can use direct solvers as umfpack or also the build-in sparsecholesky solver if you regularize the problem at the lower-right zero block. E.g. for Stokes involving velocity u and pressure p you can add

``a += -1e-9*p*q``

as regularization.

Best
Michael

a short note on the solver for saddle point problems:

you can easily use MinRes or GMRes with block-preconditioning, see e.g.
https://ngsolve.org/docu/latest/i-tutorials/unit-2.6-stokes/stokes.html
as a starting point.

Joachim

Hi Michael,

Thank you so much, I will try it.

best,

Yihui

Hi Joachim,

I will check it later, thank you for your help.

best,

Yihui

Hi Michael,

For vector space, I can use V=VectorL2(mesh, order = ), then in the following
MatrixL2 = L2(mesh, order=order, dim=4)
u,v = MatrixL2.TnT()
u.dims = (2,2)
v.dims = (2,2)
gf = GridFunction(MatrixL2)
gf.dims = (2,2)

which one is like the above space V written by me? It seems that MatrixL2 = L2(mesh, order=order, dim=4) is different from the space V.

Best,
Yihui

Hi Yihui,

writing

``V = VectorL2(mesh, order=...)``

gives you a vector and

``V = L2(mesh, order=..., dim=4)``

a 2x2 matrix (after reshaping with .dim=(2,2) for the corresponding Trial-, Test-, and GridFunctions).

Best
Michael