← Back to team overview

dolfin team mailing list archive

Re: PyDOLFIN progress

 

Hi again,

I've now added two functions:

import_form(formlist, formname):
  """Generates and imports a module corresponding to the FFC form.
  Returns the module."""

import_formfile(filename):
  """Generates and imports a module corresponding to the FFC form file.
  Returns the module."""

which allows us to do what we've discussed. I.e.:

from dolfin import *
from ffc.compiler.compiler import *

element = FiniteElement("Lagrange", "tetrahedron", 1)

v = BasisFunction(element)
u = BasisFunction(element)

a = dot(grad(u), grad(v))*dx

form1 = import_form(a, "Poisson")

a1 = form1.PoissonBilinearForm()
mesh = UnitCube(1, 1, 1)
A1 = Matrix()

FEM_assemble(a1, A1, mesh)

An even better improvement would be to hide import_form() inside an
assemble function. It should be possible to write a function:

def assemble(form, matrix, mesh):
  form1 = import_form(form, "Anonymous")
  FEM_assemble(form1.AnonymousBilinearForm(), matrix, mesh)

Then an end-user doesn't have to be aware of this step at all. There
needs to be some extra administration to take care of what type of
form and coefficients though.

  Johan



Follow ups

References