Hello, I have a system with mixed elements; 2 vector elements and 2 tensor elements (2-dimensional tensors). Since I have a system, where one of these tensors is invertet in the residuum, I need to start with a non-singular tensor, for example the identity matrix.
from dolfinx import *
from mpi4py import MPI
import numpy as np
import matplotlib.pyplot as plt
import ufl
import scipy.io
from petsc4py import PETSc
mesh = mesh.create_unit_cube(MPI.COMM_WORLD, nx=1, ny=1, nz=1)
n = ufl.FacetNormal(mesh)
P = ufl.VectorElement("CG", mesh.ufl_cell(), 1)
R = ufl.TensorElement("DG", mesh.ufl_cell(), 1)
P_wish = ufl.VectorElement("CG", mesh.ufl_cell(), 1)
R_wish = ufl.TensorElement("DG", mesh.ufl_cell(), 1)
mel = ufl.MixedElement([P, R, P_wish, R_wish])
print(mel)
U = fem.FunctionSpace(mesh, mel)
u = fem.Function(U)
(p, F, v, P) = ufl.split(u)
(dv, dP, dp, dF) = ufl.TestFunctions(U)
rho_0=1
mu=1
lamb=1
Psi_fun=lambda F: mu/2*(np.trace(F.T@F)-3)-mu*np.log(np.sqrt(np.linalg.det(F.T@F)))+lamb/2*np.log(np.sqrt(np.linalg.det(F.T@F)))**2
P_fun=lambda F: ufl.dot(F,mu*(ufl.classes.Identity(F.ufl_shape[0])-ufl.inv(ufl.dot(F.T,F)))+lamb*ufl.ln(ufl.sqrt(ufl.classes.Determinant(ufl.dot(F.T,F))))*ufl.inv(ufl.dot(F.T,F)))
u_n = fem.Function(U) # previous time step
(p_n, F_n, v_n, P_n) = ufl.split(u_n)
# Initial conditions:
def initial_cond(x,y,z):
return np.eye(F.ufl_shape[0])
F.interpolate(np.eye(F.ufl_shape[0]))
F_n.interpolate(np.eye(F.ufl_shape[0]))
It just tells me
AttributeError: 'ListTensor' object has no attribute 'interpolate'
so what I found on in the examples does not work, unfortunately. Can anybody help me how to set a tensor-function-space initially to identity?
Thank you in advance for any help!