FFC

Comment 2 for bug 897372

Revision history for this message
Anders Logg (logg) wrote : Re: [Bug 897372] [NEW] FFC is extremely slow compared to SFC for this Fung-type material law

Thanks for the bug report! I like this comment:

  "compiling is done in no more than ten minutes"

:-)

--
Anders

On Mon, Nov 28, 2011 at 07:47:09PM -0000, Anders E. Johansen wrote:
> Public bug reported:
>
> FFC uses a considerable amount of time (> 1h) compiling the following
> program. The generated .h-file exceeds 90MB. Running, it uses hours
> assembling a matrix. Using the SFC compiler, compiling is done in no
> more than ten minutes, and then the program finishes in about ten
> seconds.
>
> I have similar problems with FFC and this Fung-type material law in
> other cases, eg computing the second Piola-Kirchhoff stress tensor.
> Then, the SFC compiled code is about 22000 times faster than FFC.
>
> Anders
>
>
> from dolfin import *
>
> mesh = UnitCube(2, 2, 2)
> V = VectorFunctionSpace(mesh, "CG", 1)
> bcl = DirichletBC(V, (0.0, 0.0, 0.0), "near(x[0], 0.0) && on_boundary")
> bcr = DirichletBC(V, (0.1, 0.0, 0.0), "near(x[0], 1.0) && on_boundary")
> bcs = [bcl, bcr]
>
> v = TestFunction(V)
> u = Function(V)
> du = TrialFunction(V)
>
> K = Constant(0.876)
> C = Constant(10.0)
> bff = Constant(18.48)
> bxx = Constant(3.58)
> bfx = Constant(2.8)
>
> I = Identity(3)
> F = I + grad(u)
>
> a = Expression(("x[0]*DOLFIN_PI/8"))
> R = as_matrix([[cos(a), 0, -sin(a)], [0, 1, 0], [sin(a), 0, cos(a)]])
>
> F = variable(R.T*F*R)
> E = 0.5*(F.T*F - I)
> J = det(F)
>
> f=0; s=1; n=2
> W = (bff*E[f,f]**2
> + bxx*(E[n,n]**2 + E[s,s]**2 + E[n,s]**2)
> + bfx*(E[f,n]**2 + E[n,f]**2 + E[f,s]**2 + E[s,f]**2))
> psi = 0.5*K*(exp(W) - 1) + C*(J*ln(J) - J + 1)
>
> P = diff(psi, F)
> P = R*P*R.T
>
> L = inner(P, grad(v))*dx
> a = derivative(L, u, du)
> solve(L==0, u, bcs, J=a)
> plot(u, mode="displacement", interactive=True)
>
> ** Affects: ffc
> Importance: Undecided
> Status: New
>