I have so far solved the problem by calling solve(F == 0, T, BCS)
successfully solving the nonlinear heat transfer equation, but that was only in smaller time, in a larger time step to solve the docker always stuck (did not report any errors).
according to https://fenicsproject.discourse.group/t/the-solution-speed-is-very-slow/11576, I try to Avoid calling solve F==0 inside the loop, but I still have many questions:
I try to define the nonlinear variational problem before the time loop by,This comes from http://home.simula.no/~hpl/homepage/fenics-tutorial/release-1.0-nonabla/webm/nonlinear.html#tut-nonlinear-newton-algebraic :
.....
T = TrialFunction(V)
v = TestFunction(V)
F = mu*c*T*v*dx + dt*k(T_n)*dot(grad(T), grad(v))*dx - mu*c*T_n*v*dx - dt*f*v*dx - dt*sum(integrals_N)
T_= Function(V)
F = action(F,T_)
J = derivative(F, T_, T)
problem = NonlinearVariationalProblem(F, T_, bcs, J)
solver = NonlinearVariationalSolver(problem)
prm = solver.parameters
prm['newton_solver']['absolute_tolerance'] = 1E-8
prm['newton_solver']['relative_tolerance'] = 1E-7
prm['newton_solver']['maximum_iterations'] = 100
prm['newton_solver']['relaxation_parameter'] = 0.8
t = 0
for n in range(num_steps):
solver.solve()
.....
1.Can the above method avoid calling F==0 in the time loop?
2.What happens to the NonlinearVariationalProblem?Is it partially assembled and calculated?
3.Am I still solving the linearization problem with a direct solver in this form?If so, how do I through iteration method to solve, whether to need to manually go to https://jsdokken.com/dolfinx-tutorial/chapter4/newton-solver.html
Please forgive my stupidity!