NonlinearProblem class, assembly problems
Hi.
I am trying to implement an adaptive time integrator in FEniCS and have come across some problems I hope you can help shed some light on.
Since I am changing time step in (potentially) each iteration, I would like to do as much pre-assembly as possible before I start doing the time steps. I have read the 'avoiding assembly'-chapter in the FEniCS-book, but I am looking at a nonlinear problem, rather than a linear.
My plan is to assemble all the necessary matrices and then pass THEM to the class derived from NonlinearProblem, instead of having the class assemble the system each time.
So to my question. Why doesn't the following class work?
class MyProblem(
def __init__(self, a, L):
self.L = L
self.a = a
def F(self, b, x):
b = self.L
def J(self, A, x):
A = self.a
The remaining relevant code is as follows:
from dolfin import *
mesh = Rectangle(0, 0, 2.5, 2.5, 50, 50)
V = FunctionSpace(mesh, "Lagrange", 1)
v = TestFunction(V)
u = TrialFunction(V)
U = Function(V)
l = inner(grad(
a = derivative(l,U,u)
L = Vector()
A = Matrix()
assemble(
assemble(
solver = NewtonSolver()
problem = MySolve(A,L)
solver.
The error I get is
python: /build/
It seems like A isn't updated correctly, possibly because I am referencing it wrong. But I am somewhat lost here.
Any ideas?
Thanks in advance.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Johan Hake
- Solved:
- Last query:
- Last reply: