Hi there, I am trying to solve a two body problem and as a first step started with two parallel membranes.
I define the space
V=FunctionSpace(mesh, VectorElement(“P”, triangle, degree = 1, dim = 2))
Define forces on each membrane
f1 = Constant(-40.0)
f2 = Constant(40.0)
Define boundary conditions
u_D = Constant((0.,0.))
def boundary(x, on_boundary):
return on_boundary
bc = DirichletBC(V, u_D, boundary)
Split in two components the function and the test function (this I will need when putting unilateral conditions)
u = Function(V)
u1,u2 = split(u)
v = TestFunction(V)
v1,v2 = split(v)
Provide my variational formulation
F = dot((grad(u1)), (grad(v1)))dx+dot((grad(u2)), (grad(v2)))dx- (f1v1+f2v2)*dx
And solve
solve(F == 0, u, bc)
Now I wanto to write to one file u1+L and to one another u2-L and all my attempts failed. I can show on screen by using
plot(u1+L, title=‘Deflection1’)
plt.show()
plot(u2-L, title=‘Deflection2’)
plt.show()
To be honest, I get a warning that “Object cannot be plotted directly, projecting to piecewise linears”.
But further, all my attempts to write to file failed. I try
file1 = File(“place/u1.pvd”)
file2 = File(“place/u2.pvd”)
file1<< u1+L
file2<< u2-L
But I get "AttributeError: ‘Sum’ object has no attribute ‘_cpp_object’ "
I tried to interpolate and project the constant L before adding to u1 or u2, but I am doing something wrong and do not know what to try next.
This is probably very basic stuff, sorry for bothering you with this issue, but any help will be appreciated.