Commit fd2967c0 by Andreas Dedner

### bring snippet up to date in README.md

parent 4daf41e2
Pipeline #10582 passed with stage
in 5 minutes and 55 seconds
 ... ... @@ -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}) ``` ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!