diff --git a/README.md b/README.md index 6c17dd36a9380b31abc6cdba5ed621b602585242..379dedfa0ae9417ef57b0e6d5394edf44d26d8b7 100644 --- a/README.md +++ b/README.md @@ -8,21 +8,17 @@ dune-python aims to provide Python bindings for the DUNE grid interface: ```python import math -import dune.create as create import dune.grid # instanciate a yasp grid on a [0,1]^2 domain -domain = dune.grid.cartesianDomain([0, 0], [1, 1], [10, 10]) -grid = create.grid("Yasp", domain) +grid = dune.grid.structuredGrid([0, 0], [1, 1], [10, 10]) # set up a simple grid function providing a global representation -gridfunction = grid.gridFunction(lambda x: [-(x[1] - 0.5)*math.sin(x[0]*12)]) -# iterate over the elements of the grid and output the function t barycenters -lf = gridfunction.localFunction() +@dune.grid.gridFunction(grid) +def gridfunction(x): return [-(x[1] - 0.5)*math.sin(x[0]*12)] +# iterate over the elements of the grid and output the function at barycenters for element in grid.elements(): - lf.bind(element) x = [0.5,0.5] - y = element.geometry.position(x) - print("gridfunction( ", y, " ) = ", lf(x)) - lf.unbind() + y = element.geometry.toGlobal(x) + print("gridfunction( ", y, " ) = ", gridfunction(element,x)) # write a vtk file with a piece wise linear representtion of the function grid.writeVTK("output", pointdata={'sin': gridfunction}) ```