DOLFIN documentation

Contents:

Installation

Quick start

You probably want to read the FEniCS download and installation web page if you just want to get FEniCS installed as quickly and effortlessly as possible.

Building from source

Dependencies

DOLFIN requires a compiler that supports the C++11 standard.

The required and optional DOLFIN dependencies are listed below.

Required
Required for Python interface
Optional
  • HDF5, with MPI support enabled
  • MPI
  • ParMETIS [1]
  • PETSc (strongly recommended) [2]
  • SCOTCH and PT-SCOTCH [1]
  • SLEPc
  • Suitesparse [1]
  • Trilinos
  • VTK
Optional for the Python interface
  • petsc4py
  • slepc4py
  • mpi4py
  • Matplotlib
[1](1, 2, 3) It is strongly recommended to use the PETSc build system to download and configure and build these libraries.
[2]Its is recommended to configuration with ParMETIS, PT-SCOTCH, MUMPS and Hypre using the --download-parmetis --download-ptscotch --download-suitesparse --download-mumps --download-hypre

Using DOLFIN

As a new user to FEniCS we highly recommend starting with the tutorial.

Other resources that are helpful to get you started or keep you going when you get stuck:

Demo documentation

Using the Python interface

Introductory DOLFIN demos

These demos illustrate core DOLFIN/FEniCS usage and are a good way to begin learning FEniCS. We recommend that you go through these examples in the given order.

  1. Getting started: Solving the Poisson equation.
  2. Solving nonlinear PDEs: Solving a nonlinear Poisson equation
  3. Using mixed elements: Solving the Stokes equations
  4. Using iterative linear solvers: Solving the Stokes equations more efficiently

More advanced DOLFIN demos

These examples typically demonstrate how to solve a certain PDE using more advanced techniques. We recommend that you take a look at these demos for tips and tricks on how to use more advanced or lower-level functionality and optimizations.

All documented Python demos

Poisson equation

This demo is implemented in a single Python file, demo_poisson.py, which contains both the variational forms and the solver.

This demo illustrates how to:

  • Solve a linear partial differential equation
  • Create and apply Dirichlet boundary conditions
  • Define Expressions
  • Define a FunctionSpace
  • Create a SubDomain

The solution for \(u\) in this demo will look as follows:

demos/poisson/python/poisson_u.png
Equation and problem definition

The Poisson equation is the canonical elliptic partial differential equation. For a domain \(\Omega \subset \mathbb{R}^n\) with boundary \(\partial \Omega = \Gamma_{D} \cup \Gamma_{N}\), the Poisson equation with particular boundary conditions reads:

\[\begin{split}- \nabla^{2} u &= f \quad {\rm in} \ \Omega, \\ u &= 0 \quad {\rm on} \ \Gamma_{D}, \\ \nabla u \cdot n &= g \quad {\rm on} \ \Gamma_{N}. \\\end{split}\]

Here, \(f\) and \(g\) are input data and \(n\) denotes the outward directed boundary normal. The most standard variational form of Poisson equation reads: find \(u \in V\) such that

\[a(u, v) = L(v) \quad \forall \ v \in V,\]

where \(V\) is a suitable function space and

\[\begin{split}a(u, v) &= \int_{\Omega} \nabla u \cdot \nabla v \, {\rm d} x, \\ L(v) &= \int_{\Omega} f v \, {\rm d} x + \int_{\Gamma_{N}} g v \, {\rm d} s.\end{split}\]

The expression \(a(u, v)\) is the bilinear form and \(L(v)\) is the linear form. It is assumed that all functions in \(V\) satisfy the Dirichlet boundary conditions (\(u = 0 \ {\rm on} \ \Gamma_{D}\)).

In this demo, we shall consider the following definitions of the input functions, the domain, and the boundaries:

  • \(\Omega = [0,1] \times [0,1]\) (a unit square)
  • \(\Gamma_{D} = \{(0, y) \cup (1, y) \subset \partial \Omega\}\) (Dirichlet boundary)
  • \(\Gamma_{N} = \{(x, 0) \cup (x, 1) \subset \partial \Omega\}\) (Neumann boundary)
  • \(g = \sin(5x)\) (normal derivative)
  • \(f = 10\exp(-((x - 0.5)^2 + (y - 0.5)^2) / 0.02)\) (source term)
Implementation

This description goes through the implementation (in demo_poisson.py) of a solver for the above described Poisson equation step-by-step.

First, the dolfin module is imported:

from dolfin import *

We begin by defining a mesh of the domain and a finite element function space \(V\) relative to this mesh. As the unit square is a very standard domain, we can use a built-in mesh provided by the class UnitSquareMesh. In order to create a mesh consisting of 32 x 32 squares with each square divided into two triangles, we do as follows

# Create mesh and define function space
mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, "Lagrange", 1)

The second argument to FunctionSpace is the finite element family, while the third argument specifies the polynomial degree. Thus, in this case, our space V consists of first-order, continuous Lagrange finite element functions (or in order words, continuous piecewise linear polynomials).

Next, we want to consider the Dirichlet boundary condition. A simple Python function, returning a boolean, can be used to define the subdomain for the Dirichlet boundary condition (\(\Gamma_D\)). The function should return True for those points inside the subdomain and False for the points outside. In our case, we want to say that the points \((x, y)\) such that \(x = 0\) or \(x = 1\) are inside on the inside of \(\Gamma_D\). (Note that because of rounding-off errors, it is often wise to instead specify \(x < \epsilon\) or \(x > 1 - \epsilon\) where \(\epsilon\) is a small number (such as machine precision).)

# Define Dirichlet boundary (x = 0 or x = 1)
def boundary(x):
    return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS

Now, the Dirichlet boundary condition can be created using the class DirichletBC. A DirichletBC takes three arguments: the function space the boundary condition applies to, the value of the boundary condition, and the part of the boundary on which the condition applies. In our example, the function space is V, the value of the boundary condition (0.0) can represented using a Constant and the Dirichlet boundary is defined immediately above. The definition of the Dirichlet boundary condition then looks as follows:

# Define boundary condition
u0 = Constant(0.0)
bc = DirichletBC(V, u0, boundary)

Next, we want to express the variational problem. First, we need to specify the trial function \(u\) and the test function \(v\), both living in the function space \(V\). We do this by defining a TrialFunction and a TestFunction on the previously defined FunctionSpace V.

Further, the source \(f\) and the boundary normal derivative \(g\) are involved in the variational forms, and hence we must specify these. Both \(f\) and \(g\) are given by simple mathematical formulas, and can be easily declared using the Expression class. Note that the strings defining f and g use C++ syntax since, for efficiency, DOLFIN will generate and compile C++ code for these expressions at run-time.

With these ingredients, we can write down the bilinear form a and the linear form L (using UFL operators). In summary, this reads

# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", degree=2)
g = Expression("sin(5*x[0])", degree=2)
a = inner(grad(u), grad(v))*dx
L = f*v*dx + g*v*ds

Now, we have specified the variational forms and can consider the solution of the variational problem. First, we need to define a Function u to represent the solution. (Upon initialization, it is simply set to the zero function.) A Function represents a function living in a finite element function space. Next, we can call the solve function with the arguments a == L, u and bc as follows:

# Compute solution
u = Function(V)
solve(a == L, u, bc)

The function u will be modified during the call to solve. The default settings for solving a variational problem have been used. However, the solution process can be controlled in much more detail if desired.

A Function can be manipulated in various ways, in particular, it can be plotted and saved to file. Here, we output the solution to a VTK file (using the suffix .pvd) for later visualization and also plot it using the plot command:

# Save solution in VTK format
file = File("poisson.pvd")
file << u

# Plot solution
plot(u, interactive=True)
A simple eigenvalue solver

We recommend that you are familiar with the demo for the Poisson equation before looking at this demo.

If you want a more complex problem, we suggest that you look at the other eigenvalue demo.

Implementation

This demo is implemented in a single Python file, demo_eigenvalue.py and reads in an external mesh box_with_dent.xml.gz.

The eigensolver functionality in DOLFIN relies on the library SLEPc which in turn relies on the linear algebra library PETSc. Therefore, both PETSc and SLEPc are required for this demo. We can test whether PETSc and SLEPc are available, and exit if not, as follows

from dolfin import *
# Test for PETSc and SLEPc

if not has_linear_algebra_backend("PETSc"):
    print("DOLFIN has not been configured with PETSc. Exiting.")
    exit()

if not has_slepc():
    print("DOLFIN has not been configured with SLEPc. Exiting.")
    exit()

First, we need to construct the matrix \(A\). This will be done in three steps: defining the mesh and the function space associated with it; constructing the variational form defining the matrix; and then assembling this form. The code is shown below

# Define mesh, function space
mesh = Mesh("../box_with_dent.xml.gz")
V = FunctionSpace(mesh, "Lagrange", 1)

# Define basis and bilinear form
u = TrialFunction(V)
v = TestFunction(V)
a = dot(grad(u), grad(v))*dx

# Assemble stiffness form
A = PETScMatrix()
assemble(a, tensor=A)

Note that we (in this example) first define the matrix A as a PETScMatrix and then assemble the form into it. This is an easy way to ensure that the matrix has the right type.

In order to solve the eigenproblem, we need to define an eigensolver. To solve a standard eigenvalue problem, the eigensolver is initialized with a single argument, namely the matrix A.

# Create eigensolver
eigensolver = SLEPcEigenSolver(A)

Now, we ready solve the eigenproblem by calling the solve method of the eigensolver. Note that eigenvalue problems tend to be computationally intensive and may hence take a while.

# Compute all eigenvalues of A x = \lambda x
print("Computing eigenvalues. This can take a minute.")
eigensolver.solve()

The result is kept by the eigensolver, but can fortunately be extracted. Here, we have computed all eigenvalues, and they will be sorted by largest magnitude. We can extract the real and complex part (r and c) of the largest eigenvalue and the real and complex part of the corresponding eigenvector (ru and cu) by asking for the first eigenpair as follows

# Extract largest (first) eigenpair
r, c, rx, cx = eigensolver.get_eigenpair(0)

Finally, we want to examine the results. The eigenvalue can easily be printed. But, the real part of eigenvector is probably most easily visualized by constructing the corresponding eigenfunction. This can be done by creating a Function in the function space V and the associating eigenvector rx with the Function. Then the eigenfunction can be manipulated as any other Function, and in particular plotted

print("Largest eigenvalue: ", r)

# Initialize function and assign eigenvector
u = Function(V)
u.vector()[:] = rx

# Plot eigenfunction
plot(u)
interactive()
Built-in meshes

This demo is implemented in a single Python file, demo_built-in-meshes.py, and demonstrates use of the built-in meshes in DOLFIN.

This demo illustrates:

  • How to define some of the different built-in meshes in DOLFIN
Problem definition

The demo focuses on the built-in meshes. We will look at the following meshes:

  • UnitIntervalMesh
  • UnitSquareMesh
  • RectangleMesh
  • UnitCubeMesh
  • BoxMesh
Implementation

First, the dolfin module is imported:

from dolfin import *

The first mesh we make is a mesh over the unit interval \((0,1)\). UnitIntervalMesh takes the number of intervals \((n_x)\) as input argument, and the total number of vertices is therefore \((n_x+1)\).

mesh = UnitIntervalMesh(10)
print("Plotting a UnitIntervalMesh")
plot(mesh, title="Unit interval")

This produces a mesh looking as follows:

demos/built-in-meshes/python/unitintervalmesh.png

We then make our first version of a mesh on the unit square \([0,1] \times [0,1]\). We must give the number of cells in the horizontal and vertical directions as the first two arguments to UnitSquareMesh. There is a third optional argument that indicates the direction of the diagonals. This can be set to “left”, “right”, “right/left”, “left/right”, or “crossed”. We can also omit this argument and thereby use the default direction “right”.

mesh = UnitSquareMesh(10, 10)
print("Plotting a UnitSquareMesh")
plot(mesh, title="Unit square")
demos/built-in-meshes/python/unitsquaremesh.png

Our second version of a mesh on the unit square has diagonals to the left, the third version has crossed diagonals and our final version has diagonals to both left and right:

mesh = UnitSquareMesh(10, 10, "left")
print("Plotting a UnitSquareMesh")
plot(mesh, title="Unit square (left)")

mesh = UnitSquareMesh(10, 10, "crossed")
print("Plotting a UnitSquareMesh")
plot(mesh, title="Unit square (crossed)")

mesh = UnitSquareMesh(10, 10, "right/left")
print("Plotting a UnitSquareMesh")
plot(mesh, title="Unit square (right/left)")
demos/built-in-meshes/python/unitsquaremesh_left.png demos/built-in-meshes/python/unitsquaremesh_crossed.png demos/built-in-meshes/python/unitsquaremesh_left_right.png

The class RectangleMesh creates a mesh of a 2D rectangle spanned by two points (opposing corners) of the rectangle. Three additional arguments specify the number of divisions in the \(x\)- and \(y\)-directions, and as above the direction of the diagonals is given as a final optional argument (“left”, “right”, “left/right”, or “crossed”). In the first mesh we use the default direction (“right”) of the diagonal, and in the second mesh we use diagonals to both left and right.

mesh = RectangleMesh(Point(0.0, 0.0), Point(10.0, 4.0), 10, 10)
print("Plotting a RectangleMesh")
plot(mesh, title="Rectangle")

mesh = RectangleMesh(Point(-3.0, 2.0), Point(7.0, 6.0), 10, 10, "right/left")
print("Plotting a RectangleMesh")
plot(mesh, title="Rectangle (right/left)")
demos/built-in-meshes/python/rectanglemesh.png demos/built-in-meshes/python/rectanglemesh_left_right.png

To make a mesh of the 3D unit cube \([0,1] \times [0,1] \times [0,1]\), we use UnitCubeMesh. UnitCubeMesh takes the number of cells in the \(x\)-, \(y\)- and \(z\)-direction as the only three arguments.

mesh = UnitCubeMesh(10, 10, 10)
print("Plotting a UnitCubeMesh")
plot(mesh, title="Unit cube")
demos/built-in-meshes/python/unitcubemesh.png

Finally we will demonstrate a mesh on a rectangular prism in 3D. The prism is specified by two points (opposing corners) of the prism. Three additional arguments specify the number of divisions in the \(x\)-, \(y\)- and \(z\)-directions.

Meshes for more complex geometries may be created using the mshr library, which functions as a plugin to DOLFIN, providing support for Constructive Solid Geometry (CSG) and mesh generation. For more details, refer to the mshr documentation.

mesh = BoxMesh(Point(0.0, 0.0, 0.0), Point(10.0, 4.0, 2.0), 10, 10, 10)
print("Plotting a BoxMesh")
plot(mesh, title="Box")
demos/built-in-meshes/python/boxmesh.png

By calling interactive we are allowed to resize, move and rotate the plots.

interactive()
Mixed formulation for Poisson equation

This demo is implemented in a single Python file, demo_mixed-poisson.py, which contains both the variational forms and the solver.

This demo illustrates how to solve Poisson equation using a mixed (two-field) formulation. In particular, it illustrates how to

  • Use mixed and non-continuous finite element spaces
  • Set essential boundary conditions for subspaces and H(div) spaces
  • Define a (vector-valued) expression using additional geometry information
Equation and problem definition

An alternative formulation of Poisson equation can be formulated by introducing an additional (vector) variable, namely the (negative) flux: \(\sigma = \nabla u\). The partial differential equations then read

\[\begin{split}\sigma - \nabla u &= 0 \quad {\rm in} \ \Omega, \\ \nabla \cdot \sigma &= - f \quad {\rm in} \ \Omega,\end{split}\]

with boundary conditions

\[\begin{split}u = u_0 \quad {\rm on} \ \Gamma_{D}, \\ \sigma \cdot n = g \quad {\rm on} \ \Gamma_{N}.\end{split}\]

The same equations arise in connection with flow in porous media, and are also referred to as Darcy flow.

After multiplying by test functions \(\tau\) and \(v\), integrating over the domain, and integrating the gradient term by parts, one obtains the following variational formulation: find \(\sigma \in \Sigma\) and \(v \in V\) satisfying

\[ \begin{align}\begin{aligned}\begin{split}\int_{\Omega} (\sigma \cdot \tau + \nabla \cdot \tau \ u) \ {\rm d} x &= \int_{\Gamma} \tau \cdot n \ u \ {\rm d} s \quad \forall \ \tau \in \Sigma, \\\end{split}\\\int_{\Omega} \nabla \cdot \sigma v \ {\rm d} x &= - \int_{\Omega} f \ v \ {\rm d} x \quad \forall \ v \in V.\end{aligned}\end{align} \]

Here \(n\) denotes the outward pointing normal vector on the boundary. Looking at the variational form, we see that the boundary condition for the flux (\(\sigma \cdot n = g\)) is now an essential boundary condition (which should be enforced in the function space), while the other boundary condition (\(u = u_0\)) is a natural boundary condition (which should be applied to the variational form). Inserting the boundary conditions, this variational problem can be phrased in the general form: find \((\sigma, u) \in \Sigma_g \times V\) such that

\[a((\sigma, u), (\tau, v)) = L((\tau, v)) \quad \forall \ (\tau, v) \in \Sigma_0 \times V\]

where the variational forms \(a\) and \(L\) are defined as

\[\begin{split}a((\sigma, u), (\tau, v)) &= \int_{\Omega} \sigma \cdot \tau + \nabla \cdot \tau \ u + \nabla \cdot \sigma \ v \ {\rm d} x \\ L((\tau, v)) &= - \int_{\Omega} f v \ {\rm d} x + \int_{\Gamma_D} u_0 \tau \cdot n \ {\rm d} s\end{split}\]

and \(\Sigma_g = \{ \tau \in H({\rm div}) \text{ such that } \tau \cdot n|_{\Gamma_N} = g \}\) and \(V = L^2(\Omega)\).

To discretize the above formulation, two discrete function spaces \(\Sigma_h \subset \Sigma\) and \(V_h \subset V\) are needed to form a mixed function space \(\Sigma_h \times V_h\). A stable choice of finite element spaces is to let \(\Sigma_h\) be the Brezzi-Douglas-Marini elements of polynomial order \(k\) and let \(V_h\) be discontinuous elements of polynomial order \(k-1\).

We will use the same definitions of functions and boundaries as in the demo for Poisson’s equation. These are:

  • \(\Omega = [0,1] \times [0,1]\) (a unit square)
  • \(\Gamma_{D} = \{(0, y) \cup (1, y) \in \partial \Omega\}\)
  • \(\Gamma_{N} = \{(x, 0) \cup (x, 1) \in \partial \Omega\}\)
  • \(u_0 = 0\)
  • \(g = \sin(5x)\) (flux)
  • \(f = 10\exp(-((x - 0.5)^2 + (y - 0.5)^2) / 0.02)\) (source term)

With the above input the solution for \(u\) and \(\sigma\) will look as follows:

demos/mixed-poisson/python/mixed-poisson_u.png demos/mixed-poisson/python/mixed-poisson_sigma.png
Implementation

This demo is implemented in the demo_mixed-poisson.py file.

First, the dolfin module is imported:

from dolfin import *

Then, we need to create a Mesh covering the unit square. In this example, we will let the mesh consist of 32 x 32 squares with each square divided into two triangles:

# Create mesh
mesh = UnitSquareMesh(32, 32)

Next, we need to build the function space.

# Define finite elements spaces and build mixed space
BDM = FiniteElement("BDM", mesh.ufl_cell(), 1)
DG  = FiniteElement("DG", mesh.ufl_cell(), 0)
W = FunctionSpace(mesh, BDM * DG)

The second argument to FunctionSpace specifies underlying finite element, here mixed element obtained by * operator.

\[W = \{ (\tau, v) \ \text{such that} \ \tau \in BDM, v \in DG \}.\]

Next, we need to specify the trial functions (the unknowns) and the test functions on this space. This can be done as follows

# Define trial and test functions
(sigma, u) = TrialFunctions(W)
(tau, v) = TestFunctions(W)

In order to define the variational form, it only remains to define the source function \(f\). This is done just as for the Poisson demo:

# Define source function
f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", degree=2)

We are now ready to define the variational forms a and L. Since, \(u_0 = 0\) in this example, the boundary term on the right-hand side vanishes.

# Define variational form
a = (dot(sigma, tau) + div(tau)*u + div(sigma)*v)*dx
L = - f*v*dx

It only remains to prescribe the boundary condition for the flux. Essential boundary conditions are specified through the class DirichletBC which takes three arguments: the function space the boundary condition is supposed to be applied to, the data for the boundary condition, and the relevant part of the boundary.

We want to apply the boundary condition to the first subspace of the mixed space. Subspaces of a mixed FunctionSpace can be accessed by the method sub. In our case, this reads W.sub(0). (Do not use the separate space BDM as this would mess up the numbering.)

Next, we need to construct the data for the boundary condition. An essential boundary condition is handled by replacing degrees of freedom by the degrees of freedom evaluated at the given data. The \(BDM\) finite element spaces are vector-valued spaces and hence the degrees of freedom act on vector-valued objects. The effect is that the user is required to construct a \(G\) such that \(G \cdot n = g\). Such a \(G\) can be constructed by letting \(G = g n\). In particular, it can be created by subclassing the Expression class. Overloading the eval_cell method (instead of the usual eval) allows us to extract more geometry information such as the facet normals. Since this is a vector-valued expression, we also need to overload the value_shape method.

# Define function G such that G \cdot n = g
class BoundarySource(Expression):
    def __init__(self, mesh, **kwargs):
        self.mesh = mesh
    def eval_cell(self, values, x, ufc_cell):
        cell = Cell(self.mesh, ufc_cell.index)
        n = cell.normal(ufc_cell.local_facet)
        g = sin(5*x[0])
        values[0] = g*n[0]
        values[1] = g*n[1]
    def value_shape(self):
        return (2,)

G = BoundarySource(mesh, degree=2)

Specifying the relevant part of the boundary can be done as for the Poisson demo (but now the top and bottom of the unit square is the essential boundary):

# Define essential boundary
def boundary(x):
    return x[1] < DOLFIN_EPS or x[1] > 1.0 - DOLFIN_EPS

Now, all the pieces are in place for the construction of the essential boundary condition:

bc = DirichletBC(W.sub(0), G, boundary)

To compute the solution we use the bilinear and linear forms, and the boundary condition, but we also need to create a Function to store the solution(s). The (full) solution will be stored in the w, which we initialise using the FunctionSpace W. The actual computation is performed by calling solve. The separate components sigma and u of the solution can be extracted by calling the split function. Finally, we plot the solutions to examine the result.

# Compute solution
w = Function(W)
solve(a == L, w, bc)
(sigma, u) = w.split()

# Plot sigma and u
plot(sigma)
plot(u)
interactive()
Biharmonic equation

This demo is implemented in a single Python file, demo_biharmonic.py, which contains both the variational forms and the solver.

This demo illustrates how to:

  • Solve a linear partial differential equation
  • Use a discontinuous Galerkin method
  • Solve a fourth-order differential equation

The solution for \(u\) in this demo will look as follows:

demos/biharmonic/python/../biharmonic_u.png
Equation and problem definition

The biharmonic equation is a fourth-order elliptic equation. On the domain \(\Omega \subset \mathbb{R}^{d}\), \(1 \le d \le 3\), it reads

\[\nabla^{4} u = f \quad {\rm in} \ \Omega,\]

where \(\nabla^{4} \equiv \nabla^{2} \nabla^{2}\) is the biharmonic operator and \(f\) is a prescribed source term. To formulate a complete boundary value problem, the biharmonic equation must be complemented by suitable boundary conditions.

Multiplying the biharmonic equation by a test function and integrating by parts twice leads to a problem second-order derivatives, which would requires \(H^{2}\) conforming (roughly \(C^{1}\) continuous) basis functions. To solve the biharmonic equation using Lagrange finite element basis functions, the biharmonic equation can be split into two second-order equations (see the Mixed Poisson demo for a mixed method for the Poisson equation), or a variational formulation can be constructed that imposes weak continuity of normal derivatives between finite element cells. The demo uses a discontinuous Galerkin approach to impose continuity of the normal derivative weakly.

Consider a triangulation \(\mathcal{T}\) of the domain \(\Omega\), where the set of interior facets is denoted by \(\mathcal{E}_h^{\rm int}\). Functions evaluated on opposite sides of a facet are indicated by the subscripts ‘\(+\)‘ and ‘\(-\)‘. Using the standard continuous Lagrange finite element space

\[V = \left\{v \in H^{1}_{0}(\Omega)\,:\, v \in P_{k}(K) \ \forall \ K \in \mathcal{T} \right\}\]

and considering the boundary conditions

\[\begin{split}u &= 0 \quad {\rm on} \ \partial\Omega \\ \nabla^{2} u &= 0 \quad {\rm on} \ \partial\Omega\end{split}\]

a weak formulation of the biharmonic problem reads: find \(u \in V\) such that

\[a(u,v)=L(v) \quad \forall \ v \in V,\]

where the bilinear form is

\[a(u, v) = \sum_{K \in \mathcal{T}} \int_{K} \nabla^{2} u \nabla^{2} v \, {\rm d}x \ +\sum_{E \in \mathcal{E}_h^{\rm int}}\left(\int_{E} \frac{\alpha}{h_E} [\!\![ \nabla u ]\!\!] [\!\![ \nabla v ]\!\!] \, {\rm d}s - \int_{E} \left<\nabla^{2} u \right>[\!\![ \nabla v ]\!\!] \, {\rm d}s - \int_{E} [\!\![ \nabla u ]\!\!] \left<\nabla^{2} v \right> \, {\rm d}s\right)\]

and the linear form is

\[L(v) = \int_{\Omega} fv \, {\rm d}x\]

Furthermore, \(\left< u \right> = \frac{1}{2} (u_{+} + u_{-})\), \([\!\![ w ]\!\!] = w_{+} \cdot n_{+} + w_{-} \cdot n_{-}\), \(\alpha \ge 0\) is a penalty parameter and \(h_E\) is a measure of the cell size.

The input parameters for this demo are defined as follows:

  • \(\Omega = [0,1] \times [0,1]\) (a unit square)
  • \(\alpha = 8.0\) (penalty parameter)
  • \(f = 4.0 \pi^4\sin(\pi x)\sin(\pi y)\) (source term)
Implementation

This demo is implemented in the demo_biharmonic.py file.

First, the dolfin module is imported:

from dolfin import *

Next, some parameters for the form compiler are set:

# Optimization options for the form compiler
parameters["form_compiler"]["cpp_optimize"] = True
parameters["form_compiler"]["optimize"] = True

A mesh is created, and a quadratic finite element function space:

# Make mesh ghosted for evaluation of DG terms
parameters["ghost_mode"] = "shared_facet"

# Create mesh and define function space
mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, "CG", 2)

A subclass of SubDomain, DirichletBoundary is created for later defining the boundary of the domain:

# Define Dirichlet boundary
class DirichletBoundary(SubDomain):
    def inside(self, x, on_boundary):
        return on_boundary

A subclass of Expression, Source is created for the source term \(f\):

class Source(Expression):
    def eval(self, values, x):
        values[0] = 4.0*pi**4*sin(pi*x[0])*sin(pi*x[1])

The Dirichlet boundary condition is created:

# Define boundary condition
u0 = Constant(0.0)
bc = DirichletBC(V, u0, DirichletBoundary())

On the finite element space V, trial and test functions are created:

# Define trial and test functions
u = TrialFunction(V)
v = TestFunction(V)

A function for the cell size \(h\) is created, as is a function for the average size of cells that share a facet (h_avg). The UFL syntax ('+') and ('-') restricts a function to the ('+') and ('-') sides of a facet, respectively. The unit outward normal to cell boundaries (n) is created, as is the source term f and the penalty parameter alpha. The penalty parameters is made a Constant so that it can be changed without needing to regenerate code.

# Define normal component, mesh size and right-hand side
h = CellSize(mesh)
h_avg = (h('+') + h('-'))/2.0
n = FacetNormal(mesh)
f = Source(degree=2)

# Penalty parameter
alpha = Constant(8.0)

The bilinear and linear forms are defined:

# Define bilinear form
a = inner(div(grad(u)), div(grad(v)))*dx \
  - inner(avg(div(grad(u))), jump(grad(v), n))*dS \
  - inner(jump(grad(u), n), avg(div(grad(v))))*dS \
  + alpha/h_avg*inner(jump(grad(u),n), jump(grad(v),n))*dS

# Define linear form
L = f*v*dx

A Function is created to store the solution and the variational problem is solved:

# Solve variational problem
u = Function(V)
solve(a == L, u, bc)

The computed solution is written to a file in VTK format and plotted to the screen.

# Save solution to file
file = File("biharmonic.pvd")
file << u

# Plot solution
plot(u, interactive=True)
Auto adaptive Poisson equation

This demo is implemented in a single Python file, demo_auto-adaptive-poisson.py, which contains both the variational forms and the solver.

In this demo we will use goal oriented adaptivity and error control which applies a duality technique to derive error estimates taken directly from the computed solution which then are used to weight local residuals. To this end, we derive an \(\textit{a posteriori}\) error estimate and error indicators. We define a goal functional \(\mathcal{M} : V \rightarrow \mathbb{R}\), which expresses the localized physical properties of the solution of a simulation. The objective of goal oriented adaptive error control is to minimize computational work to obtain a given level of accuracy in \(\mathcal{M}\).

We will thus illustrate how to:

  • Solve a linear partial differential equation with automatic adaptive mesh refinement
  • Define a goal functional
  • Use AdaptiveLinearVariationalSolver

The two solutions for u in this demo will look as follows, where the first is the unrefined while the second is the refined solution:

demos/auto-adaptive-poisson/python/../u_unrefined.png demos/auto-adaptive-poisson/python/../u_refined.png
Equation and problem definition

The Poisson equation is the canonical elliptic partial differential equation. For a domain \(\Omega \subset \mathbb{R}^n\) with boundary \(\partial \Omega = \Gamma_{D} \cup \Gamma_{N}\), the Poisson equation with particular boundary conditions reads:

\[\begin{split}- \nabla^{2} u &= f \quad {\rm in} \ \Omega, \\ u &= 0 \quad {\rm on} \ \Gamma_{D}, \\ \nabla u \cdot n &= g \quad {\rm on} \ \Gamma_{N}. \\\end{split}\]

Here, \(f\) and \(g\) are input data and n denotes the outward directed boundary normal. The variational form of Poisson equation reads: find \(u \in V\) such that

\[a(u, v) = L(v) \quad \forall \ v \in \hat{V},\]

which we will call the continous primal problem, where \(V\), \(\hat{V}\) are the trial- and test spaces and

\[\begin{split}a(u, v) &= \int_{\Omega} \nabla u \cdot \nabla v \, {\rm d} x, \\ L(v) &= \int_{\Omega} f v \, {\rm d} x + \int_{\Gamma_{N}} g v \, {\rm d} s.\end{split}\]

The expression \(a(u, v)\) is the bilinear form and \(L(v)\) is the linear form. It is assumed that all functions in \(V\) satisfy the Dirichlet boundary conditions (\(u = 0 \ {\rm on} \ \Gamma_{D}\)).

The above definitions is that of the continuous problem. In the actual computer implementation we use a descrete formulation which reads: find \(u \in V_h\) such that

\[a(u_h, v) = L(v) \quad \forall \ v \in \hat{V}_h.\]

We will refer to the above equation as the discrete primal problem. Here, \(V_h\) and \(\hat{V_h}\) are finite dimensional subspaces.

The weak residual is defined as

\[r(v) = L(v) - a(u_h, v).\]

By the Galerkin orthogonality, we have

\[r(v) = L(v) - a(u_h, v) = a(u_h, v) - a(u_h, v) = 0\,\, \forall v \in \hat{V}_{h},\]

which means that the residual vanishes for all functions in \(\hat{V}_{h}\). This property is used further in the derivation of the error estimates. wish to compute a solution \(u_h\) to the discrete primal problem defined above such that for a given tolerance \(\mathrm{TOL}\) we have

\[\eta = \left| \mathcal{M}(u_h) - \mathcal{u_h} \right| \leq \mathrm{TOL}.\]

Next we derive an \(\textit{a posteriori}\) error estimate by defining the discrete dual variational problem: find \(z_h \in V_h^*\) such that

Here \(V^*, \hat{V}_h^*\) are the dual trial- and test spaces and \(a^* : V^* \times \hat{V}^* \rightarrow \mathbb{R}\) is the adjoint of \(a\) such that \(a^*(v,w) = a(w,v)\). We find that

\[\mathcal{M}(u - \mathcal{u_h}) = a^*(z, u - u_h) = a(u - u_h, z) = a(u,z) - a(u_h,z) = L(z) - a(u_h,z) = r(z)\]

and by Galerkin orthogonality we have \(r(z) = r(z - v_h)\,\, \forall v_h \in \hat{V}_h\). Note that the residual vanishes if \(z \in \hat{V}_h^*\) and has to either be approximated in a higher order element space or one may use an extrapolation. The choice of goal functional depends on what quantity you are interested in. Here, we take the goal functional to be defined as

\[\mathcal{M}(u) = \int_{\Omega} u dx.\]

We use \(D\ddot{o}rfler\) marking as the mesh marking procedure.

In this demo, we shall consider the following definitions of the input functions, the domain, and the boundaries:

  • \(\Omega = [0,1] \times [0,1]\,\) (a unit square)
  • \(\Gamma_{D} = \{(0, y) \cup (1, y) \subset \partial \Omega\}\,\) (Dirichlet boundary)
  • \(\Gamma_{N} = \{(x, 0) \cup (x, 1) \subset \partial \Omega\}\,\) (Neumann boundary)
  • \(g = \sin(5x)\,\) (normal derivative)
  • \(f = 10\exp(-((x - 0.5)^2 + (y - 0.5)^2) / 0.02)\,\) (source term)
Implementation

This description goes through the implementation (in demo_auto-adaptive-poisson.py) of a solver for the above described Poisson equation step-by-step.

First, the dolfin module is imported:

from dolfin import *

We begin by defining a mesh of the domain and a finite element function space V relative to this mesh. We used the built-in mesh provided by the class UnitSquareMesh. In order to create a mesh consisting of 8 x 8 squares with each square divided into two triangles, we do as follows:

# Create mesh and define function space
mesh = UnitSquareMesh(8, 8)
V = FunctionSpace(mesh, "Lagrange", 1)

The second argument to FunctionSpace, “Lagrange”, is the finite element family, while the third argument specifies the polynomial degree. Thus, in this case, our space V consists of first-order, continuous Lagrange finite element functions (or in order words, continuous piecewise linear polynomials).

Next, we want to consider the Dirichlet boundary condition. In our case, we want to say that the points (x, y) such that x = 0 or x = 1 are inside on the inside of \(\Gamma_D\). (Note that because of rounding-off errors, it is often wise to instead specify \(x < \epsilon\) or \(x > 1 - \epsilon\) where \(\epsilon\) is a small number (such as machine precision).)

# Define boundary condition
u0 = Function(V)
bc = DirichletBC(V, u0, "x[0] < DOLFIN_EPS || x[0] > 1.0 - DOLFIN_EPS")

Next, we want to express the variational problem. First, we need to specify the trial function u and the test function v, both living in the function space V. We do this by defining a TrialFunction and a TestFunction on the previously defined FunctionSpace V.

Further, the source f and the boundary normal derivative g are involved in the variational forms, and hence we must specify these. Both f and g are given by simple mathematical formulas, and can be easily declared using the Expression class. Note that the strings defining f and g use C++ syntax since, for efficiency, DOLFIN will generate and compile C++ code for these expressions at run-time.

With these ingredients, we can write down the bilinear form a and the linear form L (using UFL operators). In summary, this reads:

# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)",
               degree=1)
g = Expression("sin(5*x[0])", degree=1)
a = inner(grad(u), grad(v))*dx()
L = f*v*dx() + g*v*ds()

Now, we have specified the variational forms and can consider the solution of the variational problem. First, we need to define a Function u to represent the solution. (Upon initialization, it is simply set to the zero function.) A Function represents a function living in a finite element function space.

# Define function for the solution
u = Function(V)

Then define the goal functional:

# Define goal functional (quantity of interest)
M = u*dx()

Next we specify the error tolerance for when the refinement shall stop:

# Define error tolerance
tol = 1.e-5

Now, we have specified the variational forms and can consider the solution of the variational problem. First, we define the LinearVariationalProblem function with the arguments a, L, u and bc. Next we send this problem to the AdaptiveLinearVariationalSolver together with the goal functional. Note that one may also choose several adaptations in the error control. At last we solve the problem with the defined tolerance:

# Solve equation a = L with respect to u and the given boundary
# conditions, such that the estimated error (measured in M) is less
# than tol
problem = LinearVariationalProblem(a, L, u, bc)
solver = AdaptiveLinearVariationalSolver(problem, M)
solver.parameters["error_control"]["dual_variational_solver"]["linear_solver"] = "cg"
solver.parameters["error_control"]["dual_variational_solver"]["symmetric"] = True
solver.solve(tol)

solver.summary()

# Plot solution(s)
plot(u.root_node(), title="Solution on initial mesh")
plot(u.leaf_node(), title="Solution on final mesh")
interactive()
Cahn-Hilliard equation

This demo is implemented in a single Python file, demo_cahn-hilliard.py, which contains both the variational forms and the solver.

This example demonstrates the solution of a particular nonlinear time-dependent fourth-order equation, known as the Cahn-Hilliard equation. In particular it demonstrates the use of

  • The built-in Newton solver
  • Advanced use of the base class NonlinearProblem
  • Automatic linearisation
  • A mixed finite element method
  • The \(\theta\)-method for time-dependent equations
  • User-defined Expressions as Python classes
  • Form compiler options
  • Interpolation of functions
Equation and problem definition

The Cahn-Hilliard equation is a parabolic equation and is typically used to model phase separation in binary mixtures. It involves first-order time derivatives, and second- and fourth-order spatial derivatives. The equation reads:

\[\begin{split}\frac{\partial c}{\partial t} - \nabla \cdot M \left(\nabla\left(\frac{d f}{d c} - \lambda \nabla^{2}c\right)\right) &= 0 \quad {\rm in} \ \Omega, \\ M\left(\nabla\left(\frac{d f}{d c} - \lambda \nabla^{2}c\right)\right) \cdot n &= 0 \quad {\rm on} \ \partial\Omega, \\ M \lambda \nabla c \cdot n &= 0 \quad {\rm on} \ \partial\Omega.\end{split}\]

where \(c\) is the unknown field, the function \(f\) is usually non-convex in \(c\) (a fourth-order polynomial is commonly used), \(n\) is the outward directed boundary normal, and \(M\) is a scalar parameter.

Mixed form

The Cahn-Hilliard equation is a fourth-order equation, so casting it in a weak form would result in the presence of second-order spatial derivatives, and the problem could not be solved using a standard Lagrange finite element basis. A solution is to rephrase the problem as two coupled second-order equations:

\[\begin{split}\frac{\partial c}{\partial t} - \nabla \cdot M \nabla\mu &= 0 \quad {\rm in} \ \Omega, \\ \mu - \frac{d f}{d c} + \lambda \nabla^{2}c &= 0 \quad {\rm in} \ \Omega.\end{split}\]

The unknown fields are now \(c\) and \(\mu\). The weak (variational) form of the problem reads: find \((c, \mu) \in V \times V\) such that

\[\begin{split}\int_{\Omega} \frac{\partial c}{\partial t} q \, {\rm d} x + \int_{\Omega} M \nabla\mu \cdot \nabla q \, {\rm d} x &= 0 \quad \forall \ q \in V, \\ \int_{\Omega} \mu v \, {\rm d} x - \int_{\Omega} \frac{d f}{d c} v \, {\rm d} x - \int_{\Omega} \lambda \nabla c \cdot \nabla v \, {\rm d} x &= 0 \quad \forall \ v \in V.\end{split}\]
Time discretisation

Before being able to solve this problem, the time derivative must be dealt with. Apply the \(\theta\)-method to the mixed weak form of the equation:

\[\begin{split}\int_{\Omega} \frac{c_{n+1} - c_{n}}{dt} q \, {\rm d} x + \int_{\Omega} M \nabla \mu_{n+\theta} \cdot \nabla q \, {\rm d} x &= 0 \quad \forall \ q \in V \\ \int_{\Omega} \mu_{n+1} v \, {\rm d} x - \int_{\Omega} \frac{d f_{n+1}}{d c} v \, {\rm d} x - \int_{\Omega} \lambda \nabla c_{n+1} \cdot \nabla v \, {\rm d} x &= 0 \quad \forall \ v \in V\end{split}\]

where \(dt = t_{n+1} - t_{n}\) and \(\mu_{n+\theta} = (1-\theta) \mu_{n} + \theta \mu_{n+1}\). The task is: given \(c_{n}\) and \(\mu_{n}\), solve the above equation to find \(c_{n+1}\) and \(\mu_{n+1}\).

Demo parameters

The following domains, functions and time stepping parameters are used in this demo:

  • \(\Omega = (0, 1) \times (0, 1)\) (unit square)
  • \(f = 100 c^{2} (1-c)^{2}\)
  • \(\lambda = 1 \times 10^{-2}\)
  • \(M = 1\)
  • \(dt = 5 \times 10^{-6}\)
  • \(\theta = 0.5\)
Implementation

This demo is implemented in the demo_cahn-hilliard.py file.

First, the Python module random and the dolfin module are imported:

import random
from dolfin import *

A class which will be used to represent the initial conditions is then created:

# Class representing the intial conditions
class InitialConditions(Expression):
    def __init__(self, **kwargs):
        random.seed(2 + MPI.rank(mpi_comm_world()))
    def eval(self, values, x):
        values[0] = 0.63 + 0.02*(0.5 - random.random())
        values[1] = 0.0
    def value_shape(self):
        return (2,)

It is a subclass of Expression. In the constructor (__init__), the random number generator is seeded. If the program is run in parallel, the random number generator is seeded using the rank (process number) to ensure a different sequence of numbers on each process. The function eval returns values for a function of dimension two. For the first component of the function, a randomized value is returned. The method value_shape declares that the Expression is vector valued with dimension two.

A class which will represent the Cahn-Hilliard in an abstract from for use in the Newton solver is now defined. It is a subclass of NonlinearProblem.

# Class for interfacing with the Newton solver
class CahnHilliardEquation(NonlinearProblem):
    def __init__(self, a, L):
        NonlinearProblem.__init__(self)
        self.L = L
        self.a = a
    def F(self, b, x):
        assemble(self.L, tensor=b)
    def J(self, A, x):
        assemble(self.a, tensor=A)

The constructor (__init__) stores references to the bilinear (a) and linear (L) forms. These will used to compute the Jacobian matrix and the residual vector, respectively, for use in a Newton solver. The function F and J are virtual member functions of NonlinearProblem. The function F computes the residual vector b, and the function J computes the Jacobian matrix A.

Next, various model parameters are defined:

# Model parameters
lmbda  = 1.0e-02  # surface parameter
dt     = 5.0e-06  # time step
theta  = 0.5      # time stepping family, e.g. theta=1 -> backward Euler, theta=0.5 -> Crank-Nicolson

It is possible to pass arguments that control aspects of the generated code to the form compiler. The lines

# Form compiler options
parameters["form_compiler"]["optimize"]     = True
parameters["form_compiler"]["cpp_optimize"] = True

tell the form to apply optimization strategies in the code generation phase and the use compiler optimization flags when compiling the generated C++ code. Using the option ["optimize"] = True will generally result in faster code (sometimes orders of magnitude faster for certain operations, depending on the equation), but it may take considerably longer to generate the code and the generation phase may use considerably more memory).

A unit square mesh with 97 (= 96 + 1) vertices in each direction is created, and on this mesh a FunctionSpace ME is built using a pair of linear Lagrangian elements.

# Create mesh and build function space
mesh = UnitSquareMesh(96, 96)
P1 = FiniteElement("Lagrange", mesh.ufl_cell(), 1)
ME = FunctionSpace(mesh, P1*P1)

Trial and test functions of the space ME are now defined:

# Define trial and test functions
du    = TrialFunction(ME)
q, v  = TestFunctions(ME)

For the test functions, TestFunctions (note the ‘s’ at the end) is used to define the scalar test functions q and v. The TrialFunction du has dimension two. Some mixed objects of the Function class on ME are defined to represent \(u = (c_{n+1}, \mu_{n+1})\) and \(u0 = (c_{n}, \mu_{n})\), and these are then split into sub-functions:

# Define functions
u   = Function(ME)  # current solution
u0  = Function(ME)  # solution from previous converged step

# Split mixed functions
dc, dmu = split(du)
c,  mu  = split(u)
c0, mu0 = split(u0)

The line c, mu = split(u) permits direct access to the components of a mixed function. Note that c and mu are references for components of u, and not copies.

Initial conditions are created by using the class defined at the beginning of the demo and then interpolating the initial conditions into a finite element space:

# Create intial conditions and interpolate
u_init = InitialConditions(degree=1)
u.interpolate(u_init)
u0.interpolate(u_init)

The first line creates an object of type InitialConditions. The following two lines make u and u0 interpolants of u_init (since u and u0 are finite element functions, they may not be able to represent a given function exactly, but the function can be approximated by interpolating it in a finite element space).

The chemical potential \(df/dc\) is computed using automated differentiation:

# Compute the chemical potential df/dc
c = variable(c)
f    = 100*c**2*(1-c)**2
dfdc = diff(f, c)

The first line declares that c is a variable that some function can be differentiated with respect to. The next line is the function \(f\) defined in the problem statement, and the third line performs the differentiation of f with respect to the variable c.

It is convenient to introduce an expression for \(\mu_{n+\theta}\):

# mu_(n+theta)
mu_mid = (1.0-theta)*mu0 + theta*mu

which is then used in the definition of the variational forms:

# Weak statement of the equations
L0 = c*q*dx - c0*q*dx + dt*dot(grad(mu_mid), grad(q))*dx
L1 = mu*v*dx - dfdc*v*dx - lmbda*dot(grad(c), grad(v))*dx
L = L0 + L1

This is a statement of the time-discrete equations presented as part of the problem statement, using UFL syntax. The linear forms for the two equations can be summed into one form L, and then the directional derivative of L can be computed to form the bilinear form which represents the Jacobian matrix:

# Compute directional derivative about u in the direction of du (Jacobian)
a = derivative(L, u, du)

The DOLFIN Newton solver requires a NonlinearProblem object to solve a system of nonlinear equations. Here, we are using the class CahnHilliardEquation, which was declared at the beginning of the file, and which is a sub-class of NonlinearProblem. We need to instantiate objects of both CahnHilliardEquation and NewtonSolver:

# Create nonlinear problem and Newton solver
problem = CahnHilliardEquation(a, L)
solver = NewtonSolver()
solver.parameters["linear_solver"] = "lu"
solver.parameters["convergence_criterion"] = "incremental"
solver.parameters["relative_tolerance"] = 1e-6

The string "lu" passed to the Newton solver indicated that an LU solver should be used. The setting of parameters["convergence_criterion"] = "incremental" specifies that the Newton solver should compute a norm of the solution increment to check for convergence (the other possibility is to use "residual", or to provide a user-defined check). The tolerance for convergence is specified by parameters["relative_tolerance"] = 1e-6.

To run the solver and save the output to a VTK file for later visualization, the solver is advanced in time from \(t_{n}\) to \(t_{n+1}\) until a terminal time \(T\) is reached:

# Output file
file = File("output.pvd", "compressed")

# Step in time
t = 0.0
T = 50*dt
while (t < T):
    t += dt
    u0.vector()[:] = u.vector()
    solver.solve(problem, u.vector())
    file << (u.split()[0], t)

The string "compressed" indicates that the output data should be compressed to reduce the file size. Within the time stepping loop, the solution vector associated with u is copied to u0 at the beginning of each time step, and the nonlinear problem is solved by calling solver.solve(problem, u.vector()), with the new solution vector returned in u.vector(). The c component of the solution (the first component of u) is then written to file at every time step.

Finally, the last computed solution for \(c\) is plotted to the screen:

plot(u.split()[0])
interactive()

The line interactive() holds the plot (waiting for a keyboard action).

Stable and unstable finite elements for the Maxwell eigenvalue problem

The Maxwell eigenvalue problem seeks eigenvalues \(\lambda\) and the corresponding nonzero vector-valued eigenfunctions \(u\) satisfying the partial differential equation

\[\operatorname{curl}\operatorname{curl} u = \lambda u \text{ in $\Omega$}\]

(we have simplified slightly by setting the material parameters equal to 1). The PDE is to be supplemented with boundary conditions, which we take here to be the essential boundary condition

\[u \times n = 0 \text{ on $\partial\Omega$}.\]

The eigenvalues \(\lambda\) are all real and non-negative, but only the positive ones are of interest, since, if \(\lambda >0\), then it follows from the PDE that \(\operatorname{div} u = 0\), which is also a requirement of Maxwell’s equations. There exist, in addition, an infinite-dimensional family of eigenfunctions with eigenvalue \(\lambda=0\), since for any smooth function \(\phi\) vanishing to second order on the boundary, \(u=\operatorname{grad}\phi\) is such an eigenfunction. But these functions are not divergence-free and should not be considered Maxwell eigenfunctions.

Model problem

In this demo we shall consider the Maxwell eigenvalue problem in two dimensions with the domain \(\Omega\) taken to be the square \((0,\pi)\times(0,\pi)\), since in that case the exact eigenpairs have a simple analytic expression. They are

\[u(x,y) = (\sin m x, \sin n y), \quad \lambda = m^2 + n^2,\]

for any non-negative integers \(m\) and \(n,\) not both zero. Thus the eigenvalues are

\[\lambda = 1, 1, 2, 4, 4, 5, 5, 8, 9, 9, 10, 10, 13, 13, \dots\]

In the demo program we compute the 12 eigenvalues nearest 5.5, and so should obtain the first 12 numbers on this list, ranging from 1 to 10.

The weak formulation and the finite element method

A weak formulation of the eigenvalue problem seeks \(0\ne u\in H_0(\operatorname{curl})\) and \(\lambda>0\) such that

\[\int_{\Omega} \operatorname{curl} u\, \operatorname{curl}v\, {\rm d} x = \lambda \int_{\Omega} u v\, {\rm d} x \quad \forall \ v\in H_0(\operatorname{curl}),\]

where \(H_0(\operatorname{curl})\) is the space of square-integrable vector fields with square-integrable curl and satisfying the essential boundary condition. If we replace \(H_0(\operatorname{curl})\) in this formulation by a finite element subspace, we obtain a finite element method.

Stable and unstable finite elements

We consider here two possible choices of finite element spaces. The first, the Nédélec edge elements, which are obtained in FEniCS as FunctionSpace(mesh, 'H1curl', 1), are well suited to this problem and give an accurate discretization. The second choice is simply the vector-valued Lagrange piecewise linears: VectorFunctionSpace(mesh, 'Lagrange', 1). To the uninitiated it usually comes as a surprise that the Lagrange elements do not provide an accurate discretization of the Maxwell eigenvalue problem: the computed eigenvalues do not converge to the true ones as the mesh is refined! This is a subtle matter connected to the stability theory of mixed finite element methods. See this paper for details.

While the Nédélec elements behave stably for any mesh, the failure of the Lagrange elements differs on different sorts of meshes. Here we compute with two structured meshes, the first obtained from a \(40\times 40\) grid of squares by dividing each with its positively-sloped diagonal, and the second the crossed mesh obtained by dividing each subsquare into four using both diagonals. The output from the first case is:

diagonal mesh
Nédélec:   [ 1.00  1.00  2.00  4.00  4.00  5.00  5.00  8.01  8.98  8.99  9.99  9.99]
Lagrange:  [ 5.16  5.26  5.26  5.30  5.39  5.45  5.53  5.61  5.61  5.62  5.71  5.73]
Exact:     [ 1.00  1.00  2.00  4.00  4.00  5.00  5.00  8.00  9.00  9.00 10.00 10.00]

Note that the eigenvalues calculated using the Nédélec elements are all correct to within a fraction of a percent. But the 12 eigenvalues computed by the Lagrange elements are certainly all wrong, since they are far from being integers!

On the crossed mesh, we obtain a different mode of failure:

crossed mesh
Nédélec:   [ 1.00  1.00  2.00  4.00  4.00  5.00  5.00  7.99  9.00  9.00 10.00 10.00]
Lagrange:  [ 1.00  1.00  2.00  4.00  4.00  5.00  5.00  6.00  8.01  9.01  9.01 10.02]
Exact:     [ 1.00  1.00  2.00  4.00  4.00  5.00  5.00  8.00  9.00  9.00 10.00 10.00]

Again the Nédélec elements are accurate. The Lagrange elements also approximate most of the eigenvalues well, but they return a totally spurious value of 6.00 as well. If we were to compute more eigenvalues, more spurious ones would be returned. This mode of failure might be considered more dangerous, since it is harder to spot.

The implementation

Preamble. First we import dolfin and numpy and make sure that dolfin has been configured with PETSc and SLEPc (since we depend on the SLEPc eigenvalue solver).

from dolfin import *
import numpy as np
if not has_linear_algebra_backend("PETSc"):
    print("DOLFIN has not been configured with PETSc. Exiting.")
    exit()
if not has_slepc():
    print("DOLFIN has not been configured with SLEPc. Exiting.")
    exit()

Function eigenvalues. The function eigenvalues takes the finite element space V and the essential boundary conditions bcs for it, and returns a requested set of Maxwell eigenvalues (specified in the code below) as a sorted numpy array:

def eigenvalues(V, bcs):

We start by defining the bilinear forms on the right- and left-hand sides of the weak formulation:

#
    # Define the bilinear forms on the right- and left-hand sides
    u = TrialFunction(V)
    v = TestFunction(V)
    a = inner(curl(u), curl(v))*dx
    b = inner(u, v)*dx

Next we assemble the bilinear forms a and b into PETSc matrices A and B, so the eigenvalue problem is converted into a generalized matrix eigenvalue problem \(Ax=\lambda B x\). During the assembly step the essential boundary conditions are incorporated by modifying the rows and columns of the matrices corresponding to constrained boundary degrees of freedom. We use assemble_system rather than assemble to do the assembly, since it maintains the symmetry of the matrices. assemble_system is designed for source problems, rather than eigenvalue problems, and requires a right-hand side linear form, so we define a dummy form to feed it.

#
    # Assemble into PETSc matrices
    dummy = v[0]*dx
    A = PETScMatrix()
    assemble_system(a, dummy, bcs, A_tensor=A)
    B = PETScMatrix()
    assemble_system(b, dummy, bcs, A_tensor=B)

We zero out the rows of \(B\) corresponding to constrained boundary degrees of freedom, so as not to introduce spurious eigenpairs with nonzero boundary DOFs.

#
    [bc.zero(B) for bc in bcs]

Now we solve the generalized matrix eigenvalue problem using the SLEPc package. The behavior of the SLEPcEigenSolver is controlled by a parameter set (use info(solver, True) to see all possible parameters). We use parameters to set the eigensolution method to Krylov-Schur, which is good for computing a subset of the eigenvalues of a sparse matrix, and to tell SLEPc that the matrices A and B in the generalized eigenvalue problem are symmetric (Hermitian).

#
    solver = SLEPcEigenSolver(A, B)
    solver.parameters["solver"] = "krylov-schur"
    solver.parameters["problem_type"] = "gen_hermitian"

We specify that we want 12 eigenvalues nearest in magnitude to a target value of 5.5. Note that when the spectrum parameter is set to target magnitude, the spectral_transform parameter should be set to shift-and-invert and the spectral_shift parameter should be set equal to the target.

#
    solver.parameters["spectrum"] = "target magnitude"
    solver.parameters["spectral_transform"] = "shift-and-invert"
    solver.parameters["spectral_shift"] = 5.5
    neigs = 12
    solver.solve(neigs)

Finally we collect the computed eigenvalues in list which we convert to a numpy array and sort before returning. Note that we are not guaranteed to get the number of eigenvalues requested. The function solver.get_number_converged() reports the actual number of eigenvalues computed, which may be more or less than the number requested.

#
    # Return the computed eigenvalues in a sorted array
    computed_eigenvalues = []
    for i in range(min(neigs, solver.get_number_converged())):
        r, _ = solver.get_eigenvalue(i) # ignore the imaginary part
        computed_eigenvalues.append(r)
    return np.sort(np.array(computed_eigenvalues))

Function print_eigenvalues. Given just a mesh, the function print_eigenvalues calls the preceding function eigenvalues to solve the Maxwell eigenvalue problem for each of the two finite element spaces, Nédélec and Lagrange, and prints the results, together with the known exact eigenvalues:

def print_eigenvalues(mesh):

First we define the Nédélec edge element space and the essential boundary conditions for it, and call eigenvalues to compute the eigenvalues. Since the degrees of freedom for the Nédélec space are tangential components on element edges, we simply need to constrain all the DOFs associated to boundary points to zero.

#
    nedelec_V   = FunctionSpace(mesh, "N1curl", 1)
    nedelec_bcs = [DirichletBC(nedelec_V, Constant((0.0, 0.0)), DomainBoundary())]
    nedelec_eig = eigenvalues(nedelec_V, nedelec_bcs)

Then we do the same for the vector Lagrange elements. Since the Lagrange DOFs are both components of the vector, we must specify which component must vanish on which edges (the x-component on horizontal edges and the y-component on vertical edges).

#
    lagrange_V   = VectorFunctionSpace(mesh, "Lagrange", 1)
    lagrange_bcs = [DirichletBC(lagrange_V.sub(1), 0, "near(x[0], 0) || near(x[0], pi)"),
                    DirichletBC(lagrange_V.sub(0), 0, "near(x[1], 0) || near(x[1], pi)")]
    lagrange_eig = eigenvalues(lagrange_V, lagrange_bcs)

The true eigenvalues are just the 12 smallest numbers of the form \(m^2 + n^2\), \(m,n\ge0\), not counting 0.

#
    true_eig = np.sort(np.array([float(m**2 + n**2) for m in range(6) for n in range(6)]))[1:13]

Finally we print the results:

#
    np.set_printoptions(formatter={'float': '{:5.2f}'.format})
    print("Nedelec:  {}".format(nedelec_eig))
    print("Lagrange: {}".format(lagrange_eig))
    print("Exact:    {}".format(true_eig))

Calling the functions. To complete the program, we call print_eigenvalues for each of two different meshes

mesh = RectangleMesh(Point(0, 0), Point(pi, pi), 40, 40)
print("\ndiagonal mesh")
print_eigenvalues(mesh)

mesh = RectangleMesh(Point(0, 0), Point(pi, pi), 40, 40, "crossed")
print("\ncrossed mesh")
print_eigenvalues(mesh)
Hyperelasticity

This demo is implemented in a single Python file, demo_hyperelasticity.py, which contains both the variational forms and the solver.

Background

See the section hyperelasticity for some mathematical background on this demo.

Implementation

This demo is implemented in the demo_hyperelasticity.py file.

First, the dolfin module is imported:

from dolfin import *

The behavior of the form compiler FFC can be adjusted by prescribing various parameters. Here, we want to use the UFLACS backend of FFC:

# Optimization options for the form compiler
parameters["form_compiler"]["cpp_optimize"] = True
parameters["form_compiler"]["representation"] = "uflacs"

The first line tells the form compiler to use C++ compiler optimizations when compiling the generated code. The remainder is a dictionary of options which will be passed to the form compiler. It lists the optimizations strategies that we wish the form compiler to use when generating code.

First, we need a tetrahedral mesh of the domain and a function space on this mesh. Here, we choose to create a unit cube mesh with 25 ( = 24 + 1) vertices in one direction and 17 ( = 16 + 1) vertices in the other two direction. On this mesh, we define a function space of continuous piecewise linear vector polynomials (a Lagrange vector element space):

# Create mesh and define function space
mesh = UnitCubeMesh(24, 16, 16)
V = VectorFunctionSpace(mesh, "Lagrange", 1)

Note that VectorFunctionSpace creates a function space of vector fields. The dimension of the vector field (the number of components) is assumed to be the same as the spatial dimension, unless otherwise specified.

The portions of the boundary on which Dirichlet boundary conditions will be applied are now defined:

# Mark boundary subdomians
left =  CompiledSubDomain("near(x[0], side) && on_boundary", side = 0.0)
right = CompiledSubDomain("near(x[0], side) && on_boundary", side = 1.0)

The boundary subdomain left corresponds to the part of the boundary on which \(x=0\) and the boundary subdomain right corresponds to the part of the boundary on which \(x=1\). Note that C++ syntax is used in the CompiledSubDomain() <dolfin.compilemodules.subdomains.CompiledSubDomain>` function since the function will be automatically compiled into C++ code for efficiency. The (built-in) variable on_boundary is true for points on the boundary of a domain, and false otherwise.

The Dirichlet boundary values are defined using compiled expressions:

# Define Dirichlet boundary (x = 0 or x = 1)
c = Constant((0.0, 0.0, 0.0))
r = Expression(("scale*0.0",
                "scale*(y0 + (x[1] - y0)*cos(theta) - (x[2] - z0)*sin(theta) - x[1])",
                "scale*(z0 + (x[1] - y0)*sin(theta) + (x[2] - z0)*cos(theta) - x[2])"),
                scale = 0.5, y0 = 0.5, z0 = 0.5, theta = pi/3, degree=2)

Note the use of setting named parameters in the Expression for r.

The boundary subdomains and the boundary condition expressions are collected together in two DirichletBC objects, one for each part of the Dirichlet boundary:

bcl = DirichletBC(V, c, left)
bcr = DirichletBC(V, r, right)
bcs = [bcl, bcr]

The Dirichlet (essential) boundary conditions are constraints on the function space \(V\). The function space is therefore required as an argument to DirichletBC.

Trial and test functions, and the most recent approximate displacement u are defined on the finite element space V, and two objects of type Constant are declared for the body force (B) and traction (T) terms:

# Define functions
du = TrialFunction(V)            # Incremental displacement
v  = TestFunction(V)             # Test function
u  = Function(V)                 # Displacement from previous iteration
B  = Constant((0.0, -0.5, 0.0))  # Body force per unit volume
T  = Constant((0.1,  0.0, 0.0))  # Traction force on the boundary

In place of Constant, it is also possible to use as_vector, e.g. B = as_vector( [0.0, -0.5, 0.0] ). The advantage of Constant is that its values can be changed without requiring re-generation and re-compilation of C++ code. On the other hand, using as_vector can eliminate some function calls during assembly.

With the functions defined, the kinematic quantities involved in the model are defined using UFL syntax:

# Kinematics
d = len(u)
I = Identity(d)             # Identity tensor
F = I + grad(u)             # Deformation gradient
C = F.T*F                   # Right Cauchy-Green tensor

# Invariants of deformation tensors
Ic = tr(C)
J  = det(F)

Next, the material parameters are set and the strain energy density and the total potential energy are defined, again using UFL syntax:

# Elasticity parameters
E, nu = 10.0, 0.3
mu, lmbda = Constant(E/(2*(1 + nu))), Constant(E*nu/((1 + nu)*(1 - 2*nu)))

# Stored strain energy density (compressible neo-Hookean model)
psi = (mu/2)*(Ic - 3) - mu*ln(J) + (lmbda/2)*(ln(J))**2

# Total potential energy
Pi = psi*dx - dot(B, u)*dx - dot(T, u)*ds

Just as for the body force and traction vectors, Constant has been used for the model parameters mu and lmbda to avoid re-generation of C++ code when changing model parameters. Note that lambda is a reserved keyword in Python, hence the misspelling lmbda.

Directional derivatives are now computed of \(\Pi\) and \(L\) (see first_variation and second_variation):

# Compute first variation of Pi (directional derivative about u in the direction of v)
F = derivative(Pi, u, v)

# Compute Jacobian of F
J = derivative(F, u, du)

The complete variational problem can now be solved by a single call to solve:

# Solve variational problem
solve(F == 0, u, bcs, J=J)

Finally, the solution u is saved to a file named displacement.pvd in VTK format, and the deformed mesh is plotted to the screen:

# Save solution in VTK format
file = File("displacement.pvd");
file << u;

# Plot and hold solution
plot(u, mode = "displacement", interactive = True)
Nonlinear Poisson equation

This demo is implemented in a single Python file, demo_nonlinear-poisson.py, which contains both the variational form and the solver.

This demo illustrates how to:

  • Solve a nonlinear partial differential equation (in this case a nonlinear variant of Poisson’s equation)
  • Create and apply Dirichlet boundary conditions
  • Define an Expression
  • Define a FunctionSpace
  • Create a SubDomain

The solution for \(u\) in this demo will look as follows:

demos/nonlinear-poisson/python/plot_u.png

and the gradient of \(u\) will look like this:

demos/nonlinear-poisson/python/plot_u_gradient.png
Equation and problem definition

For a domain \(\Omega \subset \mathbb{R}^N\) with boundary \(\partial \Omega = \Gamma_{D} \cup \Gamma_{N}\), we consider the following nonlinear Poisson equation with given boundary conditions:

Here \(f\) is input data and \(n\) denotes the outward directed boundary normal. The nonlinear variational form can be written in the following canonical form: find \(u \in V\) such that

\[F(u;v) = 0 \quad \forall \, v \in \hat{V}\]

Here \(F:V\times\hat{V}\rightarrow\mathbb{R}\) is a semilinear form, linear in the argument subsequent to the semicolon, and \(V\) is some suitable function space. The semilinear form is defined as follows:

\[F(u;v) = \int_\Omega (1 + u^2)\cdot\nabla u \cdot \nabla v - f v \,{\rm dx} = 0.\]

To solve the nonlinear system \(b(U) = 0\) by Newton’s method we compute the Jacobian \(A = b'\), where \(U\) is the coefficients of the linear combination in the finite element solution \(u_h = \sum_{j=1}^{N}U_j\phi_j, \; b:\mathbb{R}^N\rightarrow\mathbb{R}^N\) and

\[b_i(U) = F(u_h;\hat{\phi}_i),\quad i = 1,2,\dotsc,N.\]

Linearizing the semilinear form \(F\) around \(u = u_h\), we obtain

\[F'(u_h;\delta u,v) = \int_\Omega [(2 \delta u\nabla u_h)\cdot\nabla v + ((1+u_h^2)\nabla\delta u)\nabla v] \,{\rm dx}\]

We note that for each fixed \(u_h\), \(a = F'(u_h;\,\cdot\,,\,\cdot\,)\) is a bilinear form and \(L = F(u_h;\,\cdot\,,\,\cdot\,)\) is a linear form. In each Newton iteration, we thus solve a linear variational problem of the canonical form: find \(\delta u \in V_{h,0}\) such that

\[F'(u_h;\delta u,v) = -F(u_h;v)\quad\forall\,v\in\hat{V}_h.\]

In this demo, we shall consider the following definitions of the input function, the domain, and the boundaries:

  • \(\Omega = [0,1] \times [0,1]\,\,\,\) (a unit square)
  • \(\Gamma_{D} = \{(1, y) \subset \partial \Omega\}\,\,\,\) (Dirichlet boundary)
  • \(\Gamma_{N} = \{(x, 0) \cup (x, 1) \cup (0, y) \subset \partial \Omega\}\,\,\,\) (Neumann boundary)
  • \(f(x, y) = x\sin(y)\,\,\,\) (source term)
Implementation

This description goes through the implementation (in demo_nonlinear-poisson.py) of a solver for the above described nonlinear Poisson equation step-by-step.

First, the dolfin module is imported:

from dolfin import *

Next, we want to consider the Dirichlet boundary condition. A simple Python function, returning a boolean, can be used to define the subdomain for the Dirichlet boundary condition (\(\Gamma_D\)). The function should return True for those points inside the subdomain and False for the points outside. In our case, we want to say that the points \((x, y)\) such that \(x = 1\) are inside on the inside of \(\Gamma_D\). (Note that because of rounding-off errors, it is often wise to instead specify \(|x - 1| < \epsilon\), where \(\epsilon\) is a small number (such as machine precision).):

# Sub domain for Dirichlet boundary condition
class DirichletBoundary(SubDomain):
    def inside(self, x, on_boundary):
        return abs(x[0] - 1.0) < DOLFIN_EPS and on_boundary

We then define a mesh of the domain and a finite element function space V relative to this mesh. We use the built-in mesh provided by the class UnitSquareMesh. In order to create a mesh consisting of \(32 \times 32\) squares with each square divided into two triangles, we do as follows:

# Create mesh and define function space
mesh = UnitSquareMesh(32, 32)
File("mesh.pvd") << mesh

V = FunctionSpace(mesh, "CG", 1)

The second argument to FunctionSpace is the finite element family, while the third argument specifies the polynomial degree. Thus, in this case, we use ‘CG’, for Continuous Galerkin, as a synonym for ‘Lagrange’. With degree 1, we simply get the standard linear Lagrange element, which is a triangle with nodes at the three vertices (or in other words, continuous piecewise linear polynomials).

The Dirichlet boundary condition can be created using the class DirichletBC. A DirichletBC takes three arguments: the function space the boundary condition applies to, the value of the boundary condition, and the part of the boundary on which the condition applies. In our example, the function space is V, the value of the boundary condition (1.0) can be represented using a Constant and the Dirichlet boundary is defined above. The definition of the Dirichlet boundary condition then looks as follows:

# Define boundary condition
g = Constant(1.0)
bc = DirichletBC(V, g, DirichletBoundary())

Next, we want to express the variational problem. First, we need to specify the function u which represents the solution. Upon initialization, it is simply set to the zero function, which will represent the initial guess \(u_0\). A Function represents a function living in a finite element function space. The test function \(v\) is specified, also living in the function space \(V\). We do this by defining a Function and a TestFunction on the previously defined FunctionSpace V.

Further, the source \(f\) is involved in the variational forms, and hence we must specify this. We have \(f\) given by a simple mathematical formula, which can be easily declared using the Expression class. Note that the strings defining f use C++ syntax since, for efficiency, DOLFIN will generate and compile C++ code for this expression at run-time.

By defining the function in this step and omitting the trial function we tell FEniCS that the problem is nonlinear. With these ingredients, we can write down the semilinear form F (using UFL operators). In summary, this reads:

# Define variational problem
u = Function(V)
v = TestFunction(V)
f = Expression("x[0]*sin(x[1])", degree=2)
F = inner((1 + u**2)*grad(u), grad(v))*dx - f*v*dx

Now, we have specified the variational forms and can consider the solution of the variational problem. Next, we can call the solve function with the arguments F == 0, u, bc and solver parameters as follows:

# Compute solution
solve(F == 0, u, bc,
      solver_parameters={"newton_solver":{"relative_tolerance":1e-6}})

The Newton procedure is considered to have converged when the residual \(r_n\) at iteration \(n\) is less than the absolute tolerance or the relative residual \(\frac{r_n}{r_0}\) is less than the relative tolerance.

A Function can be manipulated in various ways, in particular, it can be plotted and saved to file. Here, we output the solution to a VTK file (using the suffix .pvd) for later visualization and also plot it using the plot command:

# Plot solution and solution gradient
plot(u, title="Solution")
plot(grad(u), title="Solution gradient")
interactive()

# Save solution in VTK format
file = File("nonlinear_poisson.pvd")
file << u
Interpolation from a non-matching mesh

This example demonstrates how to interpolate functions between finite element spaces on non-matching meshes.

Note

Interpolation on non-matching meshes is not presently support in parallel. See https://bitbucket.org/fenics-project/dolfin/issues/162.

First, the dolfin module is imported:

from dolfin import *

Next, we create two different meshes. In this case we create unit square meshes with different size cells

mesh0 = UnitSquareMesh(16, 16)
mesh1 = UnitSquareMesh(64, 64)

On each mesh we create a finite element space. On the coarser mesh we use linear Lagrange elements, and on the finer mesh cubic Lagrange elements

P1 = FunctionSpace(mesh0, "Lagrange", 1)
P3 = FunctionSpace(mesh1, "Lagrange", 3)

We interpolate the function \(\sin(10x) \sin(10y)\)

v = Expression("sin(10.0*x[0])*sin(10.0*x[1])", degree=5)

into the P3 finite element space

# Create function on P3 and interpolate v
v3 = Function(P3)
v3.interpolate(v)

We now interpolate the function v3 into the P1 space

# Create function on P1 and interpolate v3
v1 = Function(P1)
v1.interpolate(v3)

The interpolated functions, v3 and v1 can ve visualised using the plot function

plot(v3, title='v3')
interactive()

plot(v1, title='v1')
interactive()

Using the C++ interface

All documented C++ demos

Poisson equation (C++)

This demo illustrates how to:

  • Solve a linear partial differential equation
  • Create and apply Dirichlet boundary conditions
  • Define Expressions
  • Define a FunctionSpace
  • Create a SubDomain

The solution for \(u\) in this demo will look as follows:

demos/poisson/cpp/../poisson_u.png
Equation and problem definition

The Poisson equation is the canonical elliptic partial differential equation. For a domain \(\Omega \subset \mathbb{R}^n\) with boundary \(\partial \Omega = \Gamma_{D} \cup \Gamma_{N}\), the Poisson equation with particular boundary conditions reads:

\[\begin{split}- \nabla^{2} u &= f \quad {\rm in} \ \Omega, \\ u &= 0 \quad {\rm on} \ \Gamma_{D}, \\ \nabla u \cdot n &= g \quad {\rm on} \ \Gamma_{N}. \\\end{split}\]

Here, \(f\) and \(g\) are input data and \(n\) denotes the outward directed boundary normal. The most standard variational form of Poisson equation reads: find \(u \in V\) such that

\[a(u, v) = L(v) \quad \forall \ v \in V,\]

where \(V\) is a suitable function space and

\[\begin{split}a(u, v) &= \int_{\Omega} \nabla u \cdot \nabla v \, {\rm d} x, \\ L(v) &= \int_{\Omega} f v \, {\rm d} x + \int_{\Gamma_{N}} g v \, {\rm d} s.\end{split}\]

The expression \(a(u, v)\) is the bilinear form and \(L(v)\) is the linear form. It is assumed that all functions in \(V\) satisfy the Dirichlet boundary conditions (\(u = 0 \ {\rm on} \ \Gamma_{D}\)).

In this demo, we shall consider the following definitions of the input functions, the domain, and the boundaries:

  • \(\Omega = [0,1] \times [0,1]\) (a unit square)
  • \(\Gamma_{D} = \{(0, y) \cup (1, y) \subset \partial \Omega\}\) (Dirichlet boundary)
  • \(\Gamma_{N} = \{(x, 0) \cup (x, 1) \subset \partial \Omega\}\) (Neumann boundary)
  • \(g = \sin(5x)\) (normal derivative)
  • \(f = 10\exp(-((x - 0.5)^2 + (y - 0.5)^2) / 0.02)\) (source term)
Implementation

The implementation is split in two files: a form file containing the definition of the variational forms expressed in UFL and a C++ file containing the actual solver.

Running this demo requires the files: main.cpp, Poisson.ufl and CMakeLists.txt.

UFL form file

The UFL file is implemented in Poisson.ufl, and the explanation of the UFL file can be found at here.

C++ program

The main solver is implemented in the main.cpp file.

At the top we include the DOLFIN header file and the generated header file “Poisson.h” containing the variational forms for the Poisson equation. For convenience we also include the DOLFIN namespace.

#include <dolfin.h>
#include "Poisson.h"

using namespace dolfin;

Then follows the definition of the coefficient functions (for \(f\) and \(g\)), which are derived from the Expression class in DOLFIN

// Source term (right-hand side)
class Source : public Expression
{
  void eval(Array<double>& values, const Array<double>& x) const
  {
    double dx = x[0] - 0.5;
    double dy = x[1] - 0.5;
    values[0] = 10*exp(-(dx*dx + dy*dy) / 0.02);
  }
};

// Normal derivative (Neumann boundary condition)
class dUdN : public Expression
{
  void eval(Array<double>& values, const Array<double>& x) const
  {
    values[0] = sin(5*x[0]);
  }
};

The DirichletBoundary is derived from the SubDomain class and defines the part of the boundary to which the Dirichlet boundary condition should be applied.

// Sub domain for Dirichlet boundary condition
class DirichletBoundary : public SubDomain
{
  bool inside(const Array<double>& x, bool on_boundary) const
  {
    return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS;
  }
};

Inside the main function, we begin by defining a mesh of the domain. As the unit square is a very standard domain, we can use a built-in mesh provided by the class UnitSquareMesh. In order to create a mesh consisting of 32 x 32 squares with each square divided into two triangles, and the finite element space (specified in the form file) defined relative to this mesh, we do as follows

int main()
{
  // Create mesh and function space
  auto mesh = std::make_shared<UnitSquareMesh>(32, 32);
  auto V = std::make_shared<Poisson::FunctionSpace>(mesh);

Now, the Dirichlet boundary condition (\(u = 0\)) can be created using the class DirichletBC. A DirichletBC takes three arguments: the function space the boundary condition applies to, the value of the boundary condition, and the part of the boundary on which the condition applies. In our example, the function space is V, the value of the boundary condition (0.0) can represented using a Constant, and the Dirichlet boundary is defined by the class DirichletBoundary listed above. The definition of the Dirichlet boundary condition then looks as follows:

// Define boundary condition
auto u0 = std::make_shared<Constant>(0.0);
auto boundary = std::make_shared<DirichletBoundary>();
DirichletBC bc(V, u0, boundary);

Next, we define the variational formulation by initializing the bilinear and linear forms (\(a\), \(L\)) using the previously defined FunctionSpace V. Then we can create the source and boundary flux term (\(f\), \(g\)) and attach these to the linear form.

// Define variational forms
Poisson::BilinearForm a(V, V);
Poisson::LinearForm L(V);
auto f = std::make_shared<Source>();
auto g = std::make_shared<dUdN>();
L.f = f;
L.g = g;

Now, we have specified the variational forms and can consider the solution of the variational problem. First, we need to define a Function u to store the solution. (Upon initialization, it is simply set to the zero function.) Next, we can call the solve function with the arguments a == L, u and bc as follows:

// Compute solution
Function u(V);
solve(a == L, u, bc);

The function u will be modified during the call to solve. A Function can be manipulated in various ways, in particular, it can be plotted and saved to file. Here, we output the solution to a VTK file (using the suffix .pvd) for later visualization and also plot it using the plot command:

  // Save solution in VTK format
  File file("poisson.pvd");
  file << u;

  // Plot solution
  plot(u);
  interactive();

  return 0;
}
A simple eigenvalue solver (C++)

We recommend that you are familiar with the demo for the Poisson equation before looking at this demo.

Implementation

Running this demo requires the files: main.cpp, StiffnessMatrix.ufl and CMakeLists.txt.

Under construction

#include <dolfin.h>
#include "StiffnessMatrix.h"

using namespace dolfin;

int main()
{
  #ifdef HAS_SLEPC

  // Create mesh
  auto mesh = std::make_shared<Mesh>("../box_with_dent.xml.gz");

  // Build stiffness matrix
  auto A = std::make_shared<PETScMatrix>();
  auto V = std::make_shared<StiffnessMatrix::FunctionSpace>(mesh);
  StiffnessMatrix::BilinearForm a(V, V);
  assemble(*A, a);

  // Create eigensolver
  SLEPcEigenSolver esolver(A);

  // Compute all eigenvalues of A x = \lambda x
  esolver.solve();

  // Extract largest (first, n =0) eigenpair
  double r, c;
  PETScVector rx, cx;
  esolver.get_eigenpair(r, c, rx, cx, 0);

  cout << "Largest eigenvalue: " << r << endl;

  // Initialize function with eigenvector
  Function u(V);
  *u.vector() = rx;

  // Plot eigenfunction
  plot(u);
  interactive();

  #else

  dolfin::cout << "SLEPc must be installed to run this demo." << dolfin::endl;

  #endif

  return 0;
}
Built-in meshes

This demo illustrates:

  • How to define some of the different built-in meshes in DOLFIN
Implementation

Running this demo requires the files: main.cpp and CMakeLists.txt.

Under construction

#include <dolfin.h>

using namespace dolfin;

int main()
{
  if (dolfin::MPI::size(MPI_COMM_WORLD) == 1)
  {
    UnitIntervalMesh interval(10);
    info("Plotting a UnitIntervalMesh");
    plot(interval, "Unit interval");
  }

  UnitSquareMesh square_default(10, 10);
  info("Plotting a UnitSquareMesh");
  plot(square_default, "Unit square");

  UnitSquareMesh square_left(10, 10, "left");
  info("Plotting a UnitSquareMesh");
  plot(square_left, "Unit square (left)");

  UnitSquareMesh square_crossed(10, 10, "crossed");
  info("Plotting a UnitSquareMesh");
  plot(square_crossed, "Unit square (crossed)");

  UnitSquareMesh square_right_left(10, 10, "right/left");
  info("Plotting a UnitSquareMesh");
  plot(square_right_left, "Unit square (right/left)");

  RectangleMesh rectangle_default(Point(0.0, 0.0), Point(10.0, 4.0), 10, 10);
  info("Plotting a RectangleMesh");
  plot(rectangle_default, "Rectangle");

  RectangleMesh rectangle_right_left(Point(-3.0, 2.0), Point(7.0, 6.0), 10, 10, "right/left");
  info("Plotting a RectangleMesh");
  plot(rectangle_right_left, "Rectangle (right/left)");

  UnitCubeMesh cube(10, 10, 10);
  info("Plotting a UnitCubeMesh");
  plot(cube, "Unit cube");

  BoxMesh box(Point(0.0, 0.0, 0.0), Point(10.0, 4.0, 2.0), 10, 10, 10);
  info("Plotting a BoxMesh");
  plot(box, "Box");

  interactive();

  return 0;
}
Mixed formulation for Poisson equation (C++)

This demo illustrates how to solve Poisson equation using a mixed (two-field) formulation. In particular, it illustrates how to

  • Use mixed and non-continuous finite element spaces
  • Set essential boundary conditions for subspaces and H(div) spaces
  • Define a (vector-valued) expression using additional geometry information
Equation and problem definition

An alternative formulation of Poisson equation can be formulated by introducing an additional (vector) variable, namely the (negative) flux: \(\sigma = \nabla u\). The partial differential equations then read

\[\begin{split}\sigma - \nabla u &= 0 \quad {\rm in} \ \Omega, \\ \nabla \cdot \sigma &= - f \quad {\rm in} \ \Omega,\end{split}\]

with boundary conditions

\[\begin{split}u = u_0 \quad {\rm on} \ \Gamma_{D}, \\ \sigma \cdot n = g \quad {\rm on} \ \Gamma_{N}.\end{split}\]

The same equations arise in connection with flow in porous media, and are also referred to as Darcy flow.

After multiplying by test functions \(\tau\) and \(v\), integrating over the domain, and integrating the gradient term by parts, one obtains the following variational formulation: find \(\sigma \in \Sigma\) and \(v \in V\) satisfying

\[ \begin{align}\begin{aligned}\begin{split}\int_{\Omega} (\sigma \cdot \tau + \nabla \cdot \tau \ u) \ {\rm d} x &= \int_{\Gamma} \tau \cdot n \ u \ {\rm d} s \quad \forall \ \tau \in \Sigma, \\\end{split}\\\int_{\Omega} \nabla \cdot \sigma v \ {\rm d} x &= - \int_{\Omega} f \ v \ {\rm d} x \quad \forall \ v \in V.\end{aligned}\end{align} \]

Here \(n\) denotes the outward pointing normal vector on the boundary. Looking at the variational form, we see that the boundary condition for the flux (\(\sigma \cdot n = g\)) is now an essential boundary condition (which should be enforced in the function space), while the other boundary condition (\(u = u_0\)) is a natural boundary condition (which should be applied to the variational form). Inserting the boundary conditions, this variational problem can be phrased in the general form: find \((\sigma, u) \in \Sigma_g \times V\) such that

\[a((\sigma, u), (\tau, v)) = L((\tau, v)) \quad \forall \ (\tau, v) \in \Sigma_0 \times V\]

where the variational forms \(a\) and \(L\) are defined as

\[\begin{split}a((\sigma, u), (\tau, v)) &= \int_{\Omega} \sigma \cdot \tau + \nabla \cdot \tau \ u + \nabla \cdot \sigma \ v \ {\rm d} x \\ L((\tau, v)) &= - \int_{\Omega} f v \ {\rm d} x + \int_{\Gamma_D} u_0 \tau \cdot n \ {\rm d} s\end{split}\]

and \(\Sigma_g = \{ \tau \in H({\rm div}) \text{ such that } \tau \cdot n|_{\Gamma_N} = g \}\) and \(V = L^2(\Omega)\).

To discretize the above formulation, two discrete function spaces \(\Sigma_h \subset \Sigma\) and \(V_h \subset V\) are needed to form a mixed function space \(\Sigma_h \times V_h\). A stable choice of finite element spaces is to let \(\Sigma_h\) be the Brezzi-Douglas-Marini elements of polynomial order \(k\) and let \(V_h\) be discontinuous elements of polynomial order \(k-1\).

We will use the same definitions of functions and boundaries as in the demo for Poisson’s equation. These are:

  • \(\Omega = [0,1] \times [0,1]\) (a unit square)
  • \(\Gamma_{D} = \{(0, y) \cup (1, y) \in \partial \Omega\}\)
  • \(\Gamma_{N} = \{(x, 0) \cup (x, 1) \in \partial \Omega\}\)
  • \(u_0 = 0\)
  • \(g = \sin(5x)\) (flux)
  • \(f = 10\exp(-((x - 0.5)^2 + (y - 0.5)^2) / 0.02)\) (source term)

With the above input the solution for \(u\) and \(\sigma\) will look as follows:

demos/mixed-poisson/cpp/../mixed-poisson_u.png demos/mixed-poisson/cpp/../mixed-poisson_sigma.png
Implementation

The implementation is split in two files, a form file containing the definition of the variational forms expressed in UFL and the solver which is implemented in a C++ file.

Running this demo requires the files: main.cpp, MixedPoisson.ufl and CMakeLists.txt.

UFL form file

The UFL file is implemented in MixedPoisson.ufl, and the explanation of the UFL file can be found at here.

C++ program

The solver is implemented in the main.cpp file.

At the top we include the DOLFIN header file and the generated header file containing the variational forms. For convenience we also include the DOLFIN namespace.

#include <dolfin.h>
#include "MixedPoisson.h"

using namespace dolfin;

Then follows the definition of the coefficient functions (for \(f\) and \(G\)), which are derived from the DOLFIN Expression class.

// Source term (right-hand side)
class Source : public Expression
{
  void eval(Array<double>& values, const Array<double>& x) const
  {
    double dx = x[0] - 0.5;
    double dy = x[1] - 0.5;
    values[0] = 10*exp(-(dx*dx + dy*dy) / 0.02);
  }
};

// Boundary source for flux boundary condition
class BoundarySource : public Expression
{
public:

  BoundarySource(const Mesh& mesh) : Expression(2), mesh(mesh) {}

  void eval(Array<double>& values, const Array<double>& x,
            const ufc::cell& ufc_cell) const
  {
    dolfin_assert(ufc_cell.local_facet >= 0);

    Cell cell(mesh, ufc_cell.index);
    Point n = cell.normal(ufc_cell.local_facet);

    const double g = sin(5*x[0]);
    values[0] = g*n[0];
    values[1] = g*n[1];
  }

private:

  const Mesh& mesh;

};

Then follows the definition of the essential boundary part of the boundary of the domain, which is derived from the SubDomain class.

// Sub domain for essential boundary condition
class EssentialBoundary : public SubDomain
{
  bool inside(const Array<double>& x, bool on_boundary) const
  {
    return x[1] < DOLFIN_EPS or x[1] > 1.0 - DOLFIN_EPS;
  }
};

Inside the main() function we first create the mesh and then we define the (mixed) function space for the variational formulation. We also define the bilinear form a and linear form L relative to this function space.

int main()
{
  // Create mesh
  auto mesh = std::make_shared<UnitSquareMesh>(32, 32);

  // Construct function space
  auto W = std::make_shared<MixedPoisson::FunctionSpace>(mesh);
  MixedPoisson::BilinearForm a(W, W);
  MixedPoisson::LinearForm L(W);

Then we create the source (\(f\)) and assign it to the linear form.

// Create source and assign to L
auto f = std::make_shared<Source>();
L.f = f;

It only remains to prescribe the boundary condition for the flux. Essential boundary conditions are specified through the class DirichletBC which takes three arguments: the function space the boundary condition is supposed to be applied to, the data for the boundary condition, and the relevant part of the boundary.

We want to apply the boundary condition to the first subspace of the mixed space. This space can be accessed through the sub member function of the FunctionSpace class.

Next, we need to construct the data for the boundary condition. An essential boundary condition is handled by replacing degrees of freedom by the degrees of freedom evaluated at the given data. The \(BDM\) finite element spaces are vector-valued spaces and hence the degrees of freedom act on vector-valued objects. The effect is that the user is required to construct a \(G\) such that \(G \cdot n = g\). Such a \(G\) can be constructed by letting \(G = g n\). This is what the derived expression class BoundarySource defined above does.

// Define boundary condition
auto G = std::make_shared<BoundarySource>(*mesh);
auto boundary = std::make_shared<EssentialBoundary>();
DirichletBC bc(W->sub(0), G, boundary);

To compute the solution we use the bilinear and linear forms, and the boundary condition, but we also need to create a Function to store the solution(s). The (full) solution will be stored in the Function w, which we initialise using the FunctionSpace W. The actual computation is performed by calling solve.

// Compute solution
Function w(W);
solve(a == L, w, bc);

Now, the separate components sigma and u of the solution can be extracted by taking components. These can easily be visualized by calling plot.

  // Extract sub functions (function views)
  Function& sigma = w[0];
  Function& u = w[1];

  // Plot solutions
  plot(u);
  plot(sigma);
  interactive();

  return 0;
}
Biharmonic equation (C++)

This demo illustrates how to:

  • Solve a linear partial differential equation
  • Use a discontinuous Galerkin method
  • Solve a fourth-order differential equation

The solution for \(u\) in this demo will look as follows:

demos/biharmonic/cpp/../biharmonic_u.png
Equation and problem definition

The biharmonic equation is a fourth-order elliptic equation. On the domain \(\Omega \subset \mathbb{R}^{d}\), \(1 \le d \le 3\), it reads

\[\nabla^{4} u = f \quad {\rm in} \ \Omega,\]

where \(\nabla^{4} \equiv \nabla^{2} \nabla^{2}\) is the biharmonic operator and \(f\) is a prescribed source term. To formulate a complete boundary value problem, the biharmonic equation must be complemented by suitable boundary conditions.

Multiplying the biharmonic equation by a test function and integrating by parts twice leads to a problem second-order derivatives, which would requires \(H^{2}\) conforming (roughly \(C^{1}\) continuous) basis functions. To solve the biharmonic equation using Lagrange finite element basis functions, the biharmonic equation can be split into two second-order equations (see the Mixed Poisson demo for a mixed method for the Poisson equation), or a variational formulation can be constructed that imposes weak continuity of normal derivatives between finite element cells. The demo uses a discontinuous Galerkin approach to impose continuity of the normal derivative weakly.

Consider a triangulation \(\mathcal{T}\) of the domain \(\Omega\), where the set of interior facets is denoted by \(\mathcal{E}_h^{\rm int}\). Functions evaluated on opposite sides of a facet are indicated by the subscripts ‘\(+\)‘ and ‘\(-\)‘. Using the standard continuous Lagrange finite element space

\[V = \left\{v \in H^{1}_{0}(\Omega)\,:\, v \in P_{k}(K) \ \forall \ K \in \mathcal{T} \right\}\]

and considering the boundary conditions

\[\begin{split}u &= 0 \quad {\rm on} \ \partial\Omega \\ \nabla^{2} u &= 0 \quad {\rm on} \ \partial\Omega\end{split}\]

a weak formulation of the biharmonic problem reads: find \(u \in V\) such that

\[a(u,v)=L(v) \quad \forall \ v \in V,\]

where the bilinear form is

\[a(u, v) = \sum_{K \in \mathcal{T}} \int_{K} \nabla^{2} u \nabla^{2} v \, {\rm d}x \ +\sum_{E \in \mathcal{E}_h^{\rm int}}\left(\int_{E} \frac{\alpha}{h_E} [\!\![ \nabla u ]\!\!] [\!\![ \nabla v ]\!\!] \, {\rm d}s - \int_{E} \left<\nabla^{2} u \right>[\!\![ \nabla v ]\!\!] \, {\rm d}s - \int_{E} [\!\![ \nabla u ]\!\!] \left<\nabla^{2} v \right> \, {\rm d}s\right)\]

and the linear form is

\[L(v) = \int_{\Omega} fv \, {\rm d}x\]

Furthermore, \(\left< u \right> = \frac{1}{2} (u_{+} + u_{-})\), \([\!\![ w ]\!\!] = w_{+} \cdot n_{+} + w_{-} \cdot n_{-}\), \(\alpha \ge 0\) is a penalty parameter and \(h_E\) is a measure of the cell size.

The input parameters for this demo are defined as follows:

  • \(\Omega = [0,1] \times [0,1]\) (a unit square)
  • \(\alpha = 8.0\) (penalty parameter)
  • \(f = 4.0 \pi^4\sin(\pi x)\sin(\pi y)\) (source term)
Implementation

The implementation is split in two files, a form file containing the definition of the variational forms expressed in UFL and the solver which is implemented in a C++ file.

Running this demo requires the files: main.cpp, Biharmonic.ufl and CMakeLists.txt.

UFL form file

The UFL file is implemented in Biharmonic.ufl, and the explanation of the UFL file can be found at here.

C++ program

The DOLFIN interface and the code generated from the UFL input is included, and the DOLFIN namespace is used:

#include <dolfin.h>
#include "Biharmonic.h"

using namespace dolfin;

A class Source is defined for the function \(f\), with the function Expression::eval overloaded:

// Source term
class Source : public Expression
{
public:

  void eval(Array<double>& values, const Array<double>& x) const
  {
    values[0] = 4.0*std::pow(DOLFIN_PI, 4)*
      std::sin(DOLFIN_PI*x[0])*std::sin(DOLFIN_PI*x[1]);
  }

};

A boundary subdomain is defined, which in this case is the entire boundary:

// Sub domain for Dirichlet boundary condition
class DirichletBoundary : public SubDomain
{
  bool inside(const Array<double>& x, bool on_boundary) const
  { return on_boundary; }
};

The main part of the program is begun, and a mesh is created with 32 vertices in each direction:

int main()
{
  // Make mesh ghosted for evaluation of DG terms
  parameters["ghost_mode"] = "shared_facet";

  // Create mesh
  auto mesh = std::make_shared<UnitSquareMesh>(32, 32);

The source function, a function for the cell size and the penalty term are declared:

// Create functions
auto f = std::make_shared<Source>();
auto alpha = std::make_shared<Constant>(8.0);

A function space object, which is defined in the generated code, is created:

// Create function space
auto V = std::make_shared<Biharmonic::FunctionSpace>(mesh);

The Dirichlet boundary condition on \(u\) is constructed by defining a Constant which is equal to zero, defining the boundary (DirichletBoundary), and using these, together with V, to create bc:

// Define boundary condition
auto u0 = std::make_shared<Constant>(0.0);
auto boundary = std::make_shared<DirichletBoundary>();
DirichletBC bc(V, u0, boundary);

Using the function space V, the bilinear and linear forms are created, and function are attached:

// Define variational problem
Biharmonic::BilinearForm a(V, V);
Biharmonic::LinearForm L(V);
a.alpha = alpha; L.f = f;

A Function is created to hold the solution and the problem is solved:

// Compute solution
Function u(V);
solve(a == L, u, bc);

The solution is then written to a file in VTK format and plotted to the screen:

  // Save solution in VTK format
  File file("biharmonic.pvd");
  file << u;

  // Plot solution
  plot(u);
  interactive();

  return 0;
}
Auto adaptive Poisson equation (C++)
Implementation

Running this demo requires the files: main.cpp, AdaptivePoisson.ufl and CMakeLists.txt.

Under construction.

#include <dolfin.h>
#include "AdaptivePoisson.h"

using namespace dolfin;

// Source term (right-hand side)
class Source : public Expression
  {
    void eval(Array<double>& values, const Array<double>& x) const
    {
      double dx = x[0] - 0.5;
      double dy = x[1] - 0.5;
      values[0] = 10*exp(-(dx*dx + dy*dy) / 0.02);
    }
  };

// Normal derivative (Neumann boundary condition)
class dUdN : public Expression
{
  void eval(Array<double>& values, const Array<double>& x) const
  { values[0] = sin(5*x[0]); }
};

// Sub domain for Dirichlet boundary condition
class DirichletBoundary : public SubDomain
{
  bool inside(const Array<double>& x, bool on_boundary) const
  { return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS; }
};

int main()
{
  // Create mesh and define function space
  auto mesh = std::make_shared<UnitSquareMesh>(8, 8);
  auto V = std::make_shared<AdaptivePoisson::BilinearForm::TrialSpace>(mesh);

  // Define boundary condition
  auto u0 = std::make_shared<Constant>(0.0);
  auto boundary = std::make_shared<DirichletBoundary>();
  auto bc = std::make_shared<DirichletBC>(V, u0, boundary);

  // Define variational forms
  auto a = std::make_shared<AdaptivePoisson::BilinearForm>(V, V);
  auto L = std::make_shared<AdaptivePoisson::LinearForm>(V);
  auto f = std::make_shared<Source>();
  auto g = std::make_shared<dUdN>();
  L->f = f;
  L->g = g;

  // Define Function for solution
  auto u = std::make_shared<Function>(V);

  // Define goal functional (quantity of interest)
  auto M = std::make_shared<AdaptivePoisson::GoalFunctional>(mesh);

  // Define error tolerance
  double tol = 1.e-5;

  // Solve equation a = L with respect to u and the given boundary
  // conditions, such that the estimated error (measured in M) is less
  // than tol
  std::vector<std::shared_ptr<const DirichletBC>> bcs({bc});
  auto problem = std::make_shared<LinearVariationalProblem>(a, L, u, bcs);
  AdaptiveLinearVariationalSolver solver(problem, M);
  solver.parameters("error_control")("dual_variational_solver")["linear_solver"]
  = "cg";
  solver.parameters("error_control")("dual_variational_solver")["symmetric"]
  = true;
  solver.solve(tol);

  solver.summary();

  // Plot final solution
  plot(u->root_node(), "Solution on initial mesh");
  plot(u->leaf_node(), "Solution on final mesh");
  interactive();

  return 0;
}
Interpolation from a non-matching mesh

This example demonstrates how to interpolate functions between finite element spaces on non-matching meshes.

Note

Interpolation on non-matching meshes is not presently support in parallel. See https://bitbucket.org/fenics-project/dolfin/issues/162.

Implementation

The implementation is split in three files: two UFL form files containing the definition of finite elements, and a C++ file containing the runtime code.

Running this demo requires the files: main.cpp, P1.ufl, P3.ufl and CMakeLists.txt.

UFL form file

The UFL files are implemented in P1.ufl and P1.ufl, and the explanations of the UFL files can be found at here (P1) and here (P3).

At the top we include the DOLFIN header file and the generated header files “P1.h” and “P2.h”. For convenience we also include the DOLFIN namespace.

#include <dolfin.h>
#include "P1.h"
#include "P3.h"

using namespace dolfin;

We then define an Expression:

class MyExpression : public Expression
{
public:

  void eval(Array<double>& values, const Array<double>& x) const
  {
    values[0] = sin(10.0*x[0])*sin(10.0*x[1]);
  }

};

Next, the main function is started and we create two unit square meshes with a differing number of vertices in each direction:

int main()
{
  // Create meshes
  auto mesh0 = std::make_shared<UnitSquareMesh>(16, 16);
  auto mesh1 = std::make_shared<UnitSquareMesh>(64, 64);

We create a linear Lagrange finite element space on the coarser mesh, and a cubic Lagrange space on the finer mesh:

// Create function spaces
auto P1 = std::make_shared<P1::FunctionSpace>(mesh0);
auto P3 = std::make_shared<P3::FunctionSpace>(mesh1);

One each space we create a finite element function:

// Create functions
Function v1(P1);
Function v3(P3);

We create an instantiation of MyExpression, and interpolate it into P3:

// Interpolate expression into P3
MyExpression e;
v3.interpolate(e);

Now, we interpolate v3 into the linear finite element space on a coarser grid:

v1.interpolate(v3);

Finally, we can visualise the function on the two meshes:

  plot(v3);
  plot(v1);
  interactive();

  return 0;
}
Hyperelasticity (C++)
Background

See the section hyperelasticity for some mathematical background on this demo.

Implementation

The implementation is split in two files: a form file containing the definition of the variational forms expressed in UFL and a C++ file containing the actual solver.

Running this demo requires the files: main.cpp, HyperElasticity.ufl and CMakeLists.txt.

UFL form file

The UFL file is implemented in Hyperelasticity.ufl, and the explanation of the UFL file can be found at here.

C++ program

The main solver is implemented in the main.cpp file.

At the top, we include the DOLFIN header file and the generated header file “HyperElasticity.h” containing the variational forms and function spaces. For convenience we also include the DOLFIN namespace.

#include <dolfin.h>
#include "HyperElasticity.h"

using namespace dolfin;

We begin by defining two classes, deriving from SubDomain for later use when specifying domains for the boundary conditions.

// Sub domain for clamp at left end
class Left : public SubDomain
{
  bool inside(const Array<double>& x, bool on_boundary) const
  {
    return (std::abs(x[0]) < DOLFIN_EPS) && on_boundary;
  }
};

// Sub domain for rotation at right end
class Right : public SubDomain
{
  bool inside(const Array<double>& x, bool on_boundary) const
  {
    return (std::abs(x[0] - 1.0) < DOLFIN_EPS) && on_boundary;
  }
};

We also define two classes, deriving from Expression, for later use when specifying values for the boundary conditions.

// Dirichlet boundary condition for clamp at left end
class Clamp : public Expression
{
public:

  Clamp() : Expression(3) {}

  void eval(Array<double>& values, const Array<double>& x) const
  {
    values[0] = 0.0;
    values[1] = 0.0;
    values[2] = 0.0;
  }

};

// Dirichlet boundary condition for rotation at right end
class Rotation : public Expression
{
public:

  Rotation() : Expression(3) {}

  void eval(Array<double>& values, const Array<double>& x) const
  {
    const double scale = 0.5;

    // Center of rotation
    const double y0 = 0.5;
    const double z0 = 0.5;

    // Large angle of rotation (60 degrees)
    double theta = 1.04719755;

    // New coordinates
    double y = y0 + (x[1] - y0)*cos(theta) - (x[2] - z0)*sin(theta);
    double z = z0 + (x[1] - y0)*sin(theta) + (x[2] - z0)*cos(theta);

    // Rotate at right end
    values[0] = 0.0;
    values[1] = scale*(y - x[1]);
    values[2] = scale*(z - x[2]);
  }
};

Next:

int main()
{

Inside the main function, we begin by defining a tetrahedral mesh of the domain and the function space on this mesh. Here, we choose to create a unit cube mesh with 25 ( = 24 + 1) verices in one direction and 17 ( = 16 + 1) vertices in the other two directions. With this mesh, we initialize the (finite element) function space defined by the generated code.

// Create mesh and define function space
auto mesh = std::make_shared<UnitCubeMesh>(24, 16, 16);
auto V = std::make_shared<HyperElasticity::FunctionSpace>(mesh);

Now, the Dirichlet boundary conditions can be created using the class DirichletBC, the previously initialized FunctionSpace V and instances of the previously listed classes Left (for the left boundary) and Right (for the right boundary), and Clamp (for the value on the left boundary) and Rotation (for the value on the right boundary).

// Define Dirichlet boundaries
auto left = std::make_shared<Left>();
auto right = std::make_shared<Right>();

// Define Dirichlet boundary functions
auto c = std::make_shared<Clamp>();
auto r = std::make_shared<Rotation>();

// Create Dirichlet boundary conditions
DirichletBC bcl(V, c, left);
DirichletBC bcr(V, r, right);
std::vector<const DirichletBC*> bcs = {{&bcl, &bcr}};

The two boundary conditions are collected in the container bcs.

We use two instances of the class Constant to define the source B and the traction T.

// Define source and boundary traction functions
auto B = std::make_shared<Constant>(0.0, -0.5, 0.0);
auto T = std::make_shared<Constant>(0.1,  0.0, 0.0);

The solution for the displacement will be an instance of the class Function, living in the function space V; we define it here:

// Define solution function
auto u = std::make_shared<Function>(V);

Next, we set the material parameters

// Set material parameters
const double E  = 10.0;
const double nu = 0.3;
auto mu = std::make_shared<Constant>(E/(2*(1 + nu)));
auto lambda = std::make_shared<Constant>(E*nu/((1 + nu)*(1 - 2*nu)));

Now, we can initialize the bilinear and linear forms (a, L) using the previously defined FunctionSpace V. We attach the material parameters and previously initialized functions to the forms.

// Create (linear) form defining (nonlinear) variational problem
HyperElasticity::ResidualForm F(V);
F.mu = mu; F.lmbda = lambda; F.u = u;
F.B = B; F.T = T;

// Create Jacobian dF = F' (for use in nonlinear solver).
HyperElasticity::JacobianForm J(V, V);
J.mu = mu; J.lmbda = lambda; J.u = u;

Now, we have specified the variational forms and can consider the solution of the variational problem.

// Solve nonlinear variational problem F(u; v) = 0
solve(F == 0, *u, bcs, J);

Finally, the solution u is saved to a file named displacement.pvd in VTK format, and the displacement solution is plotted.

  // Save solution in VTK format
  File file("displacement.pvd");
  file << *u;

  // Plot solution
  plot(*u);
  interactive();

  return 0;
}

Contributing

This page provides guidance on how to contribute to DOLFIN. For information about how to get involved and how to get in touch with the developers, see our community page.

Adding a demo

The below instructions are for adding a Python demo program to DOLFIN. DOLFIN demo programs are written in reStructuredText, and converted to Python/C++ code using pylit. The process for C++ demos is similar. The documented demo programs are displayed at http://fenics-dolfin.readthedocs.io/.

Creating the demo program

  1. Create a directory for the demo under demo/documented/, e.g. demo/documented/foo/python/.

  2. Write the demo in reStructuredText (rst), with the actual code in ‘code blocks’ (see other demos for guidance). The demo file should be named demo_foo-bar.py.rst.

  3. Convert the rst file to to a Python file using pylit (pylit is distributed with DOLFIN in utils/pylit)

    ../../../../utils/pylit/pylit.py demo_foo-bar.py.rst
    

    This will create a file demo_foo-bar.py. Test that the Python script can be run.

Adding the demo to the documentation system

  1. Add the demo to the list in doc/source/demos.rst.
  2. To check how the documentation will be displayed on the web, in doc/ run make html and open the file doc/build/html/index.html in a browser.

Make a pull request

  1. Create a git branch and add the demo_foo-bar.py.rst file to the repository. Do not add the demo_foo-bar.py file.
  2. If there is no C++ version, edit test/regression/test.py to indicate that there is no C++ version of the demo.
  3. Make a pull request at https://bitbucket.org/fenics-project/dolfin/pull-requests/ for your demo to be considered for addition to DOLFIN. Add the demo_foo-bar.py.rst file to the repository, but do not add the demo_foo-bar.py file.

API documentation (C++)

The API documentation of the C++ code is split into multiple pages based on the location in the dolfin source tree

dolfin/adaptivity

Documentation for C++ code found in dolfin/adaptivity/*.h

Functions

adapt

C++ documentation for adapt from dolfin/adaptivity/adapt.h:

std::shared_ptr<DirichletBC> dolfin::adapt(const DirichletBC &bc, std::shared_ptr<const Mesh> adapted_mesh, const FunctionSpace &S)

Refine Dirichlet bc based on refined mesh.

Parameters:
  • bc
  • adapted_mesh
  • S

C++ documentation for adapt from dolfin/adaptivity/adapt.h:

std::shared_ptr<ErrorControl> dolfin::adapt(const ErrorControl &ec, std::shared_ptr<const Mesh> adapted_mesh, bool adapt_coefficients = true)

Adapt error control object based on adapted mesh

Parameters:
  • ec – (ErrorControl ) The error control object to be adapted
  • adapted_mesh – (Mesh ) The new mesh
  • adapt_coefficients – (bool) Optional argument, default is true. If false, any form coefficients are not explicitly adapted, but pre-adapted coefficients will be transferred.
Returns:

ErrorControl The adapted error control object

C++ documentation for adapt from dolfin/adaptivity/adapt.h:

std::shared_ptr<Form> dolfin::adapt(const Form &form, std::shared_ptr<const Mesh> adapted_mesh, bool adapt_coefficients = true)

Adapt form based on adapted mesh

Parameters:
  • form – (Form ) The form that should be adapted [direction=in]
  • adapted_mesh – (Mesh ) The new mesh [direction=in]
  • adapt_coefficients – (bool) Optional argument, default is true. If false, the form coefficients are not explicitly adapted, but pre-adapted coefficients will be transferred. [direction=in]
Returns:

Form The adapted form

C++ documentation for adapt from dolfin/adaptivity/adapt.h:

std::shared_ptr<Function> dolfin::adapt(const Function &function, std::shared_ptr<const Mesh> adapted_mesh, bool interpolate = true)

Adapt Function based on adapted mesh

Parameters:
  • function – (Function &) The function that should be adapted [direction=in]
  • adapted_mesh – (std::shared_ptr<const Mesh>) The new mesh [direction=in]
  • interpolate – (bool) Optional argument, default is true. If false, the function’s function space is adapted, but the values are not interpolated. [direction=in]
Returns:

Function The adapted function

C++ documentation for adapt from dolfin/adaptivity/adapt.h:

std::shared_ptr<FunctionSpace> dolfin::adapt(const FunctionSpace &space)

Refine function space uniformly

Parameters:space – (FunctionSpace ) [direction=in]
Returns:FunctionSpace

C++ documentation for adapt from dolfin/adaptivity/adapt.h:

std::shared_ptr<FunctionSpace> dolfin::adapt(const FunctionSpace &space, const MeshFunction<bool> &cell_markers)

Refine function space based on cell markers

Parameters:
  • space – (FunctionSpace &) [direction=in]
  • cell_markers – (MehsFunction<bool>&) [direction=in]
Returns:

FunctionSpace

C++ documentation for adapt from dolfin/adaptivity/adapt.h:

std::shared_ptr<FunctionSpace> dolfin::adapt(const FunctionSpace &space, std::shared_ptr<const Mesh> adapted_mesh)

Refine function space based on refined mesh

Parameters:
  • space – (FunctionSpace &) [direction=in]
  • adapted_mesh – (std::sahred_ptr<const Mesh>) [direction=in]
Returns:

FunctionSpace

C++ documentation for adapt from dolfin/adaptivity/adapt.h:

std::shared_ptr<LinearVariationalProblem> dolfin::adapt(const LinearVariationalProblem &problem, std::shared_ptr<const Mesh> adapted_mesh)

Refine linear variational problem based on mesh.

Parameters:
  • problem
  • adapted_mesh

C++ documentation for adapt from dolfin/adaptivity/adapt.h:

std::shared_ptr<Mesh> dolfin::adapt(const Mesh &mesh)

Refine mesh uniformly

Parameters:mesh – (Mesh ) Input mesh [direction=in]
Returns:std::shared_ptr<Mesh> adapted mesh

C++ documentation for adapt from dolfin/adaptivity/adapt.h:

std::shared_ptr<Mesh> dolfin::adapt(const Mesh &mesh, const MeshFunction<bool> &cell_markers)

Refine mesh based on cell markers

Parameters:
  • mesh – (Mesh ) Input mesh [direction=in]
  • cell_markers – (MeshFunction<bool>) Markers denoting cells to be refined [direction=in]

C++ documentation for adapt from dolfin/adaptivity/adapt.h:

std::shared_ptr<MeshFunction<std::size_t>> dolfin::adapt(const MeshFunction<std::size_t> &mesh_function, std::shared_ptr<const Mesh> adapted_mesh)

Refine mesh function<std::size_t> based on mesh.

Parameters:
  • mesh_function
  • adapted_mesh

C++ documentation for adapt from dolfin/adaptivity/adapt.h:

std::shared_ptr<NonlinearVariationalProblem> dolfin::adapt(const NonlinearVariationalProblem &problem, std::shared_ptr<const Mesh> adapted_mesh)

Refine nonlinear variational problem based on mesh.

Parameters:
  • problem
  • adapted_mesh

C++ documentation for adapt from dolfin/adaptivity/adapt.h:

std::shared_ptr<GenericFunction> dolfin::adapt(std::shared_ptr<const GenericFunction> function, std::shared_ptr<const Mesh> adapted_mesh)

Refine GenericFunction based on refined mesh

Parameters:
  • function – (GeericFunction) The function that should be adapted [direction=in]
  • adapted_mesh – (Mehs) The new mesh [direction=in]
Returns:

GenericFunction The adapted function

adapt_markers

C++ documentation for adapt_markers from dolfin/adaptivity/adapt.h:

void dolfin::adapt_markers(std::vector<std::size_t> &refined_markers, const Mesh &adapted_mesh, const std::vector<std::size_t> &markers, const Mesh &mesh)

Helper function for refinement of boundary conditions.

Parameters:
  • refined_markers
  • adapted_mesh
  • markers
  • mesh
dorfler_mark

C++ documentation for dorfler_mark from dolfin/adaptivity/marking.h:

void dolfin::dorfler_mark(MeshFunction<bool> &markers, const dolfin::MeshFunction<double> &indicators, const double fraction)

Mark cells using Dorfler marking

Parameters:
  • markers – (MeshFunction<bool>) the cell markers (to be computed)
  • indicators – (MeshFunction<double>) error indicators (one per cell)
  • fraction – (double) the marking fraction
mark

C++ documentation for mark from dolfin/adaptivity/marking.h:

void dolfin::mark(MeshFunction<bool> &markers, const dolfin::MeshFunction<double> &indicators, const std::string strategy, const double fraction)

Mark cells based on indicators and given marking strategy

Parameters:
  • markers – (MeshFunction<bool>) the cell markers (to be computed)
  • indicators – (MeshFunction<double>) error indicators (one per cell)
  • strategy – (std::string) the marking strategy
  • fraction – (double) the marking fraction
solve

C++ documentation for solve from dolfin/adaptivity/adaptivesolve.h:

void dolfin::solve(const Equation &equation, Function &u, const DirichletBC &bc, const Form &J, const double tol, GoalFunctional &M)

Solve linear variational problem F(u; v) = 0 with single boundary condition

Parameters:
  • equation
  • u
  • bc
  • J
  • tol
  • M

C++ documentation for solve from dolfin/adaptivity/adaptivesolve.h:

void dolfin::solve(const Equation &equation, Function &u, const DirichletBC &bc, const double tol, GoalFunctional &M)

Solve linear variational problem a(u, v) == L(v) with single boundary condition

Parameters:
  • equation
  • u
  • bc
  • tol
  • M

C++ documentation for solve from dolfin/adaptivity/adaptivesolve.h:

void dolfin::solve(const Equation &equation, Function &u, const Form &J, const double tol, GoalFunctional &M)

Solve nonlinear variational problem F(u; v) = 0 without essential boundary conditions

Parameters:
  • equation
  • u
  • J
  • tol
  • M

C++ documentation for solve from dolfin/adaptivity/adaptivesolve.h:

void dolfin::solve(const Equation &equation, Function &u, const double tol, GoalFunctional &M)

Solve linear variational problem a(u, v) == L(v) without essential boundary conditions

Parameters:
  • equation
  • u
  • tol
  • M

C++ documentation for solve from dolfin/adaptivity/adaptivesolve.h:

void dolfin::solve(const Equation &equation, Function &u, std::vector<const DirichletBC *> bcs, const Form &J, const double tol, GoalFunctional &M)

Solve linear variational problem F(u; v) = 0 with list of boundary conditions

Parameters:
  • equation
  • u
  • bcs
  • J
  • tol
  • M

C++ documentation for solve from dolfin/adaptivity/adaptivesolve.h:

void dolfin::solve(const Equation &equation, Function &u, std::vector<const DirichletBC *> bcs, const double tol, GoalFunctional &M)

Solve linear variational problem a(u, v) == L(v) with list of boundary conditions

Parameters:
  • equation
  • u
  • bcs
  • tol
  • M

Classes

AdaptiveLinearVariationalSolver

C++ documentation for AdaptiveLinearVariationalSolver from dolfin/adaptivity/AdaptiveLinearVariationalSolver.h:

class dolfin::AdaptiveLinearVariationalSolver : public dolfin::GenericAdaptiveVariationalSolver

A class for goal-oriented adaptive solution of linear variational problems. For a linear variational problem of the form: find u in V satisfying

a(u, v) = L(v) for all v in :math:`\hat V`

and a corresponding conforming discrete problem: find u_h in V_h satisfying

a(u_h, v) = L(v) for all v in :math:`\hat V_h`

and a given goal functional M and tolerance tol, the aim is to find a V_H and a u_H in V_H satisfying the discrete problem such that

\|M(u) - M(u_H)\| < tol

This strategy is based on dual-weighted residual error estimators designed and automatically generated for the primal problem and subsequent h-adaptivity.

dolfin::AdaptiveLinearVariationalSolver::AdaptiveLinearVariationalSolver(std::shared_ptr<LinearVariationalProblem> problem, std::shared_ptr<Form> goal, std::shared_ptr<ErrorControl> control)

Create AdaptiveLinearVariationalSolver() from variational problem, goal form and error control instance Arguments problem (LinearVariationalProblem ) The primal problem goal (Form ) The goal functional control (ErrorControl ) An error controller object

Parameters:
  • problem
  • goal
  • control
dolfin::AdaptiveLinearVariationalSolver::AdaptiveLinearVariationalSolver(std::shared_ptr<LinearVariationalProblem> problem, std::shared_ptr<GoalFunctional> goal)

Create AdaptiveLinearVariationalSolver() (shared ptr version) Arguments problem (LinearVariationalProblem ) The primal problem goal (GoalFunctional ) The goal functional

Parameters:
  • problem
  • goal
void dolfin::AdaptiveLinearVariationalSolver::adapt_problem(std::shared_ptr<const Mesh> mesh)

Adapt the problem to other mesh. Arguments mesh (Mesh ) The other mesh

Parameters:mesh
double dolfin::AdaptiveLinearVariationalSolver::evaluate_goal(Form &M, std::shared_ptr<const Function> u) const

Evaluate the goal functional. Arguments M (Form ) The functional to be evaluated u (Function ) The function at which to evaluate the functional Returns double The value of M evaluated at u

Parameters:
  • M
  • u
std::vector<std::shared_ptr<const DirichletBC>> dolfin::AdaptiveLinearVariationalSolver::extract_bcs() const

Extract the boundary conditions for the primal problem. Returns std::vector<DirichletBC > The primal boundary conditions

void dolfin::AdaptiveLinearVariationalSolver::init(std::shared_ptr<LinearVariationalProblem> problem, std::shared_ptr<GoalFunctional> goal)

Helper function for instance initialization Arguments problem (LinearVariationalProblem ) The primal problem u (GoalFunctional ) The goal functional

Parameters:
  • problem
  • goal
std::size_t dolfin::AdaptiveLinearVariationalSolver::num_dofs_primal()

Return the number of degrees of freedom for primal problem Returnsstd::size_t The number of degrees of freedom

std::shared_ptr<const Function> dolfin::AdaptiveLinearVariationalSolver::solve_primal()

Solve the primal problem. Returns:cpp:any:Function The solution to the primal problem

dolfin::AdaptiveLinearVariationalSolver::~AdaptiveLinearVariationalSolver()

Destructor.

AdaptiveNonlinearVariationalSolver

C++ documentation for AdaptiveNonlinearVariationalSolver from dolfin/adaptivity/AdaptiveNonlinearVariationalSolver.h:

class dolfin::AdaptiveNonlinearVariationalSolver : public dolfin::GenericAdaptiveVariationalSolver

A class for goal-oriented adaptive solution of nonlinear variational problems. For a nonlinear variational problem of the form: find u in V satisfying

F(u; v) = 0 for all v in :math:`\hat V`

and a corresponding conforming discrete problem: find u_h in V_h satisfying (at least approximately)

F(u_h; v) = 0 for all v in :math:`\hat V_h`

and a given goal functional M and tolerance tol, the aim is to find a V_H and a u_H in V_H satisfying the discrete problem such that

\|M(u) - M(u_H)\| < tol

This strategy is based on dual-weighted residual error estimators designed and automatically generated for the primal problem and subsequent h-adaptivity.

dolfin::AdaptiveNonlinearVariationalSolver::AdaptiveNonlinearVariationalSolver(std::shared_ptr<NonlinearVariationalProblem> problem, std::shared_ptr<Form> goal, std::shared_ptr<ErrorControl> control)

Create AdaptiveLinearVariationalSolver from variational problem, goal form and error control instance Arguments problem (NonlinearVariationalProblem ) The primal problem goal (Form ) The goal functional control (ErrorControl ) An error controller object

Parameters:
  • problem
  • goal
  • control
dolfin::AdaptiveNonlinearVariationalSolver::AdaptiveNonlinearVariationalSolver(std::shared_ptr<NonlinearVariationalProblem> problem, std::shared_ptr<GoalFunctional> goal)

Create AdaptiveNonlinearVariationalSolver() (shared ptr version) Arguments problem (NonlinearVariationalProblem ) The primal problem goal (GoalFunctional ) The goal functional

Parameters:
  • problem
  • goal
void dolfin::AdaptiveNonlinearVariationalSolver::adapt_problem(std::shared_ptr<const Mesh> mesh)

Adapt the problem to other mesh. Arguments mesh (Mesh ) The other mesh

Parameters:mesh
double dolfin::AdaptiveNonlinearVariationalSolver::evaluate_goal(Form &M, std::shared_ptr<const Function> u) const

Evaluate the goal functional. Arguments M (Form ) The functional to be evaluated u (Function ) The function at which to evaluate the functional Returns double The value of M evaluated at u

Parameters:
  • M
  • u
std::vector<std::shared_ptr<const DirichletBC>> dolfin::AdaptiveNonlinearVariationalSolver::extract_bcs() const

Extract the boundary conditions for the primal problem. Returns std::vector<DirichletBC > The primal boundary conditions

void dolfin::AdaptiveNonlinearVariationalSolver::init(std::shared_ptr<NonlinearVariationalProblem> problem, std::shared_ptr<GoalFunctional> goal)

Helper function for instance initialization Arguments problem (NonlinearVariationalProblem ) The primal problem u (GoalFunctional ) The goal functional

Parameters:
  • problem
  • goal
std::size_t dolfin::AdaptiveNonlinearVariationalSolver::num_dofs_primal()

Return the number of degrees of freedom for primal problem Returnsstd::size_t The number of degrees of freedom

std::shared_ptr<const Function> dolfin::AdaptiveNonlinearVariationalSolver::solve_primal()

Solve the primal problem. Returns:cpp:any:Function The solution to the primal problem

dolfin::AdaptiveNonlinearVariationalSolver::~AdaptiveNonlinearVariationalSolver()

Destructor.

ErrorControl

C++ documentation for ErrorControl from dolfin/adaptivity/ErrorControl.h:

class dolfin::ErrorControl

(Goal-oriented) Error Control class. The notation used here follows the notation in “Automated goal-oriented error control I: stationary variational problems”, ME Rognes and A Logg, 2010-2011.

Friends: adapt().

dolfin::ErrorControl::ErrorControl(std::shared_ptr<Form> a_star, std::shared_ptr<Form> L_star, std::shared_ptr<Form> residual, std::shared_ptr<Form> a_R_T, std::shared_ptr<Form> L_R_T, std::shared_ptr<Form> a_R_dT, std::shared_ptr<Form> L_R_dT, std::shared_ptr<Form> eta_T, bool is_linear)

Create error control object

Parameters:
  • a_star – (Form ) the bilinear form for the dual problem
  • L_star – (Form ) the linear form for the dual problem
  • residual – (Form ) a functional for the residual (error estimate)
  • a_R_T – (Form ) the bilinear form for the strong cell residual problem
  • L_R_T – (Form ) the linear form for the strong cell residual problem
  • a_R_dT – (Form ) the bilinear form for the strong facet residual problem
  • L_R_dT – (Form ) the linear form for the strong facet residual problem
  • eta_T – (Form ) a linear form over DG_0 for error indicators
  • is_linear – (bool) true iff primal problem is linear
void dolfin::ErrorControl::apply_bcs_to_extrapolation(const std::vector<std::shared_ptr<const DirichletBC>> bcs)
Parameters:bcs
void dolfin::ErrorControl::compute_cell_residual(Function &R_T, const Function &u)

Compute representation for the strong cell residual from the weak residual

Parameters:
  • R_T – (Function ) the strong cell residual (to be computed)
  • u – (Function ) the primal approximation
void dolfin::ErrorControl::compute_dual(Function &z, const std::vector<std::shared_ptr<const DirichletBC>> bcs)

Compute dual approximation defined by dual variational problem and dual boundary conditions given by homogenized primal boundary conditions.

Parameters:
  • z – (Function ) the dual approximation (to be computed)
  • bcs – (std::vector<DirichletBC>) the primal boundary conditions
void dolfin::ErrorControl::compute_extrapolation(const Function &z, const std::vector<std::shared_ptr<const DirichletBC>> bcs)

Compute extrapolation with boundary conditions

Parameters:
  • z – (Function ) the extrapolated function (to be computed)
  • bcs – (std::vector<DirichletBC >) the dual boundary conditions
void dolfin::ErrorControl::compute_facet_residual(SpecialFacetFunction &R_dT, const Function &u, const Function &R_T)

Compute representation for the strong facet residual from the weak residual and the strong cell residual

Parameters:
void dolfin::ErrorControl::compute_indicators(MeshFunction<double> &indicators, const Function &u)

Compute error indicators

Parameters:
  • indicators – (MeshFunction<double>) the error indicators (to be computed)
  • u – (Function ) the primal approximation
double dolfin::ErrorControl::estimate_error(const Function &u, const std::vector<std::shared_ptr<const DirichletBC>> bcs)

Estimate the error relative to the goal M of the discrete approximation ‘u’ relative to the variational formulation by evaluating the weak residual at an approximation to the dual solution.

Parameters:
  • u – (Function ) the primal approximation
  • bcs – (std::vector<DirichletBC >) the primal boundary conditions
Returns:

double error estimate

void dolfin::ErrorControl::residual_representation(Function &R_T, SpecialFacetFunction &R_dT, const Function &u)

Compute strong representation (strong cell and facet residuals) of the weak residual.

Parameters:
  • R_T – (Function ) the strong cell residual (to be computed)
  • R_dT – (SpecialFacetFunction ) the strong facet residual (to be computed)
  • u – (Function ) the primal approximation
dolfin::ErrorControl::~ErrorControl()

Destructor.

Extrapolation

C++ documentation for Extrapolation from dolfin/adaptivity/Extrapolation.h:

class dolfin::Extrapolation

This class implements an algorithm for extrapolating a function on a given function space from an approximation of that function on a possibly lower-order function space. This can be used to obtain a higher-order approximation of a computed dual solution, which is necessary when the computed dual approximation is in the test space of the primal problem, thereby being orthogonal to the residual. It is assumed that the extrapolation is computed on the same mesh as the original function.

void dolfin::Extrapolation::add_cell_equations(Eigen::MatrixXd &A, Eigen::VectorXd &b, const Cell &cell0, const Cell &cell1, const std::vector<double> &coordinate_dofs0, const std::vector<double> &coordinate_dofs1, const ufc::cell &c0, const ufc::cell &c1, const FunctionSpace &V, const FunctionSpace &W, const Function &v, std::map<std::size_t, std::size_t> &dof2row)
Parameters:
  • A
  • b
  • cell0
  • cell1
  • coordinate_dofs0
  • coordinate_dofs1
  • c0
  • c1
  • V
  • W
  • v
  • dof2row
void dolfin::Extrapolation::average_coefficients(Function &w, std::vector<std::vector<double>> &coefficients)
Parameters:
  • w
  • coefficients
void dolfin::Extrapolation::build_unique_dofs(std::set<std::size_t> &unique_dofs, std::map<std::size_t, std::map<std::size_t, std::size_t>> &cell2dof2row, const Cell &cell0, const FunctionSpace &V)
Parameters:
  • unique_dofs
  • cell2dof2row
  • cell0
  • V
void dolfin::Extrapolation::compute_coefficients(std::vector<std::vector<double>> &coefficients, const Function &v, const FunctionSpace &V, const FunctionSpace &W, const Cell &cell0, const std::vector<double> &coordinate_dofs0, const ufc::cell &c0, const ArrayView<const dolfin::la_index> &dofs, std::size_t &offset)
Parameters:
  • coefficients
  • v
  • V
  • W
  • cell0
  • coordinate_dofs0
  • c0
  • dofs
  • offset
std::map<std::size_t, std::size_t> dolfin::Extrapolation::compute_unique_dofs(const Cell &cell, const FunctionSpace &V, std::size_t &row, std::set<std::size_t> &unique_dofs)
Parameters:
  • cell
  • V
  • row
  • unique_dofs
void dolfin::Extrapolation::extrapolate(Function &w, const Function &v)

Compute extrapolation w from v.

Parameters:
  • w
  • v
GenericAdaptiveVariationalSolver

C++ documentation for GenericAdaptiveVariationalSolver from dolfin/adaptivity/GenericAdaptiveVariationalSolver.h:

class dolfin::GenericAdaptiveVariationalSolver

An abstract class for goal-oriented adaptive solution of variational problems.

void dolfin::GenericAdaptiveVariationalSolver::adapt_problem(std::shared_ptr<const Mesh> mesh) = 0

Adapt the problem to other mesh. Must be overloaded in subclass. Arguments mesh (Mesh ) The other mesh

Parameters:mesh
std::vector<std::shared_ptr<Parameters>> dolfin::GenericAdaptiveVariationalSolver::adaptive_data() const

Return stored adaptive data Returns std::vector<Parameters > The data stored in the adaptive loop

std::shared_ptr<ErrorControl> dolfin::GenericAdaptiveVariationalSolver::control

Error control object.

double dolfin::GenericAdaptiveVariationalSolver::evaluate_goal(Form &M, std::shared_ptr<const Function> u) const = 0

Evaluate the goal functional. Must be overloaded in subclass. Arguments M (Form ) The functional to be evaluated u (Function ) The function of which to evaluate the functional Returns double The value of M evaluated at u

Parameters:
  • M
  • u
std::vector<std::shared_ptr<const DirichletBC>> dolfin::GenericAdaptiveVariationalSolver::extract_bcs() const = 0

Extract the boundary conditions for the primal problem. Must be overloaded in subclass. Returns std::vector<DirichletBC > The primal boundary conditions

std::shared_ptr<Form> dolfin::GenericAdaptiveVariationalSolver::goal

The goal functional.

std::size_t dolfin::GenericAdaptiveVariationalSolver::num_dofs_primal() = 0

Return the number of degrees of freedom for primal problem Returnsstd::size_t The number of degrees of freedom

void dolfin::GenericAdaptiveVariationalSolver::solve(const double tol)

Solve such that the functional error is less than the given tolerance. Note that each call to solve is based on the leaf-node of the variational problem Arguments tol (double) The error tolerance

Parameters:tol
std::shared_ptr<const Function> dolfin::GenericAdaptiveVariationalSolver::solve_primal() = 0

Solve the primal problem. Must be overloaded in subclass. Returns:cpp:any:Function The solution to the primal problem

void dolfin::GenericAdaptiveVariationalSolver::summary()

Present summary of all adaptive data and parameters.

dolfin::GenericAdaptiveVariationalSolver::~GenericAdaptiveVariationalSolver()
GoalFunctional

C++ documentation for GoalFunctional from dolfin/adaptivity/GoalFunctional.h:

class dolfin::GoalFunctional : public dolfin::Form

A GoalFunctional is a Form of rank 0 with an associated ErrorControl .

dolfin::GoalFunctional::GoalFunctional(std::size_t rank, std::size_t num_coefficients)

Create GoalFunctional() Arguments rank (int) the rank of the functional (should be 0) num_coefficients (int) the number of coefficients in functional

Parameters:
  • rank
  • num_coefficients
void dolfin::GoalFunctional::update_ec(const Form &a, const Form &L) = 0

Update error control instance with given forms Arguments a (Form ) a bilinear form L (Form ) a linear form

Parameters:
  • a
  • L
MeshFunction

C++ documentation for MeshFunction from dolfin/adaptivity/adapt.h:

class dolfin::MeshFunction : public dolfin::MeshFunction<T>

A MeshFunction is a function that can be evaluated at a set of mesh entities. A MeshFunction is discrete and is only defined at the set of mesh entities of a fixed topological dimension. A MeshFunction may for example be used to store a global numbering scheme for the entities of a (parallel) mesh, marking sub domains or boolean markers for mesh refinement.

dolfin::MeshFunction::MeshFunction()

Create empty mesh function.

dolfin::MeshFunction::MeshFunction(const MeshFunction<T> &f)

Copy constructor

Parameters:f – (MeshFunction() ) The object to be copied.
dolfin::MeshFunction::MeshFunction(std::shared_ptr<const Mesh> mesh)

Create empty mesh function on given mesh

Parameters:mesh – (Mesh ) The mesh to create mesh function on.
dolfin::MeshFunction::MeshFunction(std::shared_ptr<const Mesh> mesh, const MeshValueCollection<T> &value_collection)

Create function from a MeshValueCollecion (shared_ptr version)

Parameters:
  • mesh – (Mesh ) The mesh to create mesh function on.
  • value_collection – (MeshValueCollection ) The mesh value collection for the mesh function data.
dolfin::MeshFunction::MeshFunction(std::shared_ptr<const Mesh> mesh, const std::string filename)

Create function from data file (shared_ptr version)

Parameters:
  • mesh – (Mesh ) The mesh to create mesh function on.
  • filename – (std::string) The filename to create mesh function from.
dolfin::MeshFunction::MeshFunction(std::shared_ptr<const Mesh> mesh, std::size_t dim)

Create mesh function of given dimension on given mesh

Parameters:
  • mesh – (Mesh ) The mesh to create mesh function on.
  • dim – (std::size_t) The mesh entity dimension for the mesh function.
dolfin::MeshFunction::MeshFunction(std::shared_ptr<const Mesh> mesh, std::size_t dim, const MeshDomains &domains)

Create function from MeshDomains

Parameters:
  • mesh – (Mesh ) The mesh to create mesh function on.
  • dim – (std::size_t) The dimension of the MeshFunction()
  • domains – (_MeshDomains) The domains from which to extract the domain markers
dolfin::MeshFunction::MeshFunction(std::shared_ptr<const Mesh> mesh, std::size_t dim, const T &value)

Create mesh of given dimension on given mesh and initialize to a value

Parameters:
  • mesh – (Mesh ) The mesh to create mesh function on.
  • dim – (std::size_t) The mesh entity dimension.
  • value
    1. The value.
std::size_t dolfin::MeshFunction::dim() const

Return topological dimension

Returns:std::size_t The dimension.
bool dolfin::MeshFunction::empty() const

Return true if empty

Returns:bool True if empty.
void dolfin::MeshFunction::init(std::shared_ptr<const Mesh> mesh, std::size_t dim)

Initialize mesh function for given topological dimension

Parameters:
  • mesh – (Mesh ) The mesh.
  • dim – (std::size_t) The dimension.
void dolfin::MeshFunction::init(std::shared_ptr<const Mesh> mesh, std::size_t dim, std::size_t size)

Initialize mesh function for given topological dimension of given size (shared_ptr version)

Parameters:
  • mesh – (Mesh ) The mesh.
  • dim – (std::size_t) The dimension.
  • size – (std::size_t) The size.
void dolfin::MeshFunction::init(std::size_t dim)

Initialize mesh function for given topological dimension

Parameters:dim – (std::size_t) The dimension.
void dolfin::MeshFunction::init(std::size_t dim, std::size_t size)

Initialize mesh function for given topological dimension of given size

Parameters:
  • dim – (std::size_t) The dimension.
  • size – (std::size_t) The size.
std::shared_ptr<const Mesh> dolfin::MeshFunction::mesh() const

Return mesh associated with mesh function

Returns:Mesh The mesh.
MeshFunction<T> &dolfin::MeshFunction::operator=(const MeshFunction<T> &f)

Assign mesh function to other mesh function Assignment operator

Parameters:f – (MeshFunction ) A MeshFunction object to assign to another MeshFunction .
MeshFunction<T> &dolfin::MeshFunction::operator=(const MeshValueCollection<T> &mesh)

Assignment operator

Parameters:mesh – (MeshValueCollection ) A MeshValueCollection object used to construct a MeshFunction .
const MeshFunction<T> &dolfin::MeshFunction::operator=(const T &value)

Set all values to given value

Parameters:value
T &dolfin::MeshFunction::operator[](const MeshEntity &entity)

Return value at given mesh entity

return T The value at the given entity.

Parameters:entity – (MeshEntity ) The mesh entity.
const T &dolfin::MeshFunction::operator[](const MeshEntity &entity) const

Return value at given mesh entity (const version)

Parameters:entity – (MeshEntity ) The mesh entity.
Returns:T The value at the given entity.
T &dolfin::MeshFunction::operator[](std::size_t index)

Return value at given index

Parameters:index – (std::size_t) The index.
Returns:T The value at the given index.
const T &dolfin::MeshFunction::operator[](std::size_t index) const

Return value at given index (const version)

Parameters:index – (std::size_t) The index.
Returns:T The value at the given index.
void dolfin::MeshFunction::set_all(const T &value)

Set all values to given value

Parameters:value
  1. The value to set all values to.
void dolfin::MeshFunction::set_value(std::size_t index, const T &value)

Set value at given index

Parameters:
  • index – (std::size_t) The index.
  • value
    1. The value.
void dolfin::MeshFunction::set_value(std::size_t index, const T &value, const Mesh &mesh)

Compatibility function for use in SubDomains.

Parameters:
  • index
  • value
  • mesh
void dolfin::MeshFunction::set_values(const std::vector<T> &values)

Set values

Parameters:values – (std::vector<T>) The values.
std::size_t dolfin::MeshFunction::size() const

Return size (number of entities)

Returns:std::size_t The size.
std::string dolfin::MeshFunction::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
std::string dolfin::MeshFunction::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose – (bool) Flag to turn on additional output.
Returns:std::string An informal representation.
T *dolfin::MeshFunction::values()

Return array of values return T The values.

const T *dolfin::MeshFunction::values() const

Return array of values (const. version) return T The values.

std::vector<std::size_t> dolfin::MeshFunction::where_equal(T value)

Get indices where meshfunction is equal to given value Arguments value (T) The value. Returns std::vector<T> The indices.

Parameters:value
dolfin::MeshFunction::~MeshFunction()

Destructor.

dolfin/ale

Documentation for C++ code found in dolfin/ale/*.h

Classes

ALE

C++ documentation for ALE from dolfin/ale/ALE.h:

class dolfin::ALE

This class provides functionality useful for implementation of ALE (Arbitrary Lagrangian-Eulerian) methods, in particular moving the boundary vertices of a mesh and then interpolating the new coordinates for the interior vertices accordingly.

void dolfin::ALE::move(Mesh &mesh, const Function &displacement)

Move coordinates of mesh according to displacement function.

Parameters:
  • mesh – (Mesh ) The mesh to move.
  • displacement – (Function ) A vectorial Lagrange function of matching degree.
void dolfin::ALE::move(Mesh &mesh, const GenericFunction &displacement)

Move coordinates of mesh according to displacement function. This works only for affine meshes. NOTE: This cannot be implemented for higher-order geometries as there is no way of constructing function space for position unless supplied as an argument.

Parameters:
  • mesh – (Mesh ) The affine mesh to move.
  • displacement – (GenericFunction ) A vectorial generic function.
std::shared_ptr<MeshDisplacement> dolfin::ALE::move(std::shared_ptr<Mesh> mesh, const BoundaryMesh &new_boundary)

Move coordinates of mesh according to new boundary coordinates. Works only for affine meshes.

Parameters:
  • mesh – (Mesh ) The affine mesh to move.
  • new_boundary – (BoundaryMesh ) An affine mesh containing just the boundary cells.
Returns:

MeshDisplacement Displacement encapsulated in Expression subclass MeshDisplacement .

std::shared_ptr<MeshDisplacement> dolfin::ALE::move(std::shared_ptr<Mesh> mesh0, const Mesh &mesh1)

Move coordinates of mesh according to adjacent mesh with common global vertices. Works only for affine meshes.

Parameters:
  • mesh0 – (Mesh ) The affine mesh to move.
  • mesh1 – (Mesh ) The affine mesh to be fit.
Returns:

MeshDisplacement Displacement encapsulated in Expression subclass

HarmonicSmoothing

C++ documentation for HarmonicSmoothing from dolfin/ale/HarmonicSmoothing.h:

class dolfin::HarmonicSmoothing

This class implements harmonic mesh smoothing. Poisson’s equation is solved with zero right-hand side (Laplace’s equation) for each coordinate direction to compute new coordinates for all vertices, given new locations for the coordinates of the boundary.

std::shared_ptr<MeshDisplacement> dolfin::HarmonicSmoothing::move(std::shared_ptr<Mesh> mesh, const BoundaryMesh &new_boundary)

Move coordinates of mesh according to new boundary coordinates and return the displacement

Parameters:
Returns:

MeshDisplacement Displacement

MeshDisplacement

C++ documentation for MeshDisplacement from dolfin/ale/MeshDisplacement.h:

class dolfin::MeshDisplacement : public dolfin::Expression

This class encapsulates the CG1 representation of the displacement of a mesh as an Expression . This is particularly useful for the displacement returned by mesh smoothers which can subsequently be used in evaluating forms. The value rank is 1 and the value shape is equal to the geometric dimension of the mesh.

dolfin::MeshDisplacement::MeshDisplacement(const MeshDisplacement &mesh_displacement)

Copy constructor

Parameters:mesh_displacement – (MeshDisplacement() ) Object to be copied.
dolfin::MeshDisplacement::MeshDisplacement(std::shared_ptr<const Mesh> mesh)

Create MeshDisplacement() of given mesh

Parameters:mesh – (Mesh ) Mesh to be displacement defined on.
void dolfin::MeshDisplacement::compute_vertex_values(std::vector<double> &vertex_values, const Mesh &mesh) const

Compute values at all mesh vertices.

Parameters:
  • vertex_values – (Array<double>) The values at all vertices.
  • mesh – (Mesh ) The mesh.
void dolfin::MeshDisplacement::eval(Array<double> &values, const Array<double> &x, const ufc::cell &cell) const

Evaluate at given point in given cell.

Parameters:
  • values – (Array<double>) The values at the point.
  • x – (Array<double>) The coordinates of the point.
  • cell – (ufc::cell ) The cell which contains the given point.
Function &dolfin::MeshDisplacement::operator[](const std::size_t i)

Extract subfunction In python available as MeshDisplacement.sub(i)

Parameters:i – (std::size_t) Index of subfunction.
const Function &dolfin::MeshDisplacement::operator[](const std::size_t i) const

Extract subfunction. Const version

Parameters:i – (std::size_t) Index of subfunction.
dolfin::MeshDisplacement::~MeshDisplacement()

Destructor.

dolfin/common

Documentation for C++ code found in dolfin/common/*.h

Type definitions

la_index

C++ documentation for la_index from dolfin/common/types.h:

type dolfin::la_index

Index type for compatibility with linear algebra backend(s)

Enumerations

TimingClear

C++ documentation for TimingClear from dolfin/common/timing.h:

enum dolfin::TimingClear

Parameter specifying whether to clear timing(s):

  • TimingClear::keep
  • TimingClear::clear
enumerator dolfin::TimingClear::keep = false
enumerator dolfin::TimingClear::clear = true
TimingType

C++ documentation for TimingType from dolfin/common/timing.h:

enum dolfin::TimingType

Timing types:

  • TimingType::wall wall-clock time
  • TimingType::user user (cpu) time
  • TimingType::system system (kernel) time

Precision of wall is around 1 microsecond, user and system are around 10 millisecond (on Linux).

enumerator dolfin::TimingType::wall = 0
enumerator dolfin::TimingType::user = 1
enumerator dolfin::TimingType::system = 2

Functions

container_to_string

C++ documentation for container_to_string from dolfin/common/utils.h:

std::string dolfin::container_to_string(const T &x, std::string delimiter, int precision, int linebreak = 0)

Return string representation of given container of ints, floats, etc.

Parameters:
  • x
  • delimiter
  • precision
  • linebreak
dolfin_version

C++ documentation for dolfin_version from dolfin/common/defines.h:

std::string dolfin::dolfin_version()

Return DOLFIN version string.

dump_timings_to_xml

C++ documentation for dump_timings_to_xml from dolfin/common/timing.h:

void dolfin::dump_timings_to_xml(std::string filename, TimingClear clear)

Dump a summary of timings and tasks to XML file, optionally clearing stored timings. MPI_MAX , MPI_MIN and MPI_AVG reductions are stored. Collective on MPI_COMM_WORLD . Arguments filename (std::string) output filename; must have .xml suffix; existing file is silently overwritten clear (TimingClear)

  • TimingClear::clear resets stored timings
  • TimingClear::keep leaves stored timings intact
Parameters:
  • filename
  • clear
git_commit_hash

C++ documentation for git_commit_hash from dolfin/common/defines.h:

std::string dolfin::git_commit_hash()

Return git changeset hash (returns “unknown” if changeset is not known)

has_cholmod

C++ documentation for has_cholmod from dolfin/common/defines.h:

bool dolfin::has_cholmod()

Return true if DOLFIN is compiled with Cholmod.

has_debug

C++ documentation for has_debug from dolfin/common/defines.h:

bool dolfin::has_debug()

Return true if DOLFIN is compiled in debugging mode, i.e., with assertions on

has_hdf5

C++ documentation for has_hdf5 from dolfin/common/defines.h:

bool dolfin::has_hdf5()

Return true if DOLFIN is compiled with HDF5.

has_hdf5_parallel

C++ documentation for has_hdf5_parallel from dolfin/common/defines.h:

bool dolfin::has_hdf5_parallel()

Return true if DOLFIN is compiled with Parallel HDF5.

has_mpi

C++ documentation for has_mpi from dolfin/common/defines.h:

bool dolfin::has_mpi()

Return true if DOLFIN is compiled with MPI .

has_openmp

C++ documentation for has_openmp from dolfin/common/defines.h:

bool dolfin::has_openmp()

Return true if DOLFIN is compiled with OpenMP.

has_parmetis

C++ documentation for has_parmetis from dolfin/common/defines.h:

bool dolfin::has_parmetis()

Return true if DOLFIN is compiled with ParMETIS .

has_petsc

C++ documentation for has_petsc from dolfin/common/defines.h:

bool dolfin::has_petsc()

Return true if DOLFIN is compiled with PETSc.

has_scotch

C++ documentation for has_scotch from dolfin/common/defines.h:

bool dolfin::has_scotch()

Return true if DOLFIN is compiled with Scotch.

has_slepc

C++ documentation for has_slepc from dolfin/common/defines.h:

bool dolfin::has_slepc()

Return true if DOLFIN is compiled with SLEPc.

has_umfpack

C++ documentation for has_umfpack from dolfin/common/defines.h:

bool dolfin::has_umfpack()

Return true if DOLFIN is compiled with Umfpack.

has_vtk

C++ documentation for has_vtk from dolfin/common/defines.h:

bool dolfin::has_vtk()

Return true if DOLFIN is compiled with VTK.

has_zlib

C++ documentation for has_zlib from dolfin/common/defines.h:

bool dolfin::has_zlib()

Return true if DOLFIN is compiled with ZLIB.

hash_global

C++ documentation for hash_global from dolfin/common/utils.h:

std::size_t dolfin::hash_global(const MPI_Comm mpi_comm, const T &x)

Return a hash for a distributed (MPI ) object. A hash is computed on each process, and the hash of the std::vector of all local hash keys is returned. This function is collective.

Parameters:
  • mpi_comm
  • x
hash_local

C++ documentation for hash_local from dolfin/common/utils.h:

std::size_t dolfin::hash_local(const T &x)

Return a hash of a given object.

Parameters:x
indent

C++ documentation for indent from dolfin/common/utils.h:

std::string dolfin::indent(std::string block)

Indent string block.

Parameters:block
init

C++ documentation for init from dolfin/common/init.h:

void dolfin::init(int argc, char *argv[])

Initialize DOLFIN (and PETSc) with command-line arguments. This should not be needed in most cases since the initialization is otherwise handled automatically.

Parameters:
  • argc
  • argv
list_timings

C++ documentation for list_timings from dolfin/common/timing.h:

void dolfin::list_timings(TimingClear clear, std::set<TimingType> type)

List a summary of timings and tasks, optionally clearing stored timings. MPI_AVG reduction is printed. Collective on MPI_COMM_WORLD . Arguments clear (TimingClear)

  • TimingClear::clear resets stored timings
  • TimingClear::keep leaves stored timings intact type (std::set<TimingType>) subset of { TimingType::wall, TimingType::user, TimingType::system }
Parameters:
  • clear
  • type
reference_to_no_delete_pointer

C++ documentation for reference_to_no_delete_pointer from dolfin/common/NoDeleter.h:

std::shared_ptr<T> dolfin::reference_to_no_delete_pointer(T &r)

Helper function to construct shared pointer with NoDeleter with cleaner syntax.

Parameters:r
sizeof_la_index

C++ documentation for sizeof_la_index from dolfin/common/defines.h:

std::size_t dolfin::sizeof_la_index()

Return sizeof the dolfin::la_index type.

tic

C++ documentation for tic from dolfin/common/timing.h:

void dolfin::tic()

Start timing (should not be used internally in DOLFIN!)

time

C++ documentation for time from dolfin/common/timing.h:

double dolfin::time()

Return wall time elapsed since some implementation dependent epoch.

timing

C++ documentation for timing from dolfin/common/timing.h:

std::tuple<std::size_t, double, double, double> dolfin::timing(std::string task, TimingClear clear)

Return timing (count, total wall time, total user time, total system time) for given task, optionally clearing all timings for the task Arguments task (std::string) name of a task clear (TimingClear)

  • TimingClear::clear resets stored timings
  • TimingClear::keep leaves stored timings intact

Returns std::tuple<std::size_t, double, double, double> (count, total wall time, total user time, total system time)

Parameters:
  • task
  • clear
timings

C++ documentation for timings from dolfin/common/timing.h:

Table dolfin::timings(TimingClear clear, std::set<TimingType> type)

Return a summary of timings and tasks in a Table , optionally clearing stored timings Arguments clear (TimingClear)

  • TimingClear::clear resets stored timings
  • TimingClear::keep leaves stored timings intact type (std::set<TimingType>) subset of { TimingType::wall, TimingType::user, TimingType::system }

Returns:cpp:any:Table Table with timings

Parameters:
  • clear
  • type
to_string

C++ documentation for to_string from dolfin/common/utils.h:

std::string dolfin::to_string(const double *x, std::size_t n)

Return string representation of given array.

Parameters:
  • x
  • n
toc

C++ documentation for toc from dolfin/common/timing.h:

double dolfin::toc()

Return elapsed wall time (should not be used internally in DOLFIN!)

ufc_signature

C++ documentation for ufc_signature from dolfin/common/defines.h:

std::string dolfin::ufc_signature()

Return UFC signature string.

Classes

Array

C++ documentation for Array from dolfin/common/Array.h:

class dolfin::Array

This class provides a simple wrapper for a pointer to an array. A purpose of this class is to enable the simple and safe exchange of data between C++ and Python.

dolfin::Array::Array(const Array &other) = delete

Disable copy construction, to avoid unanticipated sharing or copying of data. This means that an Array() must always be passed as reference, or as a (possibly shared) pointer.

Parameters:other
dolfin::Array::Array(std::size_t N)

Create array of size N. Array() has ownership.

Parameters:N
dolfin::Array::Array(std::size_t N, T *x)

Construct array from a pointer. Array() does not take ownership.

Parameters:
  • N
  • x
T *dolfin::Array::data()

Return pointer to data (non-const version)

const T *dolfin::Array::data() const

Return pointer to data (const version)

T &dolfin::Array::operator[](std::size_t i)

Access value of given entry (non-const version)

Parameters:i
const T &dolfin::Array::operator[](std::size_t i) const

Access value of given entry (const version)

Parameters:i
std::size_t dolfin::Array::size() const

Return size of array.

std::string dolfin::Array::str(bool verbose) const

Return informal string representation (pretty-print). Note that the Array class is not a subclass of Variable (for efficiency) which means that one needs to call str() directly instead of using the info() function on Array objects.

Parameters:verbose
dolfin::Array::~Array()

Destructor.

ArrayView

C++ documentation for ArrayView from dolfin/common/ArrayView.h:

class dolfin::ArrayView

This class provides a wrapper for a pointer to an array. It never owns the data, and will not be valid if the underlying data goes out-of-scope.

dolfin::ArrayView::ArrayView()

Constructor.

dolfin::ArrayView::ArrayView(V &v)

Construct array from a container with the the data() and size() functions

Parameters:v
dolfin::ArrayView::ArrayView(const ArrayView &x)

Copy constructor.

Parameters:x
dolfin::ArrayView::ArrayView(std::size_t N, T *x)

Construct array from a pointer. Array does not take ownership.

Parameters:
  • N
  • x
T *dolfin::ArrayView::begin()

Pointer to start of array.

const T *dolfin::ArrayView::begin() const

Pointer to start of array (const)

T *dolfin::ArrayView::data()

Return pointer to data (non-const version)

const T *dolfin::ArrayView::data() const

Return pointer to data (const version)

bool dolfin::ArrayView::empty() const

Test if array view is empty.

T *dolfin::ArrayView::end()

Pointer to beyond end of array.

const T *dolfin::ArrayView::end() const

Pointer to beyond end of array (const)

T &dolfin::ArrayView::operator[](std::size_t i)

Access value of given entry (non-const version)

Parameters:i
const T &dolfin::ArrayView::operator[](std::size_t i) const

Access value of given entry (const version)

Parameters:i
void dolfin::ArrayView::set(V &v)

Update object to point to new container.

Parameters:v
void dolfin::ArrayView::set(std::size_t N, T *x)

Update object to point to new data.

Parameters:
  • N
  • x
std::size_t dolfin::ArrayView::size() const

Return size of array.

dolfin::ArrayView::~ArrayView()

Destructor.

Hierarchical

C++ documentation for Hierarchical from dolfin/common/Hierarchical.h:

class dolfin::Hierarchical

This class provides storage and data access for hierarchical classes; that is, classes where an object may have a child and a parent. Note to developers: each subclass of Hierarchical that implements an assignment operator must call the base class assignment operator at the end of the subclass assignment operator. See the Mesh class for an example.

dolfin::Hierarchical::Hierarchical(T &self)

Constructor.

Parameters:self
T &dolfin::Hierarchical::child()

Return child in hierarchy. An error is thrown if the object has no child. ReturnsT The child object.

const T &dolfin::Hierarchical::child() const

Return child in hierarchy (const version).

std::shared_ptr<T> dolfin::Hierarchical::child_shared_ptr()

Return shared pointer to child. A zero pointer is returned if the object has no child. Returns shared_ptr<T> The child object.

std::shared_ptr<const T> dolfin::Hierarchical::child_shared_ptr() const

Return shared pointer to child (const version).

void dolfin::Hierarchical::clear_child()

Clear child.

std::size_t dolfin::Hierarchical::depth() const

Return depth of the hierarchy; that is, the total number of objects in the hierarchy linked to the current object via child-parent relationships, including the object itself. Returns std::size_t The depth of the hierarchy.

bool dolfin::Hierarchical::has_child() const

Check if the object has a child. Returns bool The return value is true iff the object has a child.

bool dolfin::Hierarchical::has_parent() const

Check if the object has a parent. Returns bool The return value is true iff the object has a parent.

T &dolfin::Hierarchical::leaf_node()

Return leaf node object in hierarchy. ReturnsT The leaf node object.

const T &dolfin::Hierarchical::leaf_node() const

Return leaf node object in hierarchy (const version).

std::shared_ptr<T> dolfin::Hierarchical::leaf_node_shared_ptr()

Return shared pointer to leaf node object in hierarchy. ReturnsT The leaf node object.

std::shared_ptr<const T> dolfin::Hierarchical::leaf_node_shared_ptr() const

Return shared pointer to leaf node object in hierarchy (const version).

const Hierarchical &dolfin::Hierarchical::operator=(const Hierarchical &hierarchical)

Assignment operator.

Parameters:hierarchical
T &dolfin::Hierarchical::parent()

Return parent in hierarchy. An error is thrown if the object has no parent. ReturnsObject The parent object.

const T &dolfin::Hierarchical::parent() const

Return parent in hierarchy (const version).

std::shared_ptr<T> dolfin::Hierarchical::parent_shared_ptr()

Return shared pointer to parent. A zero pointer is returned if the object has no parent. Returns shared_ptr<T> The parent object.

std::shared_ptr<const T> dolfin::Hierarchical::parent_shared_ptr() const

Return shared pointer to parent (const version).

T &dolfin::Hierarchical::root_node()

Return root node object in hierarchy. ReturnsT The root node object.

const T &dolfin::Hierarchical::root_node() const

Return root node object in hierarchy (const version).

std::shared_ptr<T> dolfin::Hierarchical::root_node_shared_ptr()

Return shared pointer to root node object in hierarchy. ReturnsT The root node object.

std::shared_ptr<const T> dolfin::Hierarchical::root_node_shared_ptr() const

Return shared pointer to root node object in hierarchy (const version).

void dolfin::Hierarchical::set_child(std::shared_ptr<T> child)

Set child.

Parameters:child
void dolfin::Hierarchical::set_parent(std::shared_ptr<T> parent)

Set parent.

Parameters:parent
dolfin::Hierarchical::~Hierarchical()

Destructor.

IndexSet

C++ documentation for IndexSet from dolfin/common/IndexSet.h:

class dolfin::IndexSet

This class provides an efficient data structure for index sets. The cost of checking whether a given index is in the set is O(1) and very very fast (optimal) at the cost of extra storage.

dolfin::IndexSet::IndexSet(std::size_t size)

Create index set of given size.

Parameters:size
void dolfin::IndexSet::clear()

Clear set.

bool dolfin::IndexSet::empty() const

Return true if set is empty.

void dolfin::IndexSet::fill()

Fill index set with indices 0, 1, 2, ..., size - 1.

std::size_t dolfin::IndexSet::find(std::size_t index) const

Return position (if any) for given index.

Parameters:index
bool dolfin::IndexSet::has_index(std::size_t index) const

Check whether index is in set.

Parameters:index
void dolfin::IndexSet::insert(std::size_t index)

Insert index into set.

Parameters:index
std::size_t &dolfin::IndexSet::operator[](std::size_t i)

Return given index.

Parameters:i
const std::size_t &dolfin::IndexSet::operator[](std::size_t i) const

Return given index (const version)

Parameters:i
std::size_t dolfin::IndexSet::size() const

Return size of set.

dolfin::IndexSet::~IndexSet()

Destructor.

MPI

C++ documentation for MPI from dolfin/common/MPI.h:

class dolfin::MPI

This class provides utility functions for easy communication with MPI and handles cases when DOLFIN is not configured with MPI .

void dolfin::MPI::all_gather(MPI_Comm comm, const T in_value, std::vector<T> &out_values)

Gather values, one primitive from each process (MPI_Allgather)

Parameters:
  • comm
  • in_value
  • out_values
void dolfin::MPI::all_gather(MPI_Comm comm, const std::vector<T> &in_values, std::vector<T> &out_values)

Gather values from all processes. Same data count from each process (wrapper for MPI_Allgather)

Parameters:
  • comm
  • in_values
  • out_values
void dolfin::MPI::all_gather(MPI_Comm comm, const std::vector<T> &in_values, std::vector<std::vector<T>> &out_values)

Gather values from each process (variable count per process)

Parameters:
  • comm
  • in_values
  • out_values
T dolfin::MPI::all_reduce(MPI_Comm comm, const T &value, X op)

All reduce.

Parameters:
  • comm
  • value
  • op
void dolfin::MPI::all_to_all(MPI_Comm comm, std::vector<std::vector<T>> &in_values, std::vector<std::vector<T>> &out_values)

Send in_values[p0] to process p0 and receive values from process p1 in out_values[p1]

Parameters:
  • comm
  • in_values
  • out_values
T dolfin::MPI::avg(MPI_Comm comm, const T &value)

Return average across comm; implemented only for T == Table .

Parameters:
  • comm
  • value
void dolfin::MPI::barrier(MPI_Comm comm)

Set a barrier (synchronization point)

Parameters:comm
void dolfin::MPI::broadcast(MPI_Comm comm, T &value, unsigned int broadcaster = 0)

Broadcast single primitive from broadcaster to all processes.

Parameters:
  • comm
  • value
  • broadcaster
void dolfin::MPI::broadcast(MPI_Comm comm, std::vector<T> &value, unsigned int broadcaster = 0)

Broadcast vector of value from broadcaster to all processes.

Parameters:
  • comm
  • value
  • broadcaster
std::pair<std::int64_t, std::int64_t> dolfin::MPI::compute_local_range(int process, std::int64_t N, int size)

Return local range for given process, splitting [0, N - 1] into size() portions of almost equal size

Parameters:
  • process
  • N
  • size
void dolfin::MPI::error_no_mpi(const char *where)
Parameters:where
void dolfin::MPI::gather(MPI_Comm comm, const std::string &in_values, std::vector<std::string> &out_values, unsigned int receiving_process = 0)

Gather strings on one process.

Parameters:
  • comm
  • in_values
  • out_values
  • receiving_process
void dolfin::MPI::gather(MPI_Comm comm, const std::vector<T> &in_values, std::vector<T> &out_values, unsigned int receiving_process = 0)

Gather values on one process.

Parameters:
  • comm
  • in_values
  • out_values
  • receiving_process
std::size_t dolfin::MPI::global_offset(MPI_Comm comm, std::size_t range, bool exclusive)

Find global offset (index) (wrapper for MPI_(Ex)Scan with MPI_SUM as reduction op)

Parameters:
  • comm
  • range
  • exclusive
unsigned int dolfin::MPI::index_owner(MPI_Comm comm, std::size_t index, std::size_t N)

Return which process owns index (inverse of local_range)

Parameters:
  • comm
  • index
  • N
bool dolfin::MPI::is_broadcaster(MPI_Comm comm)

Determine whether we should broadcast (based on current parallel policy)

Parameters:comm
bool dolfin::MPI::is_receiver(MPI_Comm comm)

Determine whether we should receive (based on current parallel policy)

Parameters:comm
std::pair<std::int64_t, std::int64_t> dolfin::MPI::local_range(MPI_Comm comm, int process, std::int64_t N)

Return local range for given process, splitting [0, N - 1] into size() portions of almost equal size

Parameters:
  • comm
  • process
  • N
std::pair<std::int64_t, std::int64_t> dolfin::MPI::local_range(MPI_Comm comm, std::int64_t N)

Return local range for local process, splitting [0, N - 1] into size() portions of almost equal size

Parameters:
  • comm
  • N
T dolfin::MPI::max(MPI_Comm comm, const T &value)

Return global max value.

Parameters:
  • comm
  • value
T dolfin::MPI::min(MPI_Comm comm, const T &value)

Return global min value.

Parameters:
  • comm
  • value
unsigned int dolfin::MPI::rank(MPI_Comm comm)

Return process rank for the communicator.

Parameters:comm
void dolfin::MPI::scatter(MPI_Comm comm, const std::vector<T> &in_values, T &out_value, unsigned int sending_process = 0)

Scatter primitive in_values[i] to process i.

Parameters:
  • comm
  • in_values
  • out_value
  • sending_process
void dolfin::MPI::scatter(MPI_Comm comm, const std::vector<std::vector<T>> &in_values, std::vector<T> &out_value, unsigned int sending_process = 0)

Scatter vector in_values[i] to process i.

Parameters:
  • comm
  • in_values
  • out_value
  • sending_process
void dolfin::MPI::send_recv(MPI_Comm comm, const std::vector<T> &send_value, unsigned int dest, int send_tag, std::vector<T> &recv_value, unsigned int source, int recv_tag)

Send-receive data between processes (blocking)

Parameters:
  • comm
  • send_value
  • dest
  • send_tag
  • recv_value
  • source
  • recv_tag
void dolfin::MPI::send_recv(MPI_Comm comm, const std::vector<T> &send_value, unsigned int dest, std::vector<T> &recv_value, unsigned int source)

Send-receive data between processes.

Parameters:
  • comm
  • send_value
  • dest
  • recv_value
  • source
unsigned int dolfin::MPI::size(MPI_Comm comm)

Return size of the group (number of processes) associated with the communicator

Parameters:comm
T dolfin::MPI::sum(MPI_Comm comm, const T &value)

Sum values and return sum.

Parameters:
  • comm
  • value
NoDeleter

C++ documentation for NoDeleter from dolfin/common/NoDeleter.h:

class dolfin::NoDeleter

NoDeleter is a customised deleter intended for use with smart pointers.

void dolfin::NoDeleter::operator()(const void *)

Do nothing.

RangedIndexSet

C++ documentation for RangedIndexSet from dolfin/common/RangedIndexSet.h:

class dolfin::RangedIndexSet

This class provides an special-purpose data structure for testing if a given index within a range is set. It is very fast. The memory requirements are one bit per item in range, since it uses a (packed) std::vector<bool> for storage.

dolfin::RangedIndexSet::RangedIndexSet(std::pair<std::size_t, std::size_t> range)

Create a ranged set with range given as a (lower, upper) pair.

Parameters:range
dolfin::RangedIndexSet::RangedIndexSet(std::size_t upper_range)

Create a ranged set with 0 as lower range.

Parameters:upper_range
void dolfin::RangedIndexSet::clear()

Erase all indices from the set.

void dolfin::RangedIndexSet::erase(std::size_t i)

Erase an index from the set.

Parameters:i
bool dolfin::RangedIndexSet::has_index(std::size_t i) const

Check is the set contains the given index.

Parameters:i
bool dolfin::RangedIndexSet::in_range(std::size_t i) const

Return true if a given index is within range, i.e., if it can be stored in the set.

Parameters:i
bool dolfin::RangedIndexSet::insert(std::size_t i)

Insert a given index into the set. Returns true if the index was inserted (i.e., the index was not already in the set).

Parameters:i
Set

C++ documentation for Set from dolfin/common/Set.h:

class dolfin::Set

This is a set-like data structure. It is not ordered and it is based a std::vector. It uses linear search, and can be faster than std::set

dolfin::Set::Set()

Create empty set.

dolfin::Set::Set(const dolfin::Set<T> &x)

Copy constructor.

Parameters:x
dolfin::Set::Set(std::vector<T> &x)

Wrap std::vector as a set. Contents will be erased.

Parameters:x
const_iterator dolfin::Set::begin() const

Iterator to start of Set .

void dolfin::Set::clear()

Clear set.

type dolfin::Set::const_iterator

Const iterator.

const_iterator dolfin::Set::end() const

Iterator to beyond end of Set .

void dolfin::Set::erase(const T &x)

Erase an entry.

Parameters:x
iterator dolfin::Set::find(const T &x)

Find entry in set and return an iterator to the entry.

Parameters:x
const_iterator dolfin::Set::find(const T &x) const

Find entry in set and return an iterator to the entry (const)

Parameters:x
void dolfin::Set::insert(const InputIt first, const InputIt last)

Insert entries.

Parameters:
  • first
  • last
bool dolfin::Set::insert(const T &x)

Insert entry.

Parameters:x
type dolfin::Set::iterator

Iterator.

T dolfin::Set::operator[](std::size_t n) const

Index the nth entry in the set.

Parameters:n
std::vector<T> &dolfin::Set::set()

Return the vector that stores the data in the Set .

const std::vector<T> &dolfin::Set::set() const

Return the vector that stores the data in the Set .

std::size_t dolfin::Set::size() const

Set size.

void dolfin::Set::sort()

Sort set.

dolfin::Set::~Set()

Destructor.

SubSystemsManager

C++ documentation for SubSystemsManager from dolfin/common/SubSystemsManager.h:

class dolfin::SubSystemsManager : public std::string

This is a singleton class which manages the initialisation and finalisation of various sub systems, such as MPI and PETSc.

PetscErrorCode dolfin::SubSystemsManager::PetscDolfinErrorHandler(MPI_Comm comm, int line, const char *fun, const char *file, PetscErrorCode n, PetscErrorType p, const char *mess, void *ctx)

PETSc error handler. Logs everything known to DOLFIN logging system (with level TRACE) and stores the error message into pests_err_msg member.

Parameters:
  • comm
  • line
  • fun
  • file
  • n
  • p
  • mess
  • ctx
dolfin::SubSystemsManager::SubSystemsManager()
dolfin::SubSystemsManager::SubSystemsManager(const SubSystemsManager&)
Parameters:sub_sys_manager
bool dolfin::SubSystemsManager::control_mpi
void dolfin::SubSystemsManager::finalize()

Finalize subsystems. This will be called by the destructor, but in special cases it may be necessary to call finalize() explicitly.

void dolfin::SubSystemsManager::finalize_mpi()
void dolfin::SubSystemsManager::finalize_petsc()
void dolfin::SubSystemsManager::init_mpi()

Initialise MPI .

int dolfin::SubSystemsManager::init_mpi(int argc, char *argv[], int required_thread_level)

Initialise MPI with required level of thread support.

Parameters:
  • argc
  • argv
  • required_thread_level
void dolfin::SubSystemsManager::init_petsc()

Initialize PETSc without command-line arguments.

void dolfin::SubSystemsManager::init_petsc(int argc, char *argv[])

Initialize PETSc with command-line arguments. Note that PETSc command-line arguments may also be filtered and sent to PETSc by parameters.parse(argc, argv).

Parameters:
  • argc
  • argv
bool dolfin::SubSystemsManager::mpi_finalized()

Check if MPI has been finalized (returns true if MPI has been finalised)

bool dolfin::SubSystemsManager::mpi_initialized()

Check if MPI has been initialised (returns true if MPI has been initialised, even if it is later finalised)

std::string dolfin::SubSystemsManager::petsc_err_msg

Last recorded PETSc error message.

bool dolfin::SubSystemsManager::petsc_initialized
bool dolfin::SubSystemsManager::responsible_mpi()

Return true if DOLFIN initialised MPI (and is therefore responsible for finalization)

bool dolfin::SubSystemsManager::responsible_petsc()

Return true if DOLFIN initialised PETSc (and is therefore responsible for finalization)

SubSystemsManager &dolfin::SubSystemsManager::singleton()

Singleton instance. Calling this ensures singleton instance of SubSystemsManager is initialized according to the “Construct on First Use” idiom.

dolfin::SubSystemsManager::~SubSystemsManager()
Timer

C++ documentation for Timer from dolfin/common/Timer.h:

class dolfin::Timer

A timer can be used for timing tasks. The basic usage is Timer timer(“Assembling over cells”); The timer is started at construction and timing ends when the timer is destroyed (goes out of scope). It is also possible to start and stop a timer explicitly by timer.start(); timer.stop(); Timings are stored globally and a summary may be printed by calling list_timings() ;

dolfin::Timer::Timer()

Create timer without logging.

dolfin::Timer::Timer(std::string task)

Create timer with logging.

Parameters:task
std::tuple<double, double, double> dolfin::Timer::elapsed() const

Return wall, user and system time in seconds. Wall-clock time has precision around 1 microsecond; user and system around 10 millisecond.

void dolfin::Timer::resume()

Resume timer. Not well-defined for logging timer.

void dolfin::Timer::start()

Zero and start timer.

double dolfin::Timer::stop()

Stop timer, return wall time elapsed and store timing data into logger

dolfin::Timer::~Timer()

Destructor.

UniqueIdGenerator

C++ documentation for UniqueIdGenerator from dolfin/common/UniqueIdGenerator.h:

class dolfin::UniqueIdGenerator

This is a singleton class that return IDs that are unique in the lifetime of a program.

dolfin::UniqueIdGenerator::UniqueIdGenerator()
std::size_t dolfin::UniqueIdGenerator::id()

Generate a unique ID.

std::size_t dolfin::UniqueIdGenerator::next_id
UniqueIdGenerator dolfin::UniqueIdGenerator::unique_id_generator
Variable

C++ documentation for Variable from dolfin/common/Variable.h:

class dolfin::Variable

Common base class for DOLFIN variables.

dolfin::Variable::Variable()

Create unnamed variable.

dolfin::Variable::Variable(const Variable &variable)

Copy constructor.

Parameters:variable
dolfin::Variable::Variable(const std::string name, const std::string label)

Create variable with given name and label.

Parameters:
  • name
  • label
std::size_t dolfin::Variable::id() const

Get unique identifier. Returnsstd::size_t The unique integer identifier associated with the object.

std::string dolfin::Variable::label() const

Return label (description)

std::string dolfin::Variable::name() const

Return name.

const Variable &dolfin::Variable::operator=(const Variable &variable)

Assignment operator.

Parameters:variable
Parameters dolfin::Variable::parameters

Parameters .

void dolfin::Variable::rename(const std::string name, const std::string label)

Rename variable.

Parameters:
  • name
  • label
std::string dolfin::Variable::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
const std::size_t dolfin::Variable::unique_id
dolfin::Variable::~Variable()

Destructor.

dolfin/fem

Documentation for C++ code found in dolfin/fem/*.h

Type definitions

TensorProductForm

C++ documentation for TensorProductForm from dolfin/fem/LinearTimeDependentProblem.h:

type dolfin::TensorProductForm

FIXME: Temporary fix.

Functions

assemble

C++ documentation for assemble from dolfin/fem/assemble.h:

void dolfin::assemble(GenericTensor &A, const Form &a)

Assemble tensor.

Parameters:
  • A
  • a

C++ documentation for assemble from dolfin/fem/assemble.h:

double dolfin::assemble(const Form &a)

Assemble scalar.

Parameters:a
assemble_local

C++ documentation for assemble_local from dolfin/fem/assemble_local.h:

void dolfin::assemble_local(const Form &a, const Cell &cell, std::vector<double> &tensor)

Assemble form to local tensor on a cell.

Parameters:
  • a
  • cell
  • tensor
assemble_multimesh

C++ documentation for assemble_multimesh from dolfin/fem/assemble.h:

void dolfin::assemble_multimesh(GenericTensor &A, const MultiMeshForm &a)

Assemble tensor from multimesh form.

Parameters:
  • A
  • a

C++ documentation for assemble_multimesh from dolfin/fem/assemble.h:

double dolfin::assemble_multimesh(const MultiMeshForm &a)

Assemble scalar from multimesh form.

Parameters:a
assemble_system

C++ documentation for assemble_system from dolfin/fem/assemble.h:

void dolfin::assemble_system(GenericMatrix &A, GenericVector &b, const Form &a, const Form &L, std::vector<std::shared_ptr<const DirichletBC>> bcs)

Assemble system (A, b) and apply Dirichlet boundary conditions.

Parameters:
  • A
  • b
  • a
  • L
  • bcs

C++ documentation for assemble_system from dolfin/fem/assemble.h:

void dolfin::assemble_system(GenericMatrix &A, GenericVector &b, const Form &a, const Form &L, std::vector<std::shared_ptr<const DirichletBC>> bcs, const GenericVector &x0)

Assemble system (A, b) on sub domains and apply Dirichlet boundary conditions

Parameters:
  • A
  • b
  • a
  • L
  • bcs
  • x0
create_mesh

C++ documentation for create_mesh from dolfin/fem/fem_utils.h:

Mesh dolfin::create_mesh(Function &coordinates)

Creates mesh from coordinate function Topology is given by underlying mesh of the function space and geometry is given by function values. Hence resulting mesh geometry has a degree of the function space degree. Geometry of function mesh is ignored. Mesh connectivities d-0, d-1, ..., d-r are built on function mesh (where d is topological dimension of the mesh and r is maximal dimension of entity associated with any coordinate node). Consider clearing unneeded connectivities when finished.

Parameters:coordinates – (Function ) Vector Lagrange function of any degree
Returns:Mesh The mesh
dof_to_vertex_map

C++ documentation for dof_to_vertex_map from dolfin/fem/fem_utils.h:

std::vector<std::size_t> dolfin::dof_to_vertex_map(const FunctionSpace &space)

Return a map between dof indices and vertex indices Only works for FunctionSpace with dofs exclusively on vertices. For mixed FunctionSpaces vertex index is offset with the number of dofs per vertex. In parallel the returned map maps both owned and unowned dofs (using local indices) thus covering all the vertices. Hence the returned map is an inversion of vertex_to_dof_map.

Parameters:space – (FunctionSpace ) The FunctionSpace for what the dof to vertex map should be computed for
Returns:std::vector<std::size_t> The dof to vertex map
get_coordinates

C++ documentation for get_coordinates from dolfin/fem/fem_utils.h:

void dolfin::get_coordinates(Function &position, const MeshGeometry &geometry)

Stores mesh coordinates into function Mesh connectivities d-0, d-1, ..., d-r are built on function mesh (where d is topological dimension of the mesh and r is maximal dimension of entity associated with any coordinate node). Consider clearing unneeded connectivities when finished.

Parameters:
set_coordinates

C++ documentation for set_coordinates from dolfin/fem/fem_utils.h:

void dolfin::set_coordinates(MeshGeometry &geometry, const Function &position)

Sets mesh coordinates from function Mesh connectivities d-0, d-1, ..., d-r are built on function mesh (where d is topological dimension of the mesh and r is maximal dimension of entity associated with any coordinate node). Consider clearing unneeded connectivities when finished.

Parameters:
solve

C++ documentation for solve from dolfin/fem/solve.h:

void dolfin::solve(const Equation &equation, Function &u, Parameters parameters = empty_parameters)

Solve linear variational problem a(u, v) == L(v) or nonlinear variational problem F(u; v) = 0 without boundary conditions. Optional parameters can be passed to the LinearVariationalSolver or NonlinearVariationalSolver classes.

Parameters:
  • equation
  • u
  • parameters

C++ documentation for solve from dolfin/fem/solve.h:

void dolfin::solve(const Equation &equation, Function &u, const DirichletBC &bc, Parameters parameters = empty_parameters)

Solve linear variational problem a(u, v) == L(v) or nonlinear variational problem F(u; v) = 0 with a single boundary condition. Optional parameters can be passed to the LinearVariationalSolver or NonlinearVariationalSolver classes.

Parameters:
  • equation
  • u
  • bc
  • parameters

C++ documentation for solve from dolfin/fem/solve.h:

void dolfin::solve(const Equation &equation, Function &u, const DirichletBC &bc, const Form &J, Parameters parameters = empty_parameters)

Solve nonlinear variational problem F(u; v) == 0 with a single boundary condition. The argument J should provide the Jacobian bilinear form J = dF/du. Optional parameters can be passed to the LinearVariationalSolver or NonlinearVariationalSolver classes.

Parameters:
  • equation
  • u
  • bc
  • J
  • parameters

C++ documentation for solve from dolfin/fem/solve.h:

void dolfin::solve(const Equation &equation, Function &u, const Form &J, Parameters parameters = empty_parameters)

Solve nonlinear variational problem F(u; v) == 0 without boundary conditions. The argument J should provide the Jacobian bilinear form J = dF/du. Optional parameters can be passed to the LinearVariationalSolver or NonlinearVariationalSolver classes.

Parameters:
  • equation
  • u
  • J
  • parameters

C++ documentation for solve from dolfin/fem/solve.h:

void dolfin::solve(const Equation &equation, Function &u, std::vector<const DirichletBC *> bcs, Parameters parameters = empty_parameters)

Solve linear variational problem a(u, v) == L(v) or nonlinear variational problem F(u; v) = 0 with a list of boundary conditions. Optional parameters can be passed to the LinearVariationalSolver or NonlinearVariationalSolver classes.

Parameters:
  • equation
  • u
  • bcs
  • parameters

C++ documentation for solve from dolfin/fem/solve.h:

void dolfin::solve(const Equation &equation, Function &u, std::vector<const DirichletBC *> bcs, const Form &J, Parameters parameters = empty_parameters)

Solve nonlinear variational problem F(u; v) == 0 with a list of boundary conditions. The argument J should provide the Jacobian bilinear form J = dF/du. Optional parameters can be passed to the LinearVariationalSolver or NonlinearVariationalSolver classes.

Parameters:
  • equation
  • u
  • bcs
  • J
  • parameters
vertex_to_dof_map

C++ documentation for vertex_to_dof_map from dolfin/fem/fem_utils.h:

std::vector<dolfin::la_index> dolfin::vertex_to_dof_map(const FunctionSpace &space)

Return a map between vertex indices and dof indices Only works for FunctionSpace with dofs exclusively on vertices. For mixed FunctionSpaces dof index is offset with the number of dofs per vertex.

Parameters:space – (FunctionSpace ) The FunctionSpace for what the vertex to dof map should be computed for
Returns:std::vector<dolfin::la_index> The vertex to dof map

Classes

Assembler

C++ documentation for Assembler from dolfin/fem/Assembler.h:

class dolfin::Assembler

This class provides automated assembly of linear systems, or more generally, assembly of a sparse tensor from a given variational form. Subdomains for cells and facets may be specified by assigning subdomain indicators specified by MeshFunction to the Form being assembled:

form.dx = cell_domains
form.ds = exterior_facet_domains
form.dS = interior_facet_domains
dolfin::Assembler::Assembler()

Constructor.

void dolfin::Assembler::assemble(GenericTensor &A, const Form &a)

Assemble tensor from given form

Parameters:
  • A – (GenericTensor ) The tensor to assemble. [direction=out]
  • a – (Form &) The form to assemble the tensor from. [direction=in]
void dolfin::Assembler::assemble_cells(GenericTensor &A, const Form &a, UFC &ufc, std::shared_ptr<const MeshFunction<std::size_t>> domains, std::vector<double> *values)

Assemble tensor from given form over cells. This function is provided for users who wish to build a customized assembler.

Parameters:
  • A – (GenericTensor &) The tensor to assemble. [direction=out]
  • a – (Form &) The form to assemble the tensor from. [direction=in]
  • ufc – (UFC &) [direction=in]
  • domains – (MeshFunction<std::size_t>) [direction=in]
  • values – (std::vector<double>*) [direction=in]
void dolfin::Assembler::assemble_exterior_facets(GenericTensor &A, const Form &a, UFC &ufc, std::shared_ptr<const MeshFunction<std::size_t>> domains, std::vector<double> *values)

Assemble tensor from given form over exterior facets. This function is provided for users who wish to build a customized assembler.

Parameters:
  • A – (GenericTensor ) The tensor to assemble. [direction=out]
  • a – (Form ) The form to assemble the tensor from. [direction=in]
  • ufc – (UFC ) [direction=in]
  • domains – (MeshFunction ) [direction=in]
  • values – (std::vector<double>*) [direction=in]
void dolfin::Assembler::assemble_interior_facets(GenericTensor &A, const Form &a, UFC &ufc, std::shared_ptr<const MeshFunction<std::size_t>> domains, std::shared_ptr<const MeshFunction<std::size_t>> cell_domains, std::vector<double> *values)

Assemble tensor from given form over interior facets. This function is provided for users who wish to build a customized assembler.

Parameters:
  • A – (GenericTensor ) The tensor to assemble. [direction=out]
  • a – (Form ) The form to assemble the tensor from. [direction=in]
  • ufc – (UFC ) [direction=in]
  • domains – (MeshFunction<std::size_t>) [direction=in]
  • cell_domains – (MeshFunction<std::size_t>) [direction=in]
  • values – (std::vector<double>*) [direction=in]
void dolfin::Assembler::assemble_vertices(GenericTensor &A, const Form &a, UFC &ufc, std::shared_ptr<const MeshFunction<std::size_t>> domains)

Assemble tensor from given form over vertices. This function is provided for users who wish to build a customized assembler.

Parameters:
  • A – (GenericTersn) The tensor to assemble. [direction=out]
  • a – (Form ) The form to assemble the tensor from. [direction=in]
  • ufc – (UFC ) [direction=in]
  • domains – (MeshFunction ) [direction=in]
AssemblerBase

C++ documentation for AssemblerBase from dolfin/fem/AssemblerBase.h:

class dolfin::AssemblerBase

Provide some common functions used in assembler classes.

dolfin::AssemblerBase::AssemblerBase()

Constructor.

bool dolfin::AssemblerBase::add_values

add_values (bool) Default value is false. This controls whether values are added to the given tensor or if it is zeroed prior to assembly.

void dolfin::AssemblerBase::check(const Form &a)

Check form.

Parameters:a
bool dolfin::AssemblerBase::finalize_tensor

finalize_tensor (bool) Default value is true. This controls whether the assembler finalizes the given tensor after assembly is completed by calling A.apply().

void dolfin::AssemblerBase::init_global_tensor(GenericTensor &A, const Form &a)

Initialize global tensor

Parameters:
bool dolfin::AssemblerBase::keep_diagonal

keep_diagonal (bool) Default value is false. This controls whether the assembler enures that a diagonal entry exists in an assembled matrix. It may be removed if the matrix is finalised.

std::string dolfin::AssemblerBase::progress_message(std::size_t rank, std::string integral_type)

Pretty-printing for progress bar.

Parameters:
  • rank
  • integral_type
BasisFunction

C++ documentation for BasisFunction from dolfin/fem/BasisFunction.h:

class dolfin::BasisFunction

Represention of a finite element basis function. It can be used for computation of basis function values and derivatives. Evaluation of basis functions is also possible through the use of the functions evaluate_basis and evaluate_basis_derivatives available in the FiniteElement class. The BasisFunction class relies on these functions for evaluation but also implements the ufc::function interface which allows evaluate_dof to be evaluated for a basis function (on a possibly different element).

dolfin::BasisFunction::BasisFunction(std::size_t index, std::shared_ptr<const FiniteElement> element, const std::vector<double> &coordinate_dofs)

Create basis function with given index on element on given cell

Parameters:
  • index – (std::size_t) The index of the basis function.
  • element – (FiniteElement ) The element to create basis function on.
  • coordinate_dofs – (std::vector<double>&) The coordinate dofs of the cell
void dolfin::BasisFunction::eval(double *values, const double *x) const

Evaluate basis function at given point

Parameters:
  • values – (double) The values of the function at the point.
  • x – (double) The coordinates of the point.
void dolfin::BasisFunction::eval_derivatives(double *values, const double *x, std::size_t n) const

Evaluate all order n derivatives at given point

Parameters:
  • values – (double) The values of derivatives at the point.
  • x – (double) The coordinates of the point.
  • n – (std::size_t) The order of derivation.
void dolfin::BasisFunction::evaluate(double *values, const double *coordinates, const ufc::cell &cell) const

Evaluate function at given point in cell

Parameters:
  • values – (double) The values of the function at the point..
  • coordinates – (double) The coordinates of the point.
  • cell – (ufc::cell ) The cell.
void dolfin::BasisFunction::update_index(std::size_t index)

Update the basis function index

Parameters:index – (std::size_t) The index of the basis function.
dolfin::BasisFunction::~BasisFunction()

Destructor.

DirichletBC

C++ documentation for DirichletBC from dolfin/fem/DirichletBC.h:

class dolfin::DirichletBC

Interface for setting (strong) Dirichlet boundary conditions. u = g on G, where u is the solution to be computed, g is a function and G is a sub domain of the mesh. A DirichletBC is specified by the function g, the function space (trial space) and boundary indicators on (a subset of) the mesh boundary. The boundary indicators may be specified in a number of different ways. The simplest approach is to specify the boundary by a SubDomain object, using the inside() function to specify on which facets the boundary conditions should be applied. The boundary facets will then be searched for and marked only on the first call to apply. This means that the mesh could be moved after the first apply and the boundary markers would still remain intact. Alternatively, the boundary may be specified by a MeshFunction over facets labeling all mesh facets together with a number that specifies which facets should be included in the boundary. The third option is to attach the boundary information to the mesh. This is handled automatically when exporting a mesh from for example VMTK. The ‘method’ variable may be used to specify the type of method used to identify degrees of freedom on the boundary. Available methods are: topological approach (default), geometric approach, and pointwise approach. The topological approach is faster, but will only identify degrees of freedom that are located on a facet that is entirely on the boundary. In particular, the topological approach will not identify degrees of freedom for discontinuous elements (which are all internal to the cell). A remedy for this is to use the geometric approach. In the geometric approach, each dof on each facet that matches the boundary condition will be checked. To apply pointwise boundary conditions e.g. pointloads, one will have to use the pointwise approach. The three possibilities are “topological”, “geometric” and “pointwise”. Note: when using “pointwise”, the boolean argument on_boundary in SubDomain::inside will always be false. The ‘check_midpoint’ variable can be used to decide whether or not the midpoint of each facet should be checked when a user-defined SubDomain is used to define the domain of the boundary condition. By default, midpoints are always checked. Note that this variable may be of importance close to corners, in which case it is sometimes important to check the midpoint to avoid including facets “on the diagonal close” to a corner. This variable is also of importance for curved boundaries (like on a sphere or cylinder), in which case it is important not to check the midpoint which will be located in the interior of a domain defined relative to a radius. Note that there may be caching employed in BC computation for performance reasons. In particular, applicable DOFs are cached by some methods on a first apply . This means that changing a supplied object (defining boundary subdomain) after first use may have no effect. But this is implementation and method specific.

dolfin::DirichletBC::DirichletBC(const DirichletBC &bc)

Copy constructor. Either cached DOF data are copied.

Parameters:bc – (DirichletBC() &) The object to be copied. [direction=in]
dolfin::DirichletBC::DirichletBC(std::shared_ptr<const FunctionSpace> V, std::shared_ptr<const GenericFunction> g, const std::vector<std::size_t> &markers, std::string method = "topological")

Create boundary condition for subdomain by boundary markers (cells, local facet numbers)

Parameters:
  • V – (FunctionSpace ) The function space. [direction=in]
  • g – (GenericFunction ) The value. [direction=in]
  • markers – (std::vector<std:size_t>&) Subdomain markers (facet index local to process) [direction=in]
  • method – (std::string) Optional argument: A string specifying the method to identify dofs. [direction=in]
dolfin::DirichletBC::DirichletBC(std::shared_ptr<const FunctionSpace> V, std::shared_ptr<const GenericFunction> g, std::shared_ptr<const MeshFunction<std::size_t>> sub_domains, std::size_t sub_domain, std::string method = "topological")

Create boundary condition for subdomain specified by index

Parameters:
  • V – (FunctionSpace ) The function space. [direction=in]
  • g – (GenericFunction ) The value. [direction=in]
  • sub_domains – (MeshFnunction<std::size_t>) Subdomain markers [direction=in]
  • sub_domain – (std::size_t) The subdomain index (number) [direction=in]
  • method – (std::string) Optional argument: A string specifying the method to identify dofs. [direction=in]
dolfin::DirichletBC::DirichletBC(std::shared_ptr<const FunctionSpace> V, std::shared_ptr<const GenericFunction> g, std::shared_ptr<const SubDomain> sub_domain, std::string method = "topological", bool check_midpoint = true)

Create boundary condition for subdomain

Parameters:
  • V – (FunctionSpace ) The function space [direction=in]
  • g – (GenericFunction ) The value [direction=in]
  • sub_domain – (SubDomain ) The subdomain [direction=in]
  • method – (std::string) Optional argument: A string specifying the method to identify dofs [direction=in]
  • check_midpoint – (bool) [direction=in]
dolfin::DirichletBC::DirichletBC(std::shared_ptr<const FunctionSpace> V, std::shared_ptr<const GenericFunction> g, std::size_t sub_domain, std::string method = "topological")

Create boundary condition for boundary data included in the mesh

Parameters:
  • V – (FunctionSpace ) The function space. [direction=in]
  • g – (GenericFunction ) The value. [direction=in]
  • sub_domain – (std::size_t) The subdomain index (number) [direction=in]
  • method – (std::string) Optional argument: A string specifying the method to identify dofs. [direction=in]
type dolfin::DirichletBC::Map

map type used by DirichletBC

void dolfin::DirichletBC::apply(GenericMatrix &A) const

Apply boundary condition to a matrix

Parameters:A – (GenericMatrix ) The matrix to apply boundary condition to. [direction=inout]
void dolfin::DirichletBC::apply(GenericMatrix &A, GenericVector &b) const

Apply boundary condition to a linear system

Parameters:
  • A – (GenericMatrix ) The matrix to apply boundary condition to. [direction=inout]
  • b – (GenericVector ) The vector to apply boundary condition to. [direction=inout]
void dolfin::DirichletBC::apply(GenericMatrix &A, GenericVector &b, const GenericVector &x) const

Apply boundary condition to a linear system for a nonlinear problem

Parameters:
  • A – (GenericMatrix ) The matrix to apply boundary conditions to. [direction=inout]
  • b – (GenericVector ) The vector to apply boundary conditions to. [direction=inout]
  • x – (GenericVector ) Another vector (nonlinear problem). [direction=in]
void dolfin::DirichletBC::apply(GenericMatrix *A, GenericVector *b, const GenericVector *x) const
Parameters:
  • A
  • b
  • x
void dolfin::DirichletBC::apply(GenericVector &b) const

Apply boundary condition to a vector

Parameters:b – (GenericVector ) The vector to apply boundary condition to. [direction=inout]
void dolfin::DirichletBC::apply(GenericVector &b, const GenericVector &x) const

Apply boundary condition to vectors for a nonlinear problem

Parameters:
  • b – (GenericVector ) The vector to apply boundary conditions to. [direction=inout]
  • x – (GenericVector ) Another vector (nonlinear problem). [direction=in]
void dolfin::DirichletBC::check() const
void dolfin::DirichletBC::check_arguments(GenericMatrix *A, GenericVector *b, const GenericVector *x, std::size_t dim) const
Parameters:
  • A
  • b
  • x
  • dim
void dolfin::DirichletBC::compute_bc(Map &boundary_values, LocalData &data, std::string method) const
Parameters:
  • boundary_values
  • data
  • method
void dolfin::DirichletBC::compute_bc_geometric(Map &boundary_values, LocalData &data) const
Parameters:
  • boundary_values
  • data
void dolfin::DirichletBC::compute_bc_pointwise(Map &boundary_values, LocalData &data) const
Parameters:
  • boundary_values
  • data
void dolfin::DirichletBC::compute_bc_topological(Map &boundary_values, LocalData &data) const
Parameters:
  • boundary_values
  • data
std::shared_ptr<const FunctionSpace> dolfin::DirichletBC::function_space() const

Return function space V

Returns:FunctionSpace The function space to which boundary conditions are applied.
void dolfin::DirichletBC::gather(Map &boundary_values) const

Get boundary values from neighbour processes. If a method other than “pointwise” is used, this is necessary to ensure all boundary dofs are marked on all processes.

Parameters:boundary_values – (Map&) Map from dof to boundary value. [direction=inout]
void dolfin::DirichletBC::get_boundary_values(Map &boundary_values) const

Get Dirichlet dofs and values. If a method other than ‘pointwise’ is used in parallel, the map may not be complete for local vertices since a vertex can have a bc applied, but the partition might not have a facet on the boundary. To ensure all local boundary dofs are marked, it is necessary to call gather() on the returned boundary values.

Parameters:boundary_values – (Map&) Map from dof to boundary value. [direction=inout]
void dolfin::DirichletBC::homogenize()

Set value to 0.0.

void dolfin::DirichletBC::init_facets(const MPI_Comm mpi_comm) const
Parameters:mpi_comm
void dolfin::DirichletBC::init_from_mesh(std::size_t sub_domain) const
Parameters:sub_domain
void dolfin::DirichletBC::init_from_mesh_function(const MeshFunction<std::size_t> &sub_domains, std::size_t sub_domain) const
Parameters:
  • sub_domains
  • sub_domain
void dolfin::DirichletBC::init_from_sub_domain(std::shared_ptr<const SubDomain> sub_domain) const
Parameters:sub_domain
const std::vector<std::size_t> &dolfin::DirichletBC::markers() const

Return boundary markers

Returns:std::vector<std::size_t>& Boundary markers (facets stored as pairs of cells and local facet numbers).
std::string dolfin::DirichletBC::method() const

Return method used for computing Dirichlet dofs

Returns:std::string Method used for computing Dirichlet dofs (“topological”, “geometric” or “pointwise”).
const std::set<std::string> dolfin::DirichletBC::methods
bool dolfin::DirichletBC::on_facet(const double *coordinates, const Facet &facet) const
Parameters:
  • coordinates
  • facet
const DirichletBC &dolfin::DirichletBC::operator=(const DirichletBC &bc)

Assignment operator. Either cached DOF data are assigned.

Parameters:bc – (DirichletBC ) Another DirichletBC object. [direction=in]
void dolfin::DirichletBC::set_value(std::shared_ptr<const GenericFunction> g)

Set value g for boundary condition, domain remains unchanged

Parameters:g – (GenericFucntion) The value. [direction=in]
std::shared_ptr<const SubDomain> dolfin::DirichletBC::user_sub_domain() const

Return shared pointer to subdomain

Returns:SubDomain Shared pointer to subdomain.
std::shared_ptr<const GenericFunction> dolfin::DirichletBC::value() const

Return boundary value g

Returns:GenericFunction The boundary values.
void dolfin::DirichletBC::zero(GenericMatrix &A) const

Make rows of matrix associated with boundary condition zero, useful for non-diagonal matrices in a block matrix.

Parameters:A – (GenericMatrix &) The matrix [direction=inout]
void dolfin::DirichletBC::zero_columns(GenericMatrix &A, GenericVector &b, double diag_val = 0) const

Make columns of matrix associated with boundary condition zero, and update a (right-hand side) vector to reflect the changes. Useful for non-diagonals.

Parameters:
  • A – (GenericMatrix &) The matrix [direction=inout]
  • b – (GenericVector &) The vector [direction=inout]
  • diag_val – (double) This parameter would normally be -1, 0 or 1. [direction=in]
dolfin::DirichletBC::~DirichletBC()

Destructor.

LocalData

C++ documentation for LocalData from dolfin/fem/DirichletBC.h:

class dolfin::DirichletBC::LocalData
dolfin::DirichletBC::LocalData::LocalData(const FunctionSpace &V)
Parameters:V
boost::multi_array<double, 2> dolfin::DirichletBC::LocalData::coordinates
std::vector<std::size_t> dolfin::DirichletBC::LocalData::facet_dofs
std::vector<double> dolfin::DirichletBC::LocalData::w
DiscreteOperators

C++ documentation for DiscreteOperators from dolfin/fem/DiscreteOperators.h:

class dolfin::DiscreteOperators

Discrete gradient operators providing derivatives of functions. This class computes discrete gradient operators (matrices) that map derivatives of finite element functions into other finite element spaces. An example of where discrete gradient operators are required is the creation of algebraic multigrid solvers for H(curl) and H(div) problems. NOTE: This class is highly experimental and likely to change. It will eventually be expanded to provide the discrete curl and divergence.

std::shared_ptr<GenericMatrix> dolfin::DiscreteOperators::build_gradient(const FunctionSpace &V0, const FunctionSpace &V1)

Build the discrete gradient operator A that takes a \(w \in H^1\) (P1, nodal Lagrange ) to \(v \in H(curl)\) (lowest order Nedelec), i.e. v = Aw. V0 is the H(curl) space, and V1 is the P1 Lagrange space.

Parameters:
Returns:

GenericMatrix

DofMap

C++ documentation for DofMap from dolfin/fem/DofMap.h:

class dolfin::DofMap : public dolfin::GenericDofMap

Degree-of-freedom map. This class handles the mapping of degrees of freedom. It builds a dof map based on a ufc::dofmap on a specific mesh. It will reorder the dofs when running in parallel. Sub-dofmaps, both views and copies, are supported.

Friends: DofMapBuilder, MultiMeshDofMap.

dolfin::DofMap::DofMap(const DofMap &dofmap)
Parameters:dofmap
dolfin::DofMap::DofMap(const DofMap &parent_dofmap, const std::vector<std::size_t> &component, const Mesh &mesh)
Parameters:
  • parent_dofmap
  • component
  • mesh
dolfin::DofMap::DofMap(std::shared_ptr<const ufc::dofmap> ufc_dofmap, const Mesh &mesh)

Create dof map on mesh (mesh is not stored)

Parameters:
dolfin::DofMap::DofMap(std::shared_ptr<const ufc::dofmap> ufc_dofmap, const Mesh &mesh, std::shared_ptr<const SubDomain> constrained_domain)

Create a periodic dof map on mesh (mesh is not stored)

Parameters:
  • ufc_dofmap – (ufc::dofmap ) The ufc::dofmap . [direction=in]
  • mesh – (Mesh ) The mesh. [direction=in]
  • constrained_domain – (SubDomain ) The subdomain marking the constrained (tied) boundaries. [direction=in]
dolfin::DofMap::DofMap(std::unordered_map<std::size_t, std::size_t> &collapsed_map, const DofMap &dofmap_view, const Mesh &mesh)
Parameters:
  • collapsed_map
  • dofmap_view
  • mesh
int dolfin::DofMap::block_size() const

Return the block size for dof maps with components, typically used for vector valued functions.

ArrayView<const dolfin::la_index> dolfin::DofMap::cell_dofs(std::size_t cell_index) const

Local-to-global mapping of dofs on a cell

Parameters:cell_index – (std::size_t) The cell index.
Returns:ArrayView<const dolfin::la_index> Local-to-global mapping of dofs.
void dolfin::DofMap::check_dimensional_consistency(const ufc::dofmap &dofmap, const Mesh &mesh)
Parameters:
  • dofmap
  • mesh
void dolfin::DofMap::check_provided_entities(const ufc::dofmap &dofmap, const Mesh &mesh)
Parameters:
  • dofmap
  • mesh
void dolfin::DofMap::clear_sub_map_data()

Clear any data required to build sub-dofmaps (this is to reduce memory use)

std::shared_ptr<GenericDofMap> dolfin::DofMap::collapse(std::unordered_map<std::size_t, std::size_t> &collapsed_map, const Mesh &mesh) const

Create a “collapsed” dofmap (collapses a sub-dofmap)

Parameters:
  • collapsed_map – (std::unordered_map<std::size_t, std::size_t>) The “collapsed” map.
  • mesh – (Mesh ) The mesh.
Returns:

DofMap The collapsed dofmap.

std::shared_ptr<GenericDofMap> dolfin::DofMap::copy() const

Create a copy of the dof map

Returns:DofMap The Dofmap copy.
std::shared_ptr<GenericDofMap> dolfin::DofMap::create(const Mesh &new_mesh) const

Create a copy of the dof map on a new mesh

Parameters:new_mesh – (Mesh ) The new mesh to create the dof map on.
Returns:DofMap The new Dofmap copy.
std::vector<dolfin::la_index> dolfin::DofMap::dofs() const

Return list of global dof indices on this process.

std::vector<dolfin::la_index> dolfin::DofMap::dofs(const Mesh &mesh, std::size_t dim) const

Return list of dof indices on this process that belong to mesh entities of dimension dim

Parameters:
  • mesh
  • dim
std::vector<dolfin::la_index> dolfin::DofMap::entity_closure_dofs(const Mesh &mesh, std::size_t entity_dim) const

Return the dof indices associated with the closure of all entities of given dimension

Parameters:
  • mesh – (Mesh ) Mesh
  • entity_dim – (std::size_t) Entity dimension.
Returns:

std::vector<dolfin::la_index> Dof indices associated with selected entities and their closure.

std::vector<dolfin::la_index> dolfin::DofMap::entity_closure_dofs(const Mesh &mesh, std::size_t entity_dim, const std::vector<std::size_t> &entity_indices) const

Return the dof indices associated with the closure of entities of given dimension and entity indices Arguments entity_dim (std::size_t) Entity dimension. entity_indices (std::vector<dolfin::la_index>&) Entity indices to get dofs for. Returns std::vector<dolfin::la_index> Dof indices associated with selected entities and their closure.

Parameters:
  • mesh
  • entity_dim
  • entity_indices
std::vector<dolfin::la_index> dolfin::DofMap::entity_dofs(const Mesh &mesh, std::size_t entity_dim) const

Return the dof indices associated with all entities of given dimension Arguments entity_dim (std::size_t) Entity dimension. Returns std::vector<dolfin::la_index> Dof indices associated with selected entities.

Parameters:
  • mesh
  • entity_dim
std::vector<dolfin::la_index> dolfin::DofMap::entity_dofs(const Mesh &mesh, std::size_t entity_dim, const std::vector<std::size_t> &entity_indices) const

Return the dof indices associated with entities of given dimension and entity indices Arguments entity_dim (std::size_t) Entity dimension. entity_indices (std::vector<dolfin::la_index>&) Entity indices to get dofs for. Returns std::vector<dolfin::la_index> Dof indices associated with selected entities.

Parameters:
  • mesh
  • entity_dim
  • entity_indices
std::shared_ptr<GenericDofMap> dolfin::DofMap::extract_sub_dofmap(const std::vector<std::size_t> &component, const Mesh &mesh) const

Extract subdofmap component

Parameters:
  • component – (std::vector<std::size_t>) The component.
  • mesh – (Mesh ) The mesh.
Returns:

DofMap The subdofmap component.

std::size_t dolfin::DofMap::global_dimension() const

Return the dimension of the global finite element function space Returns std::size_t The dimension of the global finite element function space.

std::shared_ptr<const IndexMap> dolfin::DofMap::index_map() const

Return the map (const access)

bool dolfin::DofMap::is_view() const

True iff dof map is a view into another map Returns bool True if the dof map is a sub-dof map (a view into another map).

std::size_t dolfin::DofMap::local_to_global_index(int local_index) const

Return global dof index for a given local (process) dof index

Parameters:local_index – (int) The local local index.
Returns:std::size_t The global dof index.
const std::vector<std::size_t> &dolfin::DofMap::local_to_global_unowned() const

Return indices of dofs which are owned by other processes.

std::size_t dolfin::DofMap::max_element_dofs() const

Return the maximum dimension of the local finite element function space

Returns:std::size_t Maximum dimension of the local finite element function space.
const std::set<int> &dolfin::DofMap::neighbours() const

Return set of processes that share dofs with this process

Returns:std::set<int> The set of processes
std::size_t dolfin::DofMap::num_element_dofs(std::size_t cell_index) const

Return the dimension of the local finite element function space on a cell

Parameters:cell_index – (std::size_t) Index of cell
Returns:std::size_t Dimension of the local finite element function space.
std::size_t dolfin::DofMap::num_entity_closure_dofs(std::size_t entity_dim) const

Return the number of dofs for the closure of an entity of given dimension Arguments entity_dim (std::size_t) Entity dimension Returns std::size_t Number of dofs associated with closure of an entity of given dimension

Parameters:entity_dim
std::size_t dolfin::DofMap::num_entity_dofs(std::size_t entity_dim) const

Return the number of dofs for a given entity dimension

Parameters:entity_dim – (std::size_t) Entity dimension
Returns:std::size_t Number of dofs associated with given entity dimension
std::size_t dolfin::DofMap::num_facet_dofs() const

Return number of facet dofs

Returns:std::size_t The number of facet dofs.
const std::vector<int> &dolfin::DofMap::off_process_owner() const

Return map from nonlocal dofs that appear in local dof map to owning process

Returns:std::vector<unsigned int> The map from non-local dofs.
std::pair<std::size_t, std::size_t> dolfin::DofMap::ownership_range() const

Return the ownership range (dofs in this range are owned by this process)

Returns:std::pair<std::size_t, std::size_t> The ownership range.
void dolfin::DofMap::set(GenericVector &x, double value) const

Set dof entries in vector to a specified value. Parallel layout of vector must be consistent with dof map range. This function is typically used to construct the null space of a matrix operator.

Parameters:
  • x – (GenericVector ) The vector to set.
  • value – (double) The value to set.
const std::unordered_map<int, std::vector<int>> &dolfin::DofMap::shared_nodes() const

Return map from all shared nodes to the sharing processes (not including the current process) that share it.

Returns:std::unordered_map<std::size_t, std::vector<unsigned int>> The map from dofs to list of processes
std::string dolfin::DofMap::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose – (bool) Flag to turn on additional output.
Returns:std::string An informal representation of the function space.
void dolfin::DofMap::tabulate_entity_closure_dofs(std::vector<std::size_t> &element_dofs, std::size_t entity_dim, std::size_t cell_entity_index) const

Tabulate local-local mapping of dofs on closure of entity (dim, local_entity)

Parameters:
  • element_dofs – (std::size_t) Degrees of freedom on a single element.
  • entity_dim – (std::size_t) The entity dimension.
  • cell_entity_index – (std::size_t) The local entity index on the cell.
void dolfin::DofMap::tabulate_entity_dofs(std::vector<std::size_t> &element_dofs, std::size_t entity_dim, std::size_t cell_entity_index) const

Tabulate local-local mapping of dofs on entity (dim, local_entity)

Parameters:
  • element_dofs – (std::size_t) Degrees of freedom on a single element.
  • entity_dim – (std::size_t) The entity dimension.
  • cell_entity_index – (std::size_t) The local entity index on the cell.
void dolfin::DofMap::tabulate_facet_dofs(std::vector<std::size_t> &element_dofs, std::size_t cell_facet_index) const

Tabulate local-local facet dofs

Parameters:
  • element_dofs – (std::size_t) Degrees of freedom on a single element.
  • cell_facet_index – (std::size_t) The local facet index on the cell.
void dolfin::DofMap::tabulate_global_dofs(std::vector<std::size_t> &element_dofs) const

Tabulate globally supported dofs

Parameters:element_dofs – (std::size_t) Degrees of freedom.
void dolfin::DofMap::tabulate_local_to_global_dofs(std::vector<std::size_t> &local_to_global_map) const

Compute the map from local (this process) dof indices to global dof indices.

Parameters:local_to_global_map – (std::vector<std::size_t>) The local-to-global map to fill.
dolfin::DofMap::~DofMap()

Destructor.

DofMapBuilder

C++ documentation for DofMapBuilder from dolfin/fem/DofMapBuilder.h:

class dolfin::DofMapBuilder

Builds a DofMap on a Mesh .

void dolfin::DofMapBuilder::build(DofMap &dofmap, const Mesh &dolfin_mesh, std::shared_ptr<const SubDomain> constrained_domain)

Build dofmap. The constrained domain may be a null pointer, in which case it is ignored.

Parameters:
  • dofmap – [direction=out]
  • dolfin_mesh – [direction=in]
  • constrained_domain – [direction=in]
std::size_t dolfin::DofMapBuilder::build_constrained_vertex_indices(const Mesh &mesh, const std::map<unsigned int, std::pair<unsigned int, unsigned int>> &slave_to_master_vertices, std::vector<std::int64_t> &modified_vertex_indices_global)
Parameters:
  • mesh
  • slave_to_master_vertices
  • modified_vertex_indices_global
void dolfin::DofMapBuilder::build_dofmap(std::vector<std::vector<la_index>> &dofmap, const std::vector<std::vector<la_index>> &node_dofmap, const std::vector<int> &old_to_new_node_local, const std::size_t block_size)
Parameters:
  • dofmap
  • node_dofmap
  • old_to_new_node_local
  • block_size
void dolfin::DofMapBuilder::build_local_ufc_dofmap(std::vector<std::vector<dolfin::la_index>> &dofmap, const ufc::dofmap &ufc_dofmap, const Mesh &mesh)
Parameters:
  • dofmap
  • ufc_dofmap
  • mesh
void dolfin::DofMapBuilder::build_sub_map_view(DofMap &sub_dofmap, const DofMap &parent_dofmap, const std::vector<std::size_t> &component, const Mesh &mesh)

Build sub-dofmap. This is a view into the parent dofmap.

Parameters:
  • sub_dofmap – [direction=out]
  • parent_dofmap – [direction=in]
  • component – [direction=in]
  • mesh – [direction=in]
std::shared_ptr<const ufc::dofmap> dolfin::DofMapBuilder::build_ufc_node_graph(std::vector<std::vector<la_index>> &node_dofmap, std::vector<std::size_t> &node_local_to_global, std::vector<std::size_t> &num_mesh_entities_global, std::shared_ptr<const ufc::dofmap> ufc_dofmap, const Mesh &mesh, std::shared_ptr<const SubDomain> constrained_domain, const std::size_t block_size)
Parameters:
  • node_dofmap
  • node_local_to_global
  • num_mesh_entities_global
  • ufc_dofmap
  • mesh
  • constrained_domain
  • block_size
std::shared_ptr<const ufc::dofmap> dolfin::DofMapBuilder::build_ufc_node_graph_constrained(std::vector<std::vector<la_index>> &node_dofmap, std::vector<std::size_t> &node_local_to_global, std::vector<int> &node_ufc_local_to_local, std::vector<std::size_t> &num_mesh_entities_global, std::shared_ptr<const ufc::dofmap> ufc_dofmap, const Mesh &mesh, std::shared_ptr<const SubDomain> constrained_domain, const std::size_t block_size)
Parameters:
  • node_dofmap
  • node_local_to_global
  • node_ufc_local_to_local
  • num_mesh_entities_global
  • ufc_dofmap
  • mesh
  • constrained_domain
  • block_size
std::size_t dolfin::DofMapBuilder::compute_blocksize(const ufc::dofmap &ufc_dofmap)
Parameters:ufc_dofmap
void dolfin::DofMapBuilder::compute_constrained_mesh_indices(std::vector<std::vector<std::int64_t>> &global_entity_indices, std::vector<std::size_t> &num_mesh_entities_global, const std::vector<bool> &needs_mesh_entities, const Mesh &mesh, const SubDomain &constrained_domain)
Parameters:
  • global_entity_indices
  • num_mesh_entities_global
  • needs_mesh_entities
  • mesh
  • constrained_domain
void dolfin::DofMapBuilder::compute_global_dofs(std::set<std::size_t> &global_dofs, std::size_t &offset_local, std::shared_ptr<const ufc::dofmap> ufc_dofmap, const std::vector<std::size_t> &num_mesh_entities_local)
Parameters:
  • global_dofs
  • offset_local
  • ufc_dofmap
  • num_mesh_entities_local
std::set<std::size_t> dolfin::DofMapBuilder::compute_global_dofs(std::shared_ptr<const ufc::dofmap> ufc_dofmap, const std::vector<std::size_t> &num_mesh_entities_local)
Parameters:
  • ufc_dofmap
  • num_mesh_entities_local
int dolfin::DofMapBuilder::compute_node_ownership(std::vector<short int> &node_ownership, std::unordered_map<int, std::vector<int>> &shared_node_to_processes, std::set<int> &neighbours, const std::vector<std::vector<la_index>> &node_dofmap, const std::vector<int> &boundary_nodes, const std::set<std::size_t> &global_nodes, const std::vector<std::size_t> &node_local_to_global, const Mesh &mesh, const std::size_t global_dim)
Parameters:
  • node_ownership
  • shared_node_to_processes
  • neighbours
  • node_dofmap
  • boundary_nodes
  • global_nodes
  • node_local_to_global
  • mesh
  • global_dim
void dolfin::DofMapBuilder::compute_node_reordering(IndexMap &index_map, std::vector<int> &old_to_new_local, const std::unordered_map<int, std::vector<int>> &node_to_sharing_processes, const std::vector<std::size_t> &old_local_to_global, const std::vector<std::vector<la_index>> &node_dofmap, const std::vector<short int> &node_ownership, const std::set<std::size_t> &global_nodes, const MPI_Comm mpi_comm)
Parameters:
  • index_map
  • old_to_new_local
  • node_to_sharing_processes
  • old_local_to_global
  • node_dofmap
  • node_ownership
  • global_nodes
  • mpi_comm
std::vector<std::size_t> dolfin::DofMapBuilder::compute_num_mesh_entities_local(const Mesh &mesh, const std::vector<bool> &needs_mesh_entities)
Parameters:
  • mesh
  • needs_mesh_entities
void dolfin::DofMapBuilder::compute_shared_nodes(std::vector<int> &boundary_nodes, const std::vector<std::vector<la_index>> &node_dofmap, const std::size_t num_nodes_local, const ufc::dofmap &ufc_dofmap, const Mesh &mesh)
Parameters:
  • boundary_nodes
  • node_dofmap
  • num_nodes_local
  • ufc_dofmap
  • mesh
std::shared_ptr<ufc::dofmap> dolfin::DofMapBuilder::extract_ufc_sub_dofmap(const ufc::dofmap &ufc_dofmap, std::size_t &offset, const std::vector<std::size_t> &component, const std::vector<std::size_t> &num_global_mesh_entities)
Parameters:
  • ufc_dofmap
  • offset
  • component
  • num_global_mesh_entities
void dolfin::DofMapBuilder::get_cell_entities_global(const Cell &cell, std::vector<std::vector<std::size_t>> &entity_indices, const std::vector<bool> &needs_mesh_entities)
Parameters:
  • cell
  • entity_indices
  • needs_mesh_entities
void dolfin::DofMapBuilder::get_cell_entities_global_constrained(const Cell &cell, std::vector<std::vector<std::size_t>> &entity_indices, const std::vector<std::vector<std::int64_t>> &global_entity_indices, const std::vector<bool> &needs_mesh_entities)
Parameters:
  • cell
  • entity_indices
  • global_entity_indices
  • needs_mesh_entities
void dolfin::DofMapBuilder::get_cell_entities_local(const Cell &cell, std::vector<std::vector<std::size_t>> &entity_indices, const std::vector<bool> &needs_mesh_entities)
Parameters:
  • cell
  • entity_indices
  • needs_mesh_entities
Equation

C++ documentation for Equation from dolfin/fem/Equation.h:

class dolfin::Equation

This class represents a variational equation lhs == rhs. The equation can be either linear or nonlinear:

  1. Linear (a == L), in which case a must be a bilinear form and L must be a linear form.
  2. Nonlinear (F == 0), in which case F must be a linear form.
dolfin::Equation::Equation(std::shared_ptr<const Form> F, int rhs)

Create equation F == 0

Parameters:
  • F – (Form ) [direction=in]
  • rhs – (int) [direction=in]
dolfin::Equation::Equation(std::shared_ptr<const Form> a, std::shared_ptr<const Form> L)

Create equation a == L

Parameters:
  • a – (Form ) Form representing the LHS [direction=in]
  • L – (Form ) Form representing the RHS [direction=in]
bool dolfin::Equation::is_linear() const

Check whether equation is linear

Returns:bool
std::shared_ptr<const Form> dolfin::Equation::lhs() const

Return form for left-hand side

Returns:Form LHS form
std::shared_ptr<const Form> dolfin::Equation::rhs() const

Return form for right-hand side

Returns:Form RHS form
int dolfin::Equation::rhs_int() const

Return value for right-hand side

Returns:int
dolfin::Equation::~Equation()

Destructor.

FiniteElement

C++ documentation for FiniteElement from dolfin/fem/FiniteElement.h:

class dolfin::FiniteElement

This is a wrapper for a UFC finite element (ufc::finite_element ).

dolfin::FiniteElement::FiniteElement(std::shared_ptr<const ufc::finite_element> element)

Create finite element from UFC finite element (data may be shared)

Parameters:element – (ufc::finite_element ) UFC finite element
ufc::shape dolfin::FiniteElement::cell_shape() const

Return the cell shape

Returns:ufc::shape
std::shared_ptr<const FiniteElement> dolfin::FiniteElement::create() const

Create a new class instance.

std::shared_ptr<const FiniteElement> dolfin::FiniteElement::create_sub_element(std::size_t i) const

Create a new finite element for sub element i (for a mixed element)

Parameters:i
void dolfin::FiniteElement::evaluate_basis(std::size_t i, double *values, const double *x, const double *coordinate_dofs, int cell_orientation) const

Evaluate basis function i at given point in cell.

Parameters:
  • i
  • values
  • x
  • coordinate_dofs
  • cell_orientation
void dolfin::FiniteElement::evaluate_basis_all(double *values, const double *x, const double *coordinate_dofs, int cell_orientation) const

Evaluate all basis functions at given point in cell.

Parameters:
  • values
  • x
  • coordinate_dofs
  • cell_orientation
void dolfin::FiniteElement::evaluate_basis_derivatives(unsigned int i, unsigned int n, double *values, const double *x, const double *coordinate_dofs, int cell_orientation) const

Evaluate order n derivatives of basis function i at given point in cell.

Parameters:
  • i
  • n
  • values
  • x
  • coordinate_dofs
  • cell_orientation
void dolfin::FiniteElement::evaluate_basis_derivatives_all(unsigned int n, double *values, const double *x, const double *coordinate_dofs, int cell_orientation) const

Evaluate order n derivatives of all basis functions at given point in cell

Parameters:
  • n
  • values
  • x
  • coordinate_dofs
  • cell_orientation
double dolfin::FiniteElement::evaluate_dof(std::size_t i, const ufc::function &function, const double *coordinate_dofs, int cell_orientation, const ufc::cell &c) const

Evaluate linear functional for dof i on the function f.

Parameters:
  • i
  • function
  • coordinate_dofs
  • cell_orientation
  • c
void dolfin::FiniteElement::evaluate_dofs(double *values, const ufc::function &f, const double *coordinate_dofs, int cell_orientation, const ufc::cell &c) const

Evaluate linear functionals for all dofs on the function f.

Parameters:
  • values
  • f
  • coordinate_dofs
  • cell_orientation
  • c
std::shared_ptr<const FiniteElement> dolfin::FiniteElement::extract_sub_element(const FiniteElement &finite_element, const std::vector<std::size_t> &component)
Parameters:
  • finite_element
  • component
std::shared_ptr<const FiniteElement> dolfin::FiniteElement::extract_sub_element(const std::vector<std::size_t> &component) const

Extract sub finite element for component.

Parameters:component
unsigned int dolfin::FiniteElement::geometric_dimension() const

Return the geometric dimension of the cell shape

Returns:unsigned int
std::size_t dolfin::FiniteElement::hash() const

Return simple hash of the signature string.

void dolfin::FiniteElement::interpolate_vertex_values(double *vertex_values, double *coefficients, const double *coordinate_dofs, int cell_orientation, const ufc::cell &cell) const

Interpolate vertex values from dof values

Parameters:
  • vertex_values – (double*)
  • coefficients – (double*)
  • coordinate_dofs – (const double*)
  • cell_orientation – (int)
  • cell – (ufc::cell &)
std::size_t dolfin::FiniteElement::num_sub_elements() const

Return the number of sub elements (for a mixed element)

Returns:std::size_t number of sub-elements
std::string dolfin::FiniteElement::signature() const

Return a string identifying the finite element

Returns:std::string
std::size_t dolfin::FiniteElement::space_dimension() const

Return the dimension of the finite element function space

Returns:std::size_t
void dolfin::FiniteElement::tabulate_dof_coordinates(boost::multi_array<double, 2> &coordinates, const std::vector<double> &coordinate_dofs, const Cell &cell) const

Tabulate the coordinates of all dofs on an element

Parameters:
  • coordinates – (boost::multi_array<double, 2>) The coordinates of all dofs on a cell. [direction=inout]
  • coordinate_dofs – (std::vector<double>) The cell coordinates [direction=in]
  • cell – (Cell ) The cell. [direction=in]
std::size_t dolfin::FiniteElement::topological_dimension() const

Return the topological dimension of the cell shape

Returns:std::size_t
std::shared_ptr<const ufc::finite_element> dolfin::FiniteElement::ufc_element() const

Return underlying UFC element. Intended for libray usage only and may change.

std::size_t dolfin::FiniteElement::value_dimension(std::size_t i) const

Return the dimension of the value space for axis i.

Parameters:i
std::size_t dolfin::FiniteElement::value_rank() const

Return the rank of the value space.

dolfin::FiniteElement::~FiniteElement()

Destructor.

Form

C++ documentation for Form from dolfin/fem/Form.h:

class dolfin::Form

Base class for UFC code generated by FFC for DOLFIN with option -l.

embed:rst:leading-slashes
/// A note on the order of trial and test spaces: FEniCS numbers
/// argument spaces starting with the leading dimension of the
/// corresponding tensor (matrix). In other words, the test space is
/// numbered 0 and the trial space is numbered 1. However, in order
/// to have a notation that agrees with most existing finite element
/// literature, in particular
///
///     a = a(u, v)
///
/// the spaces are numbered from right to
///
///     a: V_1 x V_0 -> R
///
/// .. note::
///
///     Figure out how to write this in math mode without it getting
///     messed up in the Python version.
///
/// This is reflected in the ordering of the spaces that should be
/// supplied to generated subclasses. In particular, when a bilinear
/// form is initialized, it should be initialized as
///
/// .. code-block:: c++
///
///     a(V_1, V_0) = ...
///
/// where ``V_1`` is the trial space and ``V_0`` is the test space.
/// However, when a form is initialized by a list of argument spaces
/// (the variable ``function_spaces`` in the constructors below, the
/// list of spaces should start with space number 0 (the test space)
/// and then space number 1 (the trial space).
///
dolfin::Form::Form(std::shared_ptr<const ufc::form> ufc_form, std::vector<std::shared_ptr<const FunctionSpace>> function_spaces)

Create form (shared data)

Parameters:
dolfin::Form::Form(std::size_t rank, std::size_t num_coefficients)

Create form of given rank with given number of coefficients

Parameters:
  • rank – (std::size_t) The rank. [direction=in]
  • num_coefficients – (std::size_t) The number of coefficients. [direction=in]
std::shared_ptr<const MeshFunction<std::size_t>> dolfin::Form::cell_domains() const

Return cell domains (zero pointer if no domains have been specified)

Returns:MeshFunction <std::size_t> The cell domains.
void dolfin::Form::check() const

Check function spaces and coefficients.

std::shared_ptr<const GenericFunction> dolfin::Form::coefficient(std::size_t i) const

Return coefficient with given number

Parameters:i – (std::size_t) Index [direction=in]
Returns:GenericFunction The coefficient.
std::shared_ptr<const GenericFunction> dolfin::Form::coefficient(std::string name) const

Return coefficient with given name

Parameters:name – (std::string) The name. [direction=in]
Returns:GenericFunction The coefficient.
std::string dolfin::Form::coefficient_name(std::size_t i) const

Return the name of the coefficient with this number

Parameters:i – (std::size_t) The number [direction=in]
Returns:std::string The name of the coefficient with the given number.
std::size_t dolfin::Form::coefficient_number(const std::string &name) const

Return the number of the coefficient with this name

Parameters:name – (std::string) The name. [direction=in]
Returns:std::size_t The number of the coefficient with the given name.
std::vector<std::shared_ptr<const GenericFunction>> dolfin::Form::coefficients() const

Return all coefficients

Returns:std::vector<GenericFunction > All coefficients.
std::vector<std::size_t> dolfin::Form::coloring(std::size_t entity_dim) const

Return coloring type for colored assembly of form over a mesh entity of a given dimension

Parameters:entity_dim – (std::size_t) Dimension. [direction=in]
Returns:std::vector<std::size_t> Coloring type.
std::shared_ptr<const MeshFunction<std::size_t>> dolfin::Form::dP

Domain markers for vertices.

std::shared_ptr<const MeshFunction<std::size_t>> dolfin::Form::dS

Domain markers for interior facets.

std::shared_ptr<const MeshFunction<std::size_t>> dolfin::Form::ds

Domain markers for exterior facets.

std::shared_ptr<const MeshFunction<std::size_t>> dolfin::Form::dx

Domain markers for cells.

std::shared_ptr<const MeshFunction<std::size_t>> dolfin::Form::exterior_facet_domains() const

Return exterior facet domains (zero pointer if no domains have been specified)

Returns:std::shared_ptr<MeshFunction <std::size_t>> The exterior facet domains.
std::shared_ptr<const FunctionSpace> dolfin::Form::function_space(std::size_t i) const

Return function space for given argument

Parameters:i – (std::size_t) Index
Returns:FunctionSpace Function space shared pointer.
std::vector<std::shared_ptr<const FunctionSpace>> dolfin::Form::function_spaces() const

Return function spaces for arguments

Returns:std::vector<FunctionSpace > Vector of function space shared pointers.
std::shared_ptr<const MeshFunction<std::size_t>> dolfin::Form::interior_facet_domains() const

Return interior facet domains (zero pointer if no domains have been specified)

Returns:MeshFunction <std::size_t> The interior facet domains.
std::shared_ptr<const Mesh> dolfin::Form::mesh() const

Extract common mesh from form

Returns:Mesh Shared pointer to the mesh.
std::size_t dolfin::Form::num_coefficients() const

Return number of coefficients

Returns:std::size_t The number of coefficients.
Equation dolfin::Form::operator==(const Form &rhs) const

Comparison operator, returning equation lhs == rhs.

Parameters:rhs
Equation dolfin::Form::operator==(int rhs) const

Comparison operator, returning equation lhs == 0.

Parameters:rhs
std::size_t dolfin::Form::original_coefficient_position(std::size_t i) const

Return original coefficient position for each coefficient (0 <= i < n)

Parameters:i
Returns:std::size_t The position of coefficient i in original ufl form coefficients.
std::size_t dolfin::Form::rank() const

Return rank of form (bilinear form = 2, linear form = 1, functional = 0, etc)

Returns:std::size_t The rank of the form.
void dolfin::Form::set_cell_domains(std::shared_ptr<const MeshFunction<std::size_t>> cell_domains)

Set cell domains

Parameters:cell_domains – (MeshFunction <std::size_t>) The cell domains. [direction=in]
void dolfin::Form::set_coefficient(std::size_t i, std::shared_ptr<const GenericFunction> coefficient)

Set coefficient with given number (shared pointer version)

Parameters:
  • i – (std::size_t) The given number. [direction=in]
  • coefficient – (GenericFunction ) The coefficient. [direction=in]
void dolfin::Form::set_coefficient(std::string name, std::shared_ptr<const GenericFunction> coefficient)

Set coefficient with given name (shared pointer version)

Parameters:
  • name – (std::string) The name. [direction=in]
  • coefficient – (GenericFunction ) The coefficient. [direction=in]
void dolfin::Form::set_coefficients(std::map<std::string, std::shared_ptr<const GenericFunction>> coefficients)

Set all coefficients in given map. All coefficients in the given map, which may contain only a subset of the coefficients of the form, will be set.

Parameters:coefficients – (std::map<std::string, GenericFunction >) The map of coefficients. [direction=in]
void dolfin::Form::set_exterior_facet_domains(std::shared_ptr<const MeshFunction<std::size_t>> exterior_facet_domains)

Set exterior facet domains

Parameters:exterior_facet_domains – (MeshFunction <std::size_t>) The exterior facet domains. [direction=in]
void dolfin::Form::set_interior_facet_domains(std::shared_ptr<const MeshFunction<std::size_t>> interior_facet_domains)

Set interior facet domains

Parameters:interior_facet_domains – (MeshFunction <std::size_t>) The interior facet domains. [direction=in]
void dolfin::Form::set_mesh(std::shared_ptr<const Mesh> mesh)

Set mesh, necessary for functionals when there are no function spaces

Parameters:mesh – (Mesh ) The mesh. [direction=in]
void dolfin::Form::set_some_coefficients(std::map<std::string, std::shared_ptr<const GenericFunction>> coefficients)

Set some coefficients in given map. Each coefficient in the given map will be set, if the name of the coefficient matches the name of a coefficient in the form. This is useful when reusing the same coefficient map for several forms, or when some part of the form has been outcommented (for testing) in the UFL file, which means that the coefficient and attaching it to the form does not need to be outcommented in a C++ program using code from the generated UFL file.

Parameters:coefficients – (std::map<std::string, GenericFunction >) The map of coefficients. [direction=in]
void dolfin::Form::set_vertex_domains(std::shared_ptr<const MeshFunction<std::size_t>> vertex_domains)

Set vertex domains

Parameters:vertex_domains – (MeshFunction <std::size_t>) The vertex domains. [direction=in]
std::shared_ptr<const ufc::form> dolfin::Form::ufc_form() const

Return UFC form shared pointer

Returns:ufc::form The UFC form.
std::shared_ptr<const MeshFunction<std::size_t>> dolfin::Form::vertex_domains() const

Return vertex domains (zero pointer if no domains have been specified)

Returns:MeshFunction <std::size_t> The vertex domains.
dolfin::Form::~Form()

Destructor.

GenericDofMap

C++ documentation for GenericDofMap from dolfin/fem/GenericDofMap.h:

class dolfin::GenericDofMap

This class provides a generic interface for dof maps.

dolfin::GenericDofMap::GenericDofMap()

Constructor.

int dolfin::GenericDofMap::block_size() const = 0

Get block size.

std::size_t dolfin::GenericDofMap::cell_dimension(std::size_t index) const

Return the dimension of the local finite element function space on a cell (deprecated API)

Parameters:index
ArrayView<const dolfin::la_index> dolfin::GenericDofMap::cell_dofs(std::size_t cell_index) const = 0

Local-to-global mapping of dofs on a cell.

Parameters:cell_index
void dolfin::GenericDofMap::clear_sub_map_data() = 0

Clear any data required to build sub-dofmaps (this is to reduce memory use)

std::shared_ptr<GenericDofMap> dolfin::GenericDofMap::collapse(std::unordered_map<std::size_t, std::size_t> &collapsed_map, const Mesh &mesh) const = 0

Create a “collapsed” a dofmap (collapses from a sub-dofmap view)

Parameters:
  • collapsed_map
  • mesh
std::shared_ptr<const SubDomain> dolfin::GenericDofMap::constrained_domain

Subdomain mapping constrained boundaries, e.g. periodic conditions

std::shared_ptr<GenericDofMap> dolfin::GenericDofMap::copy() const = 0

Create a copy of the dof map.

std::shared_ptr<GenericDofMap> dolfin::GenericDofMap::create(const Mesh &new_mesh) const = 0

Create a new dof map on new mesh.

Parameters:new_mesh
std::vector<dolfin::la_index> dolfin::GenericDofMap::dofs() const = 0

Return list of global dof indices on this process.

std::vector<dolfin::la_index> dolfin::GenericDofMap::dofs(const Mesh &mesh, std::size_t dim) const = 0

Return list of dof indices on this process that belong to mesh entities of dimension dim

Parameters:
  • mesh
  • dim
std::vector<dolfin::la_index> dolfin::GenericDofMap::entity_closure_dofs(const Mesh &mesh, std::size_t entity_dim) const = 0

Return the dof indices associated with the closure of all entities of given dimension

Parameters:
  • mesh
  • entity_dim
std::vector<dolfin::la_index> dolfin::GenericDofMap::entity_closure_dofs(const Mesh &mesh, std::size_t entity_dim, const std::vector<std::size_t> &entity_indices) const = 0

Return the dof indices associated with the closure of entities of given dimension and entity indices

Parameters:
  • mesh
  • entity_dim
  • entity_indices
std::vector<dolfin::la_index> dolfin::GenericDofMap::entity_dofs(const Mesh &mesh, std::size_t entity_dim) const = 0

Return the dof indices associated with all entities of given dimension.

Parameters:
  • mesh
  • entity_dim
std::vector<dolfin::la_index> dolfin::GenericDofMap::entity_dofs(const Mesh &mesh, std::size_t entity_dim, const std::vector<std::size_t> &entity_indices) const = 0

Return the dof indices associated with entities of given dimension and entity indices.

Parameters:
  • mesh
  • entity_dim
  • entity_indices
std::shared_ptr<GenericDofMap> dolfin::GenericDofMap::extract_sub_dofmap(const std::vector<std::size_t> &component, const Mesh &mesh) const = 0

Extract sub dofmap component.

Parameters:
  • component
  • mesh
std::size_t dolfin::GenericDofMap::global_dimension() const = 0

Return the dimension of the global finite element function space

std::shared_ptr<const IndexMap> dolfin::GenericDofMap::index_map() const = 0

Index map (const access)

bool dolfin::GenericDofMap::is_view() const = 0

True if dof map is a view into another map (is a sub-dofmap)

std::size_t dolfin::GenericDofMap::local_to_global_index(int local_index) const = 0

Return global dof index corresponding to a given local index.

Parameters:local_index
const std::vector<std::size_t> &dolfin::GenericDofMap::local_to_global_unowned() const = 0

Return the map from unowned local dofmap nodes to global dofmap nodes. Dofmap node is dof index modulo block size.

std::size_t dolfin::GenericDofMap::max_cell_dimension() const

Return the maximum dimension of the local finite element function space (deprecated API)

std::size_t dolfin::GenericDofMap::max_element_dofs() const = 0

Return the maximum dimension of the local finite element function space

const std::set<int> &dolfin::GenericDofMap::neighbours() const = 0

Return set of processes that share dofs with the this process.

std::size_t dolfin::GenericDofMap::num_element_dofs(std::size_t index) const = 0

Return the dimension of the local finite element function space on a cell

Parameters:index
std::size_t dolfin::GenericDofMap::num_entity_closure_dofs(std::size_t entity_dim) const = 0

Return the number of dofs for closure of entity of given dimension.

Parameters:entity_dim
std::size_t dolfin::GenericDofMap::num_entity_dofs(std::size_t entity_dim) const = 0

Return the number of dofs for a given entity dimension.

Parameters:entity_dim
std::size_t dolfin::GenericDofMap::num_facet_dofs() const = 0

Return number of facet dofs.

const std::vector<int> &dolfin::GenericDofMap::off_process_owner() const = 0

Return map from nonlocal-dofs (that appear in local dof map) to owning process

std::pair<std::size_t, std::size_t> dolfin::GenericDofMap::ownership_range() const = 0

Return the ownership range (dofs in this range are owned by this process)

void dolfin::GenericDofMap::set(GenericVector &x, double value) const = 0

Set dof entries in vector to a specified value. Parallel layout of vector must be consistent with dof map range. This function is typically used to construct the null space of a matrix operator

Parameters:
  • x
  • value
const std::unordered_map<int, std::vector<int>> &dolfin::GenericDofMap::shared_nodes() const = 0

Return map from shared nodes to the processes (not including the current process) that share it.

std::string dolfin::GenericDofMap::str(bool verbose) const = 0

Return informal string representation (pretty-print)

Parameters:verbose
void dolfin::GenericDofMap::tabulate_entity_closure_dofs(std::vector<std::size_t> &element_dofs, std::size_t entity_dim, std::size_t cell_entity_index) const = 0

Tabulate the local-to-local mapping of dofs on closure of entity (dim, local_entity)

Parameters:
  • element_dofs
  • entity_dim
  • cell_entity_index
void dolfin::GenericDofMap::tabulate_entity_dofs(std::vector<std::size_t> &element_dofs, std::size_t entity_dim, std::size_t cell_entity_index) const = 0

Tabulate the local-to-local mapping of dofs on entity (dim, local_entity)

Parameters:
  • element_dofs
  • entity_dim
  • cell_entity_index
void dolfin::GenericDofMap::tabulate_facet_dofs(std::vector<std::size_t> &element_dofs, std::size_t cell_facet_index) const = 0

Tabulate local-local facet dofs.

Parameters:
  • element_dofs
  • cell_facet_index
void dolfin::GenericDofMap::tabulate_global_dofs(std::vector<std::size_t> &dofs) const = 0

Tabulate globally supported dofs.

Parameters:dofs
void dolfin::GenericDofMap::tabulate_local_to_global_dofs(std::vector<std::size_t> &local_to_global_map) const = 0

Tabulate map between local (process) and global dof indices.

Parameters:local_to_global_map
LinearTimeDependentProblem

C++ documentation for LinearTimeDependentProblem from dolfin/fem/LinearTimeDependentProblem.h:

class dolfin::LinearTimeDependentProblem

This class represents a linear time-dependent variational problem: Find u in U = U_h (x) U_k such that

a(u, v) = L(v)  for all v in V = V_h (x) V_k,

where U is a tensor-product trial space and V is a tensor-product test space.

dolfin::LinearTimeDependentProblem::LinearTimeDependentProblem(std::shared_ptr<const TensorProductForm> a, std::shared_ptr<const TensorProductForm> L, std::shared_ptr<Function> u, std::vector<std::shared_ptr<const BoundaryCondition>> bcs)

Create linear variational problem with a list of boundary conditions (shared pointer version)

Parameters:
  • a
  • L
  • u
  • bcs
std::vector<std::shared_ptr<const BoundaryCondition>> dolfin::LinearTimeDependentProblem::bcs() const

Return boundary conditions.

std::shared_ptr<const TensorProductForm> dolfin::LinearTimeDependentProblem::bilinear_form() const

Return bilinear form.

void dolfin::LinearTimeDependentProblem::check_forms() const
std::shared_ptr<const TensorProductForm> dolfin::LinearTimeDependentProblem::linear_form() const

Return linear form.

std::shared_ptr<Function> dolfin::LinearTimeDependentProblem::solution()

Return solution variable.

std::shared_ptr<const Function> dolfin::LinearTimeDependentProblem::solution() const

Return solution variable (const version)

std::shared_ptr<const FunctionSpace> dolfin::LinearTimeDependentProblem::test_space() const

Return test space.

std::shared_ptr<const FunctionSpace> dolfin::LinearTimeDependentProblem::trial_space() const

Return trial space.

LinearVariationalProblem

C++ documentation for LinearVariationalProblem from dolfin/fem/LinearVariationalProblem.h:

class dolfin::LinearVariationalProblem

This class represents a linear variational problem: Find u in V such that

a(u, v) = L(v)  for all v in V^,

where V is the trial space and V^ is the test space.

dolfin::LinearVariationalProblem::LinearVariationalProblem(std::shared_ptr<const Form> a, std::shared_ptr<const Form> L, std::shared_ptr<Function> u, std::vector<std::shared_ptr<const DirichletBC>> bcs)

Create linear variational problem with a list of boundary conditions

Parameters:
  • a
  • L
  • u
  • bcs
std::vector<std::shared_ptr<const DirichletBC>> dolfin::LinearVariationalProblem::bcs() const

Return boundary conditions.

std::shared_ptr<const Form> dolfin::LinearVariationalProblem::bilinear_form() const

Return bilinear form.

void dolfin::LinearVariationalProblem::check_forms() const
std::shared_ptr<const Form> dolfin::LinearVariationalProblem::linear_form() const

Return linear form.

std::shared_ptr<Function> dolfin::LinearVariationalProblem::solution()

Return solution variable.

std::shared_ptr<const Function> dolfin::LinearVariationalProblem::solution() const

Return solution variable (const version)

std::shared_ptr<const FunctionSpace> dolfin::LinearVariationalProblem::test_space() const

Return test space.

std::shared_ptr<const FunctionSpace> dolfin::LinearVariationalProblem::trial_space() const

Return trial space.

LinearVariationalSolver

C++ documentation for LinearVariationalSolver from dolfin/fem/LinearVariationalSolver.h:

class dolfin::LinearVariationalSolver

This class implements a solver for linear variational problems.

dolfin::LinearVariationalSolver::LinearVariationalSolver(std::shared_ptr<LinearVariationalProblem> problem)

Create linear variational solver for given problem.

Parameters:problem
void dolfin::LinearVariationalSolver::solve()

Solve variational problem.

LocalAssembler

C++ documentation for LocalAssembler from dolfin/fem/LocalAssembler.h:

class dolfin::LocalAssembler

Assembly of local cell tensors. Used by the adaptivity and LocalSolver functionality in dolfin. The local assembly functionality provided here is also wrapped as a free function assemble_local(form_a, cell) in Python for easier usage. Use from the C++ interface defined below will be faster than the free function as fewer objects need to be created and destroyed.

void dolfin::LocalAssembler::assemble(Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> &A, UFC &ufc, const std::vector<double> &coordinate_dofs, ufc::cell &ufc_cell, const Cell &cell, const MeshFunction<std::size_t> *cell_domains, const MeshFunction<std::size_t> *exterior_facet_domains, const MeshFunction<std::size_t> *interior_facet_domains)

Assemble a local tensor on a cell. Internally calls assemble_cell() , assemble_exterior_facet() , assemble_interior_facet() .

Parameters:
  • A – The tensor to assemble.
  • ufc
  • coordinate_dofs
  • ufc_cell
  • cell
  • cell_domains
  • exterior_facet_domains
  • interior_facet_domains
void dolfin::LocalAssembler::assemble_cell(Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> &A, UFC &ufc, const std::vector<double> &coordinate_dofs, const ufc::cell &ufc_cell, const Cell &cell, const MeshFunction<std::size_t> *cell_domains)

Worker method called by assemble() to perform assembly of volume integrals (UFL measure dx).

Parameters:
  • A – The tensor to assemble.
  • ufc
  • coordinate_dofs
  • ufc_cell
  • cell
  • cell_domains
void dolfin::LocalAssembler::assemble_exterior_facet(Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> &A, UFC &ufc, const std::vector<double> &coordinate_dofs, const ufc::cell &ufc_cell, const Cell &cell, const Facet &facet, const std::size_t local_facet, const MeshFunction<std::size_t> *exterior_facet_domains)

Worker method called by assemble() for each of the cell’s external facets to perform assembly of external facet integrals (UFL measure ds).

Parameters:
  • A – The tensor to assemble.
  • ufc
  • coordinate_dofs
  • ufc_cell
  • cell
  • facet
  • local_facet
  • exterior_facet_domains
void dolfin::LocalAssembler::assemble_interior_facet(Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> &A, UFC &ufc, const std::vector<double> &coordinate_dofs, const ufc::cell &ufc_cell, const Cell &cell, const Facet &facet, const std::size_t local_facet, const MeshFunction<std::size_t> *interior_facet_domains, const MeshFunction<std::size_t> *cell_domains)

Worker method called by assemble() for each of the cell’s internal facets to perform assembly of internal facet integrals (UFL measure dS)

Parameters:
  • A – The tensor to assemble.
  • ufc
  • coordinate_dofs
  • ufc_cell
  • cell
  • facet
  • local_facet
  • interior_facet_domains
  • cell_domains
LocalSolver

C++ documentation for LocalSolver from dolfin/fem/LocalSolver.h:

class dolfin::LocalSolver

Solve problems cell-wise. This class solves problems cell-wise. It computes the local left-hand side A_local which must be square locally but not globally. The right-hand side b_local is either computed locally for one cell or globally for all cells depending on which of the solve_local_rhs or solve_global_rhs methods which are called. You can optionally assemble the right-hand side vector yourself and use the solve_local method. You must then provide the DofMap of the right-hand side. The local solver solves A_local x_local = b_local. The result x_local is copied into the global vector x of the provided Function u. You can optionally call the factorize method to pre-calculate the local left-hand side factorizations to speed up repeated applications of the LocalSolver with the same LHS. The solve_xxx methods will factorise the LHS A_local matrices each time if they are not cached by a previous call to factorize. You can chose upon initialization whether you want Cholesky or LU (default) factorisations. For forms with no coupling across cell edges, this function is identical to a global solve. For problems with coupling across cells it is not. This class can be used for post-processing solutions, e.g. computing stress fields for visualisation, far more cheaply that using global projections.

dolfin::LocalSolver::LocalSolver(std::shared_ptr<const Form> a, SolverType solver_type = SolverType::LU)

Constructor (shared pointer version)

Parameters:
  • a – (Form ) input LHS form
  • solver_type – (SolverType)
dolfin::LocalSolver::LocalSolver(std::shared_ptr<const Form> a, std::shared_ptr<const Form> L, SolverType solver_type = SolverType::LU)

Constructor (shared pointer version)

Parameters:
  • a – (Form ) input LHS form
  • L – (Form ) input RHS form
  • solver_type – (SolverType)
enum dolfin::LocalSolver::SolverType

SolverType.

enumerator dolfin::LocalSolver::SolverType::LU
enumerator dolfin::LocalSolver::SolverType::Cholesky
void dolfin::LocalSolver::clear_factorization()

Reset (clear) any stored factorizations.

void dolfin::LocalSolver::factorize()

Factorise the local LHS matrices for all cells and store in cache.

void dolfin::LocalSolver::solve_global_rhs(Function &u) const

Solve local (cell-wise) problems A_e x_e = b_e, where A_e is the cell matrix LHS and b_e is the global RHS vector b restricted to the cell, i.e. b_e may contain contributions from neighbouring cells. The solution is exact for the case in which there is no coupling between cell contributions to the global matrix A, e.g. the discontinuous Galerkin matrix. The result is copied into x.

Parameters:u – (Function &) Function
void dolfin::LocalSolver::solve_local(GenericVector &x, const GenericVector &b, const GenericDofMap &dofmap_b) const

Solve local problems for given RHS and corresponding dofmap for RHS

Parameters:
void dolfin::LocalSolver::solve_local_rhs(Function &u) const

Solve local (cell-wise) problems A_e x_e = b_e where A_e and b_e are the cell element tensors. Compared to solve_global_rhs this function calculates local RHS vectors for each cell and hence does not include contributions from neighbouring cells. This function is useful for computing (approximate) cell-wise projections, for example for post-processing. It much more efficient than computing global projections.

Parameters:u – (Function &) Function
MultiMeshAssembler

C++ documentation for MultiMeshAssembler from dolfin/fem/MultiMeshAssembler.h:

class dolfin::MultiMeshAssembler

This class implements functionality for finite element assembly over cut and composite finite element (MultiMesh ) function spaces.

dolfin::MultiMeshAssembler::MultiMeshAssembler()

Constructor.

void dolfin::MultiMeshAssembler::assemble(GenericTensor &A, const MultiMeshForm &a)

Assemble tensor from given form

Parameters:
  • A – (GenericTensor ) The tensor to assemble.
  • a – (Form ) The form to assemble the tensor from.
bool dolfin::MultiMeshAssembler::extend_cut_cell_integration

extend_cut_cell_integration (bool) Default value is false. This controls whether the integration over cut cells should extend to the part of cut cells covered by cells from higher ranked meshes - thus including both the cut cell part and the overlap part.

MultiMeshDirichletBC

C++ documentation for MultiMeshDirichletBC from dolfin/fem/MultiMeshDirichletBC.h:

class dolfin::MultiMeshDirichletBC

This class is used to set Dirichlet boundary conditions for multimesh function spaces.

dolfin::MultiMeshDirichletBC::MultiMeshDirichletBC(std::shared_ptr<const MultiMeshFunctionSpace> V, std::shared_ptr<const GenericFunction> g, std::shared_ptr<const MeshFunction<std::size_t>> sub_domains, std::size_t sub_domain, std::size_t part, std::string method = "topological")

Create boundary condition for subdomain specified by index

Parameters:
  • V – (FunctionSpace ) The function space.
  • g – (GenericFunction ) The value.
  • sub_domains – (MeshFunction <std::size_t>) Subdomain markers
  • sub_domain – (std::size_t) The subdomain index (number)
  • part – (std::size_t) The part on which to set boundary conditions
  • method – (std::string) Optional argument: A string specifying the method to identify dofs.
dolfin::MultiMeshDirichletBC::MultiMeshDirichletBC(std::shared_ptr<const MultiMeshFunctionSpace> V, std::shared_ptr<const GenericFunction> g, std::shared_ptr<const SubDomain> sub_domain, std::string method = "topological", bool check_midpoint = true, bool exclude_overlapped_boundaries = true)

Create boundary condition for subdomain

Parameters:
  • V – (MultiMeshFunctionSpace ) The function space
  • g – (GenericFunction ) The value
  • sub_domain – (SubDomain ) The subdomain
  • method – (std::string) Option passed to DirichletBC .
  • check_midpoint – (bool) Option passed to DirichletBC .
  • exclude_overlapped_boundaries – (bool) If true, then the variable on_boundary will be set to false for facets that are overlapped by another mesh (irrespective of the layering order of the meshes).
void dolfin::MultiMeshDirichletBC::apply(GenericMatrix &A) const

Apply boundary condition to a matrix

Parameters:A – (GenericMatrix ) The matrix to apply boundary condition to.
void dolfin::MultiMeshDirichletBC::apply(GenericMatrix &A, GenericVector &b) const

Apply boundary condition to a linear system

Parameters:
  • A – (GenericMatrix ) The matrix to apply boundary condition to.
  • b – (GenericVector ) The vector to apply boundary condition to.
void dolfin::MultiMeshDirichletBC::apply(GenericMatrix &A, GenericVector &b, const GenericVector &x) const

Apply boundary condition to a linear system for a nonlinear problem

Parameters:
void dolfin::MultiMeshDirichletBC::apply(GenericVector &b) const

Apply boundary condition to a vector

Parameters:b – (GenericVector ) The vector to apply boundary condition to.
void dolfin::MultiMeshDirichletBC::apply(GenericVector &b, const GenericVector &x) const

Apply boundary condition to vectors for a nonlinear problem

Parameters:
dolfin::MultiMeshDirichletBC::~MultiMeshDirichletBC()

Destructor.

MultiMeshSubDomain

C++ documentation for MultiMeshSubDomain from dolfin/fem/MultiMeshDirichletBC.h:

class dolfin::MultiMeshDirichletBC::MultiMeshSubDomain
dolfin::MultiMeshDirichletBC::MultiMeshSubDomain::MultiMeshSubDomain(std::shared_ptr<const SubDomain> sub_domain, std::shared_ptr<const MultiMesh> multimesh, bool exclude_overlapped_boundaries)
Parameters:
  • sub_domain
  • multimesh
  • exclude_overlapped_boundaries
bool dolfin::MultiMeshDirichletBC::MultiMeshSubDomain::inside(const Array<double> &x, bool on_boundary) const
Parameters:
  • x
  • on_boundary
void dolfin::MultiMeshDirichletBC::MultiMeshSubDomain::set_current_part(std::size_t current_part)
Parameters:current_part
dolfin::MultiMeshDirichletBC::MultiMeshSubDomain::~MultiMeshSubDomain()
MultiMeshDofMap

C++ documentation for MultiMeshDofMap from dolfin/fem/MultiMeshDofMap.h:

class dolfin::MultiMeshDofMap

This class handles the mapping of degrees of freedom for MultiMesh function spaces.

dolfin::MultiMeshDofMap::MultiMeshDofMap()

Constructor.

dolfin::MultiMeshDofMap::MultiMeshDofMap(const MultiMeshDofMap &dofmap)

Copy constructor.

Parameters:dofmap
void dolfin::MultiMeshDofMap::add(std::shared_ptr<const GenericDofMap> dofmap)

Add dofmap Arguments dofmap (GenericDofMap ) The dofmap.

Parameters:dofmap
void dolfin::MultiMeshDofMap::build(const MultiMeshFunctionSpace &function_space, const std::vector<dolfin::la_index> &offsets)

Build MultiMesh dofmap.

Parameters:
  • function_space
  • offsets
void dolfin::MultiMeshDofMap::clear()

Clear MultiMesh dofmap.

std::size_t dolfin::MultiMeshDofMap::global_dimension() const

Return the dimension of the global finite element function space

std::shared_ptr<IndexMap> dolfin::MultiMeshDofMap::index_map() const

Return the map.

std::size_t dolfin::MultiMeshDofMap::num_parts() const

Return the number dofmaps (parts) of the MultiMesh dofmap Returns std::size_t The number of dofmaps (parts) of the MultiMesh dofmap

const std::vector<int> &dolfin::MultiMeshDofMap::off_process_owner() const

Return map from nonlocal-dofs (that appear in local dof map) to owning process

std::pair<std::size_t, std::size_t> dolfin::MultiMeshDofMap::ownership_range() const

Return the ownership range (dofs in this range are owned by this process)

std::shared_ptr<const GenericDofMap> dolfin::MultiMeshDofMap::part(std::size_t i) const

Return dofmap (part) number i Returns:cpp:any:GenericDofMap Dofmap (part) number i

Parameters:i
std::string dolfin::MultiMeshDofMap::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
dolfin::MultiMeshDofMap::~MultiMeshDofMap()

Destructor.

MultiMeshForm

C++ documentation for MultiMeshForm from dolfin/fem/MultiMeshForm.h:

class dolfin::MultiMeshForm

This class represents a variational form on a cut and composite finite element function space (MultiMesh ) defined on one or more possibly intersecting meshes.

dolfin::MultiMeshForm::MultiMeshForm()
dolfin::MultiMeshForm::MultiMeshForm(std::shared_ptr<const MultiMesh> multimesh)

Create empty multimesh functional.

Parameters:multimesh
dolfin::MultiMeshForm::MultiMeshForm(std::shared_ptr<const MultiMeshFunctionSpace> function_space)

Create empty linear multimesh variational form.

Parameters:function_space
dolfin::MultiMeshForm::MultiMeshForm(std::shared_ptr<const MultiMeshFunctionSpace> function_space_0, std::shared_ptr<const MultiMeshFunctionSpace> function_space_1)

Create empty bilinear multimesh variational form.

Parameters:
  • function_space_0
  • function_space_1
void dolfin::MultiMeshForm::add(std::shared_ptr<const Form> form)

Add form (shared pointer version)

Parameters:form – (Form ) The form.
void dolfin::MultiMeshForm::build()

Build MultiMesh form.

void dolfin::MultiMeshForm::clear()

Clear MultiMesh form.

std::shared_ptr<const MultiMeshFunctionSpace> dolfin::MultiMeshForm::function_space(std::size_t i) const

Return function space for given argument

Parameters:i – (std::size_t) Index
Returns:MultiMeshFunctionSpace Function space shared pointer.
std::shared_ptr<const MultiMesh> dolfin::MultiMeshForm::multimesh() const

Extract common multimesh from form

Returns:MultiMesh The mesh.
std::size_t dolfin::MultiMeshForm::num_parts() const

Return the number of forms (parts) of the MultiMesh form

Returns:std::size_t The number of forms (parts) of the MultiMesh form.
std::shared_ptr<const Form> dolfin::MultiMeshForm::part(std::size_t i) const

Return form (part) number i

Parameters:i
Returns:Form Form (part) number i.
std::size_t dolfin::MultiMeshForm::rank() const

Return rank of form (bilinear form = 2, linear form = 1, functional = 0, etc)

Returns:std::size_t The rank of the form.
dolfin::MultiMeshForm::~MultiMeshForm()

Destructor.

NonlinearVariationalProblem

C++ documentation for NonlinearVariationalProblem from dolfin/fem/NonlinearVariationalProblem.h:

class dolfin::NonlinearVariationalProblem

This class represents a nonlinear variational problem: Find u in V such that

F(u; v) = 0  for all v in V^,

where V is the trial space and V^ is the test space.

dolfin::NonlinearVariationalProblem::NonlinearVariationalProblem(std::shared_ptr<const Form> F, std::shared_ptr<Function> u, std::vector<std::shared_ptr<const DirichletBC>> bcs, std::shared_ptr<const Form> J = nullptr)

Create nonlinear variational problem, shared pointer version. The Jacobian form is specified which allows the use of a nonlinear solver that relies on the Jacobian (using Newton’s method).

Parameters:
  • F
  • u
  • bcs
  • J
std::vector<std::shared_ptr<const DirichletBC>> dolfin::NonlinearVariationalProblem::bcs() const

Return boundary conditions.

void dolfin::NonlinearVariationalProblem::check_forms() const
bool dolfin::NonlinearVariationalProblem::has_jacobian() const

Check whether Jacobian has been defined.

bool dolfin::NonlinearVariationalProblem::has_lower_bound() const

Check whether lower bound has been defined.

bool dolfin::NonlinearVariationalProblem::has_upper_bound() const

Check whether upper bound have has defined.

std::shared_ptr<const Form> dolfin::NonlinearVariationalProblem::jacobian_form() const

Return Jacobian form.

std::shared_ptr<const GenericVector> dolfin::NonlinearVariationalProblem::lower_bound() const

Return lower bound.

std::shared_ptr<const Form> dolfin::NonlinearVariationalProblem::residual_form() const

Return residual form.

void dolfin::NonlinearVariationalProblem::set_bounds(const Function &lb_func, const Function &ub_func)

Set the bounds for bound constrained solver.

Parameters:
  • lb_func
  • ub_func
void dolfin::NonlinearVariationalProblem::set_bounds(std::shared_ptr<const GenericVector> lb, std::shared_ptr<const GenericVector> ub)

Set the bounds for bound constrained solver.

Parameters:
  • lb
  • ub
std::shared_ptr<Function> dolfin::NonlinearVariationalProblem::solution()

Return solution variable.

std::shared_ptr<const Function> dolfin::NonlinearVariationalProblem::solution() const

Return solution variable (const version)

std::shared_ptr<const FunctionSpace> dolfin::NonlinearVariationalProblem::test_space() const

Return test space.

std::shared_ptr<const FunctionSpace> dolfin::NonlinearVariationalProblem::trial_space() const

Return trial space.

std::shared_ptr<const GenericVector> dolfin::NonlinearVariationalProblem::upper_bound() const

Return upper bound.

NonlinearVariationalSolver

C++ documentation for NonlinearVariationalSolver from dolfin/fem/NonlinearVariationalSolver.h:

class dolfin::NonlinearVariationalSolver

This class implements a solver for nonlinear variational problems.

dolfin::NonlinearVariationalSolver::NonlinearVariationalSolver(std::shared_ptr<NonlinearVariationalProblem> problem)

Create nonlinear variational solver for given problem.

Parameters:problem
std::shared_ptr<NewtonSolver> dolfin::NonlinearVariationalSolver::newton_solver
std::shared_ptr<NonlinearDiscreteProblem> dolfin::NonlinearVariationalSolver::nonlinear_problem
std::shared_ptr<PETScSNESSolver> dolfin::NonlinearVariationalSolver::snes_solver
std::pair<std::size_t, bool> dolfin::NonlinearVariationalSolver::solve()

Solve variational problem Returns std::pair<std::size_t, bool> Pair of number of Newton iterations, and whether iteration converged)

NonlinearDiscreteProblem

C++ documentation for NonlinearDiscreteProblem from dolfin/fem/NonlinearVariationalSolver.h:

class dolfin::NonlinearVariationalSolver::NonlinearDiscreteProblem
void dolfin::NonlinearVariationalSolver::NonlinearDiscreteProblem::F(GenericVector &b, const GenericVector &x)
Parameters:
  • b
  • x
void dolfin::NonlinearVariationalSolver::NonlinearDiscreteProblem::J(GenericMatrix &A, const GenericVector &x)
Parameters:
  • A
  • x
dolfin::NonlinearVariationalSolver::NonlinearDiscreteProblem::NonlinearDiscreteProblem(std::shared_ptr<const NonlinearVariationalProblem> problem, std::shared_ptr<const NonlinearVariationalSolver> solver)
Parameters:
  • problem
  • solver
dolfin::NonlinearVariationalSolver::NonlinearDiscreteProblem::~NonlinearDiscreteProblem()
PETScDMCollection

C++ documentation for PETScDMCollection from dolfin/fem/PETScDMCollection.h:

class dolfin::PETScDMCollection

This class builds and stores of collection of PETSc DM objects from a hierarchy of FunctionSpaces objects. The DM objects are used to construct multigrid solvers via PETSc. Warning: This classs is highly experimental and will change

dolfin::PETScDMCollection::PETScDMCollection(std::vector<std::shared_ptr<const FunctionSpace>> function_spaces)

Construct PETScDMCollection() from a vector of FunctionSpaces. The vector of FunctionSpaces is stored from coarse to fine.

Parameters:function_spaces
void dolfin::PETScDMCollection::check_ref_count() const

These are test/debugging functions that will be removed.

PetscErrorCode dolfin::PETScDMCollection::coarsen(DM dmf, MPI_Comm comm, DM *dmc)
Parameters:
  • dmf
  • comm
  • dmc
PetscErrorCode dolfin::PETScDMCollection::create_global_vector(DM dm, Vec *vec)
Parameters:
  • dm
  • vec
PetscErrorCode dolfin::PETScDMCollection::create_interpolation(DM dmc, DM dmf, Mat *mat, Vec *vec)
Parameters:
  • dmc
  • dmf
  • mat
  • vec
std::shared_ptr<PETScMatrix> dolfin::PETScDMCollection::create_transfer_matrix(std::shared_ptr<const FunctionSpace> coarse_space, std::shared_ptr<const FunctionSpace> fine_space)

Create the interpolation matrix from the coarse to the fine space (prolongation matrix)

Parameters:
  • coarse_space
  • fine_space
void dolfin::PETScDMCollection::find_exterior_points(MPI_Comm mpi_comm, std::shared_ptr<const BoundingBoxTree> treec, int dim, int data_size, const std::vector<double> &send_points, const std::vector<int> &send_indices, std::vector<int> &indices, std::vector<std::size_t> &cell_ids, std::vector<double> &points)
Parameters:
  • mpi_comm
  • treec
  • dim
  • data_size
  • send_points
  • send_indices
  • indices
  • cell_ids
  • points
DM dolfin::PETScDMCollection::get_dm(int i)

Return the ith DM objects. The coarest DM has index 0. Use i=-1 to get the DM for the finest level, i=-2 for the DM for the second finest level, etc.

Parameters:i
PetscErrorCode dolfin::PETScDMCollection::refine(DM dmc, MPI_Comm comm, DM *dmf)
Parameters:
  • dmc
  • comm
  • dmf
void dolfin::PETScDMCollection::reset(int i)

Debugging use - to be removed.

Parameters:i
dolfin::PETScDMCollection::~PETScDMCollection()

Destructor.

PointSource

C++ documentation for PointSource from dolfin/fem/PointSource.h:

class dolfin::PointSource

This class provides an easy mechanism for adding a point quantities (Dirac delta function) to variational problems. The associated function space must be scalar in order for the inner product with the (scalar) Dirac delta function to be well defined. For each of the constructors, Points passed to PointSource will be copied. Note: the interface to this class will likely change.

dolfin::PointSource::PointSource(std::shared_ptr<const FunctionSpace> V, const Point &p, double magnitude = 1.0)

Create point source at given point of given magnitude.

Parameters:
  • V
  • p
  • magnitude
dolfin::PointSource::PointSource(std::shared_ptr<const FunctionSpace> V, const std::vector<std::pair<const Point *, double>> sources)

Create point sources at given points of given magnitudes.

Parameters:
  • V
  • sources
dolfin::PointSource::PointSource(std::shared_ptr<const FunctionSpace> V0, std::shared_ptr<const FunctionSpace> V1, const Point &p, double magnitude = 1.0)

Create point source at given point of given magnitude.

Parameters:
  • V0
  • V1
  • p
  • magnitude
dolfin::PointSource::PointSource(std::shared_ptr<const FunctionSpace> V0, std::shared_ptr<const FunctionSpace> V1, const std::vector<std::pair<const Point *, double>> sources)

Create point sources at given points of given magnitudes.

Parameters:
  • V0
  • V1
  • sources
void dolfin::PointSource::apply(GenericMatrix &A)

Apply (add) point source to matrix.

Parameters:A
void dolfin::PointSource::apply(GenericVector &b)

Apply (add) point source to right-hand side vector.

Parameters:b
void dolfin::PointSource::check_space_supported(const FunctionSpace &V)
Parameters:V
void dolfin::PointSource::distribute_sources(const Mesh &mesh, const std::vector<std::pair<Point, double>> &sources)
Parameters:
  • mesh
  • sources
dolfin::PointSource::~PointSource()

Destructor.

SparsityPatternBuilder

C++ documentation for SparsityPatternBuilder from dolfin/fem/SparsityPatternBuilder.h:

class dolfin::SparsityPatternBuilder

This class provides functions to compute the sparsity pattern based on DOF maps

void dolfin::SparsityPatternBuilder::build(SparsityPattern &sparsity_pattern, const Mesh &mesh, const std::vector<const GenericDofMap *> dofmaps, bool cells, bool interior_facets, bool exterior_facets, bool vertices, bool diagonal, bool init = true, bool finalize = true)

Build sparsity pattern for assembly of given form.

Parameters:
  • sparsity_pattern
  • mesh
  • dofmaps
  • cells
  • interior_facets
  • exterior_facets
  • vertices
  • diagonal
  • init
  • finalize
void dolfin::SparsityPatternBuilder::build_multimesh_sparsity_pattern(SparsityPattern &sparsity_pattern, const MultiMeshForm &form)

Build sparsity pattern for assembly of given multimesh form.

Parameters:
  • sparsity_pattern
  • form
SystemAssembler

C++ documentation for SystemAssembler from dolfin/fem/SystemAssembler.h:

class dolfin::SystemAssembler

This class provides an assembler for systems of the form Ax = b. It differs from the default DOLFIN assembler in that it applies boundary conditions at the time of assembly, which preserves any symmetries in A.

dolfin::SystemAssembler::SystemAssembler(std::shared_ptr<const Form> a, std::shared_ptr<const Form> L, std::vector<std::shared_ptr<const DirichletBC>> bcs)

Constructor.

Parameters:
  • a
  • L
  • bcs
void dolfin::SystemAssembler::apply_bc(double *A, double *b, const std::vector<DirichletBC::Map> &boundary_values, const ArrayView<const dolfin::la_index> &global_dofs0, const ArrayView<const dolfin::la_index> &global_dofs1)
Parameters:
  • A
  • b
  • boundary_values
  • global_dofs0
  • global_dofs1
void dolfin::SystemAssembler::assemble(GenericMatrix &A)

Assemble matrix A.

Parameters:A
void dolfin::SystemAssembler::assemble(GenericMatrix &A, GenericVector &b)

Assemble system (A, b)

Parameters:
  • A
  • b
void dolfin::SystemAssembler::assemble(GenericMatrix &A, GenericVector &b, const GenericVector &x0)

Assemble system (A, b) for (negative) increment dx, where x = x0 - dx is solution to system a == -L subject to bcs. Suitable for use inside a (quasi-)Newton solver.

Parameters:
  • A
  • b
  • x0
void dolfin::SystemAssembler::assemble(GenericMatrix *A, GenericVector *b, const GenericVector *x0)
Parameters:
  • A
  • b
  • x0
void dolfin::SystemAssembler::assemble(GenericVector &b)

Assemble vector b.

Parameters:b
void dolfin::SystemAssembler::assemble(GenericVector &b, const GenericVector &x0)

Assemble rhs vector b for (negative) increment dx, where x = x0 - dx is solution to system a == -L subject to bcs. Suitable for use inside a (quasi-)Newton solver.

Parameters:
  • b
  • x0
bool dolfin::SystemAssembler::cell_matrix_required(const GenericTensor *A, const void *integral, const std::vector<DirichletBC::Map> &boundary_values, const ArrayView<const dolfin::la_index> &dofs)
Parameters:
  • A
  • integral
  • boundary_values
  • dofs
void dolfin::SystemAssembler::cell_wise_assembly(std::array<GenericTensor *, 2> &tensors, std::array<UFC *, 2> &ufc, Scratch &data, const std::vector<DirichletBC::Map> &boundary_values, std::shared_ptr<const MeshFunction<std::size_t>> cell_domains, std::shared_ptr<const MeshFunction<std::size_t>> exterior_facet_domains)
Parameters:
  • tensors
  • ufc
  • data
  • boundary_values
  • cell_domains
  • exterior_facet_domains
void dolfin::SystemAssembler::check_arity(std::shared_ptr<const Form> a, std::shared_ptr<const Form> L)
Parameters:
  • a
  • L
bool dolfin::SystemAssembler::check_functionspace_for_bc(std::shared_ptr<const FunctionSpace> fs, std::size_t bc_index)
Parameters:
  • fs
  • bc_index
void dolfin::SystemAssembler::compute_exterior_facet_tensor(std::array<std::vector<double>, 2> &Ae, std::array<UFC *, 2> &ufc, ufc::cell &ufc_cell, std::vector<double> &coordinate_dofs, const std::array<bool, 2> &tensor_required_cell, const std::array<bool, 2> &tensor_required_facet, const Cell &cell, const Facet &facet, const std::array<const ufc::cell_integral *, 2> &cell_integrals, const std::array<const ufc::exterior_facet_integral *, 2> &exterior_facet_integrals, const bool compute_cell_tensor)
Parameters:
  • Ae
  • ufc
  • ufc_cell
  • coordinate_dofs
  • tensor_required_cell
  • tensor_required_facet
  • cell
  • facet
  • cell_integrals
  • exterior_facet_integrals
  • compute_cell_tensor
void dolfin::SystemAssembler::compute_interior_facet_tensor(std::array<UFC *, 2> &ufc, std::array<ufc::cell, 2> &ufc_cell, std::array<std::vector<double>, 2> &coordinate_dofs, const std::array<bool, 2> &tensor_required_cell, const std::array<bool, 2> &tensor_required_facet, const std::array<Cell, 2> &cell, const std::array<std::size_t, 2> &local_facet, const bool facet_owner, const std::array<const ufc::cell_integral *, 2> &cell_integrals, const std::array<const ufc::interior_facet_integral *, 2> &interior_facet_integrals, const std::array<std::size_t, 2> &matrix_size, const std::size_t vector_size, const std::array<bool, 2> compute_cell_tensor)
Parameters:
  • ufc
  • ufc_cell
  • coordinate_dofs
  • tensor_required_cell
  • tensor_required_facet
  • cell
  • local_facet
  • facet_owner
  • cell_integrals
  • interior_facet_integrals
  • matrix_size
  • vector_size
  • compute_cell_tensor
void dolfin::SystemAssembler::facet_wise_assembly(std::array<GenericTensor *, 2> &tensors, std::array<UFC *, 2> &ufc, Scratch &data, const std::vector<DirichletBC::Map> &boundary_values, std::shared_ptr<const MeshFunction<std::size_t>> cell_domains, std::shared_ptr<const MeshFunction<std::size_t>> exterior_facet_domains, std::shared_ptr<const MeshFunction<std::size_t>> interior_facet_domains)
Parameters:
  • tensors
  • ufc
  • data
  • boundary_values
  • cell_domains
  • exterior_facet_domains
  • interior_facet_domains
bool dolfin::SystemAssembler::has_bc(const DirichletBC::Map &boundary_values, const ArrayView<const dolfin::la_index> &dofs)
Parameters:
  • boundary_values
  • dofs
void dolfin::SystemAssembler::matrix_block_add(GenericTensor &tensor, std::vector<double> &Ae, std::vector<double> &macro_A, const std::array<bool, 2> &add_local_tensor, const std::array<std::vector<ArrayView<const la_index>>, 2> &cell_dofs)
Parameters:
  • tensor
  • Ae
  • macro_A
  • add_local_tensor
  • cell_dofs
Scratch

C++ documentation for Scratch from dolfin/fem/SystemAssembler.h:

class dolfin::SystemAssembler::Scratch
std::array<std::vector<double>, 2> dolfin::SystemAssembler::Scratch::Ae
dolfin::SystemAssembler::Scratch::Scratch(const Form &a, const Form &L)
Parameters:
  • a
  • L
dolfin::SystemAssembler::Scratch::~Scratch()
UFC

C++ documentation for UFC from dolfin/fem/UFC.h:

class dolfin::UFC : public dolfin::Form

This class is a simple data structure that holds data used during assembly of a given UFC form. Data is created for each primary argument, that is, v_j for j < r. In addition, nodal basis expansion coefficients and a finite element are created for each coefficient function.

std::vector<double> dolfin::UFC::A

Local tensor.

std::vector<double> dolfin::UFC::A_facet

Local tensor.

dolfin::UFC::UFC(const Form &form)

Constructor.

Parameters:form
dolfin::UFC::UFC(const UFC &ufc)

Copy constructor.

Parameters:ufc
std::vector<std::shared_ptr<ufc::cell_integral>> dolfin::UFC::cell_integrals
std::vector<FiniteElement> dolfin::UFC::coefficient_elements
const std::vector<std::shared_ptr<const GenericFunction>> dolfin::UFC::coefficients
std::vector<std::shared_ptr<ufc::custom_integral>> dolfin::UFC::custom_integrals
std::vector<std::shared_ptr<ufc::cutcell_integral>> dolfin::UFC::cutcell_integrals
const Form &dolfin::UFC::dolfin_form

The form.

std::vector<std::shared_ptr<ufc::exterior_facet_integral>> dolfin::UFC::exterior_facet_integrals
const ufc::form &dolfin::UFC::form

Form .

ufc::cell_integral *dolfin::UFC::get_cell_integral(std::size_t domain)

Get cell integral over a given domain, falling back to the default if necessary

Parameters:domain
ufc::custom_integral *dolfin::UFC::get_custom_integral(std::size_t domain)

Get custom integral over a given domain, falling back to the default if necessary

Parameters:domain
ufc::cutcell_integral *dolfin::UFC::get_cutcell_integral(std::size_t domain)

Get cutcell integral over a given domain, falling back to the default if necessary

Parameters:domain
ufc::exterior_facet_integral *dolfin::UFC::get_exterior_facet_integral(std::size_t domain)

Get exterior facet integral over a given domain, falling back to the default if necessary

Parameters:domain
ufc::interface_integral *dolfin::UFC::get_interface_integral(std::size_t domain)

Get interface integral over a given domain, falling back to the default if necessary

Parameters:domain
ufc::interior_facet_integral *dolfin::UFC::get_interior_facet_integral(std::size_t domain)

Get interior facet integral over a given domain, falling back to the default if necessary

Parameters:domain
ufc::overlap_integral *dolfin::UFC::get_overlap_integral(std::size_t domain)

Get overlap integral over a given domain, falling back to the default if necessary

Parameters:domain
ufc::vertex_integral *dolfin::UFC::get_vertex_integral(std::size_t domain)

Get point integral over a given domain, falling back to the default if necessary

Parameters:domain
void dolfin::UFC::init(const Form &form)

Initialise memory.

Parameters:form
std::vector<std::shared_ptr<ufc::interface_integral>> dolfin::UFC::interface_integrals
std::vector<std::shared_ptr<ufc::interior_facet_integral>> dolfin::UFC::interior_facet_integrals
std::vector<double> dolfin::UFC::macro_A

Local tensor for macro element.

const double *const *dolfin::UFC::macro_w() const

Pointer to macro element coefficient data. Used to support UFC interface.

std::vector<double *> dolfin::UFC::macro_w_pointer
std::vector<std::shared_ptr<ufc::overlap_integral>> dolfin::UFC::overlap_integrals
void dolfin::UFC::update(const Cell &cell, const std::vector<double> &coordinate_dofs0, const ufc::cell &ufc_cell)

Update current cell (TODO: Remove this when PointIntegralSolver supports the version with enabled_coefficients)

Parameters:
  • cell
  • coordinate_dofs0
  • ufc_cell
void dolfin::UFC::update(const Cell &cell, const std::vector<double> &coordinate_dofs0, const ufc::cell &ufc_cell, const std::vector<bool> &enabled_coefficients)

Update current cell.

Parameters:
  • cell
  • coordinate_dofs0
  • ufc_cell
  • enabled_coefficients
void dolfin::UFC::update(const Cell &cell0, const std::vector<double> &coordinate_dofs0, const ufc::cell &ufc_cell0, const Cell &cell1, const std::vector<double> &coordinate_dofs1, const ufc::cell &ufc_cell1)

Update current pair of cells for macro element (TODO: Remove this when PointIntegralSolver supports the version with enabled_coefficients)

Parameters:
  • cell0
  • coordinate_dofs0
  • ufc_cell0
  • cell1
  • coordinate_dofs1
  • ufc_cell1
void dolfin::UFC::update(const Cell &cell0, const std::vector<double> &coordinate_dofs0, const ufc::cell &ufc_cell0, const Cell &cell1, const std::vector<double> &coordinate_dofs1, const ufc::cell &ufc_cell1, const std::vector<bool> &enabled_coefficients)

Update current pair of cells for macro element.

Parameters:
  • cell0
  • coordinate_dofs0
  • ufc_cell0
  • cell1
  • coordinate_dofs1
  • ufc_cell1
  • enabled_coefficients
std::vector<std::shared_ptr<ufc::vertex_integral>> dolfin::UFC::vertex_integrals
double **dolfin::UFC::w()

Pointer to coefficient data. Used to support UFC interface. None const version

const double *const *dolfin::UFC::w() const

Pointer to coefficient data. Used to support UFC interface.

std::vector<double *> dolfin::UFC::w_pointer
dolfin::UFC::~UFC()

Destructor.

dolfin/function

Documentation for C++ code found in dolfin/function/*.h

Functions

assign

C++ documentation for assign from dolfin/function/assign.h:

void dolfin::assign(std::shared_ptr<Function> receiving_func, std::shared_ptr<const Function> assigning_func)

Assign one function to another. The functions must reside in the same type of FunctionSpace . One or both functions can be sub functions.

Parameters:
  • receiving_func – (std::shared_ptr<Function >) The receiving function
  • assigning_func – (std::shared_ptr<Function >) The assigning function

C++ documentation for assign from dolfin/function/assign.h:

void dolfin::assign(std::shared_ptr<Function> receiving_func, std::vector<std::shared_ptr<const Function>> assigning_funcs)

Assign several functions to sub functions of a mixed receiving function. The number of receiving functions must sum up to the number of sub functions in the assigning mixed function. The sub spaces of the assigning mixed space must be of the same type ans size as the receiving spaces.

Parameters:
  • receiving_func – (std::shared_ptr<Function >) The receiving function
  • assigning_funcs – (std::vector<std::shared_ptr<Function >>) The assigning functions

C++ documentation for assign from dolfin/function/assign.h:

void dolfin::assign(std::vector<std::shared_ptr<Function>> receiving_funcs, std::shared_ptr<const Function> assigning_func)

Assign sub functions of a single mixed function to single receiving functions. The number of sub functions in the assigning mixed function must sum up to the number of receiving functions. The sub spaces of the receiving mixed space must be of the same type ans size as the assigning spaces.

Parameters:
  • receiving_funcs – (std::vector<std::shared_ptr<Function >>) The receiving functions
  • assigning_func – (std::shared_ptr<Function >) The assigning function

Classes

CoefficientAssigner

C++ documentation for CoefficientAssigner from dolfin/function/CoefficientAssigner.h:

class dolfin::CoefficientAssigner

This class is used for assignment of coefficients to forms, which allows magic like a.f = f a.g = g which will insert the coefficients f and g in the correct positions in the list of coefficients for the form.

dolfin::CoefficientAssigner::CoefficientAssigner(Form &form, std::size_t number)

Create coefficient assigner for coefficient with given number.

Parameters:
  • form
  • number
void dolfin::CoefficientAssigner::operator=(std::shared_ptr<const GenericFunction> coefficient)

Assign coefficient.

Parameters:coefficient
dolfin::CoefficientAssigner::~CoefficientAssigner()

Destructor.

Constant

C++ documentation for Constant from dolfin/function/Constant.h:

class dolfin::Constant : public dolfin::Expression

This class represents a constant-valued expression.

dolfin::Constant::Constant(const Constant &constant)

Copy constructor

Parameters:constant – (Constant() ) Object to be copied.
dolfin::Constant::Constant(double value)

Create scalar constant

Constant c(1.0);
Parameters:value – (double) The scalar to create a Constant() object from.
dolfin::Constant::Constant(double value0, double value1)

Create vector constant (dim = 2)

Constant B(0.0, 1.0);
Parameters:
  • value0 – (double) The first vector element.
  • value1 – (double) The second vector element.
dolfin::Constant::Constant(double value0, double value1, double value2)

Create vector constant (dim = 3)

Constant T(0.0, 1.0, 0.0);
Parameters:
  • value0 – (double) The first vector element.
  • value1 – (double) The second vector element.
  • value2 – (double) The third vector element.
dolfin::Constant::Constant(std::vector<double> values)

Create vector-valued constant

Parameters:values – (std::vector<double>) Values to create a vector-valued constant from.
dolfin::Constant::Constant(std::vector<std::size_t> value_shape, std::vector<double> values)

Create tensor-valued constant for flattened array of values

Parameters:
  • value_shape – (std::vector<std::size_t>) Shape of tensor.
  • values – (std::vector<double>) Values to create tensor-valued constant from.
void dolfin::Constant::eval(Array<double> &values, const Array<double> &x) const

Evaluate at given point.

Parameters:
  • values – (Array<double>) The values at the point.
  • x – (Array<double>) The coordinates of the point.
dolfin::Constant::operator double() const

Cast to double (for scalar constants)

Returns:double The scalar value.
const Constant &dolfin::Constant::operator=(const Constant &constant)

Assignment operator

Parameters:constant – (Constant ) Another constant.
const Constant &dolfin::Constant::operator=(double constant)

Assignment operator

Parameters:constant – (double) Another constant.
std::string dolfin::Constant::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
std::vector<double> dolfin::Constant::values() const

Return copy of this Constant ‘s current values

Returns:std::vector<double> The vector of scalar values of the constant.
dolfin::Constant::~Constant()

Destructor.

Expression

C++ documentation for Expression from dolfin/function/Expression.h:

class dolfin::Expression : public dolfin::GenericFunction

This class represents a user-defined expression. Expressions can be used as coefficients in variational forms or interpolated into finite element spaces. An expression is defined by overloading the eval method. Users may choose to overload either a simple version of eval , in the case of expressions only depending on the coordinate x, or an optional version for expressions depending on x and mesh data like cell indices or facet normals. The geometric dimension (the size of x) and the value rank and dimensions of an expression must supplied as arguments to the constructor.

dolfin::Expression::Expression()

Create scalar expression.

dolfin::Expression::Expression(const Expression &expression)

Copy constructor

Parameters:expression – (Expression() ) Object to be copied.
dolfin::Expression::Expression(std::size_t dim)

Create vector-valued expression with given dimension.

Parameters:dim – (std::size_t) Dimension of the vector-valued expression.
dolfin::Expression::Expression(std::size_t dim0, std::size_t dim1)

Create matrix-valued expression with given dimensions.

Parameters:
  • dim0 – (std::size_t) Dimension (rows).
  • dim1 – (std::size_t) Dimension (columns).
dolfin::Expression::Expression(std::vector<std::size_t> value_shape)

Create tensor-valued expression with given shape.

Parameters:value_shape – (std::vector<std::size_t>) Shape of expression.
void dolfin::Expression::compute_vertex_values(std::vector<double> &vertex_values, const Mesh &mesh) const

Compute values at all mesh vertices.

Parameters:
  • vertex_values – (Array<double>) The values at all vertices.
  • mesh – (Mesh ) The mesh.
void dolfin::Expression::eval(Array<double> &values, const Array<double> &x) const

Evaluate at given point.

Parameters:
  • values – (Array<double>) The values at the point.
  • x – (Array<double>) The coordinates of the point.
void dolfin::Expression::eval(Array<double> &values, const Array<double> &x, const ufc::cell &cell) const

Note: The reimplementation of eval is needed for the Python interface. Evaluate at given point in given cell.

Parameters:
  • values – (Array<double>) The values at the point.
  • x – (Array<double>) The coordinates of the point.
  • cell – (ufc::cell ) The cell which contains the given point.
std::shared_ptr<const FunctionSpace> dolfin::Expression::function_space() const

Return shared pointer to function space (NULL) Expression does not have a FunctionSpace

Returns:FunctionSpace Return the shared pointer.
void dolfin::Expression::restrict(double *w, const FiniteElement &element, const Cell &dolfin_cell, const double *coordinate_dofs, const ufc::cell &ufc_cell) const

Restrict function to local cell (compute expansion coefficients w).

Parameters:
  • w – (list of doubles) Expansion coefficients.
  • element – (FiniteElement ) The element.
  • dolfin_cell – (Cell ) The cell.
  • coordinate_dofs – (double*) The coordinates
  • ufc_cell – (ufc::cell ) The ufc::cell .
std::size_t dolfin::Expression::value_dimension(std::size_t i) const

Return value dimension for given axis.

Parameters:i – (std::size_t) Integer denoting the axis to use.
Returns:std::size_t The value dimension (for the given axis).
std::size_t dolfin::Expression::value_rank() const

Return value rank.

Returns:std::size_t The value rank.
dolfin::Expression::~Expression()

Destructor.

FacetArea

C++ documentation for FacetArea from dolfin/function/SpecialFunctions.h:

class dolfin::FacetArea : public dolfin::Expression

This function represents the area/length of a cell facet on a given mesh.

dolfin::FacetArea::FacetArea(std::shared_ptr<const Mesh> mesh)

Constructor.

Parameters:mesh
void dolfin::FacetArea::eval(Array<double> &values, const Array<double> &x, const ufc::cell &cell) const

Evaluate function.

Parameters:
  • values
  • x
  • cell
Event dolfin::FacetArea::not_on_boundary
Function

C++ documentation for Function from dolfin/function/Function.h:

class dolfin::Function : public dolfin::GenericFunction

This class represents a function \(u_h\) in a finite element function space \(V_h\) , given by .. math:

::
u_h = sum_{i=1}^{n} U_i phi_i

where \(\phi_i\}_{i=1}^{n}\) is a basis for \(V_h\) , and \(U\) is a vector of expansion coefficients for \(u_h\) .

Friends: FunctionAssigner, FunctionSpace.

dolfin::Function::Function(const Function &v)

Copy constructor Arguments v (Function() ) The object to be copied.

Parameters:v
dolfin::Function::Function(const Function &v, std::size_t i)

Sub-function constructor with shallow copy of vector (used in Python interface) Arguments v (Function() ) The function to be copied. i (std::size_t) Index of subfunction.

Parameters:
  • v
  • i
dolfin::Function::Function(std::shared_ptr<const FunctionSpace> V)

Create function on given function space (shared data) Arguments V (FunctionSpace ) The function space.

Parameters:V
dolfin::Function::Function(std::shared_ptr<const FunctionSpace> V, std::shared_ptr<GenericVector> x)

Create function on given function space with a given vector (shared data) Warning: This constructor is intended for internal library use only Arguments V (FunctionSpace ) The function space. x (GenericVector ) The vector.

Parameters:
  • V
  • x
dolfin::Function::Function(std::shared_ptr<const FunctionSpace> V, std::string filename)

Create function from vector of dofs stored to file (shared data) Arguments V (FunctionSpace ) The function space. filename_dofdata (std::string) The name of the file containing the dofmap data.

Parameters:
  • V
  • filename
void dolfin::Function::compute_vertex_values(std::vector<double> &vertex_values)

Compute values at all mesh vertices

Parameters:vertex_values – (Array<double>) The values at all vertices.
void dolfin::Function::compute_vertex_values(std::vector<double> &vertex_values, const Mesh &mesh) const

Compute values at all mesh vertices

Parameters:
  • vertex_values – (Array<double>) The values at all vertices.
  • mesh – (Mesh ) The mesh.
void dolfin::Function::eval(Array<double> &values, const Array<double> &x) const

Evaluate function at given coordinates

Parameters:
  • values – (Array<double>) The values.
  • x – (Array<double>) The coordinates.
void dolfin::Function::eval(Array<double> &values, const Array<double> &x, const Cell &dolfin_cell, const ufc::cell &ufc_cell) const

Evaluate function at given coordinates in given cell Arguments

Parameters:
  • values – (Array<double>) The values.
  • x – (Array<double>) The coordinates.
  • dolfin_cell – (Cell ) The cell.
  • ufc_cell – (ufc::cell ) The ufc::cell .
void dolfin::Function::eval(Array<double> &values, const Array<double> &x, const ufc::cell &cell) const

Evaluate at given point in given cell

Parameters:
  • values – (Array<double>) The values at the point.
  • x – (Array<double>) The coordinates of the point.
  • cell – (ufc::cell ) The cell which contains the given point.
void dolfin::Function::extrapolate(const Function &v)

Extrapolate function (from a possibly lower-degree function space) Arguments v (Function ) The function to be extrapolated.

Parameters:v
std::shared_ptr<const FunctionSpace> dolfin::Function::function_space() const

Return shared pointer to function space Returns:cpp:any:FunctionSpace Return the shared pointer.

std::size_t dolfin::Function::geometric_dimension() const

Return geometric dimension Returns std::size_t The geometric dimension.

bool dolfin::Function::get_allow_extrapolation() const

Check if extrapolation is permitted when evaluating the Function

Returns:bool True if extrapolation is permitted, otherwise false
bool dolfin::Function::in(const FunctionSpace &V) const

Check if function is a member of the given function space Arguments V (FunctionSpace ) The function space. Returns bool True if the function is in the function space.

Parameters:V
void dolfin::Function::init_vector()
void dolfin::Function::interpolate(const GenericFunction &v)

Interpolate function (on possibly non-matching meshes)

Parameters:v – (GenericFunction ) The function to be interpolated.
const Function &dolfin::Function::operator=(const Expression &v)

Assignment from expression using interpolation Arguments v (Expression ) The expression.

Parameters:v
const Function &dolfin::Function::operator=(const Function &v)

Assignment from function Arguments v (Function ) Another function.

Parameters:v
void dolfin::Function::operator=(const FunctionAXPY &axpy)

Assignment from linear combination of function Arguments v (FunctionAXPY ) A linear combination of other Functions

Parameters:axpy
Function &dolfin::Function::operator[](std::size_t i) const

Extract subfunction Arguments i (std::size_t) Index of subfunction. Returns:cpp:any:Function The subfunction.

Parameters:i
void dolfin::Function::restrict(double *w, const FiniteElement &element, const Cell &dolfin_cell, const double *coordinate_dofs, const ufc::cell &ufc_cell) const

Restrict function to local cell (compute expansion coefficients w)

Parameters:
  • w – (list of doubles) Expansion coefficients.
  • element – (FiniteElement ) The element.
  • dolfin_cell – (Cell ) The cell.
  • coordinate_dofs – (double *) The coordinates
  • ufc_cell – (ufc::cell ). The ufc::cell .
void dolfin::Function::set_allow_extrapolation(bool allow_extrapolation)

Allow extrapolation when evaluating the Function

Parameters:allow_extrapolation – (bool) Whether or not permit extrapolation.
std::size_t dolfin::Function::value_dimension(std::size_t i) const

Return value dimension for given axis Arguments i (std::size_t) The index of the axis. Returns std::size_t The value dimension.

Parameters:i
std::size_t dolfin::Function::value_rank() const

Return value rank Returns std::size_t The value rank.

std::shared_ptr<GenericVector> dolfin::Function::vector()

Return vector of expansion coefficients (non-const version) Returns:cpp:any:GenericVector The vector of expansion coefficients.

std::shared_ptr<const GenericVector> dolfin::Function::vector() const

Return vector of expansion coefficients (const version) Returns:cpp:any:GenericVector The vector of expansion coefficients (const).

dolfin::Function::~Function()

Destructor.

FunctionAXPY

C++ documentation for FunctionAXPY from dolfin/function/FunctionAXPY.h:

class dolfin::FunctionAXPY

This class represents a linear combination of functions. It is mostly used as an intermediate class for operations such as u = 3*u0 + 4*u1; where the rhs generates an FunctionAXPY .

enum dolfin::FunctionAXPY::Direction

Enum to decide what way AXPY is constructed.

enumerator dolfin::FunctionAXPY::Direction::ADD_ADD = 0
enumerator dolfin::FunctionAXPY::Direction::SUB_ADD = 1
enumerator dolfin::FunctionAXPY::Direction::ADD_SUB = 2
enumerator dolfin::FunctionAXPY::Direction::SUB_SUB = 3
dolfin::FunctionAXPY::FunctionAXPY(const FunctionAXPY &axpy)

Copy constructor.

Parameters:axpy
dolfin::FunctionAXPY::FunctionAXPY(const FunctionAXPY &axpy, double scalar)

Constructor.

Parameters:
  • axpy
  • scalar
dolfin::FunctionAXPY::FunctionAXPY(const FunctionAXPY &axpy, std::shared_ptr<const Function> func, Direction direction)

Constructor.

Parameters:
  • axpy
  • func
  • direction
dolfin::FunctionAXPY::FunctionAXPY(const FunctionAXPY &axpy0, const FunctionAXPY &axpy1, Direction direction)

Constructor.

Parameters:
  • axpy0
  • axpy1
  • direction
dolfin::FunctionAXPY::FunctionAXPY(std::shared_ptr<const Function> func, double scalar)

Constructor.

Parameters:
  • func
  • scalar
dolfin::FunctionAXPY::FunctionAXPY(std::shared_ptr<const Function> func0, std::shared_ptr<const Function> func1, Direction direction)

Constructor.

Parameters:
  • func0
  • func1
  • direction
dolfin::FunctionAXPY::FunctionAXPY(std::vector<std::pair<double, std::shared_ptr<const Function>>> pairs)

Constructor.

Parameters:pairs
FunctionAXPY dolfin::FunctionAXPY::operator*(double scale) const

Scale operator.

Parameters:scale
FunctionAXPY dolfin::FunctionAXPY::operator+(const FunctionAXPY &axpy) const

Addition operator.

Parameters:axpy
FunctionAXPY dolfin::FunctionAXPY::operator+(std::shared_ptr<const Function> func) const

Addition operator.

Parameters:func
FunctionAXPY dolfin::FunctionAXPY::operator-(const FunctionAXPY &axpy) const

Subtraction operator.

Parameters:axpy
FunctionAXPY dolfin::FunctionAXPY::operator-(std::shared_ptr<const Function> func) const

Subtraction operator.

Parameters:func
FunctionAXPY dolfin::FunctionAXPY::operator/(double scale) const

Scale operator.

Parameters:scale
const std::vector<std::pair<double, std::shared_ptr<const Function>>> &dolfin::FunctionAXPY::pairs() const

Return the scalar and Function pairs.

dolfin::FunctionAXPY::~FunctionAXPY()

Destructor.

FunctionAssigner

C++ documentation for FunctionAssigner from dolfin/function/FunctionAssigner.h:

class dolfin::FunctionAssigner

This class facilitate assignments between Function and sub Functions. It builds and caches maps between compatible dofs. These maps are used in the assignment methods which perform the actual assignment. Optionally can a MeshFunction be passed together with a label, facilitating FunctionAssignment over sub domains.

dolfin::FunctionAssigner::FunctionAssigner(std::shared_ptr<const FunctionSpace> receiving_space, std::shared_ptr<const FunctionSpace> assigning_space)

Create a FunctionAssigner() between functions residing in the same type of FunctionSpace . One or both functions can be sub functions. Arguments receiving_space (FunctionSpace ) The function space of the receiving function assigning_space (FunctionSpace ) The function space of the assigning function

Parameters:
  • receiving_space
  • assigning_space
dolfin::FunctionAssigner::FunctionAssigner(std::shared_ptr<const FunctionSpace> receiving_space, std::vector<std::shared_ptr<const FunctionSpace>> assigning_spaces)

Create a FunctionAssigner() between several functions (assigning) and one mixed function (receiving). The number of sub functions in the assigning mixed function must sum up to the number of receiving functions. The sub spaces of the receiving mixed space must be of the same type ans size as the assigning spaces. Arguments receiving_space (std::shared_ptr<FunctionSpace >) The receiving function space assigning_spaces (std::vector<std::shared_ptr<FunctionSpace > >) The assigning function spaces

Parameters:
  • receiving_space
  • assigning_spaces
dolfin::FunctionAssigner::FunctionAssigner(std::vector<std::shared_ptr<const FunctionSpace>> receiving_spaces, std::shared_ptr<const FunctionSpace> assigning_space)

Create a FunctionAssigner() between one mixed function (assigning) and several functions (receiving). The number of receiving functions must sum up to the number of sub functions in the assigning mixed function. The sub spaces of the assigning mixed space must be of the same type ans size as the receiving spaces. Arguments receiving_spaces (std::vector<FunctionSpace >) The receiving function spaces assigning_space (FunctionSpace ) The assigning function space

Parameters:
  • receiving_spaces
  • assigning_space
void dolfin::FunctionAssigner::assign(std::shared_ptr<Function> receiving_func, std::shared_ptr<const Function> assigning_func) const

Assign one function to another Arguments receiving_func (std::shared_ptr<Function >) The receiving function assigning_func (std::shared_ptr<Function >) The assigning function

Parameters:
  • receiving_func
  • assigning_func
void dolfin::FunctionAssigner::assign(std::shared_ptr<Function> receiving_func, std::vector<std::shared_ptr<const Function>> assigning_funcs) const

Assign several functions to sub functions of a mixed receiving function Arguments receiving_func (std::shared_ptr<Function >) The receiving mixed function assigning_funcs (std::vector<std::shared_ptr<Function > >) The assigning functions

Parameters:
  • receiving_func
  • assigning_funcs
void dolfin::FunctionAssigner::assign(std::vector<std::shared_ptr<Function>> receiving_funcs, std::shared_ptr<const Function> assigning_func) const

Assign sub functions of a single mixed function to single receiving functions Arguments receiving_funcs (std::vector<std::shared_ptr<Function > >) The receiving functions assigning_func (std::shared_ptr<Function >) The assigning mixed function

Parameters:
  • receiving_funcs
  • assigning_func
std::size_t dolfin::FunctionAssigner::num_assigning_functions() const

Return the number of assigning functions.

std::size_t dolfin::FunctionAssigner::num_receiving_functions() const

Return the number of receiving functions.

dolfin::FunctionAssigner::~FunctionAssigner()

Destructor.

FunctionSpace

C++ documentation for FunctionSpace from dolfin/function/FunctionSpace.h:

class dolfin::FunctionSpace

This class represents a finite element function space defined by a mesh, a finite element, and a local-to-global mapping of the degrees of freedom (dofmap).

dolfin::FunctionSpace::FunctionSpace(const FunctionSpace &V)

Copy constructor Arguments V (FunctionSpace() ) The object to be copied.

Parameters:V
dolfin::FunctionSpace::FunctionSpace(std::shared_ptr<const Mesh> mesh)

Create empty function space for later initialization. This constructor is intended for use by any sub-classes which need to construct objects before the initialisation of the base class. Data can be attached to the base class using FunctionSpace::attach (...). Arguments mesh (Mesh ) The mesh.

Parameters:mesh
dolfin::FunctionSpace::FunctionSpace(std::shared_ptr<const Mesh> mesh, std::shared_ptr<const FiniteElement> element, std::shared_ptr<const GenericDofMap> dofmap)

Create function space for given mesh, element and dofmap (shared data) Arguments mesh (Mesh ) The mesh. element (FiniteElement ) The element. dofmap (GenericDofMap ) The dofmap.

Parameters:
  • mesh
  • element
  • dofmap
void dolfin::FunctionSpace::attach(std::shared_ptr<const FiniteElement> element, std::shared_ptr<const GenericDofMap> dofmap)

Attach data to an empty function space Arguments element (FiniteElement ) The element. dofmap (GenericDofMap ) The dofmap.

Parameters:
  • element
  • dofmap
std::shared_ptr<FunctionSpace> dolfin::FunctionSpace::collapse() const

Collapse a subspace and return a new function space Returns:cpp:any:FunctionSpace The new function space.

std::shared_ptr<FunctionSpace> dolfin::FunctionSpace::collapse(std::unordered_map<std::size_t, std::size_t> &collapsed_dofs) const

Collapse a subspace and return a new function space and a map from new to old dofs Arguments collapsed_dofs (std::unordered_map<std::size_t, std::size_t>) The map from new to old dofs. Returns:cpp:any:FunctionSpace The new function space.

Parameters:collapsed_dofs
std::vector<std::size_t> dolfin::FunctionSpace::component() const

Return component w.r.t. to root superspace, i.e. W.sub(1).sub(0) == [1, 0]. Returns std::vector<std::size_t> The component (w.r.t to root superspace).

bool dolfin::FunctionSpace::contains(const FunctionSpace &V) const

Check whether V is subspace of this, or this itself Arguments V (FunctionSpace ) The space to be tested for inclusion. Returns bool True if V is contained or equal to this.

Parameters:V
std::size_t dolfin::FunctionSpace::dim() const

Return dimension of function space Returns std::size_t The dimension of the function space.

std::shared_ptr<const GenericDofMap> dolfin::FunctionSpace::dofmap() const

Return dofmap Returns:cpp:any:GenericDofMap The dofmap.

std::shared_ptr<const FiniteElement> dolfin::FunctionSpace::element() const

Return finite element Returns:cpp:any:FiniteElement The finite element.

std::shared_ptr<FunctionSpace> dolfin::FunctionSpace::extract_sub_space(const std::vector<std::size_t> &component) const

Extract subspace for component Arguments component (std::vector<std::size_t>) The component. Returns:cpp:any:FunctionSpace The subspace.

Parameters:component
bool dolfin::FunctionSpace::has_cell(const Cell &cell) const

Check if function space has given cell Arguments cell (Cell ) The cell. Returns bool True if the function space has the given cell.

Parameters:cell
bool dolfin::FunctionSpace::has_element(const FiniteElement &element) const

Check if function space has given element Arguments element (FiniteElement ) The finite element. Returns bool True if the function space has the given element.

Parameters:element
void dolfin::FunctionSpace::interpolate(GenericVector &expansion_coefficients, const GenericFunction &v) const

Interpolate function v into function space, returning the vector of expansion coefficients Arguments expansion_coefficients (GenericVector ) The expansion coefficients. v (GenericFunction ) The function to be interpolated.

Parameters:
  • expansion_coefficients
  • v
void dolfin::FunctionSpace::interpolate_from_any(GenericVector &expansion_coefficients, const GenericFunction &v) const
Parameters:
  • expansion_coefficients
  • v
void dolfin::FunctionSpace::interpolate_from_parent(GenericVector &expansion_coefficients, const GenericFunction &v) const
Parameters:
  • expansion_coefficients
  • v
std::shared_ptr<const Mesh> dolfin::FunctionSpace::mesh() const

Return mesh Returns:cpp:any:Mesh The mesh.

bool dolfin::FunctionSpace::operator!=(const FunctionSpace &V) const

Inequality operator Arguments V (FunctionSpace ) Another function space.

Parameters:V
const FunctionSpace &dolfin::FunctionSpace::operator=(const FunctionSpace &V)

Assignment operator Arguments V (FunctionSpace ) Another function space.

Parameters:V
bool dolfin::FunctionSpace::operator==(const FunctionSpace &V) const

Equality operator Arguments V (FunctionSpace ) Another function space.

Parameters:V
std::shared_ptr<FunctionSpace> dolfin::FunctionSpace::operator[](std::size_t i) const

Extract subspace for component Arguments i (std::size_t) Index of the subspace. Returns:cpp:any:FunctionSpace The subspace.

Parameters:i
void dolfin::FunctionSpace::print_dofmap() const

Print dofmap (useful for debugging)

void dolfin::FunctionSpace::set_x(GenericVector &x, double value, std::size_t component) const

Set dof entries in vector to value*x[i], where [x][i] is the coordinate of the dof spatial coordinate. Parallel layout of vector must be consistent with dof map range This function is typically used to construct the null space of a matrix operator, e.g. rigid body rotations. Arguments vector (GenericVector ) The vector to set. value (double) The value to multiply to coordinate by. component (std::size_t) The coordinate index. mesh (Mesh ) The mesh.

Parameters:
  • x
  • value
  • component
std::string dolfin::FunctionSpace::str(bool verbose) const

Return informal string representation (pretty-print) Arguments verbose (bool) Flag to turn on additional output. Returns std::string An informal representation of the function space.

Parameters:verbose
std::shared_ptr<FunctionSpace> dolfin::FunctionSpace::sub(const std::vector<std::size_t> &component) const

Extract subspace for component Arguments component (std::vector<std::size_t>) The component. Returns:cpp:any:FunctionSpace The subspace.

Parameters:component
std::shared_ptr<FunctionSpace> dolfin::FunctionSpace::sub(std::size_t component) const

Extract subspace for component Arguments component (std::size_t) Index of the subspace. Returns:cpp:any:FunctionSpace The subspace.

Parameters:component
std::vector<double> dolfin::FunctionSpace::tabulate_dof_coordinates() const

Tabulate the coordinates of all dofs on this process. This function is typically used by preconditioners that require the spatial coordinates of dofs, for example for re-partitioning or nullspace computations. Arguments mesh (Mesh ) The mesh. Returns std::vector<double> The dof coordinates (x0, y0, x1, y1, . . .)

dolfin::FunctionSpace::~FunctionSpace()

Destructor.

GenericFunction

C++ documentation for GenericFunction from dolfin/function/GenericFunction.h:

class dolfin::GenericFunction

This is a common base class for functions. Functions can be evaluated at a given point and they can be restricted to a given cell in a finite element mesh. This functionality is implemented by sub-classes that implement the eval and restrict functions. DOLFIN provides two implementations of the GenericFunction interface in the form of the classes Function and Expression . Sub-classes may optionally implement the update function that will be called prior to restriction when running in parallel.

dolfin::GenericFunction::GenericFunction()

Constructor.

void dolfin::GenericFunction::compute_vertex_values(std::vector<double> &vertex_values, const Mesh &mesh) const = 0

Compute values at all mesh vertices.

Parameters:
  • vertex_values
  • mesh
void dolfin::GenericFunction::eval(Array<double> &values, const Array<double> &x) const

Evaluate at given point.

Parameters:
  • values
  • x
void dolfin::GenericFunction::eval(Array<double> &values, const Array<double> &x, const ufc::cell &cell) const

Evaluate at given point in given cell.

Parameters:
  • values
  • x
  • cell
void dolfin::GenericFunction::evaluate(double *values, const double *coordinates, const ufc::cell &cell) const

Evaluate function at given point in cell

Parameters:
  • values – (double*)
  • coordinates – (const double*)
  • cell – (ufc::cell &)
std::shared_ptr<const FunctionSpace> dolfin::GenericFunction::function_space() const = 0

Pointer to FunctionSpace , if appropriate, otherwise NULL.

void dolfin::GenericFunction::operator()(Array<double> &values, const Point &p) const

Evaluation at given point (vector-valued function)

Parameters:
  • values
  • p
void dolfin::GenericFunction::operator()(Array<double> &values, double x) const

Evaluation at given point (vector-valued function)

Parameters:
  • values
  • x
void dolfin::GenericFunction::operator()(Array<double> &values, double x, double y) const

Evaluation at given point (vector-valued function)

Parameters:
  • values
  • x
  • y
void dolfin::GenericFunction::operator()(Array<double> &values, double x, double y, double z) const

Evaluation at given point (vector-valued function)

Parameters:
  • values
  • x
  • y
  • z
double dolfin::GenericFunction::operator()(const Point &p) const

Evaluation at given point (scalar function)

Parameters:p
double dolfin::GenericFunction::operator()(double x) const

Evaluation at given point (scalar function)

Parameters:x
double dolfin::GenericFunction::operator()(double x, double y) const

Evaluation at given point (scalar function)

Parameters:
  • x
  • y
double dolfin::GenericFunction::operator()(double x, double y, double z) const

Evaluation at given point (scalar function)

Parameters:
  • x
  • y
  • z
void dolfin::GenericFunction::restrict(double *w, const FiniteElement &element, const Cell &dolfin_cell, const double *coordinate_dofs, const ufc::cell &ufc_cell) const = 0

Restrict function to local cell (compute expansion coefficients w)

Parameters:
  • w
  • element
  • dolfin_cell
  • coordinate_dofs
  • ufc_cell
void dolfin::GenericFunction::restrict_as_ufc_function(double *w, const FiniteElement &element, const Cell &dolfin_cell, const double *coordinate_dofs, const ufc::cell &ufc_cell) const

Restrict as UFC function (by calling eval)

Parameters:
  • w
  • element
  • dolfin_cell
  • coordinate_dofs
  • ufc_cell
void dolfin::GenericFunction::update() const

Update off-process ghost coefficients.

std::size_t dolfin::GenericFunction::value_dimension(std::size_t i) const = 0

Return value dimension for given axis.

Parameters:i
std::size_t dolfin::GenericFunction::value_rank() const = 0

Return value rank.

std::size_t dolfin::GenericFunction::value_size() const

Evaluation at given point. Return value size (product of value dimensions)

dolfin::GenericFunction::~GenericFunction()

Destructor.

LagrangeInterpolator

C++ documentation for LagrangeInterpolator from dolfin/function/LagrangeInterpolator.h:

class dolfin::LagrangeInterpolator

This class interpolates efficiently from a GenericFunction to a Lagrange Function

void dolfin::LagrangeInterpolator::extract_dof_component_map(std::unordered_map<std::size_t, std::size_t> &dof_component_map, const FunctionSpace &V, int *component)
Parameters:
  • dof_component_map
  • V
  • component
bool dolfin::LagrangeInterpolator::in_bounding_box(const std::vector<double> &point, const std::vector<double> &bounding_box, const double tol)
Parameters:
  • point
  • bounding_box
  • tol
void dolfin::LagrangeInterpolator::interpolate(Function &u, const Expression &u0)

Interpolate Expression Arguments u (Function ) The resulting Function u0 (Expression ) The Expression to be interpolated.

Parameters:
  • u
  • u0
void dolfin::LagrangeInterpolator::interpolate(Function &u, const Function &u0)

Interpolate function (on possibly non-matching meshes) Arguments u (Function ) The resulting Function u0 (Function ) The Function to be interpolated.

Parameters:
  • u
  • u0
std::map<std::vector<double>, std::vector<std::size_t>, lt_coordinate> dolfin::LagrangeInterpolator::tabulate_coordinates_to_dofs(const FunctionSpace &V)
Parameters:V
MeshCoordinates

C++ documentation for MeshCoordinates from dolfin/function/SpecialFunctions.h:

class dolfin::MeshCoordinates : public dolfin::Expression

This Function represents the mesh coordinates on a given mesh.

dolfin::MeshCoordinates::MeshCoordinates(std::shared_ptr<const Mesh> mesh)

Constructor.

Parameters:mesh
void dolfin::MeshCoordinates::eval(Array<double> &values, const Array<double> &x, const ufc::cell &cell) const

Evaluate function.

Parameters:
  • values
  • x
  • cell
MultiMeshCoefficientAssigner

C++ documentation for MultiMeshCoefficientAssigner from dolfin/function/MultiMeshCoefficientAssigner.h:

class dolfin::MultiMeshCoefficientAssigner

This class is used for assignment of multimesh coefficients to forms, which allows magic like a.f = f a.g = g which will insert the coefficients f and g in the correct positions in the list of coefficients for the form. Note that coefficients can also be assigned manually to the individual parts of a multimesh form. Assigning to a multimesh coefficient assigner will assign the same coefficient to all parts of a form.

dolfin::MultiMeshCoefficientAssigner::MultiMeshCoefficientAssigner(MultiMeshForm &form, std::size_t number)

Create multimesh coefficient assigner for coefficient with given number.

Parameters:
  • form
  • number
void dolfin::MultiMeshCoefficientAssigner::operator=(const MultiMeshFunction &coefficient)

Assign coefficient from MultiMeshFunction .

Parameters:coefficient
void dolfin::MultiMeshCoefficientAssigner::operator=(std::shared_ptr<const GenericFunction> coefficient)

Assign coefficient from GenericFunction .

Parameters:coefficient
dolfin::MultiMeshCoefficientAssigner::~MultiMeshCoefficientAssigner()

Destructor.

MultiMeshFunction

C++ documentation for MultiMeshFunction from dolfin/function/MultiMeshFunction.h:

class dolfin::MultiMeshFunction

This class represents a function on a cut and composite finite element function space (MultiMesh ) defined on one or more possibly intersecting meshes.

dolfin::MultiMeshFunction::MultiMeshFunction()

Constructor.

dolfin::MultiMeshFunction::MultiMeshFunction(std::shared_ptr<const MultiMeshFunctionSpace> V)

Create MultiMesh function on given MultiMesh function space Arguments V (MultiMeshFunctionSpace ) The MultiMesh function space.

Parameters:V
dolfin::MultiMeshFunction::MultiMeshFunction(std::shared_ptr<const MultiMeshFunctionSpace> V, std::shared_ptr<GenericVector> x)

Create MultiMesh function on given MultiMesh function space with a given vector (shared data) Warning: This constructor is intended for internal library use only Arguments V (MultiMeshFunctionSpace ) The multimesh function space. x (GenericVector ) The vector.

Parameters:
  • V
  • x
void dolfin::MultiMeshFunction::compute_ghost_indices(std::pair<std::size_t, std::size_t> range, std::vector<la_index> &ghost_indices) const
Parameters:
  • range
  • ghost_indices
std::shared_ptr<const MultiMeshFunctionSpace> dolfin::MultiMeshFunction::function_space() const

Return shared pointer to multi mesh function space Returns:cpp:any:MultiMeshFunctionSpace Return the shared pointer.

void dolfin::MultiMeshFunction::init_vector()
std::shared_ptr<const Function> dolfin::MultiMeshFunction::part(std::size_t i) const

Return function (part) number i Returns:cpp:any:Function Function (part) number i

Parameters:i
std::shared_ptr<GenericVector> dolfin::MultiMeshFunction::vector()

Return vector of expansion coefficients (non-const version) Returns:cpp:any:GenericVector The vector of expansion coefficients.

std::shared_ptr<const GenericVector> dolfin::MultiMeshFunction::vector() const

Return vector of expansion coefficients (const version) Returns:cpp:any:GenericVector The vector of expansion coefficients (const).

dolfin::MultiMeshFunction::~MultiMeshFunction()

Destructor.

MultiMeshFunctionSpace

C++ documentation for MultiMeshFunctionSpace from dolfin/function/MultiMeshFunctionSpace.h:

class dolfin::MultiMeshFunctionSpace

This class represents a function space on a multimesh. It may may be created from a set of standard function spaces by repeatedly calling add , followed by a call to build . Note that a multimesh function space is not useful and its data structures are empty until build has been called.

Friends: MultiMeshSubSpace.

dolfin::MultiMeshFunctionSpace::MultiMeshFunctionSpace(std::shared_ptr<const MultiMesh> multimesh)

Create multimesh function space on multimesh (shared pointer version)

Parameters:multimesh
void dolfin::MultiMeshFunctionSpace::add(std::shared_ptr<const FunctionSpace> function_space)

Add function space Arguments function_space (FunctionSpace ) The function space.

Parameters:function_space
void dolfin::MultiMeshFunctionSpace::build()

Build multimesh function space.

void dolfin::MultiMeshFunctionSpace::build(const std::vector<dolfin::la_index> &offsets)

Build multimesh function space. This function uses offsets computed from the full function spaces on each part.

Parameters:offsets
std::size_t dolfin::MultiMeshFunctionSpace::dim() const

Return dimension of the multimesh function space Returns std::size_t The dimension of the multimesh function space.

std::shared_ptr<const MultiMeshDofMap> dolfin::MultiMeshFunctionSpace::dofmap() const

Return multimesh dofmap Returns:cpp:any:MultiMeshDofMap The dofmap.

std::shared_ptr<const MultiMesh> dolfin::MultiMeshFunctionSpace::multimesh() const

Return multimesh Returns:cpp:any:MultiMesh The multimesh.

std::size_t dolfin::MultiMeshFunctionSpace::num_parts() const

Return the number of function spaces (parts) of the multimesh function space Returns std::size_t The number of function spaces (parts) of the multimesh function space.

std::shared_ptr<const FunctionSpace> dolfin::MultiMeshFunctionSpace::part(std::size_t i) const

Return function space (part) number i Arguments i (std::size_t) The part number Returns:cpp:any:FunctionSpace Function space (part) number i

Parameters:i
std::shared_ptr<const FunctionSpace> dolfin::MultiMeshFunctionSpace::view(std::size_t i) const

Return view of multimesh function space for part number i. This function differs from the part() function in that it does not return the original function space for a part, but rather a view of the common multimesh function space (dofs global to the collection of parts). Arguments i (std::size_t) The part number Returns:cpp:any:FunctionSpace Function space (part) number i

Parameters:i
dolfin::MultiMeshFunctionSpace::~MultiMeshFunctionSpace()

Destructor.

MultiMeshSubSpace

C++ documentation for MultiMeshSubSpace from dolfin/function/MultiMeshSubSpace.h:

class dolfin::MultiMeshSubSpace : public dolfin::MultiMeshFunctionSpace

This class represents a subspace (component) of a multimesh function space. The subspace is specified by an array of indices. For example, the array [3, 0, 2] specifies subspace 2 of subspace 0 of subspace 3. A typical example is the function space W = V x P for Stokes. Here, V = W[0] is the subspace for the velocity component and P = W[1] is the subspace for the pressure component. Furthermore, W[0][0] = V[0] is the first component of the velocity space etc.

dolfin::MultiMeshSubSpace::MultiMeshSubSpace(MultiMeshFunctionSpace &V, const std::vector<std::size_t> &component)

Create subspace for given component (n levels)

Parameters:
  • V
  • component
dolfin::MultiMeshSubSpace::MultiMeshSubSpace(MultiMeshFunctionSpace &V, std::size_t component)

Create subspace for given component (one level)

Parameters:
  • V
  • component
dolfin::MultiMeshSubSpace::MultiMeshSubSpace(MultiMeshFunctionSpace &V, std::size_t component, std::size_t sub_component)

Create subspace for given component (two levels)

Parameters:
  • V
  • component
  • sub_component
SpecialFacetFunction

C++ documentation for SpecialFacetFunction from dolfin/function/SpecialFacetFunction.h:

class dolfin::SpecialFacetFunction : public dolfin::Expression

A SpecialFacetFunction is a representation of a global function that is in P(f) for each Facet f in a Mesh for some FunctionSpace P

dolfin::SpecialFacetFunction::SpecialFacetFunction(std::vector<Function> &f_e)

Create (scalar-valued) SpecialFacetFunction() Arguments f_e (std::vector<Function >) Separate _Function_s for each facet

Parameters:f_e
dolfin::SpecialFacetFunction::SpecialFacetFunction(std::vector<Function> &f_e, std::size_t dim)

Create (vector-valued) SpecialFacetFunction() Arguments f_e (std::vector<Function >) Separate _Function_s for each facet dim (int) The value-dimension of the Functions

Parameters:
  • f_e
  • dim
dolfin::SpecialFacetFunction::SpecialFacetFunction(std::vector<Function> &f_e, std::vector<std::size_t> value_shape)

Create (tensor-valued) SpecialFacetFunction() Arguments f_e (std::vector<Function >) Separate _Function_s for each facet value_shape (std::vector<std::size_t>) The values-shape of the Functions

Parameters:
  • f_e
  • value_shape
void dolfin::SpecialFacetFunction::eval(Array<double> &values, const Array<double> &x, const ufc::cell &cell) const

Evaluate SpecialFacetFunction (cf Expression .eval) Evaluate function for given cell

Parameters:
  • values
  • x
  • cell
Function &dolfin::SpecialFacetFunction::operator[](std::size_t i) const

Extract sub-function i Arguments i (int) component Returns:cpp:any:Function

Parameters:i

dolfin/generation

Documentation for C++ code found in dolfin/generation/*.h

Classes

BoxMesh

C++ documentation for BoxMesh from dolfin/generation/BoxMesh.h:

class dolfin::BoxMesh : public dolfin::Mesh

Tetrahedral mesh of the 3D rectangular prism spanned by two points p0 and p1. Given the number of cells (nx, ny, nz) in each direction, the total number of tetrahedra will be 6*nx*ny*nz and the total number of vertices will be (nx + 1)*(ny + 1)*(nz + 1).

dolfin::BoxMesh::BoxMesh(MPI_Comm comm, const Point &p0, const Point &p1, std::size_t nx, std::size_t ny, std::size_t nz)

Create a uniform finite element Mesh over the rectangular prism spanned by the two _Point_s p0 and p1. The order of the two points is not important in terms of minimum and maximum coordinates.

// Mesh with 8 cells in each direction on the
// set [-1,2] x [-1,2] x [-1,2].
Point p0(-1, -1, -1);
Point p1(2, 2, 2);
BoxMesh mesh(MPI_COMM_WORLD, p0, p1, 8, 8, 8);
Parameters:
  • comm – (MPI_Comm) MPI communicator
  • p0 – (Point ) First point.
  • p1 – (Point ) Second point.
  • nx – (double) Number of cells in x-direction.
  • ny – (double) Number of cells in y-direction.
  • nz – (double) Number of cells in z-direction.
dolfin::BoxMesh::BoxMesh(const Point &p0, const Point &p1, std::size_t nx, std::size_t ny, std::size_t nz)

Create a uniform finite element Mesh over the rectangular prism spanned by the two _Point_s p0 and p1. The order of the two points is not important in terms of minimum and maximum coordinates.

// Mesh with 8 cells in each direction on the
// set [-1,2] x [-1,2] x [-1,2].
Point p0(-1, -1, -1);
Point p1(2, 2, 2);
BoxMesh mesh(p0, p1, 8, 8, 8);
Parameters:
  • p0 – (Point ) First point.
  • p1 – (Point ) Second point.
  • nx – (double) Number of cells in x-direction.
  • ny – (double) Number of cells in y-direction.
  • nz – (double) Number of cells in z-direction.
void dolfin::BoxMesh::build(const Point &p0, const Point &p1, std::size_t nx, std::size_t ny, std::size_t nz)
Parameters:
  • p0
  • p1
  • nx
  • ny
  • nz
IntervalMesh

C++ documentation for IntervalMesh from dolfin/generation/IntervalMesh.h:

class dolfin::IntervalMesh : public dolfin::Mesh

Interval mesh of the 1D line [a,b]. Given the number of cells (nx) in the axial direction, the total number of intervals will be nx and the total number of vertices will be (nx + 1).

dolfin::IntervalMesh::IntervalMesh(MPI_Comm comm, std::size_t nx, double a, double b)

Constructor

// Create a mesh of 25 cells in the interval [-1,1]
IntervalMesh mesh(MPI_COMM_WORLD, 25, -1.0, 1.0);
Parameters:
  • comm – (MPI_Comm) MPI communicator
  • nx – (std::size_t) The number of cells.
  • a – (double) The minimum point (inclusive).
  • b – (double) The maximum point (inclusive).
dolfin::IntervalMesh::IntervalMesh(std::size_t nx, double a, double b)

Constructor

// Create a mesh of 25 cells in the interval [-1,1]
IntervalMesh mesh(25, -1.0, 1.0);
Parameters:
  • nx – (std::size_t) The number of cells.
  • a – (double) The minimum point (inclusive).
  • b – (double) The maximum point (inclusive).
void dolfin::IntervalMesh::build(std::size_t nx, double a, double b)
Parameters:
  • nx
  • a
  • b
RectangleMesh

C++ documentation for RectangleMesh from dolfin/generation/RectangleMesh.h:

class dolfin::RectangleMesh : public dolfin::Mesh

Triangular mesh of the 2D rectangle spanned by two points p0 and p1. Given the number of cells (nx, ny) in each direction, the total number of triangles will be 2*nx*ny and the total number of vertices will be (nx + 1)*(ny + 1).

dolfin::RectangleMesh::RectangleMesh(MPI_Comm comm, const Point &p0, const Point &p1, std::size_t nx, std::size_t ny, std::string diagonal = "right")
// Mesh with 8 cells in each direction on the
// set [-1,2] x [-1,2]
Point p0(-1, -1);
Point p1(2, 2);
RectangleMesh mesh(MPI_COMM_WORLD, p0, p1, 8, 8);
Parameters:
  • comm – (MPI_Comm) MPI communicator
  • p0 – (Point ) First point.
  • p1 – (Point ) Second point.
  • nx – (double) Number of cells in \(x\) -direction.
  • ny – (double) Number of cells in \(y\) -direction.
  • diagonal – (string) Direction of diagonals: “left”, “right”, “left/right”, “crossed”
dolfin::RectangleMesh::RectangleMesh(const Point &p0, const Point &p1, std::size_t nx, std::size_t ny, std::string diagonal = "right")
// Mesh with 8 cells in each direction on the
// set [-1,2] x [-1,2]
Point p0(-1, -1);
Point p1(2, 2);
RectangleMesh mesh(p0, p1, 8, 8);
Parameters:
  • p0 – (Point ) First point.
  • p1 – (Point ) Second point.
  • nx – (double) Number of cells in \(x\) -direction.
  • ny – (double) Number of cells in \(y\) -direction.
  • diagonal – (string) Direction of diagonals: “left”, “right”, “left/right”, “crossed”
void dolfin::RectangleMesh::build(const Point &p0, const Point &p1, std::size_t nx, std::size_t ny, std::string diagonal = "right")
Parameters:
  • p0
  • p1
  • nx
  • ny
  • diagonal
SphericalShellMesh

C++ documentation for SphericalShellMesh from dolfin/generation/SphericalShellMesh.h:

class dolfin::SphericalShellMesh : public dolfin::Mesh

Spherical shell approximation, icosahedral mesh, with degree=1 or degree=2.

dolfin::SphericalShellMesh::SphericalShellMesh(MPI_Comm comm, std::size_t degree)

Create a spherical shell manifold for testing.

Parameters:
  • comm
  • degree
UnitCubeMesh

C++ documentation for UnitCubeMesh from dolfin/generation/UnitCubeMesh.h:

class dolfin::UnitCubeMesh : public dolfin::BoxMesh

Tetrahedral mesh of the 3D unit cube [0,1] x [0,1] x [0,1]. Given the number of cells (nx, ny, nz) in each direction, the total number of tetrahedra will be 6*nx*ny*nz and the total number of vertices will be (nx + 1)*(ny + 1)*(nz + 1).

dolfin::UnitCubeMesh::UnitCubeMesh(MPI_Comm comm, std::size_t nx, std::size_t ny, std::size_t nz)

Create a uniform finite element Mesh over the unit cube [0,1] x [0,1] x [0,1].

UnitCubeMesh mesh(MPI_COMM_WORLD, 32, 32, 32);
Parameters:
  • comm – (MPI_Comm) MPI communicator
  • nx – (std::size_t) Number of cells in \(x\) direction.
  • ny – (std::size_t) Number of cells in \(y\) direction.
  • nz – (std::size_t) Number of cells in \(z\) direction.
dolfin::UnitCubeMesh::UnitCubeMesh(std::size_t nx, std::size_t ny, std::size_t nz)

Create a uniform finite element Mesh over the unit cube [0,1] x [0,1] x [0,1].

UnitCubeMesh mesh(32, 32, 32);
Parameters:
  • nx – (std::size_t) Number of cells in \(x\) direction.
  • ny – (std::size_t) Number of cells in \(y\) direction.
  • nz – (std::size_t) Number of cells in \(z\) direction.
UnitDiscMesh

C++ documentation for UnitDiscMesh from dolfin/generation/UnitDiscMesh.h:

class dolfin::UnitDiscMesh : public dolfin::Mesh

A unit disc mesh in 2D or 3D geometry.

dolfin::UnitDiscMesh::UnitDiscMesh(MPI_Comm comm, std::size_t n, std::size_t degree, std::size_t gdim)

Create a unit disc mesh in 2D or 3D geometry with n steps, and given degree polynomial mesh

Parameters:
  • comm
  • n
  • degree
  • gdim
UnitHexMesh

C++ documentation for UnitHexMesh from dolfin/generation/UnitHexMesh.h:

class dolfin::UnitHexMesh : public dolfin::Mesh

NB: this code is experimental, just for testing, and will generally not work with anything else

dolfin::UnitHexMesh::UnitHexMesh(MPI_Comm comm, std::size_t nx, std::size_t ny, std::size_t nz)

NB: this code is experimental, just for testing, and will generally not work with anything else

Parameters:
  • comm
  • nx
  • ny
  • nz
UnitIntervalMesh

C++ documentation for UnitIntervalMesh from dolfin/generation/UnitIntervalMesh.h:

class dolfin::UnitIntervalMesh : public dolfin::IntervalMesh

A mesh of the unit interval (0, 1) with a given number of cells (nx) in the axial direction. The total number of intervals will be nx and the total number of vertices will be (nx + 1).

dolfin::UnitIntervalMesh::UnitIntervalMesh(MPI_Comm comm, std::size_t nx)

Constructor

// Create a mesh of 25 cells in the interval [0,1]
UnitIntervalMesh mesh(MPI_COMM_WORLD, 25);
Parameters:
  • comm – (MPI_Comm) MPI communicator
  • nx – (std::size_t) The number of cells.
dolfin::UnitIntervalMesh::UnitIntervalMesh(std::size_t nx)

Constructor

// Create a mesh of 25 cells in the interval [0,1]
UnitIntervalMesh mesh(25);
Parameters:nx – (std::size_t) The number of cells.
UnitQuadMesh

C++ documentation for UnitQuadMesh from dolfin/generation/UnitQuadMesh.h:

class dolfin::UnitQuadMesh : public dolfin::Mesh

NB: this code is experimental, just for testing, and will generally not work with anything else

dolfin::UnitQuadMesh::UnitQuadMesh(MPI_Comm comm, std::size_t nx, std::size_t ny)

NB: this code is experimental, just for testing, and will generally not work with anything else

Parameters:
  • comm
  • nx
  • ny
UnitSquareMesh

C++ documentation for UnitSquareMesh from dolfin/generation/UnitSquareMesh.h:

class dolfin::UnitSquareMesh : public dolfin::RectangleMesh

Triangular mesh of the 2D unit square [0,1] x [0,1]. Given the number of cells (nx, ny) in each direction, the total number of triangles will be 2*nx*ny and the total number of vertices will be (nx + 1)*(ny + 1). std::string diagonal (“left”, “right”, “right/left”, “left/right”, or “crossed”) indicates the direction of the diagonals.

dolfin::UnitSquareMesh::UnitSquareMesh(MPI_Comm comm, std::size_t nx, std::size_t ny, std::string diagonal = "right")

Create a uniform finite element Mesh over the unit square [0,1] x [0,1].

UnitSquareMesh mesh1(MPI_COMM_WORLD, 32, 32);
UnitSquareMesh mesh2(MPI_COMM_WORLD, 32, 32, "crossed");
Parameters:
  • comm – (MPI_Comm) MPI communicator
  • nx – (std::size_t) Number of cells in horizontal direction.
  • ny – (std::size_t) Number of cells in vertical direction.
  • diagonal – (std::string) Optional argument: A std::string indicating the direction of the diagonals.
dolfin::UnitSquareMesh::UnitSquareMesh(std::size_t nx, std::size_t ny, std::string diagonal = "right")

Create a uniform finite element Mesh over the unit square [0,1] x [0,1].

UnitSquareMesh mesh1(32, 32);
UnitSquareMesh mesh2(32, 32, "crossed");
Parameters:
  • nx – (std::size_t) Number of cells in horizontal direction.
  • ny – (std::size_t) Number of cells in vertical direction.
  • diagonal – (std::string) Optional argument: A std::string indicating the direction of the diagonals.
UnitTetrahedronMesh

C++ documentation for UnitTetrahedronMesh from dolfin/generation/UnitTetrahedronMesh.h:

class dolfin::UnitTetrahedronMesh : public dolfin::Mesh

A mesh consisting of a single tetrahedron with vertices at (0, 0, 0) (1, 0, 0) (0, 1, 0) (0, 0, 1) This class is useful for testing.

dolfin::UnitTetrahedronMesh::UnitTetrahedronMesh()

Create mesh of unit tetrahedron.

UnitTriangleMesh

C++ documentation for UnitTriangleMesh from dolfin/generation/UnitTriangleMesh.h:

class dolfin::UnitTriangleMesh : public dolfin::Mesh

A mesh consisting of a single triangle with vertices at (0, 0) (1, 0) (0, 1) This class is useful for testing.

dolfin::UnitTriangleMesh::UnitTriangleMesh()

Create mesh of unit triangle.

dolfin/geometry

Documentation for C++ code found in dolfin/geometry/*.h

Functions

intersect

C++ documentation for intersect from dolfin/geometry/intersect.h:

std::shared_ptr<const MeshPointIntersection> dolfin::intersect(const Mesh &mesh, const Point &point)

Compute and return intersection between Mesh and Point . Arguments mesh (Mesh ) The mesh to be intersected. point (Point ) The point to be intersected. Returns:cpp:any:MeshPointIntersection The intersection data.

Parameters:
  • mesh
  • point
operator*

C++ documentation for operator* from dolfin/geometry/Point.h:

Point dolfin::operator*(double a, const Point &p)

Multiplication with scalar.

Parameters:
  • a
  • p
operator<<

C++ documentation for operator<< from dolfin/geometry/Point.h:

std::ostream &dolfin::operator<<(std::ostream &stream, const Point &point)

Output of Point to stream.

Parameters:
  • stream
  • point

Classes

BoundingBoxTree

C++ documentation for BoundingBoxTree from dolfin/geometry/BoundingBoxTree.h:

class dolfin::BoundingBoxTree

This class implements a (distributed) axis aligned bounding box tree (AABB tree). Bounding box trees can be created from meshes and [other data structures, to be filled in].

dolfin::BoundingBoxTree::BoundingBoxTree()

Create empty bounding box tree.

void dolfin::BoundingBoxTree::build(const Mesh &mesh)

Build bounding box tree for cells of mesh. Arguments mesh (Mesh ) The mesh for which to compute the bounding box tree.

Parameters:mesh
void dolfin::BoundingBoxTree::build(const Mesh &mesh, std::size_t tdim)

Build bounding box tree for mesh entities of given dimension. Arguments mesh (Mesh ) The mesh for which to compute the bounding box tree. dimension (std::size_t) The entity dimension (topological dimension) for which to compute the bounding box tree.

Parameters:
  • mesh
  • tdim
void dolfin::BoundingBoxTree::build(const std::vector<Point> &points, std::size_t gdim)

Build bounding box tree for point cloud. Arguments points (std::vector<Point >) The list of points. gdim (std::size_t) The geometric dimension.

Parameters:
  • points
  • gdim
bool dolfin::BoundingBoxTree::collides(const Point &point) const

Check whether given point collides with the bounding box tree. This is equivalent to calling compute_first_collision and checking whether any collision was detected. Returns bool True iff the point is inside the tree.

Parameters:point
bool dolfin::BoundingBoxTree::collides_entity(const Point &point) const

Check whether given point collides with any entity contained in the bounding box tree. This is equivalent to calling compute_first_entity_collision and checking whether any collision was detected. Returns bool True iff the point is inside the tree.

Parameters:point
std::pair<unsigned int, double> dolfin::BoundingBoxTree::compute_closest_entity(const Point &point) const

Compute closest entity to Point . Returns unsigned int The local index for the entity that is closest to the point. If more than one entity is at the same distance (or point contained in entity), then the first entity is returned. double The distance to the closest entity. Arguments point (Point ) The point.

Parameters:point
std::pair<unsigned int, double> dolfin::BoundingBoxTree::compute_closest_point(const Point &point) const

Compute closest point to Point . This function assumes that the tree has been built for a point cloud. Developer note: This function should not be confused with computing the closest point in all entities of a mesh. That function could be added with relative ease since we actually compute the closest points to get the distance in the above function (compute_closest_entity) inside the specialized implementations in TetrahedronCell.cpp etc. Returns unsigned int The local index for the point that is closest to the point. If more than one point is at the same distance (or point contained in entity), then the first point is returned. double The distance to the closest point. Arguments point (Point ) The point.

Parameters:point
std::pair<std::vector<unsigned int>, std::vector<unsigned int>> dolfin::BoundingBoxTree::compute_collisions(const BoundingBoxTree &tree) const

Compute all collisions between bounding boxes and BoundingBoxTree . Returns std::vector<unsigned int> A list of local indices for entities in this tree that collide with (intersect) entities in other tree. std::vector<unsigned int> A list of local indices for entities in other tree that collide with (intersect) entities in this tree. The two lists have equal length and contain matching entities, such that entity i in the first list collides with entity i in the second list. Note that this means that the entity lists may contain duplicate entities since a single entity may collide with several different entities. Arguments tree (BoundingBoxTree ) The bounding box tree. Note that this function only checks collisions between bounding boxes of entities. It does not check that the entities themselves actually collide. To compute entity collisions, use the function compute_entity_collisions.

Parameters:tree
std::vector<unsigned int> dolfin::BoundingBoxTree::compute_collisions(const Point &point) const

Compute all collisions between bounding boxes and Point . Returns std::vector<unsigned int> A list of local indices for entities contained in (leaf) bounding boxes that collide with (intersect) the given point. Arguments point (Point ) The point.

Parameters:point
std::pair<std::vector<unsigned int>, std::vector<unsigned int>> dolfin::BoundingBoxTree::compute_entity_collisions(const BoundingBoxTree &tree) const

Compute all collisions between entities and BoundingBoxTree . Returns std::vector<unsigned int> A list of local indices for entities in this tree that collide with (intersect) entities in other tree. std::vector<unsigned int> A list of local indices for entities in other tree that collide with (intersect) entities in this tree. The two lists have equal length and contain matching entities, such that entity i in the first list collides with entity i in the second list. Note that this means that the entity lists may contain duplicate entities since a single entity may collide with several different entities. Arguments tree (BoundingBoxTree ) The bounding box tree.

Parameters:tree
std::vector<unsigned int> dolfin::BoundingBoxTree::compute_entity_collisions(const Point &point) const

Compute all collisions between entities and Point . Returns std::vector<unsigned int> A list of local indices for entities that collide with (intersect) the given point. Arguments point (Point ) The point.

Parameters:point
unsigned int dolfin::BoundingBoxTree::compute_first_collision(const Point &point) const

Compute first collision between bounding boxes and Point . Returns unsigned int The local index for the first found entity contained in a (leaf) bounding box that collides with (intersects) the given point. If not found, std::numeric_limits<unsigned int>::max() is returned. Arguments point (Point ) The point.

Parameters:point
unsigned int dolfin::BoundingBoxTree::compute_first_entity_collision(const Point &point) const

Compute first collision between entities and Point . Returns unsigned int The local index for the first found entity that collides with (intersects) the given point. If not found, std::numeric_limits<unsigned int>::max() is returned. Arguments point (Point ) The point.

Parameters:point
std::vector<unsigned int> dolfin::BoundingBoxTree::compute_process_collisions(const Point &point) const

Compute all collisions between process bounding boxes and Point . Effectively a list of processes which may contain the Point . Returns std::vector<unsigned int> A list of process numbers where the Mesh may collide with (intersect) the given point. Arguments point (Point ) The point.

Parameters:point
dolfin::BoundingBoxTree::~BoundingBoxTree()

Destructor.

BoundingBoxTree1D

C++ documentation for BoundingBoxTree1D from dolfin/geometry/BoundingBoxTree1D.h:

class dolfin::BoundingBoxTree1D

Specialization of bounding box implementation to 1D.

bool dolfin::BoundingBoxTree1D::bbox_in_bbox(const double *a, unsigned int node) const

Check whether bounding box (a) collides with bounding box (node)

Parameters:
  • a
  • node
void dolfin::BoundingBoxTree1D::compute_bbox_of_bboxes(double *bbox, std::size_t &axis, const std::vector<double> &leaf_bboxes, const std::vector<unsigned int>::iterator &begin, const std::vector<unsigned int>::iterator &end)

Compute bounding box of bounding boxes.

Parameters:
  • bbox
  • axis
  • leaf_bboxes
  • begin
  • end
void dolfin::BoundingBoxTree1D::compute_bbox_of_points(double *bbox, std::size_t &axis, const std::vector<Point> &points, const std::vector<unsigned int>::iterator &begin, const std::vector<unsigned int>::iterator &end)

Compute bounding box of points.

Parameters:
  • bbox
  • axis
  • points
  • begin
  • end
double dolfin::BoundingBoxTree1D::compute_squared_distance_bbox(const double *x, unsigned int node) const

Compute squared distance between point and bounding box.

Parameters:
  • x
  • node
double dolfin::BoundingBoxTree1D::compute_squared_distance_point(const double *x, unsigned int node) const

Compute squared distance between point and point.

Parameters:
  • x
  • node
std::size_t dolfin::BoundingBoxTree1D::gdim() const

Return geometric dimension.

const double *dolfin::BoundingBoxTree1D::get_bbox_coordinates(unsigned int node) const

Return bounding box coordinates for node.

Parameters:node
bool dolfin::BoundingBoxTree1D::point_in_bbox(const double *x, unsigned int node) const

Check whether point (x) is in bounding box (node)

Parameters:
  • x
  • node
void dolfin::BoundingBoxTree1D::sort_bboxes(std::size_t axis, const std::vector<double> &leaf_bboxes, const std::vector<unsigned int>::iterator &begin, const std::vector<unsigned int>::iterator &middle, const std::vector<unsigned int>::iterator &end)

Sort leaf bounding boxes along given axis.

Parameters:
  • axis
  • leaf_bboxes
  • begin
  • middle
  • end
BoundingBoxTree2D

C++ documentation for BoundingBoxTree2D from dolfin/geometry/BoundingBoxTree2D.h:

class dolfin::BoundingBoxTree2D

Specialization of bounding box implementation to 2D.

bool dolfin::BoundingBoxTree2D::bbox_in_bbox(const double *a, unsigned int node) const

Check whether bounding box (a) collides with bounding box (node)

Parameters:
  • a
  • node
void dolfin::BoundingBoxTree2D::compute_bbox_of_bboxes(double *bbox, std::size_t &axis, const std::vector<double> &leaf_bboxes, const std::vector<unsigned int>::iterator &begin, const std::vector<unsigned int>::iterator &end)

Compute bounding box of bounding boxes.

Parameters:
  • bbox
  • axis
  • leaf_bboxes
  • begin
  • end
void dolfin::BoundingBoxTree2D::compute_bbox_of_points(double *bbox, std::size_t &axis, const std::vector<Point> &points, const std::vector<unsigned int>::iterator &begin, const std::vector<unsigned int>::iterator &end)

Compute bounding box of points.

Parameters:
  • bbox
  • axis
  • points
  • begin
  • end
double dolfin::BoundingBoxTree2D::compute_squared_distance_bbox(const double *x, unsigned int node) const

Compute squared distance between point and bounding box.

Parameters:
  • x
  • node
double dolfin::BoundingBoxTree2D::compute_squared_distance_point(const double *x, unsigned int node) const

Compute squared distance between point and point.

Parameters:
  • x
  • node
std::size_t dolfin::BoundingBoxTree2D::gdim() const

Return geometric dimension.

const double *dolfin::BoundingBoxTree2D::get_bbox_coordinates(unsigned int node) const

Return bounding box coordinates for node.

Parameters:node
bool dolfin::BoundingBoxTree2D::point_in_bbox(const double *x, unsigned int node) const

Check whether point (x) is in bounding box (node)

Parameters:
  • x
  • node
void dolfin::BoundingBoxTree2D::sort_bboxes(std::size_t axis, const std::vector<double> &leaf_bboxes, const std::vector<unsigned int>::iterator &begin, const std::vector<unsigned int>::iterator &middle, const std::vector<unsigned int>::iterator &end)

Sort leaf bounding boxes along given axis.

Parameters:
  • axis
  • leaf_bboxes
  • begin
  • middle
  • end
BoundingBoxTree3D

C++ documentation for BoundingBoxTree3D from dolfin/geometry/BoundingBoxTree3D.h:

class dolfin::BoundingBoxTree3D

Specialization of bounding box implementation to 3D.

bool dolfin::BoundingBoxTree3D::bbox_in_bbox(const double *a, unsigned int node) const

Check whether bounding box (a) collides with bounding box (node)

Parameters:
  • a
  • node
void dolfin::BoundingBoxTree3D::compute_bbox_of_bboxes(double *bbox, std::size_t &axis, const std::vector<double> &leaf_bboxes, const std::vector<unsigned int>::iterator &begin, const std::vector<unsigned int>::iterator &end)

Compute bounding box of bounding boxes.

Parameters:
  • bbox
  • axis
  • leaf_bboxes
  • begin
  • end
void dolfin::BoundingBoxTree3D::compute_bbox_of_points(double *bbox, std::size_t &axis, const std::vector<Point> &points, const std::vector<unsigned int>::iterator &begin, const std::vector<unsigned int>::iterator &end)

Compute bounding box of points.

Parameters:
  • bbox
  • axis
  • points
  • begin
  • end
double dolfin::BoundingBoxTree3D::compute_squared_distance_bbox(const double *x, unsigned int node) const

Compute squared distance between point and bounding box.

Parameters:
  • x
  • node
double dolfin::BoundingBoxTree3D::compute_squared_distance_point(const double *x, unsigned int node) const

Compute squared distance between point and point.

Parameters:
  • x
  • node
std::size_t dolfin::BoundingBoxTree3D::gdim() const

Return geometric dimension.

const double *dolfin::BoundingBoxTree3D::get_bbox_coordinates(unsigned int node) const

Return bounding box coordinates for node.

Parameters:node
bool dolfin::BoundingBoxTree3D::point_in_bbox(const double *x, const unsigned int node) const

Check whether point (x) is in bounding box (node)

Parameters:
  • x
  • node
void dolfin::BoundingBoxTree3D::sort_bboxes(std::size_t axis, const std::vector<double> &leaf_bboxes, const std::vector<unsigned int>::iterator &begin, const std::vector<unsigned int>::iterator &middle, const std::vector<unsigned int>::iterator &end)

Sort leaf bounding boxes along given axis.

Parameters:
  • axis
  • leaf_bboxes
  • begin
  • middle
  • end
CollisionDetection

C++ documentation for CollisionDetection from dolfin/geometry/CollisionDetection.h:

class dolfin::CollisionDetection

This class implements algorithms for detecting pairwise collisions between mesh entities of varying dimensions.

bool dolfin::CollisionDetection::collides(const MeshEntity &entity, const Point &point)

Check whether entity collides with point.

Parameters:
Returns:

bool True iff entity collides with cell.

bool dolfin::CollisionDetection::collides(const MeshEntity &entity_0, const MeshEntity &entity_1)

Check whether two entities collide.

Parameters:
Returns:

bool True iff entity collides with cell.

bool dolfin::CollisionDetection::collides_edge_edge(const Point &a, const Point &b, const Point &c, const Point &d)

Check whether edge a-b collides with edge c-d.

Parameters:
  • a
  • b
  • c
  • d
bool dolfin::CollisionDetection::collides_interval_interval(const MeshEntity &interval_0, const MeshEntity &interval_1)

Check whether interval collides with interval.

Parameters:
  • interval_0 – (MeshEntity ) The first interval.
  • interval_1 – (MeshEntity ) The second interval.
Returns:

bool True iff objects collide.

bool dolfin::CollisionDetection::collides_interval_point(const MeshEntity &interval, const Point &point)

Check whether interval collides with point.

Parameters:
Returns:

bool True iff objects collide.

bool dolfin::CollisionDetection::collides_interval_point(const Point &p0, const Point &p1, const Point &point)

The implementation of collides_interval_point.

Parameters:
  • p0
  • p1
  • point
bool dolfin::CollisionDetection::collides_tetrahedron_point(const MeshEntity &tetrahedron, const Point &point)

Check whether tetrahedron collides with point.

Parameters:
  • tetrahedron – (MeshEntity ) The tetrahedron.
  • point – (Point ) The point.
Returns:

bool True iff objects collide.

bool dolfin::CollisionDetection::collides_tetrahedron_point(const Point &p0, const Point &p1, const Point &p2, const Point &p3, const Point &point)

The implementation of collides_tetrahedron_point.

Parameters:
  • p0
  • p1
  • p2
  • p3
  • point
bool dolfin::CollisionDetection::collides_tetrahedron_tetrahedron(const MeshEntity &tetrahedron_0, const MeshEntity &tetrahedron_1)

Check whether tetrahedron collides with tetrahedron.

Parameters:
  • tetrahedron_0 – (MeshEntity ) The first tetrahedron.
  • tetrahedron_1 – (MeshEntity ) The second tetrahedron.
Returns:

bool True iff objects collide.

bool dolfin::CollisionDetection::collides_tetrahedron_triangle(const MeshEntity &tetrahedron, const MeshEntity &triangle)

Check whether tetrahedron collides with triangle.

Parameters:
Returns:

bool True iff objects collide.

bool dolfin::CollisionDetection::collides_tetrahedron_triangle(const Point &p0, const Point &p1, const Point &p2, const Point &p3, const Point &q0, const Point &q1, const Point &q2)
Parameters:
  • p0
  • p1
  • p2
  • p3
  • q0
  • q1
  • q2
bool dolfin::CollisionDetection::collides_triangle_point(const MeshEntity &triangle, const Point &point)

Check whether triangle collides with point.

Parameters:
Returns:

bool True iff objects collide.

bool dolfin::CollisionDetection::collides_triangle_point(const Point &p0, const Point &p1, const Point &p2, const Point &point)

The implementation of collides_triangle_point.

Parameters:
  • p0
  • p1
  • p2
  • point
bool dolfin::CollisionDetection::collides_triangle_point_2d(const Point &p0, const Point &p1, const Point &p2, const Point &point)

Specialised implementation of collides_triangle_point in 2D.

Parameters:
  • p0
  • p1
  • p2
  • point
bool dolfin::CollisionDetection::collides_triangle_triangle(const MeshEntity &triangle_0, const MeshEntity &triangle_1)

Check whether triangle collides with triangle.

Parameters:
  • triangle_0 – (MeshEntity ) The first triangle.
  • triangle_1 – (MeshEntity ) The second triangle.
Returns:

bool True iff objects collide.

bool dolfin::CollisionDetection::collides_triangle_triangle(const Point &p0, const Point &p1, const Point &p2, const Point &q0, const Point &q1, const Point &q2)
Parameters:
  • p0
  • p1
  • p2
  • q0
  • q1
  • q2
bool dolfin::CollisionDetection::compute_intervals(double VV0, double VV1, double VV2, double D0, double D1, double D2, double D0D1, double D0D2, double &A, double &B, double &C, double &X0, double &X1)
Parameters:
  • VV0
  • VV1
  • VV2
  • D0
  • D1
  • D2
  • D0D1
  • D0D2
  • A
  • B
  • C
  • X0
  • X1
bool dolfin::CollisionDetection::coplanar_tri_tri(const Point &N, const Point &V0, const Point &V1, const Point &V2, const Point &U0, const Point &U1, const Point &U2)
Parameters:
  • N
  • V0
  • V1
  • V2
  • U0
  • U1
  • U2
bool dolfin::CollisionDetection::edge_against_tri_edges(int i0, int i1, const Point &V0, const Point &V1, const Point &U0, const Point &U1, const Point &U2)
Parameters:
  • i0
  • i1
  • V0
  • V1
  • U0
  • U1
  • U2
bool dolfin::CollisionDetection::edge_edge_test(int i0, int i1, double Ax, double Ay, const Point &V0, const Point &U0, const Point &U1)
Parameters:
  • i0
  • i1
  • Ax
  • Ay
  • V0
  • U0
  • U1
bool dolfin::CollisionDetection::point_in_tri(int i0, int i1, const Point &V0, const Point &U0, const Point &U1, const Point &U2)
Parameters:
  • i0
  • i1
  • V0
  • U0
  • U1
  • U2
bool dolfin::CollisionDetection::separating_plane_edge_A(const std::vector<std::vector<double>> &coord_1, const std::vector<int> &masks, int f0, int f1)
Parameters:
  • coord_1
  • masks
  • f0
  • f1
bool dolfin::CollisionDetection::separating_plane_face_A_1(const std::vector<Point> &pv1, const Point &n, std::vector<double> &bc, int &mask_edges)
Parameters:
  • pv1
  • n
  • bc
  • mask_edges
bool dolfin::CollisionDetection::separating_plane_face_A_2(const std::vector<Point> &v1, const std::vector<Point> &v2, const Point &n, std::vector<double> &bc, int &mask_edges)
Parameters:
  • v1
  • v2
  • n
  • bc
  • mask_edges
bool dolfin::CollisionDetection::separating_plane_face_B_1(const std::vector<Point> &P_V2, const Point &n)
Parameters:
  • P_V2
  • n
bool dolfin::CollisionDetection::separating_plane_face_B_2(const std::vector<Point> &V1, const std::vector<Point> &V2, const Point &n)
Parameters:
  • V1
  • V2
  • n
GenericBoundingBoxTree

C++ documentation for GenericBoundingBoxTree from dolfin/geometry/GenericBoundingBoxTree.h:

class dolfin::GenericBoundingBoxTree

Base class for bounding box implementations (envelope-letter design)

dolfin::GenericBoundingBoxTree::GenericBoundingBoxTree()

Constructor.

unsigned int dolfin::GenericBoundingBoxTree::add_bbox(const BBox &bbox, const double *b, std::size_t gdim)

Add bounding box and coordinates.

Parameters:
  • bbox
  • b
  • gdim
unsigned int dolfin::GenericBoundingBoxTree::add_point(const BBox &bbox, const Point &point, std::size_t gdim)

Add bounding box and point coordinates.

Parameters:
  • bbox
  • point
  • gdim
bool dolfin::GenericBoundingBoxTree::bbox_in_bbox(const double *a, unsigned int node) const = 0

Check whether bounding box (a) collides with bounding box (node)

Parameters:
  • a
  • node
void dolfin::GenericBoundingBoxTree::build(const Mesh &mesh, std::size_t tdim)

Build bounding box tree for mesh entities of given dimension.

Parameters:
  • mesh
  • tdim
void dolfin::GenericBoundingBoxTree::build(const std::vector<Point> &points)

Build bounding box tree for point cloud.

Parameters:points
void dolfin::GenericBoundingBoxTree::build_point_search_tree(const Mesh &mesh) const

Compute point search tree if not already done.

Parameters:mesh
void dolfin::GenericBoundingBoxTree::clear()

Clear existing data if any.

void dolfin::GenericBoundingBoxTree::compute_bbox_of_bboxes(double *bbox, std::size_t &axis, const std::vector<double> &leaf_bboxes, const std::vector<unsigned int>::iterator &begin, const std::vector<unsigned int>::iterator &end) = 0

Compute bounding box of bounding boxes.

Parameters:
  • bbox
  • axis
  • leaf_bboxes
  • begin
  • end
void dolfin::GenericBoundingBoxTree::compute_bbox_of_entity(double *b, const MeshEntity &entity, std::size_t gdim) const

Compute bounding box of mesh entity.

Parameters:
  • b
  • entity
  • gdim
void dolfin::GenericBoundingBoxTree::compute_bbox_of_points(double *bbox, std::size_t &axis, const std::vector<Point> &points, const std::vector<unsigned int>::iterator &begin, const std::vector<unsigned int>::iterator &end) = 0

Compute bounding box of points.

Parameters:
  • bbox
  • axis
  • points
  • begin
  • end
std::pair<unsigned int, double> dolfin::GenericBoundingBoxTree::compute_closest_entity(const Point &point, const Mesh &mesh) const

Compute closest entity and distance to Point

Parameters:
  • point
  • mesh
std::pair<unsigned int, double> dolfin::GenericBoundingBoxTree::compute_closest_point(const Point &point) const

Compute closest point and distance to Point

Parameters:point
std::pair<std::vector<unsigned int>, std::vector<unsigned int>> dolfin::GenericBoundingBoxTree::compute_collisions(const GenericBoundingBoxTree &tree) const

Compute all collisions between bounding boxes and BoundingBoxTree

Parameters:tree
std::vector<unsigned int> dolfin::GenericBoundingBoxTree::compute_collisions(const Point &point) const

Compute all collisions between bounding boxes and Point

Parameters:point
std::pair<std::vector<unsigned int>, std::vector<unsigned int>> dolfin::GenericBoundingBoxTree::compute_entity_collisions(const GenericBoundingBoxTree &tree, const Mesh &mesh_A, const Mesh &mesh_B) const

Compute all collisions between entities and BoundingBoxTree

Parameters:
  • tree
  • mesh_A
  • mesh_B
std::vector<unsigned int> dolfin::GenericBoundingBoxTree::compute_entity_collisions(const Point &point, const Mesh &mesh) const

Compute all collisions between entities and Point

Parameters:
  • point
  • mesh
unsigned int dolfin::GenericBoundingBoxTree::compute_first_collision(const Point &point) const

Compute first collision between bounding boxes and Point

Parameters:point
unsigned int dolfin::GenericBoundingBoxTree::compute_first_entity_collision(const Point &point, const Mesh &mesh) const

Compute first collision between entities and Point

Parameters:
  • point
  • mesh
std::vector<unsigned int> dolfin::GenericBoundingBoxTree::compute_process_collisions(const Point &point) const

Compute all collisions between processes and Point

Parameters:point
double dolfin::GenericBoundingBoxTree::compute_squared_distance_bbox(const double *x, unsigned int node) const = 0

Compute squared distance between point and bounding box.

Parameters:
  • x
  • node
double dolfin::GenericBoundingBoxTree::compute_squared_distance_point(const double *x, unsigned int node) const = 0

Compute squared distance between point and point.

Parameters:
  • x
  • node
std::shared_ptr<GenericBoundingBoxTree> dolfin::GenericBoundingBoxTree::create(unsigned int dim)

Factory function returning (empty) tree of appropriate dimension.

Parameters:dim
std::size_t dolfin::GenericBoundingBoxTree::gdim() const = 0

Return geometric dimension.

const BBox &dolfin::GenericBoundingBoxTree::get_bbox(unsigned int node) const

Return bounding box for given node.

Parameters:node
const double *dolfin::GenericBoundingBoxTree::get_bbox_coordinates(unsigned int node) const = 0

Return bounding box coordinates for node.

Parameters:node
bool dolfin::GenericBoundingBoxTree::is_leaf(const BBox &bbox, unsigned int node) const

Check whether bounding box is a leaf node.

Parameters:
  • bbox
  • node
unsigned int dolfin::GenericBoundingBoxTree::num_bboxes() const

Return number of bounding boxes.

bool dolfin::GenericBoundingBoxTree::point_in_bbox(const double *x, unsigned int node) const = 0

Check whether point (x) is in bounding box (node)

Parameters:
  • x
  • node
void dolfin::GenericBoundingBoxTree::sort_bboxes(std::size_t axis, const std::vector<double> &leaf_bboxes, const std::vector<unsigned int>::iterator &begin, const std::vector<unsigned int>::iterator &middle, const std::vector<unsigned int>::iterator &end) = 0

Sort leaf bounding boxes along given axis.

Parameters:
  • axis
  • leaf_bboxes
  • begin
  • middle
  • end
void dolfin::GenericBoundingBoxTree::sort_points(std::size_t axis, const std::vector<Point> &points, const std::vector<unsigned int>::iterator &begin, const std::vector<unsigned int>::iterator &middle, const std::vector<unsigned int>::iterator &end)

Sort points along given axis.

Parameters:
  • axis
  • points
  • begin
  • middle
  • end
std::string dolfin::GenericBoundingBoxTree::str(bool verbose = false)

Print out for debugging.

Parameters:verbose
void dolfin::GenericBoundingBoxTree::tree_print(std::stringstream &s, unsigned int i)

Print out recursively, for debugging.

Parameters:
  • s
  • i
dolfin::GenericBoundingBoxTree::~GenericBoundingBoxTree()

Destructor.

IntersectionTriangulation

C++ documentation for IntersectionTriangulation from dolfin/geometry/IntersectionTriangulation.h:

class dolfin::IntersectionTriangulation

This class implements algorithms for computing triangulations of pairwise intersections of simplices.

bool dolfin::IntersectionTriangulation::intersection_edge_edge(const Point &a, const Point &b, const Point &c, const Point &d, Point &pt)
Parameters:
  • a
  • b
  • c
  • d
  • pt
bool dolfin::IntersectionTriangulation::intersection_face_edge(const Point &r, const Point &s, const Point &t, const Point &a, const Point &b, Point &pt)
Parameters:
  • r
  • s
  • t
  • a
  • b
  • pt
void dolfin::IntersectionTriangulation::triangulate_intersection(const MeshEntity &cell, const std::vector<double> &triangulation, const std::vector<Point> &normals, std::vector<double> &intersection_triangulation, std::vector<Point> &intersection_normals, std::size_t tdim)

Function for computing the intersection of a cell with a flat vector of simplices with topological dimension tdim. The geometrical dimension is assumed to be the same as for the cell. The corresponding normals are also saved.

Parameters:
  • cell
  • triangulation
  • normals
  • intersection_triangulation
  • intersection_normals
  • tdim
std::vector<double> dolfin::IntersectionTriangulation::triangulate_intersection(const MeshEntity &cell, const std::vector<double> &triangulation, std::size_t tdim)

Function for computing the intersection of a cell with a flat vector of simplices with topological dimension tdim. The geometrical dimension is assumed to be the same as for the cell.

Parameters:
  • cell
  • triangulation
  • tdim
std::vector<double> dolfin::IntersectionTriangulation::triangulate_intersection(const MeshEntity &entity_0, const MeshEntity &entity_1)

Compute triangulation of intersection of two entities

Parameters:
Returns:

std::vector<double> A flattened array of simplices of dimension num_simplices x num_vertices x gdim = num_simplices x (tdim + 1) x gdim

std::vector<double> dolfin::IntersectionTriangulation::triangulate_intersection(const std::vector<Point> &s0, std::size_t tdim0, const std::vector<Point> &s1, std::size_t tdim1, std::size_t gdim)

Function for general intersection computation of two simplices with different topological dimension but the same geometrical dimension

Parameters:
  • s0
  • tdim0
  • s1
  • tdim1
  • gdim
std::vector<double> dolfin::IntersectionTriangulation::triangulate_intersection_interval_interval(const MeshEntity &interval_0, const MeshEntity &interval_1)

Compute triangulation of intersection of two intervals

Parameters:
  • interval_0 – (MeshEntity ) The first interval.
  • interval_1 – (MeshEntity ) The second interval.
Returns:

std::vector<double> A flattened array of simplices of dimension num_simplices x num_vertices x gdim = num_simplices x (tdim + 1) x gdim

std::vector<double> dolfin::IntersectionTriangulation::triangulate_intersection_interval_interval(const std::vector<Point> &interval_0, const std::vector<Point> &interval_1, std::size_t gdim)
Parameters:
  • interval_0
  • interval_1
  • gdim
std::vector<double> dolfin::IntersectionTriangulation::triangulate_intersection_tetrahedron_tetrahedron(const MeshEntity &tetrahedron_0, const MeshEntity &tetrahedron_1)

Compute triangulation of intersection of two tetrahedra

Parameters:
  • tetrahedron_0 – (MeshEntity ) The first tetrahedron.
  • tetrahedron_1 – (MeshEntity ) The second tetrahedron.
Returns:

std::vector<double> A flattened array of simplices of dimension num_simplices x num_vertices x gdim = num_simplices x (tdim + 1) x gdim

std::vector<double> dolfin::IntersectionTriangulation::triangulate_intersection_tetrahedron_tetrahedron(const std::vector<Point> &tet_0, const std::vector<Point> &tet_1)
Parameters:
  • tet_0
  • tet_1
std::vector<double> dolfin::IntersectionTriangulation::triangulate_intersection_tetrahedron_triangle(const MeshEntity &tetrahedron, const MeshEntity &triangle)

Compute triangulation of intersection of a tetrahedron and a triangle

Parameters:
Returns:

std::vector<double> A flattened array of simplices of dimension num_simplices x num_vertices x gdim = num_simplices x (tdim + 1) x gdim

std::vector<double> dolfin::IntersectionTriangulation::triangulate_intersection_tetrahedron_triangle(const std::vector<Point> &tet, const std::vector<Point> &tri)
Parameters:
  • tet
  • tri
std::vector<double> dolfin::IntersectionTriangulation::triangulate_intersection_triangle_interval(const MeshEntity &triangle, const MeshEntity &interval)

Compute triangulation of intersection of a triangle and an interval

Parameters:
Returns:

std::vector<double> A flattened array of simplices of dimension num_simplices x num_vertices x gdim = num_simplices x (tdim + 1) x gdim

std::vector<double> dolfin::IntersectionTriangulation::triangulate_intersection_triangle_interval(const std::vector<Point> &triangle, const std::vector<Point> &interval, std::size_t gdim)
Parameters:
  • triangle
  • interval
  • gdim
std::vector<double> dolfin::IntersectionTriangulation::triangulate_intersection_triangle_triangle(const MeshEntity &triangle_0, const MeshEntity &triangle_1)

Compute triangulation of intersection of two triangles

Parameters:
  • triangle_0 – (MeshEntity ) The first triangle.
  • triangle_1 – (MeshEntity ) The second triangle.
Returns:

std::vector<double> A flattened array of simplices of dimension num_simplices x num_vertices x gdim = num_simplices x (tdim + 1) x gdim

std::vector<double> dolfin::IntersectionTriangulation::triangulate_intersection_triangle_triangle(const std::vector<Point> &tri_0, const std::vector<Point> &tri_1)
Parameters:
  • tri_0
  • tri_1
MeshPointIntersection

C++ documentation for MeshPointIntersection from dolfin/geometry/MeshPointIntersection.h:

class dolfin::MeshPointIntersection

This class represents an intersection between a Mesh and a Point . The resulting intersection is stored as a list of zero or more cells.

dolfin::MeshPointIntersection::MeshPointIntersection(const Mesh &mesh, const Point &point)

Compute intersection between mesh and point.

Parameters:
  • mesh
  • point
const std::vector<unsigned int> &dolfin::MeshPointIntersection::intersected_cells() const

Return the list of (local) indices for intersected cells.

dolfin::MeshPointIntersection::~MeshPointIntersection()

Destructor.

Point

C++ documentation for Point from dolfin/geometry/Point.h:

class dolfin::Point

A Point represents a point in \(\mathbb{R}^3\) with coordinates \(x, y, z,\) or alternatively, a vector in \(\mathbb{R}^3\) , supporting standard operations like the norm, distances, scalar and vector products etc.

dolfin::Point::Point(const Array<double> &x)

Create point from Array

Parameters:x – (Array<double>) Array of coordinates.
dolfin::Point::Point(const Point &p)

Copy constructor

Parameters:p – (Point() ) The object to be copied.
dolfin::Point::Point(const double x = 0.0, const double y = 0.0, const double z = 0.0)

Create a point at (x, y, z). Default value (0, 0, 0).

Parameters:
  • x – (double) The x-coordinate.
  • y – (double) The y-coordinate.
  • z – (double) The z-coordinate.
dolfin::Point::Point(std::size_t dim, const double *x)

Create point from array

Parameters:
  • dim – (std::size_t) Dimension of the array.
  • x – (double) The array to create a Point() from.
std::array<double, 3> dolfin::Point::array() const

Return copy of coordinate array Returns list of double The coordinates.

double *dolfin::Point::coordinates()

Return coordinate array

Returns:double* The coordinates.
const double *dolfin::Point::coordinates() const

Return coordinate array (const. version)

Returns:double* The coordinates.
const Point dolfin::Point::cross(const Point &p) const

Compute cross product with given vector

Parameters:p – (Point ) Another point.
Returns:Point The cross product.
double dolfin::Point::distance(const Point &p) const

Compute distance to given point

Point p1(0, 4, 0);
Point p2(2, 0, 4);
info("%g", p1.distance(p2));
Parameters:p – (Point ) The point to compute distance to.
Returns:double The distance.
double dolfin::Point::dot(const Point &p) const

Compute dot product with given vector

Point p1(1.0, 4.0, 8.0);
Point p2(2.0, 0.0, 0.0);
info("%g", p1.dot(p2));
Parameters:p – (Point ) Another point.
Returns:double The dot product.
double dolfin::Point::norm() const

Compute norm of point representing a vector from the origin

Point p(1.0, 2.0, 2.0);
info("%g", p.norm());
Returns:double The (Euclidean) norm of the vector from the origin to the point.
Point dolfin::Point::operator*(double a) const

Multiplication with scalar.

Parameters:a
const Point &dolfin::Point::operator*=(double a)

Incremental multiplication with scalar.

Parameters:a
Point dolfin::Point::operator+(const Point &p) const

Compute sum of two points

Parameters:p – (Point )
Returns:Point
const Point &dolfin::Point::operator+=(const Point &p)

Add given point.

Parameters:p
Point dolfin::Point::operator-()

Unary minus.

Point dolfin::Point::operator-(const Point &p) const

Compute difference of two points

Parameters:p – (Point )
Returns:Point
const Point &dolfin::Point::operator-=(const Point &p)

Subtract given point.

Parameters:p
Point dolfin::Point::operator/(double a) const

Division by scalar.

Parameters:a
const Point &dolfin::Point::operator/=(double a)

Incremental division by scalar.

Parameters:a
const Point &dolfin::Point::operator=(const Point &p)

Assignment operator.

Parameters:p
double &dolfin::Point::operator[](std::size_t i)

Return address of coordinate in direction i Returns

Parameters:i – (std::size_t) Direction.
Returns:double Address of coordinate in the given direction.
double dolfin::Point::operator[](std::size_t i) const

Return coordinate in direction i

Parameters:i – (std::size_t) Direction.
Returns:double The coordinate in the given direction.
Point dolfin::Point::rotate(const Point &a, double theta) const

Rotate around a given axis

Parameters:
  • a – (Point ) The axis to rotate around. Must be unit length.
  • theta – (double) The rotation angle.
Returns:

Point The rotated point.

double dolfin::Point::squared_distance(const Point &p) const

Compute squared distance to given point

Parameters:p – (Point ) The point to compute distance to.
Returns:double The squared distance.
double dolfin::Point::squared_norm() const

Compute norm of point representing a vector from the origin

Point p(1.0, 2.0, 2.0);
info("%g", p.squared_norm());
Returns:double The squared (Euclidean) norm of the vector from the origin of the point.
std::string dolfin::Point::str(bool verbose = false) const

Return informal string representation (pretty-print)

Parameters:verbose – (bool) Flag to turn on additional output.
Returns:std::string An informal representation of the function space.
double dolfin::Point::x() const

Return x-coordinate

Returns:double The x-coordinate.
double dolfin::Point::y() const

Return y-coordinate

Returns:double The y-coordinate.
double dolfin::Point::z() const

Return z-coordinate

Returns:double The z-coordinate.
dolfin::Point::~Point()

Destructor.

SimplexQuadrature

C++ documentation for SimplexQuadrature from dolfin/geometry/SimplexQuadrature.h:

class dolfin::SimplexQuadrature

Quadrature on simplices.

std::pair<std::vector<double>, std::vector<double>> dolfin::SimplexQuadrature::compute_quadrature_rule(const Cell &cell, std::size_t order)

Compute quadrature rule for cell. Arguments cell (Cell ) The cell. order (std::size_t) The order of convergence of the quadrature rule. Returns std::pair<std::vector<double>, std::vector<double> > A flattened array of quadrature points and a corresponding array of quadrature weights.

Parameters:
  • cell
  • order
std::pair<std::vector<double>, std::vector<double>> dolfin::SimplexQuadrature::compute_quadrature_rule(const double *coordinates, std::size_t tdim, std::size_t gdim, std::size_t order)

Compute quadrature rule for simplex. Arguments coordinates (double *) A flattened array of simplex coordinates of dimension num_vertices x gdim = (tdim + 1)*gdim. tdim (std::size_t) The topological dimension of the simplex. gdim (std::size_t) The geometric dimension. order (std::size_t) The order of convergence of the quadrature rule. Returns std::pair<std::vector<double>, std::vector<double> > A flattened array of quadrature points and a corresponding array of quadrature weights.

Parameters:
  • coordinates
  • tdim
  • gdim
  • order
std::pair<std::vector<double>, std::vector<double>> dolfin::SimplexQuadrature::compute_quadrature_rule_interval(const double *coordinates, std::size_t gdim, std::size_t order)

Compute quadrature rule for interval. Arguments coordinates (double *) A flattened array of simplex coordinates of dimension num_vertices x gdim = 2*gdim. gdim (std::size_t) The geometric dimension. order (std::size_t) The order of convergence of the quadrature rule. Returns std::pair<std::vector<double>, std::vector<double> > A flattened array of quadrature points and a corresponding array of quadrature weights.

Parameters:
  • coordinates
  • gdim
  • order
std::pair<std::vector<double>, std::vector<double>> dolfin::SimplexQuadrature::compute_quadrature_rule_tetrahedron(const double *coordinates, std::size_t gdim, std::size_t order)

Compute quadrature rule for tetrahedron. Arguments coordinates (double *) A flattened array of simplex coordinates of dimension num_vertices x gdim = 4*gdim. gdim (std::size_t) The geometric dimension. order (std::size_t) The order of convergence of the quadrature rule. Returns std::pair<std::vector<double>, std::vector<double> > A flattened array of quadrature points and a corresponding array of quadrature weights.

Parameters:
  • coordinates
  • gdim
  • order
std::pair<std::vector<double>, std::vector<double>> dolfin::SimplexQuadrature::compute_quadrature_rule_triangle(const double *coordinates, std::size_t gdim, std::size_t order)

Compute quadrature rule for triangle. Arguments coordinates (double *) A flattened array of simplex coordinates of dimension num_vertices x gdim = 3*gdim. gdim (std::size_t) The geometric dimension. order (std::size_t) The order of convergence of the quadrature rule. Returns std::pair<std::vector<double>, std::vector<double> > A flattened array of quadrature points and a corresponding array of quadrature weights.

Parameters:
  • coordinates
  • gdim
  • order

dolfin/graph

Documentation for C++ code found in dolfin/graph/*.h

Type definitions

Graph

C++ documentation for Graph from dolfin/graph/Graph.h:

type dolfin::Graph

Vector of unordered Sets.

graph_set_type

C++ documentation for graph_set_type from dolfin/graph/Graph.h:

type dolfin::graph_set_type

Typedefs for simple graph data structures. DOLFIN container for graphs

Classes

BoostGraphColoring

C++ documentation for BoostGraphColoring from dolfin/graph/BoostGraphColoring.h:

class dolfin::BoostGraphColoring

This class colors a graph using the Boost Graph Library.

std::size_t dolfin::BoostGraphColoring::compute_local_vertex_coloring(const Graph &graph, std::vector<ColorType> &colors)

Compute vertex colors.

Parameters:
  • graph
  • colors
std::size_t dolfin::BoostGraphColoring::compute_local_vertex_coloring(const T &graph, std::vector<ColorType> &colors)

Compute vertex colors.

Parameters:
  • graph
  • colors
BoostGraphOrdering

C++ documentation for BoostGraphOrdering from dolfin/graph/BoostGraphOrdering.h:

class dolfin::BoostGraphOrdering

This class computes graph re-orderings. It uses Boost Graph.

T dolfin::BoostGraphOrdering::build_csr_directed_graph(const X &graph)
Parameters:graph
T dolfin::BoostGraphOrdering::build_directed_graph(const X &graph)
Parameters:graph
T dolfin::BoostGraphOrdering::build_undirected_graph(const X &graph)
Parameters:graph
std::vector<int> dolfin::BoostGraphOrdering::compute_cuthill_mckee(const Graph &graph, bool reverse = false)

Compute re-ordering (map[old] -> new) using Cuthill-McKee algorithm

Parameters:
  • graph
  • reverse
std::vector<int> dolfin::BoostGraphOrdering::compute_cuthill_mckee(const std::set<std::pair<std::size_t, std::size_t>> &edges, std::size_t size, bool reverse = false)

Compute re-ordering (map[old] -> new) using Cuthill-McKee algorithm

Parameters:
  • edges
  • size
  • reverse
CSRGraph

C++ documentation for CSRGraph from dolfin/graph/CSRGraph.h:

class dolfin::CSRGraph

Compressed Sparse Row graph. This class provides a Compressed Sparse Row Graph defined by a vector containing edges for each node and a vector of offsets into the edge vector for each node In parallel, all nodes must be numbered from zero on process zero continuously through increasing rank processes. Edges must be defined in terms of the global node numbers. The global node offset of each process is given by node_distribution The format of the nodes, edges and distribution is identical with the formats for ParMETIS and PT-SCOTCH. See the manuals for these libraries for further information.

dolfin::CSRGraph::CSRGraph()

Empty CSR Graph.

dolfin::CSRGraph::CSRGraph(MPI_Comm mpi_comm, const T *xadj, const T *adjncy, std::size_t n)

Create a CSR Graph from ParMETIS style adjacency lists.

Parameters:
  • mpi_comm
  • xadj
  • adjncy
  • n
dolfin::CSRGraph::CSRGraph(MPI_Comm mpi_comm, const std::vector<X> &graph)

Create a CSR Graph from a collection of edges (X is a container some type, e.g. std::vector<unsigned int> or std::set<std::size_t>

Parameters:
  • mpi_comm
  • graph
void dolfin::CSRGraph::calculate_node_distribution()
std::vector<T> &dolfin::CSRGraph::edges()

Vector containing all edges for all local nodes (non-const) (“adjncy” in ParMETIS )

const std::vector<T> &dolfin::CSRGraph::edges() const

Vector containing all edges for all local nodes (“adjncy” in ParMETIS )

std::vector<T> &dolfin::CSRGraph::node_distribution()

Return number of nodes (offset) on each process (non-const)

const std::vector<T> &dolfin::CSRGraph::node_distribution() const

Return number of nodes (offset) on each process.

std::vector<T> &dolfin::CSRGraph::nodes()

Vector containing index offsets into edges for all local nodes (plus extra entry marking end) (“xadj” in ParMETIS )

const std::vector<T> &dolfin::CSRGraph::nodes() const

Vector containing index offsets into edges for all local nodes (plus extra entry marking end) (“xadj” in ParMETIS )

std::size_t dolfin::CSRGraph::num_edges() const

Number of local edges in graph.

std::size_t dolfin::CSRGraph::num_edges(std::size_t i) const

Number of edges from node i.

Parameters:i
const node dolfin::CSRGraph::operator[](std::size_t i) const

Return CSRGraph::node object which provides begin() and end() iterators, also size() , and random-access for the edges of node i.

Parameters:i
std::size_t dolfin::CSRGraph::size() const

Number of local nodes in graph.

T dolfin::CSRGraph::size_global() const

Total (global) number of nodes in parallel graph.

dolfin::CSRGraph::~CSRGraph()

Destructor.

node

C++ documentation for node from dolfin/graph/CSRGraph.h:

class dolfin::CSRGraph::node

Access edges individually by using operator()[] to get a node object

std::vector<T>::const_iterator dolfin::CSRGraph::node::begin() const

Iterator pointing to beginning of edges.

std::vector<T>::const_iterator dolfin::CSRGraph::node::begin_edge
std::vector<T>::const_iterator dolfin::CSRGraph::node::end() const

Iterator pointing to beyond end of edges.

std::vector<T>::const_iterator dolfin::CSRGraph::node::end_edge
dolfin::CSRGraph::node::node(const typename std::vector<T>::const_iterator &begin_it, const typename std::vector<T>::const_iterator &end_it)

Node object, listing a set of outgoing edges.

Parameters:
  • begin_it
  • end_it
const T &dolfin::CSRGraph::node::operator[](std::size_t i) const

Access outgoing edge i of this node.

Parameters:i
std::size_t dolfin::CSRGraph::node::size() const

Number of outgoing edges for this node.

GraphBuilder

C++ documentation for GraphBuilder from dolfin/graph/GraphBuilder.h:

class dolfin::GraphBuilder

This class builds a Graph corresponding to various objects.

Friends: MeshPartitioning.

type dolfin::GraphBuilder::FacetCellMap
std::pair<std::int32_t, std::int32_t> dolfin::GraphBuilder::compute_dual_graph(const MPI_Comm mpi_comm, const boost::multi_array<std::int64_t, 2> &cell_vertices, const CellType &cell_type, const std::int64_t num_global_vertices, std::vector<std::vector<std::size_t>> &local_graph, std::set<std::int64_t> &ghost_vertices)

Build distributed dual graph (cell-cell connections) from minimal mesh data, and return (num local edges, num non-local edges)

Parameters:
  • mpi_comm
  • cell_vertices
  • cell_type
  • num_global_vertices
  • local_graph
  • ghost_vertices
std::int32_t dolfin::GraphBuilder::compute_local_dual_graph(const MPI_Comm mpi_comm, const boost::multi_array<std::int64_t, 2> &cell_vertices, const CellType &cell_type, std::vector<std::vector<std::size_t>> &local_graph, FacetCellMap &facet_cell_map)
Parameters:
  • mpi_comm
  • cell_vertices
  • cell_type
  • local_graph
  • facet_cell_map
std::int32_t dolfin::GraphBuilder::compute_local_dual_graph_keyed(const MPI_Comm mpi_comm, const boost::multi_array<std::int64_t, 2> &cell_vertices, const CellType &cell_type, std::vector<std::vector<std::size_t>> &local_graph, FacetCellMap &facet_cell_map)
Parameters:
  • mpi_comm
  • cell_vertices
  • cell_type
  • local_graph
  • facet_cell_map
std::int32_t dolfin::GraphBuilder::compute_nonlocal_dual_graph(const MPI_Comm mpi_comm, const boost::multi_array<std::int64_t, 2> &cell_vertices, const CellType &cell_type, const std::int64_t num_global_vertices, std::vector<std::vector<std::size_t>> &local_graph, FacetCellMap &facet_cell_map, std::set<std::int64_t> &ghost_vertices)
Parameters:
  • mpi_comm
  • cell_vertices
  • cell_type
  • num_global_vertices
  • local_graph
  • facet_cell_map
  • ghost_vertices
Graph dolfin::GraphBuilder::local_graph(const Mesh &mesh, const GenericDofMap &dofmap0, const GenericDofMap &dofmap1)

Build local graph from dofmap.

Parameters:
  • mesh
  • dofmap0
  • dofmap1
Graph dolfin::GraphBuilder::local_graph(const Mesh &mesh, const std::vector<std::size_t> &coloring_type)

Build local graph from mesh (general version)

Parameters:
  • mesh
  • coloring_type
Graph dolfin::GraphBuilder::local_graph(const Mesh &mesh, std::size_t dim0, std::size_t dim1)

Build local graph (specialized version)

Parameters:
  • mesh
  • dim0
  • dim1
GraphColoring

C++ documentation for GraphColoring from dolfin/graph/GraphColoring.h:

class dolfin::GraphColoring

This class provides a common interface to graph coloring libraries.

std::size_t dolfin::GraphColoring::compute_local_vertex_coloring(const Graph &graph, std::vector<std::size_t> &colors)

Compute vertex colors.

Parameters:
  • graph
  • colors
ParMETIS

C++ documentation for ParMETIS from dolfin/graph/ParMETIS.h:

class dolfin::ParMETIS

This class provides an interface to ParMETIS .

void dolfin::ParMETIS::adaptive_repartition(MPI_Comm mpi_comm, CSRGraph<T> &csr_graph, std::vector<int> &cell_partition)
Parameters:
  • mpi_comm
  • csr_graph
  • cell_partition
void dolfin::ParMETIS::compute_partition(const MPI_Comm mpi_comm, std::vector<int> &cell_partition, std::map<std::int64_t, std::vector<int>> &ghost_procs, const boost::multi_array<std::int64_t, 2> &cell_vertices, const std::size_t num_global_vertices, const CellType &cell_type, const std::string mode = "partition")

Compute cell partition from local mesh data. The output vector cell_partition contains the desired destination process numbers for each cell. Cells shared on multiple processes have an entry in ghost_procs pointing to the set of sharing process numbers. The mode argument determines which ParMETIS function is called. It can be one of “partition”, “adaptive_repartition” or “refine”. For meshes that have already been partitioned or are already well partitioned, it can be advantageous to use “adaptive_repartition” or “refine”.

Parameters:
  • mpi_comm
  • cell_partition
  • ghost_procs
  • cell_vertices
  • num_global_vertices
  • cell_type
  • mode
void dolfin::ParMETIS::partition(MPI_Comm mpi_comm, CSRGraph<T> &csr_graph, std::vector<int> &cell_partition, std::map<std::int64_t, std::vector<int>> &ghost_procs)
Parameters:
  • mpi_comm
  • csr_graph
  • cell_partition
  • ghost_procs
void dolfin::ParMETIS::refine(MPI_Comm mpi_comm, CSRGraph<T> &csr_graph, std::vector<int> &cell_partition)
Parameters:
  • mpi_comm
  • csr_graph
  • cell_partition
SCOTCH

C++ documentation for SCOTCH from dolfin/graph/SCOTCH.h:

class dolfin::SCOTCH

This class provides an interface to SCOTCH-PT (parallel version)

std::vector<int> dolfin::SCOTCH::compute_gps(const Graph &graph, std::size_t num_passes = 5)

Compute reordering (map[old] -> new) using Gibbs-Poole-Stockmeyer (GPS) re-ordering

Parameters:
  • graph – (Graph) Input graph
  • num_passes – (std::size_t) Number of passes to use in GPS algorithm
Returns:

std::vector<int> Mapping from old to new nodes

void dolfin::SCOTCH::compute_partition(const MPI_Comm mpi_comm, std::vector<int> &cell_partition, std::map<std::int64_t, std::vector<int>> &ghost_procs, const boost::multi_array<std::int64_t, 2> &cell_vertices, const std::vector<std::size_t> &cell_weight, const std::int64_t num_global_vertices, const std::int64_t num_global_cells, const CellType &cell_type)

Compute cell partition from local mesh data. The vector cell_partition contains the desired destination process numbers for each cell. Cells shared on multiple processes have an entry in ghost_procs pointing to the set of sharing process numbers.

Parameters:
  • mpi_comm – (MPI_Comm)
  • cell_partition – (std::vector<int>)
  • ghost_procs – (std::map<std::int64_t, std::vector<int>>)
  • cell_vertices – (const boost::multi_array<std::int64_t, 2>)
  • cell_weight – (const std::vector<std::size_t>)
  • num_global_vertices – (const std::int64_t)
  • num_global_cells – (const std::int64_t)
  • cell_type – (const CellType )
std::vector<int> dolfin::SCOTCH::compute_reordering(const Graph &graph, std::string scotch_strategy = "")

Compute graph re-ordering

Parameters:
  • graph – (Graph) Input graph
  • scotch_strategy – (string) SCOTCH parameters
Returns:

std::vector<int> Mapping from old to new nodes

void dolfin::SCOTCH::compute_reordering(const Graph &graph, std::vector<int> &permutation, std::vector<int> &inverse_permutation, std::string scotch_strategy = "")

Compute graph re-ordering

Parameters:
  • graph – (Graph)
  • permutation – (std::vector<int>)
  • inverse_permutation – (std::vector<int>)
  • scotch_strategy – (std::string)
void dolfin::SCOTCH::partition(const MPI_Comm mpi_comm, CSRGraph<T> &local_graph, const std::vector<std::size_t> &node_weights, const std::set<std::int64_t> &ghost_vertices, const std::size_t num_global_vertices, std::vector<int> &cell_partition, std::map<std::int64_t, std::vector<int>> &ghost_procs)
Parameters:
  • mpi_comm
  • local_graph
  • node_weights
  • ghost_vertices
  • num_global_vertices
  • cell_partition
  • ghost_procs
ZoltanInterface

C++ documentation for ZoltanInterface from dolfin/graph/ZoltanInterface.h:

class dolfin::ZoltanInterface

This class colors a graph using Zoltan (part of Trilinos). It is designed to work on a single process.

std::size_t dolfin::ZoltanInterface::compute_local_vertex_coloring(const Graph &graph, std::vector<std::size_t> &colors)

Compute vertex colors.

Parameters:
  • graph
  • colors
ZoltanGraphInterface

C++ documentation for ZoltanGraphInterface from dolfin/graph/ZoltanInterface.h:

class dolfin::ZoltanInterface::ZoltanGraphInterface
dolfin::ZoltanInterface::ZoltanGraphInterface::ZoltanGraphInterface(const Graph &graph)

Constructor.

Parameters:graph
void dolfin::ZoltanInterface::ZoltanGraphInterface::get_all_edges(void *data, int num_gid_entries, int num_lid_entries, int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, int *num_edges, ZOLTAN_ID_PTR nbor_global_id, int *nbor_procs, int wgt_dim, float *ewgts, int *ierr)
Parameters:
  • data
  • num_gid_entries
  • num_lid_entries
  • num_obj
  • global_ids
  • local_ids
  • num_edges
  • nbor_global_id
  • nbor_procs
  • wgt_dim
  • ewgts
  • ierr
void dolfin::ZoltanInterface::ZoltanGraphInterface::get_number_edges(void *data, int num_gid_entries, int num_lid_entries, int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, int *num_edges, int *ierr)
Parameters:
  • data
  • num_gid_entries
  • num_lid_entries
  • num_obj
  • global_ids
  • local_ids
  • num_edges
  • ierr
int dolfin::ZoltanInterface::ZoltanGraphInterface::get_number_of_objects(void *data, int *ierr)
Parameters:
  • data
  • ierr
void dolfin::ZoltanInterface::ZoltanGraphInterface::get_object_list(void *data, int sizeGID, int sizeLID, ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID, int wgt_dim, float *obj_wgts, int *ierr)
Parameters:
  • data
  • sizeGID
  • sizeLID
  • globalID
  • localID
  • wgt_dim
  • obj_wgts
  • ierr
void dolfin::ZoltanInterface::ZoltanGraphInterface::num_vertex_edges(unsigned int *num_edges) const

Number of edges from each vertex.

Parameters:num_edges

dolfin/io

Documentation for C++ code found in dolfin/io/*.h

Classes

File

C++ documentation for File from dolfin/io/File.h:

class dolfin::File

A File represents a data file for reading and writing objects. Unless specified explicitly, the format is determined by the file name suffix. A list of objects that can be read/written to file can be found in GenericFile.h. Compatible file formats include:

  • Binary (.bin)
  • RAW (.raw)
  • SVG (.svg)
  • XD3 (.xd3)
  • XML (.xml)
  • XYZ (.xyz)
  • VTK (.pvd)
dolfin::File::File(MPI_Comm comm, const std::string filename, Type type, std::string encoding = "ascii")

Create a file with given name and type (format) with MPI communicator Arguments communicator (MPI_Comm) The MPI communicator. filename (std::string) Name of file. type (Type) File() format. encoding (std::string) Optional argument specifying encoding, ascii is default. Example .. code-block:: c++

File file(MPI_COMM_WORLD, "solution", vtk);
Parameters:
  • comm
  • filename
  • type
  • encoding
dolfin::File::File(MPI_Comm comm, const std::string filename, std::string encoding = "ascii")

Create a file with given name with MPI communicator Arguments communicator (MPI_Comm) The MPI communicator. filename (std::string) Name of file. encoding (std::string) Optional argument specifying encoding, ascii is default. Example .. code-block:: c++

// Save solution to file
File file(u.mesh()->mpi_comm(), "solution.pvd");
file << u;

// Read mesh data from file
File mesh_file(MPI_COMM_WORLD, "mesh.xml");
mesh_file >> mesh;

// Using compressed binary format
File comp_file(u.mesh()->mpi_comm(), "solution.pvd",
               "compressed");
Parameters:
  • comm
  • filename
  • encoding
dolfin::File::File(const std::string filename, Type type, std::string encoding = "ascii")

Create a file with given name and type (format) Arguments filename (std::string) Name of file. type (Type) File() format. encoding (std::string) Optional argument specifying encoding, ascii is default. Example .. code-block:: c++

File file("solution", vtk);
Parameters:
  • filename
  • type
  • encoding
dolfin::File::File(const std::string filename, std::string encoding = "ascii")

Create a file with given name Arguments filename (std::string) Name of file. encoding (std::string) Optional argument specifying encoding, ASCII is default. Example .. code-block:: c++

// Save solution to file
File file("solution.pvd");
file << u;

// Read mesh data from file
File mesh_file("mesh.xml");
mesh_file >> mesh;

// Using compressed binary format
File comp_file("solution.pvd", "compressed");
Parameters:
  • filename
  • encoding
dolfin::File::File(std::ostream &outstream)

Create an outfile object writing to stream Arguments outstream (std::ostream) The stream.

Parameters:outstream
enum dolfin::File::Type

File formats.

enumerator dolfin::File::Type::x3d
enumerator dolfin::File::Type::xml
enumerator dolfin::File::Type::vtk
enumerator dolfin::File::Type::raw
enumerator dolfin::File::Type::xyz
enumerator dolfin::File::Type::binary
enumerator dolfin::File::Type::svg
void dolfin::File::create_parent_path(std::string filename)

Arguments filename (std::string) Name of file / path.

Parameters:filename
bool dolfin::File::exists(std::string filename)

Check if file exists Arguments filename (std::string) Name of file. Returns bool True if the file exists.

Parameters:filename
std::unique_ptr<GenericFile> dolfin::File::file
void dolfin::File::init(MPI_Comm comm, const std::string filename, Type type, std::string encoding)
Parameters:
  • comm
  • filename
  • type
  • encoding
void dolfin::File::init(MPI_Comm comm, const std::string filename, std::string encoding)
Parameters:
  • comm
  • filename
  • encoding
void dolfin::File::operator<<(const T &t)

Write object to file.

Parameters:t
void dolfin::File::operator<<(const std::pair<const Function *, double> u)

Write Function to file with time Example .. code-block:: c++

File file("solution.pvd", "compressed");
file << std::make_pair<const Function*, double>(&u, t);
Parameters:u
void dolfin::File::operator<<(const std::pair<const Mesh *, double> mesh)

Write Function to file. Write Mesh to file with time Example .. code-block:: c++

File file("mesh.pvd", "compressed");
file << std::make_pair<const Mesh*, double>(&mesh, t);
Parameters:mesh
void dolfin::File::operator<<(const std::pair<const MeshFunction<bool> *, double> f)

Write MeshFunction to file with time Example .. code-block:: c++

File file("markers.pvd", "compressed");
file << std::make_pair<const MeshFunction<bool>*, double>(&f, t);
Parameters:f
void dolfin::File::operator<<(const std::pair<const MeshFunction<double> *, double> f)

Write MeshFunction to file with time Example .. code-block:: c++

File file("markers.pvd", "compressed");
file << std::make_pair<const MeshFunction<double>*, double>(&f, t);
Parameters:f
void dolfin::File::operator<<(const std::pair<const MeshFunction<int> *, double> f)

Write MeshFunction to file with time Example .. code-block:: c++

File file("markers.pvd", "compressed");
file << std::make_pair<const MeshFunction<int>*, double>(&f, t);
Parameters:f
void dolfin::File::operator<<(const std::pair<const MeshFunction<std::size_t> *, double> f)

Write MeshFunction to file with time Example .. code-block:: c++

File file("markers.pvd", "compressed");
file << std::make_pair<const MeshFunction<std::size_t>*, double>(&f, t);
Parameters:f
void dolfin::File::operator>>(T &t)

Read from file.

Parameters:t
dolfin::File::~File()

Destructor.

MeshValueCollection

C++ documentation for MeshValueCollection from dolfin/io/XDMFFile.h:

class dolfin::MeshValueCollection : public dolfin::MeshValueCollection<T>

The MeshValueCollection class can be used to store data associated with a subset of the entities of a mesh of a given topological dimension. It differs from the MeshFunction class in two ways. First, data does not need to be associated with all entities (only a subset). Second, data is associated with entities through the corresponding cell index and local entity number (relative to the cell), not by global entity index, which means that data may be stored robustly to file.

dolfin::MeshValueCollection::MeshValueCollection()

Create empty mesh value collection

dolfin::MeshValueCollection::MeshValueCollection(const MeshFunction<T> &mesh_function)

Create a mesh value collection from a MeshFunction

Parameters:mesh_function – (MeshFunction<T>) The mesh function for creating a MeshValueCollection() .
dolfin::MeshValueCollection::MeshValueCollection(std::shared_ptr<const Mesh> mesh)

Create an empty mesh value collection on a given mesh

Parameters:mesh – (Mesh ) The mesh.
dolfin::MeshValueCollection::MeshValueCollection(std::shared_ptr<const Mesh> mesh, const std::string filename)

Create a mesh value collection from a file.

Parameters:
  • mesh – (Mesh ) A mesh associated with the collection. The mesh is used to map collection values to the appropriate process.
  • filename – (std::string) The XML file name.
dolfin::MeshValueCollection::MeshValueCollection(std::shared_ptr<const Mesh> mesh, std::size_t dim)

Create a mesh value collection of entities of given dimension on a given mesh

Parameters:
  • mesh – (Mesh ) The mesh associated with the collection.
  • dim – (std::size_t) The mesh entity dimension for the mesh value collection.
void dolfin::MeshValueCollection::clear()

Clear all values.

std::size_t dolfin::MeshValueCollection::dim() const

Return topological dimension

Returns:std::size_t The dimension.
bool dolfin::MeshValueCollection::empty() const

Return true if the subset is empty

Returns:bool True if the subset is empty.
T dolfin::MeshValueCollection::get_value(std::size_t cell_index, std::size_t local_entity)

Get marker value for given entity defined by a cell index and a local entity index

Parameters:
  • cell_index – (std::size_t) The index of the cell.
  • local_entity – (std::size_t) The local index of the entity relative to the cell.
Returns:

marker_value (T) The value of the marker.

void dolfin::MeshValueCollection::init(std::shared_ptr<const Mesh> mesh, std::size_t dim)

Initialise MeshValueCollection with mesh and dimension

Parameters:
  • mesh – (_mesh)) The mesh on which the value collection is defined
  • dim – (std::size_t) The mesh entity dimension for the mesh value collection.
void dolfin::MeshValueCollection::init(std::size_t dim)

Set dimension. This function should not generally be used. It is for reading MeshValueCollections as the dimension is not generally known at construction.

Parameters:dim – (std::size_t) The mesh entity dimension for the mesh value collection.
std::shared_ptr<const Mesh> dolfin::MeshValueCollection::mesh() const

Return associated mesh

Returns:Mesh The mesh.
MeshValueCollection<T> &dolfin::MeshValueCollection::operator=(const MeshFunction<T> &mesh_function)

Assignment operator

Parameters:mesh_function – (MeshFunction ) A MeshFunction object used to construct a MeshValueCollection .
MeshValueCollection<T> &dolfin::MeshValueCollection::operator=(const MeshValueCollection<T> &mesh_value_collection)

Assignment operator

Parameters:mesh_value_collection – (MeshValueCollection ) A MeshValueCollection object used to construct a MeshValueCollection .
bool dolfin::MeshValueCollection::set_value(std::size_t cell_index, std::size_t local_entity, const T &value)

Set marker value for given entity defined by a cell index and a local entity index

Parameters:
  • cell_index – (std::size_t) The index of the cell.
  • local_entity – (std::size_t) The local index of the entity relative to the cell.
  • value
    1. The value of the marker.
Returns:

bool True is a new value is inserted, false if overwriting an existing value.

bool dolfin::MeshValueCollection::set_value(std::size_t entity_index, const T &value)

Set value for given entity index

Parameters:
  • entity_index – (std::size_t) Index of the entity.
  • value – (T). The value of the marker.
Returns:

bool True is a new value is inserted, false if overwriting an existing value.

std::size_t dolfin::MeshValueCollection::size() const

Return size (number of entities in subset)

Returns:std::size_t The size.
std::string dolfin::MeshValueCollection::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose – (bool) Flag to turn on additional output.
Returns:std::string An informal representation.
std::map<std::pair<std::size_t, std::size_t>, T> &dolfin::MeshValueCollection::values()

Get all values

Returns:std::map<std::pair<std::size_t, std::size_t>, T> A map from positions to values.
const std::map<std::pair<std::size_t, std::size_t>, T> &dolfin::MeshValueCollection::values() const

Get all values (const version)

Returns:std::map<std::pair<std::size_t, std::size_t>, T> A map from positions to values.
dolfin::MeshValueCollection::~MeshValueCollection()

Destructor.

RAWFile

C++ documentation for RAWFile from dolfin/io/RAWFile.h:

class dolfin::RAWFile

Output of data in raw binary format.

void dolfin::RAWFile::MeshFunctionWrite(T &meshfunction)
Parameters:meshfunction
dolfin::RAWFile::RAWFile(const std::string filename)

Constructor.

Parameters:filename
void dolfin::RAWFile::ResultsWrite(const Function &u) const
Parameters:u
void dolfin::RAWFile::operator<<(const Function &u)

Output Function

Parameters:uFunction
void dolfin::RAWFile::operator<<(const MeshFunction<double> &meshfunction)

Output MeshFunction (double)

Parameters:meshfunctionMeshFunction
void dolfin::RAWFile::operator<<(const MeshFunction<int> &meshfunction)

Output MeshFunction (int)

Parameters:meshfunctionMeshFunction
void dolfin::RAWFile::rawNameUpdate(const int counter)
Parameters:counter
std::string dolfin::RAWFile::raw_filename
dolfin::RAWFile::~RAWFile()

Destructor.

SVGFile

C++ documentation for SVGFile from dolfin/io/SVGFile.h:

class dolfin::SVGFile

This class implements output of meshes to scalable vector graphics format (SVG).

dolfin::SVGFile::SVGFile(const std::string filename)

Constructor.

Parameters:filename
void dolfin::SVGFile::operator<<(const Mesh &mesh)

Store mesh to file.

Parameters:mesh
dolfin::SVGFile::~SVGFile()

Destructor.

VTKFile

C++ documentation for VTKFile from dolfin/io/VTKFile.h:

class dolfin::VTKFile

Output of meshes and functions in VTK format. XML format for visualisation purposes. It is not suitable to checkpointing as it may decimate some data.

dolfin::VTKFile::VTKFile(const std::string filename, std::string encoding)

Create VTK file.

Parameters:
  • filename
  • encoding
bool dolfin::VTKFile::binary
void dolfin::VTKFile::clear_file(std::string file) const
Parameters:file
bool dolfin::VTKFile::compress
std::string dolfin::VTKFile::encode_string
void dolfin::VTKFile::finalize(std::string vtu_filename, double time)
Parameters:
  • vtu_filename
  • time
std::string dolfin::VTKFile::init(const Mesh &mesh, std::size_t dim) const
Parameters:
  • mesh
  • dim
void dolfin::VTKFile::mesh_function_write(T &meshfunction, double time)
Parameters:
  • meshfunction
  • time
void dolfin::VTKFile::operator<<(const Function &u)

Output Function

Parameters:u – (Function )
void dolfin::VTKFile::operator<<(const Mesh &mesh)

Output mesh.

Parameters:mesh
void dolfin::VTKFile::operator<<(const MeshFunction<bool> &meshfunction)

Output MeshFunction<bool>

Parameters:meshfunction
void dolfin::VTKFile::operator<<(const MeshFunction<double> &meshfunction)

Output MeshFunction<double>

Parameters:meshfunction
void dolfin::VTKFile::operator<<(const MeshFunction<int> &meshfunction)

Output MeshFunction<int>

Parameters:meshfunction
void dolfin::VTKFile::operator<<(const MeshFunction<std::size_t> &meshfunction)

Output MeshFunction<std::size_t>

Parameters:meshfunction
void dolfin::VTKFile::operator<<(const std::pair<const Function *, double> u)

Output Function and timestep

Parameters:uFunction and time
void dolfin::VTKFile::operator<<(const std::pair<const Mesh *, double> mesh)

Output Mesh and timestep

Parameters:meshMesh and time
void dolfin::VTKFile::operator<<(const std::pair<const MeshFunction<bool> *, double> f)

Output MeshFunction and timestep

Parameters:fMeshFunction and time
void dolfin::VTKFile::operator<<(const std::pair<const MeshFunction<double> *, double> f)

Output MeshFunction and timestep

Parameters:fMeshFunction and time
void dolfin::VTKFile::operator<<(const std::pair<const MeshFunction<int> *, double> f)

Output MeshFunction and timestep

Parameters:fMeshFunction and time
void dolfin::VTKFile::operator<<(const std::pair<const MeshFunction<std::size_t> *, double> f)

Output MeshFunction and timestep

Parameters:fMeshFunction and time
void dolfin::VTKFile::pvd_file_write(std::size_t step, double time, std::string file)
Parameters:
  • step
  • time
  • file
void dolfin::VTKFile::pvtu_write(const Function &u, const std::string pvtu_filename) const
Parameters:
  • u
  • pvtu_filename
void dolfin::VTKFile::pvtu_write_function(std::size_t dim, std::size_t rank, const std::string data_location, const std::string name, const std::string filename, std::size_t num_processes) const
Parameters:
  • dim
  • rank
  • data_location
  • name
  • filename
  • num_processes
void dolfin::VTKFile::pvtu_write_mesh(const std::string pvtu_filename, const std::size_t num_processes) const
Parameters:
  • pvtu_filename
  • num_processes
void dolfin::VTKFile::pvtu_write_mesh(pugi::xml_node xml_node) const
Parameters:xml_node
void dolfin::VTKFile::results_write(const Function &u, std::string file) const
Parameters:
  • u
  • file
std::string dolfin::VTKFile::strip_path(std::string file) const
Parameters:file
void dolfin::VTKFile::vtk_header_close(std::string file) const
Parameters:file
void dolfin::VTKFile::vtk_header_open(std::size_t num_vertices, std::size_t num_cells, std::string file) const
Parameters:
  • num_vertices
  • num_cells
  • file
std::string dolfin::VTKFile::vtu_name(const int process, const int num_processes, const int counter, std::string ext) const
Parameters:
  • process
  • num_processes
  • counter
  • ext
void dolfin::VTKFile::write_function(const Function &u, double time)
Parameters:
  • u
  • time
void dolfin::VTKFile::write_mesh(const Mesh &mesh, double time)
Parameters:
  • mesh
  • time
void dolfin::VTKFile::write_point_data(const GenericFunction &u, const Mesh &mesh, std::string file) const
Parameters:
  • u
  • mesh
  • file
dolfin::VTKFile::~VTKFile()
VTKWriter

C++ documentation for VTKWriter from dolfin/io/VTKWriter.h:

class dolfin::VTKWriter

Write VTK Mesh representation.

std::string dolfin::VTKWriter::ascii_cell_data(const Mesh &mesh, const std::vector<std::size_t> &offset, const std::vector<double> &values, std::size_t dim, std::size_t rank)
Parameters:
  • mesh
  • offset
  • values
  • dim
  • rank
std::string dolfin::VTKWriter::base64_cell_data(const Mesh &mesh, const std::vector<std::size_t> &offset, const std::vector<double> &values, std::size_t dim, std::size_t rank, bool compress)
Parameters:
  • mesh
  • offset
  • values
  • dim
  • rank
  • compress
std::string dolfin::VTKWriter::encode_inline_base64(const std::vector<T> &data)
Parameters:data
std::string dolfin::VTKWriter::encode_inline_compressed_base64(const std::vector<T> &data)
Parameters:data
std::string dolfin::VTKWriter::encode_stream(const std::vector<T> &data, bool compress)

Form (compressed) base64 encoded string for VTK.

Parameters:
  • data
  • compress
std::uint8_t dolfin::VTKWriter::vtk_cell_type(const Mesh &mesh, std::size_t cell_dim)
Parameters:
  • mesh
  • cell_dim
void dolfin::VTKWriter::write_ascii_mesh(const Mesh &mesh, std::size_t cell_dim, std::string file)
Parameters:
  • mesh
  • cell_dim
  • file
void dolfin::VTKWriter::write_base64_mesh(const Mesh &mesh, std::size_t cell_dim, std::string file, bool compress)
Parameters:
  • mesh
  • cell_dim
  • file
  • compress
void dolfin::VTKWriter::write_cell_data(const Function &u, std::string file, bool binary, bool compress)

Cell data writer.

Parameters:
  • u
  • file
  • binary
  • compress
void dolfin::VTKWriter::write_mesh(const Mesh &mesh, std::size_t cell_dim, std::string file, bool binary, bool compress)

Mesh writer.

Parameters:
  • mesh
  • cell_dim
  • file
  • binary
  • compress
X3DFile

C++ documentation for X3DFile from dolfin/io/X3DFile.h:

class dolfin::X3DFile

This class implements output of meshes to X3D (successor to VRML) graphics format (http://www.web3d.org/x3d/ ). It is suitable for output of small to medium size meshes for 3D visualisation via browsers, and can also do basic Function and MeshFunction output (on the surface) X3D files can be included on web pages with WebGL functionality (see www.x3dom.org).

dolfin::X3DFile::X3DFile(const std::string filename)

Constructor.

Parameters:filename
std::string dolfin::X3DFile::color_palette(const int pal) const
Parameters:pal
const std::string dolfin::X3DFile::facet_type
std::vector<double> dolfin::X3DFile::mesh_min_max(const Mesh &mesh) const
Parameters:mesh
void dolfin::X3DFile::operator<<(const Function &function)

Output Function to X3D format - for a 3D mesh, only producing surface facets

Parameters:function
void dolfin::X3DFile::operator<<(const Mesh &mesh)

Output Mesh to X3D format - for a 3D mesh, only producing surface facets

Parameters:mesh
void dolfin::X3DFile::operator<<(const MeshFunction<std::size_t> &meshfunction)

Output MeshFunction to X3D format - for a 3D mesh, only producing surface facets

Parameters:meshfunction
void dolfin::X3DFile::output_xml_header(pugi::xml_document &xml_doc, const std::vector<double> &xpos)
Parameters:
  • xml_doc
  • xpos
std::vector<std::size_t> dolfin::X3DFile::vertex_index(const Mesh &mesh) const
Parameters:mesh
void dolfin::X3DFile::write_meshfunction(const MeshFunction<std::size_t> &meshfunction)
Parameters:meshfunction
void dolfin::X3DFile::write_vertices(pugi::xml_document &xml_doc, const Mesh &mesh, const std::vector<std::size_t> vecindex)
Parameters:
  • xml_doc
  • mesh
  • vecindex
dolfin::X3DFile::~X3DFile()

Destructor.

X3DOM

C++ documentation for X3DOM from dolfin/io/X3DOM.h:

class dolfin::X3DOM

This class implements output of meshes to X3DOM XML or HTML5 with X3DOM strings. The latter can be used for interactive visualisation

enum dolfin::X3DOM::Viewpoint
enumerator dolfin::X3DOM::Viewpoint::top
enumerator dolfin::X3DOM::Viewpoint::bottom
enumerator dolfin::X3DOM::Viewpoint::left
enumerator dolfin::X3DOM::Viewpoint::right
enumerator dolfin::X3DOM::Viewpoint::back
enumerator dolfin::X3DOM::Viewpoint::front
enumerator dolfin::X3DOM::Viewpoint::default_view
void dolfin::X3DOM::add_html_doctype(pugi::xml_node &xml_node)
Parameters:xml_node
pugi::xml_node dolfin::X3DOM::add_html_preamble(pugi::xml_node &xml_node)
Parameters:xml_node
void dolfin::X3DOM::add_menu_color_tab(pugi::xml_node &xml_node)
Parameters:xml_node
void dolfin::X3DOM::add_menu_display(pugi::xml_node &xml_node, const Mesh &mesh, const X3DOMParameters &parameters)
Parameters:
  • xml_node
  • mesh
  • parameters
void dolfin::X3DOM::add_menu_options_option(pugi::xml_node &xml_node, std::string name)
Parameters:
  • xml_node
  • name
void dolfin::X3DOM::add_menu_options_tab(pugi::xml_node &xml_node)
Parameters:xml_node
void dolfin::X3DOM::add_menu_summary_tab(pugi::xml_node &xml_node, const Mesh &mesh)
Parameters:
  • xml_node
  • mesh
void dolfin::X3DOM::add_menu_tab_button(pugi::xml_node &xml_node, std::string name, bool checked)
Parameters:
  • xml_node
  • name
  • checked
void dolfin::X3DOM::add_menu_viewpoint_button(pugi::xml_node &xml_node, std::string name)
Parameters:
  • xml_node
  • name
void dolfin::X3DOM::add_menu_viewpoint_tab(pugi::xml_node &xml_node)
Parameters:xml_node
void dolfin::X3DOM::add_menu_warp_tab(pugi::xml_node &xml_node)
Parameters:xml_node
void dolfin::X3DOM::add_mesh_data(pugi::xml_node &xml_node, const Mesh &mesh, const std::vector<double> &vertex_values, const std::vector<double> &facet_values, const X3DOMParameters &parameters, bool surface)
Parameters:
  • xml_node
  • mesh
  • vertex_values
  • facet_values
  • parameters
  • surface
void dolfin::X3DOM::add_viewpoint_node(pugi::xml_node &xml_scene, Viewpoint viewpoint, const Point p, const double s)
Parameters:
  • xml_scene
  • viewpoint
  • p
  • s
void dolfin::X3DOM::add_viewpoint_nodes(pugi::xml_node &xml_scene, const Point p, double d, bool show_viewpoint_buttons)
Parameters:
  • xml_scene
  • p
  • d
  • show_viewpoint_buttons
pugi::xml_node dolfin::X3DOM::add_x3d_node(pugi::xml_node &xml_node, std::array<double, 2> size, bool show_stats)
Parameters:
  • xml_node
  • size
  • show_stats
void dolfin::X3DOM::add_x3dom_data(pugi::xml_node &xml_node, const Mesh &mesh, const std::vector<double> &vertex_values, const std::vector<double> &facet_values, const X3DOMParameters &parameters)
Parameters:
  • xml_node
  • mesh
  • vertex_values
  • facet_values
  • parameters
void dolfin::X3DOM::add_x3dom_doctype(pugi::xml_node &xml_node)
Parameters:xml_node
std::string dolfin::X3DOM::array_to_string3(std::array<double, 3> x)
Parameters:x
void dolfin::X3DOM::build_mesh_data(std::vector<int> &topology, std::vector<double> &geometry, std::vector<double> &value_data, const Mesh &mesh, const std::vector<double> &vertex_values, const std::vector<double> &facet_values, bool surface)
Parameters:
  • topology
  • geometry
  • value_data
  • mesh
  • vertex_values
  • facet_values
  • surface
void dolfin::X3DOM::build_x3dom_tree(pugi::xml_document &xml_doc, const Function &u, const X3DOMParameters &parameters = X3DOMParameters())

Build X3DOM pugixml tree for a Function .

Parameters:
  • xml_doc
  • u
  • parameters
void dolfin::X3DOM::build_x3dom_tree(pugi::xml_document &xml_doc, const Mesh &mesh, const X3DOMParameters &parameters = X3DOMParameters())

Build X3DOM pugixml tree for a Mesh .

Parameters:
  • xml_doc
  • mesh
  • parameters
pugi::xml_node dolfin::X3DOM::create_menu_content_node(pugi::xml_node &xml_node, std::string name, bool show)
Parameters:
  • xml_node
  • name
  • show
void dolfin::X3DOM::get_function_values(const Function &u, std::vector<double> &vertex_values, std::vector<double> &facet_values)
Parameters:
  • u
  • vertex_values
  • facet_values
std::string dolfin::X3DOM::html(const Function &u, X3DOMParameters parameters = X3DOMParameters())

Return HTML5 string with embedded X3D for a Function .

Parameters:
  • u
  • parameters
std::string dolfin::X3DOM::html(const Mesh &mesh, X3DOMParameters parameters = X3DOMParameters())

Return HTML5 string with embedded X3D for a Mesh .

Parameters:
  • mesh
  • parameters
void dolfin::X3DOM::html(pugi::xml_document &xml_doc, const Mesh &mesh, const std::vector<double> &vertex_values, const std::vector<double> &facet_values, const X3DOMParameters &parameters)
Parameters:
  • xml_doc
  • mesh
  • vertex_values
  • facet_values
  • parameters
std::pair<Point, double> dolfin::X3DOM::mesh_centre_and_distance(const Mesh &mesh)
Parameters:mesh
std::string dolfin::X3DOM::str(const Function &u, X3DOMParameters parameters = X3DOMParameters())

Return X3D string for a Function .

Parameters:
  • u
  • parameters
std::string dolfin::X3DOM::str(const Mesh &mesh, X3DOMParameters parameters = X3DOMParameters())

Return X3D string for a Mesh .

Parameters:
  • mesh
  • parameters
std::set<int> dolfin::X3DOM::surface_vertex_indices(const Mesh &mesh)
Parameters:mesh
std::string dolfin::X3DOM::to_string(pugi::xml_document &xml_doc, unsigned int flags)
Parameters:
  • xml_doc
  • flags
void dolfin::X3DOM::x3dom(pugi::xml_document &xml_doc, const Mesh &mesh, const std::vector<double> &vertex_values, const std::vector<double> &facet_values, const X3DOMParameters &parameters)
Parameters:
  • xml_doc
  • mesh
  • vertex_values
  • facet_values
  • parameters
X3DOMParameters

C++ documentation for X3DOMParameters from dolfin/io/X3DOM.h:

class dolfin::X3DOMParameters

Class data to store X3DOM view parameters.

enum dolfin::X3DOMParameters::Representation

X3DOM representation type.

enumerator dolfin::X3DOMParameters::Representation::surface
enumerator dolfin::X3DOMParameters::Representation::surface_with_edges
enumerator dolfin::X3DOMParameters::Representation::wireframe
dolfin::X3DOMParameters::X3DOMParameters()

Constructor (with default parameter settings)

void dolfin::X3DOMParameters::check_rgb(std::array<double, 3> &rgb)
Parameters:rgb
void dolfin::X3DOMParameters::check_value_range(double value, double lower, double upper)
Parameters:
  • value
  • lower
  • upper
double dolfin::X3DOMParameters::get_ambient_intensity() const

Get the ambient lighting intensity.

std::array<double, 3> dolfin::X3DOMParameters::get_background_color() const

Get background RGB color.

std::vector<double> dolfin::X3DOMParameters::get_color_map() const

Get the color map as a vector of 768 values (256*RGB) (using std::vector for Python compatibility via SWIG)

boost::multi_array<float, 2> dolfin::X3DOMParameters::get_color_map_array() const

Get the color map as a boost::multi_array (256x3)

std::array<double, 3> dolfin::X3DOMParameters::get_diffuse_color() const

Get the RGB diffuse color of the object.

std::array<double, 3> dolfin::X3DOMParameters::get_emissive_color() const

Get the RGB emissive color.

bool dolfin::X3DOMParameters::get_menu_display() const

Get the menu display state.

Representation dolfin::X3DOMParameters::get_representation() const

Get the current representation of the object (wireframe, surface or surface_with_edges)

double dolfin::X3DOMParameters::get_shininess() const

Set the surface shininess of the object.

std::array<double, 3> dolfin::X3DOMParameters::get_specular_color() const

Get the RGB specular color.

double dolfin::X3DOMParameters::get_transparency() const

Get the transparency (0-1)

std::array<double, 2> dolfin::X3DOMParameters::get_viewport_size() const

Get the size of the viewport.

bool dolfin::X3DOMParameters::get_x3d_stats() const

Get the state of the ‘statistics’ window.

void dolfin::X3DOMParameters::set_ambient_intensity(double intensity)

Set the ambient lighting intensity.

Parameters:intensity
void dolfin::X3DOMParameters::set_background_color(std::array<double, 3> rgb)

Set background RGB color.

Parameters:rgb
void dolfin::X3DOMParameters::set_color_map(const std::vector<double> &color_data)

Set the color map by supplying a vector of 768 values (256*RGB) (using std::vector for Python compatibility via SWIG)

Parameters:color_data
void dolfin::X3DOMParameters::set_diffuse_color(std::array<double, 3> rgb)

Set the RGB color of the object.

Parameters:rgb
void dolfin::X3DOMParameters::set_emissive_color(std::array<double, 3> rgb)

Set the RGB emissive color.

Parameters:rgb
void dolfin::X3DOMParameters::set_menu_display(bool show)

Toggle menu option.

Parameters:show
void dolfin::X3DOMParameters::set_representation(Representation representation)

Set representation of object (wireframe, surface or surface_with_edges)

Parameters:representation
void dolfin::X3DOMParameters::set_shininess(double shininess)

Set the surface shininess of the object.

Parameters:shininess
void dolfin::X3DOMParameters::set_specular_color(std::array<double, 3> rgb)

Set the RGB specular color.

Parameters:rgb
void dolfin::X3DOMParameters::set_transparency(double transparency)

Set the transparency (0-1)

Parameters:transparency
void dolfin::X3DOMParameters::set_x3d_stats(bool show)

Turn X3D ‘statistics’ window on/off.

Parameters:show
XDMFFile

C++ documentation for XDMFFile from dolfin/io/XDMFFile.h:

class dolfin::XDMFFile

Read and write Mesh , Function , MeshFunction and other objects in XDMF. This class supports the output of meshes and functions in XDMF (http://www.xdmf.org ) format. It creates an XML file that describes the data and points to a HDF5 file that stores the actual problem data. Output of data in parallel is supported. XDMF is not suitable for checkpointing as it may decimate some data.

enum dolfin::XDMFFile::Encoding

File encoding type.

enumerator dolfin::XDMFFile::Encoding::HDF5
enumerator dolfin::XDMFFile::Encoding::ASCII
dolfin::XDMFFile::XDMFFile(MPI_Comm comm, const std::string filename)

Constructor.

Parameters:
  • comm
  • filename
dolfin::XDMFFile::XDMFFile(const std::string filename)

Constructor.

Parameters:filename
void dolfin::XDMFFile::add_data_item(MPI_Comm comm, pugi::xml_node &xml_node, hid_t h5_id, const std::string h5_path, const T &x, const std::vector<std::int64_t> dimensions, const std::string number_type = "")
Parameters:
  • comm
  • xml_node
  • h5_id
  • h5_path
  • x
  • dimensions
  • number_type
void dolfin::XDMFFile::add_geometry_data(MPI_Comm comm, pugi::xml_node &xml_node, hid_t h5_id, const std::string path_prefix, const Mesh &mesh)
Parameters:
  • comm
  • xml_node
  • h5_id
  • path_prefix
  • mesh
void dolfin::XDMFFile::add_mesh(MPI_Comm comm, pugi::xml_node &xml_node, hid_t h5_id, const Mesh &mesh, const std::string path_prefix)
Parameters:
  • comm
  • xml_node
  • h5_id
  • mesh
  • path_prefix
void dolfin::XDMFFile::add_points(MPI_Comm comm, pugi::xml_node &xml_node, hid_t h5_id, const std::vector<Point> &points)
Parameters:
  • comm
  • xml_node
  • h5_id
  • points
void dolfin::XDMFFile::add_topology_data(MPI_Comm comm, pugi::xml_node &xml_node, hid_t h5_id, const std::string path_prefix, const Mesh &mesh, int tdim)
Parameters:
  • comm
  • xml_node
  • h5_id
  • path_prefix
  • mesh
  • tdim
void dolfin::XDMFFile::build_local_mesh_data(LocalMeshData &local_mesh_data, const CellType &cell_type, std::int64_t num_points, std::int64_t num_cells, int tdim, int gdim, const pugi::xml_node &topology_dataset_node, const pugi::xml_node &geometry_dataset_node, const boost::filesystem::path &parent_path)
Parameters:
  • local_mesh_data
  • cell_type
  • num_points
  • num_cells
  • tdim
  • gdim
  • topology_dataset_node
  • geometry_dataset_node
  • parent_path
void dolfin::XDMFFile::build_mesh(Mesh &mesh, const CellType &cell_type, std::int64_t num_points, std::int64_t num_cells, int tdim, int gdim, const pugi::xml_node &topology_dataset_node, const pugi::xml_node &geometry_dataset_node, const boost::filesystem::path &parent_path)
Parameters:
  • mesh
  • cell_type
  • num_points
  • num_cells
  • tdim
  • gdim
  • topology_dataset_node
  • geometry_dataset_node
  • parent_path
void dolfin::XDMFFile::build_mesh_quadratic(Mesh &mesh, const CellType &cell_type, std::int64_t num_points, std::int64_t num_cells, int tdim, int gdim, const pugi::xml_node &topology_dataset_node, const pugi::xml_node &geometry_dataset_node, const boost::filesystem::path &relative_path)
Parameters:
  • mesh
  • cell_type
  • num_points
  • num_cells
  • tdim
  • gdim
  • topology_dataset_node
  • geometry_dataset_node
  • relative_path
void dolfin::XDMFFile::check_encoding(Encoding encoding) const
Parameters:encoding
void dolfin::XDMFFile::close()

Close the file This closes any open HDF5 files. In ASCII mode the XML file is closed each time it is written to or read from, so close() has no effect. From Python you can also use XDMFFile as a context manager:

with XDMFFile(mpi_comm_world(), 'name.xdmf') as xdmf:
    xdmf.write(mesh)

The file is automatically closed at the end of the with block

std::set<unsigned int> dolfin::XDMFFile::compute_nonlocal_entities(const Mesh &mesh, int cell_dim)
Parameters:
  • mesh
  • cell_dim
std::vector<T> dolfin::XDMFFile::compute_quadratic_topology(const Mesh &mesh)
Parameters:mesh
std::vector<T> dolfin::XDMFFile::compute_topology_data(const Mesh &mesh, int cell_dim)
Parameters:
  • mesh
  • cell_dim
std::vector<T> dolfin::XDMFFile::compute_value_data(const MeshFunction<T> &meshfunction)
Parameters:meshfunction
std::vector<double> dolfin::XDMFFile::get_cell_data_values(const Function &u)
Parameters:u
std::pair<std::string, int> dolfin::XDMFFile::get_cell_type(const pugi::xml_node &topology_node)
Parameters:topology_node
std::vector<T> dolfin::XDMFFile::get_dataset(MPI_Comm comm, const pugi::xml_node &dataset_node, const boost::filesystem::path &parent_path)
Parameters:
  • comm
  • dataset_node
  • parent_path
std::vector<std::int64_t> dolfin::XDMFFile::get_dataset_shape(const pugi::xml_node &dataset_node)
Parameters:dataset_node
std::string dolfin::XDMFFile::get_hdf5_filename(std::string xdmf_filename)
Parameters:xdmf_filename
std::array<std::string, 2> dolfin::XDMFFile::get_hdf5_paths(const pugi::xml_node &dataitem_node)
Parameters:dataitem_node
std::int64_t dolfin::XDMFFile::get_num_cells(const pugi::xml_node &topology_node)
Parameters:topology_node
std::vector<double> dolfin::XDMFFile::get_p2_data_values(const Function &u)
Parameters:u
std::int64_t dolfin::XDMFFile::get_padded_width(const Function &u)
Parameters:u
std::vector<double> dolfin::XDMFFile::get_point_data_values(const Function &u)
Parameters:u
bool dolfin::XDMFFile::has_cell_centred_data(const Function &u)
Parameters:u
std::string dolfin::XDMFFile::rank_to_string(std::size_t value_rank)
Parameters:value_rank
void dolfin::XDMFFile::read(Mesh &mesh) const

Read in the first Mesh in XDMF file

Parameters:mesh – (Mesh ) Mesh to fill from XDMF file
void dolfin::XDMFFile::read(MeshFunction<bool> &meshfunction, std::string name = "")

Read first MeshFunction from file

Parameters:
  • meshfunction – (MeshFunction<bool>) MeshFunction to restore
  • name – (std::string) Name of data attribute in XDMF file
void dolfin::XDMFFile::read(MeshFunction<double> &meshfunction, std::string name = "")

Read MeshFunction from file, optionally specifying dataset name

Parameters:
  • meshfunction – (MeshFunction<double>) MeshFunction to restore
  • name – (std::string) Name of data attribute in XDMF file
void dolfin::XDMFFile::read(MeshFunction<int> &meshfunction, std::string name = "")

Read first MeshFunction from file

Parameters:
  • meshfunction – (MeshFunction<int>) MeshFunction to restore
  • name – (std::string) Name of data attribute in XDMF file
void dolfin::XDMFFile::read(MeshFunction<std::size_t> &meshfunction, std::string name = "")

Read MeshFunction from file, optionally specifying dataset name

Parameters:
  • meshfunction – (MeshFunction<std::size_t>) MeshFunction to restore
  • name – (std::string) Name of data attribute in XDMF file
void dolfin::XDMFFile::read(MeshValueCollection<bool> &mvc, std::string name = "")

Read MeshValueCollection from file, optionally specifying dataset name

Parameters:
  • mvc – (MeshValueCollection<bool>) MeshValueCollection to restore
  • name – (std::string) Name of data attribute in XDMF file
void dolfin::XDMFFile::read(MeshValueCollection<double> &mvc, std::string name = "")

Read MeshValueCollection from file, optionally specifying dataset name

Parameters:
  • mvc – (MeshValueCollection<double>) MeshValueCollection to restore
  • name – (std::string) Name of data attribute in XDMF file
void dolfin::XDMFFile::read(MeshValueCollection<int> &mvc, std::string name = "")

Read MeshValueCollection from file, optionally specifying dataset name

Parameters:
  • mvc – (MeshValueCollection<int>) MeshValueCollection to restore
  • name – (std::string) Name of data attribute in XDMF file
void dolfin::XDMFFile::read(MeshValueCollection<std::size_t> &mvc, std::string name = "")

Read MeshValueCollection from file, optionally specifying dataset name

Parameters:
  • mvc – (MeshValueCollection<std::size_t>) MeshValueCollection to restore
  • name – (std::string) Name of data attribute in XDMF file
void dolfin::XDMFFile::read_mesh_function(MeshFunction<T> &meshfunction, std::string name = "")
Parameters:
  • meshfunction
  • name
void dolfin::XDMFFile::read_mesh_value_collection(MeshValueCollection<T> &mvc, std::string name)
Parameters:
  • mvc
  • name
void dolfin::XDMFFile::remap_meshfunction_data(MeshFunction<T> &meshfunction, const std::vector<std::int64_t> &topology_data, const std::vector<T> &value_data)
Parameters:
  • meshfunction
  • topology_data
  • value_data
std::vector<T> dolfin::XDMFFile::string_to_vector(const std::vector<std::string> &x_str)
Parameters:x_str
std::string dolfin::XDMFFile::to_string(X x, Y y)
Parameters:
  • x
  • y
std::string dolfin::XDMFFile::vtk_cell_type_str(CellType::Type cell_type, int order)
Parameters:
  • cell_type
  • order
void dolfin::XDMFFile::write(const Function &u, Encoding encoding = Encoding::HDF5)

Save a Function to XDMF file for visualisation, using an associated HDF5 file, or storing the data inline as XML.

Parameters:
  • u – (Function ) A function to save.
  • encoding – (Encoding) Encoding to use: HDF5 or ASCII
void dolfin::XDMFFile::write(const Function &u, double t, Encoding encoding = Encoding::HDF5)

Save a Function with timestamp to XDMF file for visualisation, using an associated HDF5 file, or storing the data inline as XML. You can control the output with the following boolean parameters on the XDMFFile class:

  • rewrite_function_mesh (default true): Controls whether the mesh will be rewritten every timestep. If the mesh does not change this can be turned off to create smaller files.
  • functions_share_mesh (default false): Controls whether all functions on a single time step share the same mesh. If true the files created will be smaller and also behave better in Paraview, at least in version 5.3.0
Parameters:
  • u – (Function ) A function to save.
  • t – (double) Timestep
  • encoding – (Encoding) Encoding to use: HDF5 or ASCII
void dolfin::XDMFFile::write(const Mesh &mesh, Encoding encoding = Encoding::HDF5)

Save a mesh to XDMF format, either using an associated HDF5 file, or storing the data inline as XML Create function on given function space

Parameters:
  • mesh – (Mesh ) A mesh to save.
  • encoding – (Encoding) Encoding to use: HDF5 or ASCII
void dolfin::XDMFFile::write(const MeshFunction<bool> &meshfunction, Encoding encoding = Encoding::HDF5)

Save MeshFunction to file using an associated HDF5 file, or storing the data inline as XML.

Parameters:
  • meshfunction – (MeshFunction ) A meshfunction to save.
  • encoding – (Encoding) Encoding to use: HDF5 or ASCII
void dolfin::XDMFFile::write(const MeshFunction<double> &meshfunction, Encoding encoding = Encoding::HDF5)

Save MeshFunction to file using an associated HDF5 file, or storing the data inline as XML.

Parameters:
  • meshfunction – (MeshFunction ) A meshfunction to save.
  • encoding – (Encoding) Encoding to use: HDF5 or ASCII
void dolfin::XDMFFile::write(const MeshFunction<int> &meshfunction, Encoding encoding = Encoding::HDF5)

Save MeshFunction to file using an associated HDF5 file, or storing the data inline as XML.

Parameters:
  • meshfunction – (MeshFunction ) A meshfunction to save.
  • encoding – (Encoding) Encoding to use: HDF5 or ASCII
void dolfin::XDMFFile::write(const MeshFunction<std::size_t> &meshfunction, Encoding encoding = Encoding::HDF5)

Save MeshFunction to file using an associated HDF5 file, or storing the data inline as XML.

Parameters:
  • meshfunction – (MeshFunction ) A meshfunction to save.
  • encoding – (Encoding) Encoding to use: HDF5 or ASCII
void dolfin::XDMFFile::write(const MeshValueCollection<bool> &mvc, Encoding encoding = Encoding::HDF5)

Write out mesh value collection (subset) using an associated HDF5 file, or storing the data inline as XML.

Parameters:
  • mvc – (MeshValueCollection<bool>) MeshValueCollection to save
  • encoding – (Encoding) Encoding to use: HDF5 or ASCII
void dolfin::XDMFFile::write(const MeshValueCollection<double> &mvc, Encoding encoding = Encoding::HDF5)

Write out mesh value collection (subset) using an associated HDF5 file, or storing the data inline as XML.

Parameters:
  • mvc – (MeshValueCollection<double>) MeshValueCollection to save
  • encoding – (Encoding) Encoding to use: HDF5 or ASCII
void dolfin::XDMFFile::write(const MeshValueCollection<int> &mvc, Encoding encoding = Encoding::HDF5)

Write out mesh value collection (subset) using an associated HDF5 file, or storing the data inline as XML.

Parameters:
  • mvc – (MeshValueCollection<int>) MeshValueCollection to save
  • encoding – (Encoding) Encoding to use: HDF5 or ASCII
void dolfin::XDMFFile::write(const MeshValueCollection<std::size_t> &mvc, Encoding encoding = Encoding::HDF5)

Write out mesh value collection (subset) using an associated HDF5 file, or storing the data inline as XML.

Parameters:
  • mvc – (MeshValueCollection<int>) MeshValueCollection to save
  • encoding – (Encoding) Encoding to use: HDF5 or ASCII
void dolfin::XDMFFile::write(const std::vector<Point> &points, Encoding encoding = Encoding::HDF5)

Save a cloud of points to file using an associated HDF5 file, or storing the data inline as XML.

Parameters:
  • points – (std::vector<Point>) A list of points to save.
  • encoding – (Encoding) Encoding to use: HDF5 or ASCII
void dolfin::XDMFFile::write(const std::vector<Point> &points, const std::vector<double> &values, Encoding encoding = Encoding::HDF5)

Save a cloud of points, with scalar values using an associated HDF5 file, or storing the data inline as XML.

Parameters:
  • points – (std::vector<Point>) A list of points to save.
  • values – (std::vector<double>) A list of values at each point.
  • encoding – (Encoding) Encoding to use: HDF5 or ASCII
void dolfin::XDMFFile::write_mesh_function(const MeshFunction<T> &meshfunction, Encoding encoding)
Parameters:
  • meshfunction
  • encoding
void dolfin::XDMFFile::write_mesh_value_collection(const MeshValueCollection<T> &mvc, Encoding encoding)
Parameters:
  • mvc
  • encoding
std::string dolfin::XDMFFile::xdmf_format_str(Encoding encoding)
Parameters:encoding
dolfin::XDMFFile::~XDMFFile()

Destructor.

XMLArray

C++ documentation for XMLArray from dolfin/io/XMLArray.h:

class dolfin::XMLArray

I/O of array data in XML format.

void dolfin::XMLArray::read(std::vector<T> &x, const pugi::xml_node xml_dolfin)

Read XML vector. Vector must have correct size.

Parameters:
  • x
  • xml_dolfin
void dolfin::XMLArray::write(const std::vector<T> &x, const std::string type, pugi::xml_node xml_node)

Write the XML file.

Parameters:
  • x
  • type
  • xml_node
XMLFile

C++ documentation for XMLFile from dolfin/io/XMLFile.h:

class dolfin::XMLFile

I/O of DOLFIN objects in XML format.

dolfin::XMLFile::XMLFile(MPI_Comm mpi_comm, const std::string filename)

Constructor.

Parameters:
  • mpi_comm
  • filename
dolfin::XMLFile::XMLFile(std::ostream &s)

Constructor from a stream.

Parameters:s
const pugi::xml_node dolfin::XMLFile::get_dolfin_xml_node(pugi::xml_document &xml_doc) const
Parameters:xml_doc
void dolfin::XMLFile::load_xml_doc(pugi::xml_document &xml_doc) const
Parameters:xml_doc
void dolfin::XMLFile::operator<<(const Function &output)

Function data output.

Parameters:output
void dolfin::XMLFile::operator<<(const GenericVector &output)

Vector output.

Parameters:output
void dolfin::XMLFile::operator<<(const Mesh &output)

Mesh output.

Parameters:output
void dolfin::XMLFile::operator<<(const MeshFunction<bool> &input)

MeshFunction (bool) output.

Parameters:input
void dolfin::XMLFile::operator<<(const MeshFunction<double> &output)

MeshFunction (double) output.

Parameters:output
void dolfin::XMLFile::operator<<(const MeshFunction<int> &output)

MeshFunction (int) output.

Parameters:output
void dolfin::XMLFile::operator<<(const MeshFunction<std::size_t> &output)

MeshFunction (uint) output.

Parameters:output
void dolfin::XMLFile::operator<<(const MeshValueCollection<bool> &input)

MeshValueCollection (bool) output.

Parameters:input
void dolfin::XMLFile::operator<<(const MeshValueCollection<double> &output)

MeshValueCollection (double) output.

Parameters:output
void dolfin::XMLFile::operator<<(const MeshValueCollection<int> &output)

MeshValueCollection (int) output.

Parameters:output
void dolfin::XMLFile::operator<<(const MeshValueCollection<std::size_t> &output)

MeshValueCollection (std::size_t) output.

Parameters:output
void dolfin::XMLFile::operator<<(const Parameters &output)

Parameters output.

Parameters:output
void dolfin::XMLFile::operator<<(const Table &output)

Table output.

Parameters:output
void dolfin::XMLFile::operator>>(Function &input)

Function data input.

Parameters:input
void dolfin::XMLFile::operator>>(GenericVector &input)

Vector input.

Parameters:input
void dolfin::XMLFile::operator>>(Mesh &input)

Mesh input.

Parameters:input
void dolfin::XMLFile::operator>>(MeshFunction<bool> &input)

MeshFunction (bool) input.

Parameters:input
void dolfin::XMLFile::operator>>(MeshFunction<double> &input)

MeshFunction (double) input.

Parameters:input
void dolfin::XMLFile::operator>>(MeshFunction<int> &input)

MeshFunction (int) input.

Parameters:input
void dolfin::XMLFile::operator>>(MeshFunction<std::size_t> &input)

MeshFunction (uint) input.

Parameters:input
void dolfin::XMLFile::operator>>(MeshValueCollection<bool> &input)

MeshValueCollection (bool) input.

Parameters:input
void dolfin::XMLFile::operator>>(MeshValueCollection<double> &input)

MeshValueCollection (double) input.

Parameters:input
void dolfin::XMLFile::operator>>(MeshValueCollection<int> &input)

MeshValueCollection (int) input.

Parameters:input
void dolfin::XMLFile::operator>>(MeshValueCollection<std::size_t> &input)

MeshValueCollection (std::size_t) input.

Parameters:input
void dolfin::XMLFile::operator>>(Parameters &input)

Parameters input.

Parameters:input
void dolfin::XMLFile::operator>>(Table &input)

Table input.

Parameters:input
std::shared_ptr<std::ostream> dolfin::XMLFile::outstream
void dolfin::XMLFile::read_mesh_function(MeshFunction<T> &t, const std::string type) const
Parameters:
  • t
  • type
void dolfin::XMLFile::read_mesh_value_collection(MeshValueCollection<T> &t, const std::string type) const
Parameters:
  • t
  • type
void dolfin::XMLFile::read_vector(std::vector<double> &input, std::vector<dolfin::la_index> &indices)

Vector input.

Parameters:
  • input
  • indices
void dolfin::XMLFile::save_xml_doc(const pugi::xml_document &xml_doc) const
Parameters:xml_doc
pugi::xml_node dolfin::XMLFile::write_dolfin(pugi::xml_document &doc)
Parameters:doc
void dolfin::XMLFile::write_mesh_function(const MeshFunction<T> &t, const std::string type)
Parameters:
  • t
  • type
void dolfin::XMLFile::write_mesh_value_collection(const MeshValueCollection<T> &t, const std::string type)
Parameters:
  • t
  • type
dolfin::XMLFile::~XMLFile()
XMLFunctionData

C++ documentation for XMLFunctionData from dolfin/io/XMLFunctionData.h:

class dolfin::XMLFunctionData

I/O for XML representation of Function .

void dolfin::XMLFunctionData::build_dof_map(std::vector<std::vector<dolfin::la_index>> &global_dof_to_cell_dof, const FunctionSpace &V)
Parameters:
  • global_dof_to_cell_dof
  • V
void dolfin::XMLFunctionData::build_global_to_cell_dof(std::vector<std::vector<std::pair<dolfin::la_index, dolfin::la_index>>> &global_dof_to_cell_dof, const FunctionSpace &V)
Parameters:
  • global_dof_to_cell_dof
  • V
void dolfin::XMLFunctionData::read(Function &u, pugi::xml_node xml_node)

Read the XML file with function data.

Parameters:
  • u
  • xml_node
void dolfin::XMLFunctionData::write(const Function &u, pugi::xml_node xml_node)

Write the XML file with function data.

Parameters:
  • u
  • xml_node
XMLMesh

C++ documentation for XMLMesh from dolfin/io/XMLMesh.h:

class dolfin::XMLMesh

I/O of XML representation of a Mesh .

void dolfin::XMLMesh::read(Mesh &mesh, const pugi::xml_node mesh_node)

Read mesh from XML.

Parameters:
  • mesh
  • mesh_node
void dolfin::XMLMesh::read_array_uint(std::vector<std::size_t> &array, const pugi::xml_node xml_array)
Parameters:
  • array
  • xml_array
void dolfin::XMLMesh::read_data(MeshData &data, const Mesh &mesh, const pugi::xml_node mesh_node)
Parameters:
  • data
  • mesh
  • mesh_node
void dolfin::XMLMesh::read_domain_data(LocalMeshData &mesh_data, const pugi::xml_node mesh_node)

Read domain data in LocalMeshData .

Parameters:
  • mesh_data
  • mesh_node
void dolfin::XMLMesh::read_domains(MeshDomains &domains, const Mesh &mesh, const pugi::xml_node mesh_node)
Parameters:
  • domains
  • mesh
  • mesh_node
void dolfin::XMLMesh::read_mesh(Mesh &mesh, const pugi::xml_node mesh_node)
Parameters:
  • mesh
  • mesh_node
void dolfin::XMLMesh::write(const Mesh &mesh, pugi::xml_node mesh_node)

Write mesh to XML.

Parameters:
  • mesh
  • mesh_node
void dolfin::XMLMesh::write_data(const Mesh &mesh, const MeshData &data, pugi::xml_node mesh_node)
Parameters:
  • mesh
  • data
  • mesh_node
void dolfin::XMLMesh::write_domains(const Mesh &mesh, const MeshDomains &domains, pugi::xml_node mesh_node)
Parameters:
  • mesh
  • domains
  • mesh_node
void dolfin::XMLMesh::write_mesh(const Mesh &mesh, pugi::xml_node mesh_node)
Parameters:
  • mesh
  • mesh_node
XMLMeshFunction

C++ documentation for XMLMeshFunction from dolfin/io/XMLMeshFunction.h:

class dolfin::XMLMeshFunction

I/O of XML representation of MeshFunction .

void dolfin::XMLMeshFunction::read(MeshFunction<T> &mesh_function, const std::string type, const pugi::xml_node xml_mesh)

Read XML MeshFunction .

Parameters:
  • mesh_function
  • type
  • xml_mesh
void dolfin::XMLMeshFunction::read(MeshValueCollection<T> &mesh_value_collection, const std::string type, const pugi::xml_node xml_mesh)

Read XML MeshFunction as a MeshValueCollection .

Parameters:
  • mesh_value_collection
  • type
  • xml_mesh
void dolfin::XMLMeshFunction::write(const MeshFunction<T> &mesh_function, const std::string type, pugi::xml_node xml_node, bool write_mesh = true)

Write the XML file.

Parameters:
  • mesh_function
  • type
  • xml_node
  • write_mesh
XMLMeshValueCollection

C++ documentation for XMLMeshValueCollection from dolfin/io/XMLMeshValueCollection.h:

class dolfin::XMLMeshValueCollection

I/O of XML representation of a MeshValueCollection .

void dolfin::XMLMeshValueCollection::read(MeshValueCollection<T> &mesh_value_collection, const std::string type, const pugi::xml_node xml_node)

Read mesh value collection from XML file.

Parameters:
  • mesh_value_collection
  • type
  • xml_node
void dolfin::XMLMeshValueCollection::write(const MeshValueCollection<T> &mesh_value_collection, const std::string type, pugi::xml_node xml_node)

Write mesh value collection to XML file.

Parameters:
  • mesh_value_collection
  • type
  • xml_node
XMLParameters

C++ documentation for XMLParameters from dolfin/io/XMLParameters.h:

class dolfin::XMLParameters

I/O of Parameters in XML format.

void dolfin::XMLParameters::add_parameter(Parameters &p, const std::string &key, T value)
Parameters:
  • p
  • key
  • value
void dolfin::XMLParameters::read(Parameters &parameters, const pugi::xml_node xml_dolfin)

Read parameters from XML file.

Parameters:
  • parameters
  • xml_dolfin
void dolfin::XMLParameters::read_parameter_nest(Parameters &p, const pugi::xml_node xml_node)
Parameters:
  • p
  • xml_node
void dolfin::XMLParameters::write(const Parameters &parameters, pugi::xml_node xml_node)

Write the XML file.

Parameters:
  • parameters
  • xml_node
XMLTable

C++ documentation for XMLTable from dolfin/io/XMLTable.h:

class dolfin::XMLTable

Output of XML representation of DOLFIN Table .

void dolfin::XMLTable::read(Table &table, pugi::xml_node xml_node)

Read the XML file.

Parameters:
  • table
  • xml_node
void dolfin::XMLTable::write(const Table &table, pugi::xml_node xml_node)

Write the XML file.

Parameters:
  • table
  • xml_node
XMLVector

C++ documentation for XMLVector from dolfin/io/XMLVector.h:

class dolfin::XMLVector

I/O of XML representation of GenericVector .

void dolfin::XMLVector::read(GenericVector &x, const pugi::xml_node xml_dolfin)

Read XML vector. Vector must have correct size.

Parameters:
  • x
  • xml_dolfin
void dolfin::XMLVector::read(std::vector<double> &x, std::vector<dolfin::la_index> &indices, const pugi::xml_node xml_dolfin)

Read XML vector in Array .

Parameters:
  • x
  • indices
  • xml_dolfin
std::size_t dolfin::XMLVector::read_size(const pugi::xml_node xml_dolfin)

Read XML vector size.

Parameters:xml_dolfin
void dolfin::XMLVector::write(const GenericVector &vector, pugi::xml_node xml_node, bool write_to_stream)

Write the XML file.

Parameters:
  • vector
  • xml_node
  • write_to_stream
XYZFile

C++ documentation for XYZFile from dolfin/io/XYZFile.h:

class dolfin::XYZFile

Simple and light file format for use with Xd3d.

dolfin::XYZFile::XYZFile(const std::string filename)

Simple and light file format for use with Xd3d. Supports scalar solution on 2D convex domains. The files only have a list of xyz coordinates ‘x y u(x,y)=z’

Parameters:filename
void dolfin::XYZFile::mesh_function_write(T &meshfunction)
Parameters:meshfunction
void dolfin::XYZFile::operator<<(const Function &u)

Output Function

Parameters:uFunction
void dolfin::XYZFile::results_write(const Function &u) const
Parameters:u
std::string dolfin::XYZFile::xyz_filename
void dolfin::XYZFile::xyz_name_update()
dolfin::XYZFile::~XYZFile()

dolfin/la

Documentation for C++ code found in dolfin/la/*.h

Functions

as_type

C++ documentation for as_type from dolfin/la/LinearAlgebraObject.h:

Y &dolfin::as_type(X &x)

Cast object to its derived class, if possible (non-const version). An error is thrown if the cast is unsuccessful.

Parameters:x

C++ documentation for as_type from dolfin/la/LinearAlgebraObject.h:

std::shared_ptr<Y> dolfin::as_type(std::shared_ptr<X> x)

Cast shared pointer object to its derived class, if possible. Caller must check for success (returns null if cast fails).

Parameters:x
has_krylov_solver_method

C++ documentation for has_krylov_solver_method from dolfin/la/solve.h:

bool dolfin::has_krylov_solver_method(std::string method)

Return true if Krylov method for the current linear algebra backend is available

Parameters:method
has_krylov_solver_preconditioner

C++ documentation for has_krylov_solver_preconditioner from dolfin/la/solve.h:

bool dolfin::has_krylov_solver_preconditioner(std::string preconditioner)

Return true if Preconditioner for the current linear algebra backend is available

Parameters:preconditioner
has_linear_algebra_backend

C++ documentation for has_linear_algebra_backend from dolfin/la/solve.h:

bool dolfin::has_linear_algebra_backend(std::string backend)

Return true if a specific linear algebra backend is supported.

Parameters:backend
has_lu_solver_method

C++ documentation for has_lu_solver_method from dolfin/la/solve.h:

bool dolfin::has_lu_solver_method(std::string method)

Return true if LU method for the current linear algebra backend is available

Parameters:method
has_type

C++ documentation for has_type from dolfin/la/LinearAlgebraObject.h:

bool dolfin::has_type(const X &x)

Check whether the object matches a specific type.

Parameters:x
in_nullspace

C++ documentation for in_nullspace from dolfin/la/test_nullspace.h:

bool dolfin::in_nullspace(const GenericLinearOperator &A, const VectorSpaceBasis &x, std::string type = "right")

Check whether a vector space basis is in the nullspace of a given operator. The string option ‘type’ can be “right” for the right nullspace (Ax=0) or “left” for the left nullspace (A^Tx = 0). To test the left nullspace, A must also be of type GenericMatrix .

Parameters:
  • A
  • x
  • type
krylov_solver_methods

C++ documentation for krylov_solver_methods from dolfin/la/solve.h:

std::map<std::string, std::string> dolfin::krylov_solver_methods()

Return a list of available Krylov methods for current linear algebra backend

krylov_solver_preconditioners

C++ documentation for krylov_solver_preconditioners from dolfin/la/solve.h:

std::map<std::string, std::string> dolfin::krylov_solver_preconditioners()

Return a list of available preconditioners for current linear algebra backend

linear_algebra_backends

C++ documentation for linear_algebra_backends from dolfin/la/solve.h:

std::map<std::string, std::string> dolfin::linear_algebra_backends()

Return available linear algebra backends.

linear_solver_methods

C++ documentation for linear_solver_methods from dolfin/la/solve.h:

std::map<std::string, std::string> dolfin::linear_solver_methods()

Return a list of available solver methods for current linear algebra backend

list_krylov_solver_methods

C++ documentation for list_krylov_solver_methods from dolfin/la/solve.h:

void dolfin::list_krylov_solver_methods()

List available Krylov methods for current linear algebra backend.

list_krylov_solver_preconditioners

C++ documentation for list_krylov_solver_preconditioners from dolfin/la/solve.h:

void dolfin::list_krylov_solver_preconditioners()

List available preconditioners for current linear algebra backend

list_linear_algebra_backends

C++ documentation for list_linear_algebra_backends from dolfin/la/solve.h:

void dolfin::list_linear_algebra_backends()

List available linear algebra backends.

list_linear_solver_methods

C++ documentation for list_linear_solver_methods from dolfin/la/solve.h:

void dolfin::list_linear_solver_methods()

List available solver methods for current linear algebra backend.

list_lu_solver_methods

C++ documentation for list_lu_solver_methods from dolfin/la/solve.h:

void dolfin::list_lu_solver_methods()

List available LU methods for current linear algebra backend.

lu_solver_methods

C++ documentation for lu_solver_methods from dolfin/la/solve.h:

std::map<std::string, std::string> dolfin::lu_solver_methods()

Return a list of available LU methods for current linear algebra backend

norm

C++ documentation for norm from dolfin/la/solve.h:

double dolfin::norm(const GenericVector &x, std::string norm_type = "l2")

Compute norm of vector. Valid norm types are “l2”, “l1” and “linf”.

Parameters:
  • x
  • norm_type
normalize

C++ documentation for normalize from dolfin/la/solve.h:

double dolfin::normalize(GenericVector &x, std::string normalization_type = "average")

Normalize vector according to given normalization type.

Parameters:
  • x
  • normalization_type
residual

C++ documentation for residual from dolfin/la/solve.h:

double dolfin::residual(const GenericLinearOperator &A, const GenericVector &x, const GenericVector &b)

Compute residual ||Ax - b||.

Parameters:
  • A
  • x
  • b
solve

C++ documentation for solve from dolfin/la/solve.h:

std::size_t dolfin::solve(const GenericLinearOperator &A, GenericVector &x, const GenericVector &b, std::string method = "lu", std::string preconditioner = "none")

Solve linear system Ax = b.

Parameters:
  • A
  • x
  • b
  • method
  • preconditioner
usermult

C++ documentation for usermult from dolfin/la/PETScLinearOperator.cpp:

int dolfin::usermult(Mat A, Vec x, Vec y)

Callback function for PETSc mult function.

Parameters:
  • A
  • x
  • y

Classes

Amesos2LUSolver

C++ documentation for Amesos2LUSolver from dolfin/la/Amesos2LUSolver.h:

class dolfin::Amesos2LUSolver : public dolfin::GenericLinearSolver

This class implements the direct solution (LU factorization) for linear systems of the form Ax = b. It is a wrapper for the Trilinos Amesos2 LU solver.

dolfin::Amesos2LUSolver::Amesos2LUSolver(std::shared_ptr<const TpetraMatrix> A, std::string method = "default")

Constructor.

Parameters:
  • A
  • method
dolfin::Amesos2LUSolver::Amesos2LUSolver(std::string method = "default")

Constructor.

Parameters:method
const GenericLinearOperator &dolfin::Amesos2LUSolver::get_operator() const

Get operator (matrix)

void dolfin::Amesos2LUSolver::init_solver(std::string &method)
Parameters:method
std::map<std::string, std::string> dolfin::Amesos2LUSolver::methods()

Return a list of available solver methods.

std::string dolfin::Amesos2LUSolver::parameter_type() const

Return parameter type: “krylov_solver” or “lu_solver”.

void dolfin::Amesos2LUSolver::set_operator(std::shared_ptr<const GenericLinearOperator> A)

Set operator (matrix)

Parameters:A
void dolfin::Amesos2LUSolver::set_operator(std::shared_ptr<const TpetraMatrix> A)

Set operator (matrix)

Parameters:A
std::size_t dolfin::Amesos2LUSolver::solve(GenericVector &x, const GenericVector &b)

Solve linear system Ax = b.

Parameters:
  • x
  • b
std::size_t dolfin::Amesos2LUSolver::solve(const GenericLinearOperator &A, GenericVector &x, const GenericVector &b)

Solve linear system Ax = b.

Parameters:
  • A
  • x
  • b
std::size_t dolfin::Amesos2LUSolver::solve(const TpetraMatrix &A, TpetraVector &x, const TpetraVector &b)

Solve linear system Ax = b.

Parameters:
  • A
  • x
  • b
std::string dolfin::Amesos2LUSolver::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
dolfin::Amesos2LUSolver::~Amesos2LUSolver()

Destructor.

BelosKrylovSolver

C++ documentation for BelosKrylovSolver from dolfin/la/BelosKrylovSolver.h:

class dolfin::BelosKrylovSolver : public dolfin::GenericLinearSolver

This class implements Krylov methods for linear systems of the form Ax = b. It is a wrapper for the Belos iterative solver from Trilinos

Friends: Ifpack2Preconditioner, MueluPreconditioner.

dolfin::BelosKrylovSolver::BelosKrylovSolver(std::string method, std::shared_ptr<TrilinosPreconditioner> preconditioner)

Create Krylov solver for a particular method and TrilinosPreconditioner .

Parameters:
  • method
  • preconditioner
dolfin::BelosKrylovSolver::BelosKrylovSolver(std::string method = "default", std::string preconditioner = "default")

Create Krylov solver for a particular method and names preconditioner

Parameters:
  • method
  • preconditioner
void dolfin::BelosKrylovSolver::check_dimensions(const TpetraMatrix &A, const GenericVector &x, const GenericVector &b) const
Parameters:
  • A
  • x
  • b
const TpetraMatrix &dolfin::BelosKrylovSolver::get_operator() const

Get operator (matrix)

void dolfin::BelosKrylovSolver::init(const std::string &method)
Parameters:method
std::map<std::string, std::string> dolfin::BelosKrylovSolver::methods()

Return a list of available solver methods.

type dolfin::BelosKrylovSolver::op_type

Tpetra operator type.

std::string dolfin::BelosKrylovSolver::parameter_type() const

Return parameter type: “krylov_solver” or “lu_solver”.

std::map<std::string, std::string> dolfin::BelosKrylovSolver::preconditioners()

Return a list of available preconditioners.

type dolfin::BelosKrylovSolver::problem_type

Belos problem type.

void dolfin::BelosKrylovSolver::set_operator(std::shared_ptr<const GenericLinearOperator> A)

Set operator (matrix)

Parameters:A
void dolfin::BelosKrylovSolver::set_operators(std::shared_ptr<const GenericLinearOperator> A, std::shared_ptr<const GenericLinearOperator> P)

Set operator (matrix) and preconditioner matrix.

Parameters:
  • A
  • P
void dolfin::BelosKrylovSolver::set_options()
std::size_t dolfin::BelosKrylovSolver::solve(GenericVector &x, const GenericVector &b)

Solve linear system Ax = b and return number of iterations.

Parameters:
  • x
  • b
std::size_t dolfin::BelosKrylovSolver::solve(const GenericLinearOperator &A, GenericVector &x, const GenericVector &b)

Solve linear system Ax = b and return number of iterations.

Parameters:
  • A
  • x
  • b
std::string dolfin::BelosKrylovSolver::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
dolfin::BelosKrylovSolver::~BelosKrylovSolver()

Destructor.

BlockMatrix

C++ documentation for BlockMatrix from dolfin/la/BlockMatrix.h:

class dolfin::BlockMatrix

Block Matrix .

dolfin::BlockMatrix::BlockMatrix(std::size_t m = 0, std::size_t n = 0)

Constructor.

Parameters:
  • m
  • n
void dolfin::BlockMatrix::apply(std::string mode)

Finalize assembly of tensor.

Parameters:mode
std::shared_ptr<GenericMatrix> dolfin::BlockMatrix::get_block(std::size_t i, std::size_t j)

Get block.

Parameters:
  • i
  • j
std::shared_ptr<const GenericMatrix> dolfin::BlockMatrix::get_block(std::size_t i, std::size_t j) const

Get block (const version)

Parameters:
  • i
  • j
boost::multi_array<std::shared_ptr<GenericMatrix>, 2> dolfin::BlockMatrix::matrices
void dolfin::BlockMatrix::mult(const BlockVector &x, BlockVector &y, bool transposed = false) const

Matrix-vector product, y = Ax.

Parameters:
  • x
  • y
  • transposed
std::shared_ptr<GenericMatrix> dolfin::BlockMatrix::schur_approximation(bool symmetry = true) const

Create a crude explicit Schur approximation of S = D - C A^-1 B of (A B; C D) If symmetry != 0, then the caller promises that B = symmetry * transpose(C).

Parameters:symmetry
void dolfin::BlockMatrix::set_block(std::size_t i, std::size_t j, std::shared_ptr<GenericMatrix> m)

Set block.

Parameters:
  • i
  • j
  • m
std::size_t dolfin::BlockMatrix::size(std::size_t dim) const

Return size of given dimension.

Parameters:dim
std::string dolfin::BlockMatrix::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
void dolfin::BlockMatrix::zero()

Set all entries to zero and keep any sparse structure.

dolfin::BlockMatrix::~BlockMatrix()

Destructor.

BlockVector

C++ documentation for BlockVector from dolfin/la/BlockVector.h:

class dolfin::BlockVector

Block vector.

dolfin::BlockVector::BlockVector(std::size_t n = 0)

Constructor.

Parameters:n
void dolfin::BlockVector::axpy(double a, const BlockVector &x)

Add multiple of given vector (AXPY operation)

Parameters:
  • a
  • x
BlockVector *dolfin::BlockVector::copy() const

Return copy of tensor.

bool dolfin::BlockVector::empty() const

Return true if empty.

std::shared_ptr<const GenericVector> dolfin::BlockVector::get_block(std::size_t i) const

Get sub-vector (const)

Parameters:i
std::shared_ptr<GenericVector> dolfin::BlockVector::get_block(std::size_t)

Get sub-vector (non-const)

Parameters:i
double dolfin::BlockVector::inner(const BlockVector &x) const

Return inner product with given vector.

Parameters:x
double dolfin::BlockVector::max() const

Return maximum value of vector.

double dolfin::BlockVector::min() const

Return minimum value of vector.

double dolfin::BlockVector::norm(std::string norm_type) const

Return norm of vector.

Parameters:norm_type
const BlockVector &dolfin::BlockVector::operator*=(double a)

Multiply vector by given number.

Parameters:a
const BlockVector &dolfin::BlockVector::operator+=(const BlockVector &x)

Add given vector.

Parameters:x
const BlockVector &dolfin::BlockVector::operator-=(const BlockVector &x)

Subtract given vector.

Parameters:x
const BlockVector &dolfin::BlockVector::operator/=(double a)

Divide vector by given number.

Parameters:a
const BlockVector &dolfin::BlockVector::operator=(const BlockVector &x)

Assignment operator.

Parameters:x
const BlockVector &dolfin::BlockVector::operator=(double a)

Assignment operator.

Parameters:a
void dolfin::BlockVector::set_block(std::size_t i, std::shared_ptr<GenericVector> v)

Set function.

Parameters:
  • i
  • v
std::size_t dolfin::BlockVector::size() const

Number of vectors.

std::string dolfin::BlockVector::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
std::vector<std::shared_ptr<GenericVector>> dolfin::BlockVector::vectors
dolfin::BlockVector::~BlockVector()

Destructor.

CoordinateMatrix

C++ documentation for CoordinateMatrix from dolfin/la/CoordinateMatrix.h:

class dolfin::CoordinateMatrix

Coordinate sparse matrix.

dolfin::CoordinateMatrix::CoordinateMatrix(const GenericMatrix &A, bool symmetric, bool base_one)

Constructor.

Parameters:
  • A
  • symmetric
  • base_one
bool dolfin::CoordinateMatrix::base_one() const

Whether indices start from 0 (C-style) or 1 (FORTRAN-style)

const std::vector<std::size_t> &dolfin::CoordinateMatrix::columns() const

Get column indices.

MPI_Comm dolfin::CoordinateMatrix::mpi_comm() const

Get MPI_Comm.

double dolfin::CoordinateMatrix::norm(std::string norm_type) const

Return norm of matrix.

Parameters:norm_type
const std::vector<std::size_t> &dolfin::CoordinateMatrix::rows() const

Get row indices.

std::size_t dolfin::CoordinateMatrix::size(std::size_t dim) const

Size

Parameters:dim – (std::size_t) Dimension (0 or 1)
const std::vector<double> &dolfin::CoordinateMatrix::values() const

Get values.

dolfin::CoordinateMatrix::~CoordinateMatrix()

Destructor.

DefaultFactory

C++ documentation for DefaultFactory from dolfin/la/DefaultFactory.h:

class dolfin::DefaultFactory

Default linear algebra factory based on global parameter “linear_algebra_backend”.

dolfin::DefaultFactory::DefaultFactory()

Constructor.

std::shared_ptr<dolfin::GenericLinearSolver> dolfin::DefaultFactory::create_krylov_solver(MPI_Comm comm, std::string method, std::string preconditioner) const

Create Krylov solver.

Parameters:
  • comm
  • method
  • preconditioner
std::shared_ptr<TensorLayout> dolfin::DefaultFactory::create_layout(std::size_t rank) const

Create empty tensor layout.

Parameters:rank
std::shared_ptr<GenericLinearOperator> dolfin::DefaultFactory::create_linear_operator(MPI_Comm comm) const

Create empty linear operator.

Parameters:comm
std::shared_ptr<dolfin::GenericLinearSolver> dolfin::DefaultFactory::create_lu_solver(MPI_Comm comm, std::string method) const

Create LU solver.

Parameters:
  • comm
  • method
std::shared_ptr<GenericMatrix> dolfin::DefaultFactory::create_matrix(MPI_Comm comm) const

Create empty matrix.

Parameters:comm
std::shared_ptr<GenericVector> dolfin::DefaultFactory::create_vector(MPI_Comm comm) const

Create empty vector.

Parameters:comm
GenericLinearAlgebraFactory &dolfin::DefaultFactory::factory()

Return instance of default backend.

std::map<std::string, std::string> dolfin::DefaultFactory::krylov_solver_methods() const

Return a list of available Krylov solver methods.

std::map<std::string, std::string> dolfin::DefaultFactory::krylov_solver_preconditioners() const

Return a list of available preconditioners.

std::map<std::string, std::string> dolfin::DefaultFactory::lu_solver_methods() const

Return a list of available LU solver methods.

dolfin::DefaultFactory::~DefaultFactory()

Destructor.

EigenFactory

C++ documentation for EigenFactory from dolfin/la/EigenFactory.h:

class dolfin::EigenFactory

Eigen linear algebra factory.

dolfin::EigenFactory::EigenFactory()
std::shared_ptr<GenericLinearSolver> dolfin::EigenFactory::create_krylov_solver(MPI_Comm comm, std::string method, std::string preconditioner) const

Create Krylov solver.

Parameters:
  • comm
  • method
  • preconditioner
std::shared_ptr<TensorLayout> dolfin::EigenFactory::create_layout(std::size_t rank) const

Create empty tensor layout.

Parameters:rank
std::shared_ptr<GenericLinearOperator> dolfin::EigenFactory::create_linear_operator(MPI_Comm comm) const

Create empty linear operator.

Parameters:comm
std::shared_ptr<GenericLinearSolver> dolfin::EigenFactory::create_lu_solver(MPI_Comm comm, std::string method) const

Create LU solver.

Parameters:
  • comm
  • method
std::shared_ptr<GenericMatrix> dolfin::EigenFactory::create_matrix(MPI_Comm comm) const

Create empty matrix.

Parameters:comm
std::shared_ptr<GenericVector> dolfin::EigenFactory::create_vector(MPI_Comm comm) const

Create empty vector.

Parameters:comm
EigenFactory dolfin::EigenFactory::factory
EigenFactory &dolfin::EigenFactory::instance()

Return singleton instance.

std::map<std::string, std::string> dolfin::EigenFactory::krylov_solver_methods() const

Return a list of available Krylov solver methods.

std::map<std::string, std::string> dolfin::EigenFactory::krylov_solver_preconditioners() const

Return a list of available preconditioners.

std::map<std::string, std::string> dolfin::EigenFactory::lu_solver_methods() const

Return a list of available LU solver methods.

dolfin::EigenFactory::~EigenFactory()

Destructor.

EigenKrylovSolver

C++ documentation for EigenKrylovSolver from dolfin/la/EigenKrylovSolver.h:

class dolfin::EigenKrylovSolver : public dolfin::GenericLinearSolver

This class implements Krylov methods for linear systems of the form Ax = b. It is a wrapper for the Krylov solvers of Eigen.

dolfin::EigenKrylovSolver::EigenKrylovSolver(std::string method = "default", std::string preconditioner = "default")

Create Krylov solver for a particular method and names preconditioner

Parameters:
  • method
  • preconditioner
std::size_t dolfin::EigenKrylovSolver::call_solver(Solver &solver, GenericVector &x, const GenericVector &b)
Parameters:
  • solver
  • x
  • b
std::shared_ptr<const EigenMatrix> dolfin::EigenKrylovSolver::get_operator() const

Get operator (matrix)

void dolfin::EigenKrylovSolver::init(const std::string method, const std::string pc = "default")
Parameters:
  • method
  • pc
std::map<std::string, std::string> dolfin::EigenKrylovSolver::methods()

Return a list of available solver methods.

std::string dolfin::EigenKrylovSolver::parameter_type() const

Return parameter type: “krylov_solver” or “lu_solver”.

std::map<std::string, std::string> dolfin::EigenKrylovSolver::preconditioners()

Return a list of available preconditioners.

void dolfin::EigenKrylovSolver::set_operator(std::shared_ptr<const EigenMatrix> A)

Set operator (matrix)

Parameters:A
void dolfin::EigenKrylovSolver::set_operator(std::shared_ptr<const GenericLinearOperator> A)

Set operator (matrix)

Parameters:A
void dolfin::EigenKrylovSolver::set_operators(std::shared_ptr<const EigenMatrix> A, std::shared_ptr<const EigenMatrix> P)

Set operator (matrix) and preconditioner matrix.

Parameters:
  • A
  • P
void dolfin::EigenKrylovSolver::set_operators(std::shared_ptr<const GenericLinearOperator> A, std::shared_ptr<const GenericLinearOperator> P)

Set operator (matrix) and preconditioner matrix.

Parameters:
  • A
  • P
std::size_t dolfin::EigenKrylovSolver::solve(EigenVector &x, const EigenVector &b)

Solve linear system Ax = b and return number of iterations.

Parameters:
  • x
  • b
std::size_t dolfin::EigenKrylovSolver::solve(GenericVector &x, const GenericVector &b)

Solve linear system Ax = b and return number of iterations.

Parameters:
  • x
  • b
std::size_t dolfin::EigenKrylovSolver::solve(const EigenMatrix &A, EigenVector &x, const EigenVector &b)

Solve linear system Ax = b and return number of iterations.

Parameters:
  • A
  • x
  • b
std::size_t dolfin::EigenKrylovSolver::solve(const GenericLinearOperator &A, GenericVector &x, const GenericVector &b)

Solve linear system Ax = b and return number of iterations.

Parameters:
  • A
  • x
  • b
std::string dolfin::EigenKrylovSolver::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
dolfin::EigenKrylovSolver::~EigenKrylovSolver()

Destructor.

EigenLUSolver

C++ documentation for EigenLUSolver from dolfin/la/EigenLUSolver.h:

class dolfin::EigenLUSolver : public dolfin::GenericLinearSolver

This class implements the direct solution (LU factorization) for linear systems of the form Ax = b.

dolfin::EigenLUSolver::EigenLUSolver(std::shared_ptr<const EigenMatrix> A, std::string method = "default")

Constructor.

Parameters:
  • A
  • method
dolfin::EigenLUSolver::EigenLUSolver(std::string method = "default")

Constructor.

Parameters:method
void dolfin::EigenLUSolver::call_solver(Solver &solver, GenericVector &x, const GenericVector &b)
Parameters:
  • solver
  • x
  • b
const GenericLinearOperator &dolfin::EigenLUSolver::get_operator() const

Get operator (matrix)

std::map<std::string, std::string> dolfin::EigenLUSolver::methods()

Return a list of available solver methods.

std::string dolfin::EigenLUSolver::parameter_type() const

Return parameter type: “krylov_solver” or “lu_solver”.

std::string dolfin::EigenLUSolver::select_solver(const std::string method) const
Parameters:method
void dolfin::EigenLUSolver::set_operator(std::shared_ptr<const EigenMatrix> A)

Set operator (matrix)

Parameters:A
void dolfin::EigenLUSolver::set_operator(std::shared_ptr<const GenericLinearOperator> A)

Set operator (matrix)

Parameters:A
std::size_t dolfin::EigenLUSolver::solve(GenericVector &x, const GenericVector &b)

Solve linear system Ax = b.

Parameters:
  • x
  • b
std::size_t dolfin::EigenLUSolver::solve(const EigenMatrix &A, EigenVector &x, const EigenVector &b)

Solve linear system Ax = b.

Parameters:
  • A
  • x
  • b
std::size_t dolfin::EigenLUSolver::solve(const GenericLinearOperator &A, GenericVector &x, const GenericVector &b)

Solve linear system Ax = b.

Parameters:
  • A
  • x
  • b
std::string dolfin::EigenLUSolver::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
dolfin::EigenLUSolver::~EigenLUSolver()

Destructor.

EigenMatrix

C++ documentation for EigenMatrix from dolfin/la/EigenMatrix.h:

class dolfin::EigenMatrix : public dolfin::GenericMatrix

This class provides a sparse matrix class based on Eigen. It is a simple wrapper for Eigen::SparseMatrix implementing the GenericMatrix interface. The interface is intentionally simple. For advanced usage, access the underlying Eigen matrix and use the standard Eigen interface which is documented at http://eigen.tuxfamily.org

dolfin::EigenMatrix::EigenMatrix()

Create empty matrix.

dolfin::EigenMatrix::EigenMatrix(const EigenMatrix &A)

Copy constructor.

Parameters:A
dolfin::EigenMatrix::EigenMatrix(std::size_t M, std::size_t N)

Create M x N matrix.

Parameters:
  • M
  • N
void dolfin::EigenMatrix::add(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Add block of values using global indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::EigenMatrix::add_local(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Add block of values using local indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::EigenMatrix::apply(std::string mode)

Finalize assembly of tensor.

Parameters:mode
void dolfin::EigenMatrix::axpy(double a, const GenericMatrix &A, bool same_nonzero_pattern)

Add multiple of given matrix (AXPY operation)

Parameters:
  • a
  • A
  • same_nonzero_pattern
void dolfin::EigenMatrix::compress()

Compress matrix (eliminate all zeros from a sparse matrix)

std::shared_ptr<GenericMatrix> dolfin::EigenMatrix::copy() const

Return copy of matrix.

std::tuple<const int *, const int *, const double *, std::size_t> dolfin::EigenMatrix::data() const

Return pointers to underlying compressed storage data See GenericMatrix for documentation.

type dolfin::EigenMatrix::eigen_matrix_type

Eigen Matrix type.

bool dolfin::EigenMatrix::empty() const

Return true if empty.

GenericLinearAlgebraFactory &dolfin::EigenMatrix::factory() const

Return linear algebra backend factory.

void dolfin::EigenMatrix::get(double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols) const

Get block of values.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::EigenMatrix::get_diagonal(GenericVector &x) const

Get diagonal of a matrix.

Parameters:x
void dolfin::EigenMatrix::getrow(std::size_t row, std::vector<std::size_t> &columns, std::vector<double> &values) const

Get non-zero values of given row.

Parameters:
  • row
  • columns
  • values
void dolfin::EigenMatrix::ident(std::size_t m, const dolfin::la_index *rows)

Set given rows to identity matrix.

Parameters:
  • m
  • rows
void dolfin::EigenMatrix::ident_local(std::size_t m, const dolfin::la_index *rows)

Set given rows to identity matrix.

Parameters:
  • m
  • rows
void dolfin::EigenMatrix::init(const TensorLayout &tensor_layout)

Initialize zero tensor using tenor layout.

Parameters:tensor_layout
void dolfin::EigenMatrix::init_vector(GenericVector &z, std::size_t dim) const

Initialise vector z to be compatible with the matrix-vector product y = Ax.

Parameters:
  • z – (GenericVector &) Vector to initialise
  • dim – (std::size_t) The dimension (axis): dim = 0 –> z = y, dim = 1 –> z = x
std::pair<std::int64_t, std::int64_t> dolfin::EigenMatrix::local_range(std::size_t dim) const

Return local ownership range.

Parameters:dim
eigen_matrix_type &dolfin::EigenMatrix::mat()

Return reference to Eigen matrix (non-const version)

const eigen_matrix_type &dolfin::EigenMatrix::mat() const

Return reference to Eigen matrix (const version)

MPI_Comm dolfin::EigenMatrix::mpi_comm() const

Return MPI communicator.

void dolfin::EigenMatrix::mult(const GenericVector &x, GenericVector &y) const

Matrix-vector product, y = Ax.

Parameters:
  • x
  • y
std::size_t dolfin::EigenMatrix::nnz() const

Return number of non-zero entries in matrix.

double dolfin::EigenMatrix::norm(std::string norm_type) const

Return norm of matrix.

Parameters:norm_type
double dolfin::EigenMatrix::operator()(dolfin::la_index i, dolfin::la_index j) const

Access value of given entry.

Parameters:
  • i
  • j
const EigenMatrix &dolfin::EigenMatrix::operator*=(double a)

Multiply matrix by given number.

Parameters:a
const EigenMatrix &dolfin::EigenMatrix::operator/=(double a)

Divide matrix by given number.

Parameters:a
const EigenMatrix &dolfin::EigenMatrix::operator=(const EigenMatrix &A)

Assignment operator.

Parameters:A
const GenericMatrix &dolfin::EigenMatrix::operator=(const GenericMatrix &A)

Assignment operator.

Parameters:A
void dolfin::EigenMatrix::resize(std::size_t M, std::size_t N)

Resize matrix to M x N.

Parameters:
  • M
  • N
void dolfin::EigenMatrix::set(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Set block of values using global indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::EigenMatrix::set_diagonal(const GenericVector &x)

Set diagonal of a matrix.

Parameters:x
void dolfin::EigenMatrix::set_local(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Set block of values using local indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::EigenMatrix::setrow(std::size_t row_idx, const std::vector<std::size_t> &columns, const std::vector<double> &values)

Set values for given row.

Parameters:
  • row_idx
  • columns
  • values
std::size_t dolfin::EigenMatrix::size(std::size_t dim) const

Return size of given dimension.

Parameters:dim
std::string dolfin::EigenMatrix::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
void dolfin::EigenMatrix::transpmult(const GenericVector &x, GenericVector &y) const

Matrix-vector product, y = A^T x.

Parameters:
  • x
  • y
void dolfin::EigenMatrix::zero()

Set all entries to zero and keep any sparse structure.

void dolfin::EigenMatrix::zero(std::size_t m, const dolfin::la_index *rows)

Set given rows (global row indices) to zero.

Parameters:
  • m
  • rows
void dolfin::EigenMatrix::zero_local(std::size_t m, const dolfin::la_index *rows)

Set given rows (local row indices) to zero.

Parameters:
  • m
  • rows
dolfin::EigenMatrix::~EigenMatrix()

Destructor.

EigenVector

C++ documentation for EigenVector from dolfin/la/EigenVector.h:

class dolfin::EigenVector : public dolfin::GenericVector

This class provides a simple vector class based on Eigen. It is a simple wrapper for a Eigen vector implementing the GenericVector interface. The interface is intentionally simple. For advanced usage, access the underlying Eigen vector and use the standard Eigen interface which is documented at http://eigen.tuxfamily.org

dolfin::EigenVector::EigenVector()

Create empty vector (on MPI_COMM_SELF)

dolfin::EigenVector::EigenVector(MPI_Comm comm)

Create empty vector.

Parameters:comm
dolfin::EigenVector::EigenVector(MPI_Comm comm, std::size_t N)

Create vector of size N.

Parameters:
  • comm
  • N
dolfin::EigenVector::EigenVector(const EigenVector &x)

Copy constructor.

Parameters:x
dolfin::EigenVector::EigenVector(std::shared_ptr<Eigen::VectorXd> x)

Construct vector from an Eigen shared_ptr.

Parameters:x
void dolfin::EigenVector::abs()

Replace all entries in the vector by their absolute values.

void dolfin::EigenVector::add(const double *block, std::size_t m, const dolfin::la_index *rows)

Add block of values using global indices.

Parameters:
  • block
  • m
  • rows
void dolfin::EigenVector::add_local(const Array<double> &values)

Add values to each entry on local process.

Parameters:values
void dolfin::EigenVector::add_local(const double *block, std::size_t m, const dolfin::la_index *rows)

Add block of values using local indices.

Parameters:
  • block
  • m
  • rows
void dolfin::EigenVector::apply(std::string mode)

Finalize assembly of tensor.

Parameters:mode
void dolfin::EigenVector::axpy(double a, const GenericVector &x)

Add multiple of given vector (AXPY operation)

Parameters:
  • a
  • x
void dolfin::EigenVector::check_mpi_size(const MPI_Comm comm)
Parameters:comm
std::shared_ptr<GenericVector> dolfin::EigenVector::copy() const

Create copy of tensor.

double *dolfin::EigenVector::data()

Return pointer to underlying data.

const double *dolfin::EigenVector::data() const

Return pointer to underlying data (const version)

bool dolfin::EigenVector::empty() const

Return true if vector is empty.

GenericLinearAlgebraFactory &dolfin::EigenVector::factory() const

Return linear algebra backend factory.

void dolfin::EigenVector::gather(GenericVector &x, const std::vector<dolfin::la_index> &indices) const

Gather entries into local vector x.

Parameters:
  • x
  • indices
void dolfin::EigenVector::gather(std::vector<double> &x, const std::vector<dolfin::la_index> &indices) const

Gather entries into x.

Parameters:
  • x
  • indices
void dolfin::EigenVector::gather_on_zero(std::vector<double> &x) const

Gather all entries into x on process 0.

Parameters:x
void dolfin::EigenVector::get(double *block, std::size_t m, const dolfin::la_index *rows) const

Get block of values using global indices.

Parameters:
  • block
  • m
  • rows
void dolfin::EigenVector::get_local(double *block, std::size_t m, const dolfin::la_index *rows) const

Get block of values using local indices.

Parameters:
  • block
  • m
  • rows
void dolfin::EigenVector::get_local(std::vector<double> &values) const

Get all values on local process.

Parameters:values
void dolfin::EigenVector::init(std::pair<std::size_t, std::size_t> range)

Resize vector with given ownership range.

Parameters:range
void dolfin::EigenVector::init(std::pair<std::size_t, std::size_t> range, const std::vector<std::size_t> &local_to_global_map, const std::vector<la_index> &ghost_indices)

Resize vector with given ownership range and with ghost values.

Parameters:
  • range
  • local_to_global_map
  • ghost_indices
void dolfin::EigenVector::init(std::size_t N)

Initialize vector to size N.

Parameters:N
double dolfin::EigenVector::inner(const GenericVector &x) const

Return inner product with given vector.

Parameters:x
std::pair<std::int64_t, std::int64_t> dolfin::EigenVector::local_range() const

Return local ownership range of a vector.

std::size_t dolfin::EigenVector::local_size() const

Return local size of vector.

double dolfin::EigenVector::max() const

Return maximum value of vector.

double dolfin::EigenVector::min() const

Return minimum value of vector.

MPI_Comm dolfin::EigenVector::mpi_comm() const

Return MPI communicator.

double dolfin::EigenVector::norm(std::string norm_type) const

Compute norm of vector.

Parameters:norm_type
const EigenVector &dolfin::EigenVector::operator*=(const GenericVector &x)

Multiply vector by another vector pointwise.

Parameters:x
const EigenVector &dolfin::EigenVector::operator*=(double a)

Multiply vector by given number.

Parameters:a
const EigenVector &dolfin::EigenVector::operator+=(const GenericVector &x)

Add given vector.

Parameters:x
const EigenVector &dolfin::EigenVector::operator+=(double a)

Add number to all components of a vector.

Parameters:a
const EigenVector &dolfin::EigenVector::operator-=(const GenericVector &x)

Subtract given vector.

Parameters:x
const EigenVector &dolfin::EigenVector::operator-=(double a)

Subtract number from all components of a vector.

Parameters:a
const EigenVector &dolfin::EigenVector::operator/=(double a)

Divide vector by given number.

Parameters:a
const EigenVector &dolfin::EigenVector::operator=(const EigenVector &x)

Assignment operator.

Parameters:x
const GenericVector &dolfin::EigenVector::operator=(const GenericVector &x)

Assignment operator.

Parameters:x
const EigenVector &dolfin::EigenVector::operator=(double a)

Assignment operator.

Parameters:a
double &dolfin::EigenVector::operator[](dolfin::la_index i)

Access value of given entry (non-const version)

Parameters:i
double dolfin::EigenVector::operator[](dolfin::la_index i) const

Access value of given entry (const version)

Parameters:i
bool dolfin::EigenVector::owns_index(std::size_t i) const

Determine whether global vector index is owned by this process.

Parameters:i
void dolfin::EigenVector::resize(std::size_t N)

Resize vector to size N.

Parameters:N
void dolfin::EigenVector::set(const double *block, std::size_t m, const dolfin::la_index *rows)

Set block of values using global indices.

Parameters:
  • block
  • m
  • rows
void dolfin::EigenVector::set_local(const double *block, std::size_t m, const dolfin::la_index *rows)

Set block of values using local indices.

Parameters:
  • block
  • m
  • rows
void dolfin::EigenVector::set_local(const std::vector<double> &values)

Set all values on local process.

Parameters:values
std::size_t dolfin::EigenVector::size() const

Return true if vector is empty.

std::string dolfin::EigenVector::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
double dolfin::EigenVector::sum() const

Return sum of values of vector.

double dolfin::EigenVector::sum(const Array<std::size_t> &rows) const

Return sum of selected rows in vector. Repeated entries are only summed once.

Parameters:rows
Eigen::VectorXd &dolfin::EigenVector::vec()

Return reference to Eigen vector (non-const version)

const Eigen::VectorXd &dolfin::EigenVector::vec() const

Return reference to Eigen vector (const version)

void dolfin::EigenVector::zero()

Set all entries to zero and keep any sparse structure.

dolfin::EigenVector::~EigenVector()

Destructor.

GenericLinearAlgebraFactory

C++ documentation for GenericLinearAlgebraFactory from dolfin/la/GenericLinearAlgebraFactory.h:

class dolfin::GenericLinearAlgebraFactory

Base class for LinearAlgebra factories.

dolfin::GenericLinearAlgebraFactory::GenericLinearAlgebraFactory()

Constructor.

std::shared_ptr<GenericLinearSolver> dolfin::GenericLinearAlgebraFactory::create_krylov_solver(MPI_Comm comm, std::string method, std::string preconditioner) const = 0

Create Krylov solver.

Parameters:
  • comm
  • method
  • preconditioner
std::shared_ptr<TensorLayout> dolfin::GenericLinearAlgebraFactory::create_layout(std::size_t rank) const = 0

Create empty tensor layout.

Parameters:rank
std::shared_ptr<GenericLinearOperator> dolfin::GenericLinearAlgebraFactory::create_linear_operator(MPI_Comm comm) const = 0

Create empty linear operator.

Parameters:comm
std::shared_ptr<GenericLinearSolver> dolfin::GenericLinearAlgebraFactory::create_lu_solver(MPI_Comm comm, std::string method) const = 0

Create LU solver.

Parameters:
  • comm
  • method
std::shared_ptr<GenericMatrix> dolfin::GenericLinearAlgebraFactory::create_matrix(MPI_Comm comm) const = 0

Create empty matrix.

Parameters:comm
std::shared_ptr<GenericVector> dolfin::GenericLinearAlgebraFactory::create_vector(MPI_Comm comm) const = 0

Create empty vector.

Parameters:comm
std::map<std::string, std::string> dolfin::GenericLinearAlgebraFactory::krylov_solver_methods() const

Return a list of available Krylov solver methods. This function should be overloaded by subclass if non-empty.

std::map<std::string, std::string> dolfin::GenericLinearAlgebraFactory::krylov_solver_preconditioners() const

Return a list of available preconditioners. This function should be overloaded by subclass if non-empty.

std::map<std::string, std::string> dolfin::GenericLinearAlgebraFactory::lu_solver_methods() const

Return a list of available LU solver methods. This function should be overloaded by subclass if non-empty.

dolfin::GenericLinearAlgebraFactory::~GenericLinearAlgebraFactory()

Destructor.

GenericLinearOperator

C++ documentation for GenericLinearOperator from dolfin/la/GenericLinearOperator.h:

class dolfin::GenericLinearOperator : public dolfin::LinearAlgebraObject

This class defines a common interface for linear operators, including actual matrices (class GenericMatrix ) and linear operators only defined in terms of their action on vectors. This class is used internally by DOLFIN to define a class hierarchy of backend independent linear operators and solvers. Users should not interface to this class directly but instead use the LinearOperator class.

Friends: LinearOperator.

void dolfin::GenericLinearOperator::init_layout(const GenericVector &x, const GenericVector &y, GenericLinearOperator *wrapper)

Initialize linear operator to match parallel layout of vectors x and y for product y = Ax. Needs to be implemented by backend.

Parameters:
  • x
  • y
  • wrapper
void dolfin::GenericLinearOperator::mult(const GenericVector &x, GenericVector &y) const = 0

Compute matrix-vector product y = Ax.

Parameters:
  • x
  • y
std::size_t dolfin::GenericLinearOperator::size(std::size_t dim) const = 0

Return size of given dimension.

Parameters:dim
std::string dolfin::GenericLinearOperator::str(bool verbose) const = 0

Return informal string representation (pretty-print)

Parameters:verbose
dolfin::GenericLinearOperator::~GenericLinearOperator()
GenericLinearSolver

C++ documentation for GenericLinearSolver from dolfin/la/GenericLinearSolver.h:

class dolfin::GenericLinearSolver

This class provides a general solver for linear systems Ax = b.

std::string dolfin::GenericLinearSolver::parameter_type() const

Return parameter type: “krylov_solver” or “lu_solver”.

const GenericMatrix &dolfin::GenericLinearSolver::require_matrix(const GenericLinearOperator &A)

Down-cast GenericLinearOperator to GenericMatrix when an actual matrix is required, not only a linear operator. This is the const reference version of the down-cast.

Parameters:A
std::shared_ptr<const GenericMatrix> dolfin::GenericLinearSolver::require_matrix(std::shared_ptr<const GenericLinearOperator> A)

Down-cast GenericLinearOperator to GenericMatrix when an actual matrix is required, not only a linear operator. This is the const reference version of the down-cast.

Parameters:A
void dolfin::GenericLinearSolver::set_operator(std::shared_ptr<const GenericLinearOperator> A) = 0

Set operator (matrix)

Parameters:A
void dolfin::GenericLinearSolver::set_operators(std::shared_ptr<const GenericLinearOperator> A, std::shared_ptr<const GenericLinearOperator> P)

Set operator (matrix) and preconditioner matrix.

Parameters:
  • A
  • P
std::size_t dolfin::GenericLinearSolver::solve(GenericVector &x, const GenericVector &b) = 0

Solve linear system Ax = b.

Parameters:
  • x
  • b
std::size_t dolfin::GenericLinearSolver::solve(const GenericLinearOperator &A, GenericVector &x, const GenericVector &b)

Solve linear system Ax = b.

Parameters:
  • A
  • x
  • b
void dolfin::GenericLinearSolver::update_parameters(const Parameters &parameters)

Update solver parameters (useful for LinearSolver wrapper)

Parameters:parameters
GenericMatrix

C++ documentation for GenericMatrix from dolfin/la/GenericMatrix.h:

class dolfin::GenericMatrix : public dolfin::GenericLinearOperator, dolfin::GenericTensor

This class defines a common interface for matrices.

void dolfin::GenericMatrix::add(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)

Add block of values using global indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericMatrix::add(const double *block, const std::vector<ArrayView<const dolfin::la_index>> &rows)

Add block of values using global indices.

Parameters:
  • block
  • rows
void dolfin::GenericMatrix::add(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols) = 0

Add block of values using global indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::GenericMatrix::add_local(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)

Add block of values using local indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericMatrix::add_local(const double *block, const std::vector<ArrayView<const dolfin::la_index>> &rows)

Add block of values using local indices.

Parameters:
  • block
  • rows
void dolfin::GenericMatrix::add_local(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols) = 0

Add block of values using local indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::GenericMatrix::apply(std::string mode) = 0

Finalize assembly of tensor.

Parameters:mode
void dolfin::GenericMatrix::axpy(double a, const GenericMatrix &A, bool same_nonzero_pattern) = 0

Add multiple of given matrix (AXPY operation)

Parameters:
  • a
  • A
  • same_nonzero_pattern
std::shared_ptr<GenericMatrix> dolfin::GenericMatrix::copy() const = 0

Return copy of matrix.

void dolfin::GenericMatrix::get(double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows) const

Get block of values.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericMatrix::get(double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols) const = 0

Get block of values.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::GenericMatrix::get_diagonal(GenericVector &x) const = 0

Get diagonal of a matrix.

Parameters:x
double dolfin::GenericMatrix::getitem(std::pair<dolfin::la_index, dolfin::la_index> ij) const

Get value of given entry.

Parameters:ij
void dolfin::GenericMatrix::getrow(std::size_t row, std::vector<std::size_t> &columns, std::vector<double> &values) const = 0

Get non-zero values of given row (global index) on local process.

Parameters:
  • row
  • columns
  • values
void dolfin::GenericMatrix::ident(std::size_t m, const dolfin::la_index *rows) = 0

Set given rows (global row indices) to identity matrix.

Parameters:
  • m
  • rows
void dolfin::GenericMatrix::ident_local(std::size_t m, const dolfin::la_index *rows) = 0

Set given rows (local row indices) to identity matrix.

Parameters:
  • m
  • rows
void dolfin::GenericMatrix::ident_zeros()

Insert one on the diagonal for all zero rows.

void dolfin::GenericMatrix::init_vector(GenericVector &z, std::size_t dim) const = 0

Initialize vector z to be compatible with the matrix-vector product y = Ax. In the parallel case, both size and layout are important.

Parameters:
  • z – (GenericVector &) Vector to initialise
  • dim – (std::size_t) The dimension (axis): dim = 0 –> z = y, dim = 1 –> z = x
bool dolfin::GenericMatrix::is_symmetric(double tol) const

Test if matrix is symmetric.

Parameters:tol
std::pair<std::int64_t, std::int64_t> dolfin::GenericMatrix::local_range(std::size_t dim) const = 0

Return local ownership range.

Parameters:dim
std::size_t dolfin::GenericMatrix::nnz() const = 0

Return number of non-zero entries in matrix (collective)

double dolfin::GenericMatrix::norm(std::string norm_type) const = 0

Return norm of matrix.

Parameters:norm_type
double dolfin::GenericMatrix::operator()(dolfin::la_index i, dolfin::la_index j) const

Get value of given entry.

Parameters:
  • i
  • j
const GenericMatrix &dolfin::GenericMatrix::operator*=(double a) = 0

Multiply matrix by given number.

Parameters:a
const GenericMatrix &dolfin::GenericMatrix::operator+=(const GenericMatrix &A)

Add given matrix.

Parameters:A
const GenericMatrix &dolfin::GenericMatrix::operator-=(const GenericMatrix &A)

Subtract given matrix.

Parameters:A
const GenericMatrix &dolfin::GenericMatrix::operator/=(double a) = 0

Divide matrix by given number.

Parameters:a
const GenericMatrix &dolfin::GenericMatrix::operator=(const GenericMatrix &x) = 0

Assignment operator.

Parameters:x
std::size_t dolfin::GenericMatrix::rank() const

Return tensor rank (number of dimensions)

void dolfin::GenericMatrix::set(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)

Set block of values using global indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericMatrix::set(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols) = 0

Set block of values using global indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::GenericMatrix::set_diagonal(const GenericVector &x) = 0

Set diagonal of a matrix.

Parameters:x
void dolfin::GenericMatrix::set_local(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)

Set block of values using local indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericMatrix::set_local(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols) = 0

Set block of values using local indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::GenericMatrix::setitem(std::pair<dolfin::la_index, dolfin::la_index> ij, double value)

Set given entry to value. apply(“insert”) must be called before using using the object.

Parameters:
  • ij
  • value
void dolfin::GenericMatrix::setrow(std::size_t row, const std::vector<std::size_t> &columns, const std::vector<double> &values) = 0

Set values for given row (global index) on local process.

Parameters:
  • row
  • columns
  • values
std::size_t dolfin::GenericMatrix::size(std::size_t dim) const = 0

Return size of given dimension.

Parameters:dim
std::string dolfin::GenericMatrix::str(bool verbose) const = 0

Return informal string representation (pretty-print)

Parameters:verbose
void dolfin::GenericMatrix::transpmult(const GenericVector &x, GenericVector &y) const = 0

Matrix-vector product, y = A^T x. The y vector must either be zero-sized or have correct size and parallel layout.

Parameters:
  • x
  • y
void dolfin::GenericMatrix::zero() = 0

Set all entries to zero and keep any sparse structure.

void dolfin::GenericMatrix::zero(std::size_t m, const dolfin::la_index *rows) = 0

Set given rows (global row indices) to zero.

Parameters:
  • m
  • rows
void dolfin::GenericMatrix::zero_local(std::size_t m, const dolfin::la_index *rows) = 0

Set given rows (local row indices) to zero.

Parameters:
  • m
  • rows
dolfin::GenericMatrix::~GenericMatrix()

Destructor.

GenericTensor

C++ documentation for GenericTensor from dolfin/la/GenericTensor.h:

class dolfin::GenericTensor : public dolfin::LinearAlgebraObject

A common interface for arbitrary rank tensors.

void dolfin::GenericTensor::add(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows) = 0

Add block of values using global indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericTensor::add(const double *block, const std::vector<ArrayView<const dolfin::la_index>> &rows) = 0

Add block of values using global indices.

Parameters:
  • block
  • rows
void dolfin::GenericTensor::add_local(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows) = 0

Add block of values using local indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericTensor::add_local(const double *block, const std::vector<ArrayView<const dolfin::la_index>> &rows) = 0

Add block of values using local indices.

Parameters:
  • block
  • rows
void dolfin::GenericTensor::apply(std::string mode) = 0

Finalize assembly of tensor.

Parameters:mode
bool dolfin::GenericTensor::empty() const = 0

Return true if empty.

GenericLinearAlgebraFactory &dolfin::GenericTensor::factory() const = 0

Return linear algebra backend factory.

void dolfin::GenericTensor::get(double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows) const = 0

Get block of values.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericTensor::init(const TensorLayout &tensor_layout) = 0

Initialize zero tensor using tensor layout.

Parameters:tensor_layout
std::pair<std::int64_t, std::int64_t> dolfin::GenericTensor::local_range(std::size_t dim) const = 0

Return local ownership range.

Parameters:dim
std::size_t dolfin::GenericTensor::rank() const = 0

Return tensor rank (number of dimensions)

void dolfin::GenericTensor::set(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows) = 0

Set block of values using global indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericTensor::set_local(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows) = 0

Set block of values using local indices.

Parameters:
  • block
  • num_rows
  • rows
std::size_t dolfin::GenericTensor::size(std::size_t dim) const = 0

Return size of given dimension.

Parameters:dim
std::string dolfin::GenericTensor::str(bool verbose) const = 0

Return MPI communicator. Return informal string representation (pretty-print)

Parameters:verbose
void dolfin::GenericTensor::zero() = 0

Set all entries to zero and keep any sparse structure.

dolfin::GenericTensor::~GenericTensor()

Destructor.

GenericVector

C++ documentation for GenericVector from dolfin/la/GenericVector.h:

class dolfin::GenericVector : public dolfin::GenericTensor

This class defines a common interface for vectors.

void dolfin::GenericVector::abs() = 0

Replace all entries in the vector by their absolute values.

void dolfin::GenericVector::add(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)

Add block of values using global indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericVector::add(const double *block, const std::vector<ArrayView<const dolfin::la_index>> &rows)

Add block of values using global indices.

Parameters:
  • block
  • rows
void dolfin::GenericVector::add(const double *block, std::size_t m, const dolfin::la_index *rows) = 0

Add block of values using global indices.

Parameters:
  • block
  • m
  • rows
void dolfin::GenericVector::add_local(const Array<double> &values) = 0

Add values to each entry on local process.

Parameters:values
void dolfin::GenericVector::add_local(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)

Add block of values using local indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericVector::add_local(const double *block, const std::vector<ArrayView<const dolfin::la_index>> &rows)

Add block of values using local indices.

Parameters:
  • block
  • rows
void dolfin::GenericVector::add_local(const double *block, std::size_t m, const dolfin::la_index *rows) = 0

Add block of values using local indices.

Parameters:
  • block
  • m
  • rows
void dolfin::GenericVector::apply(std::string mode) = 0

Finalize assembly of tensor.

Parameters:mode
void dolfin::GenericVector::axpy(double a, const GenericVector &x) = 0

Add multiple of given vector (AXPY operation)

Parameters:
  • a
  • x
std::shared_ptr<GenericVector> dolfin::GenericVector::copy() const = 0

Return copy of vector.

void dolfin::GenericVector::gather(GenericVector &x, const std::vector<dolfin::la_index> &indices) const = 0

Gather entries (given by global indices) into local vector x

Parameters:
  • x
  • indices
void dolfin::GenericVector::gather(std::vector<double> &x, const std::vector<dolfin::la_index> &indices) const = 0

Gather entries (given by global indices) into x.

Parameters:
  • x
  • indices
void dolfin::GenericVector::gather_on_zero(std::vector<double> &x) const = 0

Gather all entries into x on process 0.

Parameters:x
void dolfin::GenericVector::get(double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows) const

Get block of values using global indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericVector::get(double *block, std::size_t m, const dolfin::la_index *rows) const = 0

Get block of values using global indices (values must all live on the local process, ghosts cannot be accessed)

Parameters:
  • block
  • m
  • rows
void dolfin::GenericVector::get_local(double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows) const

Get block of values using local indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericVector::get_local(double *block, std::size_t m, const dolfin::la_index *rows) const = 0

Get block of values using local indices (values must all live on the local process, ghost are accessible)

Parameters:
  • block
  • m
  • rows
void dolfin::GenericVector::get_local(std::vector<double> &values) const = 0

Get all values on local process.

Parameters:values
double dolfin::GenericVector::getitem(dolfin::la_index i) const

Get value of given entry.

Parameters:i
void dolfin::GenericVector::init(const TensorLayout &tensor_layout)

Initialize zero tensor using sparsity pattern FIXME: This needs to be implemented on backend side! Remove it!

Parameters:tensor_layout
void dolfin::GenericVector::init(std::pair<std::size_t, std::size_t> range) = 0

Initialize vector with given local ownership range.

Parameters:range
void dolfin::GenericVector::init(std::pair<std::size_t, std::size_t> range, const std::vector<std::size_t> &local_to_global_map, const std::vector<la_index> &ghost_indices) = 0

Initialise vector with given ownership range and with ghost values FIXME: Reimplement using init(const TensorLayout&) and deprecate

Parameters:
  • range
  • local_to_global_map
  • ghost_indices
void dolfin::GenericVector::init(std::size_t N) = 0

Initialize vector to global size N.

Parameters:N
double dolfin::GenericVector::inner(const GenericVector &x) const = 0

Return inner product with given vector.

Parameters:x
std::pair<std::int64_t, std::int64_t> dolfin::GenericVector::local_range() const = 0

Return local ownership range of a vector.

std::pair<std::int64_t, std::int64_t> dolfin::GenericVector::local_range(std::size_t dim) const

Return local ownership range.

Parameters:dim
std::size_t dolfin::GenericVector::local_size() const = 0

Return local size of vector.

double dolfin::GenericVector::max() const = 0

Return maximum value of vector.

double dolfin::GenericVector::min() const = 0

Return minimum value of vector.

double dolfin::GenericVector::norm(std::string norm_type) const = 0

Return norm of vector.

Parameters:norm_type
const GenericVector &dolfin::GenericVector::operator*=(const GenericVector &x) = 0

Multiply vector by another vector pointwise.

Parameters:x
const GenericVector &dolfin::GenericVector::operator*=(double a) = 0

Multiply vector by given number.

Parameters:a
const GenericVector &dolfin::GenericVector::operator+=(const GenericVector &x) = 0

Add given vector.

Parameters:x
const GenericVector &dolfin::GenericVector::operator+=(double a) = 0

Add number to all components of a vector.

Parameters:a
const GenericVector &dolfin::GenericVector::operator-=(const GenericVector &x) = 0

Subtract given vector.

Parameters:x
const GenericVector &dolfin::GenericVector::operator-=(double a) = 0

Subtract number from all components of a vector.

Parameters:a
const GenericVector &dolfin::GenericVector::operator/=(double a) = 0

Divide vector by given number.

Parameters:a
const GenericVector &dolfin::GenericVector::operator=(const GenericVector &x) = 0

Assignment operator.

Parameters:x
const GenericVector &dolfin::GenericVector::operator=(double a) = 0

Assignment operator.

Parameters:a
double dolfin::GenericVector::operator[](dolfin::la_index i) const

Get value of given entry.

Parameters:i
bool dolfin::GenericVector::owns_index(std::size_t i) const = 0

Determine whether global vector index is owned by this process.

Parameters:i
std::size_t dolfin::GenericVector::rank() const

Return tensor rank (number of dimensions)

void dolfin::GenericVector::set(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)

Set block of values using global indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericVector::set(const double *block, std::size_t m, const dolfin::la_index *rows) = 0

Set block of values using global indices.

Parameters:
  • block
  • m
  • rows
void dolfin::GenericVector::set_local(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)

Set block of values using local indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::GenericVector::set_local(const double *block, std::size_t m, const dolfin::la_index *rows) = 0

Set block of values using local indices.

Parameters:
  • block
  • m
  • rows
void dolfin::GenericVector::set_local(const std::vector<double> &values) = 0

Set all values on local process.

Parameters:values
void dolfin::GenericVector::setitem(dolfin::la_index i, double value)

Set given entry to value. apply(“insert”) should be called before using using the object.

Parameters:
  • i
  • value
std::size_t dolfin::GenericVector::size() const = 0

Return global size of vector.

std::size_t dolfin::GenericVector::size(std::size_t dim) const

Return size of given dimension.

Parameters:dim
std::string dolfin::GenericVector::str(bool verbose) const = 0

Return informal string representation (pretty-print)

Parameters:verbose
double dolfin::GenericVector::sum() const = 0

Return sum of vector.

double dolfin::GenericVector::sum(const Array<std::size_t> &rows) const = 0

Return sum of selected rows in vector. Repeated entries are only summed once.

Parameters:rows
void dolfin::GenericVector::zero() = 0

Set all entries to zero and keep any sparse structure.

dolfin::GenericVector::~GenericVector()

Destructor.

Ifpack2Preconditioner

C++ documentation for Ifpack2Preconditioner from dolfin/la/Ifpack2Preconditioner.h:

class dolfin::Ifpack2Preconditioner

Implements preconditioners using Ifpack2 from Trilinos.

dolfin::Ifpack2Preconditioner::Ifpack2Preconditioner(std::string type = "default")

Create a particular preconditioner object.

Parameters:type
void dolfin::Ifpack2Preconditioner::init(std::shared_ptr<const TpetraMatrix> P)

Initialise preconditioner based on Operator P.

Parameters:P
type dolfin::Ifpack2Preconditioner::prec_type
std::map<std::string, std::string> dolfin::Ifpack2Preconditioner::preconditioners()

Return a list of available preconditioners.

void dolfin::Ifpack2Preconditioner::set(BelosKrylovSolver &solver)

Set the preconditioner type on a solver.

Parameters:solver
std::string dolfin::Ifpack2Preconditioner::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
dolfin::Ifpack2Preconditioner::~Ifpack2Preconditioner()

Destructor.

IndexMap

C++ documentation for IndexMap from dolfin/la/IndexMap.h:

class dolfin::IndexMap

This class represents the distribution index arrays across processes. An index array is a contiguous collection of N+1 indices [0, 1, . . ., N] that are distributed across processes M processes. On a given process, the IndexMap stores a portion of the index set using local indices [0, 1, . . . , n], and a map from the local indices to a unique global index.

dolfin::IndexMap::IndexMap()

Constructor.

dolfin::IndexMap::IndexMap(MPI_Comm mpi_comm)

Index map with no data.

Parameters:mpi_comm
dolfin::IndexMap::IndexMap(MPI_Comm mpi_comm, std::size_t local_size, std::size_t block_size)

Index map with local size on each process. This constructor is collective

Parameters:
  • mpi_comm
  • local_size
  • block_size
enum dolfin::IndexMap::MapSize

MapSize (ALL = all local indices, OWNED = owned local indices, UNOWNED = unowned local indices, GLOBAL = total indices globally)

enumerator dolfin::IndexMap::MapSize::ALL = 0
enumerator dolfin::IndexMap::MapSize::OWNED = 1
enumerator dolfin::IndexMap::MapSize::UNOWNED = 2
enumerator dolfin::IndexMap::MapSize::GLOBAL = 3
int dolfin::IndexMap::block_size() const

Get block size.

int dolfin::IndexMap::global_index_owner(std::size_t index) const

Get process owner of any global index.

Parameters:index
void dolfin::IndexMap::init(std::size_t local_size, std::size_t block_size)

Initialise with number of local entries and block size. This function is collective

Parameters:
  • local_size
  • block_size
std::pair<std::size_t, std::size_t> dolfin::IndexMap::local_range() const

Local range of indices.

std::size_t dolfin::IndexMap::local_to_global(std::size_t i) const

Get global index of local index i.

Parameters:i
const std::vector<std::size_t> &dolfin::IndexMap::local_to_global_unowned() const

Get local to global map for unowned indices (local indexing beyond end of local range)

MPI_Comm dolfin::IndexMap::mpi_comm() const

Return MPI communicator.

const std::vector<int> &dolfin::IndexMap::off_process_owner() const

Get off process owner for unowned indices.

void dolfin::IndexMap::set_local_to_global(const std::vector<std::size_t> &indices)

Set local_to_global map for unowned indices (beyond end of local range). Computes and stores off-process owner array.

Parameters:indices
std::size_t dolfin::IndexMap::size(MapSize type) const

Get number of local indices of type MapSize::OWNED, MapSize::UNOWNED, MapSize::ALL or MapSize::GLOBAL

Parameters:type
dolfin::IndexMap::~IndexMap()

Destructor.

KrylovSolver

C++ documentation for KrylovSolver from dolfin/la/KrylovSolver.h:

class dolfin::KrylovSolver : public dolfin::GenericLinearSolver

This class defines an interface for a Krylov solver. The appropriate solver is chosen on the basis of the matrix/vector type.

dolfin::KrylovSolver::KrylovSolver(MPI_Comm comm, std::shared_ptr<const GenericLinearOperator> A, std::string method = "default", std::string preconditioner = "default")

Constructor.

Parameters:
  • comm
  • A
  • method
  • preconditioner
dolfin::KrylovSolver::KrylovSolver(MPI_Comm comm, std::string method = "default", std::string preconditioner = "default")

Constructor.

Parameters:
  • comm
  • method
  • preconditioner
dolfin::KrylovSolver::KrylovSolver(std::shared_ptr<const GenericLinearOperator> A, std::string method = "default", std::string preconditioner = "default")

Constructor.

Parameters:
  • A
  • method
  • preconditioner
dolfin::KrylovSolver::KrylovSolver(std::string method = "default", std::string preconditioner = "default")

Constructor.

Parameters:
  • method
  • preconditioner
void dolfin::KrylovSolver::init(std::string method, std::string preconditioner, MPI_Comm comm)
Parameters:
  • method
  • preconditioner
  • comm
std::string dolfin::KrylovSolver::parameter_type() const

Return parameter type: “krylov_solver” or “lu_solver”.

void dolfin::KrylovSolver::set_operator(std::shared_ptr<const GenericLinearOperator> A)

Set operator (matrix)

Parameters:A
void dolfin::KrylovSolver::set_operators(std::shared_ptr<const GenericLinearOperator> A, std::shared_ptr<const GenericLinearOperator> P)

Set operator (matrix) and preconditioner matrix.

Parameters:
  • A
  • P
std::size_t dolfin::KrylovSolver::solve(GenericVector &x, const GenericVector &b)

Solve linear system Ax = b.

Parameters:
  • x
  • b
std::size_t dolfin::KrylovSolver::solve(const GenericLinearOperator &A, GenericVector &x, const GenericVector &b)

Solve linear system Ax = b.

Parameters:
  • A
  • x
  • b
std::shared_ptr<GenericLinearSolver> dolfin::KrylovSolver::solver
void dolfin::KrylovSolver::update_parameters(const Parameters &parameters)

Update solver parameters (pass parameters down to wrapped implementation)

Parameters:parameters
dolfin::KrylovSolver::~KrylovSolver()

Destructor.

LUSolver

C++ documentation for LUSolver from dolfin/la/LUSolver.h:

class dolfin::LUSolver : public dolfin::GenericLinearSolver

LU solver for the built-in LA backends.

dolfin::LUSolver::LUSolver(MPI_Comm comm, std::shared_ptr<const GenericLinearOperator> A, std::string method = "default")

Constructor.

Parameters:
  • comm
  • A
  • method
dolfin::LUSolver::LUSolver(MPI_Comm comm, std::string method = "default")

Constructor.

Parameters:
  • comm
  • method
dolfin::LUSolver::LUSolver(std::shared_ptr<const GenericLinearOperator> A, std::string method = "default")

Constructor.

Parameters:
  • A
  • method
dolfin::LUSolver::LUSolver(std::string method = "default")

Constructor.

Parameters:method
void dolfin::LUSolver::init(MPI_Comm comm, std::string method)
Parameters:
  • comm
  • method
std::string dolfin::LUSolver::parameter_type() const

Return parameter type: “krylov_solver” or “lu_solver”.

void dolfin::LUSolver::set_operator(std::shared_ptr<const GenericLinearOperator> A)

Set operator (matrix)

Parameters:A
std::size_t dolfin::LUSolver::solve(GenericVector &x, const GenericVector &b)

Solve linear system Ax = b.

Parameters:
  • x
  • b
std::size_t dolfin::LUSolver::solve(const GenericLinearOperator &A, GenericVector &x, const GenericVector &b)

Solve linear system.

Parameters:
  • A
  • x
  • b
std::shared_ptr<GenericLinearSolver> dolfin::LUSolver::solver
void dolfin::LUSolver::update_parameters(const Parameters &parameters)

Update solver parameters (pass parameters down to wrapped implementation)

Parameters:parameters
dolfin::LUSolver::~LUSolver()

Destructor.

LinearAlgebraObject

C++ documentation for LinearAlgebraObject from dolfin/la/LinearAlgebraObject.h:

class dolfin::LinearAlgebraObject

This is a common base class for all DOLFIN linear algebra objects. In particular, it provides casting mechanisms between different types.

T &dolfin::LinearAlgebraObject::down_cast()

Cast object to its derived class, if possible (non-const version). An error is thrown if the cast is unsuccessful.

const T &dolfin::LinearAlgebraObject::down_cast() const

Cast object to its derived class, if possible (const version). An error is thrown if the cast is unsuccessful.

std::shared_ptr<X> dolfin::LinearAlgebraObject::down_cast(std::shared_ptr<Y> A)

Cast shared pointer object to its derived class, if possible. Caller must check for success (returns null if cast fails).

Parameters:A
LinearAlgebraObject *dolfin::LinearAlgebraObject::instance()

Return concrete instance / unwrap (non-const version)

const LinearAlgebraObject *dolfin::LinearAlgebraObject::instance() const

Return concrete instance / unwrap (const version)

MPI_Comm dolfin::LinearAlgebraObject::mpi_comm() const = 0

Return MPI communicator.

std::shared_ptr<LinearAlgebraObject> dolfin::LinearAlgebraObject::shared_instance()

Return concrete shared ptr instance / unwrap (non-const version)

std::shared_ptr<const LinearAlgebraObject> dolfin::LinearAlgebraObject::shared_instance() const

Return concrete shared ptr instance / unwrap (const version)

LinearOperator

C++ documentation for LinearOperator from dolfin/la/LinearOperator.h:

class dolfin::LinearOperator : public dolfin::GenericLinearOperator

This class defines an interface for linear operators defined only in terms of their action (matrix-vector product) and can be used for matrix-free solution of linear systems. The linear algebra backend is decided at run-time based on the present value of the “linear_algebra_backend” parameter. To define a linear operator, users need to inherit from this class and overload the function mult(x, y) which defines the action of the matrix on the vector x as y = Ax.

dolfin::LinearOperator::LinearOperator()

Create linear operator.

dolfin::LinearOperator::LinearOperator(const GenericVector &x, const GenericVector &y)

Create linear operator to match parallel layout of vectors x and y for product y = Ax.

Parameters:
  • x
  • y
GenericLinearOperator *dolfin::LinearOperator::instance()

Return concrete instance / unwrap (non-const version)

const GenericLinearOperator *dolfin::LinearOperator::instance() const

Return concrete instance / unwrap (const version)

MPI_Comm dolfin::LinearOperator::mpi_comm() const

Return the MPI communicator.

void dolfin::LinearOperator::mult(const GenericVector &x, GenericVector &y) const = 0

Compute matrix-vector product y = Ax.

Parameters:
  • x
  • y
std::shared_ptr<LinearAlgebraObject> dolfin::LinearOperator::shared_instance()

Return concrete instance / unwrap (shared pointer version)

std::shared_ptr<const LinearAlgebraObject> dolfin::LinearOperator::shared_instance() const

Return concrete instance / unwrap (const shared pointer version)

std::size_t dolfin::LinearOperator::size(std::size_t dim) const = 0

Return size of given dimension.

Parameters:dim
std::string dolfin::LinearOperator::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
dolfin::LinearOperator::~LinearOperator()

Destructor.

LinearSolver

C++ documentation for LinearSolver from dolfin/la/LinearSolver.h:

class dolfin::LinearSolver : public dolfin::GenericLinearSolver

This class provides a general solver for linear systems Ax = b.

Friends: KrylovSolver, LUSolver, LinearVariationalSolver, NewtonSolver.

dolfin::LinearSolver::LinearSolver(MPI_Comm comm, std::string method = "default", std::string preconditioner = "default")

Create linear solver.

Parameters:
  • comm
  • method
  • preconditioner
dolfin::LinearSolver::LinearSolver(std::string method = "default", std::string preconditioner = "default")

Create linear solver.

Parameters:
  • method
  • preconditioner
bool dolfin::LinearSolver::in_list(const std::string &method, const std::map<std::string, std::string> &methods)
Parameters:
  • method
  • methods
std::string dolfin::LinearSolver::parameter_type() const

Return parameter type: “krylov_solver” or “lu_solver”.

void dolfin::LinearSolver::set_operator(std::shared_ptr<const GenericLinearOperator> A)

Set the operator (matrix)

Parameters:A
void dolfin::LinearSolver::set_operators(std::shared_ptr<const GenericLinearOperator> A, std::shared_ptr<const GenericLinearOperator> P)

Set the operator (matrix) and preconditioner matrix.

Parameters:
  • A
  • P
std::size_t dolfin::LinearSolver::solve(GenericVector &x, const GenericVector &b)

Solve linear system Ax = b.

Parameters:
  • x
  • b
std::size_t dolfin::LinearSolver::solve(const GenericLinearOperator &A, GenericVector &x, const GenericVector &b)

Solve linear system Ax = b.

Parameters:
  • A
  • x
  • b
std::unique_ptr<GenericLinearSolver> dolfin::LinearSolver::solver
void dolfin::LinearSolver::update_parameters(const Parameters &parameters)

Update solver parameters (pass parameters down to wrapped implementation)

Parameters:parameters
dolfin::LinearSolver::~LinearSolver()

Destructor.

Matrix

C++ documentation for Matrix from dolfin/la/Matrix.h:

class dolfin::Matrix : public dolfin::GenericMatrix

This class provides the default DOLFIN matrix class, based on the default DOLFIN linear algebra backend.

dolfin::Matrix::Matrix(MPI_Comm comm = MPI_COMM_WORLD)

Create empty matrix.

Parameters:comm
dolfin::Matrix::Matrix(const GenericMatrix &A)

Create a Vector from a GenericVector .

Parameters:A
dolfin::Matrix::Matrix(const Matrix &A)

Copy constructor.

Parameters:A
void dolfin::Matrix::add(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Add block of values using global indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::Matrix::add_local(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Add block of values using local indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::Matrix::apply(std::string mode)

Finalize assembly of tensor.

Parameters:mode
void dolfin::Matrix::axpy(double a, const GenericMatrix &A, bool same_nonzero_pattern)

Add multiple of given matrix (AXPY operation)

Parameters:
  • a
  • A
  • same_nonzero_pattern
std::shared_ptr<GenericMatrix> dolfin::Matrix::copy() const

Return copy of matrix.

bool dolfin::Matrix::empty() const

Return true if matrix is empty.

GenericLinearAlgebraFactory &dolfin::Matrix::factory() const

Return linear algebra backend factory.

void dolfin::Matrix::get(double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols) const

Get block of values.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::Matrix::get_diagonal(GenericVector &x) const

Get diagonal of a matrix.

Parameters:x
void dolfin::Matrix::getrow(std::size_t row, std::vector<std::size_t> &columns, std::vector<double> &values) const

Get non-zero values of given row.

Parameters:
  • row
  • columns
  • values
void dolfin::Matrix::ident(std::size_t m, const dolfin::la_index *rows)

Set given rows (global row indices) to identity matrix.

Parameters:
  • m
  • rows
void dolfin::Matrix::ident_local(std::size_t m, const dolfin::la_index *rows)

Set given rows (local row indices) to identity matrix.

Parameters:
  • m
  • rows
void dolfin::Matrix::init(const TensorLayout &tensor_layout)

Initialize zero tensor using tensor layout.

Parameters:tensor_layout
void dolfin::Matrix::init_vector(GenericVector &y, std::size_t dim) const

Resize vector y such that is it compatible with matrix for multiplication Ax = b (dim = 0 -> b, dim = 1 -> x) In parallel case, size and layout are important.

Parameters:
  • y
  • dim
GenericMatrix *dolfin::Matrix::instance()

Return concrete instance / unwrap (non-const version)

const GenericMatrix *dolfin::Matrix::instance() const

Return concrete instance / unwrap (const version)

bool dolfin::Matrix::is_symmetric(double tol) const

Test if matrix is symmetric.

Parameters:tol
std::pair<std::int64_t, std::int64_t> dolfin::Matrix::local_range(std::size_t dim) const

Return local ownership range.

Parameters:dim
std::shared_ptr<GenericMatrix> dolfin::Matrix::matrix
MPI_Comm dolfin::Matrix::mpi_comm() const

Return MPI communicator.

void dolfin::Matrix::mult(const GenericVector &x, GenericVector &y) const

Compute matrix-vector product y = Ax.

Parameters:
  • x
  • y
std::size_t dolfin::Matrix::nnz() const

Return number of non-zero entries in matrix (collective)

double dolfin::Matrix::norm(std::string norm_type) const

Return norm of matrix.

Parameters:norm_type
const Matrix &dolfin::Matrix::operator*=(double a)

Multiply matrix by given number.

Parameters:a
const Matrix &dolfin::Matrix::operator/=(double a)

Divide matrix by given number.

Parameters:a
const GenericMatrix &dolfin::Matrix::operator=(const GenericMatrix &A)

Assignment operator.

Parameters:A
const Matrix &dolfin::Matrix::operator=(const Matrix &A)

Assignment operator.

Parameters:A
void dolfin::Matrix::set(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Set block of values using global indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::Matrix::set_diagonal(const GenericVector &x)

Set diagonal of a matrix.

Parameters:x
void dolfin::Matrix::set_local(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Set block of values using local indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::Matrix::setrow(std::size_t row, const std::vector<std::size_t> &columns, const std::vector<double> &values)

Set values for given row.

Parameters:
  • row
  • columns
  • values
std::shared_ptr<LinearAlgebraObject> dolfin::Matrix::shared_instance()

Return concrete shared ptr instance / unwrap (non-const version)

std::shared_ptr<const LinearAlgebraObject> dolfin::Matrix::shared_instance() const

Return concrete shared ptr instance / unwrap (const version)

std::size_t dolfin::Matrix::size(std::size_t dim) const

Return size of given dimension.

Parameters:dim
std::string dolfin::Matrix::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
void dolfin::Matrix::transpmult(const GenericVector &x, GenericVector &y) const

Matrix-vector product, y = A^T x. The y vector must either be zero-sized or have correct size and parallel layout.

Parameters:
  • x
  • y
void dolfin::Matrix::zero()

Set all entries to zero and keep any sparse structure.

void dolfin::Matrix::zero(std::size_t m, const dolfin::la_index *rows)

Set given rows to zero.

Parameters:
  • m
  • rows
void dolfin::Matrix::zero_local(std::size_t m, const dolfin::la_index *rows)

Set given rows (local row indices) to zero.

Parameters:
  • m
  • rows
dolfin::Matrix::~Matrix()

Destructor.

MueluPreconditioner

C++ documentation for MueluPreconditioner from dolfin/la/MueluPreconditioner.h:

class dolfin::MueluPreconditioner

Implements Muelu preconditioner from Trilinos.

dolfin::MueluPreconditioner::MueluPreconditioner()

Create a particular preconditioner object.

void dolfin::MueluPreconditioner::init(std::shared_ptr<const TpetraMatrix> P)

Initialise preconditioner based on Operator P.

Parameters:P
type dolfin::MueluPreconditioner::op_type
type dolfin::MueluPreconditioner::prec_type
void dolfin::MueluPreconditioner::set(BelosKrylovSolver &solver)

Set the preconditioner on a solver.

Parameters:solver
std::string dolfin::MueluPreconditioner::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
dolfin::MueluPreconditioner::~MueluPreconditioner()

Destructor.

PETScBaseMatrix

C++ documentation for PETScBaseMatrix from dolfin/la/PETScBaseMatrix.h:

class dolfin::PETScBaseMatrix

This class is a base class for matrices that can be used in PETScKrylovSolver .

dolfin::PETScBaseMatrix::PETScBaseMatrix()

Constructor.

dolfin::PETScBaseMatrix::PETScBaseMatrix(Mat A)

Constructor.

Parameters:A
dolfin::PETScBaseMatrix::PETScBaseMatrix(const PETScBaseMatrix &A)

Copy constructor.

Parameters:A
void dolfin::PETScBaseMatrix::init_vector(GenericVector &z, std::size_t dim) const

Initialize vector to be compatible with the matrix-vector product y = Ax. In the parallel case, both size and layout are important.

Parameters:
  • z – (GenericVector &) Vector to initialise
  • dim – (std::size_t) The dimension (axis): dim = 0 –> z = y, dim = 1 –> z = x
std::pair<std::int64_t, std::int64_t> dolfin::PETScBaseMatrix::local_range(std::size_t dim) const

Return local range along dimension dim.

Parameters:dim
Mat dolfin::PETScBaseMatrix::mat() const

Return PETSc Mat pointer.

MPI_Comm dolfin::PETScBaseMatrix::mpi_comm() const

Return the MPI communicator.

std::pair<std::int64_t, std::int64_t> dolfin::PETScBaseMatrix::size() const

Return number of rows and columns (num_rows, num_cols). PETSc returns -1 if size has not been set.

std::size_t dolfin::PETScBaseMatrix::size(std::size_t dim) const

Return number of rows (dim = 0) or columns (dim = 1)

Parameters:dim
std::string dolfin::PETScBaseMatrix::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
dolfin::PETScBaseMatrix::~PETScBaseMatrix()

Destructor.

PETScFactory

C++ documentation for PETScFactory from dolfin/la/PETScFactory.h:

class dolfin::PETScFactory

PETSc linear algebra factory.

dolfin::PETScFactory::PETScFactory()

Private constructor.

std::shared_ptr<GenericLinearSolver> dolfin::PETScFactory::create_krylov_solver(MPI_Comm comm, std::string method, std::string preconditioner) const

Create Krylov solver.

Parameters:
  • comm
  • method
  • preconditioner
std::shared_ptr<TensorLayout> dolfin::PETScFactory::create_layout(std::size_t rank) const

Create empty tensor layout.

Parameters:rank
std::shared_ptr<GenericLinearOperator> dolfin::PETScFactory::create_linear_operator(MPI_Comm comm) const

Create empty linear operator.

Parameters:comm
std::shared_ptr<GenericLinearSolver> dolfin::PETScFactory::create_lu_solver(MPI_Comm comm, std::string method) const

Create LU solver.

Parameters:
  • comm
  • method
std::shared_ptr<GenericMatrix> dolfin::PETScFactory::create_matrix(MPI_Comm comm) const

Create empty matrix.

Parameters:comm
std::shared_ptr<GenericVector> dolfin::PETScFactory::create_vector(MPI_Comm comm) const

Create empty vector.

Parameters:comm
PETScFactory dolfin::PETScFactory::factory
PETScFactory &dolfin::PETScFactory::instance()

Return singleton instance.

std::map<std::string, std::string> dolfin::PETScFactory::krylov_solver_methods() const

Return a list of available Krylov solver methods.

std::map<std::string, std::string> dolfin::PETScFactory::krylov_solver_preconditioners() const

Return a list of available preconditioners.

std::map<std::string, std::string> dolfin::PETScFactory::lu_solver_methods() const

Return a list of available LU solver methods.

dolfin::PETScFactory::~PETScFactory()

Destructor.

PETScKrylovSolver

C++ documentation for PETScKrylovSolver from dolfin/la/PETScKrylovSolver.h:

class dolfin::PETScKrylovSolver : public dolfin::GenericLinearSolver

This class implements Krylov methods for linear systems of the form Ax = b. It is a wrapper for the Krylov solvers of PETSc.

Friends: PETScSNESSolver, PETScTAOSolver.

dolfin::PETScKrylovSolver::PETScKrylovSolver(KSP ksp)

Create solver wrapper of a PETSc KSP object.

Parameters:ksp
dolfin::PETScKrylovSolver::PETScKrylovSolver(MPI_Comm comm, std::string method, std::shared_ptr<PETScPreconditioner> preconditioner)

Create Krylov solver for a particular method and PETScPreconditioner (shared_ptr version)

Parameters:
  • comm
  • method
  • preconditioner
dolfin::PETScKrylovSolver::PETScKrylovSolver(MPI_Comm comm, std::string method, std::shared_ptr<PETScUserPreconditioner> preconditioner)

Create Krylov solver for a particular method and PETScPreconditioner (shared_ptr version)

Parameters:
  • comm
  • method
  • preconditioner
dolfin::PETScKrylovSolver::PETScKrylovSolver(MPI_Comm comm, std::string method = "default", std::string preconditioner = "default")

Create Krylov solver for a particular method and named preconditioner

Parameters:
  • comm
  • method
  • preconditioner
dolfin::PETScKrylovSolver::PETScKrylovSolver(std::string method, std::shared_ptr<PETScPreconditioner> preconditioner)

Create Krylov solver for a particular method and PETScPreconditioner (shared_ptr version)

Parameters:
  • method
  • preconditioner
dolfin::PETScKrylovSolver::PETScKrylovSolver(std::string method, std::shared_ptr<PETScUserPreconditioner> preconditioner)

Create Krylov solver for a particular method and PETScPreconditioner (shared_ptr version)

Parameters:
  • method
  • preconditioner
dolfin::PETScKrylovSolver::PETScKrylovSolver(std::string method = "default", std::string preconditioner = "default")

Create Krylov solver for a particular method and named preconditioner

Parameters:
  • method
  • preconditioner
void dolfin::PETScKrylovSolver::check_dimensions(const PETScBaseMatrix &A, const GenericVector &x, const GenericVector &b) const
Parameters:
  • A
  • x
  • b
norm_type dolfin::PETScKrylovSolver::get_norm_type() const

Get norm type used in convergence testing.

PETScKrylovSolver::norm_type dolfin::PETScKrylovSolver::get_norm_type(std::string norm)
Parameters:norm
std::string dolfin::PETScKrylovSolver::get_options_prefix() const

Returns the prefix used by PETSc when searching the PETSc options database

KSP dolfin::PETScKrylovSolver::ksp() const

Return PETSc KSP pointer.

std::map<std::string, std::string> dolfin::PETScKrylovSolver::methods()

Return a list of available solver methods.

void dolfin::PETScKrylovSolver::monitor(bool monitor_convergence)

Monitor residual at each iteration.

Parameters:monitor_convergence
MPI_Comm dolfin::PETScKrylovSolver::mpi_comm() const

Return MPI communicator.

enum dolfin::PETScKrylovSolver::norm_type

Norm types used in convergence testing. Not all solvers types support all norm types (see http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSetNormType.html ). Note that ‘default’ is a reserved keyword, so we use ‘default_norm’

enumerator dolfin::PETScKrylovSolver::norm_type::none
enumerator dolfin::PETScKrylovSolver::norm_type::default_norm
enumerator dolfin::PETScKrylovSolver::norm_type::preconditioned
enumerator dolfin::PETScKrylovSolver::norm_type::unpreconditioned
enumerator dolfin::PETScKrylovSolver::norm_type::natural
std::string dolfin::PETScKrylovSolver::parameter_type() const

Return parameter type: “krylov_solver” or “lu_solver”.

PETScUserPreconditioner *dolfin::PETScKrylovSolver::pc_dolfin
bool dolfin::PETScKrylovSolver::preconditioner_set
std::map<std::string, std::string> dolfin::PETScKrylovSolver::preconditioners()

Return a list of available named preconditioners.

void dolfin::PETScKrylovSolver::set_dm(DM dm)

Set the DM.

Parameters:dm
void dolfin::PETScKrylovSolver::set_dm_active(bool val)

Activate/deactivate DM.

Parameters:val
void dolfin::PETScKrylovSolver::set_from_options() const

Set options from PETSc options database.

void dolfin::PETScKrylovSolver::set_nonzero_guess(bool nonzero_guess)

Use nonzero initial guess for solution function (nonzero_guess=true, the solution vector x will not be zeroed before the solver starts)

Parameters:nonzero_guess
void dolfin::PETScKrylovSolver::set_norm_type(norm_type type)

Set norm type used in convergence testing - not all solvers types support all norm types

Parameters:type
void dolfin::PETScKrylovSolver::set_operator(const PETScBaseMatrix &A)

Set operator (PETScMatrix ). This is memory-safe as PETSc will increase the reference count to the underlying PETSc object.

Parameters:A
void dolfin::PETScKrylovSolver::set_operator(std::shared_ptr<const GenericLinearOperator> A)

Set operator (matrix)

Parameters:A
void dolfin::PETScKrylovSolver::set_operators(const PETScBaseMatrix &A, const PETScBaseMatrix &P)

Set operator and preconditioner matrix (PETScMatrix ). This is memory-safe as PETSc will increase the reference count to the underlying PETSc objects.

Parameters:
  • A
  • P
void dolfin::PETScKrylovSolver::set_operators(std::shared_ptr<const GenericLinearOperator> A, std::shared_ptr<const GenericLinearOperator> P)

Set operator (matrix) and preconditioner matrix.

Parameters:
  • A
  • P
void dolfin::PETScKrylovSolver::set_options_prefix(std::string options_prefix)

Sets the prefix used by PETSc when searching the PETSc options database

Parameters:options_prefix
void dolfin::PETScKrylovSolver::set_reuse_preconditioner(bool reuse_pc)

Reuse preconditioner if true, even if matrix operator changes (by default preconditioner will be re-built if the matrix changes)

Parameters:reuse_pc
void dolfin::PETScKrylovSolver::set_tolerances(double relative, double absolute, double diverged, int max_iter)

Set tolerances (relative residual, alsolute residial, maximum number of iterations)

Parameters:
  • relative
  • absolute
  • diverged
  • max_iter
std::size_t dolfin::PETScKrylovSolver::solve(GenericVector &x, const GenericVector &b)

Solve linear system Ax = b and return number of iterations.

Parameters:
  • x
  • b
std::size_t dolfin::PETScKrylovSolver::solve(GenericVector &x, const GenericVector &b, bool transpose)

Solve linear system Ax = b and return number of iterations (A^t x = b if transpose is true)

Parameters:
  • x
  • b
  • transpose
std::size_t dolfin::PETScKrylovSolver::solve(PETScVector &x, const PETScVector &b, bool transpose = false)

Solve linear system Ax = b and return number of iterations (A^t x = b if transpose is true)

Parameters:
  • x
  • b
  • transpose
std::size_t dolfin::PETScKrylovSolver::solve(const GenericLinearOperator &A, GenericVector &x, const GenericVector &b)

Solve linear system Ax = b and return number of iterations.

Parameters:
  • A
  • x
  • b
std::string dolfin::PETScKrylovSolver::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
void dolfin::PETScKrylovSolver::write_report(int num_iterations, KSPConvergedReason reason)
Parameters:
  • num_iterations
  • reason
dolfin::PETScKrylovSolver::~PETScKrylovSolver()

Destructor.

PETScLUSolver

C++ documentation for PETScLUSolver from dolfin/la/PETScLUSolver.h:

class dolfin::PETScLUSolver : public dolfin::GenericLinearSolver

This class implements the direct solution (LU factorization) for linear systems of the form Ax = b. It is a wrapper for the LU solver of PETSc.

Friends: PETScSNESSolver, PETScTAOSolver.

dolfin::PETScLUSolver::PETScLUSolver(MPI_Comm comm, std::shared_ptr<const PETScMatrix> A, std::string method = "default")

Constructor.

Parameters:
  • comm
  • A
  • method
dolfin::PETScLUSolver::PETScLUSolver(MPI_Comm comm, std::string method = "default")

Constructor.

Parameters:
  • comm
  • method
dolfin::PETScLUSolver::PETScLUSolver(std::shared_ptr<const PETScMatrix> A, std::string method = "default")

Constructor.

Parameters:
  • A
  • method
dolfin::PETScLUSolver::PETScLUSolver(std::string method = "default")

Constructor.

Parameters:method
std::string dolfin::PETScLUSolver::get_options_prefix() const

Returns the prefix used by PETSc when searching the options database

KSP dolfin::PETScLUSolver::ksp() const

Return PETSc KSP pointer.

std::map<std::string, const MatSolverPackage> dolfin::PETScLUSolver::lumethods
std::map<std::string, std::string> dolfin::PETScLUSolver::methods()

Return a list of available solver methods.

MPI_Comm dolfin::PETScLUSolver::mpi_comm() const

Returns the MPI communicator.

std::string dolfin::PETScLUSolver::parameter_type() const

Return parameter type: “krylov_solver” or “lu_solver”.

const MatSolverPackage dolfin::PETScLUSolver::select_solver(MPI_Comm comm, std::string method)
Parameters:
  • comm
  • method
void dolfin::PETScLUSolver::set_from_options() const

Set options from the PETSc options database.

void dolfin::PETScLUSolver::set_operator(const PETScMatrix &A)

Set operator (matrix)

Parameters:A
void dolfin::PETScLUSolver::set_operator(std::shared_ptr<const GenericLinearOperator> A)

Set operator (matrix)

Parameters:A
void dolfin::PETScLUSolver::set_options_prefix(std::string options_prefix)

Sets the prefix used by PETSc when searching the options database

Parameters:options_prefix
std::size_t dolfin::PETScLUSolver::solve(GenericVector &x, const GenericVector &b)

Solve linear system Ax = b.

Parameters:
  • x
  • b
std::size_t dolfin::PETScLUSolver::solve(GenericVector &x, const GenericVector &b, bool transpose)

Solve linear system Ax = b (A^t x = b if transpose is true)

Parameters:
  • x
  • b
  • transpose
std::size_t dolfin::PETScLUSolver::solve(const GenericLinearOperator &A, GenericVector &x, const GenericVector &b)

Solve linear system Ax = b.

Parameters:
  • A
  • x
  • b
std::size_t dolfin::PETScLUSolver::solve(const PETScMatrix &A, PETScVector &x, const PETScVector &b)

Solve linear system Ax = b.

Parameters:
  • A
  • x
  • b
std::string dolfin::PETScLUSolver::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
dolfin::PETScLUSolver::~PETScLUSolver()

Destructor.

PETScLinearOperator

C++ documentation for PETScLinearOperator from dolfin/la/PETScLinearOperator.h:

class dolfin::PETScLinearOperator : public dolfin::GenericLinearOperator, dolfin::PETScBaseMatrix

PETSc version of the GenericLinearOperator . Matrix-free interface for the solution of linear systems defined in terms of the action (matrix-vector product) of a linear operator.

dolfin::PETScLinearOperator::PETScLinearOperator(MPI_Comm comm)

Constructor.

Parameters:comm
void dolfin::PETScLinearOperator::init_layout(const GenericVector &x, const GenericVector &y, GenericLinearOperator *wrapper)

Initialize linear operator to match parallel layout of vectors x and y for product y = Ax. Needs to be implemented by backend.

Parameters:
  • x
  • y
  • wrapper
MPI_Comm dolfin::PETScLinearOperator::mpi_comm() const

Return MPI communicator.

void dolfin::PETScLinearOperator::mult(const GenericVector &x, GenericVector &y) const

Compute matrix-vector product y = Ax.

Parameters:
  • x
  • y
std::size_t dolfin::PETScLinearOperator::size(std::size_t dim) const

Return size of given dimension.

Parameters:dim
std::string dolfin::PETScLinearOperator::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
GenericLinearOperator *dolfin::PETScLinearOperator::wrapper()

Return pointer to wrapper (const version)

const GenericLinearOperator *dolfin::PETScLinearOperator::wrapper() const

Return pointer to wrapper (const version)

PETScMatrix

C++ documentation for PETScMatrix from dolfin/la/PETScMatrix.h:

class dolfin::PETScMatrix : public dolfin::GenericMatrix, dolfin::PETScBaseMatrix

This class provides a simple matrix class based on PETSc. It is a wrapper for a PETSc matrix pointer (Mat) implementing the GenericMatrix interface. The interface is intentionally simple. For advanced usage, access the PETSc Mat pointer using the function mat and use the standard PETSc interface.

dolfin::PETScMatrix::PETScMatrix()

Create empty matrix (on MPI_COMM_WORLD)

dolfin::PETScMatrix::PETScMatrix(MPI_Comm comm)

Create empty matrix.

Parameters:comm
dolfin::PETScMatrix::PETScMatrix(Mat A)

Create a wrapper around a PETSc Mat pointer. The Mat object should have been created, e.g. via PETSc MatCreate.

Parameters:A
dolfin::PETScMatrix::PETScMatrix(const PETScMatrix &A)

Copy constructor.

Parameters:A
void dolfin::PETScMatrix::add(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Add block of values using global indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::PETScMatrix::add_local(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Add block of values using local indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::PETScMatrix::apply(std::string mode)

Finalize assembly of tensor. The following values are recognized for the mode parameter: add - corresponds to PETSc MatAssemblyBegin+End(MAT_FINAL_ASSEMBLY) insert - corresponds to PETSc MatAssemblyBegin+End(MAT_FINAL_ASSEMBLY) flush - corresponds to PETSc MatAssemblyBegin+End(MAT_FLUSH_ASSEMBLY)

Parameters:mode
void dolfin::PETScMatrix::axpy(double a, const GenericMatrix &A, bool same_nonzero_pattern)

Add multiple of given matrix (AXPY operation)

Parameters:
  • a
  • A
  • same_nonzero_pattern
void dolfin::PETScMatrix::binary_dump(std::string file_name) const

Dump matrix to PETSc binary format.

Parameters:file_name
std::shared_ptr<GenericMatrix> dolfin::PETScMatrix::copy() const

Return copy of matrix.

MatNullSpace dolfin::PETScMatrix::create_petsc_nullspace(const VectorSpaceBasis &nullspace) const
Parameters:nullspace
bool dolfin::PETScMatrix::empty() const

Return true if empty.

GenericLinearAlgebraFactory &dolfin::PETScMatrix::factory() const

Return linear algebra backend factory.

void dolfin::PETScMatrix::get(double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols) const

Get block of values.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::PETScMatrix::get_diagonal(GenericVector &x) const

Get diagonal of a matrix.

Parameters:x
std::string dolfin::PETScMatrix::get_options_prefix() const

Returns the prefix used by PETSc when searching the options database

void dolfin::PETScMatrix::getrow(std::size_t row, std::vector<std::size_t> &columns, std::vector<double> &values) const

Get non-zero values of given row.

Parameters:
  • row
  • columns
  • values
void dolfin::PETScMatrix::ident(std::size_t m, const dolfin::la_index *rows)

Set given rows (global row indices) to identity matrix.

Parameters:
  • m
  • rows
void dolfin::PETScMatrix::ident_local(std::size_t m, const dolfin::la_index *rows)

Set given rows (local row indices) to identity matrix.

Parameters:
  • m
  • rows
void dolfin::PETScMatrix::init(const TensorLayout &tensor_layout)

Initialize zero tensor using tensor layout.

Parameters:tensor_layout
void dolfin::PETScMatrix::init_vector(GenericVector &z, std::size_t dim) const

Initialize vector z to be compatible with the matrix-vector product y = Ax. In the parallel case, both size and layout are important.

Parameters:
  • z – (GenericVector &) Vector to initialise
  • dim – (std::size_t) The dimension (axis): dim = 0 –> z = y, dim = 1 –> z = x
bool dolfin::PETScMatrix::is_symmetric(double tol) const

Test if matrix is symmetric.

Parameters:tol
std::pair<std::int64_t, std::int64_t> dolfin::PETScMatrix::local_range(std::size_t dim) const

Return local ownership range.

Parameters:dim
MPI_Comm dolfin::PETScMatrix::mpi_comm() const

Return MPI communicator.

void dolfin::PETScMatrix::mult(const GenericVector &x, GenericVector &y) const

Compute matrix-vector product y = Ax.

Parameters:
  • x
  • y
std::size_t dolfin::PETScMatrix::nnz() const

Return number of non-zero entries in matrix (collective)

double dolfin::PETScMatrix::norm(std::string norm_type) const

Return norm of matrix.

Parameters:norm_type
const std::map<std::string, NormType> dolfin::PETScMatrix::norm_types
const PETScMatrix &dolfin::PETScMatrix::operator*=(double a)

Multiply matrix by given number.

Parameters:a
const PETScMatrix &dolfin::PETScMatrix::operator/=(double a)

Divide matrix by given number.

Parameters:a
const GenericMatrix &dolfin::PETScMatrix::operator=(const GenericMatrix &A)

Assignment operator.

Parameters:A
const PETScMatrix &dolfin::PETScMatrix::operator=(const PETScMatrix &A)

Assignment operator.

Parameters:A
void dolfin::PETScMatrix::set(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Set block of values using global indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::PETScMatrix::set_diagonal(const GenericVector &x)

Set diagonal of a matrix.

Parameters:x
void dolfin::PETScMatrix::set_from_options()

Call PETSc function MatSetFromOptions on the PETSc Mat object.

void dolfin::PETScMatrix::set_local(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Set block of values using local indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::PETScMatrix::set_near_nullspace(const VectorSpaceBasis &nullspace)

Attach near nullspace to matrix (used by preconditioners, such as smoothed aggregation algerbraic multigrid)

Parameters:nullspace
void dolfin::PETScMatrix::set_nullspace(const VectorSpaceBasis &nullspace)

Attach nullspace to matrix (typically used by Krylov solvers when solving singular systems)

Parameters:nullspace
void dolfin::PETScMatrix::set_options_prefix(std::string options_prefix)

Sets the prefix used by PETSc when searching the options database

Parameters:options_prefix
void dolfin::PETScMatrix::setrow(std::size_t row, const std::vector<std::size_t> &columns, const std::vector<double> &values)

Set values for given row.

Parameters:
  • row
  • columns
  • values
std::size_t dolfin::PETScMatrix::size(std::size_t dim) const

Return size of given dimension.

Parameters:dim
std::string dolfin::PETScMatrix::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
void dolfin::PETScMatrix::transpmult(const GenericVector &x, GenericVector &y) const

Matrix-vector product, y = A^T x. The y vector must either be zero-sized or have correct size and parallel layout.

Parameters:
  • x
  • y
void dolfin::PETScMatrix::zero()

Set all entries to zero and keep any sparse structure.

void dolfin::PETScMatrix::zero(std::size_t m, const dolfin::la_index *rows)

Set given rows (global row indices) to zero.

Parameters:
  • m
  • rows
void dolfin::PETScMatrix::zero_local(std::size_t m, const dolfin::la_index *rows)

Set given rows (local row indices) to zero.

Parameters:
  • m
  • rows
dolfin::PETScMatrix::~PETScMatrix()

Destructor.

PETScObject

C++ documentation for PETScObject from dolfin/la/PETScObject.h:

class dolfin::PETScObject

This class calls SubSystemsManager to initialise PETSc. All PETSc objects must be derived from this class.

dolfin::PETScObject::PETScObject()

Constructor. Ensures that PETSc has been initialised.

void dolfin::PETScObject::petsc_error(int error_code, std::string filename, std::string petsc_function)

Print error message for PETSc calls that return an error.

Parameters:
  • error_code
  • filename
  • petsc_function
dolfin::PETScObject::~PETScObject()

Destructor.

PETScOptions

C++ documentation for PETScOptions from dolfin/la/PETScOptions.h:

class dolfin::PETScOptions

These class provides static functions that permit users to set and retrieve PETSc options via the PETSc option/parameter system. The option must not be prefixed by ‘-‘, e.g.

PETScOptions::set("mat_mumps_icntl_14", 40);

Note: the non-templated functions are to simplify SWIG wapping into Python.

void dolfin::PETScOptions::clear()

Clear PETSc global options database.

void dolfin::PETScOptions::clear(std::string option)

Clear a PETSc option.

Parameters:option
void dolfin::PETScOptions::set(std::string option)

Set PETSc option that takes no value.

Parameters:option
void dolfin::PETScOptions::set(std::string option, bool value)

Set PETSc boolean option.

Parameters:
  • option
  • value
void dolfin::PETScOptions::set(std::string option, const T value)

Genetic function for setting PETSc option.

Parameters:
  • option
  • value
void dolfin::PETScOptions::set(std::string option, double value)

Set PETSc double option.

Parameters:
  • option
  • value
void dolfin::PETScOptions::set(std::string option, int value)

Set PETSc integer option.

Parameters:
  • option
  • value
void dolfin::PETScOptions::set(std::string option, std::string value)

Set PETSc string option.

Parameters:
  • option
  • value
PETScPreconditioner

C++ documentation for PETScPreconditioner from dolfin/la/PETScPreconditioner.h:

class dolfin::PETScPreconditioner

This class is a wrapper for configuring PETSc preconditioners. It does not own a preconditioner. It can take a PETScKrylovSolver and set the preconditioner type and parameters.

Friends: PETScSNESSolver, PETScTAOSolver.

dolfin::PETScPreconditioner::PETScPreconditioner(std::string type = "default")

Create a particular preconditioner object.

Parameters:type
std::size_t dolfin::PETScPreconditioner::gdim
std::map<std::string, std::string> dolfin::PETScPreconditioner::preconditioners()

Return a list of available preconditioners.

void dolfin::PETScPreconditioner::set(PETScKrylovSolver &solver)

Set the preconditioner type and parameters.

Parameters:solver
void dolfin::PETScPreconditioner::set_coordinates(const std::vector<double> &x, std::size_t dim)

Set the coordinates of the operator (matrix) rows and geometric dimension d. This is can be used by required for certain preconditioners, e.g. ML. The input for this function can be generated using GenericDofMap::tabulate_all_dofs.

Parameters:
  • x
  • dim
void dolfin::PETScPreconditioner::set_fieldsplit(PETScKrylovSolver &solver, const std::vector<std::vector<dolfin::la_index>> &fields, const std::vector<std::string> &split_names)

Assign indices from fields as separate PETSc index sets, with given names

Parameters:
  • solver – (PETScKrylovSolver &)
  • fields – (std::vector<std::vector<dolfin::la_index>>&)
  • split_names – (std::vector<std::string>&)
void dolfin::PETScPreconditioner::set_type(PETScKrylovSolver &solver, std::string type)

Select type by name.

Parameters:
  • solver
  • type
std::string dolfin::PETScPreconditioner::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
dolfin::PETScPreconditioner::~PETScPreconditioner()

Destructor.

PETScUserPreconditioner

C++ documentation for PETScUserPreconditioner from dolfin/la/PETScUserPreconditioner.h:

class dolfin::PETScUserPreconditioner

This class specifies the interface for user-defined Krylov method PETScPreconditioners. A user wishing to implement her own PETScPreconditioner needs only supply a function that approximately solves the linear system given a right-hand side.

int dolfin::PETScUserPreconditioner::PCApply(PC pc, Vec x, Vec y)
Parameters:
  • pc
  • x
  • y
int dolfin::PETScUserPreconditioner::PCCreate(PC pc)
Parameters:pc
dolfin::PETScUserPreconditioner::PETScUserPreconditioner()

Constructor.

PC dolfin::PETScUserPreconditioner::petscpc

PETSc PC object.

void dolfin::PETScUserPreconditioner::setup(const KSP ksp, PETScUserPreconditioner &pc)

Set up.

Parameters:
  • ksp
  • pc
void dolfin::PETScUserPreconditioner::solve(PETScVector &x, const PETScVector &b) = 0

Solve linear system approximately for given right-hand side b.

Parameters:
  • x
  • b
dolfin::PETScUserPreconditioner::~PETScUserPreconditioner()

Destructor.

PETScVector

C++ documentation for PETScVector from dolfin/la/PETScVector.h:

class dolfin::PETScVector : public dolfin::GenericVector

A simple vector class based on PETSc. It is a simple wrapper for a PETSc vector pointer (Vec) implementing the GenericVector interface. The interface is intentionally simple. For advanced usage, access the PETSc Vec pointer using the function vec and use the standard PETSc interface.

dolfin::PETScVector::PETScVector()

Create empty vector (on MPI_COMM_WORLD)

dolfin::PETScVector::PETScVector(MPI_Comm comm)

Create empty vector on an MPI communicator.

Parameters:comm
dolfin::PETScVector::PETScVector(MPI_Comm comm, std::size_t N)

Create vector of size N.

Parameters:
  • comm
  • N
dolfin::PETScVector::PETScVector(Vec x)

Create vector wrapper of PETSc Vec pointer. The reference counter of the Vec will be increased, and decreased upon destruction of this object.

Parameters:x
dolfin::PETScVector::PETScVector(const PETScVector &x)

Copy constructor.

Parameters:x
dolfin::PETScVector::PETScVector(const SparsityPattern &sparsity_pattern)

Create vector.

Parameters:sparsity_pattern
void dolfin::PETScVector::abs()

Replace all entries in the vector by their absolute values.

void dolfin::PETScVector::add(const double *block, std::size_t m, const dolfin::la_index *rows)

Add block of values using global indices.

Parameters:
  • block
  • m
  • rows
void dolfin::PETScVector::add_local(const Array<double> &values)

Add values to each entry on local process.

Parameters:values
void dolfin::PETScVector::add_local(const double *block, std::size_t m, const dolfin::la_index *rows)

Add block of values using local indices.

Parameters:
  • block
  • m
  • rows
void dolfin::PETScVector::apply(std::string mode)

Finalize assembly of tensor.

Parameters:mode
void dolfin::PETScVector::axpy(double a, const GenericVector &x)

Add multiple of given vector (AXPY operation)

Parameters:
  • a
  • x
std::shared_ptr<GenericVector> dolfin::PETScVector::copy() const

Return copy of vector.

bool dolfin::PETScVector::empty() const

Return true if vector is empty.

GenericLinearAlgebraFactory &dolfin::PETScVector::factory() const

Return linear algebra backend factory.

void dolfin::PETScVector::gather(GenericVector &y, const std::vector<dolfin::la_index> &indices) const

Gather entries (given by global indices) into local (MPI_COMM_SELF) vector x. Provided x must be empty or of correct dimension (same as provided indices). This operation is collective

Parameters:
  • y
  • indices
void dolfin::PETScVector::gather(std::vector<double> &x, const std::vector<dolfin::la_index> &indices) const

Gather entries (given by global indices) into x. This operation is collective

Parameters:
  • x
  • indices
void dolfin::PETScVector::gather_on_zero(std::vector<double> &x) const

Gather all entries into x on process 0. This operation is collective

Parameters:x
void dolfin::PETScVector::get(double *block, std::size_t m, const dolfin::la_index *rows) const

Get block of values using global indices (all values must be owned by local process, ghosts cannot be accessed)

Parameters:
  • block
  • m
  • rows
void dolfin::PETScVector::get_local(double *block, std::size_t m, const dolfin::la_index *rows) const

Get block of values using local indices.

Parameters:
  • block
  • m
  • rows
void dolfin::PETScVector::get_local(std::vector<double> &values) const

Get all values on local process.

Parameters:values
std::string dolfin::PETScVector::get_options_prefix() const

Returns the prefix used by PETSc when searching the options database

void dolfin::PETScVector::init(std::pair<std::size_t, std::size_t> range)

Initialize vector with given ownership range.

Parameters:range
void dolfin::PETScVector::init(std::pair<std::size_t, std::size_t> range, const std::vector<std::size_t> &local_to_global_map, const std::vector<la_index> &ghost_indices)

Initialize vector with given ownership range and with ghost values

Parameters:
  • range
  • local_to_global_map
  • ghost_indices
void dolfin::PETScVector::init(std::size_t N)

Initialize vector to global size N.

Parameters:N
double dolfin::PETScVector::inner(const GenericVector &v) const

Return inner product with given vector.

Parameters:v
std::pair<std::int64_t, std::int64_t> dolfin::PETScVector::local_range() const

Return ownership range of a vector.

std::size_t dolfin::PETScVector::local_size() const

Return local size of vector.

double dolfin::PETScVector::max() const

Return maximum value of vector.

double dolfin::PETScVector::min() const

Return minimum value of vector.

MPI_Comm dolfin::PETScVector::mpi_comm() const

Return MPI communicator.

double dolfin::PETScVector::norm(std::string norm_type) const

Return norm of vector.

Parameters:norm_type
const std::map<std::string, NormType> dolfin::PETScVector::norm_types
const PETScVector &dolfin::PETScVector::operator*=(const GenericVector &x)

Multiply vector by another vector pointwise.

Parameters:x
const PETScVector &dolfin::PETScVector::operator*=(double a)

Multiply vector by given number.

Parameters:a
const PETScVector &dolfin::PETScVector::operator+=(const GenericVector &x)

Add given vector.

Parameters:x
const PETScVector &dolfin::PETScVector::operator+=(double a)

Add number to all components of a vector.

Parameters:a
const PETScVector &dolfin::PETScVector::operator-=(const GenericVector &x)

Subtract given vector.

Parameters:x
const PETScVector &dolfin::PETScVector::operator-=(double a)

Subtract number from all components of a vector.

Parameters:a
const PETScVector &dolfin::PETScVector::operator/=(double a)

Divide vector by given number.

Parameters:a
const GenericVector &dolfin::PETScVector::operator=(const GenericVector &x)

Assignment operator.

Parameters:x
const PETScVector &dolfin::PETScVector::operator=(const PETScVector &x)

Assignment operator.

Parameters:x
const PETScVector &dolfin::PETScVector::operator=(double a)

Assignment operator.

Parameters:a
bool dolfin::PETScVector::owns_index(std::size_t i) const

Determine whether global vector index is owned by this process.

Parameters:i
void dolfin::PETScVector::reset(Vec vec)

Switch underlying PETSc object. Intended for internal library usage.

Parameters:vec
void dolfin::PETScVector::set(const double *block, std::size_t m, const dolfin::la_index *rows)

Set block of values using global indices.

Parameters:
  • block
  • m
  • rows
void dolfin::PETScVector::set_from_options()

Call PETSc function VecSetFromOptions on the underlying Vec object

void dolfin::PETScVector::set_local(const double *block, std::size_t m, const dolfin::la_index *rows)

Set block of values using local indices.

Parameters:
  • block
  • m
  • rows
void dolfin::PETScVector::set_local(const std::vector<double> &values)

Set all values on local process.

Parameters:values
void dolfin::PETScVector::set_options_prefix(std::string options_prefix)

Sets the prefix used by PETSc when searching the options database

Parameters:options_prefix
std::size_t dolfin::PETScVector::size() const

Return size of vector.

std::string dolfin::PETScVector::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
double dolfin::PETScVector::sum() const

Return sum of values of vector.

double dolfin::PETScVector::sum(const Array<std::size_t> &rows) const

Return sum of selected rows in vector.

Parameters:rows
void dolfin::PETScVector::update_ghost_values()

Update values shared from remote processes.

Vec dolfin::PETScVector::vec() const

Return pointer to PETSc Vec object.

void dolfin::PETScVector::zero()

Set all entries to zero and keep any sparse structure.

dolfin::PETScVector::~PETScVector()

Destructor.

Scalar

C++ documentation for Scalar from dolfin/la/Scalar.h:

class dolfin::Scalar : public dolfin::GenericTensor

This class represents a real-valued scalar quantity and implements the GenericTensor interface for scalars.

dolfin::Scalar::Scalar()

Create zero scalar.

dolfin::Scalar::Scalar(MPI_Comm comm)

Create zero scalar.

Parameters:comm
void dolfin::Scalar::add(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)

Add block of values using global indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::Scalar::add(const double *block, const std::vector<ArrayView<const dolfin::la_index>> &rows)

Add block of values using global indices.

Parameters:
  • block
  • rows
void dolfin::Scalar::add_local(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)

Add block of values using local indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::Scalar::add_local(const double *block, const std::vector<ArrayView<const dolfin::la_index>> &rows)

Add block of values using local indices.

Parameters:
  • block
  • rows
void dolfin::Scalar::add_local_value(double value)

Add to local increment (added for testing, remove if we add a better way from python)

Parameters:value
void dolfin::Scalar::apply(std::string mode)

Finalize assembly of tensor.

Parameters:mode
std::shared_ptr<Scalar> dolfin::Scalar::copy() const

Return copy of scalar.

bool dolfin::Scalar::empty() const

Return true if empty.

GenericLinearAlgebraFactory &dolfin::Scalar::factory() const

Return a factory for the default linear algebra backend.

void dolfin::Scalar::get(double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows) const

Get block of values.

Parameters:
  • block
  • num_rows
  • rows
double dolfin::Scalar::get_scalar_value() const

Get final value (assumes prior apply() , not part of GenericTensor interface)

void dolfin::Scalar::init(const TensorLayout &tensor_layout)

Initialize zero tensor using sparsity pattern.

Parameters:tensor_layout
std::pair<std::int64_t, std::int64_t> dolfin::Scalar::local_range(std::size_t dim) const

Return local ownership range.

Parameters:dim
MPI_Comm dolfin::Scalar::mpi_comm() const

Return MPI communicator.

std::size_t dolfin::Scalar::rank() const

Return tensor rank (number of dimensions)

void dolfin::Scalar::set(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)

Set block of values using global indices.

Parameters:
  • block
  • num_rows
  • rows
void dolfin::Scalar::set_local(const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)

Set block of values using local indices.

Parameters:
  • block
  • num_rows
  • rows
std::size_t dolfin::Scalar::size(std::size_t dim) const

Return size of given dimension.

Parameters:dim
std::string dolfin::Scalar::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
void dolfin::Scalar::zero()

Set all entries to zero and keep any sparse structure.

dolfin::Scalar::~Scalar()

Destructor.

SparsityPattern

C++ documentation for SparsityPattern from dolfin/la/SparsityPattern.h:

class dolfin::SparsityPattern

This class implements a sparsity pattern data structure. It is used by most linear algebra backends.

dolfin::SparsityPattern::SparsityPattern(MPI_Comm mpi_comm, std::vector<std::shared_ptr<const IndexMap>> index_maps, std::size_t primary_dim)

Create sparsity pattern for a generic tensor.

Parameters:
  • mpi_comm
  • index_maps
  • primary_dim
dolfin::SparsityPattern::SparsityPattern(std::size_t primary_dim)

Create empty sparsity pattern.

Parameters:primary_dim
enum dolfin::SparsityPattern::Type

Whether SparsityPattern is sorted.

enumerator dolfin::SparsityPattern::Type::sorted
enumerator dolfin::SparsityPattern::Type::unsorted
void dolfin::SparsityPattern::apply()

Finalize sparsity pattern.

std::vector<set_type> dolfin::SparsityPattern::diagonal
std::vector<std::vector<std::size_t>> dolfin::SparsityPattern::diagonal_pattern(Type type) const

Return underlying sparsity pattern (diagonal). Options are ‘sorted’ and ‘unsorted’.

Parameters:type
set_type dolfin::SparsityPattern::full_rows
void dolfin::SparsityPattern::info_statistics() const
void dolfin::SparsityPattern::init(MPI_Comm mpi_comm, std::vector<std::shared_ptr<const IndexMap>> index_maps)

Initialize sparsity pattern for a generic tensor.

Parameters:
  • mpi_comm
  • index_maps
void dolfin::SparsityPattern::insert_full_rows_local(const std::vector<std::size_t> &rows)

Insert full rows (or columns, according to primary dimension) using local (process-wise) indices. This must be called before any other sparse insertion occurs to avoid quadratic complexity of dense rows insertion

Parameters:rows
void dolfin::SparsityPattern::insert_global(const std::vector<ArrayView<const dolfin::la_index>> &entries)

Insert non-zero entries using global indices.

Parameters:entries
void dolfin::SparsityPattern::insert_global(dolfin::la_index i, dolfin::la_index j)

Insert a global entry - will be fixed by apply()

Parameters:
  • i
  • j
void dolfin::SparsityPattern::insert_local(const std::vector<ArrayView<const dolfin::la_index>> &entries)

Insert non-zero entries using local (process-wise) indices.

Parameters:entries
std::pair<std::size_t, std::size_t> dolfin::SparsityPattern::local_range(std::size_t dim) const

Return local range for dimension dim.

Parameters:dim
MPI_Comm dolfin::SparsityPattern::mpi_comm() const

Return MPI communicator.

std::vector<std::size_t> dolfin::SparsityPattern::non_local
void dolfin::SparsityPattern::num_local_nonzeros(std::vector<std::size_t> &num_nonzeros) const

Fill vector with number of nonzeros in local_range for dimension 0

Parameters:num_nonzeros
std::size_t dolfin::SparsityPattern::num_nonzeros() const

Return number of local nonzeros.

void dolfin::SparsityPattern::num_nonzeros_diagonal(std::vector<std::size_t> &num_nonzeros) const

Fill array with number of nonzeros for diagonal block in local_range for dimension 0. For matrices, fill array with number of nonzeros per local row for diagonal block

Parameters:num_nonzeros
void dolfin::SparsityPattern::num_nonzeros_off_diagonal(std::vector<std::size_t> &num_nonzeros) const

Fill array with number of nonzeros for off-diagonal block in local_range for dimension 0. For matrices, fill array with number of nonzeros per local row for off-diagonal block. If there is no off-diagonal pattern, the vector is resized to zero-length

Parameters:num_nonzeros
std::vector<set_type> dolfin::SparsityPattern::off_diagonal
std::vector<std::vector<std::size_t>> dolfin::SparsityPattern::off_diagonal_pattern(Type type) const

Return underlying sparsity pattern (off-diagonal). Options are ‘sorted’ and ‘unsorted’. Empty vector is returned if there is no off-diagonal contribution.

Parameters:type
std::size_t dolfin::SparsityPattern::primary_dim() const

Return primary dimension (e.g., 0=row partition, 1=column partition)

std::size_t dolfin::SparsityPattern::rank() const

Return rank.

type dolfin::SparsityPattern::set_type

Set type used for the rows of the sparsity pattern.

std::string dolfin::SparsityPattern::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
TensorLayout

C++ documentation for TensorLayout from dolfin/la/TensorLayout.h:

class dolfin::TensorLayout

This class described the size and possibly the sparsity of a (sparse) tensor. It is used by the linear algebra backends to initialise tensors.

enum dolfin::TensorLayout::Ghosts

Ghosted or unghosted layout.

enumerator dolfin::TensorLayout::Ghosts::GHOSTED = true
enumerator dolfin::TensorLayout::Ghosts::UNGHOSTED = false
enum dolfin::TensorLayout::Sparsity

Sparse or dense layout.

enumerator dolfin::TensorLayout::Sparsity::SPARSE = true
enumerator dolfin::TensorLayout::Sparsity::DENSE = false
dolfin::TensorLayout::TensorLayout(MPI_Comm mpi_comm, std::vector<std::shared_ptr<const IndexMap>> index_maps, std::size_t primary_dim, Sparsity sparsity_pattern, Ghosts ghosted)

Create a tensor layout.

Parameters:
  • mpi_comm
  • index_maps
  • primary_dim
  • sparsity_pattern
  • ghosted
dolfin::TensorLayout::TensorLayout(std::size_t primary_dim, Sparsity sparsity_pattern)

Create empty tensor layout.

Parameters:
  • primary_dim
  • sparsity_pattern
std::shared_ptr<const IndexMap> dolfin::TensorLayout::index_map(std::size_t i) const

Return IndexMap for dimension.

Parameters:i
void dolfin::TensorLayout::init(MPI_Comm mpi_comm, std::vector<std::shared_ptr<const IndexMap>> index_maps, Ghosts ghosted)

Initialize tensor layout.

Parameters:
  • mpi_comm
  • index_maps
  • ghosted
Ghosts dolfin::TensorLayout::is_ghosted() const

Require ghosts.

std::pair<std::size_t, std::size_t> dolfin::TensorLayout::local_range(std::size_t dim) const

Return local range for dimension dim.

Parameters:dim
MPI_Comm dolfin::TensorLayout::mpi_comm() const

Return MPI communicator.

const std::size_t dolfin::TensorLayout::primary_dim

Primary storage dim (e.g., 0=row major, 1=column major)

std::size_t dolfin::TensorLayout::rank() const

Return rank.

std::size_t dolfin::TensorLayout::size(std::size_t i) const

Return global size for dimension i (size of tensor, includes non-zeroes)

Parameters:i
std::shared_ptr<SparsityPattern> dolfin::TensorLayout::sparsity_pattern()

Return sparsity pattern (possibly null)

std::shared_ptr<const SparsityPattern> dolfin::TensorLayout::sparsity_pattern() const

Return sparsity pattern (possibly null), const version.

std::string dolfin::TensorLayout::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
TpetraFactory

C++ documentation for TpetraFactory from dolfin/la/TpetraFactory.h:

class dolfin::TpetraFactory

Tpetra linear algebra factory.

dolfin::TpetraFactory::TpetraFactory()

Private constructor.

std::shared_ptr<GenericLinearSolver> dolfin::TpetraFactory::create_krylov_solver(MPI_Comm comm, std::string method, std::string preconditioner) const

Create Krylov solver.

Parameters:
  • comm
  • method
  • preconditioner
std::shared_ptr<TensorLayout> dolfin::TpetraFactory::create_layout(std::size_t rank) const

Create empty tensor layout.

Parameters:rank
std::shared_ptr<GenericLinearOperator> dolfin::TpetraFactory::create_linear_operator(MPI_Comm comm) const

Create empty linear operator.

Parameters:comm
std::shared_ptr<GenericLinearSolver> dolfin::TpetraFactory::create_lu_solver(MPI_Comm comm, std::string method) const

Create LU solver.

Parameters:
  • comm
  • method
std::shared_ptr<GenericMatrix> dolfin::TpetraFactory::create_matrix(MPI_Comm comm) const

Create empty matrix.

Parameters:comm
std::shared_ptr<GenericVector> dolfin::TpetraFactory::create_vector(MPI_Comm comm) const

Create empty vector.

Parameters:comm
TpetraFactory dolfin::TpetraFactory::factory
TpetraFactory &dolfin::TpetraFactory::instance()

Return singleton instance.

std::map<std::string, std::string> dolfin::TpetraFactory::krylov_solver_methods() const

Return a list of available Krylov solver methods.

std::map<std::string, std::string> dolfin::TpetraFactory::krylov_solver_preconditioners() const

Return a list of available preconditioners.

std::map<std::string, std::string> dolfin::TpetraFactory::lu_solver_methods() const

Return a list of available LU solver methods.

dolfin::TpetraFactory::~TpetraFactory()

Destructor.

TpetraMatrix

C++ documentation for TpetraMatrix from dolfin/la/TpetraMatrix.h:

class dolfin::TpetraMatrix : public dolfin::GenericMatrix

This class provides a simple matrix class based on Tpetra. It is a wrapper for a Tpetra matrix pointer (Teuchos::RCP<matrix_type>) implementing the GenericMatrix interface. The interface is intentionally simple. For advanced usage, access the Tpetra::RCP<matrix_type> pointer using the function mat and use the standard Tpetra interface.

dolfin::TpetraMatrix::TpetraMatrix()

Create empty matrix.

dolfin::TpetraMatrix::TpetraMatrix(Teuchos::RCP<matrix_type> A)

Create a wrapper around a Teuchos::RCP<matrix_type> pointer.

Parameters:A
dolfin::TpetraMatrix::TpetraMatrix(const TpetraMatrix &A)

Copy constructor.

Parameters:A
void dolfin::TpetraMatrix::add(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Add block of values using global indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::TpetraMatrix::add_local(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Add block of values using local indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::TpetraMatrix::apply(std::string mode)

Finalize assembly of tensor. The mode parameter is ignored.

Parameters:mode
void dolfin::TpetraMatrix::axpy(double a, const GenericMatrix &A, bool same_nonzero_pattern)

Add multiple of given matrix (AXPY operation)

Parameters:
  • a
  • A
  • same_nonzero_pattern
std::shared_ptr<GenericMatrix> dolfin::TpetraMatrix::copy() const

Return copy of matrix.

bool dolfin::TpetraMatrix::empty() const

Return true if empty.

GenericLinearAlgebraFactory &dolfin::TpetraMatrix::factory() const

Return linear algebra backend factory.

void dolfin::TpetraMatrix::get(double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols) const

Get block of values.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::TpetraMatrix::get_diagonal(GenericVector &x) const

Get diagonal of a matrix.

Parameters:x
void dolfin::TpetraMatrix::getrow(std::size_t row, std::vector<std::size_t> &columns, std::vector<double> &values) const

Get non-zero values of given row.

Parameters:
  • row
  • columns
  • values
type dolfin::TpetraMatrix::graph_type

Graph type (local index, global index)

void dolfin::TpetraMatrix::graphdump(const Teuchos::RCP<const graph_type> graph)

Print out a graph, for debugging.

Parameters:graph
void dolfin::TpetraMatrix::ident(std::size_t m, const dolfin::la_index *rows)

Set given rows (global row indices) to identity matrix.

Parameters:
  • m
  • rows
void dolfin::TpetraMatrix::ident_local(std::size_t m, const dolfin::la_index *rows)

Set given rows (local row indices) to identity matrix.

Parameters:
  • m
  • rows
std::array<std::shared_ptr<const IndexMap>, 2> dolfin::TpetraMatrix::index_map
void dolfin::TpetraMatrix::init(const TensorLayout &tensor_layout)

Initialize zero tensor using tensor layout.

Parameters:tensor_layout
void dolfin::TpetraMatrix::init_vector(GenericVector &z, std::size_t dim) const

Initialize vector z to be compatible with the matrix-vector product y = Ax. In the parallel case, both size and layout are important.

Parameters:
  • z – (GenericVector &) Vector to initialise
  • dim – (std::size_t) The dimension (axis): dim = 0 –> z = y, dim = 1 –> z = x
bool dolfin::TpetraMatrix::is_symmetric(double tol) const

Test if matrix is symmetric.

Parameters:tol
std::pair<std::int64_t, std::int64_t> dolfin::TpetraMatrix::local_range(std::size_t dim) const

Return local ownership range.

Parameters:dim
type dolfin::TpetraMatrix::map_type

Map type (local index, global index)

Teuchos::RCP<matrix_type> dolfin::TpetraMatrix::mat()

Return Teuchos reference counted pointer to raw matrix.

Teuchos::RCP<const matrix_type> dolfin::TpetraMatrix::mat() const

Return Teuchos reference counted pointer to raw matrix (const)

type dolfin::TpetraMatrix::matrix_type

Matrix type (scalar, local index, global index)

MPI_Comm dolfin::TpetraMatrix::mpi_comm() const

Return MPI communicator.

void dolfin::TpetraMatrix::mult(const GenericVector &x, GenericVector &y) const

Compute matrix-vector product y = Ax.

Parameters:
  • x
  • y
std::size_t dolfin::TpetraMatrix::nnz() const

Return number of non-zero entries in matrix (collective)

double dolfin::TpetraMatrix::norm(std::string norm_type) const

Return norm of matrix.

Parameters:norm_type
const TpetraMatrix &dolfin::TpetraMatrix::operator*=(double a)

Multiply matrix by given number.

Parameters:a
const TpetraMatrix &dolfin::TpetraMatrix::operator/=(double a)

Divide matrix by given number.

Parameters:a
const GenericMatrix &dolfin::TpetraMatrix::operator=(const GenericMatrix &A)

Assignment operator.

Parameters:A
const TpetraMatrix &dolfin::TpetraMatrix::operator=(const TpetraMatrix &A)

Assignment operator.

Parameters:A
void dolfin::TpetraMatrix::set(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Set block of values using global indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::TpetraMatrix::set_diagonal(const GenericVector &x)

Set diagonal of a matrix.

Parameters:x
void dolfin::TpetraMatrix::set_local(const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)

Set block of values using local indices.

Parameters:
  • block
  • m
  • rows
  • n
  • cols
void dolfin::TpetraMatrix::setrow(std::size_t row, const std::vector<std::size_t> &columns, const std::vector<double> &values)

Set values for given row.

Parameters:
  • row
  • columns
  • values
std::size_t dolfin::TpetraMatrix::size(std::size_t dim) const

Return size of given dimension.

Parameters:dim
std::string dolfin::TpetraMatrix::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
void dolfin::TpetraMatrix::transpmult(const GenericVector &x, GenericVector &y) const

Matrix-vector product, y = A^T x. The y vector must either be zero-sized or have correct size and parallel layout.

Parameters:
  • x
  • y
void dolfin::TpetraMatrix::zero()

Set all entries to zero and keep any sparse structure.

void dolfin::TpetraMatrix::zero(std::size_t m, const dolfin::la_index *rows)

Set given rows (global row indices) to zero.

Parameters:
  • m
  • rows
void dolfin::TpetraMatrix::zero_local(std::size_t m, const dolfin::la_index *rows)

Set given rows (local row indices) to zero.

Parameters:
  • m
  • rows
dolfin::TpetraMatrix::~TpetraMatrix()

Destructor.

TpetraVector

C++ documentation for TpetraVector from dolfin/la/TpetraVector.h:

class dolfin::TpetraVector : public dolfin::GenericVector

This class provides a simple vector class based on Tpetra. It is a wrapper for Teuchos::RCP<Tpetra::MultiVector> implementing the GenericVector interface. The interface is intentionally simple. For advanced usage, access the Teuchos::RCP<Tpetra::MultiVector> using the function vec and use the standard Tpetra interface.

Friends: TpetraMatrix.

dolfin::TpetraVector::TpetraVector(MPI_Comm comm, std::size_t N)

Create vector of size N.

Parameters:
  • comm
  • N
dolfin::TpetraVector::TpetraVector(MPI_Comm comm = MPI_COMM_WORLD)

Create empty vector.

Parameters:comm
dolfin::TpetraVector::TpetraVector(const TpetraVector &x)

Copy constructor.

Parameters:x
void dolfin::TpetraVector::abs()

Replace all entries in the vector by their absolute values.

void dolfin::TpetraVector::add(const double *block, std::size_t m, const dolfin::la_index *rows)

Add block of values using global indices.

Parameters:
  • block
  • m
  • rows
void dolfin::TpetraVector::add_local(const Array<double> &values)

Add values to each entry on local process.

Parameters:values
void dolfin::TpetraVector::add_local(const double *block, std::size_t m, const dolfin::la_index *rows)

Add block of values using local indices.

Parameters:
  • block
  • m
  • rows
void dolfin::TpetraVector::apply(std::string mode)

Finalize assembly of tensor.

Parameters:mode
void dolfin::TpetraVector::axpy(double a, const GenericVector &x)

Add multiple of given vector (AXPY operation)

Parameters:
  • a
  • x
std::shared_ptr<GenericVector> dolfin::TpetraVector::copy() const

Return copy of vector.

bool dolfin::TpetraVector::empty() const

Return true if vector is empty.

GenericLinearAlgebraFactory &dolfin::TpetraVector::factory() const

Return linear algebra backend factory.

void dolfin::TpetraVector::gather(GenericVector &y, const std::vector<dolfin::la_index> &indices) const

Gather entries (given by global indices) into local (MPI_COMM_SELF) vector x. Provided x must be empty or of correct dimension (same as provided indices). This operation is collective

Parameters:
  • y
  • indices
void dolfin::TpetraVector::gather(std::vector<double> &x, const std::vector<dolfin::la_index> &indices) const

Gather entries (given by global indices) into x. This operation is collective

Parameters:
  • x
  • indices
void dolfin::TpetraVector::gather_on_zero(std::vector<double> &x) const

Gather all entries into x on process 0. This operation is collective

Parameters:x
void dolfin::TpetraVector::get(double *block, std::size_t m, const dolfin::la_index *rows) const

Get block of values using global indices (all values must be owned by local process, ghosts cannot be accessed)

Parameters:
  • block
  • m
  • rows
void dolfin::TpetraVector::get_local(double *block, std::size_t m, const dolfin::la_index *rows) const

Get block of values using local indices.

Parameters:
  • block
  • m
  • rows
void dolfin::TpetraVector::get_local(std::vector<double> &values) const

Get all values on local process.

Parameters:values
void dolfin::TpetraVector::init(std::pair<std::size_t, std::size_t> range)

Initialize vector with given ownership range.

Parameters:range
void dolfin::TpetraVector::init(std::pair<std::size_t, std::size_t> range, const std::vector<std::size_t> &local_to_global_map, const std::vector<la_index> &ghost_indices)

Initialize vector with given ownership range and with ghost values

Parameters:
  • range
  • local_to_global_map
  • ghost_indices
void dolfin::TpetraVector::init(std::size_t N)

Initialize vector to global size N.

Parameters:N
double dolfin::TpetraVector::inner(const GenericVector &v) const

Return inner product with given vector.

Parameters:v
std::pair<std::int64_t, std::int64_t> dolfin::TpetraVector::local_range() const

Return ownership range of a vector.

std::size_t dolfin::TpetraVector::local_size() const

Return local size of vector.

type dolfin::TpetraVector::map_type

TpetraVector map type (local index, global index)

void dolfin::TpetraVector::mapdump(Teuchos::RCP<const map_type> xmap, const std::string desc)

output map for debugging

Parameters:
  • xmap
  • desc
void dolfin::TpetraVector::mapdump(const std::string desc)

Dump x.map and ghost_map for debugging.

Parameters:desc
double dolfin::TpetraVector::max() const

Return maximum value of vector.

double dolfin::TpetraVector::min() const

Return minimum value of vector.

MPI_Comm dolfin::TpetraVector::mpi_comm() const

Return MPI communicator.

type dolfin::TpetraVector::node_type

Node type.

double dolfin::TpetraVector::norm(std::string norm_type) const

Return norm of vector.

Parameters:norm_type
const TpetraVector &dolfin::TpetraVector::operator*=(const GenericVector &x)

Multiply vector by another vector pointwise.

Parameters:x
const TpetraVector &dolfin::TpetraVector::operator*=(double a)

Multiply vector by given number.

Parameters:a
const TpetraVector &dolfin::TpetraVector::operator+=(const GenericVector &x)

Add given vector.

Parameters:x
const TpetraVector &dolfin::TpetraVector::operator+=(double a)

Add number to all components of a vector.

Parameters:a
const TpetraVector &dolfin::TpetraVector::operator-=(const GenericVector &x)

Subtract given vector.

Parameters:x
const TpetraVector &dolfin::TpetraVector::operator-=(double a)

Subtract number from all components of a vector.

Parameters:a
const TpetraVector &dolfin::TpetraVector::operator/=(double a)

Divide vector by given number.

Parameters:a
const GenericVector &dolfin::TpetraVector::operator=(const GenericVector &x)

Assignment operator.

Parameters:x
const TpetraVector &dolfin::TpetraVector::operator=(const TpetraVector &x)

Assignment operator.

Parameters:x
const TpetraVector &dolfin::TpetraVector::operator=(double a)

Assignment operator.

Parameters:a
bool dolfin::TpetraVector::owns_index(std::size_t i) const

Determine whether global vector index is owned by this process.

Parameters:i
void dolfin::TpetraVector::set(const double *block, std::size_t m, const dolfin::la_index *rows)

Set block of values using global indices.

Parameters:
  • block
  • m
  • rows
void dolfin::TpetraVector::set_local(const double *block, std::size_t m, const dolfin::la_index *rows)

Set block of values using local indices.

Parameters:
  • block
  • m
  • rows
void dolfin::TpetraVector::set_local(const std::vector<double> &values)

Set all values on local process.

Parameters:values
std::size_t dolfin::TpetraVector::size() const

Return size of vector.

std::string dolfin::TpetraVector::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
double dolfin::TpetraVector::sum() const

Return sum of values of vector.

double dolfin::TpetraVector::sum(const Array<std::size_t> &rows) const

Return sum of selected rows in vector.

Parameters:rows
void dolfin::TpetraVector::update_ghost_values()

Update ghost values in vector.

Teuchos::RCP<vector_type> dolfin::TpetraVector::vec() const

Return pointer to Tpetra vector object.

type dolfin::TpetraVector::vector_type

TpetraVector vector type (scalar, local index, global index, node)

void dolfin::TpetraVector::zero()

Set all entries to zero and keep any sparse structure.

dolfin::TpetraVector::~TpetraVector()

Create vector wrapper of Tpetra Vec pointer. Destructor

TrilinosParameters

C++ documentation for TrilinosParameters from dolfin/la/TrilinosParameters.h:

class dolfin::TrilinosParameters

Method for translating DOLFIN Parameters to Teuchos::ParameterList needed by Trilinos objects

void dolfin::TrilinosParameters::insert_parameters(const Parameters &params, Teuchos::RCP<Teuchos::ParameterList> parameter_list)

Copy over parameters from a dolfin Parameters object to a Teuchos::ParameterList

Parameters:
  • params – (Parameters ) dolfin parameter set [direction=in]
  • parameter_list – (Teuchos::RCP<Teuchos::ParameterList>) Trilinos Teuchos parameter set [direction=inout]
TrilinosPreconditioner

C++ documentation for TrilinosPreconditioner from dolfin/la/TrilinosPreconditioner.h:

class dolfin::TrilinosPreconditioner

This class provides a common base for Trilinos preconditioners.

dolfin::TrilinosPreconditioner::TrilinosPreconditioner()

Constructor.

void dolfin::TrilinosPreconditioner::init(std::shared_ptr<const TpetraMatrix> P) = 0

Initialise this preconditioner with the operator P.

Parameters:P
void dolfin::TrilinosPreconditioner::set(BelosKrylovSolver &solver) = 0

Set this preconditioner on a solver.

Parameters:solver
dolfin::TrilinosPreconditioner::~TrilinosPreconditioner()

Destructor.

Vector

C++ documentation for Vector from dolfin/la/Vector.h:

class dolfin::Vector : public dolfin::GenericVector

This class provides the default DOLFIN vector class, based on the default DOLFIN linear algebra backend.

dolfin::Vector::Vector(MPI_Comm comm, std::size_t N)

Create vector of size N.

Parameters:
  • comm
  • N
dolfin::Vector::Vector(MPI_Comm comm = MPI_COMM_WORLD)

Create empty vector.

Parameters:comm
dolfin::Vector::Vector(const GenericVector &x)

Create a Vector() from a GenericVector .

Parameters:x
dolfin::Vector::Vector(const Vector &x)

Copy constructor.

Parameters:x
void dolfin::Vector::abs()

Replace all entries in the vector by their absolute values.

void dolfin::Vector::add(const double *block, std::size_t m, const dolfin::la_index *rows)

Add block of values using global indices.

Parameters:
  • block
  • m
  • rows
void dolfin::Vector::add_local(const Array<double> &values)

Add values to each entry on local process.

Parameters:values
void dolfin::Vector::add_local(const double *block, std::size_t m, const dolfin::la_index *rows)

Add block of values using local indices.

Parameters:
  • block
  • m
  • rows
void dolfin::Vector::apply(std::string mode)

Finalize assembly of tensor.

Parameters:mode
void dolfin::Vector::axpy(double a, const GenericVector &x)

Add multiple of given vector (AXPY operation)

Parameters:
  • a
  • x
std::shared_ptr<GenericVector> dolfin::Vector::copy() const

Return copy of vector.

bool dolfin::Vector::empty() const

Return true if vector is empty.

GenericLinearAlgebraFactory &dolfin::Vector::factory() const

Return linear algebra backend factory.

void dolfin::Vector::gather(GenericVector &x, const std::vector<dolfin::la_index> &indices) const

Gather entries (given by global indices) into local vector x

Parameters:
  • x
  • indices
void dolfin::Vector::gather(std::vector<double> &x, const std::vector<dolfin::la_index> &indices) const

Gather entries (given by global indices) into x.

Parameters:
  • x
  • indices
void dolfin::Vector::gather_on_zero(std::vector<double> &x) const

Gather all entries into x on process 0.

Parameters:x
void dolfin::Vector::get(double *block, std::size_t m, const dolfin::la_index *rows) const

Get block of values using global indices (values must all live on the local process, ghosts are no accessible)

Parameters:
  • block
  • m
  • rows
void dolfin::Vector::get_local(double *block, std::size_t m, const dolfin::la_index *rows) const

Get block of values using local indices (values must all live on the local process)

Parameters:
  • block
  • m
  • rows
void dolfin::Vector::get_local(std::vector<double> &values) const

Get all values on local process.

Parameters:values
void dolfin::Vector::init(std::pair<std::size_t, std::size_t> range)

Initialize vector with given ownership range.

Parameters:range
void dolfin::Vector::init(std::pair<std::size_t, std::size_t> range, const std::vector<std::size_t> &local_to_global_map, const std::vector<la_index> &ghost_indices)

Initialize vector with given ownership range and with ghost values

Parameters:
  • range
  • local_to_global_map
  • ghost_indices
void dolfin::Vector::init(std::size_t N)

Initialize vector to size N.

Parameters:N
double dolfin::Vector::inner(const GenericVector &x) const

Return inner product with given vector.

Parameters:x
GenericVector *dolfin::Vector::instance()

Return concrete instance / unwrap (non-const version)

const GenericVector *dolfin::Vector::instance() const

Return concrete instance / unwrap (const version)

std::pair<std::int64_t, std::int64_t> dolfin::Vector::local_range() const

Return local ownership range of a vector.

std::size_t dolfin::Vector::local_size() const

Return local size of vector.

double dolfin::Vector::max() const

Return maximum value of vector.

double dolfin::Vector::min() const

Return minimum value of vector.

MPI_Comm dolfin::Vector::mpi_comm() const

Return MPI communicator.

double dolfin::Vector::norm(std::string norm_type) const

Return norm of vector.

Parameters:norm_type
const Vector &dolfin::Vector::operator*=(const GenericVector &x)

Multiply vector by another vector pointwise.

Parameters:x
const Vector &dolfin::Vector::operator*=(double a)

Multiply vector by given number.

Parameters:a
const Vector &dolfin::Vector::operator+=(const GenericVector &x)

Add given vector.

Parameters:x
const GenericVector &dolfin::Vector::operator+=(double a)

Add number to all components of a vector.

Parameters:a
const Vector &dolfin::Vector::operator-=(const GenericVector &x)

Subtract given vector.

Parameters:x
const GenericVector &dolfin::Vector::operator-=(double a)

Subtract number from all components of a vector.

Parameters:a
const Vector &dolfin::Vector::operator/=(double a)

Divide vector by given number.

Parameters:a
const GenericVector &dolfin::Vector::operator=(const GenericVector &x)

Assignment operator.

Parameters:x
const Vector &dolfin::Vector::operator=(const Vector &x)

Assignment operator.

Parameters:x
const Vector &dolfin::Vector::operator=(double a)

Assignment operator.

Parameters:a
bool dolfin::Vector::owns_index(std::size_t i) const

Determine whether global vector index is owned by this process.

Parameters:i
void dolfin::Vector::set(const double *block, std::size_t m, const dolfin::la_index *rows)

Set block of values using global indices.

Parameters:
  • block
  • m
  • rows
void dolfin::Vector::set_local(const double *block, std::size_t m, const dolfin::la_index *rows)

Set block of values using local indices.

Parameters:
  • block
  • m
  • rows
void dolfin::Vector::set_local(const std::vector<double> &values)

Set all values on local process.

Parameters:values
std::shared_ptr<LinearAlgebraObject> dolfin::Vector::shared_instance()

Return concrete shared ptr instance / unwrap (non-const version)

std::shared_ptr<const LinearAlgebraObject> dolfin::Vector::shared_instance() const

Return concrete shared ptr instance / unwrap (const version)

std::size_t dolfin::Vector::size() const

Return size of vector.

std::string dolfin::Vector::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
double dolfin::Vector::sum() const

Return sum of values of vector.

double dolfin::Vector::sum(const Array<std::size_t> &rows) const

Return sum of selected rows in vector. Repeated entries are only summed once.

Parameters:rows
std::shared_ptr<GenericVector> dolfin::Vector::vector
void dolfin::Vector::zero()

Set all entries to zero and keep any sparse structure.

VectorSpaceBasis

C++ documentation for VectorSpaceBasis from dolfin/la/VectorSpaceBasis.h:

class dolfin::VectorSpaceBasis

This class defines a basis for vector spaces, typically used for expressing nullspaces of singular operators and ‘near nullspaces’ used in smoothed aggregation algebraic multigrid.

dolfin::VectorSpaceBasis::VectorSpaceBasis(const std::vector<std::shared_ptr<GenericVector>> basis)

Constructor.

Parameters:basis
std::size_t dolfin::VectorSpaceBasis::dim() const

Number of vectors in the basis.

bool dolfin::VectorSpaceBasis::is_orthogonal(double tol = 1.0e-10) const

Test if basis is orthogonal.

Parameters:tol
bool dolfin::VectorSpaceBasis::is_orthonormal(double tol = 1.0e-10) const

Test if basis is orthonormal.

Parameters:tol
std::shared_ptr<const GenericVector> dolfin::VectorSpaceBasis::operator[](std::size_t i) const

Get a particular basis vector.

Parameters:i
void dolfin::VectorSpaceBasis::orthogonalize(GenericVector &x) const

Orthogonalize x with respect to basis.

Parameters:x
void dolfin::VectorSpaceBasis::orthonormalize(double tol = 1.0e-10)

Apply the Gram-Schmidt process to orthonormalize the basis. Throws an error if a (near) linear dependency is detected. Error is thrown if <x_i, x_i> < tol.

Parameters:tol
dolfin::VectorSpaceBasis::~VectorSpaceBasis()

Destructor.

dolfin/log

Documentation for C++ code found in dolfin/log/*.h

Enumerations

LogLevel

C++ documentation for LogLevel from dolfin/log/LogLevel.h:

enum dolfin::LogLevel

These log levels match the levels in the Python ‘logging’ module (and adds trace/progress).

enumerator dolfin::LogLevel::CRITICAL = 50
enumerator dolfin::LogLevel::ERROR = 40
enumerator dolfin::LogLevel::WARNING = 30
enumerator dolfin::LogLevel::INFO = 20
enumerator dolfin::LogLevel::PROGRESS = 16
enumerator dolfin::LogLevel::TRACE = 13
enumerator dolfin::LogLevel::DBG = 10

Functions

begin

C++ documentation for begin from dolfin/log/log.h:

void dolfin::begin(int debug_level, std::string msg, ...)

Begin task (increase indentation level)

Parameters:
  • debug_level
  • msg

C++ documentation for begin from dolfin/log/log.h:

void dolfin::begin(std::string msg, ...)

Begin task (increase indentation level)

Parameters:msg
deprecation

C++ documentation for deprecation from dolfin/log/log.h:

void dolfin::deprecation(std::string feature, std::string version_deprecated, std::string message, ...)

Issue deprecation warning for removed feature Arguments feature (std::string) Name of the feature that has been removed. version_deprecated (std::string) Version number of the release in which the feature is deprecated. message (std::string) A format string explaining the deprecation.

Parameters:
  • feature
  • version_deprecated
  • message
dolfin_error

C++ documentation for dolfin_error from dolfin/log/log.h:

void dolfin::dolfin_error(std::string location, std::string task, std::string reason, ...)

Print error message. Prefer this to the above generic error message. Arguments location (std::string) Name of the file from which the error message was generated. task (std::string) Name of the task that failed. Note that this string should begin with lowercase. Note that this string should not be punctuated. reason (std::string) A format string explaining the reason for the failure. Note that this string should begin with uppercase. Note that this string should not be punctuated. Note that this string may contain printf style formatting. ... (primitive types like int, std::size_t, double, bool) Optional arguments for the format string. Developers should read the file dolfin/log/README in the DOLFIN source tree for further notes about the use of this function.

Parameters:
  • location
  • task
  • reason
end

C++ documentation for end from dolfin/log/log.h:

void dolfin::end()

End task (decrease indentation level)

error

C++ documentation for error from dolfin/log/log.h:

void dolfin::error(std::string msg, ...)

Print error message and throw an exception. Note to developers: this function should not be used internally in DOLFIN. Use the more informative dolfin_error instead.

Parameters:msg
get_log_level

C++ documentation for get_log_level from dolfin/log/log.h:

int dolfin::get_log_level()

Get log level.

info

C++ documentation for info from dolfin/log/log.h:

void dolfin::info(const Parameters &parameters, bool verbose = false)

Print parameter (using output of str() method)

Parameters:
  • parameters
  • verbose

C++ documentation for info from dolfin/log/log.h:

void dolfin::info(const Variable &variable, bool verbose = false)

Print variable (using output of str() method)

Parameters:
  • variable
  • verbose

C++ documentation for info from dolfin/log/log.h:

void dolfin::info(std::string msg, ...)

Print message. The DOLFIN log system provides the following set of functions for uniform handling of log messages, warnings and errors. In addition, macros are provided for debug messages and dolfin_assertions. Only messages with a debug level higher than or equal to the current log level are printed (the default being zero). Logging may also be turned off by calling set_log_active(false).

Parameters:msg
info_stream

C++ documentation for info_stream from dolfin/log/log.h:

void dolfin::info_stream(std::ostream &out, std::string msg)

Print message to stream.

Parameters:
  • out
  • msg
info_underline

C++ documentation for info_underline from dolfin/log/log.h:

void dolfin::info_underline(std::string msg, ...)

Print underlined message.

Parameters:msg
log

C++ documentation for log from dolfin/log/log.h:

void dolfin::log(int debug_level, std::string msg, ...)

Print message at given debug level.

Parameters:
  • debug_level
  • msg
monitor_memory_usage

C++ documentation for monitor_memory_usage from dolfin/log/log.h:

void dolfin::monitor_memory_usage()

Monitor memory usage. Call this function at the start of a program to continuously monitor the memory usage of the process.

not_working_in_parallel

C++ documentation for not_working_in_parallel from dolfin/log/log.h:

void dolfin::not_working_in_parallel(std::string what)

Report that functionality has not (yet) been implemented to work in parallel

Parameters:what
set_log_active

C++ documentation for set_log_active from dolfin/log/log.h:

void dolfin::set_log_active(bool active = true)

Turn logging on or off.

Parameters:active
set_log_level

C++ documentation for set_log_level from dolfin/log/log.h:

void dolfin::set_log_level(int level)

Set log level.

Parameters:level
set_output_stream

C++ documentation for set_output_stream from dolfin/log/log.h:

void dolfin::set_output_stream(std::ostream &out)

Set output stream.

Parameters:out
warning

C++ documentation for warning from dolfin/log/log.h:

void dolfin::warning(std::string msg, ...)

Print warning.

Parameters:msg

Variables

cout

C++ documentation for cout from dolfin/log/LogStream.h:

LogStream dolfin::cout

dolfin::cout

endl

C++ documentation for endl from dolfin/log/LogStream.h:

LogStream dolfin::endl

dolfin::endl ;

Classes

Event

C++ documentation for Event from dolfin/log/Event.h:

class dolfin::Event

A event is a string message which is displayed only a limited number of times.

Event event("System is stiff, damping is needed.");
while ()
{
...
if ( ... )
{
event();
...
}
}
dolfin::Event::Event(const std::string msg, unsigned int maxcount = 1)

Constructor.

Parameters:
  • msg
  • maxcount
unsigned int dolfin::Event::count() const

Display count.

unsigned int dolfin::Event::maxcount() const

Maximum display count.

void dolfin::Event::operator()()

Display message.

dolfin::Event::~Event()

Destructor.

LogManager

C++ documentation for LogManager from dolfin/log/LogManager.h:

class dolfin::LogManager

Logger initialisation.

Logger &dolfin::LogManager::logger()

Singleton instance of logger.

LogStream

C++ documentation for LogStream from dolfin/log/LogStream.h:

class dolfin::LogStream

This class provides functionality similar to standard C++ streams (std::cout, std::endl) for output but working through the DOLFIN log system.

dolfin::LogStream::LogStream(Type type)

Create log stream of given type.

Parameters:type
enum dolfin::LogStream::Type

Stream types.

enumerator dolfin::LogStream::Type::COUT
enumerator dolfin::LogStream::Type::ENDL
std::stringstream dolfin::LogStream::buffer
LogStream &dolfin::LogStream::operator<<(const LogStream &stream)

Output for log stream.

Parameters:stream
LogStream &dolfin::LogStream::operator<<(const MeshEntity &entity)

Output for mesh entity (not subclass of Variable for efficiency)

Parameters:entity
LogStream &dolfin::LogStream::operator<<(const Point &point)

Output for point (not subclass of Variable for efficiency)

Parameters:point
LogStream &dolfin::LogStream::operator<<(const Variable &variable)

Output for variable (calling str() method)

Parameters:variable
LogStream &dolfin::LogStream::operator<<(const std::string &s)

Output for string.

Parameters:s
LogStream &dolfin::LogStream::operator<<(double a)

Output for double.

Parameters:a
LogStream &dolfin::LogStream::operator<<(int a)

Output for int.

Parameters:a
LogStream &dolfin::LogStream::operator<<(long int a)

Output for long int.

Parameters:a
LogStream & dolfin::LogStream::operator<<(long unsigned int a)

Output for long int.

Parameters:a
LogStream &dolfin::LogStream::operator<<(std::complex<double> z)

Output for std::complex<double>

Parameters:z
LogStream &dolfin::LogStream::operator<<(unsigned int a)

Output for unsigned int.

Parameters:a
void dolfin::LogStream::setprecision(std::streamsize n)

Set precision.

Parameters:n
dolfin::LogStream::~LogStream()

Destructor.

Logger

C++ documentation for Logger from dolfin/log/Logger.h:

class dolfin::Logger

Handling of error messages, logging and informational display.

dolfin::Logger::Logger()

Constructor.

void dolfin::Logger::begin(std::string msg, int log_level = INFO)

Begin task (increase indentation level)

Parameters:
  • msg
  • log_level
void dolfin::Logger::deprecation(std::string feature, std::string version_deprecated, std::string message) const

Issue deprecation warning for removed feature.

Parameters:
  • feature
  • version_deprecated
  • message
void dolfin::Logger::dolfin_error(std::string location, std::string task, std::string reason, int mpi_rank = -1) const

Print error message, prefer this to the above generic error message.

Parameters:
  • location
  • task
  • reason
  • mpi_rank
void dolfin::Logger::dump_timings_to_xml(std::string filename, TimingClear clear)

Dump a summary of timings and tasks to XML file, optionally clearing stored timings. MPI_MAX , MPI_MIN and MPI_AVG reductions are stored. Collective on ``Logger::mpi_comm() `` .

Parameters:
  • filename
  • clear
void dolfin::Logger::end()

End task (decrease indentation level)

void dolfin::Logger::error(std::string msg) const

Print error message and throw exception.

Parameters:msg
int dolfin::Logger::get_log_level() const

Get log level.

std::ostream &dolfin::Logger::get_output_stream()

Get output stream.

int dolfin::Logger::indentation_level
bool dolfin::Logger::is_active()

Return true iff logging is active.

void dolfin::Logger::list_timings(TimingClear clear, std::set<TimingType> type)

List a summary of timings and tasks, optionally clearing stored timings. MPI_AVG reduction is printed. Collective on ``Logger::mpi_comm() `` .

Parameters:
  • clear
  • type
void dolfin::Logger::log(std::string msg, int log_level = INFO) const

Print message.

Parameters:
  • msg
  • log_level
void dolfin::Logger::log_underline(std::string msg, int log_level = INFO) const

Print underlined message.

Parameters:
  • msg
  • log_level
std::ostream *dolfin::Logger::logstream
void dolfin::Logger::monitor_memory_usage()

Monitor memory usage. Call this function at the start of a program to continuously monitor the memory usage of the process.

MPI_Comm dolfin::Logger::mpi_comm()

Return MPI Communicator of Logger .

void dolfin::Logger::progress(std::string title, double p) const

Draw progress bar.

Parameters:
  • title
  • p
void dolfin::Logger::register_timing(std::string task, std::tuple<double, double, double> elapsed)

Register timing (for later summary)

Parameters:
  • task
  • elapsed
void dolfin::Logger::set_log_active(bool active)

Turn logging on or off.

Parameters:active
void dolfin::Logger::set_log_level(int log_level)

Set log level.

Parameters:log_level
void dolfin::Logger::set_output_stream(std::ostream &stream)

Set output stream.

Parameters:stream
std::tuple<std::size_t, double, double, double> dolfin::Logger::timing(std::string task, TimingClear clear)

Return timing (count, total wall time, total user time, total system time) for given task, optionally clearing all timings for the task

Parameters:
  • task
  • clear
Table dolfin::Logger::timings(TimingClear clear, std::set<TimingType> type)

Return a summary of timings and tasks in a Table , optionally clearing stored timings

Parameters:
  • clear
  • type
void dolfin::Logger::warning(std::string msg) const

Print warning.

Parameters:msg
void dolfin::Logger::write(int log_level, std::string msg) const
Parameters:
  • log_level
  • msg
dolfin::Logger::~Logger()

Destructor.

Progress

C++ documentation for Progress from dolfin/log/Progress.h:

class dolfin::Progress

This class provides a simple way to create and update progress bars during a computation.

A progress bar may be used either in an iteration with a known number
of steps:
Progress p("Iterating...", n);
for (int i = 0; i < n; i++)
{
...
p++;
}
or in an iteration with an unknown number of steps:
Progress p("Iterating...");
while (t < T)
{
...
p = t / T;
}
dolfin::Progress::Progress(std::string title)

Create progress bar with an unknown number of steps

Parameters:title – (std::string) The title.
dolfin::Progress::Progress(std::string title, unsigned int n)

Create progress bar with a known number of steps

Parameters:
  • title – (std::string) The title.
  • n – (unsigned int) Number of steps.
bool dolfin::Progress::always
std::size_t dolfin::Progress::c_step
std::size_t dolfin::Progress::counter
bool dolfin::Progress::displayed
bool dolfin::Progress::finished
std::size_t dolfin::Progress::i
void dolfin::Progress::operator++(int)

Increment progress.

void dolfin::Progress::operator=(double p)

Set current position

Parameters:p – (double) The position.
double dolfin::Progress::t_step
double dolfin::Progress::tc
void dolfin::Progress::update(double p)
Parameters:p
dolfin::Progress::~Progress()

Destructor.

Table

C++ documentation for Table from dolfin/log/Table.h:

class dolfin::Table

This class provides storage and pretty-printing for tables. Example usage: Table table(“Timings”); table(“Eigen”, “Assemble”) = 0.010; table(“Eigen”, “Solve”) = 0.020; table(“PETSc”, “Assemble”) = 0.011; table(“PETSc”, “Solve”) = 0.019; table(“Tpetra”, “Assemble”) = 0.012; table(“Tpetra”, “Solve”) = 0.018; info(table);

Friends: MPI, XMLTable.

dolfin::Table::Table(std::string title = "", bool right_justify = true)

Create empty table.

Parameters:
  • title
  • right_justify
std::set<std::string> dolfin::Table::col_set
std::vector<std::string> dolfin::Table::cols
std::map<std::pair<std::string, std::string>, double> dolfin::Table::dvalues
std::string dolfin::Table::get(std::string row, std::string col) const

Get value of table entry.

Parameters:
  • row
  • col
double dolfin::Table::get_value(std::string row, std::string col) const

Get value of table entry.

Parameters:
  • row
  • col
TableEntry dolfin::Table::operator()(std::string row, std::string col)

Return table entry.

Parameters:
  • row
  • col
const Table &dolfin::Table::operator=(const Table &table)

Assignment operator.

Parameters:table
std::set<std::string> dolfin::Table::row_set
std::vector<std::string> dolfin::Table::rows
void dolfin::Table::set(std::string row, std::string col, double value)

Set value of table entry.

Parameters:
  • row
  • col
  • value
void dolfin::Table::set(std::string row, std::string col, int value)

Set value of table entry.

Parameters:
  • row
  • col
  • value
void dolfin::Table::set(std::string row, std::string col, std::size_t value)

Set value of table entry.

Parameters:
  • row
  • col
  • value
void dolfin::Table::set(std::string row, std::string col, std::string value)

Set value of table entry.

Parameters:
  • row
  • col
  • value
std::string dolfin::Table::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
std::string dolfin::Table::str_latex() const

Return informal string representation for LaTeX.

std::map<std::pair<std::string, std::string>, std::string> dolfin::Table::values
dolfin::Table::~Table()

Destructor.

TableEntry

C++ documentation for TableEntry from dolfin/log/Table.h:

class dolfin::TableEntry

This class represents an entry in a Table .

dolfin::TableEntry::TableEntry(std::string row, std::string col, Table &table)

Create table entry.

Parameters:
  • row
  • col
  • table
dolfin::TableEntry::operator std::string() const

Cast to entry value.

const TableEntry &dolfin::TableEntry::operator=(double value)

Assign value to table entry.

Parameters:value
const TableEntry &dolfin::TableEntry::operator=(int value)

Assign value to table entry.

Parameters:value
const TableEntry &dolfin::TableEntry::operator=(std::size_t value)

Assign value to table entry.

Parameters:value
const TableEntry &dolfin::TableEntry::operator=(std::string value)

Assign value to table entry.

Parameters:value
dolfin::TableEntry::~TableEntry()

Destructor.

dolfin/math

Documentation for C++ code found in dolfin/math/*.h

Functions

between

C++ documentation for between from dolfin/math/basic.h:

bool dolfin::between(double x, std::pair<double, double> range)

Check whether x is between x0 and x1 (inclusive, to within DOLFIN_EPS)

Parameters:
  • x – (double) Value to check
  • range – (std::pair<double, double>) Range to check
Returns:

bool

ipow

C++ documentation for ipow from dolfin/math/basic.h:

std::size_t dolfin::ipow(std::size_t a, std::size_t n)

Return a to the power n. NOTE: Overflow is not checked!

Parameters:
  • a – (std::size_t) Value
  • n – (std::size_t) Power
Returns:

std::size_t

near

C++ documentation for near from dolfin/math/basic.h:

bool dolfin::near(double x, double x0, double eps = DOLFIN_EPS)

Check whether x is close to x0 (to within DOLFIN_EPS)

Parameters:
  • x – (double) First value
  • x0 – (double) Second value
  • eps – (double) Tolerance
Returns:

bool

rand

C++ documentation for rand from dolfin/math/basic.h:

double dolfin::rand()

Return a random number, uniformly distributed between [0.0, 1.0)

Returns:double
seed

C++ documentation for seed from dolfin/math/basic.h:

void dolfin::seed(std::size_t s)

Seed random number generator

Parameters:s – (std::size_t) Seed value

Variables

rand_seeded

C++ documentation for rand_seeded from dolfin/math/basic.cpp:

bool dolfin::rand_seeded

Flag to determine whether to reseed dolfin::rand() . Normally on first call.

Classes

Lagrange

C++ documentation for Lagrange from dolfin/math/Lagrange.h:

class dolfin::Lagrange

Lagrange polynomial (basis) with given degree q determined by n = q + 1 nodal points. Example: q = 1 (n = 2) Lagrange p(1); p.set(0, 0.0); p.set(1, 1.0); It is the callers responsibility that the points are distinct. This creates a Lagrange polynomial (actually two Lagrange polynomials): p(0,x) = 1 - x (one at x = 0, zero at x = 1) p(1,x) = x (zero at x = 0, one at x = 1)

dolfin::Lagrange::Lagrange(const Lagrange &p)

Copy constructor.

Parameters:p
dolfin::Lagrange::Lagrange(std::size_t q)

Constructor.

Parameters:q
std::vector<double> dolfin::Lagrange::constants
std::size_t dolfin::Lagrange::counter
double dolfin::Lagrange::ddx(std::size_t i, double x)

Return derivate of polynomial i at given point x

Parameters:
  • i – (std::size_t)
  • x – (double)
std::size_t dolfin::Lagrange::degree() const

Return degree

Returns:std::size_t
double dolfin::Lagrange::dqdx(std::size_t i)

Return derivative q (a constant) of polynomial

Parameters:i – (std::size_t)
double dolfin::Lagrange::eval(std::size_t i, double x)

Return value of polynomial i at given point x

Parameters:
  • i – (std::size_t)
  • x – (double)
void dolfin::Lagrange::init()
Event dolfin::Lagrange::instability_detected
double dolfin::Lagrange::operator()(std::size_t i, double x)

Return value of polynomial i at given point x

Parameters:
  • i – (std::size_t)
  • x – (double)
double dolfin::Lagrange::point(std::size_t i) const

Return point

Parameters:i – (std::size_t)
std::vector<double> dolfin::Lagrange::points
void dolfin::Lagrange::set(std::size_t i, double x)

Specify point

Parameters:
  • i – (std::size_t)
  • x – (double)
std::size_t dolfin::Lagrange::size() const

Return number of points

Returns:std::size_t
std::string dolfin::Lagrange::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose – (bool) Verbosity of output string
Legendre

C++ documentation for Legendre from dolfin/math/Legendre.h:

class dolfin::Legendre

Interface for computing Legendre polynomials via Boost.

double dolfin::Legendre::d2dx(std::size_t n, double x)

Evaluate second derivative of polynomial of order n at point x

Parameters:
  • n – (std::size_t) Order
  • x – (double) Point
Returns:

double Legendre polynomial 2nd derivative value at x

double dolfin::Legendre::ddx(std::size_t n, double x)

Evaluate first derivative of polynomial of order n at point x

Parameters:
  • n – (std::size_t) Order
  • x – (double) Point
Returns:

double Legendre polynomial derivative value at x

double dolfin::Legendre::eval(std::size_t n, double x)

Evaluate polynomial of order n at point x

Parameters:
  • n – (std::size_t) Order
  • x – (double) Point
Returns:

double Legendre polynomial value at x

dolfin/mesh

Documentation for C++ code found in dolfin/mesh/*.h

Type definitions

CellIterator

C++ documentation for CellIterator from dolfin/mesh/Cell.h:

type dolfin::CellIterator

A CellIterator is a MeshEntityIterator of topological codimension 0.

EdgeIterator

C++ documentation for EdgeIterator from dolfin/mesh/Edge.h:

type dolfin::EdgeIterator

An EdgeIterator is a MeshEntityIterator of topological dimension 1.

FaceIterator

C++ documentation for FaceIterator from dolfin/mesh/Face.h:

type dolfin::FaceIterator

A FaceIterator is a MeshEntityIterator of topological dimension 2.

FacetIterator

C++ documentation for FacetIterator from dolfin/mesh/Facet.h:

type dolfin::FacetIterator

A FacetIterator is a MeshEntityIterator of topological codimension 1.

VertexIterator

C++ documentation for VertexIterator from dolfin/mesh/Vertex.h:

type dolfin::VertexIterator

A VertexIterator is a MeshEntityIterator of topological dimension 0.

quadrature_rule

C++ documentation for quadrature_rule from dolfin/mesh/MultiMesh.h:

type dolfin::quadrature_rule

Typedefs.

Classes

BoundaryComputation

C++ documentation for BoundaryComputation from dolfin/mesh/BoundaryComputation.h:

class dolfin::BoundaryComputation

Provide a set of basic algorithms for the computation of boundaries.

void dolfin::BoundaryComputation::compute_boundary(const Mesh &mesh, const std::string type, BoundaryMesh &boundary)

Compute the exterior boundary of a given mesh

Parameters:
  • mesh – input mesh [direction=in]
  • type – “internal” or “external” [direction=in]
  • boundary – output boundary mesh [direction=out]
void dolfin::BoundaryComputation::reorder(std::vector<std::size_t> &vertices, const Facet &facet)
Parameters:
  • vertices
  • facet
BoundaryMesh

C++ documentation for BoundaryMesh from dolfin/mesh/BoundaryMesh.h:

class dolfin::BoundaryMesh : public dolfin::Mesh

A BoundaryMesh is a mesh over the boundary of some given mesh. The cells of the boundary mesh (facets of the original mesh) are oriented to produce outward pointing normals relative to the original mesh.

dolfin::BoundaryMesh::BoundaryMesh()
dolfin::BoundaryMesh::BoundaryMesh(const Mesh &mesh, std::string type, bool order = true)

Create boundary mesh from given mesh.

Parameters:
  • mesh – (Mesh ) Another Mesh object.
  • type – (std::string) The type of BoundaryMesh() , which can be “exterior”, “interior” or “local”. “exterior” is the globally external boundary, “interior” is the inter-process mesh and “local” is the boundary of the local (this process) mesh.
  • order – (bool) Optional argument which can be used to control whether or not the boundary mesh should be ordered according to the UFC ordering convention. If set to false, the boundary mesh will be ordered with right-oriented facets (outward-pointing unit normals). The default value is true.
MeshFunction<std::size_t> &dolfin::BoundaryMesh::entity_map(std::size_t d)

Get index map for entities of dimension d in the boundary mesh to the entity in the original full mesh

Parameters:d
const MeshFunction<std::size_t> &dolfin::BoundaryMesh::entity_map(std::size_t d) const

Get index map for entities of dimension d in the boundary mesh to the entity in the original full mesh (const version)

Parameters:d
dolfin::BoundaryMesh::~BoundaryMesh()

Destructor.

Cell

C++ documentation for Cell from dolfin/mesh/Cell.h:

class dolfin::Cell

A Cell is a MeshEntity of topological codimension 0.

dolfin::Cell::Cell()

Create empty cell.

dolfin::Cell::Cell(const Mesh &mesh, std::size_t index)

Create cell on given mesh with given index

Parameters:
  • mesh – The mesh.
  • index – The index.
Point dolfin::Cell::cell_normal() const

Compute normal to cell itself (viewed as embedded in 3D)

Returns:Point Normal of the cell
double dolfin::Cell::circumradius() const

Compute circumradius of cell

UnitSquareMesh mesh(1, 1);
Cell cell(mesh, 0);
info("%g", cell.circumradius());
Returns:double The circumradius of the cell.
bool dolfin::Cell::collides(const MeshEntity &entity) const

Check whether given entity collides with cell

Parameters:entity – The cell to be checked.
Returns:bool True iff entity collides with cell.
bool dolfin::Cell::collides(const Point &point) const

Check whether given point collides with cell

Parameters:point – The point to be checked.
Returns:bool True iff point collides with cell.
bool dolfin::Cell::contains(const Point &point) const

Check whether given point is contained in cell. This function is identical to the function collides(point).

Parameters:point – The point to be checked.
Returns:bool True iff point is contained in cell.
double dolfin::Cell::distance(const Point &point) const

Compute distance to given point.

Parameters:point – The point.
Returns:double The distance to the point.
double dolfin::Cell::facet_area(std::size_t facet) const

Compute the area/length of given facet with respect to the cell

Parameters:facet – Index of the facet.
Returns:double Area/length of the facet.
void dolfin::Cell::get_cell_data(ufc::cell &ufc_cell, int local_facet = -1) const

Fill UFC cell with miscellaneous data.

Parameters:
  • ufc_cell
  • local_facet
void dolfin::Cell::get_cell_topology(ufc::cell &ufc_cell) const

Fill UFC cell with topology data.

Parameters:ufc_cell
void dolfin::Cell::get_coordinate_dofs(std::vector<double> &coordinates) const

Get cell coordinate dofs (not vertex coordinates)

Parameters:coordinates
void dolfin::Cell::get_vertex_coordinates(std::vector<double> &coordinates) const

Get cell vertex coordinates (not coordinate dofs)

Parameters:coordinates
double dolfin::Cell::h() const

Compute greatest distance between any two vertices

UnitSquareMesh mesh(1, 1);
Cell cell(mesh, 0);
info("%g", cell.h());
Returns:double The greatest distance between any two vertices of the cell.
double dolfin::Cell::inradius() const

Compute inradius of cell

UnitSquareMesh mesh(1, 1);
Cell cell(mesh, 0);
info("%g", cell.inradius());
Returns:double Radius of the sphere inscribed in the cell.
Point dolfin::Cell::normal(std::size_t facet) const

Compute normal of given facet with respect to the cell

Parameters:facet – Index of facet.
Returns:Point Normal of the facet.
double dolfin::Cell::normal(std::size_t facet, std::size_t i) const

Compute component i of normal of given facet with respect to the cell

Parameters:
  • facet – Index of facet.
  • i – Component.
Returns:

double Component i of the normal of the facet.

std::size_t dolfin::Cell::num_vertices() const

Return number of vertices of cell.

void dolfin::Cell::order(const std::vector<std::int64_t> &local_to_global_vertex_indices)

Order entities locally

Parameters:local_to_global_vertex_indices – The global vertex indices.
bool dolfin::Cell::ordered(const std::vector<std::int64_t> &local_to_global_vertex_indices) const

Check if entities are ordered

Parameters:local_to_global_vertex_indices – The global vertex indices.
Returns:bool True iff ordered.
std::size_t dolfin::Cell::orientation() const

Compute orientation of cell

Returns:std::size_t Orientation of the cell (0 is ‘up’/’right’, 1 is ‘down’/’left’)
std::size_t dolfin::Cell::orientation(const Point &up) const

Compute orientation of cell relative to given ‘up’ direction

Parameters:up – The direction defined as ‘up’
Returns:std::size_t Orientation of the cell (0 is ‘same’, 1 is ‘opposite’)
double dolfin::Cell::radius_ratio() const

Compute ratio of inradius to circumradius times dim for cell. Useful as cell quality measure. Returns 1. for equilateral and 0. for degenerate cell. See Jonathan Richard Shewchuk: What Is a Good Linear Finite Element?, online: http://www.cs.berkeley.edu/~jrs/papers/elemj.pdf

UnitSquareMesh mesh(1, 1);
Cell cell(mesh, 0);
info("%g", cell.radius_ratio());
Returns:double topological_dimension * inradius / circumradius
double dolfin::Cell::squared_distance(const Point &point) const

Compute squared distance to given point.

Parameters:point – The point.
Returns:double The squared distance to the point.
std::vector<double> dolfin::Cell::triangulate_intersection(const MeshEntity &entity) const

Compute triangulation of intersection with given entity

Parameters:entity – The entity with which to intersect.
Returns:std::vector<double> A flattened array of simplices of dimension num_simplices x num_vertices x gdim = num_simplices x (tdim + 1) x gdim
CellType::Type dolfin::Cell::type() const

Return type of cell.

double dolfin::Cell::volume() const

Compute (generalized) volume of cell

UnitSquare mesh(1, 1);
Cell cell(mesh, 0);
info("%g", cell.volume());
Returns:double The volume of the cell.
dolfin::Cell::~Cell()

Destructor.

CellFunction

C++ documentation for CellFunction from dolfin/mesh/Cell.h:

class dolfin::CellFunction : public dolfin::CellFunction<T>, dolfin::MeshFunction<T>

A CellFunction is a MeshFunction of topological codimension 0.

dolfin::CellFunction::CellFunction(std::shared_ptr<const Mesh> mesh)

Constructor on Mesh .

Parameters:mesh
dolfin::CellFunction::CellFunction(std::shared_ptr<const Mesh> mesh, const T &value)

Constructor on Mesh and value.

Parameters:
  • mesh
  • value
CellType

C++ documentation for CellType from dolfin/mesh/CellType.h:

class dolfin::CellType

This class provides a common interface for different cell types. Each cell type implements mesh functionality that is specific to a certain type of cell.

dolfin::CellType::CellType(Type cell_type, Type facet_type)

Constructor.

Parameters:
  • cell_type
  • facet_type
enum dolfin::CellType::Type

Enum for different cell types.

enumerator dolfin::CellType::Type::point
enumerator dolfin::CellType::Type::interval
enumerator dolfin::CellType::Type::triangle
enumerator dolfin::CellType::Type::quadrilateral
enumerator dolfin::CellType::Type::tetrahedron
enumerator dolfin::CellType::Type::hexahedron
Point dolfin::CellType::cell_normal(const Cell &cell) const = 0

Compute normal to given cell (viewed as embedded in 3D)

Parameters:cell
Type dolfin::CellType::cell_type() const

Return type of cell.

double dolfin::CellType::circumradius(const MeshEntity &entity) const = 0

Compute circumradius of mesh entity.

Parameters:entity
bool dolfin::CellType::collides(const Cell &cell, const MeshEntity &entity) const = 0

Check whether given entity collides with cell.

Parameters:
  • cell
  • entity
bool dolfin::CellType::collides(const Cell &cell, const Point &point) const = 0

Check whether given point collides with cell.

Parameters:
  • cell
  • point
CellType *dolfin::CellType::create(Type type)

Create cell type from type (factory function)

Parameters:type
CellType *dolfin::CellType::create(std::string type)

Create cell type from string (factory function)

Parameters:type
void dolfin::CellType::create_entities(boost::multi_array<unsigned int, 2> &e, std::size_t dim, const unsigned int *v) const = 0

Create entities e of given topological dimension from vertices v

Parameters:
  • e
  • dim
  • v
std::string dolfin::CellType::description(bool plural) const = 0

Return description of cell type.

Parameters:plural
std::size_t dolfin::CellType::dim() const = 0

Return topological dimension of cell.

Type dolfin::CellType::entity_type(std::size_t i) const

Return type of cell for entity of dimension i.

Parameters:i
double dolfin::CellType::facet_area(const Cell &cell, std::size_t facet) const = 0

Compute the area/length of given facet with respect to the cell.

Parameters:
  • cell
  • facet
Type dolfin::CellType::facet_type() const

Return type of cell for facets.

double dolfin::CellType::h(const MeshEntity &entity) const

Compute greatest distance between any two vertices.

Parameters:entity
bool dolfin::CellType::increasing(std::size_t n0, const unsigned int *v0, std::size_t n1, const unsigned int *v1, std::size_t num_vertices, const unsigned int *vertices, const std::vector<std::int64_t> &local_to_global_vertex_indices)
Parameters:
  • n0
  • v0
  • n1
  • v1
  • num_vertices
  • vertices
  • local_to_global_vertex_indices
bool dolfin::CellType::increasing(std::size_t num_vertices, const unsigned int *vertices, const std::vector<std::int64_t> &local_to_global_vertex_indices)
Parameters:
  • num_vertices
  • vertices
  • local_to_global_vertex_indices
double dolfin::CellType::inradius(const Cell &cell) const

Compute inradius of cell.

Parameters:cell
Point dolfin::CellType::normal(const Cell &cell, std::size_t facet) const = 0

Compute of given facet with respect to the cell.

Parameters:
  • cell
  • facet
double dolfin::CellType::normal(const Cell &cell, std::size_t facet, std::size_t i) const = 0

Compute component i of normal of given facet with respect to the cell.

Parameters:
  • cell
  • facet
  • i
std::size_t dolfin::CellType::num_entities(std::size_t dim) const = 0

Return number of entities of given topological dimension.

Parameters:dim
std::size_t dolfin::CellType::num_vertices() const

Return number of vertices for cell.

std::size_t dolfin::CellType::num_vertices(std::size_t dim) const = 0

Return number of vertices for entity of given topological dimension.

Parameters:dim
void dolfin::CellType::order(Cell &cell, const std::vector<std::int64_t> &local_to_global_vertex_indices) const = 0

Order entities locally.

Parameters:
  • cell
  • local_to_global_vertex_indices
bool dolfin::CellType::ordered(const Cell &cell, const std::vector<std::int64_t> &local_to_global_vertex_indices) const

Check if entities are ordered.

Parameters:
  • cell
  • local_to_global_vertex_indices
std::size_t dolfin::CellType::orientation(const Cell &cell) const = 0

Return orientation of the cell (assuming flat space)

Parameters:cell
std::size_t dolfin::CellType::orientation(const Cell &cell, const Point &up) const

Return orientation of the cell relative to given up direction.

Parameters:
  • cell
  • up
double dolfin::CellType::radius_ratio(const Cell &cell) const

Compute dim*inradius/circumradius for given cell.

Parameters:cell
void dolfin::CellType::sort_entities(std::size_t num_vertices, unsigned int *vertices, const std::vector<std::int64_t> &local_to_global_vertex_indices)

Sort vertices based on global entity indices.

Parameters:
  • num_vertices
  • vertices
  • local_to_global_vertex_indices
double dolfin::CellType::squared_distance(const Cell &cell, const Point &point) const = 0

Compute squared distance to given point.

Parameters:
  • cell
  • point
Type dolfin::CellType::string2type(std::string type)

Convert from string to cell type.

Parameters:type
std::vector<double> dolfin::CellType::triangulate_intersection(const Cell &c0, const Cell &c1) const = 0

Compute triangulation of intersection of two cells.

Parameters:
  • c0
  • c1
std::string dolfin::CellType::type2string(Type type)

Convert from cell type to string.

Parameters:type
double dolfin::CellType::volume(const MeshEntity &entity) const = 0

Compute (generalized) volume of mesh entity.

Parameters:entity
std::vector<std::int8_t> dolfin::CellType::vtk_mapping() const = 0

Mapping of DOLFIN/UFC vertex ordering to VTK/XDMF ordering.

dolfin::CellType::~CellType()

Destructor.

DistributedMeshTools

C++ documentation for DistributedMeshTools from dolfin/mesh/DistributedMeshTools.h:

class dolfin::DistributedMeshTools

This class provides various functionality for working with distributed meshes.

type dolfin::DistributedMeshTools::Entity
void dolfin::DistributedMeshTools::compute_entity_ownership(const MPI_Comm mpi_comm, const std::map<std::vector<std::size_t>, unsigned int> &entities, const std::map<std::int32_t, std::set<unsigned int>> &shared_vertices_local, const std::vector<std::int64_t> &global_vertex_indices, std::size_t d, std::vector<std::size_t> &owned_entities, std::array<std::map<Entity, EntityData>, 2> &shared_entities)
Parameters:
  • mpi_comm
  • entities
  • shared_vertices_local
  • global_vertex_indices
  • d
  • owned_entities
  • shared_entities
void dolfin::DistributedMeshTools::compute_final_entity_ownership(const MPI_Comm mpi_comm, std::vector<std::size_t> &owned_entities, std::array<std::map<Entity, EntityData>, 2> &entity_ownership)
Parameters:
  • mpi_comm
  • owned_entities
  • entity_ownership
std::pair<std::size_t, std::size_t> dolfin::DistributedMeshTools::compute_num_global_entities(const MPI_Comm mpi_comm, std::size_t num_local_entities, std::size_t num_processes, std::size_t process_number)
Parameters:
  • mpi_comm
  • num_local_entities
  • num_processes
  • process_number
void dolfin::DistributedMeshTools::compute_preliminary_entity_ownership(const MPI_Comm mpi_comm, const std::map<std::size_t, std::set<unsigned int>> &shared_vertices, const std::map<Entity, unsigned int> &entities, std::vector<std::size_t> &owned_entities, std::array<std::map<Entity, EntityData>, 2> &entity_ownership)
Parameters:
  • mpi_comm
  • shared_vertices
  • entities
  • owned_entities
  • entity_ownership
std::unordered_map<unsigned int, std::vector<std::pair<unsigned int, unsigned int>>> dolfin::DistributedMeshTools::compute_shared_entities(const Mesh &mesh, std::size_t d)

Compute map from local index of shared entity to list of sharing process and local index, i.e. (local index, [(sharing process p, local index on p)])

Parameters:
  • mesh
  • d
void dolfin::DistributedMeshTools::init_facet_cell_connections(Mesh &mesh)

Compute number of cells connected to each facet (globally). Facets on internal boundaries will be connected to two cells (with the cells residing on neighboring processes)

Parameters:mesh
bool dolfin::DistributedMeshTools::is_shared(const std::vector<std::size_t> &entity_vertices, const std::map<std::size_t, std::set<unsigned int>> &shared_vertices)
Parameters:
  • entity_vertices
  • shared_vertices
std::map<std::size_t, std::set<std::pair<std::size_t, std::size_t>>> dolfin::DistributedMeshTools::locate_off_process_entities(const std::vector<std::size_t> &entity_indices, std::size_t dim, const Mesh &mesh)

Find processes that own or share mesh entities (using entity global indices). Returns (global_dof, set(process_num, local_index)). Exclusively local entities will not appear in the map. Works only for vertices and cells

Parameters:
  • entity_indices
  • dim
  • mesh
std::size_t dolfin::DistributedMeshTools::number_entities(const Mesh &mesh, const std::map<unsigned int, std::pair<unsigned int, unsigned int>> &slave_entities, std::vector<std::int64_t> &global_entity_indices, std::map<std::int32_t, std::set<unsigned int>> &shared_entities, std::size_t d)

Create global entity indices for entities of dimension d for given global vertex indices.

Parameters:
  • mesh
  • slave_entities
  • global_entity_indices
  • shared_entities
  • d
void dolfin::DistributedMeshTools::number_entities(const Mesh &mesh, std::size_t d)

Create global entity indices for entities of dimension d.

Parameters:
  • mesh
  • d
void dolfin::DistributedMeshTools::reorder_values_by_global_indices(MPI_Comm mpi_comm, std::vector<double> &values, const std::size_t width, const std::vector<std::int64_t> &global_indices)

Reorder the values of given width, according to explicit global indices, distributing evenly across processes

Parameters:
  • mpi_comm
  • values
  • width
  • global_indices
void dolfin::DistributedMeshTools::reorder_values_by_global_indices(const Mesh &mesh, std::vector<double> &data, const std::size_t width)

Reorder the values (of given width) in data to be in global vertex index order on the Mesh , redistributing evenly across processes

Parameters:
  • mesh
  • data
  • width
std::vector<double> dolfin::DistributedMeshTools::reorder_vertices_by_global_indices(const Mesh &mesh)

Reorders the vertices in a distributed mesh according to their global index, and redistributes them evenly across processes returning the coordinates as a local vector

Parameters:mesh
DomainBoundary

C++ documentation for DomainBoundary from dolfin/mesh/DomainBoundary.h:

class dolfin::DomainBoundary

This class provides a SubDomain which picks out the boundary of a mesh, and provides a convenient way to specify boundary conditions on the entire boundary of a mesh.

dolfin::DomainBoundary::DomainBoundary()

Constructor.

bool dolfin::DomainBoundary::inside(const Array<double> &x, bool on_boundary) const

Return true for points on the boundary.

Parameters:
  • x
  • on_boundary
dolfin::DomainBoundary::~DomainBoundary()

Destructor.

DynamicMeshEditor

C++ documentation for DynamicMeshEditor from dolfin/mesh/DynamicMeshEditor.h:

class dolfin::DynamicMeshEditor

This class provides an interface for dynamic editing of meshes, that is, when the number of vertices and cells are not known a priori. If the number of vertices and cells are known a priori, it is more efficient to use the default editor MeshEditor .

dolfin::DynamicMeshEditor::DynamicMeshEditor()

Constructor.

void dolfin::DynamicMeshEditor::add_cell(std::size_t c, const std::vector<std::size_t> &v)

Add cell with given vertices.

Parameters:
  • c
  • v
void dolfin::DynamicMeshEditor::add_cell(std::size_t c, std::size_t v0, std::size_t v1)

Add cell (interval) with given vertices.

Parameters:
  • c
  • v0
  • v1
void dolfin::DynamicMeshEditor::add_cell(std::size_t c, std::size_t v0, std::size_t v1, std::size_t v2)

Add cell (triangle) with given vertices.

Parameters:
  • c
  • v0
  • v1
  • v2
void dolfin::DynamicMeshEditor::add_cell(std::size_t c, std::size_t v0, std::size_t v1, std::size_t v2, std::size_t v3)

Add cell (tetrahedron) with given vertices.

Parameters:
  • c
  • v0
  • v1
  • v2
  • v3
void dolfin::DynamicMeshEditor::add_vertex(std::size_t v, const Point &p)

Add vertex v at given point p.

Parameters:
  • v
  • p
void dolfin::DynamicMeshEditor::add_vertex(std::size_t v, double x)

Add vertex v at given coordinate x.

Parameters:
  • v
  • x
void dolfin::DynamicMeshEditor::add_vertex(std::size_t v, double x, double y)

Add vertex v at given coordinate (x, y)

Parameters:
  • v
  • x
  • y
void dolfin::DynamicMeshEditor::add_vertex(std::size_t v, double x, double y, double z)

Add vertex v at given coordinate (x, y, z)

Parameters:
  • v
  • x
  • y
  • z
std::vector<std::size_t> dolfin::DynamicMeshEditor::cell_vertices
void dolfin::DynamicMeshEditor::clear()
void dolfin::DynamicMeshEditor::close(bool order = false)

Close mesh, finish editing, and order entities locally.

Parameters:order
void dolfin::DynamicMeshEditor::open(Mesh &mesh, CellType::Type type, std::size_t tdim, std::size_t gdim, std::size_t num_global_vertices, std::size_t num_global_cells)

Open mesh of given cell type, topological and geometrical dimension.

Parameters:
  • mesh
  • type
  • tdim
  • gdim
  • num_global_vertices
  • num_global_cells
void dolfin::DynamicMeshEditor::open(Mesh &mesh, std::string type, std::size_t tdim, std::size_t gdim, std::size_t num_global_vertices, std::size_t num_global_cells)

Open mesh of given cell type, topological and geometrical dimension.

Parameters:
  • mesh
  • type
  • tdim
  • gdim
  • num_global_vertices
  • num_global_cells
std::vector<double> dolfin::DynamicMeshEditor::vertex_coordinates
dolfin::DynamicMeshEditor::~DynamicMeshEditor()

Destructor.

Edge

C++ documentation for Edge from dolfin/mesh/Edge.h:

class dolfin::Edge

An Edge is a MeshEntity of topological dimension 1.

dolfin::Edge::Edge(MeshEntity &entity)

Create edge from mesh entity

Parameters:entity – (MeshEntity ) The mesh entity to create an edge from.
dolfin::Edge::Edge(const Mesh &mesh, std::size_t index)

Create edge on given mesh

Parameters:
  • mesh – (Mesh ) The mesh.
  • index – (std::size_t) Index of the edge.
double dolfin::Edge::dot(const Edge &edge) const

Compute dot product between edge and other edge

UnitSquare mesh(2, 2);
Edge edge1(mesh, 0);
Edge edge2(mesh, 1);
info("%g", edge1.dot(edge2));
Parameters:edge – (Edge ) Another edge.
Returns:double The dot product.
double dolfin::Edge::length() const

Compute Euclidean length of edge

UnitSquare mesh(2, 2);
Edge edge(mesh, 0);
info("%g", edge.length());
Returns:double Euclidean length of edge.
dolfin::Edge::~Edge()

Destructor.

EdgeFunction

C++ documentation for EdgeFunction from dolfin/mesh/Edge.h:

class dolfin::EdgeFunction : public dolfin::EdgeFunction<T>, dolfin::MeshFunction<T>

An EdgeFunction is a MeshFunction of topological dimension 1.

dolfin::EdgeFunction::EdgeFunction(std::shared_ptr<const Mesh> mesh)

Constructor on Mesh .

Parameters:mesh
dolfin::EdgeFunction::EdgeFunction(std::shared_ptr<const Mesh> mesh, const T &value)

Constructor on Mesh and value.

Parameters:
  • mesh
  • value
Face

C++ documentation for Face from dolfin/mesh/Face.h:

class dolfin::Face

A Face is a MeshEntity of topological dimension 2.

dolfin::Face::Face(const Mesh &mesh, std::size_t index)

Constructor.

Parameters:
  • mesh
  • index
double dolfin::Face::area() const

Calculate the area of the face (triangle)

Point dolfin::Face::normal() const

Compute normal to the face.

double dolfin::Face::normal(std::size_t i) const

Compute component i of the normal to the face.

Parameters:i
dolfin::Face::~Face()

Destructor.

FaceFunction

C++ documentation for FaceFunction from dolfin/mesh/Face.h:

class dolfin::FaceFunction : public dolfin::FaceFunction<T>, dolfin::MeshFunction<T>

A FaceFunction is a MeshFunction of topological dimension 2.

dolfin::FaceFunction::FaceFunction(std::shared_ptr<const Mesh> mesh)

Constructor on Mesh .

Parameters:mesh
dolfin::FaceFunction::FaceFunction(std::shared_ptr<const Mesh> mesh, const T &value)

Constructor on Mesh and value.

Parameters:
  • mesh
  • value
Facet

C++ documentation for Facet from dolfin/mesh/Facet.h:

class dolfin::Facet

A Facet is a MeshEntity of topological codimension 1.

dolfin::Facet::Facet(const Mesh &mesh, std::size_t index)

Constructor.

Parameters:
  • mesh
  • index
double dolfin::Facet::distance(const Point &point) const

Compute distance to given point.

Parameters:point – (Point ) The point.
Returns:double The distance to the point.
bool dolfin::Facet::exterior() const

Return true if facet is an exterior facet (relative to global mesh, so this function will return false for facets on partition boundaries). Facet connectivity must be initialized before calling this function.

Point dolfin::Facet::normal() const

Compute normal to the facet.

double dolfin::Facet::normal(std::size_t i) const

Compute component i of the normal to the facet.

Parameters:i
double dolfin::Facet::squared_distance(const Point &point) const

Compute squared distance to given point.

Parameters:point – (Point ) The point.
Returns:double The squared distance to the point.
dolfin::Facet::~Facet()

Destructor.

FacetCell

C++ documentation for FacetCell from dolfin/mesh/FacetCell.h:

class dolfin::FacetCell : public dolfin::Cell

This class represents a cell in a mesh incident to a facet on the boundary. It is useful in cases where one needs to iterate over a boundary mesh and access the corresponding cells in the original mesh.

dolfin::FacetCell::FacetCell(const BoundaryMesh &mesh, const Cell &facet)

Create cell on mesh corresponding to given facet (cell) on boundary.

Parameters:
  • mesh
  • facet
std::size_t dolfin::FacetCell::facet_index() const

Return local index of facet with respect to the cell.

dolfin::FacetCell::~FacetCell()

Destructor.

FacetFunction

C++ documentation for FacetFunction from dolfin/mesh/Facet.h:

class dolfin::FacetFunction : public dolfin::FacetFunction<T>, dolfin::MeshFunction<T>

A FacetFunction is a MeshFunction of topological codimension 1.

dolfin::FacetFunction::FacetFunction(std::shared_ptr<const Mesh> mesh)

Constructor on Mesh .

Parameters:mesh
dolfin::FacetFunction::FacetFunction(std::shared_ptr<const Mesh> mesh, const T &value)

Constructor on Mesh and value.

Parameters:
  • mesh
  • value
HexahedronCell

C++ documentation for HexahedronCell from dolfin/mesh/HexahedronCell.h:

class dolfin::HexahedronCell

This class implements functionality for triangular meshes.

dolfin::HexahedronCell::HexahedronCell()

Specify cell type and facet type.

Point dolfin::HexahedronCell::cell_normal(const Cell &cell) const

Compute normal to given cell (viewed as embedded in 3D)

Parameters:cell
double dolfin::HexahedronCell::circumradius(const MeshEntity &triangle) const

Compute diameter of triangle.

Parameters:triangle
bool dolfin::HexahedronCell::collides(const Cell &cell, const MeshEntity &entity) const

Check whether given entity collides with cell.

Parameters:
  • cell
  • entity
bool dolfin::HexahedronCell::collides(const Cell &cell, const Point &point) const

Check whether given point collides with cell.

Parameters:
  • cell
  • point
void dolfin::HexahedronCell::create_entities(boost::multi_array<unsigned int, 2> &e, std::size_t dim, const unsigned int *v) const

Create entities e of given topological dimension from vertices v.

Parameters:
  • e
  • dim
  • v
std::string dolfin::HexahedronCell::description(bool plural) const

Return description of cell type.

Parameters:plural
std::size_t dolfin::HexahedronCell::dim() const

Return topological dimension of cell.

double dolfin::HexahedronCell::facet_area(const Cell &cell, std::size_t facet) const

Compute the area/length of given facet with respect to the cell.

Parameters:
  • cell
  • facet
Point dolfin::HexahedronCell::normal(const Cell &cell, std::size_t facet) const

Compute of given facet with respect to the cell.

Parameters:
  • cell
  • facet
double dolfin::HexahedronCell::normal(const Cell &cell, std::size_t facet, std::size_t i) const

Compute component i of normal of given facet with respect to the cell.

Parameters:
  • cell
  • facet
  • i
std::size_t dolfin::HexahedronCell::num_entities(std::size_t dim) const

Return number of entities of given topological dimension.

Parameters:dim
std::size_t dolfin::HexahedronCell::num_vertices(std::size_t dim) const

Return number of vertices for entity of given topological dimension.

Parameters:dim
void dolfin::HexahedronCell::order(Cell &cell, const std::vector<std::int64_t> &local_to_global_vertex_indices) const

Order entities locally.

Parameters:
  • cell
  • local_to_global_vertex_indices
std::size_t dolfin::HexahedronCell::orientation(const Cell &cell) const

Return orientation of the cell.

Parameters:cell
double dolfin::HexahedronCell::squared_distance(const Cell &cell, const Point &point) const

Compute squared distance to given point (3D enabled)

Parameters:
  • cell
  • point
std::vector<double> dolfin::HexahedronCell::triangulate_intersection(const Cell &c0, const Cell &c1) const

Compute triangulation of intersection of two cells.

Parameters:
  • c0
  • c1
double dolfin::HexahedronCell::volume(const MeshEntity &triangle) const

Compute (generalized) volume (area) of triangle.

Parameters:triangle
std::vector<std::int8_t> dolfin::HexahedronCell::vtk_mapping() const

Mapping of DOLFIN/UFC vertex ordering to VTK/XDMF ordering.

IntervalCell

C++ documentation for IntervalCell from dolfin/mesh/IntervalCell.h:

class dolfin::IntervalCell

This class implements functionality for interval meshes.

dolfin::IntervalCell::IntervalCell()

Specify cell type and facet type.

Point dolfin::IntervalCell::cell_normal(const Cell &cell) const

Compute normal to given cell (viewed as embedded in 2D)

Parameters:cell
double dolfin::IntervalCell::circumradius(const MeshEntity &interval) const

Compute circumradius of interval.

Parameters:interval
bool dolfin::IntervalCell::collides(const Cell &cell, const MeshEntity &entity) const

Check whether given entity collides with cell.

Parameters:
  • cell
  • entity
bool dolfin::IntervalCell::collides(const Cell &cell, const Point &point) const

Check whether given point collides with cell.

Parameters:
  • cell
  • point
void dolfin::IntervalCell::create_entities(boost::multi_array<unsigned int, 2> &e, std::size_t dim, const unsigned int *v) const

Create entities e of given topological dimension from vertices v.

Parameters:
  • e
  • dim
  • v
std::string dolfin::IntervalCell::description(bool plural) const

Return description of cell type.

Parameters:plural
std::size_t dolfin::IntervalCell::dim() const

Return topological dimension of cell.

double dolfin::IntervalCell::facet_area(const Cell &cell, std::size_t facet) const

Compute the area/length of given facet with respect to the cell.

Parameters:
  • cell
  • facet
Point dolfin::IntervalCell::normal(const Cell &cell, std::size_t facet) const

Compute of given facet with respect to the cell.

Parameters:
  • cell
  • facet
double dolfin::IntervalCell::normal(const Cell &cell, std::size_t facet, std::size_t i) const

Compute component i of normal of given facet with respect to the cell

Parameters:
  • cell
  • facet
  • i
std::size_t dolfin::IntervalCell::num_entities(std::size_t dim) const

Return number of entities of given topological dimension.

Parameters:dim
std::size_t dolfin::IntervalCell::num_vertices(std::size_t dim) const

Return number of vertices for entity of given topological dimension

Parameters:dim
void dolfin::IntervalCell::order(Cell &cell, const std::vector<std::int64_t> &local_to_global_vertex_indices) const

Order entities locally.

Parameters:
  • cell
  • local_to_global_vertex_indices
std::size_t dolfin::IntervalCell::orientation(const Cell &cell) const

Return orientation of the cell (assuming flat space)

Parameters:cell
double dolfin::IntervalCell::squared_distance(const Cell &cell, const Point &point) const

Compute squared distance to given point (3D enabled)

Parameters:
  • cell
  • point
double dolfin::IntervalCell::squared_distance(const Point &point, const Point &a, const Point &b)

Compute squared distance to given point. This version takes the two vertex coordinates as 3D points. This makes it possible to reuse this function for computing the (squared) distance to a triangle.

Parameters:
  • point
  • a
  • b
std::vector<double> dolfin::IntervalCell::triangulate_intersection(const Cell &c0, const Cell &c1) const

Compute triangulation of intersection of two cells.

Parameters:
  • c0
  • c1
double dolfin::IntervalCell::volume(const MeshEntity &interval) const

Compute (generalized) volume (length) of interval.

Parameters:interval
std::vector<std::int8_t> dolfin::IntervalCell::vtk_mapping() const

Mapping of DOLFIN/UFC vertex ordering to VTK/XDMF ordering.

LocalMeshData

C++ documentation for LocalMeshData from dolfin/mesh/LocalMeshData.h:

class dolfin::LocalMeshData

This class stores mesh data on a local processor corresponding to a portion of a (larger) global mesh. Note that the data stored in this class does typically not correspond to a topologically connected mesh; it merely stores a list of vertex coordinates, a list of cell-vertex mappings and a list of global vertex numbers for the locally stored vertices. It is typically used for parsing meshes in parallel from mesh XML files. After local mesh data has been parsed on each processor, a subsequent repartitioning takes place: first a geometric partitioning of the vertices followed by a redistribution of vertex and cell data, and then a topological partitioning again followed by redistribution of vertex and cell data, at that point corresponding to topologically connected meshes instead of local mesh data.

dolfin::LocalMeshData::LocalMeshData(const MPI_Comm mpi_comm)

Create empty local mesh data.

Parameters:mpi_comm
dolfin::LocalMeshData::LocalMeshData(const Mesh &mesh)

Create local mesh data for given mesh.

Parameters:mesh
void dolfin::LocalMeshData::broadcast_mesh_data(const MPI_Comm mpi_comm)

Broadcast mesh data from main process (used when Mesh is created on one process)

Parameters:mpi_comm
void dolfin::LocalMeshData::check() const

Check that all essential data has been initialized, and throw error if there is a problem

void dolfin::LocalMeshData::clear()

Clear all data.

std::map<std::size_t, std::vector<std::pair<std::pair<std::size_t, std::size_t>, std::size_t>>> dolfin::LocalMeshData::domain_data

Mesh domain data [dim](line, (cell_index, local_index, value))

void dolfin::LocalMeshData::extract_mesh_data(const Mesh &mesh)

Copy data from mesh.

Parameters:mesh
Geometry dolfin::LocalMeshData::geometry

Geometry data.

MPI_Comm dolfin::LocalMeshData::mpi_comm() const

Return MPI communicator.

void dolfin::LocalMeshData::receive_mesh_data(const MPI_Comm mpi_comm)

Receive mesh data from main process.

Parameters:mpi_comm
void dolfin::LocalMeshData::reorder()

Reorder cell data.

std::string dolfin::LocalMeshData::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
Topology dolfin::LocalMeshData::topology

Holder for topology data.

dolfin::LocalMeshData::~LocalMeshData()

Destructor.

LocalMeshValueCollection

C++ documentation for LocalMeshValueCollection from dolfin/mesh/LocalMeshValueCollection.h:

class dolfin::LocalMeshValueCollection

This class stores mesh data on a local processor corresponding to a portion of a MeshValueCollection .

dolfin::LocalMeshValueCollection::LocalMeshValueCollection(MPI_Comm comm, const MeshValueCollection<T> &values, std::size_t dim)

Create local mesh data for given LocalMeshValueCollection() .

Parameters:
  • comm
  • values
  • dim
std::size_t dolfin::LocalMeshValueCollection::dim() const

Return dimension of cell entity.

const std::vector<std::pair<std::pair<std::size_t, std::size_t>, T>> &dolfin::LocalMeshValueCollection::values() const

Return data.

dolfin::LocalMeshValueCollection::~LocalMeshValueCollection()

Destructor.

Mesh

C++ documentation for Mesh from dolfin/mesh/Mesh.h:

class dolfin::Mesh

A Mesh consists of a set of connected and numbered mesh entities. Both the representation and the interface are dimension-independent, but a concrete interface is also provided for standard named mesh entities:

Entity Dimension Codimension
Vertex 0  
Edge 1  
Face 2  
Facet   1
Cell   0

When working with mesh iterators, all entities and connectivity are precomputed automatically the first time an iterator is created over any given topological dimension or connectivity. Note that for efficiency, only entities of dimension zero (vertices) and entities of the maximal dimension (cells) exist when creating a Mesh . Other entities must be explicitly created by calling init() . For example, all edges in a mesh may be created by a call to mesh.init(1). Similarly, connectivities such as all edges connected to a given vertex must also be explicitly created (in this case by a call to mesh.init(0, 1)).

Friends: MeshEditor, MeshPartitioning, TopologyComputation, create_mesh().

dolfin::Mesh::Mesh()

Create empty mesh.

dolfin::Mesh::Mesh(MPI_Comm comm)

Create empty mesh.

Parameters:comm
dolfin::Mesh::Mesh(MPI_Comm comm, LocalMeshData &local_mesh_data)

Create a distributed mesh from local (per process) data.

Parameters:
  • comm – (MPI_Comm) MPI communicator for the mesh.
  • local_mesh_data – (LocalMeshData ) Data from which to build the mesh.
dolfin::Mesh::Mesh(MPI_Comm comm, std::string filename)

Create mesh from data file.

Parameters:
  • comm – (MPI_Comm) The MPI communicator
  • filename – (std::string) Name of file to load.
dolfin::Mesh::Mesh(const Mesh &mesh)

Copy constructor.

Parameters:mesh – (Mesh() ) Object to be copied.
dolfin::Mesh::Mesh(std::string filename)

Create mesh from data file.

Parameters:filename – (std::string) Name of file to load.
std::shared_ptr<BoundingBoxTree> dolfin::Mesh::bounding_box_tree() const

Get bounding box tree for mesh. The bounding box tree is initialized and built upon the first call to this function. The bounding box tree can be used to compute collisions between the mesh and other objects. It is the responsibility of the caller to use (and possibly rebuild) the tree. It is stored as a (mutable) member of the mesh to enable sharing of the bounding box tree data structure.

Returns:std::shared_ptr<BoundingBoxTree>
const std::vector<int> &dolfin::Mesh::cell_orientations() const

Return cell_orientations (const version)

Returns:std::vector<int> :: Map from cell index to orientation of cell. Is empty if cell orientations have not been computed.
const std::vector<unsigned int> &dolfin::Mesh::cells() const

Get cell connectivity.

Returns:std::vector<unsigned int>& Connectivity for all cells.
void dolfin::Mesh::clean()

Clean out all auxiliary topology data. This clears all topological data, except the connectivity between cells and vertices.

const std::vector<std::size_t> &dolfin::Mesh::color(std::string coloring_type) const

Color the cells of the mesh such that no two neighboring cells share the same color. A colored mesh keeps a CellFunction<std::size_t> named “cell colors” as mesh data which holds the colors of the mesh.

Parameters:coloring_type – (std::string) Coloring type, specifying what relation makes two cells neighbors, can be one of “vertex”, “edge” or “facet”.
Returns:std::vector<std::size_t>& The colors as a mesh function over the cells of the mesh.
const std::vector<std::size_t> &dolfin::Mesh::color(std::vector<std::size_t> coloring_type) const

Color the cells of the mesh such that no two neighboring cells share the same color. A colored mesh keeps a CellFunction<std::size_t> named “cell colors” as mesh data which holds the colors of the mesh.

Parameters:coloring_type – (std::vector<std::size_t>&) Coloring type given as list of topological dimensions, specifying what relation makes two mesh entities neighbors.
Returns:std::vector<std::size_t>& The colors as a mesh function over entities of the mesh.
std::vector<double> &dolfin::Mesh::coordinates()

Get vertex coordinates.

Returns:std::vector<double>& Coordinates of all vertices.
const std::vector<double> &dolfin::Mesh::coordinates() const

Return coordinates of all vertices (const version).

Returns:std::vector<double>& Coordinates of all vertices.
MeshData &dolfin::Mesh::data()

Get mesh data.

Returns:MeshData & The mesh data object associated with the mesh.
const MeshData &dolfin::Mesh::data() const

Get mesh data (const version).

Returns:MeshData & The mesh data object associated with the mesh.
MeshDomains &dolfin::Mesh::domains()

Get mesh (sub)domains.

Returns:MeshDomains The (sub)domains associated with the mesh.
const MeshDomains &dolfin::Mesh::domains() const

Get mesh (sub)domains (const).

Returns:MeshDomains The (sub)domains associated with the mesh.
MeshGeometry &dolfin::Mesh::geometry()

Get mesh geometry.

Returns:MeshGeometry The geometry object associated with the mesh.
const MeshGeometry &dolfin::Mesh::geometry() const

Get mesh geometry (const version).

Returns:MeshGeometry The geometry object associated with the mesh.
std::string dolfin::Mesh::ghost_mode() const

Ghost mode used for partitioning. Possible values are same as parameters["ghost_mode"] . WARNING: the interface may change in future without deprecation; the method is now intended for internal library use.

std::size_t dolfin::Mesh::hash() const

Compute hash of mesh, currently based on the has of the mesh geometry and mesh topology.

Returns:std::size_t A tree-hashed value of the coordinates over all MPI processes
double dolfin::Mesh::hmax() const

Compute maximum cell size in mesh, measured greatest distance between any two vertices of a cell.

Returns:double The maximum cell size. The size is computed using Cell::h
double dolfin::Mesh::hmin() const

Compute minimum cell size in mesh, measured greatest distance between any two vertices of a cell.

Returns:double The minimum cell size. The size is computed using Cell::h
void dolfin::Mesh::init() const

Compute all entities and connectivity.

void dolfin::Mesh::init(std::size_t d0, std::size_t d1) const

Compute connectivity between given pair of dimensions.

Parameters:
  • d0 – (std::size_t) Topological dimension.
  • d1 – (std::size_t) Topological dimension.
std::size_t dolfin::Mesh::init(std::size_t dim) const

Compute entities of given topological dimension.

Parameters:dim – (std::size_t) Topological dimension.
Returns:std::size_t Number of created entities.
void dolfin::Mesh::init_cell_orientations(const Expression &global_normal)

Compute and initialize cell_orientations relative to a given global outward direction/normal/orientation. Only defined if mesh is orientable.

Parameters:global_normal – (Expression ) A global normal direction to the mesh
void dolfin::Mesh::init_global(std::size_t dim) const

Compute global indices for entity dimension dim.

Parameters:dim
MPI_Comm dolfin::Mesh::mpi_comm() const

Mesh MPI communicator

Returns:MPI_Comm
std::size_t dolfin::Mesh::num_cells() const

Get number of cells in mesh.

Returns:std::size_t Number of cells.
std::size_t dolfin::Mesh::num_edges() const

Get number of edges in mesh.

Returns:std::size_t Number of edges.
std::size_t dolfin::Mesh::num_entities(std::size_t d) const

Get number of entities of given topological dimension.

Parameters:d – (std::size_t) Topological dimension.
Returns:std::size_t Number of entities of topological dimension d.
std::size_t dolfin::Mesh::num_faces() const

Get number of faces in mesh.

Returns:std::size_t Number of faces.
std::size_t dolfin::Mesh::num_facets() const

Get number of facets in mesh.

Returns:std::size_t Number of facets.
std::size_t dolfin::Mesh::num_vertices() const

Get number of vertices in mesh.

Returns:std::size_t Number of vertices.
const Mesh &dolfin::Mesh::operator=(const Mesh &mesh)

Assignment operator

Parameters:mesh – (Mesh ) Another Mesh object.
void dolfin::Mesh::order()

Order all mesh entities. See also: UFC documentation (put link here!)

bool dolfin::Mesh::ordered() const

Check if mesh is ordered according to the UFC numbering convention.

Returns:bool The return values is true iff the mesh is ordered.
Mesh dolfin::Mesh::renumber_by_color() const

Renumber mesh entities by coloring. This function is currently restricted to renumbering by cell coloring. The cells (cell-vertex connectivity) and the coordinates of the mesh are renumbered to improve the locality within each color. It is assumed that the mesh has already been colored and that only cell-vertex connectivity exists as part of the mesh.

Returns:Mesh
double dolfin::Mesh::rmax() const

Compute maximum cell inradius.

Returns:double The maximum of cells’ inscribed sphere radii
double dolfin::Mesh::rmin() const

Compute minimum cell inradius.

Returns:double The minimum of cells’ inscribed sphere radii
void dolfin::Mesh::rotate(double angle, std::size_t axis, const Point &point)

Rotate mesh around a coordinate axis through a given point

Parameters:
  • angle – (double) The number of degrees (0-360) of rotation.
  • axis – (std::size_t) The coordinate axis around which to rotate the mesh.
  • point – (Point ) The point around which to rotate the mesh.
void dolfin::Mesh::rotate(double angle, std::size_t axis = 2)

Rotate mesh around a coordinate axis through center of mass of all mesh vertices

Parameters:
  • angle – (double) The number of degrees (0-360) of rotation.
  • axis – (std::size_t) The coordinate axis around which to rotate the mesh.
std::size_t dolfin::Mesh::size(std::size_t dim) const

Get number of local entities of given topological dimension.

Parameters:dim – (std::size_t) Topological dimension.
Returns:std::size_t Number of local entities of topological dimension d.
std::size_t dolfin::Mesh::size_global(std::size_t dim) const

Get global number of entities of given topological dimension.

Parameters:dim – (std::size_t) Topological dimension.
Returns:std::size_t Global number of entities of topological dimension d.
void dolfin::Mesh::smooth(std::size_t num_iterations = 1)

Smooth internal vertices of mesh by local averaging.

Parameters:num_iterations – (std::size_t) Number of iterations to perform smoothing, default value is 1.
void dolfin::Mesh::smooth_boundary(std::size_t num_iterations = 1, bool harmonic_smoothing = true)

Smooth boundary vertices of mesh by local averaging.

Parameters:
  • num_iterations – (std::size_t) Number of iterations to perform smoothing, default value is 1.
  • harmonic_smoothing – (bool) Flag to turn on harmonics smoothing, default value is true.
void dolfin::Mesh::snap_boundary(const SubDomain &sub_domain, bool harmonic_smoothing = true)

Snap boundary vertices of mesh to match given sub domain.

Parameters:
  • sub_domain – (SubDomain ) A SubDomain object.
  • harmonic_smoothing – (bool) Flag to turn on harmonics smoothing, default value is true.
std::string dolfin::Mesh::str(bool verbose) const

Informal string representation.

Parameters:verbose – (bool) Flag to turn on additional output.
Returns:std::string An informal representation of the mesh.
MeshTopology &dolfin::Mesh::topology()

Get mesh topology.

Returns:MeshTopology The topology object associated with the mesh.
const MeshTopology &dolfin::Mesh::topology() const

Get mesh topology (const version).

Returns:MeshTopology The topology object associated with the mesh.
void dolfin::Mesh::translate(const Point &point)

Translate mesh according to a given vector.

Parameters:point – (Point ) The vector defining the translation.
CellType &dolfin::Mesh::type()

Get mesh cell type.

Returns:CellType & The cell type object associated with the mesh.
const CellType &dolfin::Mesh::type() const

Get mesh cell type (const version).

dolfin::Mesh::~Mesh()

Destructor.

MeshColoring

C++ documentation for MeshColoring from dolfin/mesh/MeshColoring.h:

class dolfin::MeshColoring

This class computes colorings for a local mesh. It supports vertex, edge, and facet-based colorings.

CellFunction<std::size_t> dolfin::MeshColoring::cell_colors(std::shared_ptr<const Mesh> mesh, std::string coloring_type)

Return a MeshFunction with the cell colors (used for visualisation)

Parameters:
  • mesh
  • coloring_type
CellFunction<std::size_t> dolfin::MeshColoring::cell_colors(std::shared_ptr<const Mesh> mesh, std::vector<std::size_t> coloring_type)

Return a MeshFunction with the cell colors (used for visualisation)

Parameters:
  • mesh
  • coloring_type
const std::vector<std::size_t> &dolfin::MeshColoring::color(Mesh &mesh, const std::vector<std::size_t> &coloring_type)

Color the cells of a mesh for given coloring type specified by topological dimension, which can be one of 0, 1 or D -

  1. Coloring is saved in the mesh topology
Parameters:
  • mesh
  • coloring_type
const std::vector<std::size_t> &dolfin::MeshColoring::color_cells(Mesh &mesh, std::string coloring_type)

Color the cells of a mesh for given coloring type, which can be one of “vertex”, “edge” or “facet”. Coloring is saved in the mesh topology

Parameters:
  • mesh
  • coloring_type
std::size_t dolfin::MeshColoring::compute_colors(const Mesh &mesh, std::vector<std::size_t> &colors, const std::vector<std::size_t> &coloring_type)

Compute cell colors for given coloring type specified by topological dimension, which can be one of 0, 1 or D - 1.

Parameters:
  • mesh
  • colors
  • coloring_type
std::size_t dolfin::MeshColoring::type_to_dim(std::string coloring_type, const Mesh &mesh)

Convert coloring type to topological dimension.

Parameters:
  • coloring_type
  • mesh
MeshConnectivity

C++ documentation for MeshConnectivity from dolfin/mesh/MeshConnectivity.h:

class dolfin::MeshConnectivity

Mesh connectivity stores a sparse data structure of connections (incidence relations) between mesh entities for a fixed pair of topological dimensions. The connectivity can be specified either by first giving the number of entities and the number of connections for each entity, which may either be equal for all entities or different, or by giving the entire (sparse) connectivity pattern.

dolfin::MeshConnectivity::MeshConnectivity(const MeshConnectivity &connectivity)

Copy constructor.

Parameters:connectivity
dolfin::MeshConnectivity::MeshConnectivity(std::size_t d0, std::size_t d1)

Create empty connectivity between given dimensions (d0 – d1)

Parameters:
  • d0
  • d1
void dolfin::MeshConnectivity::clear()

Clear all data.

bool dolfin::MeshConnectivity::empty() const

Return true if the total number of connections is equal to zero.

std::size_t dolfin::MeshConnectivity::hash() const

Hash of connections.

std::vector<unsigned int> dolfin::MeshConnectivity::index_to_position
void dolfin::MeshConnectivity::init(std::size_t num_entities, std::size_t num_connections)

Initialize number of entities and number of connections (equal for all)

Parameters:
  • num_entities
  • num_connections
void dolfin::MeshConnectivity::init(std::vector<std::size_t> &num_connections)

Initialize number of entities and number of connections (individually)

Parameters:num_connections
const std::vector<unsigned int> &dolfin::MeshConnectivity::operator()() const

Return contiguous array of connections for all entities.

const unsigned int *dolfin::MeshConnectivity::operator()(std::size_t entity) const

Return array of connections for given entity.

Parameters:entity
const MeshConnectivity &dolfin::MeshConnectivity::operator=(const MeshConnectivity &connectivity)

Assignment.

Parameters:connectivity
void dolfin::MeshConnectivity::set(const T &connections)

Set all connections for all entities (T is a ‘2D’ container, e.g. a std::vector<<std::vector<std::size_t>>, std::vector<<std::set<std::size_t>>, etc)

Parameters:connections
void dolfin::MeshConnectivity::set(std::size_t entity, const T &connections)

Set all connections for given entity. T is a contains, e.g. std::vector<std::size_t>

Parameters:
  • entity
  • connections
void dolfin::MeshConnectivity::set(std::size_t entity, std::size_t *connections)

Set all connections for given entity.

Parameters:
  • entity
  • connections
void dolfin::MeshConnectivity::set(std::size_t entity, std::size_t connection, std::size_t pos)

Set given connection for given entity.

Parameters:
  • entity
  • connection
  • pos
void dolfin::MeshConnectivity::set_global_size(const std::vector<unsigned int> &num_global_connections)

Set global number of connections for all local entities.

Parameters:num_global_connections
std::size_t dolfin::MeshConnectivity::size() const

Return total number of connections.

std::size_t dolfin::MeshConnectivity::size(std::size_t entity) const

Return number of connections for given entity.

Parameters:entity
std::size_t dolfin::MeshConnectivity::size_global(std::size_t entity) const

Return global number of connections for given entity.

Parameters:entity
std::string dolfin::MeshConnectivity::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
dolfin::MeshConnectivity::~MeshConnectivity()

Destructor.

MeshData

C++ documentation for MeshData from dolfin/mesh/MeshData.h:

class dolfin::MeshData

The class MeshData is a container for auxiliary mesh data, represented either as arrays or maps. Each dataset is identified by a unique user-specified string. Only std::size_t-valued data are currently supported. Auxiliary mesh data may be attached to a mesh by users as a convenient way to store data associated with a mesh. It is also used internally by DOLFIN to communicate data associated with meshes. The following named mesh data are recognized by DOLFIN: Facet orientation (used for assembly over interior facets)

  • “facet_orientation” - std:vector <std::size_t> of dimension D - 1

Sub meshes (used by the class SubMesh )

  • “parent_vertex_indices” - std::vector <std::size_t> of dimension 0

Note to developers: use underscore in names in place of spaces.

Friends: XMLMesh.

dolfin::MeshData::MeshData()

Constructor.

std::vector<std::size_t> &dolfin::MeshData::array(std::string name, std::size_t dim)

Return array with given name (returning zero if data is not available)

Parameters:
  • name – (std::string) The name of the array.
  • dim – (std::size_t) Dimension.
Returns:

std::vector<std::size_t> The array.

const std::vector<std::size_t> &dolfin::MeshData::array(std::string name, std::size_t dim) const

Return array with given name (returning zero if data is not available)

Parameters:
  • name – (std::string) The name of the array.
  • dim – (std::size_t) Dimension.
Returns:

std::vector<std::size_t> The array.

void dolfin::MeshData::check_deprecated(std::string name) const
Parameters:name
void dolfin::MeshData::clear()

Clear all data.

std::vector<std::size_t> &dolfin::MeshData::create_array(std::string name, std::size_t dim)

Create array (vector) with given name and size

Parameters:
  • name – (std::string) The name of the array.
  • dim – (std::size_t) Dimension.
Returns:

std::vector<std::size_t> The array.

void dolfin::MeshData::erase_array(const std::string name, std::size_t dim)

Erase array with given name

Parameters:
  • name – (std::string) The name of the array.
  • dim – (std::size_t) Dimension.
bool dolfin::MeshData::exists(std::string name, std::size_t dim) const

Check is array exists

Parameters:
  • name – (std::string) The name of the array.
  • dim – (std::size_t)
Returns:

bool True is array exists, false otherwise.

const MeshData &dolfin::MeshData::operator=(const MeshData &data)

Assignment operator

Parameters:data – (MeshData ) Another MeshData object.
std::string dolfin::MeshData::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose – (bool) Flag to turn on additional output.
Returns:std::string An informal representation.
dolfin::MeshData::~MeshData()

Destructor.

MeshDomains

C++ documentation for MeshDomains from dolfin/mesh/MeshDomains.h:

class dolfin::MeshDomains

The class MeshDomains stores the division of a Mesh into subdomains. For each topological dimension 0 <= d <= D, where D is the topological dimension of the Mesh , a set of integer markers are stored for a subset of the entities of dimension d, indicating for each entity in the subset the number of the subdomain. It should be noted that the subset does not need to contain all entities of any given dimension; entities not contained in the subset are “unmarked”.

dolfin::MeshDomains::MeshDomains()

Create empty mesh domains.

void dolfin::MeshDomains::clear()

Clear all data.

std::size_t dolfin::MeshDomains::get_marker(std::size_t entity_index, std::size_t dim) const

Get marker (entity index, marker value) of a given dimension d. Throws an error if marker does not exist.

Parameters:
  • entity_index
  • dim
void dolfin::MeshDomains::init(std::size_t dim)

Initialize mesh domains for given topological dimension.

Parameters:dim
bool dolfin::MeshDomains::is_empty() const

Check whether domain data is empty.

std::map<std::size_t, std::size_t> &dolfin::MeshDomains::markers(std::size_t dim)

Get subdomain markers for given dimension (shared pointer version)

Parameters:dim
const std::map<std::size_t, std::size_t> &dolfin::MeshDomains::markers(std::size_t dim) const

Get subdomain markers for given dimension (const shared pointer version)

Parameters:dim
std::size_t dolfin::MeshDomains::max_dim() const

Return maximum topological dimension of stored markers.

std::size_t dolfin::MeshDomains::num_marked(std::size_t dim) const

Return number of marked entities of given dimension.

Parameters:dim
const MeshDomains &dolfin::MeshDomains::operator=(const MeshDomains &domains)

Assignment operator.

Parameters:domains
bool dolfin::MeshDomains::set_marker(std::pair<std::size_t, std::size_t> marker, std::size_t dim)

Set marker (entity index, marker value) of a given dimension d. Returns true if a new key is inserted, false otherwise.

Parameters:
  • marker
  • dim
dolfin::MeshDomains::~MeshDomains()

Destructor.

MeshEditor

C++ documentation for MeshEditor from dolfin/mesh/MeshEditor.h:

class dolfin::MeshEditor

A simple mesh editor for creating simplicial meshes in 1D, 2D and 3D.

Friends: TetrahedronCell.

dolfin::MeshEditor::MeshEditor()

Constructor.

void dolfin::MeshEditor::add_cell(std::size_t c, const T &v)

Add cell with given vertices

Parameters:
  • c – (std::size_t) The cell (index).
  • v – (typename T) The vertex indices (local indices)
void dolfin::MeshEditor::add_cell(std::size_t c, const std::vector<std::size_t> &v)

Add cell with given vertices (non-templated version for Python interface)

Parameters:
  • c – (std::size_t) The cell (index).
  • v – (std::vector<std::size_t>) The vertex indices (local indices)
void dolfin::MeshEditor::add_cell(std::size_t c, std::size_t v0, std::size_t v1)

Add cell with given vertices (1D)

Parameters:
  • c – (std::size_t) The cell (index).
  • v0 – (std::vector<std::size_t>) The first vertex (local index).
  • v1 – (std::vector<std::size_t>) The second vertex (local index).
void dolfin::MeshEditor::add_cell(std::size_t c, std::size_t v0, std::size_t v1, std::size_t v2)

Add cell with given vertices (2D)

Parameters:
  • c – (std::size_t) The cell (index).
  • v0 – (std::vector<std::size_t>) The first vertex (local index).
  • v1 – (std::vector<std::size_t>) The second vertex (local index).
  • v2 – (std::vector<std::size_t>) The third vertex (local index).
void dolfin::MeshEditor::add_cell(std::size_t c, std::size_t v0, std::size_t v1, std::size_t v2, std::size_t v3)

Add cell with given vertices (3D)

Parameters:
  • c – (std::size_t) The cell (index).
  • v0 – (std::vector<std::size_t>) The first vertex (local index).
  • v1 – (std::vector<std::size_t>) The second vertex (local index).
  • v2 – (std::vector<std::size_t>) The third vertex (local index).
  • v3 – (std::vector<std::size_t>) The fourth vertex (local index).
void dolfin::MeshEditor::add_cell(std::size_t local_index, std::size_t global_index, const T &v)

Add cell with given vertices

Parameters:
  • local_index – (std::size_t) The cell (index).
  • global_index – (std::size_t) The global (user) cell index.
  • v – (std::vector<std::size_t>) The vertex indices (local indices)
void dolfin::MeshEditor::add_cell_common(std::size_t v, std::size_t dim)
Parameters:
  • v
  • dim
void dolfin::MeshEditor::add_entity_point(std::size_t entity_dim, std::size_t order, std::size_t index, const Point &p)

Add a point in a given entity of dimension entity_dim.

Parameters:
  • entity_dim
  • order
  • index
  • p
void dolfin::MeshEditor::add_vertex(std::size_t index, const Point &p)

Add vertex v at given point p

Parameters:
  • index – (std::size_t) The vertex (index).
  • p – (Point ) The point.
void dolfin::MeshEditor::add_vertex(std::size_t index, const std::vector<double> &x)

Add vertex v at given coordinate x

Parameters:
  • index – (std::size_t) The vertex (index).
  • x – (std::vector<double>) The x-coordinates.
void dolfin::MeshEditor::add_vertex(std::size_t index, double x)

Add vertex v at given point x (for a 1D mesh)

Parameters:
  • index – (std::size_t) The vertex (index).
  • x – (double) The x-coordinate.
void dolfin::MeshEditor::add_vertex(std::size_t index, double x, double y)

Add vertex v at given point (x, y) (for a 2D mesh)

Parameters:
  • index – (std::size_t) The vertex (index).
  • x – (double) The x-coordinate.
  • y – (double) The y-coordinate.
void dolfin::MeshEditor::add_vertex(std::size_t index, double x, double y, double z)

Add vertex v at given point (x, y, z) (for a 3D mesh)

Parameters:
  • index – (std::size_t) The vertex (index).
  • x – (double) The x-coordinate.
  • y – (double) The y-coordinate.
  • z – (double) The z-coordinate.
void dolfin::MeshEditor::add_vertex_common(std::size_t v, std::size_t dim)
Parameters:
  • v
  • dim
void dolfin::MeshEditor::add_vertex_global(std::size_t local_index, std::size_t global_index, const Point &p)

Add vertex v at given point p

Parameters:
  • local_index – (std::size_t) The vertex (local index).
  • global_index – (std::size_t) The vertex (global_index).
  • p – (Point ) The point.
void dolfin::MeshEditor::add_vertex_global(std::size_t local_index, std::size_t global_index, const std::vector<double> &x)

Add vertex v at given coordinate x

Parameters:
  • local_index – (std::size_t) The vertex (local index).
  • global_index – (std::size_t) The vertex (global_index).
  • x – (std::vector<double>) The x-coordinates.
void dolfin::MeshEditor::check_vertices(const T &v) const
Parameters:v
void dolfin::MeshEditor::clear()
void dolfin::MeshEditor::close(bool order = true)

Close mesh, finish editing, and order entities locally

MeshEditor editor;
editor.open(mesh, 2, 2);
...
editor.close()
Parameters:order – (bool) Order entities locally if true. Default values is true.
void dolfin::MeshEditor::compute_boundary_indicators()
void dolfin::MeshEditor::init_cells(std::size_t num_cells)

Specify number of cells (serial version)

Mesh mesh;
MeshEditor editor;
editor.open(mesh, 2, 2);
editor.init_cells(8);
Parameters:num_cells – (std::size_t) The number of cells.
void dolfin::MeshEditor::init_cells_global(std::size_t num_local_cells, std::size_t num_global_cells)

Specify number of cells (distributed version)

Mesh mesh;
MeshEditor editor;
editor.open(mesh, 2, 2);
editor.init_cells(2, 6);
Parameters:
  • num_local_cells – (std::size_t) The number of local cells.
  • num_global_cells – (std::size_t) The number of cells in distributed mesh.
void dolfin::MeshEditor::init_entities()

Initialise entities in MeshGeometry Create required Edges and Faces for the current polynomial degree in the mesh topology, so that points can be added for them. In order to initialise entities, cells must all be added first.

void dolfin::MeshEditor::init_vertices(std::size_t num_vertices)

Specify number of vertices (serial version)

Mesh mesh;
MeshEditor editor;
editor.open(mesh, 2, 2);
editor.init_vertices(9);
Parameters:num_vertices – (std::size_t) The number of vertices.
void dolfin::MeshEditor::init_vertices_global(std::size_t num_local_vertices, std::size_t num_global_vertices)

Specify number of vertices (distributed version)

Mesh mesh;
MeshEditor editor;
editor.open(mesh, 2, 2);
editor.init_vertices(4, 8);
Parameters:
  • num_local_vertices – (std::size_t) The number of vertices on this process.
  • num_global_vertices – (std::size_t) The number of vertices in distributed mesh.
std::size_t dolfin::MeshEditor::next_cell
std::size_t dolfin::MeshEditor::next_vertex
void dolfin::MeshEditor::open(Mesh &mesh, CellType::Type type, std::size_t tdim, std::size_t gdim, std::size_t degree = 1)

Open mesh of given cell type, topological and geometrical dimension

Parameters:
  • mesh – (Mesh ) The mesh to open.
  • type – (CellType::Type ) Cell type.
  • tdim – (std::size_t) The topological dimension.
  • gdim – (std::size_t) The geometrical dimension.
  • degree – (std::size_t) The polynomial degree.
void dolfin::MeshEditor::open(Mesh &mesh, std::size_t tdim, std::size_t gdim, std::size_t degree = 1)

Open mesh of given topological and geometrical dimension

Parameters:
  • mesh – (Mesh ) The mesh to open.
  • tdim – (std::size_t) The topological dimension.
  • gdim – (std::size_t) The geometrical dimension.
  • degree – (std::size_t) The polynomial degree. :: Mesh mesh; MeshEditor editor; editor.open(mesh, 2, 2, 1);
void dolfin::MeshEditor::open(Mesh &mesh, std::string type, std::size_t tdim, std::size_t gdim, std::size_t degree = 1)

Open mesh of given cell type, topological and geometrical dimension

Parameters:
  • mesh – (Mesh ) The mesh to open.
  • type – (std::string) Cell type.
  • tdim – (std::size_t) The topological dimension.
  • gdim – (std::size_t) The geometrical dimension.
  • degree – (std::size_t) The polynomial degree.
dolfin::MeshEditor::~MeshEditor()

Destructor.

MeshEntity

C++ documentation for MeshEntity from dolfin/mesh/MeshEntity.h:

class dolfin::MeshEntity

A MeshEntity represents a mesh entity associated with a specific topological dimension of some Mesh .

Friends: MeshEntityIterator, MeshEntityIteratorBase, SubsetIterator.

dolfin::MeshEntity::MeshEntity()

Default Constructor.

dolfin::MeshEntity::MeshEntity(const Mesh &mesh, std::size_t dim, std::size_t index)

Constructor

Parameters:
  • mesh – (Mesh ) The mesh.
  • dim – (std::size_t) The topological dimension.
  • index – (std::size_t) The index.
std::size_t dolfin::MeshEntity::dim() const

Return topological dimension

Returns:std::size_t The dimension.
const unsigned int *dolfin::MeshEntity::entities(std::size_t dim) const

Return array of indices for incident mesh entities of given topological dimension

Parameters:dim – (std::size_t) The topological dimension.
Returns:std::size_t The index for incident mesh entities of given dimension.
std::int64_t dolfin::MeshEntity::global_index() const

Return global index of mesh entity

Returns:std::size_t The global index. Set to std::numerical_limits<std::size_t>::max() if global index has not been computed
bool dolfin::MeshEntity::incident(const MeshEntity &entity) const

Check if given entity is incident

Parameters:entity – (MeshEntity ) The entity.
Returns:bool True if the given entity is incident
std::size_t dolfin::MeshEntity::index() const

Return index of mesh entity

Returns:std::size_t The index.
std::size_t dolfin::MeshEntity::index(const MeshEntity &entity) const

Compute local index of given incident entity (error if not found)

Parameters:entity – (MeshEntity ) The mesh entity.
Returns:std::size_t The local index of given entity.
void dolfin::MeshEntity::init(const Mesh &mesh, std::size_t dim, std::size_t index)

Initialize mesh entity with given data

Parameters:
  • mesh – (Mesh ) The mesh.
  • dim – (std::size_t) The topological dimension.
  • index – (std::size_t) The index.
bool dolfin::MeshEntity::is_ghost() const

Determine whether an entity is a ‘ghost’ from another process

Returns:bool True if entity is a ghost entity
bool dolfin::MeshEntity::is_shared() const

Determine if an entity is shared or not

Returns:bool True if entity is shared
const Mesh &dolfin::MeshEntity::mesh() const

Return mesh associated with mesh entity

Returns:Mesh The mesh.
std::size_t dolfin::MeshEntity::mesh_id() const

Return unique mesh ID

Returns:std::size_t The unique mesh ID.
Point dolfin::MeshEntity::midpoint() const

Compute midpoint of cell

Returns:Point The midpoint of the cell.
std::size_t dolfin::MeshEntity::num_entities(std::size_t dim) const

Return local number of incident mesh entities of given topological dimension

Parameters:dim – (std::size_t) The topological dimension.
Returns:std::size_t The number of local incident MeshEntity objects of given dimension.
std::size_t dolfin::MeshEntity::num_global_entities(std::size_t dim) const

Return global number of incident mesh entities of given topological dimension

Parameters:dim – (std::size_t) The topological dimension.
Returns:std::size_t The number of global incident MeshEntity objects of given dimension.
bool dolfin::MeshEntity::operator!=(const MeshEntity &e) const

Comparison Operator

Parameters:e – (MeshEntity ) Another mesh entity.
Returns:bool True if the two mesh entities are NOT equal.
bool dolfin::MeshEntity::operator==(const MeshEntity &e) const

Comparison Operator

Parameters:e – (MeshEntity ) Another mesh entity
Returns:bool True if the two mesh entities are equal.
unsigned int dolfin::MeshEntity::owner() const

Get ownership of this entity - only really valid for cells

Returns:unsigned int Owning process
std::set<unsigned int> dolfin::MeshEntity::sharing_processes() const

Return set of sharing processes

Returns:std::set<unsigned int> List of sharing processes
std::string dolfin::MeshEntity::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose – (bool) Flag to turn on additional output.
Returns:std::string An informal representation of the function space.
dolfin::MeshEntity::~MeshEntity()

Destructor.

MeshEntityIterator

C++ documentation for MeshEntityIterator from dolfin/mesh/MeshEntityIterator.h:

class dolfin::MeshEntityIterator

MeshEntityIterator provides a common iterator for mesh entities over meshes, boundaries and incidence relations. The basic use is illustrated below.

The following example shows how to iterate over all mesh entities
of a mesh of topological dimension dim:
for (MeshEntityIterator e(mesh, dim); !e.end(); ++e)
{
e->foo();
}
The following example shows how to iterate over mesh entities of
topological dimension dim connected (incident) to some mesh entity f:
for (MeshEntityIterator e(f, dim); !e.end(); ++e)
{
e->foo();
}

In addition to the general iterator, a set of specific named iterators are provided for entities of type Vertex , Edge , Face , Facet and Cell . These iterators are defined along with their respective classes.

dolfin::MeshEntityIterator::MeshEntityIterator()

Default constructor.

dolfin::MeshEntityIterator::MeshEntityIterator(const Mesh &mesh, std::size_t dim)

Create iterator for mesh entities over given topological dimension.

Parameters:
  • mesh
  • dim
dolfin::MeshEntityIterator::MeshEntityIterator(const Mesh &mesh, std::size_t dim, std::string opt)

Iterator over MeshEntity of dimension dim on mesh, with string option to iterate over “regular”, “ghost” or “all” entities

Parameters:
  • mesh
  • dim
  • opt
dolfin::MeshEntityIterator::MeshEntityIterator(const MeshEntity &entity, std::size_t dim)

Create iterator for entities of given dimension connected to given entity

Parameters:
  • entity
  • dim
dolfin::MeshEntityIterator::MeshEntityIterator(const MeshEntityIterator &it)

Copy constructor.

Parameters:it
bool dolfin::MeshEntityIterator::end() const

Check if iterator has reached the end.

MeshEntityIterator dolfin::MeshEntityIterator::end_iterator()

Provide a safeguard iterator pointing beyond the end of an iteration process, either iterating over the mesh /or incident entities. Added to be bit more like STL iterators, since many algorithms rely on a kind of beyond iterator.

const unsigned int *dolfin::MeshEntityIterator::index
bool dolfin::MeshEntityIterator::operator!=(const MeshEntityIterator &it) const

Comparison operator.

Parameters:it
MeshEntity &dolfin::MeshEntityIterator::operator*()

Dereference operator.

MeshEntityIterator &dolfin::MeshEntityIterator::operator++()

Step to next mesh entity (prefix increment)

MeshEntityIterator &dolfin::MeshEntityIterator::operator--()

Step to the previous mesh entity (prefix decrease)

MeshEntity *dolfin::MeshEntityIterator::operator->()

Member access operator.

bool dolfin::MeshEntityIterator::operator==(const MeshEntityIterator &it) const

Comparison operator.

Parameters:it
std::size_t dolfin::MeshEntityIterator::pos() const

Return current position.

std::size_t dolfin::MeshEntityIterator::pos_end
void dolfin::MeshEntityIterator::set_end()
dolfin::MeshEntityIterator::~MeshEntityIterator()

Destructor.

MeshEntityIteratorBase

C++ documentation for MeshEntityIteratorBase from dolfin/mesh/MeshEntityIteratorBase.h:

class dolfin::MeshEntityIteratorBase

Base class for MeshEntityIterators.

dolfin::MeshEntityIteratorBase::MeshEntityIteratorBase(const Mesh &mesh)

Create iterator for mesh entities over given topological dimension.

Parameters:mesh
dolfin::MeshEntityIteratorBase::MeshEntityIteratorBase(const Mesh &mesh, std::string opt)

Iterator over MeshEntity of dimension dim on mesh, with string option to iterate over “regular”, “ghost” or “all” entities

Parameters:
  • mesh
  • opt
dolfin::MeshEntityIteratorBase::MeshEntityIteratorBase(const MeshEntity &entity)

Create iterator for entities of given dimension connected to given entity.

Parameters:entity
dolfin::MeshEntityIteratorBase::MeshEntityIteratorBase(const MeshEntityIteratorBase &it)

Copy constructor.

Parameters:it
bool dolfin::MeshEntityIteratorBase::end() const

Check if iterator has reached the end.

MeshEntityIteratorBase dolfin::MeshEntityIteratorBase::end_iterator()

Provide a safeguard iterator pointing beyond the end of an iteration process, either iterating over the mesh /or incident entities. Added to be bit more like STL iterators, since many algorithms rely on a kind of beyond iterator.

const unsigned int *dolfin::MeshEntityIteratorBase::index
bool dolfin::MeshEntityIteratorBase::operator!=(const MeshEntityIteratorBase &it) const

Comparison operator.

Parameters:it
T &dolfin::MeshEntityIteratorBase::operator*()

Dereference operator.

MeshEntityIteratorBase &dolfin::MeshEntityIteratorBase::operator++()

Step to next mesh entity (prefix increment)

MeshEntityIteratorBase &dolfin::MeshEntityIteratorBase::operator--()

Step to the previous mesh entity (prefix decrease)

T *dolfin::MeshEntityIteratorBase::operator->()

Member access operator.

bool dolfin::MeshEntityIteratorBase::operator==(const MeshEntityIteratorBase &it) const

Comparison operator.

Parameters:it
std::size_t dolfin::MeshEntityIteratorBase::pos() const

Return current position.

std::size_t dolfin::MeshEntityIteratorBase::pos_end
void dolfin::MeshEntityIteratorBase::set_end()

Set pos to end position. To create a kind of mesh.end() iterator.

dolfin::MeshEntityIteratorBase::~MeshEntityIteratorBase()

Destructor.

MeshGeometry

C++ documentation for MeshGeometry from dolfin/mesh/MeshGeometry.h:

class dolfin::MeshGeometry

MeshGeometry stores the geometry imposed on a mesh. Currently, the geometry is represented by the set of coordinates for the vertices of a mesh, but other representations are possible.

dolfin::MeshGeometry::MeshGeometry()

Create empty set of coordinates.

dolfin::MeshGeometry::MeshGeometry(const MeshGeometry &geometry)

Copy constructor.

Parameters:geometry
std::vector<double> dolfin::MeshGeometry::coordinates
std::size_t dolfin::MeshGeometry::degree() const

Return polynomial degree of coordinate field.

std::size_t dolfin::MeshGeometry::dim() const

Return Euclidean dimension of coordinate system.

std::vector<std::vector<std::size_t>> dolfin::MeshGeometry::entity_offsets
std::size_t dolfin::MeshGeometry::get_entity_index(std::size_t entity_dim, std::size_t order, std::size_t index) const

Get the index for an entity point in coordinates.

Parameters:
  • entity_dim
  • order
  • index
std::size_t dolfin::MeshGeometry::hash() const

Hash of coordinate values Returns std::size_t A tree-hashed value of the coordinates over all MPI processes

void dolfin::MeshGeometry::init(std::size_t dim, std::size_t degree)

Initialize coordinate list to given dimension and degree.

Parameters:
  • dim
  • degree
void dolfin::MeshGeometry::init_entities(const std::vector<std::size_t> &num_entities)

Initialise entities. To be called after init.

Parameters:num_entities
std::size_t dolfin::MeshGeometry::num_entity_coordinates(std::size_t entity_dim) const

Get the number of coordinate points per entity for this degree.

Parameters:entity_dim
std::size_t dolfin::MeshGeometry::num_points() const

Return the total number of points in the geometry, located on any entity

std::size_t dolfin::MeshGeometry::num_vertices() const

Return the number of vertex coordinates.

const MeshGeometry &dolfin::MeshGeometry::operator=(const MeshGeometry &geometry)

Assignment.

Parameters:geometry
Point dolfin::MeshGeometry::point(std::size_t n) const

Return coordinate with local index n as a 3D point value.

Parameters:n
const double *dolfin::MeshGeometry::point_coordinates(std::size_t point_index)

Get vertex coordinates.

Parameters:point_index
void dolfin::MeshGeometry::set(std::size_t local_index, const double *x)

Set value of coordinate.

Parameters:
  • local_index
  • x
std::string dolfin::MeshGeometry::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
const double *dolfin::MeshGeometry::vertex_coordinates(std::size_t point_index)

Get vertex coordinates.

Parameters:point_index
std::vector<double> &dolfin::MeshGeometry::x()

Return array of values for all coordinates.

const std::vector<double> &dolfin::MeshGeometry::x() const

Return array of values for all coordinates.

const double *dolfin::MeshGeometry::x(std::size_t n) const

Return array of values for coordinate with local index n.

Parameters:n
double dolfin::MeshGeometry::x(std::size_t n, std::size_t i) const

Return value of coordinate with local index n in direction i.

Parameters:
  • n
  • i
dolfin::MeshGeometry::~MeshGeometry()

Destructor.

MeshHierarchy

C++ documentation for MeshHierarchy from dolfin/mesh/MeshHierarchy.h:

class dolfin::MeshHierarchy

Experimental implementation of a list of Meshes as a hierarchy.

dolfin::MeshHierarchy::MeshHierarchy()

Constructor.

dolfin::MeshHierarchy::MeshHierarchy(std::shared_ptr<const Mesh> mesh)

Constructor with initial mesh.

Parameters:mesh
std::shared_ptr<const MeshHierarchy> dolfin::MeshHierarchy::coarsen(const MeshFunction<bool> &markers) const

Coarsen finest mesh by one level, based on markers (level n->n)

Parameters:markers
std::shared_ptr<const Mesh> dolfin::MeshHierarchy::coarsest() const

Get the coarsest mesh of the MeshHierarchy .

std::shared_ptr<const Mesh> dolfin::MeshHierarchy::finest() const

Get the finest mesh of the MeshHierarchy .

std::shared_ptr<const Mesh> dolfin::MeshHierarchy::operator[](int i) const

Get Mesh i, in range [0:size() ] where 0 is the coarsest Mesh .

Parameters:i
std::shared_ptr<Mesh> dolfin::MeshHierarchy::rebalance() const

Rebalance across processes.

std::shared_ptr<const MeshHierarchy> dolfin::MeshHierarchy::refine(const MeshFunction<bool> &markers) const

Refine finest mesh of existing hierarchy, creating a new hierarchy (level n -> n+1)

Parameters:markers
unsigned int dolfin::MeshHierarchy::size() const

Number of meshes.

std::shared_ptr<const MeshHierarchy> dolfin::MeshHierarchy::unrefine() const

Unrefine by returning the previous MeshHierarchy (level n -> n-1) Returns NULL for a MeshHierarchy containing a single Mesh

std::vector<std::size_t> dolfin::MeshHierarchy::weight() const

Calculate the number of cells on the finest Mesh which are descendents of each cell on the coarsest Mesh , returning a vector over the cells of the coarsest Mesh .

dolfin::MeshHierarchy::~MeshHierarchy()

Destructor.

MeshOrdering

C++ documentation for MeshOrdering from dolfin/mesh/MeshOrdering.h:

class dolfin::MeshOrdering

This class implements the ordering of mesh entities according to the UFC specification (see appendix of DOLFIN user manual).

void dolfin::MeshOrdering::order(Mesh &mesh)

Order mesh.

Parameters:mesh
bool dolfin::MeshOrdering::ordered(const Mesh &mesh)

Check if mesh is ordered.

Parameters:mesh
MeshPartitioning

C++ documentation for MeshPartitioning from dolfin/mesh/MeshPartitioning.h:

class dolfin::MeshPartitioning

This class partitions and distributes a mesh based on partitioned local mesh data.The local mesh data will also be repartitioned and redistributed during the computation of the mesh partitioning. After partitioning, each process has a local mesh and some data that couples the meshes together.

void dolfin::MeshPartitioning::build(Mesh &mesh, const LocalMeshData &data, const std::vector<int> &cell_partition, const std::map<std::int64_t, std::vector<int>> &ghost_procs, const std::string ghost_mode)
Parameters:
  • mesh
  • data
  • cell_partition
  • ghost_procs
  • ghost_mode
void dolfin::MeshPartitioning::build_distributed_mesh(Mesh &mesh)

Build a distributed mesh from a local mesh on process 0.

Parameters:mesh
void dolfin::MeshPartitioning::build_distributed_mesh(Mesh &mesh, const LocalMeshData &data, const std::string ghost_mode)

Build a distributed mesh from ‘local mesh data’ that is distributed across processes

Parameters:
  • mesh
  • data
  • ghost_mode
void dolfin::MeshPartitioning::build_distributed_mesh(Mesh &mesh, const std::vector<int> &cell_partition, const std::string ghost_mode)

Build a distributed mesh from a local mesh on process 0, with distribution of cells supplied (destination processes for each cell)

Parameters:
  • mesh
  • cell_partition
  • ghost_mode
void dolfin::MeshPartitioning::build_distributed_value_collection(MeshValueCollection<T> &values, const LocalMeshValueCollection<T> &local_data, const Mesh &mesh)

Build a MeshValueCollection based on LocalMeshValueCollection .

Parameters:
  • values
  • local_data
  • mesh
void dolfin::MeshPartitioning::build_local_mesh(Mesh &mesh, const std::vector<std::int64_t> &global_cell_indices, const boost::multi_array<std::int64_t, 2> &cell_global_vertices, const CellType::Type cell_type, const int tdim, const std::int64_t num_global_cells, const std::vector<std::int64_t> &vertex_indices, const boost::multi_array<double, 2> &vertex_coordinates, const int gdim, const std::int64_t num_global_vertices, const std::map<std::int64_t, std::int32_t> &vertex_global_to_local_indices)
Parameters:
  • mesh
  • global_cell_indices
  • cell_global_vertices
  • cell_type
  • tdim
  • num_global_cells
  • vertex_indices
  • vertex_coordinates
  • gdim
  • num_global_vertices
  • vertex_global_to_local_indices
void dolfin::MeshPartitioning::build_mesh_domains(Mesh &mesh, const LocalMeshData &local_data)
Parameters:
  • mesh
  • local_data
void dolfin::MeshPartitioning::build_mesh_value_collection(const Mesh &mesh, const std::vector<std::pair<std::pair<std::size_t, std::size_t>, T>> &local_value_data, MeshValueCollection &mesh_values)
Parameters:
  • mesh
  • local_value_data
  • mesh_values
void dolfin::MeshPartitioning::build_shared_vertices(MPI_Comm mpi_comm, std::map<std::int32_t, std::set<unsigned int>> &shared_vertices, const std::map<std::int64_t, std::int32_t> &vertex_global_to_local_indices, const std::vector<std::vector<std::size_t>> &received_vertex_indices)
Parameters:
  • mpi_comm
  • shared_vertices
  • vertex_global_to_local_indices
  • received_vertex_indices
std::int32_t dolfin::MeshPartitioning::compute_vertex_mapping(MPI_Comm mpi_comm, const std::int32_t num_regular_cells, const boost::multi_array<std::int64_t, 2> &cell_vertices, std::vector<std::int64_t> &vertex_indices, std::map<std::int64_t, std::int32_t> &vertex_global_to_local)
Parameters:
  • mpi_comm
  • num_regular_cells
  • cell_vertices
  • vertex_indices
  • vertex_global_to_local
void dolfin::MeshPartitioning::distribute_cell_layer(MPI_Comm mpi_comm, const int num_regular_cells, const std::int64_t num_global_vertices, std::map<std::int32_t, std::set<unsigned int>> &shared_cells, boost::multi_array<std::int64_t, 2> &cell_vertices, std::vector<std::int64_t> &global_cell_indices, std::vector<int> &cell_partition)
Parameters:
  • mpi_comm
  • num_regular_cells
  • num_global_vertices
  • shared_cells
  • cell_vertices
  • global_cell_indices
  • cell_partition
std::int32_t dolfin::MeshPartitioning::distribute_cells(const MPI_Comm mpi_comm, const LocalMeshData &data, const std::vector<int> &cell_partition, const std::map<std::int64_t, std::vector<int>> &ghost_procs, boost::multi_array<std::int64_t, 2> &new_cell_vertices, std::vector<std::int64_t> &new_global_cell_indices, std::vector<int> &new_cell_partition, std::map<std::int32_t, std::set<unsigned int>> &shared_cells)
Parameters:
  • mpi_comm
  • data
  • cell_partition
  • ghost_procs
  • new_cell_vertices
  • new_global_cell_indices
  • new_cell_partition
  • shared_cells
void dolfin::MeshPartitioning::distribute_vertices(const MPI_Comm mpi_comm, const LocalMeshData &mesh_data, const std::vector<std::int64_t> &vertex_indices, boost::multi_array<double, 2> &new_vertex_coordinates, std::map<std::int64_t, std::int32_t> &vertex_global_to_local_indices, std::map<std::int32_t, std::set<unsigned int>> &shared_vertices_local)
Parameters:
  • mpi_comm
  • mesh_data
  • vertex_indices
  • new_vertex_coordinates
  • vertex_global_to_local_indices
  • shared_vertices_local
void dolfin::MeshPartitioning::partition_cells(const MPI_Comm &mpi_comm, const LocalMeshData &mesh_data, const std::string partitioner, std::vector<int> &cell_partition, std::map<std::int64_t, std::vector<int>> &ghost_procs)
Parameters:
  • mpi_comm
  • mesh_data
  • partitioner
  • cell_partition
  • ghost_procs
void dolfin::MeshPartitioning::reorder_cells_gps(MPI_Comm mpi_comm, const unsigned int num_regular_cells, const CellType &cell_type, const std::map<std::int32_t, std::set<unsigned int>> &shared_cells, const boost::multi_array<std::int64_t, 2> &cell_vertices, const std::vector<std::int64_t> &global_cell_indices, std::map<std::int32_t, std::set<unsigned int>> &reordered_shared_cells, boost::multi_array<std::int64_t, 2> &reordered_cell_vertices, std::vector<std::int64_t> &reordered_global_cell_indices)
Parameters:
  • mpi_comm
  • num_regular_cells
  • cell_type
  • shared_cells
  • cell_vertices
  • global_cell_indices
  • reordered_shared_cells
  • reordered_cell_vertices
  • reordered_global_cell_indices
void dolfin::MeshPartitioning::reorder_vertices_gps(MPI_Comm mpi_comm, const std::int32_t num_regular_vertices, const std::int32_t num_regular_cells, const int num_cell_vertices, const boost::multi_array<std::int64_t, 2> &cell_vertices, const std::vector<std::int64_t> &vertex_indices, const std::map<std::int64_t, std::int32_t> &vertex_global_to_local, std::vector<std::int64_t> &reordered_vertex_indices, std::map<std::int64_t, std::int32_t> &reordered_vertex_global_to_local)
Parameters:
  • mpi_comm
  • num_regular_vertices
  • num_regular_cells
  • num_cell_vertices
  • cell_vertices
  • vertex_indices
  • vertex_global_to_local
  • reordered_vertex_indices
  • reordered_vertex_global_to_local
MeshQuality

C++ documentation for MeshQuality from dolfin/mesh/MeshQuality.h:

class dolfin::MeshQuality

The class provides functions to quantify mesh quality.

void dolfin::MeshQuality::dihedral_angles(const Cell &cell, std::vector<double> &dh_angle)

Get internal dihedral angles of a tetrahedral cell.

Parameters:
  • cell
  • dh_angle
std::pair<std::vector<double>, std::vector<double>> dolfin::MeshQuality::dihedral_angles_histogram_data(const Mesh &mesh, std::size_t num_bins = 100)

Create (dihedral angles, number of cells) data for creating a histogram of dihedral

Parameters:
  • mesh
  • num_bins
std::string dolfin::MeshQuality::dihedral_angles_matplotlib_histogram(const Mesh &mesh, std::size_t num_intervals = 100)

Create Matplotlib string to plot dihedral angles quality histogram.

Parameters:
  • mesh
  • num_intervals
std::pair<double, double> dolfin::MeshQuality::dihedral_angles_min_max(const Mesh &mesh)

Get internal minimum and maximum dihedral angles of a 3D mesh.

Parameters:mesh
std::pair<std::vector<double>, std::vector<double>> dolfin::MeshQuality::radius_ratio_histogram_data(const Mesh &mesh, std::size_t num_bins = 50)

Create (ratio, number of cells) data for creating a histogram of cell quality

Parameters:
  • mesh – (const Mesh &)
  • num_bins – (std::size_t)
Returns:

std::pair<std::vector<double>, std::vector<double>>

std::string dolfin::MeshQuality::radius_ratio_matplotlib_histogram(const Mesh &mesh, std::size_t num_intervals = 50)

Create Matplotlib string to plot cell quality histogram

Parameters:
  • mesh – (const Mesh &)
  • num_intervals – (std::size_t)
Returns:

std::string

std::pair<double, double> dolfin::MeshQuality::radius_ratio_min_max(const Mesh &mesh)

Compute the minimum and maximum radius ratio of cells (across all processes)

Parameters:mesh – (const Mesh &)
Returns:std::pair<double, double> The [minimum, maximum] cell radii ratio (geometric_dimension * * inradius / circumradius, geometric_dimension is normalization factor). It has range zero to one. Zero indicates a degenerate element.
CellFunction<double> dolfin::MeshQuality::radius_ratios(std::shared_ptr<const Mesh> mesh)

Compute the radius ratio for all cells.

Parameters:mesh – (std::shared_ptr<const Mesh>)
Returns:CellFunction<double> The cell radius ratio radius ratio geometric_dimension * * inradius / circumradius (geometric_dimension is normalization factor). It has range zero to one. Zero indicates a degenerate element.
MeshRelation

C++ documentation for MeshRelation from dolfin/mesh/MeshRelation.h:

class dolfin::MeshRelation

MeshRelation encapsulates the relationships which may exist between two Meshes or which may exist in a Mesh as a result of being related to another Mesh

Friends: MeshHierarchy, PlazaRefinementND.

dolfin::MeshRelation::MeshRelation()

Constructor.

std::shared_ptr<const std::map<std::size_t, std::size_t>> dolfin::MeshRelation::edge_to_global_vertex
dolfin::MeshRelation::~MeshRelation()

Destructor.

MeshRenumbering

C++ documentation for MeshRenumbering from dolfin/mesh/MeshRenumbering.h:

class dolfin::MeshRenumbering

This class implements renumbering algorithms for meshes.

void dolfin::MeshRenumbering::compute_renumbering(const Mesh &mesh, const std::vector<std::size_t> &coloring, std::vector<double> &coordinates, std::vector<std::size_t> &connectivity)
Parameters:
  • mesh
  • coloring
  • coordinates
  • connectivity
Mesh dolfin::MeshRenumbering::renumber_by_color(const Mesh &mesh, std::vector<std::size_t> coloring)

Renumber mesh entities by coloring. This function is currently restricted to renumbering by cell coloring. The cells (cell-vertex connectivity) and the coordinates of the mesh are renumbered to improve the locality within each color. It is assumed that the mesh has already been colored and that only cell-vertex connectivity exists as part of the mesh.

Parameters:
  • mesh – (Mesh ) Mesh to be renumbered.
  • coloring – (std::vector<std::size_t>) Mesh coloring type.
Returns:

Mesh

MeshSmoothing

C++ documentation for MeshSmoothing from dolfin/mesh/MeshSmoothing.h:

class dolfin::MeshSmoothing

This class implements various mesh smoothing algorithms.

void dolfin::MeshSmoothing::move_interior_vertices(Mesh &mesh, BoundaryMesh &boundary, bool harmonic_smoothing)
Parameters:
  • mesh
  • boundary
  • harmonic_smoothing
void dolfin::MeshSmoothing::smooth(Mesh &mesh, std::size_t num_iterations = 1)

Smooth internal vertices of mesh by local averaging.

Parameters:
  • mesh
  • num_iterations
void dolfin::MeshSmoothing::smooth_boundary(Mesh &mesh, std::size_t num_iterations = 1, bool harmonic_smoothing = true)

Smooth boundary vertices of mesh by local averaging and (optionally) use harmonic smoothing on interior vertices

Parameters:
  • mesh
  • num_iterations
  • harmonic_smoothing
void dolfin::MeshSmoothing::snap_boundary(Mesh &mesh, const SubDomain &sub_domain, bool harmonic_smoothing = true)

Snap boundary vertices of mesh to match given sub domain and (optionally) use harmonic smoothing on interior vertices

Parameters:
  • mesh
  • sub_domain
  • harmonic_smoothing
MeshTopology

C++ documentation for MeshTopology from dolfin/mesh/MeshTopology.h:

class dolfin::MeshTopology

MeshTopology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relations for the mesh entities). Note that the mesh entities don’t need to be stored, only the number of entities and the connectivity. Any numbering scheme for the mesh entities is stored separately in a MeshFunction over the entities. A mesh entity e may be identified globally as a pair e = (dim, i), where dim is the topological dimension and i is the index of the entity within that topological dimension.

dolfin::MeshTopology::MeshTopology()

Create empty mesh topology.

dolfin::MeshTopology::MeshTopology(const MeshTopology &topology)

Copy constructor.

Parameters:topology
std::vector<unsigned int> &dolfin::MeshTopology::cell_owner()

Return mapping from local ghost cell index to owning process Since ghost cells are at the end of the range, this is just a vector over those cells

const std::vector<unsigned int> &dolfin::MeshTopology::cell_owner() const

Return mapping from local ghost cell index to owning process (const version) Since ghost cells are at the end of the range, this is just a vector over those cells

void dolfin::MeshTopology::clear()

Clear all data.

void dolfin::MeshTopology::clear(std::size_t d0, std::size_t d1)

Clear data for given pair of topological dimensions.

Parameters:
  • d0
  • d1
std::map<std::vector<std::size_t>, std::pair<std::vector<std::size_t>, std::vector<std::vector<std::size_t>>>> dolfin::MeshTopology::coloring

Mesh entity colors, if computed. First vector is (colored entity dim - dim1 - dim2 - ... - colored entity dim) The first vector in the pair stores mesh entity colors and the vector<vector> is a list of all mesh entity indices of the same color, e.g. vector<vector>[col][i] is the index of the ith entity of color ‘col’.

std::vector<std::vector<MeshConnectivity>> dolfin::MeshTopology::connectivity
std::size_t dolfin::MeshTopology::dim() const

Return topological dimension.

std::size_t dolfin::MeshTopology::ghost_offset(std::size_t dim) const

Return number of regular (non-ghost) entities or equivalently, the offset of where ghost entities begin

Parameters:dim
std::vector<std::size_t> dolfin::MeshTopology::ghost_offset_index
const std::vector<std::int64_t> &dolfin::MeshTopology::global_indices(std::size_t d) const

Get local-to-global index map for entities of topological dimension d

Parameters:d
std::vector<std::size_t> dolfin::MeshTopology::global_num_entities
size_t dolfin::MeshTopology::hash() const

Return hash based on the hash of cell-vertex connectivity.

bool dolfin::MeshTopology::have_global_indices(std::size_t dim) const

Check if global indices are available for entities of dimension dim

Parameters:dim
bool dolfin::MeshTopology::have_shared_entities(unsigned int dim) const

Check whether there are any shared entities calculated of dimension dim

Parameters:dim
void dolfin::MeshTopology::init(std::size_t dim)

Initialize topology of given maximum dimension.

Parameters:dim
void dolfin::MeshTopology::init(std::size_t dim, std::size_t local_size, std::size_t global_size)

Set number of local entities (local_size) and global entities (global_size) for given topological dimension dim

Parameters:
  • dim
  • local_size
  • global_size
void dolfin::MeshTopology::init_ghost(std::size_t dim, std::size_t index)

Initialise the offset index of ghost entities for this dimension.

Parameters:
  • dim
  • index
void dolfin::MeshTopology::init_global_indices(std::size_t dim, std::size_t size)

Initialize storage for global entity numbering for entities of dimension dim

Parameters:
  • dim
  • size
std::vector<unsigned int> dolfin::MeshTopology::num_entities
dolfin::MeshConnectivity &dolfin::MeshTopology::operator()(std::size_t d0, std::size_t d1)

Return connectivity for given pair of topological dimensions.

Parameters:
  • d0
  • d1
const dolfin::MeshConnectivity &dolfin::MeshTopology::operator()(std::size_t d0, std::size_t d1) const

Return connectivity for given pair of topological dimensions.

Parameters:
  • d0
  • d1
MeshTopology &dolfin::MeshTopology::operator=(const MeshTopology &topology)

Assignment.

Parameters:topology
void dolfin::MeshTopology::set_global_index(std::size_t dim, std::size_t local_index, std::int64_t global_index)

Set global index for entity of dimension dim and with local index

Parameters:
  • dim
  • local_index
  • global_index
std::map<std::int32_t, std::set<unsigned int>> &dolfin::MeshTopology::shared_entities(unsigned int dim)

Return map from shared entities (local index) to processes that share the entity

Parameters:dim
const std::map<std::int32_t, std::set<unsigned int>> &dolfin::MeshTopology::shared_entities(unsigned int dim) const

Return map from shared entities (local index) to process that share the entity (const version)

Parameters:dim
std::size_t dolfin::MeshTopology::size(std::size_t dim) const

Return number of entities for given dimension.

Parameters:dim
std::size_t dolfin::MeshTopology::size_global(std::size_t dim) const

Return global number of entities for given dimension.

Parameters:dim
std::string dolfin::MeshTopology::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
dolfin::MeshTopology::~MeshTopology()

Destructor.

MeshTransformation

C++ documentation for MeshTransformation from dolfin/mesh/MeshTransformation.h:

class dolfin::MeshTransformation

This class implements various transformations of the coordinates of a mesh.

void dolfin::MeshTransformation::rescale(Mesh &mesh, const double scale, const Point &center)

Rescale mesh by a given scaling factor with respect to a center point.

Parameters:
  • mesh – (Mesh ) The mesh
  • scale – (double) The scaling factor.
  • center – (Point ) The center of the scaling.
void dolfin::MeshTransformation::rotate(Mesh &mesh, double angle, std::size_t axis)

Rotate mesh around a coordinate axis through center of mass of all mesh vertices

Parameters:
  • mesh – (Mesh ) The mesh.
  • angle – (double) The number of degrees (0-360) of rotation.
  • axis – (std::size_t) The coordinate axis around which to rotate the mesh.
void dolfin::MeshTransformation::rotate(Mesh &mesh, double angle, std::size_t axis, const Point &p)

Rotate mesh around a coordinate axis through a given point

Parameters:
  • mesh – (Mesh ) The mesh.
  • angle – (double) The number of degrees (0-360) of rotation.
  • axis – (std::size_t) The coordinate axis around which to rotate the mesh.
  • p – (Point ) The point around which to rotate the mesh.
void dolfin::MeshTransformation::translate(Mesh &mesh, const Point &point)

Translate mesh according to a given vector.

Parameters:
  • mesh – (Mesh ) The mesh
  • point – (Point ) The vector defining the translation.
MultiMesh

C++ documentation for MultiMesh from dolfin/mesh/MultiMesh.h:

class dolfin::MultiMesh

This class represents a collection of meshes with arbitrary overlaps. A multimesh may be created from a set of standard meshes spaces by repeatedly calling add , followed by a call to build . Note that a multimesh is not useful until build has been called.

Friends: plot().

dolfin::MultiMesh::MultiMesh()

Create empty multimesh.

dolfin::MultiMesh::MultiMesh(std::shared_ptr<const Mesh> mesh_0, std::shared_ptr<const Mesh> mesh_1, std::shared_ptr<const Mesh> mesh_2, std::size_t quadrature_order)

Create multimesh from three meshes.

Parameters:
  • mesh_0
  • mesh_1
  • mesh_2
  • quadrature_order
dolfin::MultiMesh::MultiMesh(std::shared_ptr<const Mesh> mesh_0, std::shared_ptr<const Mesh> mesh_1, std::size_t quadrature_order)

Create multimesh from two meshes.

Parameters:
  • mesh_0
  • mesh_1
  • quadrature_order
dolfin::MultiMesh::MultiMesh(std::shared_ptr<const Mesh> mesh_0, std::size_t quadrature_order)

Create multimesh from one mesh.

Parameters:
  • mesh_0
  • quadrature_order
dolfin::MultiMesh::MultiMesh(std::vector<std::shared_ptr<const Mesh>> meshes, std::size_t quadrature_order)

Create multimesh from given list of meshes.

Parameters:
  • meshes
  • quadrature_order
void dolfin::MultiMesh::add(std::shared_ptr<const Mesh> mesh)

Add mesh Arguments mesh (Mesh ) The mesh

Parameters:mesh
std::shared_ptr<const BoundingBoxTree> dolfin::MultiMesh::bounding_box_tree(std::size_t part) const

Return the bounding box tree for the mesh of the given part Arguments part (std::size_t) The part number Returns std::shared_ptr<const BoundingBoxTree> The bounding box tree

Parameters:part
std::shared_ptr<const BoundingBoxTree> dolfin::MultiMesh::bounding_box_tree_boundary(std::size_t part) const

Return the bounding box tree for the boundary mesh of the given part Arguments part (std::size_t) The part number Returns std::shared_ptr<const BoundingBoxTree> The bounding box tree

Parameters:part
void dolfin::MultiMesh::build(std::size_t quadrature_order = 2)

Build multimesh.

Parameters:quadrature_order
void dolfin::MultiMesh::clear()

Clear multimesh.

const std::map<unsigned int, std::vector<std::pair<std::size_t, unsigned int>>> &dolfin::MultiMesh::collision_map_cut_cells(std::size_t part) const

Return the collision map for cut cells of the given part Arguments part (std::size_t) The part number Returns std::map<unsigned int, std::vector<std::pair<std::size_t, unsigned int> > > A map from cell indices of cut cells to a list of cutting cells. Each cutting cell is represented as a pair (part_number, cutting_cell_index).

Parameters:part
const std::vector<unsigned int> &dolfin::MultiMesh::covered_cells(std::size_t part) const

Return the list of covered cells for given part. The covered cells are defined as all cells that collide with the domain of any part with higher part number, but not with the boundary of that part; in other words cells that are completely covered by any other part (and which therefore are inactive). Arguments part (std::size_t) The part number Returns std::vector<unsigned int> List of covered cell indices for given part

Parameters:part
const std::vector<unsigned int> &dolfin::MultiMesh::cut_cells(std::size_t part) const

Return the list of cut cells for given part. The cut cells are defined as all cells that collide with the boundary of any part with higher part number. FIXME: Figure out whether this makes sense; a cell may collide with the boundary of part j but may still be covered completely by the domain of part j + 1. Possible solution is to for each part i check overlapping parts starting from the top and working back down to i + 1. Arguments part (std::size_t) The part number Returns std::vector<unsigned int> List of cut cell indices for given part

Parameters:part
const std::map<unsigned int, std::vector<std::vector<double>>> &dolfin::MultiMesh::facet_normals(std::size_t part) const

Return facet normals for the interface on the given part Arguments part (std::size_t) The part number Returns std::map<unsigned int, std::vector<std::vector<double> > > A map from cell indices of cut cells to facet normals on an interface part cutting through the cell. A separate list of facet normals, one for each quadrature point, is given for each cutting cell and stored in the same order as in the collision map. The facet normals for each set of quadrature points is stored as a contiguous flattened array, the length of which should be equal to the number of quadrature points multiplied by the geometric dimension. Puh!

Parameters:part
std::size_t dolfin::MultiMesh::num_parts() const

Return the number of meshes (parts) of the multimesh Returns std::size_t The number of meshes (parts) of the multimesh.

std::shared_ptr<const Mesh> dolfin::MultiMesh::part(std::size_t i) const

Return mesh (part) number i Arguments i (std::size_t) The part number Returns:cpp:any:Mesh Mesh (part) number i

Parameters:i
quadrature_rule dolfin::MultiMesh::quadrature_rule_cut_cell(std::size_t part, unsigned int cell_index) const

Return quadrature rule for a given cut cell on the given part Arguments part (std::size_t) The part number cell (unsigned int) The cell index Returns std::pair<std::vector<double>, std::vector<double> > A quadrature rule represented as a pair of a flattened array of quadrature points and a corresponding array of quadrature weights. An error is raised if the given cell is not in the map. Developer note: this function is mainly useful from Python and could be replaced by a suitable typemap that would make the previous more general function accessible from Python.

Parameters:
  • part
  • cell_index
const std::map<unsigned int, quadrature_rule> &dolfin::MultiMesh::quadrature_rule_cut_cells(std::size_t part) const

Return quadrature rules for cut cells on the given part Arguments part (std::size_t) The part number Returns std::map<unsigned int, std::pair<std::vector<double>, std::vector<double> > > A map from cell indices of cut cells to quadrature rules. Each quadrature rule is represented as a pair of a flattened array of quadrature points and a corresponding array of quadrature weights.

Parameters:part
const std::map<unsigned int, std::vector<quadrature_rule>> &dolfin::MultiMesh::quadrature_rule_interface(std::size_t part) const

Return quadrature rules for the interface on the given part Arguments part (std::size_t) The part number Returns std::map<unsigned int, std::pair<std::vector<double>, std::vector<double> > > A map from cell indices of cut cells to quadrature rules on an interface part cutting through the cell. A separate quadrature rule is given for each cutting cell and stored in the same order as in the collision map. Each quadrature rule is represented as a pair of an array of quadrature points and a corresponding flattened array of quadrature weights.

Parameters:part
const std::map<unsigned int, std::vector<quadrature_rule>> &dolfin::MultiMesh::quadrature_rule_overlap(std::size_t part) const

Return quadrature rules for the overlap on the given part. Arguments part (std::size_t) The part number Returns std::map<unsigned int, std::pair<std::vector<double>, std::vector<double> > > A map from cell indices of cut cells to quadrature rules. A separate quadrature rule is given for each cutting cell and stored in the same order as in the collision map. Each quadrature rule is represented as a pair of an array of quadrature points and a corresponding flattened array of quadrature weights.

Parameters:part
const std::vector<unsigned int> &dolfin::MultiMesh::uncut_cells(std::size_t part) const

Return the list of uncut cells for given part. The uncut cells are defined as all cells that don’t collide with any cells in any other part with higher part number. Arguments part (std::size_t) The part number Returns std::vector<unsigned int> List of uncut cell indices for given part

Parameters:part
dolfin::MultiMesh::~MultiMesh()

Destructor.

PeriodicBoundaryComputation

C++ documentation for PeriodicBoundaryComputation from dolfin/mesh/PeriodicBoundaryComputation.h:

class dolfin::PeriodicBoundaryComputation

This class computes map from slave entity to master entity.

std::map<unsigned int, std::pair<unsigned int, unsigned int>> dolfin::PeriodicBoundaryComputation::compute_periodic_pairs(const Mesh &mesh, const SubDomain &sub_domain, const std::size_t dim)

For entities of dimension dim, compute map from a slave entity on this process (local index) to its master entity (owning process, local index on owner). If a master entity is shared by processes, only one of the owning processes is returned.

Parameters:
  • mesh
  • sub_domain
  • dim
bool dolfin::PeriodicBoundaryComputation::in_bounding_box(const std::vector<double> &point, const std::vector<double> &bounding_box, const double tol)
Parameters:
  • point
  • bounding_box
  • tol
MeshFunction<std::size_t> dolfin::PeriodicBoundaryComputation::masters_slaves(std::shared_ptr<const Mesh> mesh, const SubDomain &sub_domain, const std::size_t dim)

This function returns a MeshFunction which marks mesh entities of dimension dim according to:

2: slave entities
1: master entities
0: all other entities

It is useful for visualising and debugging the Expression::map function that is used to apply periodic boundary conditions.

Parameters:
  • mesh
  • sub_domain
  • dim
PointCell

C++ documentation for PointCell from dolfin/mesh/PointCell.h:

class dolfin::PointCell

This class implements functionality for triangular meshes.

dolfin::PointCell::PointCell()

Specify cell type and facet type.

Point dolfin::PointCell::cell_normal(const Cell &cell) const

Compute normal to given cell (viewed as embedded in 1D)

Parameters:cell
double dolfin::PointCell::circumradius(const MeshEntity &point) const

Compute circumradius of PointCell .

Parameters:point
bool dolfin::PointCell::collides(const Cell &cell, const MeshEntity &entity) const

Check whether given entity collides with cell.

Parameters:
  • cell
  • entity
bool dolfin::PointCell::collides(const Cell &cell, const Point &point) const

Check whether given point is contained in cell.

Parameters:
  • cell
  • point
void dolfin::PointCell::create_entities(boost::multi_array<unsigned int, 2> &e, std::size_t dim, const unsigned int *v) const

Create entities e of given topological dimension from vertices v.

Parameters:
  • e
  • dim
  • v
std::string dolfin::PointCell::description(bool plural) const

Return description of cell type.

Parameters:plural
std::size_t dolfin::PointCell::dim() const

Return topological dimension of cell.

double dolfin::PointCell::facet_area(const Cell &cell, std::size_t facet) const

Compute the area/length of given facet with respect to the cell

Parameters:
  • cell
  • facet
std::size_t dolfin::PointCell::find_edge(std::size_t i, const Cell &cell) const
Parameters:
  • i
  • cell
Point dolfin::PointCell::normal(const Cell &cell, std::size_t facet) const

Compute of given facet with respect to the cell.

Parameters:
  • cell
  • facet
double dolfin::PointCell::normal(const Cell &cell, std::size_t facet, std::size_t i) const

Compute component i of normal of given facet with respect to the cell

Parameters:
  • cell
  • facet
  • i
std::size_t dolfin::PointCell::num_entities(std::size_t dim) const

Return number of entities of given topological dimension.

Parameters:dim
std::size_t dolfin::PointCell::num_vertices(std::size_t dim) const

Return number of vertices for entity of given topological dimension

Parameters:dim
void dolfin::PointCell::order(Cell &cell) const

Order entities locally.

Parameters:cell
void dolfin::PointCell::order(Cell &cell, const std::vector<std::int64_t> &local_to_global_vertex_indices) const

Order entities locally (connectivity 1-0, 2-0, 2-1)

Parameters:
  • cell
  • local_to_global_vertex_indices
std::size_t dolfin::PointCell::orientation(const Cell &cell) const

Return orientation of the cell.

Parameters:cell
double dolfin::PointCell::squared_distance(const Cell &cell, const Point &point) const

Compute squared distance to given point.

Parameters:
  • cell
  • point
std::vector<double> dolfin::PointCell::triangulate_intersection(const Cell &c0, const Cell &c1) const

Compute triangulation of intersection of two cells.

Parameters:
  • c0
  • c1
double dolfin::PointCell::volume(const MeshEntity &triangle) const

Compute (generalized) volume (area) of triangle.

Parameters:triangle
std::vector<std::int8_t> dolfin::PointCell::vtk_mapping() const

Mapping of DOLFIN/UFC vertex ordering to VTK/XDMF ordering.

QuadrilateralCell

C++ documentation for QuadrilateralCell from dolfin/mesh/QuadrilateralCell.h:

class dolfin::QuadrilateralCell

This class implements functionality for triangular meshes.

dolfin::QuadrilateralCell::QuadrilateralCell()

Specify cell type and facet type.

Point dolfin::QuadrilateralCell::cell_normal(const Cell &cell) const

Compute normal to given cell (viewed as embedded in 3D)

Parameters:cell
double dolfin::QuadrilateralCell::circumradius(const MeshEntity &triangle) const

Compute circumradius of triangle.

Parameters:triangle
bool dolfin::QuadrilateralCell::collides(const Cell &cell, const MeshEntity &entity) const

Check whether given entity collides with cell.

Parameters:
  • cell
  • entity
bool dolfin::QuadrilateralCell::collides(const Cell &cell, const Point &point) const

Check whether given point collides with cell.

Parameters:
  • cell
  • point
void dolfin::QuadrilateralCell::create_entities(boost::multi_array<unsigned int, 2> &e, std::size_t dim, const unsigned int *v) const

Create entities e of given topological dimension from vertices v.

Parameters:
  • e
  • dim
  • v
std::string dolfin::QuadrilateralCell::description(bool plural) const

Return description of cell type.

Parameters:plural
std::size_t dolfin::QuadrilateralCell::dim() const

Return topological dimension of cell.

double dolfin::QuadrilateralCell::facet_area(const Cell &cell, std::size_t facet) const

Compute the area/length of given facet with respect to the cell.

Parameters:
  • cell
  • facet
Point dolfin::QuadrilateralCell::normal(const Cell &cell, std::size_t facet) const

Compute of given facet with respect to the cell.

Parameters:
  • cell
  • facet
double dolfin::QuadrilateralCell::normal(const Cell &cell, std::size_t facet, std::size_t i) const

Compute component i of normal of given facet with respect to the cell.

Parameters:
  • cell
  • facet
  • i
std::size_t dolfin::QuadrilateralCell::num_entities(std::size_t dim) const

Return number of entities of given topological dimension.

Parameters:dim
std::size_t dolfin::QuadrilateralCell::num_vertices(std::size_t dim) const

Return number of vertices for entity of given topological dimension.

Parameters:dim
void dolfin::QuadrilateralCell::order(Cell &cell, const std::vector<std::int64_t> &local_to_global_vertex_indices) const

Order entities locally.

Parameters:
  • cell
  • local_to_global_vertex_indices
std::size_t dolfin::QuadrilateralCell::orientation(const Cell &cell) const

Return orientation of the cell.

Parameters:cell
double dolfin::QuadrilateralCell::squared_distance(const Cell &cell, const Point &point) const

Compute squared distance to given point (3D enabled)

Parameters:
  • cell
  • point
std::vector<double> dolfin::QuadrilateralCell::triangulate_intersection(const Cell &c0, const Cell &c1) const

Compute triangulation of intersection of two cells.

Parameters:
  • c0
  • c1
double dolfin::QuadrilateralCell::volume(const MeshEntity &triangle) const

Compute (generalized) volume (area) of triangle.

Parameters:triangle
std::vector<std::int8_t> dolfin::QuadrilateralCell::vtk_mapping() const

Mapping of DOLFIN/UFC vertex ordering to VTK/XDMF ordering.

SubDomain

C++ documentation for SubDomain from dolfin/mesh/SubDomain.h:

class dolfin::SubDomain

This class defines the interface for definition of subdomains. Alternatively, subdomains may be defined by a Mesh and a MeshFunction<std::size_t> over the mesh.

Friends: DirichletBC, PeriodicBC.

dolfin::SubDomain::SubDomain(const double map_tol = 1.0e-10)

Constructor

Parameters:map_tol – (double) The tolerance used when identifying mapped points using the function SubDomain::map .
void dolfin::SubDomain::apply_markers(S &sub_domains, T sub_domain, const Mesh &mesh, bool check_midpoint) const

Apply marker of type T (most likely an std::size_t) to object of class S (most likely MeshFunction or MeshValueCollection )

Parameters:
  • sub_domains
  • sub_domain
  • mesh
  • check_midpoint
void dolfin::SubDomain::apply_markers(std::map<std::size_t, std::size_t> &sub_domains, std::size_t dim, T sub_domain, const Mesh &mesh, bool check_midpoint) const
Parameters:
  • sub_domains
  • dim
  • sub_domain
  • mesh
  • check_midpoint
std::size_t dolfin::SubDomain::geometric_dimension() const

Return geometric dimension

Returns:std::size_t The geometric dimension.
bool dolfin::SubDomain::inside(const Array<double> &x, bool on_boundary) const

Return true for points inside the subdomain

Parameters:
  • x – (Array<double>) The coordinates of the point.
  • on_boundary – (bool) True for points on the boundary.
Returns:

bool True for points inside the subdomain.

void dolfin::SubDomain::map(const Array<double> &x, Array<double> &y) const

Map coordinate x in domain H to coordinate y in domain G (used for periodic boundary conditions)

Parameters:
  • x – (Array<double>) The coordinates in domain H.
  • y – (Array<double>) The coordinates in domain G.
const double dolfin::SubDomain::map_tolerance

Return tolerance uses to find matching point via map function

Returns:double The tolerance.
void dolfin::SubDomain::mark(Mesh &mesh, std::size_t dim, std::size_t sub_domain, bool check_midpoint = true) const

Set subdomain markers (std::size_t) for given topological dimension and subdomain number

Parameters:
  • mesh – (Mesh ) The mesh to be marked.
  • dim – (std::size_t) The topological dimension of entities to be marked.
  • sub_domain – (std::size_t) The subdomain number.
  • check_midpoint – (bool) Flag for whether midpoint of cell should be checked (default).
void dolfin::SubDomain::mark(MeshFunction<bool> &sub_domains, bool sub_domain, bool check_midpoint = true) const

Set subdomain markers (bool) for given subdomain

Parameters:
  • sub_domains – (MeshFunction<bool>) The subdomain markers.
  • sub_domain – (bool) The subdomain number.
  • check_midpoint – (bool) Flag for whether midpoint of cell should be checked (default).
void dolfin::SubDomain::mark(MeshFunction<double> &sub_domains, double sub_domain, bool check_midpoint = true) const

Set subdomain markers (double) for given subdomain number

Parameters:
  • sub_domains – (MeshFunction<double>) The subdomain markers.
  • sub_domain – (double) The subdomain number.
  • check_midpoint – (bool) Flag for whether midpoint of cell should be checked (default).
void dolfin::SubDomain::mark(MeshFunction<int> &sub_domains, int sub_domain, bool check_midpoint = true) const

Set subdomain markers (int) for given subdomain number

Parameters:
  • sub_domains – (MeshFunction<int>) The subdomain markers.
  • sub_domain – (int) The subdomain number.
  • check_midpoint – (bool) Flag for whether midpoint of cell should be checked (default).
void dolfin::SubDomain::mark(MeshFunction<std::size_t> &sub_domains, std::size_t sub_domain, bool check_midpoint = true) const

Set subdomain markers (std::size_t) for given subdomain number

Parameters:
  • sub_domains – (MeshFunction<std::size_t>) The subdomain markers.
  • sub_domain – (std::size_t) The subdomain number.
  • check_midpoint – (bool) Flag for whether midpoint of cell should be checked (default).
void dolfin::SubDomain::mark(MeshValueCollection<bool> &sub_domains, bool sub_domain, const Mesh &mesh, bool check_midpoint = true) const

Set subdomain markers (bool) for given subdomain

Parameters:
  • sub_domains – (MeshValueCollection<bool>) The subdomain markers
  • sub_domain – (bool) The subdomain number
  • mesh – (Mesh ) The mesh.
  • check_midpoint – (bool) Flag for whether midpoint of cell should be checked (default).
void dolfin::SubDomain::mark(MeshValueCollection<double> &sub_domains, double sub_domain, const Mesh &mesh, bool check_midpoint = true) const

Set subdomain markers (double) for given subdomain number

Parameters:
  • sub_domains – (MeshValueCollection<double>) The subdomain markers.
  • sub_domain – (double) The subdomain number
  • mesh – (Mesh ) The mesh.
  • check_midpoint – (bool) Flag for whether midpoint of cell should be checked (default).
void dolfin::SubDomain::mark(MeshValueCollection<int> &sub_domains, int sub_domain, const Mesh &mesh, bool check_midpoint = true) const

Set subdomain markers (int) for given subdomain number

Parameters:
  • sub_domains – (MeshValueCollection<int>) The subdomain markers
  • sub_domain – (int) The subdomain number
  • mesh – (Mesh ) The mesh.
  • check_midpoint – (bool) Flag for whether midpoint of cell should be checked (default).
void dolfin::SubDomain::mark(MeshValueCollection<std::size_t> &sub_domains, std::size_t sub_domain, const Mesh &mesh, bool check_midpoint = true) const

Set subdomain markers (std::size_t) for given subdomain number

Parameters:
  • sub_domains – (MeshValueCollection<std::size_t>) The subdomain markers.
  • sub_domain – (std::size_t) The subdomain number.
  • mesh – (Mesh ) The mesh.
  • check_midpoint – (bool) Flag for whether midpoint of cell should be checked (default).
void dolfin::SubDomain::mark_cells(Mesh &mesh, std::size_t sub_domain, bool check_midpoint = true) const

Set subdomain markers (std::size_t) on cells for given subdomain number

Parameters:
  • mesh – (Mesh ) The mesh to be marked.
  • sub_domain – (std::size_t) The subdomain number.
  • check_midpoint – (bool) Flag for whether midpoint of cell should be checked (default).
void dolfin::SubDomain::mark_facets(Mesh &mesh, std::size_t sub_domain, bool check_midpoint = true) const

Set subdomain markers (std::size_t) on facets for given subdomain number

Parameters:
  • mesh – (Mesh ) The mesh to be marked.
  • sub_domain – (std::size_t) The subdomain number.
  • check_midpoint – (bool) Flag for whether midpoint of cell should be checked (default).
void dolfin::SubDomain::snap(Array<double> &x) const

Snap coordinate to boundary of subdomain

Parameters:x – (Array<double>) The coordinates.
dolfin::SubDomain::~SubDomain()

Destructor.

SubMesh

C++ documentation for SubMesh from dolfin/mesh/SubMesh.h:

class dolfin::SubMesh : public dolfin::Mesh

A SubMesh is a mesh defined as a subset of a given mesh. It provides a convenient way to create matching meshes for multiphysics applications by creating meshes for subdomains as subsets of a single global mesh. A mapping from the vertices of the sub mesh to the vertices of the parent mesh is stored as the mesh data named “parent_vertex_indices”.

dolfin::SubMesh::SubMesh(const Mesh &mesh, const MeshFunction<std::size_t> &sub_domains, std::size_t sub_domain)

Create subset of given mesh marked by mesh function.

Parameters:
  • mesh
  • sub_domains
  • sub_domain
dolfin::SubMesh::SubMesh(const Mesh &mesh, const SubDomain &sub_domain)

Create subset of given mesh marked by sub domain.

Parameters:
  • mesh
  • sub_domain
dolfin::SubMesh::SubMesh(const Mesh &mesh, std::size_t sub_domain)

Create subset of given mesh from stored MeshValueCollection .

Parameters:
  • mesh
  • sub_domain
void dolfin::SubMesh::init(const Mesh &mesh, const std::vector<std::size_t> &sub_domains, std::size_t sub_domain)

Create sub mesh.

Parameters:
  • mesh
  • sub_domains
  • sub_domain
dolfin::SubMesh::~SubMesh()

Destructor.

SubsetIterator

C++ documentation for SubsetIterator from dolfin/mesh/SubsetIterator.h:

class dolfin::SubsetIterator

A SubsetIterator is similar to a MeshEntityIterator but iterates over a specified subset of the range of entities as specified by a MeshFunction that labels the entities.

dolfin::SubsetIterator::SubsetIterator(const MeshFunction<std::size_t> &labels, std::size_t label)

Create iterator for given mesh function. The iterator visits all entities that match the given label.

Parameters:
  • labels
  • label
dolfin::SubsetIterator::SubsetIterator(const SubsetIterator &subset_iter)

Copy Constructor.

Parameters:subset_iter
bool dolfin::SubsetIterator::end() const

Check if iterator has reached the end.

SubsetIterator dolfin::SubsetIterator::end_iterator()

Beyond end iterator.

std::vector<std::size_t>::iterator dolfin::SubsetIterator::it
bool dolfin::SubsetIterator::operator!=(const SubsetIterator &sub_iter) const

Comparison operator.

Parameters:sub_iter
MeshEntity &dolfin::SubsetIterator::operator*()

Dereference operator.

SubsetIterator &dolfin::SubsetIterator::operator++()

Step to next mesh entity (prefix increment)

MeshEntity *dolfin::SubsetIterator::operator->()

Member access operator.

bool dolfin::SubsetIterator::operator==(const SubsetIterator &sub_iter) const

Comparison operator.

Parameters:sub_iter
void dolfin::SubsetIterator::set_end()

Set pos to end position. To create a kind of mesh.end() iterator.

std::vector<std::size_t> &dolfin::SubsetIterator::subset
dolfin::SubsetIterator::~SubsetIterator()

Destructor.

TetrahedronCell

C++ documentation for TetrahedronCell from dolfin/mesh/TetrahedronCell.h:

class dolfin::TetrahedronCell

This class implements functionality for tetrahedral meshes.

dolfin::TetrahedronCell::TetrahedronCell()

Specify cell type and facet type.

Point dolfin::TetrahedronCell::cell_normal(const Cell &cell) const

Compute normal to given cell (viewed as embedded in 4D ...)

Parameters:cell
double dolfin::TetrahedronCell::circumradius(const MeshEntity &tetrahedron) const

Compute circumradius of tetrahedron.

Parameters:tetrahedron
bool dolfin::TetrahedronCell::collides(const Cell &cell, const MeshEntity &entity) const

Check whether given entity collides with cell.

Parameters:
  • cell
  • entity
bool dolfin::TetrahedronCell::collides(const Cell &cell, const Point &point) const

Check whether given point collides with cell.

Parameters:
  • cell
  • point
void dolfin::TetrahedronCell::create_entities(boost::multi_array<unsigned int, 2> &e, std::size_t dim, const unsigned int *v) const

Create entities e of given topological dimension from vertices v.

Parameters:
  • e
  • dim
  • v
std::string dolfin::TetrahedronCell::description(bool plural) const

Return description of cell type.

Parameters:plural
std::size_t dolfin::TetrahedronCell::dim() const

Return topological dimension of cell.

double dolfin::TetrahedronCell::facet_area(const Cell &cell, std::size_t facet) const

Compute the area/length of given facet with respect to the cell.

Parameters:
  • cell
  • facet
std::size_t dolfin::TetrahedronCell::find_edge(std::size_t i, const Cell &cell) const
Parameters:
  • i
  • cell
Point dolfin::TetrahedronCell::normal(const Cell &cell, std::size_t facet) const

Compute normal of given facet with respect to the cell.

Parameters:
  • cell
  • facet
double dolfin::TetrahedronCell::normal(const Cell &cell, std::size_t facet, std::size_t i) const

Compute component i of normal of given facet with respect to the cell

Parameters:
  • cell
  • facet
  • i
std::size_t dolfin::TetrahedronCell::num_entities(std::size_t dim) const

Return number of entities of given topological dimension.

Parameters:dim
std::size_t dolfin::TetrahedronCell::num_vertices(std::size_t dim) const

Return number of vertices for entity of given topological dimension.

Parameters:dim
void dolfin::TetrahedronCell::order(Cell &cell, const std::vector<std::int64_t> &local_to_global_vertex_indices) const

Order entities locally.

Parameters:
  • cell
  • local_to_global_vertex_indices
std::size_t dolfin::TetrahedronCell::orientation(const Cell &cell) const

Return orientation of the cell.

Parameters:cell
bool dolfin::TetrahedronCell::point_outside_of_plane(const Point &point, const Point &A, const Point &B, const Point &C, const Point &D) const
Parameters:
  • point
  • A
  • B
  • C
  • D
double dolfin::TetrahedronCell::squared_distance(const Cell &cell, const Point &point) const

Compute squared distance to given point.

Parameters:
  • cell
  • point
std::vector<double> dolfin::TetrahedronCell::triangulate_intersection(const Cell &c0, const Cell &c1) const

Compute triangulation of intersection of two cells.

Parameters:
  • c0
  • c1
double dolfin::TetrahedronCell::volume(const MeshEntity &tetrahedron) const

Compute volume of tetrahedron.

Parameters:tetrahedron
std::vector<std::int8_t> dolfin::TetrahedronCell::vtk_mapping() const

Mapping of DOLFIN/UFC vertex ordering to VTK/XDMF ordering.

TopologyComputation

C++ documentation for TopologyComputation from dolfin/mesh/TopologyComputation.h:

class dolfin::TopologyComputation

This class implements a set of basic algorithms that automate the computation of mesh entities and connectivity.

void dolfin::TopologyComputation::compute_connectivity(Mesh &mesh, std::size_t d0, std::size_t d1)

Compute connectivity for given pair of topological dimensions.

Parameters:
  • mesh
  • d0
  • d1
std::size_t dolfin::TopologyComputation::compute_entities(Mesh &mesh, std::size_t dim)

Compute mesh entities of given topological dimension, and connectivity cell-to-enity (tdim, dim)

Parameters:
  • mesh
  • dim
std::int32_t dolfin::TopologyComputation::compute_entities_by_key_matching(Mesh &mesh, int dim)
Parameters:
  • mesh
  • dim
std::size_t dolfin::TopologyComputation::compute_entities_old(Mesh &mesh, std::size_t dim)

Compute mesh entities of given topological dimension. Note: this function will be replaced by the new ‘compute_entities’ function, which is considerably faster, especially for poorly ordered mesh.

Parameters:
  • mesh
  • dim
void dolfin::TopologyComputation::compute_from_intersection(Mesh &mesh, std::size_t d0, std::size_t d1, std::size_t d)
Parameters:
  • mesh
  • d0
  • d1
  • d
void dolfin::TopologyComputation::compute_from_map(Mesh &mesh, std::size_t d0, std::size_t d1)
Parameters:
  • mesh
  • d0
  • d1
void dolfin::TopologyComputation::compute_from_transpose(Mesh &mesh, std::size_t d0, std::size_t d1)
Parameters:
  • mesh
  • d0
  • d1
TriangleCell

C++ documentation for TriangleCell from dolfin/mesh/TriangleCell.h:

class dolfin::TriangleCell

This class implements functionality for triangular meshes.

dolfin::TriangleCell::TriangleCell()

Specify cell type and facet type.

Point dolfin::TriangleCell::cell_normal(const Cell &cell) const

Compute normal to given cell (viewed as embedded in 3D)

Parameters:cell
double dolfin::TriangleCell::circumradius(const MeshEntity &triangle) const

Compute diameter of triangle.

Parameters:triangle
bool dolfin::TriangleCell::collides(const Cell &cell, const MeshEntity &entity) const

Check whether given entity collides with cell.

Parameters:
  • cell
  • entity
bool dolfin::TriangleCell::collides(const Cell &cell, const Point &point) const

Check whether given point collides with cell.

Parameters:
  • cell
  • point
void dolfin::TriangleCell::create_entities(boost::multi_array<unsigned int, 2> &e, std::size_t dim, const unsigned int *v) const

Create entities e of given topological dimension from vertices v.

Parameters:
  • e
  • dim
  • v
std::string dolfin::TriangleCell::description(bool plural) const

Return description of cell type.

Parameters:plural
std::size_t dolfin::TriangleCell::dim() const

Return topological dimension of cell.

double dolfin::TriangleCell::facet_area(const Cell &cell, std::size_t facet) const

Compute the area/length of given facet with respect to the cell.

Parameters:
  • cell
  • facet
std::size_t dolfin::TriangleCell::find_edge(std::size_t i, const Cell &cell) const
Parameters:
  • i
  • cell
Point dolfin::TriangleCell::normal(const Cell &cell, std::size_t facet) const

Compute of given facet with respect to the cell.

Parameters:
  • cell
  • facet
double dolfin::TriangleCell::normal(const Cell &cell, std::size_t facet, std::size_t i) const

Compute component i of normal of given facet with respect to the cell.

Parameters:
  • cell
  • facet
  • i
std::size_t dolfin::TriangleCell::num_entities(std::size_t dim) const

Return number of entities of given topological dimension.

Parameters:dim
std::size_t dolfin::TriangleCell::num_vertices(std::size_t dim) const

Return number of vertices for entity of given topological dimension.

Parameters:dim
void dolfin::TriangleCell::order(Cell &cell, const std::vector<std::int64_t> &local_to_global_vertex_indices) const

Order entities locally.

Parameters:
  • cell
  • local_to_global_vertex_indices
std::size_t dolfin::TriangleCell::orientation(const Cell &cell) const

Return orientation of the cell.

Parameters:cell
double dolfin::TriangleCell::squared_distance(const Cell &cell, const Point &point) const

Compute squared distance to given point (3D enabled)

Parameters:
  • cell
  • point
double dolfin::TriangleCell::squared_distance(const Point &point, const Point &a, const Point &b, const Point &c)

Compute squared distance to given point. This version takes the three vertex coordinates as 3D points. This makes it possible to reuse this function for computing the (squared) distance to a tetrahedron.

Parameters:
  • point
  • a
  • b
  • c
std::vector<double> dolfin::TriangleCell::triangulate_intersection(const Cell &c0, const Cell &c1) const

Compute triangulation of intersection of two cells.

Parameters:
  • c0
  • c1
double dolfin::TriangleCell::volume(const MeshEntity &triangle) const

Compute (generalized) volume (area) of triangle.

Parameters:triangle
std::vector<std::int8_t> dolfin::TriangleCell::vtk_mapping() const

Mapping of DOLFIN/UFC vertex ordering to VTK/XDMF ordering.

Vertex

C++ documentation for Vertex from dolfin/mesh/Vertex.h:

class dolfin::Vertex

A Vertex is a MeshEntity of topological dimension 0.

dolfin::Vertex::Vertex(MeshEntity &entity)

Create vertex from mesh entity.

Parameters:entity
dolfin::Vertex::Vertex(const Mesh &mesh, std::size_t index)

Create vertex on given mesh.

Parameters:
  • mesh
  • index
Point dolfin::Vertex::point() const

Return vertex coordinates as a 3D point value.

const double *dolfin::Vertex::x() const

Return array of vertex coordinates (const version)

double dolfin::Vertex::x(std::size_t i) const

Return value of vertex coordinate i.

Parameters:i
dolfin::Vertex::~Vertex()

Destructor.

VertexFunction

C++ documentation for VertexFunction from dolfin/mesh/Vertex.h:

class dolfin::VertexFunction : public dolfin::MeshFunction<T>, dolfin::VertexFunction<T>

A VertexFunction is a MeshFunction of topological dimension 0.

dolfin::VertexFunction::VertexFunction(std::shared_ptr<const Mesh> mesh)

Constructor on Mesh .

Parameters:mesh
dolfin::VertexFunction::VertexFunction(std::shared_ptr<const Mesh> mesh, const T &value)

Constructor on Mesh and value.

Parameters:
  • mesh
  • value

dolfin/multistage

Documentation for C++ code found in dolfin/multistage/*.h

Classes

MultiStageScheme

C++ documentation for MultiStageScheme from dolfin/multistage/MultiStageScheme.h:

class dolfin::MultiStageScheme

Place-holder for forms and solutions for a multi-stage Butcher tableau based method.

dolfin::MultiStageScheme::MultiStageScheme(std::vector<std::vector<std::shared_ptr<const Form>>> stage_forms, std::shared_ptr<const Form> last_stage, std::vector<std::shared_ptr<Function>> stage_solutions, std::shared_ptr<Function> u, std::shared_ptr<Constant> t, std::shared_ptr<Constant> dt, std::vector<double> dt_stage_offset, std::vector<int> jacobian_indices, unsigned int order, const std::string name, const std::string human_form, std::vector<std::shared_ptr<const DirichletBC>> bcs = {})

Constructor.

Parameters:
  • stage_forms
  • last_stage
  • stage_solutions
  • u
  • t
  • dt
  • dt_stage_offset
  • jacobian_indices
  • order
  • name
  • human_form
  • bcs
std::vector<std::shared_ptr<const DirichletBC>> dolfin::MultiStageScheme::bcs() const

Return boundary conditions.

std::shared_ptr<Constant> dolfin::MultiStageScheme::dt()

Return local timestep.

const std::vector<double> &dolfin::MultiStageScheme::dt_stage_offset() const

Return local timestep.

bool dolfin::MultiStageScheme::implicit() const

Return true if the whole scheme is implicit.

bool dolfin::MultiStageScheme::implicit(unsigned int stage) const

Return true if stage is implicit.

Parameters:stage
int dolfin::MultiStageScheme::jacobian_index(unsigned int stage) const

Return a distinct jacobian index for a given stage if negative the stage is explicit and hence no jacobian needed.

Parameters:stage
std::shared_ptr<const Form> dolfin::MultiStageScheme::last_stage()

Return the last stage.

unsigned int dolfin::MultiStageScheme::order() const

Return the order of the scheme.

std::shared_ptr<Function> dolfin::MultiStageScheme::solution()

Return solution variable.

std::shared_ptr<const Function> dolfin::MultiStageScheme::solution() const

Return solution variable (const version)

std::vector<std::vector<std::shared_ptr<const Form>>> &dolfin::MultiStageScheme::stage_forms()

Return the stages.

std::vector<std::shared_ptr<Function>> &dolfin::MultiStageScheme::stage_solutions()

Return stage solutions.

std::string dolfin::MultiStageScheme::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
std::shared_ptr<Constant> dolfin::MultiStageScheme::t()

Return local time.

PointIntegralSolver

C++ documentation for PointIntegralSolver from dolfin/multistage/PointIntegralSolver.h:

class dolfin::PointIntegralSolver

This class is a time integrator for general Runge Kutta forms. It only includes Point integrals with piecewise linear test functions. Such problems are disconnected at the vertices and can therefore be solved locally.

dolfin::PointIntegralSolver::PointIntegralSolver(std::shared_ptr<MultiStageScheme> scheme)

Constructor FIXME: Include version where one can pass a Solver and/or Parameters

Parameters:scheme
std::size_t dolfin::PointIntegralSolver::num_jacobian_computations() const

Return number of computations of jacobian.

void dolfin::PointIntegralSolver::reset_newton_solver()

Reset newton solver.

void dolfin::PointIntegralSolver::reset_stage_solutions()

Reset stage solutions.

std::shared_ptr<MultiStageScheme> dolfin::PointIntegralSolver::scheme() const

Return the MultiStageScheme .

void dolfin::PointIntegralSolver::step(double dt)

Step solver with time step dt.

Parameters:dt
void dolfin::PointIntegralSolver::step_interval(double t0, double t1, double dt)

Step solver an interval using dt as time step.

Parameters:
  • t0
  • t1
  • dt
dolfin::PointIntegralSolver::~PointIntegralSolver()

Destructor.

RKSolver

C++ documentation for RKSolver from dolfin/multistage/RKSolver.h:

class dolfin::RKSolver

This class is a time integrator for general Runge Kutta problems.

dolfin::RKSolver::RKSolver(std::shared_ptr<MultiStageScheme> scheme)

Constructor FIXME: Include version where one can pass a Solver and/or Parameters

Parameters:scheme
std::shared_ptr<MultiStageScheme> dolfin::RKSolver::scheme() const

Return the MultiStageScheme .

void dolfin::RKSolver::step(double dt)

Step solver with time step dt.

Parameters:dt
void dolfin::RKSolver::step_interval(double t0, double t1, double dt)

Step solver an interval using dt as time step.

Parameters:
  • t0
  • t1
  • dt

dolfin/nls

Documentation for C++ code found in dolfin/nls/*.h

Classes

NewtonSolver

C++ documentation for NewtonSolver from dolfin/nls/NewtonSolver.h:

class dolfin::NewtonSolver

This class defines a Newton solver for nonlinear systems of equations of the form \(F(x) = 0\) .

dolfin::NewtonSolver::NewtonSolver(MPI_Comm comm, std::shared_ptr<GenericLinearSolver> solver, GenericLinearAlgebraFactory &factory)

Create nonlinear solver using provided linear solver Arguments comm (MPI_Ccmm) The MPI communicator. solver (GenericLinearSolver ) The linear solver. factory (GenericLinearAlgebraFactory ) The factory.

Parameters:
  • comm
  • solver
  • factory
dolfin::NewtonSolver::NewtonSolver(MPI_Comm comm = MPI_COMM_WORLD)

Create nonlinear solver.

Parameters:comm
bool dolfin::NewtonSolver::converged(const GenericVector &r, const NonlinearProblem &nonlinear_problem, std::size_t iteration)

Convergence test. It may be overloaded using virtual inheritance and this base criterion may be called from derived, both in C++ and Python. Arguments r (GenericVector ) Residual for criterion evaluation. nonlinear_problem (NonlinearProblem ) The nonlinear problem. iteration (std::size_t) Newton iteration number. Returns bool Whether convergence occurred.

Parameters:
  • r
  • nonlinear_problem
  • iteration
double dolfin::NewtonSolver::get_relaxation_parameter()

Get relaxation parameter Returns double Relaxation parameter value.

std::size_t dolfin::NewtonSolver::iteration() const

Return current Newton iteration number Returns std::size_t The iteration number.

std::size_t dolfin::NewtonSolver::krylov_iterations() const

Return number of Krylov iterations elapsed since solve started Returns std::size_t The number of iterations.

GenericLinearSolver &dolfin::NewtonSolver::linear_solver() const

Return the linear solver Returns:cpp:any:GenericLinearSolver The linear solver.

double dolfin::NewtonSolver::relative_residual() const

Return current relative residual Returns double Current relative residual.

double dolfin::NewtonSolver::residual() const

Return current residual Returns double Current residual.

double dolfin::NewtonSolver::residual0() const

Return initial residual Returns double Initial residual.

void dolfin::NewtonSolver::set_relaxation_parameter(double relaxation_parameter)

Set relaxation parameter. Default value 1.0 means full Newton method, value smaller than 1.0 relaxes the method by shrinking effective Newton step size by the given factor. Arguments relaxation_parameter(double) Relaxation parameter value.

Parameters:relaxation_parameter
std::pair<std::size_t, bool> dolfin::NewtonSolver::solve(NonlinearProblem &nonlinear_function, GenericVector &x)

Solve abstract nonlinear problem \(F(x) = 0\) for given \(F\) and Jacobian \(\dfrac{\partial F}{\partial x}\) . Arguments nonlinear_function (NonlinearProblem ) The nonlinear problem. x (GenericVector ) The vector. Returns std::pair<std::size_t, bool> Pair of number of Newton iterations, and whether iteration converged)

Parameters:
  • nonlinear_function
  • x
void dolfin::NewtonSolver::solver_setup(std::shared_ptr<const GenericMatrix> A, std::shared_ptr<const GenericMatrix> P, const NonlinearProblem &nonlinear_problem, std::size_t iteration)

Setup solver to be used with system matrix A and preconditioner matrix P. It may be overloaded to get finer control over linear solver setup, various linesearch tricks, etc. Note that minimal implementation should call set_operators method of the linear solver. Arguments A (std::shared_ptr<const GenericMatrix>) System Jacobian matrix. J (std::shared_ptr<const GenericMatrix>) System preconditioner matrix. nonlinear_problem (NonlinearProblem ) The nonlinear problem. iteration (std::size_t) Newton iteration number.

Parameters:
  • A
  • P
  • nonlinear_problem
  • iteration
void dolfin::NewtonSolver::update_solution(GenericVector &x, const GenericVector &dx, double relaxation_parameter, const NonlinearProblem &nonlinear_problem, std::size_t iteration)

Update solution vector by computed Newton step. Default update is given by formula:: x -= relaxation_parameter*dx Arguments x (GenericVector >) The solution vector to be updated. dx (GenericVector >) The update vector computed by Newton step. relaxation_parameter (double) Newton relaxation parameter. nonlinear_problem (NonlinearProblem ) The nonlinear problem. iteration (std::size_t) Newton iteration number.

Parameters:
  • x
  • dx
  • relaxation_parameter
  • nonlinear_problem
  • iteration
dolfin::NewtonSolver::~NewtonSolver()

Destructor.

NonlinearProblem

C++ documentation for NonlinearProblem from dolfin/nls/NonlinearProblem.h:

class dolfin::NonlinearProblem

This is a base class for nonlinear problems which can return the nonlinear function F(u) and its Jacobian J = dF(u)/du.

void dolfin::NonlinearProblem::F(GenericVector &b, const GenericVector &x) = 0

Compute F at current point x.

Parameters:
  • b
  • x
void dolfin::NonlinearProblem::J(GenericMatrix &A, const GenericVector &x) = 0

Compute J = F’ at current point x.

Parameters:
  • A
  • x
void dolfin::NonlinearProblem::J_pc(GenericMatrix &P, const GenericVector &x)

Compute J_pc used to precondition J. Not implementing this or leaving P empty results in system matrix A being used to construct preconditioner. Note that if nonempty P is not assembled on first call then a solver implementation may throw away P and not call this routine ever again.

Parameters:
  • P
  • x
dolfin::NonlinearProblem::NonlinearProblem()

Constructor.

void dolfin::NonlinearProblem::form(GenericMatrix &A, GenericMatrix &P, GenericVector &b, const GenericVector &x)

Function called by Newton solver before requesting F, J or J_pc. This can be used to compute F, J and J_pc together. Preconditioner matrix P can be left empty so that A is used instead

Parameters:
  • A
  • P
  • b
  • x
void dolfin::NonlinearProblem::form(GenericMatrix &A, GenericVector &b, const GenericVector &x)

Function called by Newton solver before requesting F or J. This can be used to compute F and J together. NOTE: This function is deprecated. Use variant with preconditioner

Parameters:
  • A
  • b
  • x
dolfin::NonlinearProblem::~NonlinearProblem()

Destructor.

OptimisationProblem

C++ documentation for OptimisationProblem from dolfin/nls/OptimisationProblem.h:

class dolfin::OptimisationProblem

This is a base class for nonlinear optimisation problems which return the real-valued objective function \(f(x)\) , its gradient \(F(x) = f'(x)``and its Hessian :math:`\) J(x) = f’‘(x)`

void dolfin::OptimisationProblem::F(GenericVector &b, const GenericVector &x) = 0

Compute the gradient \(F(x) = f'(x)\).

Parameters:
  • b
  • x
void dolfin::OptimisationProblem::J(GenericMatrix &A, const GenericVector &x) = 0

Compute the Hessian \(J(x) = f''(x)\).

Parameters:
  • A
  • x
void dolfin::OptimisationProblem::J_pc(GenericMatrix &P, const GenericVector &x)

Compute J_pc used to precondition J. Not implementing this or leaving P empty results in system matrix A being used to construct preconditioner. Note that if nonempty P is not assembled on first call then a solver implementation may throw away P and not call this routine ever again.

Parameters:
  • P
  • x
dolfin::OptimisationProblem::OptimisationProblem()

Constructor.

double dolfin::OptimisationProblem::f(const GenericVector &x) = 0

Compute the objective function \(f(x)\)

Parameters:x
void dolfin::OptimisationProblem::form(GenericMatrix &A, GenericMatrix &P, GenericVector &b, const GenericVector &x)

Function called by the solver before requesting F, J or J_pc. This can be used to compute F, J and J_pc together. Preconditioner matrix P can be left empty so that A is used instead

Parameters:
  • A
  • P
  • b
  • x
void dolfin::OptimisationProblem::form(GenericMatrix &A, GenericVector &b, const GenericVector &x)

Compute the Hessian \(J(x)=f''(x)``and the gradient :math:`\) F(x)=f’(x)` together. Called before requesting F or J. NOTE: This function is deprecated. Use variant with preconditioner

Parameters:
  • A
  • b
  • x
dolfin::OptimisationProblem::~OptimisationProblem()

Destructor.

PETScSNESSolver

C++ documentation for PETScSNESSolver from dolfin/nls/PETScSNESSolver.h:

class dolfin::PETScSNESSolver

This class implements methods for solving nonlinear systems via PETSc’s SNES interface. It includes line search and trust region techniques for globalising the convergence of the nonlinear iteration.

PetscErrorCode dolfin::PETScSNESSolver::FormFunction(SNES snes, Vec x, Vec f, void *ctx)
Parameters:
  • snes
  • x
  • f
  • ctx
PetscErrorCode dolfin::PETScSNESSolver::FormJacobian(SNES snes, Vec x, Mat A, Mat B, void *ctx)
Parameters:
  • snes
  • x
  • A
  • B
  • ctx
PetscErrorCode dolfin::PETScSNESSolver::FormObjective(SNES snes, Vec x, PetscReal *out, void *ctx)
Parameters:
  • snes
  • x
  • out
  • ctx
dolfin::PETScSNESSolver::PETScSNESSolver(MPI_Comm comm, std::string nls_type = "default")

Create SNES solver.

Parameters:
  • comm
  • nls_type
dolfin::PETScSNESSolver::PETScSNESSolver(std::string nls_type = "default")

Create SNES solver on MPI_COMM_WORLD.

Parameters:nls_type
std::string dolfin::PETScSNESSolver::get_options_prefix() const

Returns the prefix used by PETSc when searching the PETSc options database

void dolfin::PETScSNESSolver::init(NonlinearProblem &nonlinear_problem, GenericVector &x)

Set up the SNES object, but don’t do anything yet, in case the user wants to access the SNES object directly

Parameters:
  • nonlinear_problem
  • x
bool dolfin::PETScSNESSolver::is_vi() const
std::shared_ptr<const PETScVector> dolfin::PETScSNESSolver::lb
std::vector<std::pair<std::string, std::string>> dolfin::PETScSNESSolver::methods()

Return a list of available solver methods.

MPI_Comm dolfin::PETScSNESSolver::mpi_comm() const

Return the MPI communicator.

Parameters dolfin::PETScSNESSolver::parameters

Parameters .

void dolfin::PETScSNESSolver::set_bounds(GenericVector &x)
Parameters:x
void dolfin::PETScSNESSolver::set_from_options() const

Set options from the PETSc options database.

void dolfin::PETScSNESSolver::set_linear_solver_parameters()
void dolfin::PETScSNESSolver::set_options_prefix(std::string options_prefix)

Sets the prefix used by PETSc when searching the PETSc options database

Parameters:options_prefix
SNES dolfin::PETScSNESSolver::snes() const

Return PETSc SNES pointer.

std::pair<std::size_t, bool> dolfin::PETScSNESSolver::solve(NonlinearProblem &nonlinear_function, GenericVector &x)

Solve abstract nonlinear problem \(F(x) = 0\) for given \(F\) and Jacobian \(\dfrac{\partial F}{\partial x}\) . Arguments nonlinear_function (NonlinearProblem ) The nonlinear problem. x (GenericVector ) The vector. Returns std::pair<std::size_t, bool> Pair of number of Newton iterations, and whether iteration converged)

Parameters:
  • nonlinear_function
  • x
std::pair<std::size_t, bool> dolfin::PETScSNESSolver::solve(NonlinearProblem &nonlinear_problem, GenericVector &x, const GenericVector &lb, const GenericVector &ub)

Solve a nonlinear variational inequality with bound constraints Arguments nonlinear_function (NonlinearProblem ) The nonlinear problem. x (GenericVector ) The vector. lb (GenericVector ) The lower bound. ub (GenericVector ) The upper bound. Returns std::pair<std::size_t, bool> Pair of number of Newton iterations, and whether iteration converged)

Parameters:
  • nonlinear_problem
  • x
  • lb
  • ub
std::shared_ptr<const PETScVector> dolfin::PETScSNESSolver::ub
dolfin::PETScSNESSolver::~PETScSNESSolver()

Destructor.

PETScTAOSolver

C++ documentation for PETScTAOSolver from dolfin/nls/PETScTAOSolver.h:

class dolfin::PETScTAOSolver

This class implements methods for solving nonlinear optimisation problems via PETSc TAO solver. It supports unconstrained as well as bound-constrained minimisation problem

PetscErrorCode dolfin::PETScTAOSolver::FormFunctionGradient(Tao tao, Vec x, PetscReal *fobj, Vec G, void *ctx)
Parameters:
  • tao
  • x
  • fobj
  • G
  • ctx
PetscErrorCode dolfin::PETScTAOSolver::FormHessian(Tao tao, Vec x, Mat H, Mat Hpre, void *ctx)
Parameters:
  • tao
  • x
  • H
  • Hpre
  • ctx
dolfin::PETScTAOSolver::PETScTAOSolver(MPI_Comm comm, std::string tao_type = "default", std::string ksp_type = "default", std::string pc_type = "default")

Create TAO solver.

Parameters:
  • comm
  • tao_type
  • ksp_type
  • pc_type
dolfin::PETScTAOSolver::PETScTAOSolver(std::string tao_type = "default", std::string ksp_type = "default", std::string pc_type = "default")

Create TAO solver on MPI_COMM_WORLD.

Parameters:
  • tao_type
  • ksp_type
  • pc_type
PetscErrorCode dolfin::PETScTAOSolver::TaoConvergenceTest(Tao tao, void *ctx)
Parameters:
  • tao
  • ctx
void dolfin::PETScTAOSolver::init(OptimisationProblem &optimisation_problem, PETScVector &x)

Initialise the TAO solver for an unconstrained minimisation problem, in case the user wants to access the TAO object directly

Parameters:
  • optimisation_problem
  • x
void dolfin::PETScTAOSolver::init(OptimisationProblem &optimisation_problem, PETScVector &x, const PETScVector &lb, const PETScVector &ub)

Initialise the TAO solver for a bound-constrained minimisation problem, in case the user wants to access the TAO object directly

Parameters:
  • optimisation_problem
  • x
  • lb
  • ub
std::vector<std::pair<std::string, std::string>> dolfin::PETScTAOSolver::methods()

Return a list of available solver methods.

MPI_Comm dolfin::PETScTAOSolver::mpi_comm() const

Return the MPI communicator.

Parameters dolfin::PETScTAOSolver::parameters

Parameters for the PETSc TAO solver.

void dolfin::PETScTAOSolver::set_ksp_options()
void dolfin::PETScTAOSolver::set_tao(std::string tao_type)
Parameters:tao_type
void dolfin::PETScTAOSolver::set_tao_options()
std::pair<std::size_t, bool> dolfin::PETScTAOSolver::solve(OptimisationProblem &optimisation_problem, GenericVector &x)

Solve a nonlinear unconstrained minimisation problem Arguments optimisation_problem (OptimisationProblem ) The nonlinear optimisation problem. x (GenericVector ) The solution vector (initial guess). Returns (its, converged) (std::pair<std::size_t, bool>) Pair of number of iterations, and whether iteration converged

Parameters:
  • optimisation_problem
  • x
std::pair<std::size_t, bool> dolfin::PETScTAOSolver::solve(OptimisationProblem &optimisation_problem, GenericVector &x, const GenericVector &lb, const GenericVector &ub)

Solve a nonlinear bound-constrained optimisation problem Arguments optimisation_problem (OptimisationProblem ) The nonlinear optimisation problem. x (GenericVector ) The solution vector (initial guess). lb (GenericVector ) The lower bound. ub (GenericVector ) The upper bound. Returns (its, converged) (std::pair<std::size_t, bool>) Pair of number of iterations, and whether iteration converged

Parameters:
  • optimisation_problem
  • x
  • lb
  • ub
std::pair<std::size_t, bool> dolfin::PETScTAOSolver::solve(OptimisationProblem &optimisation_problem, PETScVector &x, const PETScVector &lb, const PETScVector &ub)

Solve a nonlinear bound-constrained minimisation problem Arguments optimisation_problem (OptimisationProblem ) The nonlinear optimisation problem. x (PETScVector ) The solution vector (initial guess). lb (PETScVector ) The lower bound. ub (PETScVector ) The upper bound. Returns (its, converged) (std::pair<std::size_t, bool>) Pair of number of iterations, and whether iteration converged

Parameters:
  • optimisation_problem
  • x
  • lb
  • ub
Tao dolfin::PETScTAOSolver::tao() const

Return the TAO pointer.

void dolfin::PETScTAOSolver::update_parameters(std::string tao_type, std::string ksp_type, std::string pc_type)
Parameters:
  • tao_type
  • ksp_type
  • pc_type
dolfin::PETScTAOSolver::~PETScTAOSolver()

Destructor.

TAOLinearBoundSolver

C++ documentation for TAOLinearBoundSolver from dolfin/nls/TAOLinearBoundSolver.h:

class dolfin::TAOLinearBoundSolver

This class provides a bound constrained solver for a linear variational inequality defined by a matrix A and a vector b. It solves the problem: Find \(x_l\leq x\leq x_u\) such that \((Ax-b)\cdot (y-x)\geq 0,\; \forall x_l\leq y\leq x_u\) It is a wrapper for the TAO bound constrained solver.

# Assemble the linear system
A, b = assemble_system(a, L, bc)
# Define the constraints
constraint_u = Constant(1.)
constraint_l = Constant(0.)
u_min = interpolate(constraint_l, V)
u_max = interpolate(constraint_u, V)
# Define the function to store the solution
usol=Function(V)
# Create the TAOLinearBoundSolver
solver=TAOLinearBoundSolver("tao_gpcg","gmres")
# Set some parameters
solver.parameters["monitor_convergence"]=True
solver.parameters["report"]=True
# Solve the problem
solver.solve(A, usol.vector(), b , u_min.vector(), u_max.vector())
info(solver.parameters,True)
dolfin::TAOLinearBoundSolver::TAOLinearBoundSolver(MPI_Comm comm)

Create TAO bound constrained solver.

Parameters:comm
dolfin::TAOLinearBoundSolver::TAOLinearBoundSolver(const std::string method = "default", const std::string ksp_type = "default", const std::string pc_type = "default")

Create TAO bound constrained solver.

Parameters:
  • method
  • ksp_type
  • pc_type
std::shared_ptr<const PETScMatrix> dolfin::TAOLinearBoundSolver::get_matrix() const

Return Matrix shared pointer.

std::shared_ptr<const PETScVector> dolfin::TAOLinearBoundSolver::get_vector() const

Return load vector shared pointer.

void dolfin::TAOLinearBoundSolver::init(const std::string &method)
Parameters:method
std::map<std::string, std::string> dolfin::TAOLinearBoundSolver::krylov_solvers()

Return a list of available krylov solvers.

std::map<std::string, std::string> dolfin::TAOLinearBoundSolver::methods()

Return a list of available Tao solver methods.

std::map<std::string, std::string> dolfin::TAOLinearBoundSolver::preconditioners()

Return a list of available preconditioners.

void dolfin::TAOLinearBoundSolver::read_parameters()
void dolfin::TAOLinearBoundSolver::set_ksp(const std::string ksp_type = "default")

Set PETSC Krylov Solver (ksp) used by TAO.

Parameters:ksp_type
void dolfin::TAOLinearBoundSolver::set_ksp_options()
void dolfin::TAOLinearBoundSolver::set_operators(std::shared_ptr<const GenericMatrix> A, std::shared_ptr<const GenericVector> b)
Parameters:
  • A
  • b
void dolfin::TAOLinearBoundSolver::set_operators(std::shared_ptr<const PETScMatrix> A, std::shared_ptr<const PETScVector> b)
Parameters:
  • A
  • b
void dolfin::TAOLinearBoundSolver::set_solver(const std::string&)

Set the TAO solver type.

Parameters:method
std::size_t dolfin::TAOLinearBoundSolver::solve(const GenericMatrix &A, GenericVector &x, const GenericVector &b, const GenericVector &xl, const GenericVector &xu)

Solve the linear variational inequality defined by A and b with xl =< x <= xu

Parameters:
  • A
  • x
  • b
  • xl
  • xu
std::size_t dolfin::TAOLinearBoundSolver::solve(const PETScMatrix &A, PETScVector &x, const PETScVector &b, const PETScVector &xl, const PETScVector &xu)

Solve the linear variational inequality defined by A and b with xl =< x <= xu

Parameters:
  • A
  • x
  • b
  • xl
  • xu
Tao dolfin::TAOLinearBoundSolver::tao() const

Return TAO solver pointer.

dolfin::TAOLinearBoundSolver::~TAOLinearBoundSolver()

Destructor.

dolfin/parameter

Documentation for C++ code found in dolfin/parameter/*.h

Variables

empty_parameters

C++ documentation for empty_parameters from dolfin/parameter/Parameters.cpp:

Parameters dolfin::empty_parameters

Default empty parameters.

parameters

C++ documentation for parameters from dolfin/parameter/GlobalParameters.h:

GlobalParameters dolfin::parameters

The global parameter database.

Classes

BoolParameter

C++ documentation for BoolParameter from dolfin/parameter/Parameter.h:

class dolfin::BoolParameter

Parameter with value type bool.

dolfin::BoolParameter::BoolParameter(std::string key)

Create unset bool-valued parameter.

Parameters:key
dolfin::BoolParameter::BoolParameter(std::string key, bool value)

Create bool-valued parameter.

Parameters:
  • key
  • value
dolfin::BoolParameter::operator bool() const

Cast parameter to bool.

const BoolParameter &dolfin::BoolParameter::operator=(bool value)

Assignment.

Parameters:value
std::string dolfin::BoolParameter::range_str() const

Return range string.

std::string dolfin::BoolParameter::str() const

Return short string description.

std::string dolfin::BoolParameter::type_str() const

Return value type string.

std::string dolfin::BoolParameter::value_str() const

Return value string.

dolfin::BoolParameter::~BoolParameter()

Destructor.

DoubleParameter

C++ documentation for DoubleParameter from dolfin/parameter/Parameter.h:

class dolfin::DoubleParameter

Parameter with value type double.

dolfin::DoubleParameter::DoubleParameter(std::string key)

Create unset double-valued parameter.

Parameters:key
dolfin::DoubleParameter::DoubleParameter(std::string key, double value)

Create double-valued parameter.

Parameters:
  • key
  • value
void dolfin::DoubleParameter::get_range(double &min_value, double &max_value) const

Get range.

Parameters:
  • min_value
  • max_value
dolfin::DoubleParameter::operator double() const

Cast parameter to double.

const DoubleParameter &dolfin::DoubleParameter::operator=(double value)

Assignment.

Parameters:value
std::string dolfin::DoubleParameter::range_str() const

Return range string.

void dolfin::DoubleParameter::set_range(double min_value, double max_value)

Set range.

Parameters:
  • min_value
  • max_value
std::string dolfin::DoubleParameter::str() const

Return short string description.

std::string dolfin::DoubleParameter::type_str() const

Return value type string.

std::string dolfin::DoubleParameter::value_str() const

Return value string.

dolfin::DoubleParameter::~DoubleParameter()

Destructor.

GlobalParameters

C++ documentation for GlobalParameters from dolfin/parameter/GlobalParameters.h:

class dolfin::GlobalParameters

This class defines the global DOLFIN parameter database.

dolfin::GlobalParameters::GlobalParameters()

Constructor.

void dolfin::GlobalParameters::parse(int argc, char *argv[])

Parse parameters from command-line.

Parameters:
  • argc
  • argv
dolfin::GlobalParameters::~GlobalParameters()

Destructor.

IntParameter

C++ documentation for IntParameter from dolfin/parameter/Parameter.h:

class dolfin::IntParameter

Parameter with value type int.

dolfin::IntParameter::IntParameter(std::string key)

Create unset int-valued.

Parameters:key
dolfin::IntParameter::IntParameter(std::string key, int value)

Create int-valued parameter.

Parameters:
  • key
  • value
void dolfin::IntParameter::get_range(int &min_value, int &max_value) const

Get range.

Parameters:
  • min_value
  • max_value
dolfin::IntParameter::operator int() const

Cast parameter to int.

dolfin::IntParameter::operator std::size_t() const

Cast parameter to std::size_t.

const IntParameter &dolfin::IntParameter::operator=(int value)

Assignment.

Parameters:value
std::string dolfin::IntParameter::range_str() const

Return range string.

void dolfin::IntParameter::set_range(int min_value, int max_value)

Set range.

Parameters:
  • min_value
  • max_value
std::string dolfin::IntParameter::str() const

Return short string description.

std::string dolfin::IntParameter::type_str() const

Return value type string.

std::string dolfin::IntParameter::value_str() const

Return value string.

dolfin::IntParameter::~IntParameter()

Destructor.

Parameter

C++ documentation for Parameter from dolfin/parameter/Parameter.h:

class dolfin::Parameter

Base class for parameters.

dolfin::Parameter::Parameter(std::string key)

Create parameter for given key

Parameters:key – (std::string)
std::size_t dolfin::Parameter::access_count() const

Return access count (number of times parameter has been accessed)

Returns:std::size_t
std::size_t dolfin::Parameter::change_count() const

Return change count (number of times parameter has been changed)

Returns:std::size_t
void dolfin::Parameter::check_key(std::string key)

Check that key name is allowed.

Parameters:key
std::string dolfin::Parameter::description() const

Return parameter description

Returns:std::string
void dolfin::Parameter::get_range(double &min_value, double &max_value) const

Get range for double-valued parameter

Parameters:
  • min_value – (double) [direction=out]
  • max_value – (double) [direction=out]
void dolfin::Parameter::get_range(int &min_value, int &max_value) const

Get range for int-valued parameter

Parameters:
  • min_value – (int) [direction=out]
  • max_value – (int) [direction=out]
void dolfin::Parameter::get_range(std::set<std::string> &range) const

Get range for string-valued parameter

Parameters:range – (std::set<std::string>) [direction=out]
bool dolfin::Parameter::is_set() const

Return true if parameter is set, return false otherwise

Returns:bool
std::string dolfin::Parameter::key() const

Return parameter key

Returns:std::string
dolfin::Parameter::operator bool() const

Cast parameter to bool.

dolfin::Parameter::operator double() const

Cast parameter to double.

dolfin::Parameter::operator int() const

Cast parameter to int.

dolfin::Parameter::operator std::size_t() const

Cast parameter to std::size_t.

dolfin::Parameter::operator std::string() const

Cast parameter to string.

const Parameter &dolfin::Parameter::operator=(bool value)

Assignment from bool

Parameters:value – (bool)
const Parameter &dolfin::Parameter::operator=(const char *value)

Assignment from string

Parameters:value – (char *)
const Parameter &dolfin::Parameter::operator=(double value)

Assignment from double

Parameters:value – (double)
const Parameter &dolfin::Parameter::operator=(int value)

Assignment from int

Parameters:value – (int)
const Parameter &dolfin::Parameter::operator=(std::string value)

Assignment from string

Parameters:value – (std::string)
std::string dolfin::Parameter::range_str() const = 0

Return range string.

void dolfin::Parameter::reset()

Reset the parameter to empty, so that is_set() returns false.

void dolfin::Parameter::set_range(double min_value, double max_value)

Set range for double-valued parameter

Parameters:
  • min_value – (double)
  • max_value – (double)
void dolfin::Parameter::set_range(int min_value, int max_value)

Set range for int-valued parameter

Parameters:
  • min_value – (int)
  • max_value – (int)
void dolfin::Parameter::set_range(std::set<std::string> range)

Set range for string-valued parameter

Parameters:range – (std::set<std::string>)
std::string dolfin::Parameter::str() const = 0

Return short string description.

std::string dolfin::Parameter::type_str() const = 0

Return value type string.

std::string dolfin::Parameter::value_str() const = 0

Return value string.

dolfin::Parameter::~Parameter()

Destructor.

Parameters

C++ documentation for Parameters from dolfin/parameter/Parameters.h:

class dolfin::Parameters

This class stores a set of parameters. Each parameter is identified by a unique string (the key) and a value of some given value type. Parameter sets can be nested at arbitrary depths. A parameter may be either int, double, string or boolean valued. Parameters may be added as follows:

Parameters p("my_parameters");
p.add("relative_tolerance",  1e-15);
p.add("absolute_tolerance",  1e-15);
p.add("gmres_restart",       30);
p.add("monitor_convergence", false);

Parameters may be changed as follows:

p["gmres_restart"] = 50;

Parameter values may be retrieved as follows:

int gmres_restart = p["gmres_restart"];

Parameter sets may be nested as follows:

Parameters q("nested_parameters");
p.add(q);

Nested parameters may then be accessed by

p("nested_parameters")["..."]

Parameters may be nested at arbitrary depths. Parameters may be parsed from the command-line as follows:

p.parse(argc, argv);

Note: spaces in parameter keys are not allowed (to simplify usage from command-line).

dolfin::Parameters::Parameters(const Parameters &parameters)

Copy constructor.

Parameters:parameters
dolfin::Parameters::Parameters(std::string key = "parameters")

Create empty parameter set.

Parameters:key
void dolfin::Parameters::add(const Parameters &parameters)

Add nested parameter set.

Parameters:parameters
void dolfin::Parameters::add(std::string key)

Add an unset parameter of type T. For example, to create a unset parameter of type bool, do parameters.add<bool>(“my_setting”)

Parameters:key
void dolfin::Parameters::add(std::string key, T min, T max)

Add an unset parameter of type T with allows parameters. For example, to create a unset parameter of type bool, do parameters.add<bool>(“my_setting”)

Parameters:
  • key
  • min
  • max
void dolfin::Parameters::add(std::string key, bool value)

Add bool-valued parameter.

Parameters:
  • key
  • value
void dolfin::Parameters::add(std::string key, const char *value)

Add string-valued parameter.

Parameters:
  • key
  • value
void dolfin::Parameters::add(std::string key, const char *value, std::set<std::string> range)

Add string-valued parameter with given range.

Parameters:
  • key
  • value
  • range
void dolfin::Parameters::add(std::string key, double value)

Add double-valued parameter.

Parameters:
  • key
  • value
void dolfin::Parameters::add(std::string key, double value, double min_value, double max_value)

Add double-valued parameter with given range.

Parameters:
  • key
  • value
  • min_value
  • max_value
void dolfin::Parameters::add(std::string key, int value)

Add int-valued parameter.

Parameters:
  • key
  • value
void dolfin::Parameters::add(std::string key, int value, int min_value, int max_value)

Add int-valued parameter with given range.

Parameters:
  • key
  • value
  • min_value
  • max_value
void dolfin::Parameters::add(std::string key, std::set<T> valid_values)

Add an unset parameter of type T with allows parameters. For example, to create a unset parameter of type bool, do parameters.add<bool>(“my_setting”)

Parameters:
  • key
  • valid_values
void dolfin::Parameters::add(std::string key, std::string value)

Add string-valued parameter.

Parameters:
  • key
  • value
void dolfin::Parameters::add(std::string key, std::string value, std::set<std::string> range)

Add string-valued parameter with given range.

Parameters:
  • key
  • value
  • range
void dolfin::Parameters::add_parameter_set_to_po(boost::program_options::options_description &desc, const Parameters &parameters, std::string base_name = "") const
Parameters:
  • desc
  • parameters
  • base_name
void dolfin::Parameters::clear()

Clear parameter set.

Parameter *dolfin::Parameters::find_parameter(std::string key) const

Return pointer to parameter for given key and 0 if not found.

Parameters:key
Parameters *dolfin::Parameters::find_parameter_set(std::string key) const

Return pointer to parameter set for given key and 0 if not found.

Parameters:key
void dolfin::Parameters::get_parameter_keys(std::vector<std::string> &keys) const

Return a vector of parameter keys.

Parameters:keys
void dolfin::Parameters::get_parameter_set_keys(std::vector<std::string> &keys) const

Return a vector of parameter set keys.

Parameters:keys
bool dolfin::Parameters::has_key(std::string key) const

Check if parameter set has key (parameter or nested parameter set)

Parameters:key
bool dolfin::Parameters::has_parameter(std::string key) const

Check if parameter set has given parameter.

Parameters:key
bool dolfin::Parameters::has_parameter_set(std::string key) const

Check if parameter set has given nested parameter set.

Parameters:key
std::string dolfin::Parameters::name() const

Return name for parameter set.

Parameters &dolfin::Parameters::operator()(std::string key)

Return nested parameter set for given key.

Parameters:key
const Parameters &dolfin::Parameters::operator()(std::string key) const

Return nested parameter set for given key (const)

Parameters:key
const Parameters &dolfin::Parameters::operator=(const Parameters &parameters)

Assignment operator.

Parameters:parameters
Parameter &dolfin::Parameters::operator[](std::string key)

Return parameter for given key.

Parameters:key
const Parameter &dolfin::Parameters::operator[](std::string key) const

Return parameter for given key (const version)

Parameters:key
void dolfin::Parameters::parse(int argc, char *argv[])

Parse parameters from command-line.

Parameters:
  • argc
  • argv
void dolfin::Parameters::parse_common(int argc, char *argv[])

Parse filtered options (everything except PETSc options)

Parameters:
  • argc
  • argv
void dolfin::Parameters::parse_petsc(int argc, char *argv[])

Parse filtered options (only PETSc options)

Parameters:
  • argc
  • argv
void dolfin::Parameters::read_vm(boost::program_options::variables_map &vm, Parameters &parameters, std::string base_name = "")
Parameters:
  • vm
  • parameters
  • base_name
void dolfin::Parameters::remove(std::string key)

Remove parameter or parameter set with given key.

Parameters:key
void dolfin::Parameters::rename(std::string key)

Rename parameter set.

Parameters:key
std::string dolfin::Parameters::str(bool verbose) const

Return informal string representation (pretty-print)

Parameters:verbose
void dolfin::Parameters::update(const Parameters &parameters)

Update parameters with another set of parameters.

Parameters:parameters
dolfin::Parameters::~Parameters()

Destructor.

StringParameter

C++ documentation for StringParameter from dolfin/parameter/Parameter.h:

class dolfin::StringParameter

Parameter with value type string.

dolfin::StringParameter::StringParameter(std::string key)

Create unset string-valued parameter.

Parameters:key
dolfin::StringParameter::StringParameter(std::string key, std::string value)

Create string-valued parameter.

Parameters:
  • key
  • value
void dolfin::StringParameter::get_range(std::set<std::string> &range) const

Get range.

Parameters:range
dolfin::StringParameter::operator std::string() const

Cast parameter to string.

const StringParameter &dolfin::StringParameter::operator=(const char *value)

Assignment.

Parameters:value
const StringParameter &dolfin::StringParameter::operator=(std::string value)

Assignment.

Parameters:value
std::string dolfin::StringParameter::range_str() const

Return range string.

void dolfin::StringParameter::set_range(std::set<std::string> range)

Set range.

Parameters:range
std::string dolfin::StringParameter::str() const

Return short string description.

std::string dolfin::StringParameter::type_str() const

Return value type string.

std::string dolfin::StringParameter::value_str() const

Return value string.

dolfin::StringParameter::~StringParameter()

Destructor.

dolfin/plot

Documentation for C++ code found in dolfin/plot/*.h

Functions

interactive

C++ documentation for interactive from dolfin/plot/plot.h:

void dolfin::interactive(bool really = false)

Make the current plots interactive. If really is set, the interactive mode is entered even if ‘Q’ has been pressed.

Parameters:really
plot

C++ documentation for plot from dolfin/plot/plot.h:

void dolfin::plot(const Expression &expression, const Mesh &mesh, const Parameters &parameters)

Plot expression (parameter version)

Parameters:
  • expression
  • mesh
  • parameters

C++ documentation for plot from dolfin/plot/plot.h:

void dolfin::plot(const Expression &expression, const Mesh &mesh, std::string title = "", std::string mode = "auto")

Plot expression.

Parameters:
  • expression
  • mesh
  • title
  • mode

C++ documentation for plot from dolfin/plot/plot.h:

void dolfin::plot(const MultiMesh &multimesh)

Plot multimesh.

Parameters:multimesh

C++ documentation for plot from dolfin/plot/plot.h:

void dolfin::plot(const Variable&, const Parameters &parameters)

Plot variable (parameter version)

Parameters:
  • var
  • parameters

C++ documentation for plot from dolfin/plot/plot.h:

void dolfin::plot(const Variable&, std::string title = "", std::string mode = "auto")

Simple built-in plot commands for plotting functions and meshes. Plot variable of any supported type

Parameters:
  • var
  • title
  • mode

C++ documentation for plot from dolfin/plot/plot.h:

std::shared_ptr<VTKPlotter> dolfin::plot(std::shared_ptr<const Expression> expression, std::shared_ptr<const Mesh> mesh, std::shared_ptr<const Parameters> parameters)

Plot expression (parameter, shared_ptr version)

Parameters:
  • expression
  • mesh
  • parameters

C++ documentation for plot from dolfin/plot/plot.h:

std::shared_ptr<VTKPlotter> dolfin::plot(std::shared_ptr<const Expression> expression, std::shared_ptr<const Mesh> mesh, std::string title = "", std::string mode = "auto")

Plot expression (shared_ptr version)

Parameters:
  • expression
  • mesh
  • title
  • mode

C++ documentation for plot from dolfin/plot/plot.h:

void dolfin::plot(std::shared_ptr<const MultiMesh> multimesh)

Plot multimesh (shared_ptr version)

Parameters:multimesh

C++ documentation for plot from dolfin/plot/plot.h:

std::shared_ptr<VTKPlotter> dolfin::plot(std::shared_ptr<const Variable>, std::shared_ptr<const Parameters> parameters)

Plot variable (parameter, shared_ptr version)

Parameters:
  • var
  • parameters

C++ documentation for plot from dolfin/plot/plot.h:

std::shared_ptr<VTKPlotter> dolfin::plot(std::shared_ptr<const Variable>, std::string title = "", std::string mode = "auto")

Plot variable (shared_ptr version)

Parameters:
  • var
  • title
  • mode

Classes

ExpressionWrapper

C++ documentation for ExpressionWrapper from dolfin/plot/ExpressionWrapper.h:

class dolfin::ExpressionWrapper

A light wrapper class to hold an expression to plot, along with the mesh to plot it on. Allows clean, templated plotter code in plot.cpp

dolfin::ExpressionWrapper::ExpressionWrapper(std::shared_ptr<const Expression> expression, std::shared_ptr<const Mesh> mesh)

Create wrapped expression object.

Parameters:
  • expression
  • mesh
std::shared_ptr<const Expression> dolfin::ExpressionWrapper::expression() const

Get shared pointer to the expression.

std::shared_ptr<const Mesh> dolfin::ExpressionWrapper::mesh() const

Get shared pointer to the mesh.

dolfin/refinement

Documentation for C++ code found in dolfin/refinement/*.h

Functions

p_refine

C++ documentation for p_refine from dolfin/refinement/refine.h:

void dolfin::p_refine(Mesh &refined_mesh, const Mesh &mesh)

Increase the polynomial order of the mesh from 1 to 2, i.e. add points at the Edge midpoints, to make a quadratic mesh.

Parameters:
  • refined_mesh – (Mesh ) The mesh that will be the quadratic mesh.
  • mesh – (Mesh ) The original linear mesh.

C++ documentation for p_refine from dolfin/refinement/refine.h:

Mesh dolfin::p_refine(const Mesh &mesh)

Return a p_refined mesh Increase the polynomial order of the mesh from 1 to 2, i.e. add points at the Edge midpoints, to make a quadratic mesh.

Parameters:mesh – (Mesh ) The original linear mesh.
Returns:Mesh
refine

C++ documentation for refine from dolfin/refinement/refine.h:

void dolfin::refine(Mesh &refined_mesh, const Mesh &mesh, bool redistribute = true)

Create uniformly refined mesh

Parameters:
  • refined_mesh – (Mesh ) The mesh that will be the refined mesh.
  • mesh – (Mesh ) The original mesh.
  • redistribute – (bool) Optional argument to redistribute the refined mesh if mesh is a distributed mesh.

C++ documentation for refine from dolfin/refinement/refine.h:

void dolfin::refine(Mesh &refined_mesh, const Mesh &mesh, const MeshFunction<bool> &cell_markers, bool redistribute = true)

Create locally refined mesh

Parameters:
  • refined_mesh – (Mesh ) The mesh that will be the refined mesh.
  • mesh – (Mesh ) The original mesh.
  • cell_markers – (MeshFunction<bool>) A mesh function over booleans specifying which cells that should be refined (and which should not).
  • redistribute – (bool) Optional argument to redistribute the refined mesh if mesh is a distributed mesh.

C++ documentation for refine from dolfin/refinement/refine.h:

Mesh dolfin::refine(const Mesh &mesh, bool redistribute = true)

Create uniformly refined mesh

mesh = refine(mesh);
Parameters:
  • mesh – (Mesh ) The mesh to refine.
  • redistribute – (bool) Optional argument to redistribute the refined mesh if mesh is a distributed mesh.
Returns:

Mesh The refined mesh.

C++ documentation for refine from dolfin/refinement/refine.h:

Mesh dolfin::refine(const Mesh &mesh, const MeshFunction<bool> &cell_markers, bool redistribute = true)

Create locally refined mesh

CellFunction<bool> cell_markers(mesh);
cell_markers.set_all(false);
Point origin(0.0, 0.0, 0.0);
for (CellIterator cell(mesh); !cell.end(); ++cell)
{
Point p = cell->midpoint();
if (p.distance(origin) < 0.1)
cell_markers[*cell] = true;
}
mesh = refine(mesh, cell_markers);
Parameters:
  • mesh – (Mesh ) The mesh to refine.
  • cell_markers – (MeshFunction<bool>) A mesh function over booleans specifying which cells that should be refined (and which should not).
  • redistribute – (bool) Optional argument to redistribute the refined mesh if mesh is a distributed mesh.
Returns:

Mesh The locally refined mesh.

C++ documentation for refine from dolfin/refinement/refine.h:

std::shared_ptr<const MeshHierarchy> dolfin::refine(const MeshHierarchy &hierarchy, const MeshFunction<bool> &markers)

Refine a MeshHierarchy .

Parameters:
  • hierarchy
  • markers

Classes

BisectionRefinement1D

C++ documentation for BisectionRefinement1D from dolfin/refinement/BisectionRefinement1D.h:

class dolfin::BisectionRefinement1D

This class implements mesh refinement in 1D.

void dolfin::BisectionRefinement1D::refine(Mesh &refined_mesh, const Mesh &mesh, bool redistribute = false)

Refine mesh uniformly

Parameters:
  • refined_mesh – (Mesh )
  • mesh – (const Mesh )
  • redistribute – (bool)
void dolfin::BisectionRefinement1D::refine(Mesh &refined_mesh, const Mesh &mesh, const MeshFunction<bool> &cell_markers, bool redistribute = false)

Refine mesh based on cell markers

Parameters:
  • refined_mesh – (Mesh )
  • mesh – (const Mesh )
  • cell_markers – (const MeshFunction<bool>)
  • redistribute – (bool)
LocalMeshCoarsening

C++ documentation for LocalMeshCoarsening from dolfin/refinement/LocalMeshCoarsening.h:

class dolfin::LocalMeshCoarsening

This class implements local mesh coarsening for different mesh types.

bool dolfin::LocalMeshCoarsening::coarsen_cell(Mesh &mesh, Mesh &coarse_mesh, int cell_id, std::vector<int> &old2new_vertex, std::vector<int> &old2new_cell, bool coarsen_boundary = false)

Coarsen simplicial cell by edge collapse.

Parameters:
  • mesh
  • coarse_mesh
  • cell_id
  • old2new_vertex
  • old2new_cell
  • coarsen_boundary
void dolfin::LocalMeshCoarsening::coarsen_mesh_by_edge_collapse(Mesh &mesh, MeshFunction<bool> &cell_marker, bool coarsen_boundary = false)

Coarsen simplicial mesh locally by edge collapse.

Parameters:
  • mesh
  • cell_marker
  • coarsen_boundary
bool dolfin::LocalMeshCoarsening::coarsen_mesh_ok(Mesh &mesh, std::size_t edge_index, std::size_t *edge_vertex, MeshFunction<bool> &vertex_forbidden)

Check that edge collapse is ok.

Parameters:
  • mesh
  • edge_index
  • edge_vertex
  • vertex_forbidden
void dolfin::LocalMeshCoarsening::collapse_edge(Mesh &mesh, Edge &edge, Vertex &vertex_to_remove, MeshFunction<bool> &cell_to_remove, std::vector<int> &old2new_vertex, std::vector<int> &old2new_cell, MeshEditor &editor, std::size_t &current_cell)

Collapse edge by node deletion.

Parameters:
  • mesh
  • edge
  • vertex_to_remove
  • cell_to_remove
  • old2new_vertex
  • old2new_cell
  • editor
  • current_cell
ParallelRefinement

C++ documentation for ParallelRefinement from dolfin/refinement/ParallelRefinement.h:

class dolfin::ParallelRefinement

Data structure and methods for refining meshes in parallel. ParallelRefinement encapsulates two main features: a distributed EdgeFunction , which can be updated across processes, and storage for local mesh data, which can be used to construct the new Mesh

dolfin::ParallelRefinement::ParallelRefinement(const Mesh &mesh)

Constructor.

Parameters:mesh
void dolfin::ParallelRefinement::build_local(Mesh &new_mesh) const

Build local mesh from internal data when not running in parallel

Parameters:new_mesh – (Mesh )
void dolfin::ParallelRefinement::create_new_vertices()

Add new vertex for each marked edge, and create new_vertex_coordinates and global_edge->new_vertex mapping. Communicate new vertices with MPI to all affected processes.

std::shared_ptr<const std::map<std::size_t, std::size_t>> dolfin::ParallelRefinement::edge_to_new_vertex() const

Mapping of old edge (to be removed) to new global vertex number. Useful for forming new topology

bool dolfin::ParallelRefinement::is_marked(std::size_t edge_index) const

Return marked status of edge

Parameters:edge_index – (std::size_t)
std::shared_ptr<std::map<std::size_t, std::size_t>> dolfin::ParallelRefinement::local_edge_to_new_vertex
void dolfin::ParallelRefinement::mark(const MeshEntity &cell)

Mark all incident edges of an entity

Parameters:cell – (MeshEntity )
void dolfin::ParallelRefinement::mark(const MeshFunction<bool> &refinement_marker)

Mark all edges incident on entities indicated by refinement marker

Parameters:refinement_marker – (const MeshFunction<bool>)
void dolfin::ParallelRefinement::mark(std::size_t edge_index)

Mark edge by index

Parameters:edge_index – (std::size_t) Index of edge to mark
void dolfin::ParallelRefinement::mark_all()

Mark all edges in mesh.

std::vector<std::size_t> dolfin::ParallelRefinement::marked_edge_list(const MeshEntity &cell) const

Return list of marked edges incident on this MeshEntity - usually a cell

Parameters:cell – (const MeshEntity )
std::vector<bool> dolfin::ParallelRefinement::marked_edges
std::vector<std::vector<std::size_t>> dolfin::ParallelRefinement::marked_for_update
const Mesh &dolfin::ParallelRefinement::mesh() const

Original mesh associated with this refinement.

void dolfin::ParallelRefinement::new_cell(const Cell &cell)

Add a new cell to the list in 3D or 2D

Parameters:cell – (const Cell )
void dolfin::ParallelRefinement::new_cell(std::size_t i0, std::size_t i1, std::size_t i2)

Add a new cell with vertex indices

Parameters:
  • i0 – (std::size_t)
  • i1 – (std::size_t)
  • i2 – (std::size_t)
void dolfin::ParallelRefinement::new_cell(std::size_t i0, std::size_t i1, std::size_t i2, std::size_t i3)

Add a new cell with vertex indices

Parameters:
  • i0 – (std::size_t)
  • i1 – (std::size_t)
  • i2 – (std::size_t)
  • i3 – (std::size_t)
std::vector<std::size_t> dolfin::ParallelRefinement::new_cell_topology
void dolfin::ParallelRefinement::new_cells(const std::vector<std::size_t> &idx)

Add new cells with vertex indices

Parameters:idx – (const std::vector<std::size_t>)
std::vector<double> dolfin::ParallelRefinement::new_vertex_coordinates
void dolfin::ParallelRefinement::partition(Mesh &new_mesh, bool redistribute) const

Use vertex and topology data to partition new mesh across processes

Parameters:
  • new_mesh – (Mesh )
  • redistribute – (bool)
std::unordered_map<unsigned int, std::vector<std::pair<unsigned int, unsigned int>>> dolfin::ParallelRefinement::shared_edges
void dolfin::ParallelRefinement::update_logical_edgefunction()

Transfer marked edges between processes.

dolfin::ParallelRefinement::~ParallelRefinement()

Destructor.

PlazaRefinementND

C++ documentation for PlazaRefinementND from dolfin/refinement/PlazaRefinementND.h:

class dolfin::PlazaRefinementND

Implementation of the refinement method described in Plaza and Carey “Local refinement of simplicial grids based on the skeleton” (Applied Numerical Mathematics 32 (2000) 195-218)

void dolfin::PlazaRefinementND::do_refine(Mesh &new_mesh, const Mesh &mesh, ParallelRefinement &p_ref, const std::vector<unsigned int> &long_edge, const std::vector<bool> &edge_ratio_ok, bool redistribute, bool calculate_parent_facets, MeshRelation &mesh_relation)
Parameters:
  • new_mesh
  • mesh
  • p_ref
  • long_edge
  • edge_ratio_ok
  • redistribute
  • calculate_parent_facets
  • mesh_relation
void dolfin::PlazaRefinementND::enforce_rules(ParallelRefinement &p_ref, const Mesh &mesh, const std::vector<unsigned int> &long_edge)
Parameters:
  • p_ref
  • mesh
  • long_edge
void dolfin::PlazaRefinementND::face_long_edge(std::vector<unsigned int> &long_edge, std::vector<bool> &edge_ratio_ok, const Mesh &mesh)
Parameters:
  • long_edge
  • edge_ratio_ok
  • mesh
void dolfin::PlazaRefinementND::get_simplices(std::vector<std::size_t> &simplex_set, const std::vector<bool> &marked_edges, const std::vector<std::size_t> &longest_edge, std::size_t tdim, bool uniform)

Get the subdivision of an original simplex into smaller simplices, for a given set of marked edges, and the longest edge of each facet (cell local indexing). A flag indicates if a uniform subdivision is preferable in 2D.

Parameters:
  • simplex_set – Returned set of triangles/tets topological description
  • marked_edgesVector indicating which edges are to be split
  • longest_edgeVector indicating the longest edge for each triangle. For tdim=2, one entry, for tdim=3, four entries.
  • tdim – Topological dimension (2 or 3)
  • uniform – Make a “uniform” subdivision with all triangles being similar shape
void dolfin::PlazaRefinementND::get_tetrahedra(std::vector<std::size_t> &tet_set, const std::vector<bool> &marked_edges, const std::vector<std::size_t> &longest_edge)
Parameters:
  • tet_set
  • marked_edges
  • longest_edge
void dolfin::PlazaRefinementND::get_triangles(std::vector<std::size_t> &tri_set, const std::vector<bool> &marked_edges, const std::size_t longest_edge, bool uniform)
Parameters:
  • tri_set
  • marked_edges
  • longest_edge
  • uniform
void dolfin::PlazaRefinementND::refine(Mesh &new_mesh, const Mesh &mesh, bool redistribute, bool calculate_parent_facets)

Uniform refine, optionally redistributing and optionally calculating the parent-child relation for facets (in 2D)

Parameters:
  • new_mesh – New Mesh
  • mesh – Input mesh to be refined
  • redistribute – Flag to call the Mesh Partitioner to redistribute after refinement
  • calculate_parent_facets – Flag to build parent facet information, needed to propagate information on boundaries
void dolfin::PlazaRefinementND::refine(Mesh &new_mesh, const Mesh &mesh, const MeshFunction<bool> &refinement_marker, bool calculate_parent_facets, MeshRelation &mesh_relation)

Refine with markers, optionally calculating facet relations, and saving relation data in MeshRelation structure

Parameters:
  • new_mesh – New Mesh
  • mesh – Input mesh to be refined
  • refinement_markerMeshFunction listing MeshEntities which should be split by this refinement
  • calculate_parent_facets – Flag to build parent facet information, needed to propagate information on boundaries
  • mesh_relation – New relationship between the two meshes
void dolfin::PlazaRefinementND::refine(Mesh &new_mesh, const Mesh &mesh, const MeshFunction<bool> &refinement_marker, bool redistribute, bool calculate_parent_facets)

Refine with markers, optionally redistributing and optionally calculating the parent-child relation for facets (in 2D)

Parameters:
  • new_mesh – New Mesh
  • mesh – Input mesh to be refined
  • refinement_markerMeshFunction listing MeshEntities which should be split by this refinement
  • redistribute – Flag to call the Mesh Partitioner to redistribute after refinement
  • calculate_parent_facets – Flag to build parent facet information, needed to propagate information on boundaries
void dolfin::PlazaRefinementND::set_parent_facet_markers(const Mesh &mesh, Mesh &new_mesh, const std::map<std::size_t, std::size_t> &new_vertex_map)
Parameters:
  • mesh
  • new_mesh
  • new_vertex_map
RegularCutRefinement

C++ documentation for RegularCutRefinement from dolfin/refinement/RegularCutRefinement.h:

class dolfin::RegularCutRefinement

This class implements local mesh refinement by a regular cut of each cell marked for refinement in combination with propagation of cut edges to neighboring cells.

void dolfin::RegularCutRefinement::compute_markers(std::vector<int> &refinement_markers, IndexSet &marked_edges, const Mesh &mesh, const MeshFunction<bool> &cell_markers)
Parameters:
  • refinement_markers
  • marked_edges
  • mesh
  • cell_markers
std::size_t dolfin::RegularCutRefinement::count_markers(const std::vector<bool> &markers)
Parameters:markers
std::size_t dolfin::RegularCutRefinement::extract_edge(const std::vector<bool> &markers)
Parameters:markers
std::pair<std::size_t, std::size_t> dolfin::RegularCutRefinement::find_bisection_edges(const Cell &cell, const Mesh &mesh, std::size_t bisection_twin)
Parameters:
  • cell
  • mesh
  • bisection_twin
std::pair<std::size_t, std::size_t> dolfin::RegularCutRefinement::find_bisection_vertices(const Cell &cell, const Mesh &mesh, std::size_t bisection_twin, const std::pair<std::size_t, std::size_t> &bisection_edges)
Parameters:
  • cell
  • mesh
  • bisection_twin
  • bisection_edges
std::pair<std::size_t, std::size_t> dolfin::RegularCutRefinement::find_common_edges(const Cell &cell, const Mesh &mesh, std::size_t bisection_twin)
Parameters:
  • cell
  • mesh
  • bisection_twin
enum dolfin::RegularCutRefinement::marker_type
enumerator dolfin::RegularCutRefinement::marker_type::no_refinement = -1
enumerator dolfin::RegularCutRefinement::marker_type::regular_refinement = -2
enumerator dolfin::RegularCutRefinement::marker_type::backtrack_bisection = -3
enumerator dolfin::RegularCutRefinement::marker_type::backtrack_bisection_refine = -4
void dolfin::RegularCutRefinement::refine(Mesh &refined_mesh, const Mesh &mesh, const MeshFunction<bool> &cell_markers)

Refine mesh based on cell markers

Parameters:
  • refined_mesh – New Mesh
  • mesh – Input Mesh
  • cell_markers – Markers of MeshEntities to split (typically Cells)
void dolfin::RegularCutRefinement::refine_marked(Mesh &refined_mesh, const Mesh &mesh, const std::vector<int> &refinement_markers, const IndexSet &marked_edges)
Parameters:
  • refined_mesh
  • mesh
  • refinement_markers
  • marked_edges
bool dolfin::RegularCutRefinement::too_thin(const Cell &cell, const std::vector<bool> &edge_markers)
Parameters:
  • cell
  • edge_markers

ufc

Documentation for C++ code found in ffc/backends/ufc/*.h

UFC, Unified Form-assembly Code, is the interface between the form compiler, FFC, and the DOLFIN problem solving environment. You can, in principle, code your own finite elements and weak forms using the UFC interface to “save” you from using the UFL language to specify forms and elements and FFC to compile the forms to C++. In practice very few people implement code for the UFC interface by hand.

Enumerations

shape

C++ documentation for shape from ufc.h:

enum ufc::shape

Valid cell shapes.

enumerator ufc::shape::interval
enumerator ufc::shape::triangle
enumerator ufc::shape::quadrilateral
enumerator ufc::shape::tetrahedron
enumerator ufc::shape::hexahedron

Classes

cell

C++ documentation for cell from ufc.h:

class ufc::cell

This class defines the data structure for a cell in a mesh.

ufc::cell::cell()

Constructor.

shape ufc::cell::cell_shape

Shape of the cell.

std::vector<std::vector<std::size_t>> ufc::cell::entity_indices

Array of global indices for the mesh entities of the cell.

std::size_t ufc::cell::geometric_dimension

Geometric dimension of the mesh.

std::size_t ufc::cell::index

Cell index (short-cut for entity_indices[topological_dimension][0])

int ufc::cell::local_facet

Local facet index.

int ufc::cell::mesh_identifier

Unique mesh identifier.

int ufc::cell::orientation

Cell orientation.

std::size_t ufc::cell::topological_dimension

Topological dimension of the mesh.

ufc::cell::~cell()

Destructor.

cell_integral

C++ documentation for cell_integral from ufc.h:

class ufc::cell_integral

This class defines the interface for the tabulation of the cell tensor corresponding to the local contribution to a form from the integral over a cell.

void ufc::cell_integral::tabulate_tensor(double *A, const double *const *w, const double *coordinate_dofs, int cell_orientation) const = 0

Tabulate the tensor for the contribution from a local cell.

Parameters:
  • A
  • w
  • coordinate_dofs
  • cell_orientation
ufc::cell_integral::~cell_integral()

Destructor.

coordinate_mapping

C++ documentation for coordinate_mapping from ufc.h:

class ufc::coordinate_mapping

A representation of a coordinate mapping parameterized by a local finite element basis on each cell.

shape ufc::coordinate_mapping::cell_shape() const = 0

Return cell shape of the coordinate_mapping .

void ufc::coordinate_mapping::compute_geometry(double *x, double *J, double *detJ, double *K, std::size_t num_points, const double *X, const double *coordinate_dofs, double cell_orientation) const = 0

Combined (for convenience) computation of x, J, detJ, K from X and coordinate_dofs on a cell.

Parameters:
  • x
  • J
  • detJ
  • K
  • num_points
  • X
  • coordinate_dofs
  • cell_orientation
void ufc::coordinate_mapping::compute_jacobian_determinants(double *detJ, std::size_t num_points, const double *J, double cell_orientation) const = 0

Compute determinants of (pseudo-)Jacobians J.

Parameters:
  • detJ
  • num_points
  • J
  • cell_orientation
void ufc::coordinate_mapping::compute_jacobian_inverses(double *K, std::size_t num_points, const double *J, const double *detJ) const = 0

Compute (pseudo-)inverses K of (pseudo-)Jacobians J.

Parameters:
  • K
  • num_points
  • J
  • detJ
void ufc::coordinate_mapping::compute_jacobians(double *J, std::size_t num_points, const double *X, const double *coordinate_dofs) const = 0

Compute X, J, detJ, K from physical coordinates x on a cell // TODO: Can compute all this at no extra cost. Compute Jacobian of coordinate mapping J = dx/dX at reference coordinates X

Parameters:
  • J
  • num_points
  • X
  • coordinate_dofs
void ufc::coordinate_mapping::compute_physical_coordinates(double *x, std::size_t num_points, const double *X, const double *coordinate_dofs) const = 0

Compute physical coordinates x from reference coordinates X, the inverse of compute_reference_coordinates.

Parameters:
  • x
  • num_points
  • X
  • coordinate_dofs
void ufc::coordinate_mapping::compute_reference_coordinates(double *X, std::size_t num_points, const double *x, const double *coordinate_dofs, double cell_orientation) const = 0

Compute reference coordinates X from physical coordinates x, the inverse of compute_physical_coordinates.

Parameters:
  • X
  • num_points
  • x
  • coordinate_dofs
  • cell_orientation
coordinate_mapping *ufc::coordinate_mapping::create() const = 0

Create object of the same type.

dofmap *ufc::coordinate_mapping::create_coordinate_dofmap() const = 0

Create dofmap object representing the coordinate parameterization.

finite_element *ufc::coordinate_mapping::create_coordinate_finite_element() const = 0

Create finite_element object representing the coordinate parameterization.

std::size_t ufc::coordinate_mapping::geometric_dimension() const = 0

Return geometric dimension of the coordinate_mapping .

const char *ufc::coordinate_mapping::signature() const = 0

Return coordinate_mapping signature string.

std::size_t ufc::coordinate_mapping::topological_dimension() const = 0

Return topological dimension of the coordinate_mapping .

ufc::coordinate_mapping::~coordinate_mapping()
custom_integral

C++ documentation for custom_integral from ufc.h:

class ufc::custom_integral

This class defines the interface for the tabulation of the tensor corresponding to the local contribution to a form from the integral over a custom domain defined in terms of a set of quadrature points and weights.

ufc::custom_integral::custom_integral()

Constructor.

std::size_t ufc::custom_integral::num_cells() const = 0

Return the number of cells involved in evaluation of the integral.

void ufc::custom_integral::tabulate_tensor(double *A, const double *const *w, const double *coordinate_dofs, std::size_t num_quadrature_points, const double *quadrature_points, const double *quadrature_weights, const double *facet_normals, int cell_orientation) const = 0

Tabulate the tensor for the contribution from a custom domain.

Parameters:
  • A
  • w
  • coordinate_dofs
  • num_quadrature_points
  • quadrature_points
  • quadrature_weights
  • facet_normals
  • cell_orientation
ufc::custom_integral::~custom_integral()

Destructor.

cutcell_integral

C++ documentation for cutcell_integral from ufc.h:

class ufc::cutcell_integral

This class defines the interface for the tabulation of the tensor corresponding to the local contribution to a form from the integral over a cut cell defined in terms of a set of quadrature points and weights.

ufc::cutcell_integral::cutcell_integral()

Constructor.

void ufc::cutcell_integral::tabulate_tensor(double *A, const double *const *w, const double *coordinate_dofs, std::size_t num_quadrature_points, const double *quadrature_points, const double *quadrature_weights, int cell_orientation) const = 0

Tabulate the tensor for the contribution from a cutcell domain.

Parameters:
  • A
  • w
  • coordinate_dofs
  • num_quadrature_points
  • quadrature_points
  • quadrature_weights
  • cell_orientation
ufc::cutcell_integral::~cutcell_integral()

Destructor.

dofmap

C++ documentation for dofmap from ufc.h:

class ufc::dofmap

This class defines the interface for a local-to-global mapping of degrees of freedom (dofs).

dofmap *ufc::dofmap::create() const = 0

Create a new class instance.

dofmap *ufc::dofmap::create_sub_dofmap(std::size_t i) const = 0

Create a new dofmap for sub dofmap i (for a mixed element)

Parameters:i
std::size_t ufc::dofmap::global_dimension(const std::vector<std::size_t> &num_global_mesh_entities) const = 0

Return the dimension of the global finite element function space.

Parameters:num_global_mesh_entities
bool ufc::dofmap::needs_mesh_entities(std::size_t d) const = 0

Return true iff mesh entities of topological dimension d are needed

Parameters:d
std::size_t ufc::dofmap::num_element_dofs() const = 0

Return the dimension of the local finite element function space for a cell

std::size_t ufc::dofmap::num_entity_closure_dofs(std::size_t d) const = 0

Return the number of dofs associated with the closure of each cell entity dimension d

Parameters:d
std::size_t ufc::dofmap::num_entity_dofs(std::size_t d) const = 0

Return the number of dofs associated with each cell entity of dimension d

Parameters:d
std::size_t ufc::dofmap::num_facet_dofs() const = 0

Return the number of dofs on each cell facet.

std::size_t ufc::dofmap::num_sub_dofmaps() const = 0

Return the number of sub dofmaps (for a mixed element)

const char *ufc::dofmap::signature() const = 0

Return a string identifying the dofmap.

void ufc::dofmap::tabulate_dofs(std::size_t *dofs, const std::vector<std::size_t> &num_global_entities, const std::vector<std::vector<std::size_t>> &entity_indices) const = 0

Tabulate the local-to-global mapping of dofs on a cell.

Parameters:
  • dofs
  • num_global_entities
  • entity_indices
void ufc::dofmap::tabulate_entity_closure_dofs(std::size_t *dofs, std::size_t d, std::size_t i) const = 0

Tabulate the local-to-local mapping of dofs on the closure of entity (d, i)

Parameters:
  • dofs
  • d
  • i
void ufc::dofmap::tabulate_entity_dofs(std::size_t *dofs, std::size_t d, std::size_t i) const = 0

Tabulate the local-to-local mapping of dofs on entity (d, i)

Parameters:
  • dofs
  • d
  • i
void ufc::dofmap::tabulate_facet_dofs(std::size_t *dofs, std::size_t facet) const = 0

Tabulate the local-to-local mapping from facet dofs to cell dofs.

Parameters:
  • dofs
  • facet
std::size_t ufc::dofmap::topological_dimension() const = 0

Return the topological dimension of the associated cell shape.

ufc::dofmap::~dofmap()

Destructor.

exterior_facet_integral

C++ documentation for exterior_facet_integral from ufc.h:

class ufc::exterior_facet_integral

This class defines the interface for the tabulation of the exterior facet tensor corresponding to the local contribution to a form from the integral over an exterior facet.

void ufc::exterior_facet_integral::tabulate_tensor(double *A, const double *const *w, const double *coordinate_dofs, std::size_t facet, int cell_orientation) const = 0

Tabulate the tensor for the contribution from a local exterior facet.

Parameters:
  • A
  • w
  • coordinate_dofs
  • facet
  • cell_orientation
ufc::exterior_facet_integral::~exterior_facet_integral()

Destructor.

finite_element

C++ documentation for finite_element from ufc.h:

class ufc::finite_element

This class defines the interface for a finite element.

shape ufc::finite_element::cell_shape() const = 0

Return the cell shape.

finite_element *ufc::finite_element::create() const = 0

Create a new class instance.

finite_element *ufc::finite_element::create_sub_element(std::size_t i) const = 0

Create a new finite element for sub element i (for a mixed element)

Parameters:i
std::size_t ufc::finite_element::degree() const = 0

Return the maximum polynomial degree of the finite element function space.

void ufc::finite_element::evaluate_basis(std::size_t i, double *values, const double *x, const double *coordinate_dofs, int cell_orientation) const = 0

Evaluate basis function i at given point x in cell.

Parameters:
  • i
  • values
  • x
  • coordinate_dofs
  • cell_orientation
void ufc::finite_element::evaluate_basis_all(double *values, const double *x, const double *coordinate_dofs, int cell_orientation) const = 0

Evaluate all basis functions at given point x in cell.

Parameters:
  • values
  • x
  • coordinate_dofs
  • cell_orientation
void ufc::finite_element::evaluate_basis_derivatives(std::size_t i, std::size_t n, double *values, const double *x, const double *coordinate_dofs, int cell_orientation) const = 0

Evaluate order n derivatives of basis function i at given point x in cell.

Parameters:
  • i
  • n
  • values
  • x
  • coordinate_dofs
  • cell_orientation
void ufc::finite_element::evaluate_basis_derivatives_all(std::size_t n, double *values, const double *x, const double *coordinate_dofs, int cell_orientation) const = 0

Evaluate order n derivatives of all basis functions at given point x in cell.

Parameters:
  • n
  • values
  • x
  • coordinate_dofs
  • cell_orientation
double ufc::finite_element::evaluate_dof(std::size_t i, const function &f, const double *coordinate_dofs, int cell_orientation, const cell &c) const = 0

Evaluate linear functional for dof i on the function f.

Parameters:
  • i
  • f
  • coordinate_dofs
  • cell_orientation
  • c
void ufc::finite_element::evaluate_dofs(double *values, const function &f, const double *coordinate_dofs, int cell_orientation, const cell &c) const = 0

Evaluate linear functionals for all dofs on the function f.

Parameters:
  • values
  • f
  • coordinate_dofs
  • cell_orientation
  • c
const char *ufc::finite_element::family() const = 0

Return the family of the finite element function space.

std::size_t ufc::finite_element::geometric_dimension() const = 0

Return the geometric dimension of the cell shape.

void ufc::finite_element::interpolate_vertex_values(double *vertex_values, const double *dof_values, const double *coordinate_dofs, int cell_orientation, const cell &c) const = 0

Interpolate vertex values from dof values.

Parameters:
  • vertex_values
  • dof_values
  • coordinate_dofs
  • cell_orientation
  • c
std::size_t ufc::finite_element::num_sub_elements() const = 0

Return the number of sub elements (for a mixed element)

std::size_t ufc::finite_element::reference_value_dimension(std::size_t i) const = 0

Return the dimension of the reference value space for axis i.

Parameters:i
std::size_t ufc::finite_element::reference_value_rank() const = 0

Return the rank of the reference value space.

std::size_t ufc::finite_element::reference_value_size() const = 0

Return the number of components of the reference value space.

const char *ufc::finite_element::signature() const = 0

Return a string identifying the finite element.

std::size_t ufc::finite_element::space_dimension() const = 0

Return the dimension of the finite element function space.

void ufc::finite_element::tabulate_dof_coordinates(double *dof_coordinates, const double *coordinate_dofs) const = 0

Tabulate the coordinates of all dofs on a cell.

Parameters:
  • dof_coordinates
  • coordinate_dofs
std::size_t ufc::finite_element::topological_dimension() const = 0

Return the topological dimension of the cell shape.

std::size_t ufc::finite_element::value_dimension(std::size_t i) const = 0

Return the dimension of the value space for axis i.

Parameters:i
std::size_t ufc::finite_element::value_rank() const = 0

Return the rank of the value space.

std::size_t ufc::finite_element::value_size() const = 0

Return the number of components of the value space.

ufc::finite_element::~finite_element()

Destructor.

form

C++ documentation for form from ufc.h:

class ufc::form

This class defines the interface for the assembly of the global tensor corresponding to a form with r + n arguments, that is, a mapping

a : V1 x V2 x ... Vr x W1 x W2 x ... x Wn -> R

with arguments v1, v2, ..., vr, w1, w2, ..., wn. The rank r global tensor A is defined by

A = a(V1, V2, ..., Vr, w1, w2, ..., wn),

where each argument Vj represents the application to the sequence of basis functions of Vj and w1, w2, ..., wn are given fixed functions (coefficients).

cell_integral *ufc::form::create_cell_integral(std::size_t subdomain_id) const = 0

Create a new cell integral on sub domain subdomain_id.

Parameters:subdomain_id
dofmap *ufc::form::create_coordinate_dofmap() const = 0

Create a new dofmap for parameterization of coordinates.

finite_element *ufc::form::create_coordinate_finite_element() const = 0

Create a new finite element for parameterization of coordinates.

coordinate_mapping *ufc::form::create_coordinate_mapping() const = 0

Create a new coordinate mapping.

custom_integral *ufc::form::create_custom_integral(std::size_t subdomain_id) const = 0

Create a new custom integral on sub domain subdomain_id.

Parameters:subdomain_id
cutcell_integral *ufc::form::create_cutcell_integral(std::size_t subdomain_id) const = 0

Create a new cutcell integral on sub domain subdomain_id.

Parameters:subdomain_id
cell_integral *ufc::form::create_default_cell_integral() const = 0

Create a new cell integral on everywhere else.

custom_integral *ufc::form::create_default_custom_integral() const = 0

Create a new custom integral on everywhere else.

cutcell_integral *ufc::form::create_default_cutcell_integral() const = 0

Create a new cutcell integral on everywhere else.

exterior_facet_integral *ufc::form::create_default_exterior_facet_integral() const = 0

Create a new exterior facet integral on everywhere else.

interface_integral *ufc::form::create_default_interface_integral() const = 0

Create a new interface integral on everywhere else.

interior_facet_integral *ufc::form::create_default_interior_facet_integral() const = 0

Create a new interior facet integral on everywhere else.

overlap_integral *ufc::form::create_default_overlap_integral() const = 0

Create a new overlap integral on everywhere else.

vertex_integral *ufc::form::create_default_vertex_integral() const = 0

Create a new vertex integral on everywhere else.

dofmap *ufc::form::create_dofmap(std::size_t i) const = 0

Create a new dofmap for argument function 0 <= i < r+n.

Parameters:i
exterior_facet_integral *ufc::form::create_exterior_facet_integral(std::size_t subdomain_id) const = 0

Create a new exterior facet integral on sub domain subdomain_id.

Parameters:subdomain_id
finite_element *ufc::form::create_finite_element(std::size_t i) const = 0

Create a new finite element for argument function 0 <= i < r+n.

Parameters:i
interface_integral *ufc::form::create_interface_integral(std::size_t subdomain_id) const = 0

Create a new interface integral on sub domain subdomain_id.

Parameters:subdomain_id
interior_facet_integral *ufc::form::create_interior_facet_integral(std::size_t subdomain_id) const = 0

Create a new interior facet integral on sub domain subdomain_id.

Parameters:subdomain_id
overlap_integral *ufc::form::create_overlap_integral(std::size_t subdomain_id) const = 0

Create a new overlap integral on sub domain subdomain_id.

Parameters:subdomain_id
vertex_integral *ufc::form::create_vertex_integral(std::size_t subdomain_id) const = 0

Create a new vertex integral on sub domain subdomain_id.

Parameters:subdomain_id
bool ufc::form::has_cell_integrals() const = 0

Return whether form has any cell integrals.

bool ufc::form::has_custom_integrals() const = 0

Return whether form has any custom integrals.

bool ufc::form::has_cutcell_integrals() const = 0

Return whether form has any cutcell integrals.

bool ufc::form::has_exterior_facet_integrals() const = 0

Return whether form has any exterior facet integrals.

bool ufc::form::has_interface_integrals() const = 0

Return whether form has any interface integrals.

bool ufc::form::has_interior_facet_integrals() const = 0

Return whether form has any interior facet integrals.

bool ufc::form::has_overlap_integrals() const = 0

Return whether form has any overlap integrals.

bool ufc::form::has_vertex_integrals() const = 0

Return whether form has any vertex integrals.

std::size_t ufc::form::max_cell_subdomain_id() const = 0

Return the upper bound on subdomain ids for cell integrals.

std::size_t ufc::form::max_custom_subdomain_id() const = 0

Return the upper bound on subdomain ids for custom integrals.

std::size_t ufc::form::max_cutcell_subdomain_id() const = 0

Return the upper bound on subdomain ids for cutcell integrals.

std::size_t ufc::form::max_exterior_facet_subdomain_id() const = 0

Return the upper bound on subdomain ids for exterior facet integrals.

std::size_t ufc::form::max_interface_subdomain_id() const = 0

Return the upper bound on subdomain ids for interface integrals.

std::size_t ufc::form::max_interior_facet_subdomain_id() const = 0

Return the upper bound on subdomain ids for interior facet integrals.

std::size_t ufc::form::max_overlap_subdomain_id() const = 0

Return the upper bound on subdomain ids for overlap integrals.

std::size_t ufc::form::max_vertex_subdomain_id() const = 0

Return the upper bound on subdomain ids for vertex integrals.

std::size_t ufc::form::num_coefficients() const = 0

Return the number of coefficients (n)

std::size_t ufc::form::original_coefficient_position(std::size_t i) const = 0

Return original coefficient position for each coefficient (0 <= i < n)

Parameters:i
std::size_t ufc::form::rank() const = 0

Return the rank of the global tensor (r)

const char *ufc::form::signature() const = 0

Return a string identifying the form.

ufc::form::~form()

Destructor.

function

C++ documentation for function from ufc.h:

class ufc::function

This class defines the interface for a general tensor-valued function.

void ufc::function::evaluate(double *values, const double *coordinates, const cell &c) const = 0

Evaluate function at given point in cell.

Parameters:
  • values
  • coordinates
  • c
ufc::function::~function()

Destructor.

integral

C++ documentation for integral from ufc.h:

class ufc::integral

This class defines the shared interface for classes implementing the tabulation of a tensor corresponding to the local contribution to a form from an integral.

const std::vector<bool> &ufc::integral::enabled_coefficients() const = 0

Tabulate which form coefficients are used by this integral.

ufc::integral::~integral()

Destructor.

interface_integral

C++ documentation for interface_integral from ufc.h:

class ufc::interface_integral

This class defines the interface for the tabulation of the tensor corresponding to the local contribution to a form from the integral over a cut cell defined in terms of a set of quadrature points and weights.

ufc::interface_integral::interface_integral()

Constructor.

void ufc::interface_integral::tabulate_tensor(double *A, const double *const *w, const double *coordinate_dofs, std::size_t num_quadrature_points, const double *quadrature_points, const double *quadrature_weights, const double *facet_normals, int cell_orientation) const = 0

Tabulate the tensor for the contribution from an interface domain.

Parameters:
  • A
  • w
  • coordinate_dofs
  • num_quadrature_points
  • quadrature_points
  • quadrature_weights
  • facet_normals
  • cell_orientation
ufc::interface_integral::~interface_integral()

Destructor.

interior_facet_integral

C++ documentation for interior_facet_integral from ufc.h:

class ufc::interior_facet_integral

This class defines the interface for the tabulation of the interior facet tensor corresponding to the local contribution to a form from the integral over an interior facet.

void ufc::interior_facet_integral::tabulate_tensor(double *A, const double *const *w, const double *coordinate_dofs_0, const double *coordinate_dofs_1, std::size_t facet_0, std::size_t facet_1, int cell_orientation_0, int cell_orientation_1) const = 0

Tabulate the tensor for the contribution from a local interior facet.

Parameters:
  • A
  • w
  • coordinate_dofs_0
  • coordinate_dofs_1
  • facet_0
  • facet_1
  • cell_orientation_0
  • cell_orientation_1
ufc::interior_facet_integral::~interior_facet_integral()

Destructor.

overlap_integral

C++ documentation for overlap_integral from ufc.h:

class ufc::overlap_integral

This class defines the interface for the tabulation of the tensor corresponding to the local contribution to a form from the integral over the overlapped portion of a cell defined in terms of a set of quadrature points and weights.

ufc::overlap_integral::overlap_integral()

Constructor.

void ufc::overlap_integral::tabulate_tensor(double *A, const double *const *w, const double *coordinate_dofs, std::size_t num_quadrature_points, const double *quadrature_points, const double *quadrature_weights, int cell_orientation) const = 0

Tabulate the tensor for the contribution from an overlap domain.

Parameters:
  • A
  • w
  • coordinate_dofs
  • num_quadrature_points
  • quadrature_points
  • quadrature_weights
  • cell_orientation
ufc::overlap_integral::~overlap_integral()

Destructor.

vertex_integral

C++ documentation for vertex_integral from ufc.h:

class ufc::vertex_integral

This class defines the interface for the tabulation of an expression evaluated at exactly one point.

void ufc::vertex_integral::tabulate_tensor(double *A, const double *const *w, const double *coordinate_dofs, std::size_t vertex, int cell_orientation) const = 0

Tabulate the tensor for the contribution from the local vertex.

Parameters:
  • A
  • w
  • coordinate_dofs
  • vertex
  • cell_orientation
ufc::vertex_integral::vertex_integral()

Constructor.

ufc::vertex_integral::~vertex_integral()

Destructor.

API documentation (Python)

Work in progress

The Python documentation is missing, see our old docs for now.

Full API

We should split this somehow

Developer resources

DOLFIN development takes place on Bitbucket. For information about how to get involved and how to get in touch with the developers, see our community page.

C++ coding style guide

Naming conventions

Class names

Use camel caps for class names:

class FooBar
{
  ...
};
Function names

Use lower-case for function names and underscore to separate words:

foo();
bar();
foo_bar(...);

Functions returning a value should be given the name of that value, for example:

class Array:
{
public:

  /// Return size of array (number of entries)
  std::size_t size() const;

};

In the above example, the function should be named size rather than get_size. On the other hand, a function not returning a value but rather taking a variable (by reference) and assigning a value to it, should use the get_foo naming scheme, for example:

class Parameters:
{
public:

  /// Retrieve all parameter keys
  void get_parameter_keys(std::vector<std::string>& parameter_keys) const;

};
Variable names

Use lower-case for variable names and underscore to separate words:

Foo foo;
Bar bar;
FooBar foo_bar;
Enum variables and constants

Enum variables should be lower-case with underscore to separate words:

enum Type {foo, bar, foo_bar};

We try to avoid using #define to define constants, but when necessary constants should be capitalized:

#define FOO 3.14159265358979
File names

Use camel caps for file names if they contain the declaration/definition of a class. Header files should have the suffix .h and implementation files should have the suffix .cpp:

FooBar.h
FooBar.cpp

Use lower-case for file names that contain utilities/functions (not classes).

Miscellaneous

Indentation

Indentation should be two spaces and it should be spaces. Do not use tab(s).

Comments

Comment your code, and do it often. Capitalize the first letter and don’t use punctuation (unless the comment runs over several sentences). Here’s a good example from TopologyComputation.cpp:

// Check if connectivity has already been computed
if (connectivity.size() > 0)
  return;

// Invalidate ordering
mesh._ordered = false;

// Compute entities if they don't exist
if (topology.size(d0) == 0)
  compute_entities(mesh, d0);
if (topology.size(d1) == 0)
  compute_entities(mesh, d1);

// Check if connectivity still needs to be computed
if (connectivity.size() > 0)
  return;

...

Always use // for comments and /// for documentation (see Documenting the interface (Programmer’s reference)). Never use /* ... */, not even for comments that runs over multiple lines.

Integers and reals

Use std::size_t instead of int (unless you really want to use negative integers or memory usage is critical).

std::size_t i = 0;
double x = 0.0;
Placement of brackets and indent style

Use the BSD/Allman style when formatting blocks of code, i.e., curly brackets following multiline control statements should appear on the next line and should not be indented:

for (std::size_t i = 0; i < 10; i++)
{
  ...
}

For one line statements, omit the brackets:

for (std::size_t i = 0; i < 10; i++)
  foo(i);
Header file layout

Header files should follow the below template:

// Copyright (C) 2008 Foo Bar
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// Modified by Bar Foo 2008

#ifndef __FOO_H
#define __FOO_H

namespace dolfin
{

  class Bar; // Forward declarations here

  /// Documentation of class

  class Foo
  {
  public:

    ...

  private:

    ...

  };

}

#endif
Implementation file layout

Implementation files should follow the below template:

// Copyright (C) 2008 Foo Bar
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// Modified by Bar Foo 2008

#include <dolfin/Foo.h>

using namespace dolfin;

//-----------------------------------------------------------------------------
Foo::Foo() : // variable initialization here
{
  ...
}
//-----------------------------------------------------------------------------
Foo::~Foo()
{
  // Do nothing
}
//-----------------------------------------------------------------------------

The horizontal lines above (including the slashes) should be exactly 79 characters wide.

Including header files and using forward declarations

Do not use #include <dolfin.h> or #include <dolfin/dolfin_foo.h> inside the DOLFIN source tree. Only include the portions of DOLFIN you are actually using.

Include as few header files as possible and use forward declarations whenever possible (in header files). Put the #include in the implementation file. This reduces compilation time and minimizes the risk of cyclic dependencies.

Explicit constructors

Make all one argument constructors (except copy constructors) explicit:

class Foo
{
  explicit Foo(std::size_t i);
};
Virtual functions

Always declare inherited virtual functions as virtual in the subclasses. This makes it easier to spot which functions are virtual.

class Foo
{
  virtual void foo();
  virtual void bar() = 0;
};

class Bar : public Foo
{
  virtual void foo();
  virtual void bar();
};

Use of libraries

Prefer C++ strings and streams over old C-style char*

Use std::string instead of const char* and use std::istream and std::ostream instead of FILE. Avoid printf, sprintf and other C functions.

There are some exceptions to this rule where we need to use old C-style function calls. One such exception is handling of command-line arguments (char* argv[]).

Prefer smart pointers over plain pointers

Use std::shared_ptr and std::unique_ptr in favour of plain pointers. Smart pointers reduce the likelihood of memory leaks and make ownership clear. Use unique_ptr for a pointer that is not shared and shared_ptr when multiple pointers point to the same object.

Documenting the interface (Programmer’s reference)

The DOLFIN Programmer’s Reference is generated for the DOLFIN C++ library and Python module from the source code using the documentation tool Sphinx. This page describes how to generate the DOLFIN documentation locally and how to extend the contents of the Programmer’s Reference.

How to locally build the DOLFIN documentation

The DOLFIN documentation can be generated and built from the DOLFIN source directly as follows:

  • Make sure that Sphinx is installed.

  • Go to the doc/ directory

  • Build the documentation by running:

    make html

  • Study the results in doc/build/html or dolfin/swig/*/docstrings.i

How to improve and extend the DOLFIN Programmer’s reference

The documentation contents are extracted from specially formatted comments (docstring comments) in the source code, converted to reStructuredText, and formatted using Sphinx. The syntax used for these specially formatted comments is described below.

To document a feature,

  1. Add appropriate docstring comments to source files (see Syntax for docstring comments).
  2. Build the documentation as described in How to locally build the DOLFIN documentation to check the result.
Syntax for docstring comments

Doxygen is used to parse the C++ header files for special comments, we generally use comments starting with ///. For information on the required format, see the doxygen documentation http://www.doxygen.org/manual/index.html

In addition we try to support some Sphinx syntax like :math:`\lambda_3`. We may add some more special tricks like raw ReStructuredText passthrough, but in general you should stick to normal doxygen syntax

Change log

2017.1.0 (2017-05-09)

  • Refactor PETScLUSolver to use functionality from PETScKrylovSolver. Simplify interface for solving transposed systems. Fixes #815.
  • Switch default Python version to Python 3. Use -DDOLFIN_USE_PYTHON3=off to build with Python 2.
  • Remove redundant solve_transpose functions (use solve with bool argument instead)
  • Remove OpenMpAsssmebler
  • Remove MPI communicator as argument in GenericVector::init functions (communicator should be passed via constructor)
  • Remove Function::operator[+-*/] to prevent memory corruption problems (does not affect Python interface)
  • Fix XDMF3 output of time series. The default output method is now to assume that all functions have different meshes, and that the meshes change from time step to time step. Two parameters control the output, one limits each function to only one mesh for the whole time series, turn off the default on parameter rewrite_function_mesh to enable this. You can also make all functions share the same mesh and time series, which currently is better supported in Paraview than the alternative, turn on functions_share_mesh for this. These two parameters can also be combined in case all functions share the same mesh at all time steps. This creates minimal size files.
  • Add PETScSNESSolver and PETScTAOSolver constructor accepting both communicator and type
  • Expression(“f[0]*f[1]”, f=obj) notation now supported for non-scalar GenericFunction obj
  • Expression(“f”, f=obj) notation now supports obj of MeshFunction types (only cell based)
  • Fix MPI deadlock in case of instant compilation failure
  • Allow using Timer as context manager and add timed decorator to measure timings of functions and methods
  • Add NonlinearProblem::J_pc and support preconditioning matrix in NewtonSolver, PETScSNESSolver and PETScTAOSolver

2016.2.0 [2016-11-30]

  • Updates to XDMFFile interface, now fully supporting MeshFunction and MeshValueCollection with multiple named datasets in one file (useful for volume/boundary markers). Time series now only when a time is explicitly specified for each step. Full support for ASCII/XML XDMF.
  • Improved X3DOM support
  • Improved detection of UFC
  • Add CMake option -DDOLFIN_USE_PYTHON3 to create a Python 3 build
  • Require CMake version 3.5 or higher
  • Add pylit to generate demo doc from rst
  • More careful checks of Dirichlet BC function spaces
  • Change definition of FunctionSpace::component()
  • Adaptive solving now works for tensor-valued unknowns
  • Improve logging of PETSc errors; details logged at level TRACE

2016.1.0 [2016-06-23]

  • Remove support for ‘uint’-valued MeshFunction (replaced by ‘size_t’)
  • Major performance improvements and simplifications of the XDMF IO.
  • Remove Zoltan graph partitioning interface
  • Add new algorithm for computing mesh entiites. Typical speed-up of two with gcc and four with clang. Reduced memory usage for meshes with irregularly numbered cells.
  • Remove STLMatrix, STLVector, MUMPSLUSolver and PastixLUSolver classes
  • Remove PETScPreconditioner::set_near_nullspace and add PETScMatrix::set_near_nullspace
  • Build system updates for VTK 7.0
  • Remove XDMF from File interface. XDMF is XML based, and has many possibilities for file access, which are not accessible through the limited File interface and “<<” “>>” operators. Instead of File, use XDMFFile, and use XDMFFile.read() and XDMFFile.write() for I/O. Demos and tests have been updated to show usage. XDMF now also supports ASCII I/O in serial, useful for compatibility with users who do not have the HDF5 library available.
  • Require polynomial degree or finite element for Expressions in the Python interface (fixes Issue #355, https://bitbucket.org/fenics-project/dolfin/issues/355)
  • Switch to Google Test framwork for C++ unit tests
  • Fix bug when reading domain data from mesh file for a ghosted mesh
  • Add interface for manipulating mesh geometry using (higher-order) FE functions: free functions set_coordinates, get_coordinates, create_mesh
  • Fix bug when reading domain data from mesh file for a ghosted mesh.
  • Remove reference versions of constructors for many classes that store a pointer/reference to the object passed to the constructor. This is an intrusive interface change for C++ users, but necessary to improve code maintainabilty and to improve memory safety. The Python interface is (virtually) unaffected.
  • Remove class SubSpace. Using FunctionSpace::sub(...) instead
  • Remove reference versions constructors of NonlinearVariationalSolver
  • Remove setting of bounds from NonlinearVariationalSolver (was already available through NonlinearVariationalProblem)
  • Update Trilinos support to include Amesos2, and better support from Python
  • Rewrite interface of TensorLayout and SparsityPattern; local-to-global maps now handled using new IndexMap class; GenericSparsityPattern class removed
  • Remove QT (was an optional dependency)
  • PETScTAOSolver::solve() now returns a pair of number of iterations (std::size_t) and whether iteration converged (bool)
  • Better quality refinement in 2D in Plaza algorithm, by choosing refinement pattern based on max/min edge ratio
  • Removed refine_cell() method in CellTypes
  • Enable marker refinement to work in parallel for 1D meshes too
  • Add std::abort to Python exception hook to avoid parallel deadlocks
  • Extend dof_to_vertex_map with unowned dofs, thus making dof_to_vertex_map an inverse of vertex_to_dof_map
  • Clean-up in PyDOLFIN function space design, issue #576
  • Deprecate MixedFunctionSpace and EnrichedFunctionSpace in favour of initialization by suitable UFL element
  • Add experimental matplotlib-based plotting backend, see mplot demo
  • Remove method argument of DirichletBC::get_boundary_values()
  • Change return types of free functions adapt() to shared_ptr

1.6.0 [2015-07-28]

  • Remove redundant pressure boundary condition in Stokes demos
  • Require Point in RectangleMesh and BoxMesh constructors
  • Remove BinaryFile (TimeSeries now requires HDF5)
  • Add (highly experimental) support for Tpetra matrices and vectors from Trilinos, interfacing to Belos, Amesos2, IfPack2 and Muelu.
  • Enable (highly experimental) support for Quadrilateral and Hexahedral meshes, including some I/O, but no assembly yet.
  • Enable UMFPACK and CHOLMOD solvers with Eigen backend
  • Add an MPI_Comm to logger, currently defaulted to MPI_COMM_WORLD allowing better control over output in parallel
  • Experimental output of quadratic geometry in XDMF files, allows more exact visualisation of P2 Functions
  • Remove GenericMatrix::compressed (see Issue #61)
  • Deprecate and PETScKryloveSolver::set_nullspace() and add PETScMatrix::set_nullspace()
  • Remove uBLAS backend
  • Remove UmfpackLUSolver and CholmodSolver
  • Add EigenMatrix/Vector::data()
  • Remove GenericMatrix/Vector::data() and GenericMatrix/Vector::data() (to use backends that support data(), cast first to backend type, e.g. A = A.as_backend_type()
  • Remove cmake.local, replaced by fenics-install-component.sh
  • Make interior facet integrals define - and + cells ordered by cell_domains value.
  • Remove deprecated arguments *_domains from assemble() and Form().
  • Change measure definition notation from dx[mesh_function] to dx(subdomain_data=mesh_function).
  • Set locale to “C” before reading from file
  • Change GenericDofMap::cell_dofs return type from const std::vector<..>& to ArrayView<const ..>
  • Add ArrayView class for views into arrays
  • Change fall back linear algebra backend to Eigen
  • Add Eigen linear algebra backend
  • Remove deprecated GenericDofMap::geometric_dim function (fixes Issue #443)
  • Add quadrature rules for multimesh/cut-cell integration up to order 6
  • Implement MPI reductions and XML ouput of Table class
  • list_timings() is now collective and returns MPI average across processes
  • Add dump_timings_to_xml()
  • Add enum TimingType { wall, user, system } for selecting wall-clock, user and system time in timing routines
  • Bump required SWIG version to 3.0.3
  • Increase default maximum iterations in NewtonSolver to 50.
  • Deprecate Python free function homogenize(bc) in favour of member function DirichletBC::homogenize()

1.5.0 [2015-01-12]

  • DG demos working in parallel
  • Simplify re-use of LU factorisations
  • CMake 3 compatibility
  • Make underlying SLEPc object accessible
  • Full support for linear algebra backends with 64-bit integers
  • Add smoothed aggregation AMG elasticity demo
  • Add support for slepc4py
  • Some self-assignment fixes in mesh data structures
  • Deprecated GenericDofMap::geometric_dimension()
  • Experimental support for ghosted meshes (overlapping region in parallel)
  • Significant memory reduction in dofmap storage
  • Re-write dofmap construction with significant performance and scaling improvements in parallel
  • Switch to local (process-wise) indexing for dof indices
  • Support local (process-wise) indexing in linear algerbra backends
  • Added support for PETSc 3.5, require version >= 3.3
  • Exposed DofMap::tabulate_local_to_global_dofs, MeshEntity::sharing_processes in Python
  • Added GenericDofmap::local_dimension(“all”|”owned”|”unowned”)
  • Added access to SLEPc or slepc4py EPS object of SLEPcEigenSolver (requires slepc4py version >= 3.5.1)
  • LinearOperator can now be accessed using petsc4py
  • Add interface (PETScTAOSolver) for the PETSc nonlinear (bound-constrained) optimisation solver (TAO)
  • Add GenericMatrix::nnz() function to return number of nonzero entries in matrix (fixes #110)
  • Add smoothed aggregation algerbraic multigrid demo for elasticity
  • Add argument ‘function’ to project, to store the result into a preallocated function
  • Remove CGAL dependency and mesh generation, now provided by mshr
  • Python 2.7 required
  • Add experimental Python 3 support. Need swig version 3.0.3 or later
  • Move to py.test, speed up unit tests and make tests more robust in parallel
  • Repeated initialization of PETScMatrix is now an error
  • MPI interface change: num_processes -> size, process_number -> rank
  • Add optional argument project(..., function=f), to avoid superfluous allocation
  • Remove excessive printing of points during extrapolation
  • Clean up DG demos by dropping restrictions of Constants: c(‘+’) -> c
  • Fix systemassembler warning when a and L both provide the same subdomain data.
  • Require mesh instead of cell argument to FacetArea, FacetNormal, CellSize, CellVolume, SpatialCoordinate, Circumradius, MinFacetEdgeLength, MaxFacetEdgeLength
  • Remove argument reset_sparsity to assemble()
  • Simplify assemble() and Form() signature: remove arguments mesh, coefficients, function_spaces, common_cell. These are now all found by inspecting the UFL form
  • Speed up assembly of forms with multiple integrals depending on different functions, e.g. f*dx(1) + g*dx(2).
  • Handle accessing of GenericVectors using numpy arrays in python layer instead of in hard-to-maintain C++ layer
  • Add support for mpi groups in jit-compilation
  • Make access to HDFAttributes more dict like
  • Add 1st and 2nd order Rush Larsen schemes for the PointIntegralSolver
  • Add vertex assembler for PointIntegrals
  • Add support for assembly of custom_integral
  • Add support for multimesh assembly, function spaces, dofmaps and functions
  • Fix to Cell-Point collision detection to prevent Points inside the mesh from falling between Cells due to rounding errors
  • Enable reordering of cells and vertices in parallel via SCOTCH and the Giibs-Poole-Stockmeyer algorithm
  • Efficiency improvements in dof assignment in parallel, working on HPC up to 24000 cores
  • Introduction of PlazaRefinement methods based on refinement of the Mesh skeleton, giving better quality refinement in 3D in parallel
  • Basic support for ‘ghost cells’ allowing integration over interior facets in parallel

1.4.0 [2014-06-02]

  • Feature: Add set_diagonal (with GenericVector) to GenericMatrix
  • Fix many bugs associated with cell orientations on manifolds
  • Force all global dofs to be ordered last and to be on the last process in parallel
  • Speed up dof reordering of mixed space including global dofs by removing the latter from graph reordering
  • Force all dofs on a shared facet to be owned by the same process
  • Add FEniCS (‘fenics’) Python module, identical with DOLFIN Python module
  • Add function Form::set_some_coefficients()
  • Remove Boost.MPI dependency
  • Change GenericMatrix::compresss to return a new matrix (7be3a29)
  • Add function GenericTensor::empty()
  • Deprecate resizing of linear algebra via the GenericFoo interfaces (fixes #213)
  • Deprecate MPI::process_number() in favour of MPI::rank(MPI_Comm)
  • Use PETSc built-in reference counting to manage lifetime of wrapped PETSc objects
  • Remove random access function from MeshEntityIterator (fixes #178)
  • Add support for VTK 6 (fixes #149)
  • Use MPI communicator in interfaces. Permits the creation of distributed and local objects, e.g. Meshes.
  • Reduce memory usage and increase speed of mesh topology computation

1.3.0 [2014-01-07]

  • Feature: Enable assignment of sparse MeshValueCollections to MeshFunctions
  • Feature: Add free function assign that is used for sub function assignment
  • Feature: Add class FunctionAssigner that cache dofs for sub function assignment
  • Fix runtime dependency on checking swig version
  • Deprecate DofMap member methods vertex_to_dof_map and dof_to_vertex_map
  • Add free functions: vertex_to_dof_map and dof_to_vertex_map, and correct the ordering of the map.
  • Introduce CompiledSubDomain a more robust version of compiled_subdomains, which is now deprecated
  • CMake now takes care of calling the correct generate-foo script if so needed.
  • Feature: Add new built-in computational geometry library (BoundingBoxTree)
  • Feature: Add support for setting name and label to an Expression when constructed
  • Feature: Add support for passing a scalar GenericFunction as default value to a CompiledExpression
  • Feature: Add support for distance queries for 3-D meshes
  • Feature: Add PointIntegralSolver, which uses the MultiStageSchemes to solve local ODEs at Vertices
  • Feature: Add RKSolver and MultiStageScheme for general time integral solvers
  • Feature: Add support for assigning a Function with linear combinations of Functions, which lives in the same FunctionSpace
  • Added Python wrapper for SystemAssembler
  • Added a demo using compiled_extension_module with separate source files
  • Fixes for NumPy 1.7
  • Remove DOLFIN wrapper code (moved to FFC)
  • Add set_options_prefix to PETScKrylovSolver
  • Remove base class BoundarCondition
  • Set block size for PETScMatrix when available from TensorLayout
  • Add support to get block compressed format from STLMatrix
  • Add detection of block structures in the dofmap for vector equations
  • Expose PETSc GAMG parameters
  • Modify SystemAssembler to support separate assembly of A and b

1.2.0 [2013-03-24]

  • Fixes bug where child/parent hierarchy in Python were destroyed
  • Add utility script dolfin-get-demos
  • MeshFunctions in python now support iterable protocol
  • Add timed VTK output for Mesh and MeshFunction in addtion to Functions
  • Expose ufc::dofmap::tabulate_entity_dofs to GenericDofMap interface
  • Expose ufc::dofmap::num_entity_dofs to GenericDofMap interface
  • Allow setting of row dof coordinates in preconditioners (only works with PETSc backed for now)
  • Expose more PETSc/ML parameters
  • Improve speed to tabulating coordinates in some DofMap functions
  • Feature: Add support for passing a Constant as default value to a CompiledExpression
  • Fix bug in dimension check for 1-D ALE
  • Remove some redundant graph code
  • Improvements in speed of parallel dual graph builder
  • Fix bug in XMDF output for cell-based Functions
  • Fixes for latest version of clang compiler
  • LocalSolver class added to efficiently solve cell-wise problems
  • New implementation of periodic boundary conditions. Now incorporated into the dofmap
  • Optional arguments to assemblers removed
  • SymmetricAssembler removed
  • Domains for assemblers can now only be attached to forms
  • SubMesh can now be constructed without a CellFunction argument, if the MeshDomain contains marked celldomains.
  • MeshDomains are propagated to a SubMesh during construction
  • Simplify generation of a MeshFunction from MeshDomains: No need to call mesh_function with mesh
  • Rename dolfin-config.cmake to DOLFINConfig.cmake
  • Use CMake to configure JIT compilation of extension modules
  • Feature: Add vertex_to_dof_map to DofMap, which map vertex indices to dolfin dofs
  • Feature: Add support for solving on m dimensional meshes embedded in n >= m dimensions

1.1.0 [2013-01-08]

  • Add support for solving singular problems with Krylov solvers (PETSc only)
  • Add new typedef dolfin::la_index for consistent indexing with linear algebra backends.
  • Change default unsigned integer type to std::size_t
  • Add support to attaching operator null space to preconditioner (required for smoothed aggregation AMG)
  • Add basic interface to the PETSc AMG preconditioner
  • Make SCOTCH default graph partitioner (GNU-compatible free license, unlike ParMETIS)
  • Add scalable construction of mesh dual graph for mesh partitioning
  • Improve performance of mesh building in parallel
  • Add mesh output to SVG
  • Add support for Facet and cell markers to mesh converted from Diffpack
  • Add support for Facet and cell markers/attributes to mesh converted from Triangle
  • Change interface for auto-adaptive solvers: these now take the goal functional as a constructor argument
  • Add memory usage monitor: monitor_memory_usage()
  • Compare mesh hash in interpolate_vertex_values
  • Add hash() for Mesh and MeshTopology
  • Expose GenericVector::operator{+=,-=,+,-}(double) to Python
  • Add function Function::compute_vertex_values not needing a mesh argument
  • Add support for XDMF and HDF5
  • Add new interface LinearOperator for matrix-free linear systems
  • Remove MTL4 linear algebra backend
  • Rename down_cast –> as_type in C++ / as_backend_type in Python
  • Remove KrylovMatrix interface
  • Remove quadrature classes
  • JIT compiled C++ code can now include a dolfin namespace
  • Expression string parsing now understand C++ namespace such as std::cosh
  • Fix bug in Expression so one can pass min, max
  • Fix bug in SystemAssembler, where mesh.init(D-1, D) was not called before assemble
  • Fix bug where the reference count of Py_None was not increased
  • Fix bug in reading TimeSeries of size smaller than 3
  • Improve code design for Mesh FooIterators to avoid dubious down cast
  • Bug fix in destruction of PETSc user preconditioners
  • Add CellVolume(mesh) convenience wrapper to Python interface for UFL function
  • Fix bug in producing outward pointing normals of BoundaryMesh
  • Fix bug introduced by SWIG 2.0.5, where typemaps of templated typedefs are not handled correctly
  • Fix bug introduced by SWIG 2.0.5, which treated uint as Python long
  • Add check that sample points for TimeSeries are monotone
  • Fix handling of parameter “report” in Krylov solvers
  • Add new linear algebra backend “PETScCusp” for GPU-accelerated linear algebra
  • Add sparray method in the Python interface of GenericMatrix, requires scipy.sparse
  • Make methods that return a view of contiguous c-arrays, via a NumPy array, keep a reference from the object so it wont get out of scope
  • Add parameter: “use_petsc_signal_handler”, which enables/disable PETSc system signals
  • Avoid unnecessary resize of result vector for A*b
  • MPI functionality for distributing values between neighbours
  • SystemAssembler now works in parallel with topological/geometric boundary search
  • New symmetric assembler with ability for stand-alone RHS assemble
  • Major speed-up of DirichletBC computation and mesh marking
  • Major speed-up of assembly of functions and expressions
  • Major speed-up of mesh topology computation
  • Add simple 2D and 3D mesh generation (via CGAL)
  • Add creation of mesh from triangulations of points (via CGAL)
  • Split the SWIG interface into six combined modules instead of one
  • Add has_foo to easy check what solver and preconditioners are available
  • Add convenience functions for listing available linear_algebra_backends
  • Change naming convention for cpp unit tests test.cpp -> Foo.cpp
  • Added cpp unit test for GenericVector::operator{-,+,*,/}= for all la backends
  • Add functionality for rotating meshes
  • Add mesh generation based on NETGEN constructive solid geometry
  • Generalize SparsityPattern and STLMatrix to support column-wise storage
  • Add interfaces to wrap PaStiX and MUMPS direct solvers
  • Add CoordinateMatrix class
  • Make STLMatrix work in parallel
  • Remove all tr1::tuple and use boost::tuple
  • Fix wrong link in Python quick reference.

1.0.0 [2011-12-07]

  • Change return value of IntervalCell::facet_area() 0.0 –> 1.0.
  • Recompile all forms with FFC 1.0.0
  • Fix for CGAL 3.9 on OS X
  • Improve docstrings for Box and Rectangle
  • Check number of dofs on local patch in extrapolation

1.0-rc2 [2011-11-28]

  • Fix bug in 1D mesh refinement
  • Fix bug in handling of subdirectories for TimeSeries
  • Fix logic behind vector assignment, especially in parallel

1.0-rc1 [2011-11-21]

  • 33 bugs fixed
  • Implement traversal of bounding box trees for all codimensions
  • Edit and improve all error messages
  • Added [un]equality operator to FunctionSpace
  • Remove batch compilation of Expression (Expressions) from Python interface
  • Added get_value to MeshValueCollection
  • Added assignment operator to MeshValueCollection

1.0-beta2 [2011-10-26]

  • Change search path of parameter file to ~/.fenics/dolfin_parameters.xml
  • Add functions Parameters::has_parameter, Parameters::has_parameter_set
  • Added option to store all connectivities in a mesh for TimeSeries (false by default)
  • Added option for gzip compressed binary files for TimeSeries
  • Propagate global parameters to Krylov and LU solvers
  • Fix OpenMp assemble of scalars
  • Make OpenMP assemble over sub domains work
  • DirichletBC.get_boundary_values, FunctionSpace.collapse now return a dict in Python
  • Changed name of has_la_backend to has_linear_algebra_backend
  • Added has_foo functions which can be used instead of the HAS_FOO defines
  • Less trict check on kwargs for compiled Expression
  • Add option to not right-justify tables
  • Rename summary –> list_timings
  • Add function list_linear_solver_methods
  • Add function list_lu_solver_methods
  • Add function list_krylov_solver_methods
  • Add function list_krylov_solver_preconditioners
  • Support subdomains in SystemAssembler (not for interior facet integrals)
  • Add option functionality apply(“flush”) to PETScMatrix
  • Add option finalize_tensor=true to assemble functions
  • Solver parameters can now be passed to solve
  • Remove deprecated function Variable::disp()
  • Remove deprecated function logging()
  • Add new class MeshValueCollection
  • Add new class MeshDomains replacing old storage of boundary markers as part of MeshData. The following names are no longer supported: - boundary_facet_cells - boundary_facet_numbers - boundary_indicators - material_indicators - cell_domains - interior_facet_domains - exterior_facet_domains
  • Rename XML tag <meshfunction> –> <mesh_function>
  • Rename SubMesh data “global_vertex_indices” –> “parent_vertex_indices”
  • Get XML input/output of boundary markers working again
  • Get FacetArea working again

1.0-beta [2011-08-11]

  • Print percentage of non-zero entries when computing sparsity patterns
  • Use ufl.Real for Constant in Python interface
  • Add Dirichlet boundary condition argument to Python project function
  • Add remove functionality for parameter sets
  • Added out typemap for vector of shared_ptr objects
  • Fix typemap bug for list of shared_ptr objects
  • Support parallel XML vector io
  • Add support for gzipped XML output
  • Use pugixml for XML output
  • Move XML SAX parser to libxml2 SAX2 interface
  • Simplify XML io
  • Change interface for variational problems, class VariationalProblem removed
  • Add solve interface: solve(a == L), solve(F == 0)
  • Add new classes Linear/NonlinearVariationalProblem
  • Add new classes Linear/NonlinearVariationalSolver
  • Ad form class aliases ResidualForm and Jacobian form in wrapper code
  • Default argument to variables in Expression are passed as kwargs in the Python interface
  • Add has_openmp as utility function in Python interface
  • Add improved error reporting using dolfin_error
  • Use Boost to compute Legendre polynolials
  • Remove ode code
  • Handle parsing of unrecognized command-line parameters
  • All const std::vector<foo>& now return a read-only NumPy array
  • Make a robust macro for generating a NumPy array from data
  • Exposing low level fem functionality to Python, by adding a Cell -> ufc::cell typemap
  • Added ufl_cell as a method to Mesh in Python interface
  • Fix memory leak in Zoltan interface
  • Remove some ‘new’ for arrays in favour of std::vector
  • Added cell as an optional argument to Constant
  • Prevent the use of non contiguous NumPy arrays for most typemaps
  • Point can now be used to evaluate a Function or Expression in Python
  • Fixed dimension check for Function and Expression eval in Python
  • Fix compressed VTK output for tensors in 2D

0.9.11 [2011-05-16]

  • Change license from LGPL v2.1 to LGPL v3 or later
  • Moved meshconverter to dolfin_utils
  • Add support for conversion of material markers for Gmsh meshes
  • Add support for point sources (class PointSource)
  • Rename logging –> set_log_active
  • Add parameter “clear_on_write” to TimeSeries
  • Add support for input/output of nested parameter sets
  • Check for dimensions in linear solvers
  • Add support for automated error control for variational problems
  • Add support for refinement of MeshFunctions after mesh refinement
  • Change order of test and trial spaces in Form constructors
  • Make SWIG version >= 2.0 a requirement
  • Recognize subdomain data in Assembler from both Form and Mesh
  • Add storage for subdomains (cell_domains etc) in Form class
  • Rename MeshData “boundary facet cells” –> “boundary_facet_cells”
  • Rename MeshData “boundary facet numbers” –> “boundary_facet_numbers”
  • Rename MeshData “boundary indicators” –> “boundary_indicators”
  • Rename MeshData “exterior facet domains” –> “exterior_facet_domains”
  • Updates for UFC 2.0.1
  • Add FiniteElement::evaluate_basis_derivatives_all
  • Add support for VTK output of facet-based MeshFunctions
  • Change default log level from PROGRESS to INFO
  • Add copy functions to FiniteElement and DofMap
  • Simplify DofMap
  • Interpolate vector values when reading from time series

0.9.10 [2011-02-23]

  • Updates for UFC 2.0.0
  • Handle TimeSeries stored backward in time (automatic reversal)
  • Automatic storage of hierarchy during refinement
  • Remove directory/library ‘main’, merged into ‘common’
  • dolfin_init –> init, dolfin_set_precision –> set_precision
  • Remove need for mesh argument to functional assembly when possible
  • Add function set_output_stream
  • Add operator () for evaluation at points for Function/Expression in C++
  • Add abs() to GenericVector interface
  • Fix bug for local refinement of manifolds
  • Interface change: VariationalProblem now takes: a, L or F, (dF)
  • Map linear algebra objects to processes consistently with mesh partition
  • Lots of improvemenst to parallel assembly, dof maps and linear algebra
  • Add lists supported_elements and supported_elements_for_plotting in Python
  • Add script dolfin-plot for plotting meshes and elements from the command-line
  • Add support for plotting elements from Python
  • Add experimental OpenMP assembler
  • Thread-safe fixed in Function class
  • Make GenericFunction::eval thread-safe (Data class removed)
  • Optimize and speedup topology computation (mesh.init())
  • Add function Mesh::clean() for cleaning out auxilliary topology data
  • Improve speed and accuracy of timers
  • Fix bug in 3D uniform mesh refinement
  • Add built-in meshes UnitTriangle and UnitTetrahedron
  • Only create output directories when they don’t exist
  • Make it impossible to set the linear algebra backend to something illegal
  • Overload value_shape instead of dim for userdefined Python Expressions
  • Permit unset parameters
  • Search only for BLAS library (not cblas.h)

0.9.9 [2010-09-01]

  • Change build system to CMake
  • Add named MeshFunctions: VertexFunction, EdgeFunction, FaceFunction, FacetFunction, CellFunction
  • Allow setting constant boundary conditions directly without using Constant
  • Allow setting boundary conditions based on string (“x[0] == 0.0”)
  • Create missing directories if specified as part of file names
  • Allow re-use of preconditioners for most backends
  • Fixes for UMFPACK solver on some 32 bit machines
  • Provide access to more Hypre preconditioners via PETSc
  • Updates for SLEPc 3.1
  • Improve and implement re-use of LU factorizations for all backends
  • Fix bug in refinement of MeshFunctions

0.9.8 [2010-07-01]

  • Optimize and improve StabilityAnalysis.
  • Use own implementation of binary search in ODESolution (takes advantage of previous values as initial guess)
  • Improve reading ODESolution spanning multiple files
  • Dramatic speedup of progress bar (and algorithms using it)
  • Fix bug in writing meshes embedded higher dimensions to M-files
  • Zero vector in uBLASVector::resize() to fix spurious bug in Krylov solver
  • Handle named fields (u.rename()) in VTK output
  • Bug fix in computation of FacetArea for tetrahedrons
  • Add support for direct plotting of Dirichlet boundary conditions: plot(bc)
  • Updates for PETSc 3.1
  • Add relaxation parameter to NewtonSolver
  • Implement collapse of renumbered dof maps (serial and parallel)
  • Simplification of DofMapBuilder for parallel dof maps
  • Improve and simplify DofMap
  • Add Armadillo dependency for dense linear algebra
  • Remove LAPACKFoo wrappers
  • Add abstract base class GenericDofMap
  • Zero small values in VTK output to avoid VTK crashes
  • Handle MeshFunction/markers in homogenize bc
  • Make preconditioner selectable in VariationalProblem (new parameter)
  • Read/write meshes in binary format
  • Add parameter “use_ident” in DirichletBC
  • Issue error by default when solvers don’t converge (parameter “error_on_convergence”)
  • Add option to print matrix/vector for a VariationalProblem
  • Trilinos backend now works in parallel
  • Remove Mesh refine members functions. Use free refine(...) functions instead
  • Remove AdapativeObjects
  • Add Stokes demo using the MINI element
  • Interface change: operator+ now used to denote enriched function spaces
  • Interface change: operator+ –> operator* for mixed elements
  • Add option ‘allow_extrapolation’ useful when interpolating to refined meshes
  • Add SpatialCoordinates demo
  • Add functionality for accessing time series sample times: vector_times(), mesh_times()
  • Add functionality for snapping mesh to curved boundaries during refinement
  • Add functionality for smoothing the boundary of a mesh
  • Speedup assembly over exterior facets by not using BoundaryMesh
  • Mesh refinement improvements, remove unecessary copying in Python interface
  • Clean PETSc and Epetra Krylov solvers
  • Add separate preconditioner classes for PETSc and Epetra solvers
  • Add function ident_zeros for inserting one on diagonal for zero rows
  • Add LU support for Trilinos interface

0.9.7 [2010-02-17]

  • Add support for specifying facet orientation in assembly over interior facets
  • Allow user to choose which LU package PETScLUSolver uses
  • Add computation of intersection between arbitrary mesh entities
  • Random access to MeshEntitiyIterators
  • Modify SWIG flags to prevent leak when using SWIG director feature
  • Fix memory leak in std::vector<Foo*> typemaps
  • Add interface for SCOTCH for parallel mesh partitioning
  • Bug fix in SubDomain::mark, fixes bug in DirichletBC based on SubDomain::inside
  • Improvements in time series class, recognizing old stored values
  • Add FacetCell class useful in algorithms iterating over boundary facets
  • Rename reconstruct –> extrapolate
  • Remove GTS dependency

0.9.6 [2010-02-03]

  • Simplify access to form compiler parameters, now integrated with global parameters
  • Add DofMap member function to return set of dofs
  • Fix memory leak in the LA interface
  • Do not import cos, sin, exp from NumPy to avoid clash with UFL functions
  • Fix bug in MTL4Vector assignment
  • Remove sandbox (moved to separate repository)
  • Remove matrix factory (dolfin/mf)
  • Update .ufl files for changes in UFL
  • Added swig/import/foo.i for easy type importing from dolfin modules
  • Allow optional argument cell when creating Expression
  • Change name of Expression argument cpparg –> cppcode
  • Add simple constructor (dim0, dim1) for C++ matrix Expressions
  • Add example demonstrating the use of cpparg (C++ code in Python)
  • Add least squares solver for dense systems (wrapper for DGELS)
  • New linear algebra wrappers for LAPACK matrices and vectors
  • Experimental support for reconstruction of higher order functions
  • Modified interface for eval() and inside() in C++ using Array
  • Introduce new Array class for simplified wrapping of arrays in SWIG
  • Improved functionality for intersection detection
  • Re-implementation of intersection detection using CGAL

0.9.5 [2009-12-03]

  • Set appropriate parameters for symmetric eigenvalue problems with SLEPc
  • Fix for performance regression in recent uBLAS releases
  • Simplify Expression interface: f = Expression(“sin(x[0])”)
  • Simplify Constant interface: c = Constant(1.0)
  • Fix bug in periodic boundary conditions
  • Add simple script dolfin-tetgen for generating DOLFIN XML meshes from STL
  • Make XML parser append/overwrite parameter set when reading parameters from file
  • Refinement of function spaces and automatic interpolation of member functions
  • Allow setting global parameters for Krylov solver
  • Fix handling of Constants in Python interface to avoid repeated JIT compilation
  • Allow simple specification of subdomains in Python without needing to subclass SubDomain
  • Add function homogenize() for simple creation of homogeneous BCs from given BCs
  • Add copy constructor and possibility to change value for DirichletBC
  • Add simple wrapper for ufl.cell.n. FacetNormal(mesh) now works again in Python.
  • Support apply(A), apply(b) and apply(b, x) in PeriodicBC
  • Enable setting spectral transformation for SLEPc eigenvalue solver

0.9.4 [2009-10-12]

  • Remove set, get and operator() methods from MeshFunction
  • Added const and none const T &operator[uint/MeshEntity] to MeshFunction
  • More clean up in SWIG interface files, remove global renames and ignores
  • Update Python interface to Expression, with extended tests for value ranks
  • Removed DiscreteFunction class
  • Require value_shape and geometric_dimension in Expression
  • Introduce new class Expression replacing user-defined Functions
  • interpolate_vertex_values –> compute_vertex_values
  • std::map<std::string, Coefficient> replaces generated CoefficientSet code
  • Cleanup logic in Function class as a result of new Expression class
  • Introduce new Coefficient base class for form coefficients
  • Replace CellSize::min,max by Mesh::hmin,hmax
  • Use MUMPS instead of UMFPACK as default direct solver in both serial and parallel
  • Fix bug in SystemAssembler
  • Remove support for PETSc 2.3 and support PETSc 3.0.0 only
  • Remove FacetNormal Function. Use UFL facet normal instead.
  • Add update() function to FunctionSpace and DofMap for use in adaptive mesh refinement
  • Require mesh in constructor of functionals (C++) or argument to assemble (Python)

0.9.3 [2009-09-25]

  • Add global parameter “ffc_representation” for form representation in FFC JIT compiler
  • Make norm() function handle both vectors and functions in Python
  • Speedup periodic boundary conditions and make work for mixed (vector-valued) elements
  • Add possibilities to use any number numpy array when assigning matrices and vectors
  • Add possibilities to use any integer numpy array for indices in matrices and vectors
  • Fix for int typemaps in PyDOLFIN
  • Split mult into mult and transpmult
  • Filter out PETSc argument when parsing command-line parameters
  • Extend comments to SWIG interface files
  • Add copyright statements to SWIG interface files (not finished yet)
  • Add typemaps for misc std::vector<types> in PyDOLFIN
  • Remove dependencies on std_vector.i reducing SWIG wrapper code size
  • Use relative %includes in dolfin.i
  • Changed names on SWIG interface files dolfin_foo.i -> foo.i
  • Add function interpolate() in Python interface
  • Fix typmaps for uint in python 2.6
  • Use TypeError instead of ValueError in typechecks in typmaps.i
  • Add in/out shared_ptr<Epetra_FEFoo> typemaps for PyDOLFIN
  • Fix JIT compiling in parallel
  • Add a compile_extension_module function in PyDOLFIN
  • Fix bug in Python vector assignment
  • Add support for compressed base64 encoded VTK files (using zlib)
  • Add support for base64 encoded VTK files
  • Experimental support for parallel assembly and solve
  • Bug fix in project() function, update to UFL syntax
  • Remove disp() functions and replace by info(foo, true)
  • Add fem unit test (Python)
  • Clean up SystemAssembler
  • Enable assemble_system through PyDOLFIN
  • Add ‘norm’ to GenericMatrix
  • Efficiency improvements in NewtonSolver
  • Rename NewtonSolver::get_iteration() to NewtonSolver::iteration()
  • Improvements to EpetraKrylovSolver::solve
  • Add constructor Vector::Vector(const GenericVector& x)
  • Remove SCons deprecation warnings
  • Memory leak fix in PETScKrylovSolver
  • Rename dolfin_assert -> assert and use C++ version
  • Fix debug/optimise flags
  • Remove AvgMeshSize, InvMeshSize, InvFacetArea from SpecialFunctions
  • Rename MeshSize -> CellSize
  • Rewrite parameter system with improved support for command-line parsing, localization of parameters (per class) and usability from Python
  • Remove OutflowFacet from SpecialFunctions
  • Rename interpolate(double*) –> interpolate_vertex_values(double*)
  • Add Python version of Cahn-Hilliard demo
  • Fix bug in assemble.py
  • Permit interpolation of functions between non-matching meshes
  • Remove Function::Function(std::string filename)
  • Transition to new XML io
  • Remove GenericSparsityPattern::sort
  • Require sorted/unsorted parameter in SparsityPattern constructor
  • Improve performance of SparsityPattern::insert
  • Replace enums with strings for linear algebra and built-in meshes
  • Allow direct access to Constant value
  • Initialize entities in MeshEntity constructor automatically and check range
  • Add unit tests to the memorycheck
  • Add call to clean up libxml2 parser at exit
  • Remove unecessary arguments in DofMap member functions
  • Remove reference constructors from DofMap, FiniteElement and FunctionSpace
  • Use a shared_ptr to store the mesh in DofMap objects
  • Interface change for wrapper code: PoissonBilinearForm –> Poisson::BilinearForm
  • Add function info_underline() for writing underlined messages
  • Rename message() –> info() for “compatibility” with Python logging module
  • Add elementwise multiplication in GeneriVector interface
  • GenericVector interface in PyDOLFIN now support the sequence protocol
  • Rename of camelCaps functions names: fooBar –> foo_bar Note: mesh.numVertices() –> mesh.num_vertices(), mesh.numCells() –> mesh.num_cells()
  • Add slicing capabilities for GenericMatrix interface in PyDOLFIN (only getitem)
  • Add slicing capabilities for GenericVector interface in PyDOLFIN
  • Add sum to GenericVector interface

0.9.2 [2009-04-07]

  • Enable setting parameters for Newton solver in VariationalProblem
  • Simplified and improved implementation of C++ plotting, calling Viper on command-line
  • Remove precompiled elements and projections
  • Automatically interpolate user-defined functions on assignment
  • Add new built-in function MeshCoordinates, useful in ALE simulations
  • Add new constructor to Function class, Function(V, “vector.xml”)
  • Remove class Array (using std::vector instead)
  • Add vector_mapping data to MeshData
  • Use std::vector instead of Array in MeshData
  • Add assignment operator and copy constructor for MeshFunction
  • Add function mesh.move(other_mesh) for moving mesh according to matching mesh (for FSI)
  • Add function mesh.move(u) for moving mesh according to displacement function (for FSI)
  • Add macro dolfin_not_implemented()
  • Add new interpolate() function for interpolation of user-defined function to discrete
  • Make _function_space protected in Function
  • Added access to crs data from python for uBLAS and MTL4 backend

0.9.1 [2009-02-17]

  • Check Rectangle and Box for non-zero dimensions
  • ODE solvers now solve the dual problem
  • New class SubMesh for simple extraction of matching meshes for sub domains
  • Improvements of multiprecision ODE solver
  • Fix Function class copy constructor
  • Bug fixes for errornorm(), updates for new interface
  • Interface update for MeshData: createMeshFunction –> create_mesh_function etc
  • Interface update for Rectangle and Box
  • Add elastodynamics demo
  • Fix memory leak in IntersectionDetector/GTSInterface
  • Add check for swig version, in jit and compile functions
  • Bug fix in dolfin-order script for gzipped files
  • Make shared_ptr work across C++/Python interface
  • Replace std::tr1::shared_ptr with boost::shared_ptr
  • Bug fix in transfinite mean-value interpolation
  • Less annoying progress bar (silent when progress is fast)
  • Fix assignment operator for MeshData
  • Improved adaptive mesh refinement (recursive Rivara) producing better quality meshes

0.9.0 [2009-01-05]

  • Cross-platform fixes
  • PETScMatrix::copy fix
  • Some Trilinos fixes
  • Improvements in MeshData class
  • Do not use initial guess in Newton solver
  • Change OutflowFacet to IsOutflowFacet and change syntax
  • Used shared_ptr for underling linear algebra objects
  • Cache subspaces in FunctionSpace
  • Improved plotting, now support plot(grad(u)), plot(div(u)) etc
  • Simple handling of JIT-compiled functions
  • Sign change (bug fix) in increment for Newton solver
  • New class VariationalProblem replacing LinearPDE and NonlinearPDE
  • Parallel parsing and partitioning of meshes (experimental)
  • Add script dolfin-order for ordering mesh files
  • Add new class SubSpace (replacing SubSystem)
  • Add new class FunctionSpace
  • Complete redesign of Function class hierarchy, now a single Function class
  • Increased use of shared_ptr in Function, FunctionSpace, etc
  • New interface for boundary conditions, form not necessary
  • Allow simple setting of coefficient functions based on names (not their index)
  • Don’t order mesh automatically, meshes must now be ordered explicitly
  • Simpler definition of user-defined functions (constructors not necessary)
  • Make mesh iterators const to allow for const-correct Mesh code

0.8.1 [2008-10-20]

  • Add option to use ML multigrid preconditioner through PETSc
  • Interface change for ODE solvers: uBLASVector –> double*
  • Remove homotopy solver
  • Remove typedef real, now using plain double instead
  • Add various operators -=, += to GenericMatrix
  • Don’t use -Werror when compiling SWIG generated code
  • Remove init(n) and init(m, n) from GenericVector/Matrix. Use resize and zero instead
  • Add new function is_combatible() for checking compatibility of boundary conditions
  • Use x as initial guess in Krylov solvers (PETSc, uBLAS, ITL)
  • Add new function errornorm()
  • Add harmonic ALE mesh smoothing
  • Refinements of Graph class
  • Add CholmodCholeskySlover (direct solver for symmetric matrices)
  • Implement application of Dirichlet boundary conditions within assembly loop
  • Improve efficiency of SparsityPattern
  • Allow a variable number of smoothings
  • Add class Table for pretty-printing of tables
  • Add experimental MTL4 linear algebra backend
  • Add OutflowFacet to SpecialFunctions for DG transport problems
  • Remove unmaintained OpenDX file format
  • Fix problem with mesh smoothing near nonconvex corners
  • Simple projection of functions in Python
  • Add file format: XYZ for use with Xd3d
  • Add built-in meshes: UnitCircle, Box, Rectangle, UnitSphere

0.8.0 [2008-06-23]

  • Fix input of matrix data from XML
  • Add function normalize()
  • Integration with VMTK for reading DOLFIN XML meshes produced by VMTK
  • Extend mesh XML format to handle boundary indicators
  • Add support for attaching arbitrarily named data to meshes
  • Add support for dynamically choosing the linear algebra backend
  • Add Epetra/Trilinos linear solvers
  • Add setrow() to matrix interface
  • Add new solver SingularSolver for solving singular (pressure) systems
  • Add MeshSize::min(), max() for easy computation of smallest/largest mesh size
  • LinearSolver now handles all backends and linear solvers
  • Add access to normal in Function, useful for inflow boundary conditions
  • Remove GMRES and LU classes, use solve() instead
  • Improve solve() function, now handles both LU and Krylov + preconditioners
  • Add ALE mesh interpolation (moving mesh according to new boundary coordinates)

0.7.3 [2008-04-30]

  • Add support for Epetra/Trilinos
  • Bug fix for order of values in interpolate_vertex_values, now according to UFC
  • Boundary meshes are now always oriented with respect to outward facet normals
  • Improved linear algebra, both in C++ and Python
  • Make periodic boundary conditions work in Python
  • Fix saving of user-defined functions
  • Improve plotting
  • Simple computation of various norms of functions from Python
  • Evaluation of Functions at arbitrary points in a mesh
  • Fix bug in assembling over exterior facets (subdomains were ignored)
  • Make progress bar less annoying
  • New scons-based build system replaces autotools
  • Fix bug when choosing iterative solver from Python

0.7.2 [2008-02-18]

  • Improve sparsity pattern generator efficiency
  • Dimension-independent sparsity pattern generator
  • Add support for setting strong boundary values for DG elements
  • Add option setting boundary conditions based on geometrical search
  • Check UMFPACK return argument for warnings/errors
  • Simplify setting simple Dirichlet boundary conditions
  • Much improved integration with FFC in PyDOLFIN
  • Caching of forms by JIT compiler now works
  • Updates for UFC 1.1
  • Catch exceptions in PyDOLFIN
  • Work on linear algebra interfaces GenericTensor/Matrix/Vector
  • Add linear algebra factory (backend) interface
  • Add support for 1D meshes
  • Make Assembler independent of linear algebra backend
  • Add manager for handling sub systems (PETSc and MPI)
  • Add parallel broadcast of Mesh and MeshFunction
  • Add experimental support for parallel assembly
  • Use PETSc MPI matrices when running in parallel
  • Add predefined functions FacetNormal and AvgMeshSize
  • Add left/right/crisscross options for UnitSquare
  • Add more Python demos
  • Add support for Exodus II format in dolfin-convert
  • Autogenerate docstrings for PyDOLFIN
  • Various small bug fixes and improvements

0.7.1 [2007-08-31]

  • Integrate FFC form language into PyDOLFIN
  • Just-in-time (JIT) compilation of variational forms
  • Conversion from from Diffpack grid format to DOLFIN XML
  • Name change: BoundaryCondition –> DirichletBC
  • Add support for periodic boundary conditions: class PeriodicBC
  • Redesign default linear algebra interface (Matrix, Vector, KrylovSolver, etc)
  • Add function to return Vector associated with a DiscreteFunction

0.7.0-1 [2007-06-22]

  • Recompile all forms with latest FFC release
  • Remove typedefs SparseMatrix and SparseVector
  • Fix includes in LinearPDE
  • Rename DofMaps -> DofMapSet

0.7.0 [2007-06-20]

  • Move to UFC interface for code generation
  • Major rewrite, restructure, cleanup
  • Add support for Brezzi-Douglas-Marini (BDM) elements
  • Add support for Raviart-Thomas (RT) elements
  • Add support for Discontinuous Galerkin (DG) methods
  • Add support for mesh partitioning (through SCOTCH)
  • Handle both UMFPACK and UFSPARSE
  • Local mesh refinement
  • Mesh smoothing
  • Built-in plotting (through Viper)
  • Cleanup log system
  • Numerous fixes for mesh, in particular MeshFunction
  • Much improved Python bindings for mesh
  • Fix Python interface for vertex and cell maps in boundary computation

0.6.4 [2006-12-01]

  • Switch from Python Numeric to Python NumPy
  • Improved mesh Python bindings
  • Add input/output support for MeshFunction
  • Change Mesh::vertices() –> Mesh::coordinates()
  • Fix bug in output of mesh to MATLAB format
  • Add plasticty module (experimental)
  • Fix configure test for Python dev (patch from Åsmund Ødegård)
  • Add mesh benchmark
  • Fix memory leak in mesh (data not deleted correctly in MeshTopology)
  • Fix detection of curses libraries
  • Remove Tecplot output format

0.6.3 [2006-10-27]

  • Move to new mesh library
  • Remove dolfin-config and move to pkg-config
  • Remove unused classes PArray, PList, Table, Tensor
  • Visualization of 2D solutions in OpenDX is now supported (3D supported before)
  • Add support for evaluation of functionals
  • Fix bug in Vector::sum() for uBLAS vectors

0.6.2-1 [2006-09-06]

  • Fix compilation error when using –enable-petsc (dolfin::uBLASVector::PETScVector undefined)

0.6.2 [2006-09-05]

  • Finish chapter in manual on linear algebra
  • Enable PyDOLFIN by default, use –disable-pydolfin to disable
  • Disable PETSc by default, use –enable-petsc to enable
  • Modify ODE solver interface for u0() and f()
  • Add class ConvectionMatrix
  • Readd classes LoadVector, MassMatrix, StiffnessMatrix
  • Add matrix factory for simple creation of standard finite element matrices
  • Collect static solvers in LU and GMRES
  • Bug fixes for Python interface PyDOLFIN
  • Enable use of direct solver for ODE solver (experimental)
  • Remove demo bistable
  • Restructure and cleanup linear algebra
  • Use UMFPACK for LU solver with uBLAS matrix types
  • Add templated wrapper class for different uBLAS matrix types
  • Add ILU preconditioning for uBLAS matrices
  • Add Krylov solver for uBLAS sparse matrices (GMRES and BICGSTAB)
  • Add first version of new mesh library (NewMesh, experimental)
  • Add Parametrized::readParameters() to trigger reading of values on set()
  • Remove output of zeros in Octave matrix file format
  • Use uBLAS-based vector for Vector if PETSc disabled
  • Add wrappers for uBLAS compressed_matrix class
  • Compute eigenvalues using SLEPc (an extension of PETSc)
  • Clean up assembly and linear algebra
  • Add function to solve Ax = b for dense matrices and dense vectors
  • Make it possible to compile without PETSc (–disable-petsc)
  • Much improved ODE solvers
  • Complete multi-adaptive benchmarks reaction and wave
  • Assemble boundary integrals
  • FEM class cleaned up.
  • Fix multi-adaptive benchmark problem reaction
  • Small fixes for Intel C++ compiler version 9.1
  • Test for Intel C++ compiler and configure appropriately
  • Add new classes DenseMatrix and DenseVector (wrappers for ublas)
  • Fix bug in conversion from Gmsh format

0.6.1 [2006-03-28]

  • Regenerate build system in makedist script
  • Update for new FFC syntax: BasisFunction –> TestFunction, TrialFunction
  • Fixes for conversion script dolfin-convert
  • Initial cleanups and fixes for ODE solvers
  • Numerous small fixes to improve portability
  • Remove dolfin:: qualifier on output << in Parameter.h
  • Don’t use anonymous classes in demos, gives errors with some compilers
  • Remove KrylovSolver::solver()
  • Fix bug in convection-diffusion demo (boundary condition for pressure), use direct solver
  • LinearPDE and NewonSolver use umfpack LU solver by default (if available) when doing direct solve
  • Set PETSc matrix type through Matrix constructor
  • Allow linear solver and preconditioner type to be passed to NewtonSolver
  • Fix bug in Stokes demos (wrong boundary conditions)
  • Cleanup Krylov solver
  • Remove KrylovSolver::setPreconditioner() etc. and move to constructors
  • Remove KrylovSolver::setRtol() etc. and replace with parameters
  • Fix remaining name changes: noFoo() –> numFoo()
  • Add Cahn-Hilliard equation demo
  • NewtonSolver option to use residual or incremental convergence criterion
  • Add separate function to nls to test for convergence of Newton iterations
  • Fix bug in dolfin-config (wrong version number)

0.6.0 [2006-03-01]

  • Fix bug in XML output format (writing multiple objects)
  • Fix bug in XML matrix output format (handle zero rows)
  • Add new nonlinear PDE demo
  • Restructure PDE class to use envelope-letter design
  • Add precompiled finite elements for q <= 5
  • Add FiniteElementSpec and factor function for FiniteElement
  • Add input/output of Function to DOLFIN XML
  • Name change: dof –> node
  • Name change: noFoo() –> numFoo()
  • Add conversion from gmsh format in dolfin-convert script
  • Updates for PETSc 2.3.1
  • Add new type of Function (constant)
  • Simplify use of Function class
  • Add new demo Stokes + convection-diffusion
  • Add new demo Stokes (equal-order stabilized)
  • Add new demo Stokes (Taylor-Hood)
  • Add new parameter for KrylovSolvers: “monitor convergence”
  • Add conversion script dolfin-convert for various mesh formats
  • Add new demo elasticity
  • Move poisson demo to src/demo/pde/poisson
  • Move to Mercurial (hg) from CVS
  • Use libtool to build libraries (including shared)

0.5.12 [2006-01-12]

  • Make Stokes solver dimension independent (2D/3D)
  • Make Poisson solver dimension independent (2D/3D)
  • Fix sparse matrix output format for MATLAB
  • Modify demo problem for Stokes, add exact solution and compute error
  • Change interface for boundary conditions: operator() –> eval()
  • Add two benchmark problems for the Navier-Stokes solver
  • Add support for 2D/3D selection in Navier-Stokes solver
  • Move tic()/toc() to timing.h
  • Navier-Stokes solver back online
  • Make Solver a subclass of Parametrized
  • Add support for localization of parameters
  • Redesign of parameter system

0.5.11 [2005-12-15]

  • Add script monitor for monitoring memory usage
  • Remove meminfo.h (not portable)
  • Remove dependence on parameter system in log system
  • Don’t use drand48() (not portable)
  • Don’t use strcasecmp() (not portable)
  • Remove sysinfo.h and class System (not portable)
  • Don’t include <sys/utsname.h> (not portable)
  • Change ::show() –> ::disp() everywhere
  • Clean out old quadrature classes on triangles and tetrahedra
  • Clean out old sparse matrix code
  • Update chapter on Functions in manual
  • Use std::map to store parameters
  • Implement class KrylovSolver
  • Name change: Node –> Vertex
  • Add nonlinear solver demos
  • Add support for picking sub functions and components of functions
  • Update interface for FiniteElement for latest FFC version
  • Improve and restructure implementation of the Function class
  • Dynamically adjust safety factor during integration
  • Improve output Matrix::disp()
  • Check residual at end of time step, reject step if too large
  • Implement Vector::sum()
  • Implement nonlinear solver
  • New option for ODE solver: “save final solution” –> solution.data
  • New ODE test problem: reaction
  • Fixes for automake 1.9 (nobase_include_HEADERS)
  • Reorganize build system, remove fake install and require make install
  • Add checks for non-standard PETSc component HYPRE in NSE solver
  • Make GMRES solver return the number of iterations
  • Add installation script for Python interface
  • Add Matrix Market format (Haiko Etzel)
  • Automatically reinitialize GMRES solver when system size changes
  • Implement cout << for class Vector

0.5.10 [2005-10-11]

  • Modify ODE solver interface: add T to constructor
  • Fix compilation on AMD 64 bit systems (add -fPIC)
  • Add new BLAS mode for form evaluation
  • Change enum types in File to lowercase
  • Change default file type for .m to Octave
  • Add experimental Python interface PyDOLFIN
  • Fix compilation for gcc 4.0

0.5.9 [2005-09-23]

  • Add Stokes module
  • Support for arbitrary mixed elements through FFC
  • VTK output interface now handles time-dependent functions automatically
  • Fix cout for empty matrix
  • Change dolfin_start() –> dolfin_end()
  • Add chapters to manual: about, log system, parameters, reference elements, installation, contributing, license
  • Use new template fenicsmanual.cls for manual
  • Add compiler flag -U__STRICT_ANSI__ when compiling under Cygwin
  • Add class EigenvalueSolver

0.5.8 [2005-07-05]

  • Add new output format Paraview/VTK (Garth N. Wells)
  • Update Tecplot interface
  • Move to PETSc 2.3.0
  • Complete support for general order Lagrange elements in triangles and tetrahedra
  • Add test problem in src/demo/fem/convergence/ for general Lagrange elements
  • Make FEM::assemble() estimate the number of nonzeros in each row
  • Implement Matrix::init(M, N, nzmax)
  • Add Matrix::nz(), Matrix::nzsum() and Matrix::nzmax()
  • Improve Mesh::disp()
  • Add FiniteElement::disp() and FEM::disp() (useful for debugging)
  • Remove old class SparseMatrix
  • Change FEM::setBC() –> FEM::applyBC()
  • Change Mesh::tetrahedrons –> Mesh::tetrahedra
  • Implement Dirichlet boundary conditions for tetrahedra
  • Implement Face::contains(const Point& p)
  • Add test for shape dimension of mesh and form in FEM::assemble()
  • Move src/demo/fem/ demo to src/demo/fem/simple/
  • Add README file in src/demo/poisson/ (simple manual)
  • Add simple demo program src/demo/poisson/
  • Update computation of alignment of faces to match FFC/FIAT

0.5.7 [2005-06-23]

  • Clean up ODE test problems
  • Implement automatic detection of sparsity pattern from given matrix
  • Clean up homotopy solver
  • Implement automatic computation of Jacobian
  • Add support for assembly of non-square systems (Andy Terrel)
  • Make ODE solver report average number of iterations
  • Make progress bar write first update at 0%
  • Initialize all values of u before solution in multi-adaptive solver, not only components given by dependencies
  • Allow user to modify and verify a converging homotopy path
  • Make homotopy solver save a list of the solutions
  • Add Matrix::norm()
  • Add new test problem for CES economy
  • Remove cast from Parameter to const char* (use std::string)
  • Make solution data filename optional for homotopy solver
  • Append homotopy solution data to file during solution
  • Add dolfin::seed(int) for optionally seeding random number generator
  • Remove dolfin::max,min (use std::max,min)
  • Add polynomial-integer (true polynomial) form of general CES system
  • Compute multi-adaptive efficiency index
  • Updates for gcc 4.0 (patches by Garth N. Wells)
  • Add Matrix::mult(const real x[], uint row) (temporary fix, assumes uniprocessor case)
  • Add Matrix::mult(const Vector& x, uint row) (temporary fix, assumes uniprocessor case)
  • Update shortcuts MassMatrix and StiffnessMatrix to new system
  • Add missing friend to Face.h (reported by Garth N. Wells)

0.5.6 [2005-05-17]

  • Implementation of boundary conditions for general order Lagrange (experimental)
  • Use interpolation function automatically generated by FFC
  • Put computation of map into class AffineMap
  • Clean up assembly
  • Use dof maps automatically generated by FFC (experimental)
  • Modify interface FiniteElement for new version of FFC
  • Update ODE homotopy test problems
  • Add cross product to class Point
  • Sort mesh entities locally according to ordering used by FIAT and FFC
  • Add new format for dof maps (preparation for higher-order elements)
  • Code cleanups: NewFoo –> Foo complete
  • Updates for new version of FFC (0.1.7)
  • Bypass log system when finalizing PETSc (may be out of scope)

0.5.5 [2005-04-26]

  • Fix broken log system, curses works again
  • Much improved multi-adaptive time-stepping
  • Move elasticity module to new system based on FFC
  • Add boundary conditions for systems
  • Improve regulation of time steps
  • Clean out old assembly classes
  • Clean out old form classes
  • Remove kernel module map
  • Remove kernel module element
  • Move convection-diffusion module to new system based on FFC
  • Add iterators for cell neighbors of edges and faces
  • Implement polynomial for of CES economy
  • Rename all new linear algebra classes: NewFoo –> Foo
  • Clean out old linear algebra
  • Speedup setting of boundary conditions (add MAT_KEEP_ZEROED_ROWS)
  • Fix bug for option –disable-curses

0.5.4 [2005-03-29]

  • Remove option to compile with PETSc 2.2.0 (2.2.1 required)
  • Make make install work again (fix missing includes)
  • Add support for mixing multiple finite elements (through FFC)
  • Improve functionality of homotopy solver
  • Simple creation of piecewise linear functions (without having an element)
  • Simple creation of piecewise linear elements
  • Add support of automatic creation of simple meshes (unit cube, unit square)

0.5.3 [2005-02-26]

  • Change to PETSc version 2.2.1
  • Add flag –with-petsc=<path> to configure script
  • Move Poisson’s equation to system based on FFC
  • Add support for automatic creation of homotopies
  • Make all ODE solvers automatically handle complex ODEs: (M) z’ = f(z,t)
  • Implement version of mono-adaptive solver for implicit ODEs: M u’ = f(u,t)
  • Implement Newton’s method for multi- and mono-adaptive ODE solvers
  • Update PETSc wrappers NewVector, NewMatrix, and NewGMRES
  • Fix initialization of PETSc
  • Add mono-adaptive cG(q) and dG(q) solvers (experimental)
  • Implementation of new assebly: NewFEM, using output from FFC
  • Add access to mesh for nodes, cells, faces and edges
  • Add Tecplot I/O interface; contributed by Garth N. Wells

0.5.2 [2005-01-26]

  • Benchmarks for DOLFIN vs PETSc (src/demo/form and src/demo/test)
  • Complete rewrite of the multi-adaptive ODE solver (experimental)
  • Add wrapper for PETSc GMRES solver
  • Update class Point with new operators
  • Complete rewrite of the multi-adaptive solver to improve performance
  • Add PETSc wrappers NewMatrix and NewVector
  • Add DOLFIN/PETSc benchmarks

0.5.1 [2004-11-10]

  • Experimental support for automatic generation of forms using FFC
  • Allow user to supply Jacobian to ODE solver
  • Add optional test to check if a dependency already exists (Sparsity)
  • Modify sparse matrix output (Matrix::show())
  • Add FGMRES solver in new format (patch from eriksv)
  • Add non-const version of quick-access of sparse matrices
  • Add linear mappings for simple computation of derivatives
  • Add check of matrix dimensions for ODE sparsity pattern
  • Include missing cmath in Function.cpp

0.5.0 [2004-08-18]

  • First prototype of new form evaluation system
  • New classes Jacobi, SOR, Richardson (preconditioners and linear solvers)
  • Add integrals on the boundary (ds), partly working
  • Add maps from boundary of reference cell
  • Add evaluation of map from reference cell
  • New Matrix functions: max, min, norm, and sum of rows and columns (erik)
  • Derivatives/gradients of ElementFunction (coefficients f.ex.) implemented
  • Enable assignment to all elements of a NewArray
  • Add functions Boundary::noNodes(), noFaces(), noEdges()
  • New class GaussSeidel (preconditioner and linear solver)
  • New classes Preconditioner and LinearSolver
  • Bug fix for tetrahedral mesh refinement (ingelstrom)
  • Add iterators for Edge and Face on Boundary
  • Add functionality to Map: bdet() and cell()
  • Add connectivity face-cell and edge-cell
  • New interface for assembly: Galerkin –> FEM
  • Bug fix for PDE systems of size > 3

0.4.11 [2004-04-23]

  • Add multigrid solver (experimental)
  • Update manual

0.4.10

  • Automatic model reduction (experimental)
  • Fix bug in ParticleSystem (divide by mass)
  • Improve control of integration (add function ODE::update())
  • Load/save parameters in XML-format
  • Add assembly test
  • Add simple StiffnessMatrix, MassMatrix, and LoadVector
  • Change dK –> dx
  • Change dx() –> ddx()
  • Add support for GiD file format
  • Add performance tests for multi-adaptivity (both stiff and non-stiff)
  • First version of Newton for the multi-adaptive solver
  • Test for Newton for the multi-adaptive solver

0.4.9

  • Add multi-adaptive solver for the bistable equation
  • Add BiCGSTAB solver (thsv)
  • Fix bug in SOR (thsv)
  • Improved visual program for OpenDX
  • Fix OpenDX file format for scalar functions
  • Allow access to samples of multi-adaptive solution
  • New patch from thsv for gcc 3.4.0 and 3.5.0
  • Make progress step a parameter
  • New function ODE::sparse(const Matrix& A)
  • Access nodes, cells, edges, faces by id
  • New function Matrix::lump()

0.4.8

  • Add support for systems (jansson and bengzon)
  • Add new module wave
  • Add new module wave-vector
  • Add new module elasticity
  • Add new module elasticity-stationary
  • Multi-adaptive updates
  • Fix compilation error in LogStream
  • Fix local Newton iteration for higher order elements
  • Init matrix to given type
  • Add output of cG(q) and dG(q) weights in matrix format
  • Fix numbering of frames from plotslab script
  • Add png output for plotslab script
  • Add script for running stiff test problems, plot solutions
  • Fix bug in MeshInit (node neighbors of node)
  • Modify output of sysinfo()
  • Compile with -Wall -Werror -pedantic -ansi -std=c++98 (thsv)

0.4.7

  • Make all stiff test problems work
  • Display status report also when using step()
  • Improve adaptive damping for stiff problems (remove spikes)
  • Modify Octave/Matlab format for solution data (speed improvement)
  • Adaptive sampling of solution (optional)
  • Restructure stiff test problems
  • Check if value of right-hand side is valid
  • Modify divergence test in AdaptiveIterationLevel1

0.4.6

  • Save vectors and matrices from Matlab/Octave (foufas)
  • Rename writexml.m to xmlmesh.m
  • Inlining of important functions
  • Optimize evaluation of elements
  • Optimize Lagrange polynomials
  • Optimize sparsity: use stl containers
  • Optimize choice of discrete residual for multi-adaptive solver
  • Don’t save solution in benchmark proble
  • Improve computation of divergence factor for underdamped systems
  • Don’t check residual on first slab for fixed time step
  • Decrease largest (default) time step to 0.1
  • Add missing <cmath> in TimeStepper
  • Move real into dolfin namespace

0.4.5

  • Rename function.h to enable compilation under Cygwin
  • Add new benchmark problem for multi-adaptive solver
  • Bug fix for ParticleSystem
  • Initialization of first time step
  • Improve time step regulation (threshold)
  • Improve stabilization
  • Improve TimeStepper interface (Ko Project)
  • Use iterators instead of recursively calling TimeSlab::update()
  • Clean up ODESolver
  • Add iterators for elements in time slabs and element groups
  • Add -f to creation of symbolic links

0.4.4

  • Add support for 3D graphics in Octave using Open Inventor (jj)

0.4.3

  • Stabilization of multi-adaptive solver (experimental)
  • Improved non-support for curses (–disable-curses)
  • New class MechanicalSystem for simulating mechanical systems
  • Save debug info from primal and dual (plotslab.m)
  • Fix bug in progress bar
  • Add missing include file in Components.h (kakr)
  • New function dolfin_end(const char* msg, ...)
  • Move numerical differentiation to RHS
  • New class Event for limited display of messages
  • Fix bug in LogStream (large numbers in floating point format)
  • Specify individual time steps for different components
  • Compile without warnings
  • Add -Werror to option enable-debug
  • Specify individual methods for different components
  • Fix bug in dGqMethods
  • Fix bug (delete old block) in ElementData
  • Add parameters for method and order
  • New test problem reaction
  • New class FixedPointIteration
  • Fix bug in grid refinement

0.4.2

  • Fix bug in computation of residual (divide by k)
  • Add automatic generation and solution of the dual problem
  • Automatic selection of file names for primal and dual
  • Fix bug in progress bar (TerminalLogger)
  • Many updates of multi-adaptive solver
  • Add class ODEFunction
  • Update function class hierarchies
  • Move functions to a separate directory
  • Store multi-adaptive solution binary on disk with cache

0.4.1

  • First version of multi-adaptive solver working
  • Clean up file formats
  • Start changing from int to unsigned int where necessary
  • Fix bool->int when using stdard in Parameter
  • Add NewArray and NewList (will replace Array and List)

0.4.0

  • Initiation of the FEniCS project
  • Change syntax of mesh files: grid -> mesh
  • Create symbolic links instead of copying files
  • Tanganyika -> ODE
  • Add Heat module
  • Grid -> Mesh
  • Move forms and mappings to separate libraries
  • Fix missing include of DirectSolver.h

0.3.12

  • Adaptive grid refinement (!)
  • Add User Manual
  • Add function dolfin_log() to turn logging on/off
  • Change from pointers to references for Node, Cell, Edge, Face
  • Update writexml.m
  • Add new grid files and rename old grid files

0.3.11

  • Add configure option –disable-curses
  • Grid refinement updates
  • Make OpenDX file format work for grids (output)
  • Add volume() and diameter() in cell
  • New classes TriGridRefinement and TetGridRefinement
  • Add iterators for faces and edges on a boundary
  • New class GridHierarchy

0.3.10

  • Use new boundary structure in Galerkin
  • Make dolfin_start() and dolfin_end() work
  • Make dolfin_assert() raise segmentation fault for plain text mode
  • Add configure option –enable-debug
  • Use autoreconf instead of scripts/preconfigure
  • Rename configure.in -> configure.ac
  • New class FaceIterator
  • New class Face
  • Move computation of boundary from GridInit to BoundaryInit
  • New class BoundaryData
  • New class BoundaryInit
  • New class Boundary
  • Make InitGrid compute edges
  • Add test program for generic matrix in src/demo/la
  • Clean up Grid classes
  • Add new class GridRefinementData
  • Move data from Cell to GenericCell
  • Make GMRES work with user defined matrix, only mult() needed
  • GMRES now uses only one function to compute residual()
  • Change Matrix structure (a modified envelope/letter)
  • Update script checkerror.m for Poisson
  • Add function dolfin_info_aptr()
  • Add cast to element pointer for iterators
  • Clean up and improve the Tensor class
  • New class: List
  • Name change: List -> Table
  • Name change: ShortList -> Array
  • Make functions in GridRefinement static
  • Make functions in GridInit static
  • Fix bug in GridInit (eriksv)
  • Add output to OpenDX format for 3D grids
  • Clean up ShortList class
  • Clean up List class
  • New class ODE, Equation replaced by PDE
  • Add Lorenz test problem
  • Add new problem type for ODEs
  • Add new module ode
  • Work on multi-adaptive ODE solver (lots of new stuff)
  • Work on grid refinement
  • Write all macros in LoggerMacros in one line
  • Add transpose functions to Matrix (Erik)

0.3.9

  • Update Krylov solver (Erik, Johan)
  • Add new LU factorization and LU solve (Niklas)
  • Add benchmark test in src/demo/bench
  • Add silent logger

0.3.8

  • Make sure dolfin-config is regenerated every time
  • Add demo program for cG(q) and dG(q)
  • Add dG(q) precalc of nodal points and weights
  • Add cG(q) precalc of nodal points and weights
  • Fix a bug in configure.in (AC_INIT with README)
  • Add Lagrange polynomials
  • Add multiplication with transpose
  • Add scalar products with rows and columns
  • Add A[i][j] index operator for quick access to dense matrix

0.3.7

  • Add new Matlab-like syntax like A(i,all) = x or A(3,all) = A(4,all)
  • Add dolfin_assert() macro enabled if debug is defined
  • Redesign of Matrix/DenseMatrix/SparseMatrix to use Matrix as common interface
  • Include missing cmath in Legendre.cpp and GaussianQuadrature.cpp

0.3.6

  • Add output functionality in DenseMatrix
  • Add high precision solver to DirectSolver
  • Clean up error messages in Matrix
  • Make solvers directly accessible through Matrix and DenseMatrix
  • Add quadrature (Gauss, Radau, and Lobatto) from Tanganyika
  • Start merge with Tanganyika
  • Add support for automatic documentation using doxygen
  • Update configure scripts
  • Add greeting at end of compilation

0.3.5

  • Define version number only in the file configure.in
  • Fix compilation problem (missing depcomp)

0.3.4

  • Fix bugs in some of the ElementFunction operators
  • Make convection-diffusion solver work again
  • Fix bug in integration, move multiplication with the determinant
  • Fix memory leaks in ElementFunction
  • Add parameter to choose output format
  • Make OctaveFile and MatlabFile subclasses of MFile
  • Add classes ScalarExpressionFunction and VectorExpressionFunction
  • Make progress bars work cleaner
  • Get ctrl-c in curses logger
  • Remove <Problem>Settings-classes and use dolfin_parameter()
  • Redesign settings to match the structure of the log system
  • Add vector functions: Function::Vector
  • Add vector element functions: ElementFunction::Vector

0.3.3

  • Increased functionality of curses-based interface
  • Add progress bars to log system

0.3.2

  • More work on grid refinement
  • Add new curses based log system

0.3.1

  • Makefile updates: make install should now work properly
  • KrylovSolver updates
  • Preparation for grid refinement
  • Matrix and Vector updates

0.3.0

  • Make poisson work again, other modules still not working
  • Add output format for octave
  • Fix code to compile with g++-3.2 -Wall -Werror
  • New operators for Matrix
  • New and faster GMRES solver (speedup factor 4)
  • Changed name from SparseMatrix to Matrix
  • Remove old unused code
  • Add subdirectory math containing mathematical functions
  • Better access for A(i,j) += to improve speed in assembling
  • Add benchmark for linear algebra
  • New definition of finite element
  • Add algebra for function spaces
  • Convert grids in data/grids to xml.gz
  • Add iterators for Nodes and Cells
  • Change from .hh to .h
  • Add operators to Vector class (foufas)
  • Add dependence on libxml2
  • Change from .C to .cpp to make Jim happy.
  • Change input/output functionality to streams
  • Change to new data structure for Grid
  • Change to object-oriented API at top level
  • Add use of C++ namespaces
  • Complete and major restructuring of the code
  • Fix compilation error in src/config
  • Fix name of keyword for convection-diffusion

0.2.11-1

  • Fix compilation error (source) on Solaris

0.2.11

  • Automate build process to simplify addition of new modules
  • Fix bug in matlab_write_field() (walter)
  • Fix bug in SparseMatrix::GetCopy() (foufas)

0.2.10-1

  • Fix compilation errors on RedHat (thsv)

0.2.10

  • Fix compilation of problems to use correct compiler
  • Change default test problems to the ones in the report
  • Improve memory management using mpatrol for tracking allocations
  • Change bool to int for va_arg, seems to be a problem with gcc > 3.0
  • Improve input / output support: GiD, Matlab, OpenDX

0.2.8

  • Navier-Stokes starting to work again
  • Add Navier-Stokes 2d
  • Bug fixes

0.2.7

  • Add support for 2D problems
  • Add module convection-diffusion
  • Add local/global fields in equation/problem
  • Bug fixes
  • Navier-Stokes updates (still broken)

0.2.6 [2002-02-19]

  • Navier-Stokes updates (still broken)
  • Output to matlab format

0.2.5

  • Add variational formulation with overloaded operators for systems
  • ShapeFunction/LocalField/FiniteElement according to Scott & Brenner

0.2.4

  • Add boundary conditions
  • Poisson seems to work ok

0.2.3

  • Add GMRES solver
  • Add CG solver
  • Add direct solver
  • Add Poisson solver
  • Big changes to the organisation of the source tree
  • Add kwdist.sh script
  • Bug fixes

0.2.2:

  • Remove curses temporarily

0.2.1:

  • Remove all PETSc stuff. Finally!
  • Gauss-Seidel cannot handle the pressure equation

0.2.0:

  • First GPL release
  • Remove all of Klas Samuelssons proprietary grid code
  • Adaptivity and refinement broken, include in next release

Indices and tables