This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Avoid repeated assembly of multilinear forms

+1 vote

Dear all,

I am trying to apply the ideas of the "Avoid Assembly" paragraph from the "Time-Dependent problems" tutorial to speed up a slightly more complicated problem.

One of the form I would like to pre-assemble looks like the following:

mesh = RectangleMesh (0, 0, 1, 1, 10, 10)
V = VectorFunctionSpace(mesh, "CG", 1)
g = Function(V)
u = TrialFunction(V)
v = TestFunction(V)

a = inner(g, u)*inner(g, v)*dx
A = assemble(a)

The values of the function g is changing at each iteration of the computation. So the assembly is done from zero at every iteration. Is there a way to assemble a matrix (or several) that would be multiplied by g to get A so that the repeated assembly of A can be avoided ?

asked Oct 24, 2013 by tlecomte FEniCS Novice (330 points)

1 Answer

+4 votes
 
Best answer

Hi,

Unfortunately, there's no immediate way to do what you propose if your form is correct. Basically, the avoiding assemble trick is used to compute the assembling of linear forms quickly in terms of a matrix-vector product. You can do

A = assemble(inner(u, v)*dx)

and then get

G = assemble(inner(g, v)*dx)

with the short and fast

G = A*g.vector()

But the nonlinear in g and bilinear form you suggest needs to be reassembled each timestep.

answered Oct 24, 2013 by mikael-mortensen FEniCS Expert (29,340 points)
selected Nov 1, 2013 by Jan Blechta

Thank you for your answer. This is so bad !! Could there be a solution in the direction of mixed spaces ?

Sorry, nonlinear equations are tough and I don't know of any solution in the direction of mixed spaces.

Ok. Let me note that the equation obtained by a = inner(g, u)*inner(g, v)*dx is linear, since g is known. It is the assembly that would be multilinear, so the matrix A produced would actually be a tensor instead of a matrix...

Ok, I assumed your g was a function of the solution and thus a regular nonlinear problem that had been linearized. Unfortunately you cannot store tensors of rank higher than 2 with FEniCS, and I guess that would be required for the fast assembling trick of multilinear forms.

...