This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Assign Initial Value to TensorElement in Mixed Finite Element

0 votes

Hello,

I have a mixed element/space and I need to assign initially identity tensor for one of the spaces, in this case, a tensor element space:

V1 = VectorElement("CG", model.ufl_cell(), 1)
F1 = TensorElement("CG", model.ufl_cell(), 1)

MFEM = FunctionSpace(model, MixedElement((V1, F1, F1)))

fc_uFP = Function(MFEM, name='Disp-Grad-Press')
fc_u, fc_F, fc_P = split(fc_uFP)

I need to assign an identity tensor as initial conditions to fc_F.

Any idea how to do it?

Cheers,

asked Dec 12, 2016 by RDOLL FEniCS User (2,230 points)

I found a workaround, but it's not an elegant way:

mdim = model.geometry().dim()
WF = TensorFunctionSpace(model, "CG", 1)
fc_F0 = project(Identity(mdim), WF )

assign(fc_uFP.sub(1), fc_F0)

Interpolation might be faster than projection.

...