Last active
August 29, 2015 13:57
-
-
Save wence-/9831170 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 * | |
| m = PeriodicUnitIntervalMesh(4) | |
| V = FunctionSpace(m, 'CG', 1) | |
| print m.coordinates.dat.data | |
| u = Function(V) | |
| # Interpolate does this: | |
| to_element = V.fiat_element | |
| to_pts = [] | |
| for dual in to_element.dual_basis(): | |
| to_pts.append(dual.pt_dict.keys()[0]) | |
| coords = m.coordinates | |
| coords_space = coords.function_space() | |
| coords_element = coords_space.fiat_element | |
| X = coords_element.tabulate(0, to_pts).values()[0] | |
| for cell in range(4): | |
| for k in range(2): | |
| print cell, u.cell_node_map().values[cell][k], sum([X.T[k][i] * coords.dat.data[coords.cell_node_map().values[cell]][i] for i in range(2)]) | |
| u.dat.data[u.cell_node_map().values[cell][k]] = sum([X.T[k][i] * coords.dat.data[coords.cell_node_map().values[cell]][i] for i in range(2)]) | |
| print u.dat.data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment