Hi! I'm trying to solve a non linear problem following the cahn hilliard demo but I have a system made up by three equations. I have dirichlet conditions for the first and the third variables.
mesh=Mesh("brain.xml")
V = FunctionSpace(mesh,"Lagrange",1)
ME = MixedFunctionSpace([V,V,V])
g_c = Constant(0.0)
bc_c = DirichletBC(ME.sub(0), g_c, DirichletBoundary())
g_n = Constant(1.0)
bc_n = DirichletBC(ME.sub(2), g_n, DirichletBoundary())
bcs = [bc_c, bc_n]
If I define the non linear problem as
class MyTumor(NonlinearProblem):
def __init__(self, L, a, bcs):
NonlinearProblem.__init__(self)
self.L = L
self.a = a
self.bcs = bcs
def F(self, b, x):
assemble(self.L, tensor=b, bcs=self.bcs)
def J(self, A, x):
assemble(self.a, tensor=A bcs=self.bcs)
It gives me annoying warnings about applying manually the BC.
If I apply them manually :
class MyTumor(NonlinearProblem):
def __init__(self, L, a, bcs):
NonlinearProblem.__init__(self)
self.L = L
self.a = a
self.bcs = bcs
def F(self, b, x):
assemble(self.L, tensor=b)
self.bcs.apply(b,x)
def J(self, A, x):
assemble(self.a, tensor=A)
self.bcs.apply(A)
It gives me this error:
AttributeError: 'list' object has no attribute 'apply'
I recall the problem with
problem = MyTumor(L,J,[bcs])
How can I apply my Dirichlet conditions ??