Hi, I am facing a problem with the interpolation of the following function u_init
MWE Code for u_init
mesh = UnitIntervalMesh(256)
V = FunctionSpace(mesh, 'P', 1)
def u0_boundary(x, on_boundary):
return on_boundary
bc = DirichletBC(V, Constant(0.0), u0_boundary)
u = TrialFunction(V)
v = TestFunction(V)
A = inner(nabla_grad(u), nabla_grad(v))*dx
RHS = v*dx
u_init = Function(V)
solve(A == RHS, u_init, bc)
plot(u_init)
I am getting the following plot of the u_init
I am using the following code for interpolating the 1D function
u_init
to a 2D function p
mesh1 = UnitSquareMesh(256, 256)
V1 = FunctionSpace(mesh1, "P", 1)
p = Function(V1)
p = interpolate(u_init, V1)
plot(p)
The plot of p
is the following
But I need the interpolation of the same function
u_init
in the x
direction and it should look likeWhat should I do? Please help.
I am using FEniCS 2019.