In the demo “Mixed formulation for the Poisson equation”
k = 1
#we should set the size of the vector element ?
Q_el = element("BDMCF", domain.basix_cell(), k)
P_el = element("DG", domain.basix_cell(), k - 1)
Is Q_el a vector-valued element (it’s the element for \nabla u ) ? But the shape parameter is not set.
In the demo “Stokes equations using Taylor-Hood elements”
If I write the eqution
\nabla \cdot (\nabla u + p I) = f
explicitly, it should be
\begin{aligned}
\frac{\partial}{\partial x}\left(p_x + \frac{\partial u_x}{\partial x} \right) + \frac{\partial}{\partial y}\left(\frac{\partial u_x}{\partial y} \right) + \frac{\partial}{\partial z}\left(\frac{\partial u_x}{\partial z} \right) &= f_x \\
\frac{\partial}{\partial x}\left(\frac{\partial u_y}{\partial x} \right) + \frac{\partial}{\partial y}\left(p_y + \frac{\partial u_y}{\partial y} \right) + \frac{\partial}{\partial z}\left(\frac{\partial u_y}{\partial z} \right) &= f_y \\
\frac{\partial}{\partial x}\left(\frac{\partial u_z}{\partial x} \right) + \frac{\partial}{\partial y}\left(\frac{\partial u_z}{\partial y} \right) + \frac{\partial}{\partial z}\left(p_z + \frac{\partial u_z}{\partial z} \right) &= f_z
\end{aligned}
The \nabla u should be a matrix, but why we use grad
here ? It seems that u
is just a scalar ?
a = form([[inner(grad(u), grad(v)) * dx, inner(p, div(v)) * dx],
[inner(div(u), q) * dx, None]])
But in this line, the shape of element is set
P2 = element("Lagrange", msh.basix_cell(), 2, shape=(msh.geometry.dim,))
u
should be a vector I think.
Why we use Nested matrix in the stokes equation demo ? Can we just combine all the variational form into a single scalar equation as we usually do ?
dokken
April 23, 2024, 5:24am
2
Smith_Jack:
Q_el = element("BDMCF", domain.basix_cell(), k)
P_el = element("DG", domain.basix_cell(), k - 1)
Is Q_el a vector-valued element (it’s the element for \nabla u∇u\nabla u) ? But the shape parameter is not set.
BDMCF have vector valued basis functions, and scalar dofs, see: DefElement
Smith_Jack:
The \nabla u∇u\nabla u should be a matrix, but why we use grad
here ? It seems that u
is just a scalar ?
a = form([[inner(grad(u), grad(v)) * dx, inner(p, div(v)) * dx],
[inner(div(u), q) * dx, None]])
I dont quite understand the question here, as u is a vector
Nested matrices are used to illustrate that you can then precondition each block. The demo shows four different methods for solving the problem. You should look at:
https://docs.fenicsproject.org/dolfinx/v0.7.2/python/demos/demo_stokes.html#non-blocked-direct-solver
for the fully unblocked problem.
Thanks for your reply, for the second question I mean that, \vec{u} is a vector, then \nabla\vec{u} should be a matrix, maybe nabla_grad(u)
should be used ? inner(grad(u), grad(v))
should be dot(nabla_grad(u), nabla_grad(v))
?
dokken
April 23, 2024, 11:02am
4
Yes, grad(u) is a matrix (the same is nabla_grad
, which is its transpose). The inner product reduces this to a scalar valued expression, by component-wise multiplying the two tensors together.
It should not be dot
, as then the resulting expression would be a vector, which cannot be assembled