Hello,
I was trying to run heat equation from the tutorial and have this question.
How to give a user defined initial condition which is just some random 2d data. I mean, I could generate a random number matrix in 2d which I want to give as initial condition.
Here is the code from tutorial:
nx = ny = 8
mesh = UnitSquareMesh(nx, ny)
V = FunctionSpace(mesh, ‘P’, 1)
#Define boundary condition
u_D = Expression(‘1 + x[0]x[0] + alphax[1]x[1] + betat’,
degree=2, alpha=alpha, beta=beta, t=0)
def boundary(x, on_boundary):
return on_boundary
bc = DirichletBC(V, u_D, boundary)
#Define initial value
u_n = interpolate(u_D, V)
#u_n = project(u_D, V)
So in the above code instead of defining u_n using Expression and interpolate, I want to provide a matrix. Perhaps something like this:
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 2 2 2 1 1
1 1 1 2 2 2 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
So how can I do this?
Thanks!