Hello,
Here I have defined a “Real” function space for the macroscopic strain. And at the end I interpolate the solution:
import dolfin
import numpy as np
mesh = dolfin.RectangleMesh(
dolfin.Point(0, 0, 0), dolfin.Point(1, 1, 0),
2, 2,
"crossed")
boundaries_mf = dolfin.MeshFunction("size_t", mesh, mesh.topology().dim()-1)
V_element = dolfin.VectorElement("CG", mesh.ufl_cell(), 2)
T_element = dolfin.TensorElement("R", mesh.ufl_cell(), 0, symmetry=True)
TH = dolfin.MixedElement([V_element, T_element])
fs_V = dolfin.FunctionSpace(mesh, V_element)
fs_T = dolfin.FunctionSpace(mesh, T_element)
W = dolfin.FunctionSpace(mesh, TH)
du = dolfin.TrialFunction(W)
v = dolfin.TestFunction(W)
w = dolfin.Function(W)
(u, eps) = dolfin.split(w)
(delta_v, delta_eps) = dolfin.split(v)
V_CG2_out = dolfin.VectorFunctionSpace(mesh, 'CG', 2)
X_0 = dolfin.Constant((1/2.,1/2.))
X_coord = dolfin.Expression(('x[0]','x[1]'),degree=1,domain=mesh)
u_bar = eps*(X_coord-X_0)
u_tot = u + u_bar
d = len(u)
I = dolfin.Identity(d)
F = I + dolfin.grad(u + u_bar)
C = F.T*F
Ic = dolfin.tr(C)
J = dolfin.det(F)
mu = dolfin.Constant(31.7)
I1b = Ic*J**(-2./3.)
psi = (mu/2.0)*(I1b - 3.0)
dx = dolfin.dx
Pi = psi*dx
dPi = dolfin.derivative(Pi, w, v)
Jac = dolfin.derivative(dPi, w, du)
bcs = []
u_tot = dolfin.project(u_bar+u, V_CG2_out, solver_type='mumps')
dolfin.solve(dPi == 0, w, bcs, J=Jac)
func = dolfin.Function(fs_V)
func.interpolate(u)
I’m facing the following error:
self._cpp_object.interpolate(u)
AttributeError: 'ListTensor' object has no attribute '_cpp_object'
That comes from the last line. Can you please let me know if there is any solution for this?
Thanks