Skip to content

Instantly share code, notes, and snippets.

@wence-
Created November 12, 2013 15:34
Show Gist options
  • Select an option

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

Select an option

Save wence-/7432927 to your computer and use it in GitHub Desktop.
from firedrake import *
from pyop2 import op2
m = UnitSquareMesh(40, 40)
V = VectorFunctionSpace(m, 'CG', 1)
f = Function(V)
k = op2.Kernel("""
void k(double *x, double *coords) {
double dx = coords[0] - 0.5;
double dy = coords[1] - 0.5;
x[0] = 500.0*exp(-(dx*dx + dy*dy)/0.02);
x[1] = 250.0*exp(-(dx*dx + dy*dy)/0.01);
}""", "k")
op2.par_loop(k, f.node_set, f.dat(op2.WRITE),
f.function_space().mesh()._coordinate_field.dat(op2.READ))
out = File("foo.vtu")
out << f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment