Created
June 2, 2015 12:12
-
-
Save wence-/6dd3b2a6c5519d044921 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from firedrake import * | |
| import numpy as np | |
| Dx = 0.1; Nx = 10 | |
| mesh = IntervalMesh(Nx, Nx*Dx) | |
| V = FunctionSpace(mesh, "DG", 0) | |
| def coord2idx(x, coords): | |
| for i, cell in enumerate(coords.cell_node_map().values): | |
| a, b = coords.dat.data_ro_with_halos[cell] | |
| a, b = (a, b) if a < b else (b, a) | |
| if a <= x < b: | |
| return i | |
| return None | |
| print "Rank " + str(op2.MPI.comm.rank) | |
| point = 0.5 | |
| idx = coord2idx(point, mesh.coordinates) | |
| print idx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment