I am trying to solve the following set of equations:
$$\frac{\partial P_x}{\partial t} + \frac{\partial D}{\partial x} = 0$$
$$\frac{\partial P_y}{\partial t} + \frac{\partial D}{\partial y} = 0$$
Where P_x is the partial derivative of a scalar function P with respect to x. For P with some boundary conditions, where D is known.
The form I use with backward Euler is:
F3 = (1.0/dt)*dot(grad(p_)-grad(p_n), v)*dx + dot(grad(D), v)*dx
a3 = lhs(F3)
L3 = rhs(F3)
A3 = assemble(a3)
When I try running this I get and error in the bcp line:
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
Newton iteration 0: r (abs) = 4.981e-01 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
Traceback (most recent call last):
...
*** Error: Unable to successfully call PETSc function 'KSPSolve'.
*** Reason: PETSc error code is: 62 (Invalid argument).
What does the error mean? Am I setting the problem up correctly? The boundary conditions I would like to add are $P_x = 0$ at $x=0$ and $x=2$ and $P_y = 0$ at $y=0$.
The code is here:
from fenics import *
dt = 0.01 # time step size
nElems = 32
# Create mesh and define function spaces
mesh = UnitSquareMesh(nElems, nElems)
V = VectorFunctionSpace(mesh, 'P', 2)
Q = FunctionSpace(mesh, 'P', 1)
# Define trial and test functions
v = TestFunction(V)
# Define functions for solutions at previous and current time steps
p_n = Function(Q)
p_ = Function(Q)
D = Function(Q)
# Define expressions used in variational forms
k = Constant(dt)
F3 = (1.0/dt)*dot(grad(p_)-grad(p_n), v)*dx + dot(grad(D), v)*dx
a3 = lhs(F3)
L3 = rhs(F3)
A3 = assemble(a3)
b3 = assemble(L3)
solve(A3, p_.vector(), b3)