Discontinuous Galerkin for the Nonlinear Heat Equation
- sindresb
- Topic Author
- New Member
Less
More
1 year 5 months ago #4783
by sindresb
Discontinuous Galerkin for the Nonlinear Heat Equation was created by sindresb
Dear community,
I am looking to solve the steady heat equation with temperature-dependent conductivity using the discontinuous Galerkin method. To this end, I have used Tutorial 2.8 [1] as my starting point. The code from this tutorial runs smoothly for a simple linear test problem. My next step was to update the code to use a Newton solver (like I would for a nonlinear problem) and apply it to the same linear test problem. Using the same recipe as has previously brought success in a CG-setting, I swap the sign of the term(s) that usually go in the linear form and add them instead to the bilinear form, a. I then apply the Newton solver to solve a=0. In particular, I used the Newton solver from Tutorial 3.7 [2], which has worked well for me in the past. Unfortunately, the Newton solver diverges to infinity within roughly 10 iterations.
Any hints at how to solve this problem would be much appreciated. My code can be found on Github [3].
[1] docu.ngsolve.org/v6.2.1808/i-tutorials/unit-2.8-DG/DG.html
[2] docu.ngsolve.org/nightly/i-tutorials/uni...inear/nonlinear.html
[3] gist.github.com/blakseth/de3448f60de406c3975e2f04cc744f48
Best regards,
Sindre
I am looking to solve the steady heat equation with temperature-dependent conductivity using the discontinuous Galerkin method. To this end, I have used Tutorial 2.8 [1] as my starting point. The code from this tutorial runs smoothly for a simple linear test problem. My next step was to update the code to use a Newton solver (like I would for a nonlinear problem) and apply it to the same linear test problem. Using the same recipe as has previously brought success in a CG-setting, I swap the sign of the term(s) that usually go in the linear form and add them instead to the bilinear form, a. I then apply the Newton solver to solve a=0. In particular, I used the Newton solver from Tutorial 3.7 [2], which has worked well for me in the past. Unfortunately, the Newton solver diverges to infinity within roughly 10 iterations.
Any hints at how to solve this problem would be much appreciated. My code can be found on Github [3].
[1] docu.ngsolve.org/v6.2.1808/i-tutorials/unit-2.8-DG/DG.html
[2] docu.ngsolve.org/nightly/i-tutorials/uni...inear/nonlinear.html
[3] gist.github.com/blakseth/de3448f60de406c3975e2f04cc744f48
Best regards,
Sindre
1 year 5 months ago #4791
by joachim
Replied by joachim on topic Discontinuous Galerkin for the Nonlinear Heat Equation
Hi Sindre,
your MWE is working with the upcoming nightly release (boundary-skeleton terms were missing in the AssembleLinearization).
However, I have to warn you. DG and non-linear assembling is not tested too much from our side, be careful. I would recommend to switch to HDG, if possible for you.
Joachim
your MWE is working with the upcoming nightly release (boundary-skeleton terms were missing in the AssembleLinearization).
However, I have to warn you. DG and non-linear assembling is not tested too much from our side, be careful. I would recommend to switch to HDG, if possible for you.
Joachim
The following user(s) said Thank You: sindresb
- sindresb
- Topic Author
- New Member
Less
More
1 year 5 months ago #4816
by sindresb
Replied by sindresb on topic Discontinuous Galerkin for the Nonlinear Heat Equation
Thanks a lot, Joachim
I confirm that the fix in the nightly update solved my problem. Unfortunately, I immediately encountered another (cf. bug report [1]), so I decided to give HDG a go, although I have not used it before.
Since I am interested in nonlinear problems, I wanted to adapt the HDG example from Tutorial 2.8 to use a Newton solver (the same one I used earlier). However, when I go about this the usual way, the Newton solver complains that my "a" matrix is singular (cf. minimal not-working example [2]). It is not clear to me why this is the case, as I have not modified "a" apart from the addition of the load term. Any guidance would be much appreciated!
(Note that I am here trying to solve the same linear problem as in Tutorial 2.8, just using a Newton solver instead of the matrix inversions used in the tutorial.)
[1] github.com/NGSolve/ngsolve/issues/63
[2] gist.github.com/blakseth/91da94676215c17e9ded3ed125e1b3f9
Best,
Sindre
I confirm that the fix in the nightly update solved my problem. Unfortunately, I immediately encountered another (cf. bug report [1]), so I decided to give HDG a go, although I have not used it before.
Since I am interested in nonlinear problems, I wanted to adapt the HDG example from Tutorial 2.8 to use a Newton solver (the same one I used earlier). However, when I go about this the usual way, the Newton solver complains that my "a" matrix is singular (cf. minimal not-working example [2]). It is not clear to me why this is the case, as I have not modified "a" apart from the addition of the load term. Any guidance would be much appreciated!
(Note that I am here trying to solve the same linear problem as in Tutorial 2.8, just using a Newton solver instead of the matrix inversions used in the tutorial.)
[1] github.com/NGSolve/ngsolve/issues/63
[2] gist.github.com/blakseth/91da94676215c17e9ded3ed125e1b3f9
Best,
Sindre
1 year 5 months ago #4817
by joachim
Replied by joachim on topic Discontinuous Galerkin for the Nonlinear Heat Equation
the fes.FreeDofs(..) requires an argument whether we want to invert on all non-constrained dofs, or only on the coupling dofs remaining after static condensation. Change this and your MWE is working:
du.data = a.mat.Inverse(fes.FreeDofs(a.condense)) * res
See also section 1.4 on static condensation.
Joachim
du.data = a.mat.Inverse(fes.FreeDofs(a.condense)) * res
See also section 1.4 on static condensation.
Joachim
- sindresb
- Topic Author
- New Member
Less
More
1 year 5 months ago #4820
by sindresb
Replied by sindresb on topic Discontinuous Galerkin for the Nonlinear Heat Equation
Thanks again for your help.
For anyone looking at this in the future, in addition to updating the line mentioned by Joachim, I also had to add the following two lines immediately below that line:
du.data += a.harmonic_extension * du
du.data += a.inner_solve * res
For anyone looking at this in the future, in addition to updating the line mentioned by Joachim, I also had to add the following two lines immediately below that line:
du.data += a.harmonic_extension * du
du.data += a.inner_solve * res
Time to create page: 0.092 seconds