Hey, I need help with this:
class InitialConditions(Expression):
def eval(self, values, x):
values[0] = 0.38*((x[0]-203)**2+(x[1]-291)**2+(x[2]-27.8)**2<=225) + 0.0*((x[0]-203)**2+(x[1]-291)**2+(x[2]-27.8)**2>=225)
values[1] = 0.0
values[2] = 1.0
def value_shape(self):
return (3,)
mesh = Mesh("brain.xml")
V=FunctionSpace(mesh,"Lagrange",1)
ME = MixedFunctionSpace([V,V,V])
du = TrialFunction(ME)
q, v, w = TestFunctions(ME)
u = Function(ME)
u0 = Function(ME)
dc,dmu,dn = split(du)
c,mu,n = split(u)
c0,mu0,n0 = split(u0)
u_init = InitialConditions()
u.interpolate(u_init)
u0.interpolate(u_init)
Once I've created initial condition, I use c0 to solve a poisson like equation:
def Boundary(x, on_boundary):
return on_boundary
bc = DirichletBC(V, Constant("1.0"), Boundary)
m = TrialFunction(V)
t = TestFunction(V)
beta=1.6
a = inner(grad(m), grad(t))*dx + c0*m*t*dx + beta*m*t*dx
L = beta*t*dx
m = Function(V)
solve(a == L, m, bc)
Now I have to assign m to n0 in order to have the right initial condition for my cahn hilliard like problem!
Can anyone help??