Skip to content

Instantly share code, notes, and snippets.

@wence-
Created February 29, 2016 13:17
Show Gist options
  • Select an option

  • Save wence-/610f270b0f4dda38dde9 to your computer and use it in GitHub Desktop.

Select an option

Save wence-/610f270b0f4dda38dde9 to your computer and use it in GitHub Desktop.
from firedrake import *
mesh = UnitSquareMesh(1, 1)
V = FunctionSpace(mesh, 'CG', 1)
u = TrialFunction(V)
v = TestFunction(V)
f = Function(V)
problem = LinearVariationalProblem(u*v*dx, v*dx, f)
solver = LinearVariationalSolver(problem)
def monitor(snes, it, rnorm, constant):
constant.assign(10)
some_const = Constant(1)
solver.snes.setMonitor(monitor, args=(some_const, ))
solver.solve()
print some_const.dat.data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment