Download fulltext - DiVA Portal
Transcript
Algorithm 2 ESDIRK.solve 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: Get Butcher-tableau and create s Function-objects to store the stage values if linear problem then Call getLinearVariationalForms else Call getNonlinearVariationalForms end if while in the time stepping loop do Set first stage value equal to previous time step Solve for the next s − 1 stage values Estimate local error if Local error in current time step < tolerance then Accept step, calculate new step size. else Reject step, calculate new step size. end if end while Generate specified output and terminate program 2.4 A Code Example We will round off this part by showing the code required to solve the problem introduced in section 2.3: ∂u = ∇2 u + (β − 2 − 2α ), u ∈ Ω, ∂t u = 1 + x2 + y2 + β t, u ∈ ∂ Ω, u = 1 + x2 + y2 , t = 0, on the domain Ω = (x, y) ∈ [0, 1] × [0, 1] with α = 3 and β = 1.2 with u = u(x, y). Listing 2.2 shows the code for solving (2.20) using FEniCS alone. The code was constructed by following the FEniCS tutorial. Listing 2.3 shows the code for solving (2.20) using FEniCS in combination with Gryphon. The code snippets can also be found in the attached files sol_FEniCS.py and sol_FEniCS_Gryphon.py. See appendix A for details. 30