diff --git a/src/TransientFETools/TransientFEOperators.jl b/src/TransientFETools/TransientFEOperators.jl index 8a1a629..02b4f7f 100644 --- a/src/TransientFETools/TransientFEOperators.jl +++ b/src/TransientFETools/TransientFEOperators.jl @@ -193,11 +193,18 @@ function TransientFEOperator(res::Function,jac::Function,jac_t::Function, end function TransientFEOperator(res::Function,trial,test;order::Integer=1) - jacs = () - for i in 1:order+1 + function jac_0(t,x,dx0,dv) + function res_0(y) + x0 = (y,x[2:end]...) + res(t,x0,dv) + end + jacobian(res_0,x[1]) + end + jacs = (jac_0,) + for i in 2:order+1 function jac_i(t,x,dxi,dv) function res_i(y) - x[i] = y + x = (x[1:i-1]...,y,x[i+1:end]...) res(t,x,dv) end jacobian(res_i,x[i]) diff --git a/test/TransientFEsTests/HeatEquationAutoDiffTests.jl b/test/TransientFEsTests/HeatEquationAutoDiffTests.jl index 3ec19eb..e548305 100644 --- a/test/TransientFEsTests/HeatEquationAutoDiffTests.jl +++ b/test/TransientFEsTests/HeatEquationAutoDiffTests.jl @@ -50,11 +50,11 @@ dv = get_fe_basis(V0) du = get_trial_fe_basis(U₀) uh = FEFunction(U₀,rand(num_free_dofs(U₀))) -cell_j = get_array(jac(0.5,uh,uh,du,dv)) -cell_j_t = get_array(jac_t(0.5,uh,uh,du,dv)) +cell_j = get_array(jac(0.5,(uh,uh),du,dv)) +cell_j_t = get_array(jac_t(0.5,(uh,uh),du,dv)) -cell_j_auto = get_array(jacobian(x->res(0.5,x,uh,dv),uh)) -cell_j_t_auto = get_array(jacobian(x->res(0.5,uh,x,dv),uh)) +cell_j_auto = get_array(jacobian(x->res(0.5,(x,uh),dv),uh)) +cell_j_t_auto = get_array(jacobian(x->res(0.5,(uh,x),dv),uh)) test_array(cell_j_auto,cell_j,≈) test_array(cell_j_t_auto,cell_j_t,≈)