FFC

Comment 5 for bug 897372

Revision history for this message
Marie Rognes (meg-simula) wrote : Re: [Bug 897372] Re: FFC is extremely slow compared to SFC for this Fung-type material law

On 28. nov. 2011, at 23:15, Kent-Andre Mardal <email address hidden> wrote:

> On 28 November 2011 22:07, Anders E. Johansen
> <email address hidden>wrote:
>
>> Kristian, I'm using the optimization options from the Hyperelasticity
>> demo. But with
>>
>> parameters["form_compiler"]["cpp_optimize"] = True
>>
>> FFC won't compile when computing 2PK (at least not in an hour). Using
>> the same bcs, parameters, etc. as in my first post, this code reads
>>
>> # Kinematics
>> I = Identity(3)
>> F = variable(I + grad(u))
>> C = variable(F.T*F)
>> E = 0.5*(C - I)
>> J = sqrt(det(C))
>>
>> # Material law
>> 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) + Cc*(J*ln(J) - J + 1)
>>
>> # 2PK
>> S = 2*diff(psi, C)
>>
>> # 1PK
>> P = F*S
>> #P = diff(psi, F)
>>
>> When computing 1PK directly, there is no problem at all.
>>
>> The reason I want to use FFC, is that SFC is not in active development,
>> and have lack of developers, users and features compared to FFC, I have
>> been told.
>>
>>
> :)
> We will make sure SFC works also in the future. But at present, SFC does
> what we need...
> If you have specific needs, let us know.
>

I tried filing a bug a while back but it did not seem to receive much attention. Is there another channel for letting you know?

--
Marie

> Kent
>
>
>> Logg - When you are used to waiting an hour for the code to compile, ten
>> minutes is like heaven :-)
>>
>>
>> Anders
>>
>> --
>> You received this bug notification because you are subscribed to FFC.
>> https://bugs.launchpad.net/bugs/897372
>>
>> Title:
>> FFC is extremely slow compared to SFC for this Fung-type material law
>>
>> Status in FEniCS Form Compiler:
>> New
>>
>> Bug description:
>> 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)
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/ffc/+bug/897372/+subscriptions
>>
>
> --
> You received this bug notification because you are a member of FFC Core
> Team, which is subscribed to FFC.
> https://bugs.launchpad.net/bugs/897372
>
> Title:
> FFC is extremely slow compared to SFC for this Fung-type material law
>
> Status in FEniCS Form Compiler:
> New
>
> Bug description:
> 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)
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ffc/+bug/897372/+subscriptions