Skip to content

Did I implement this simple method correctly? #2335

Discussion options

You must be logged in to vote

As David correctly pointed out, the issue was my my misunderstanding of UFL's "+"and "-". Here is the correct implementation. To experiment with it, you can change the finite element space to "DG0", "DG1", "DG2", "CG1", "CG2", etc.

from firedrake import *
import matplotlib.pyplot as plt

# spatial and time discretization
n = 100; dt = 1.0/(10*n) #overkill CFL to be safe

# initialize mesh and set initial condition
mesh = UnitIntervalMesh(n)
V = FunctionSpace(mesh, "DG", 1)
u = Function(V) # solution
x = SpatialCoordinate(mesh)[0]
u.interpolate((10**4*(0.1-x)**2*(0.2-x)**2)*(x<0.2)*(x>0.1))

# set up Heun's method
phi, v = TrialFunction(V), TestFunction(V)
a = phi * v * dx
Lv = (Constant(0…

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@APaganini
Comment options

APaganini Feb 7, 2022
Collaborator Author

@danshapero
Comment options

@wence-
Comment options

Comment options

You must be logged in to vote
1 reply
@APaganini
Comment options

APaganini Feb 7, 2022
Collaborator Author

Comment options

APaganini
Feb 7, 2022
Collaborator Author

You must be logged in to vote
0 replies
Answer selected by APaganini
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants