I have a tensor functional space and a tensor variable:
TensorSpace = TensorFunctionSpace(mesh, 'CG', 1)
sigma = TrialFunction(VectorSpace)
How can I create an array of this tensor variable, so that I can have 8 different values for sigma and that can be accessed like a NumPy array?
sigma[0]+sigma[1] + ... + sigma[7]
Hello,
A TensorFunctionSpace
can be indexed using two numbers: eg sigma[2,1]
. For a 3D mesh, there will be nine values, each index going from 0 to 2 (inclusive).
If you want 8 values that you can address sigma[0]
to sigma[7]
, you can create a VectorFunctionSpace
of size 8:
space = VectorFunctionSpace(mesh, "CG", 1, 8)
sigma = TrialFunction(space)
(Note: I’m using dolfinx, but I’m pretty certain this also works in older versions)