Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Python Bindings for the DUNE-FEM module

Authors: Andreas Dedner, Martin Nolte, and Robert Klöfkorn

dune-fempy aims to provide Python bindings for the dune-fem discretization module. Here an example for solving Poisson's equation:

import math
from ufl import *
import dune.ufl
import dune.create as create

grid = create.grid("ALUConform", dune.grid.cartesianDomain([0, 0], [1, 1], [8, 8]), dimgrid=2)

# set up a diffusion reaction model using UFL
uflSpace = dune.ufl.Space((grid.dimGrid, grid.dimWorld), 1, field="double")
u = TrialFunction(uflSpace)
v = TestFunction(uflSpace)
x = SpatialCoordinate(uflSpace.cell())
a = (inner(grad(u), grad(v)) + inner(u,v)) * dx
# provide an exact solution that will be used to add suitable forcing and dirichlet b.c.
exact = as_vector( [cos(2.*pi*x[0])*cos(2.*pi*x[1])] )
model = create.model("elliptic", grid, a==0, exact=exact, dirichlet={ 1:exact } )

# set up a space and a conforming finite element scheme and solve the PDE
space  = dune.create.space("Lagrange", grid, dimrange=1, order=1)
scheme = create.scheme("h1", space, model, "cg")
uh,info = scheme.solve()

# make 'exact' into a grid function for output and uh into an UFL coefficient for error computation
exact_gf = create.function("ufl", grid, "exact", 5, exact)
uh_coeff = dune.ufl.GridCoefficient(uh)
# now define a grid function representing the pointwise error
l2error_gf = create.function("ufl", grid, "error", 5, as_vector([(exact[0]-uh_coeff[0])**2]) )

error = math.sqrt( l2error_gf.integrate() )
print("size:",grid.size(0),"L2-error:",error)
grid.writeVTK("laplace", pointdata=[ uh, l2error_gf, exact_gf ])

See the file COPYING for full copying permissions.

If you find this tutorial helpful for getting your own projects up and running please cite

Title: Python Bindings for the DUNE-FEM module Authors: Andreas Dedner, Martin Nolte, and Robert Klöfkorn Publisher: Zenodoo, 2020 DOI 10.5281/zenodo.3706994

DOI

Dependencies

dune-fempy depends on the following DUNE modules:

  • dune-common 2.8+
  • dune-geometry 2.8+
  • dune-grid 2.8+
  • dune-python 2.8+
  • dune-fem 2.8+

In addition to the dependencies of these DUNE modules, the following software packages are required:

  • a C++17 compatible C++ compiler
  • Python 2.7+ (although mostly tested with 3.4+)

We strongly recommend installing the following Python packages to make full use of dune-fem's Python bindings:

  • numpy
  • mpi4py
  • ufl (2016.1.0+)

git-2d404a0a28ab3122f8ae41ce03c19f1b9699eb79

Metadata

Release files for dune-fempy 2.8.0.dev20210524

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dune-fempy 2.8.0.dev20210524
File Size Uploaded Provenance Actions
dune-fempy-2.8.0.dev20210524.tar.gz 20.6 MB Without provenance Details for dune-fempy-2.8.0.dev20210524.tar.gz

Release files / dune-fempy-2.8.0.dev20210524.tar.gz

Download URL dune-fempy-2.8.0.dev20210524.tar.gz
Size 20.6 MB
Tags Source
SHA-256 checksum
How to use checksums
a24022bfb41bf9762b5c8fae7a50a4e939d0b2824cd1439a61f30fedff5f47a7
BLAKE2b-256 checksum
How to use checksums
3e74bad04706b0bf0278f61551357e4067c18c0da3a4ffcfeae58e2dd8d8535b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

Security for dune-fempy 2.8.0.dev20210524

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page