To enjoy the differentiation and Newton method chi
would need to be implemented using UFL. I suppose that a table, you mention, would result in piece-wise expression which can be implemented using UFL Conditional
. (Differentiation of Conditional
is correct assuming that the expression is continuous.)
But I warn you that a deeply-nested combination of Conditional
s (implementing a long table) may not scale well with the size of the table.
Implementing the table using DOLFIN Expression
(possibly C++ expression for performance), treating the term using fixed-point, may be useful and efficient.
EDIT: I can imagine, the latter approach could be improved by the derivative of chi dchi
provided by the code providing chi
.
u = Function(V)
chi, dchi = compute_material_data(u) # returns Expressions
v = TestFunction(V)
F = chi*inner(grad(u), grad(v))*dx - rhs
dF = derivative(F, u) + dchi*inner(grad(u), grad(v))*dx # or using UFL replace
solve(F == 0, bcs=bcs, J=dF)
Note this can really work as a proper Newton method if Expressions chi
and dchi
have a reference to u
and update their values dynamically within each Newton step.