The following is a simplified (linear) example of a nonlinear PDE that I am interested in.
I can solve it using solve(lhs(F) == rhs(F)...), but the nonlinear solve(F == 0...) raises as exception:
ArityMismatch: Adding expressions with non-matching form arguments ('v_0', 'v_1') vs ('v_0',).
from fenics import *
mesh = UnitIntervalMesh(4)
el_scalar = FiniteElement("Lagrange", mesh.ufl_cell(), 1)
el_vector = VectorElement("Lagrange", mesh.ufl_cell(), 1)
el = MixedElement([el_scalar, el_vector])
Vmixed = FunctionSpace(mesh, el)
vs, vv = TestFunctions(Vmixed)
T, q = TrialFunctions(Vmixed)
Vscalar = Vmixed.sub(0)
Vvector = Vmixed.sub(1)
k = Constant(1.0)
f = Constant(2.0)
F = dot(k*grad(T) + q, vv) * dx + dot(q, grad(vs)) * dx - f * vs * dx
bc = DirichletBC(Vscalar, Constant(0.0), "on_boundary")
u = Function(Vmixed)
# solve(F == 0, u, bc) # does not work
solve(lhs(F) == rhs(F), u, bc)
Hi,
nonlinear problems must involve only TestFunctions, TrialFunctions are used only to define bilinear forms in linear problems. In your above F, just replace
Thanks. If I try it, I get a different error: Edit: My bad confused u.split() and split(u).
RuntimeError:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to successfully call PETSc function 'MatSetValuesLocal'.
*** Reason: PETSc error code is: 63 (Argument out of range).
*** Where: This error was encountered inside /build/dolfin-GfMsdO/dolfin-2019.1.0/dolfin/la/PETScMatrix.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.1.0
*** Git changeset: unknown
*** -------------------------------------------------------------------------