FFC

FFC is extremely slow compared to SFC for this Fung-type material law

Bug #897372 reported by Anders E. Johansen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
FFC
Invalid
High
Unassigned

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)

Revision history for this message
Kristian B. Ølgaard (k.b.oelgaard) wrote : Re: [Bug 897372] [NEW] FFC is extremely slow compared to SFC for this Fung-type material law
Download full text (4.6 KiB)

On 28 November 2011 20:47, Anders E. Johansen <email address hidden> 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.

Thank you for the bug report.
I don't have time at the moment to fix this, there is no simple
solution other than serious profiling and I foresee a lot of code to
be rewritten to get around this.

Are you using any GCC optimisations?
'-O2 -funroll-loops' usually gives good performance with quadrature code.
With a 90MB header file you might be stressing your hardware though.

You could also try to switch on FFC optimisations, I expect it will add to
the FFC compile time, if at all possible.
Use '-O -fprecompute_basis_const -feliminate_zeros' as I doubt
'-O' will work, it is quite memory intense.

I'm not surprised that SFC outperformes FFC, as it was designed with these
hyper elastic models in mind.
Are there any particular reasons you want to use FFC instead of SFC?

> 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.

Could you add an example of such a case, it's good to have a more
forms for testing these things.
Slightly less complex forms are also appreciated, waiting hours
between each debug cycle is rather inefficient.

> 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
>
> --
> 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, ...

Read more...

Revision history for this message
Anders Logg (logg) wrote :

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
>

Revision history for this message
Anders E. Johansen (andersej) 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.

Logg - When you are used to waiting an hour for the code to compile, ten minutes is like heaven :-)

Anders

Revision history for this message
Kent-Andre Mardal (kent-and) wrote : Re: [Bug 897372] Re: FFC is extremely slow compared to SFC for this Fung-type material law
Download full text (3.1 KiB)

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.

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...

Read more...

Revision history for this message
Marie Rognes (meg-simula) wrote :
Download full text (5.5 KiB)

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]...

Read more...

Revision history for this message
Kristian B. Ølgaard (k.b.oelgaard) wrote :
Download full text (3.2 KiB)

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

OK. Not much more you can do then in terms of FFC optimisations.

> 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

OK. So no chance of an easy solution to this bug.

Kristian

> # 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.
>
> 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 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.la...

Read more...

Revision history for this message
Anders Logg (logg) wrote :

On Mon, Nov 28, 2011 at 10:26:22PM -0000, Marie Rognes wrote:
> 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?

I can't find that bug report. Where is it?

--
Anders

Revision history for this message
Marie Rognes (meg-simula) wrote :

On 29. nov. 2011, at 00:20, Anders Logg <email address hidden> wrote:

>>>>
>>>> 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?
>
> I can't find that bug report. Where is it?

At launchpad in fenics-syfi #845176
Not with the Students for Free Culture.

--
Marie

Revision history for this message
Anders Logg (logg) wrote :

On Mon, Nov 28, 2011 at 11:30:12PM -0000, Marie Rognes wrote:
> On 29. nov. 2011, at 00:20, Anders Logg <email address hidden> wrote:
>
> >>>>
> >>>> 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?
> >
> > I can't find that bug report. Where is it?
>
>
> At launchpad in fenics-syfi #845176

Aha! Then I understand. I thought you meant a bug report for FFC
regarding Anders J's problem.

--
Anders

Revision history for this message
Martin Sandve Alnæs (martinal) wrote :
Download full text (5.5 KiB)

Kristian: I think you mentioned somewhere that arguments to mathfunctions
are not optimized well, that could be it.

Martin
Den 29. nov. 2011 00.15 skrev "Kristian B. Ølgaard" <
<email address hidden>> følgende:

> 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
>
> OK. Not much more you can do then in terms of FFC optimisations.
>
> > 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
>
> OK. So no chance of an easy solution to this bug.
>
> Kristian
>
> > # 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.
> >
> > 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 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 =...

Read more...

Revision history for this message
Kent-Andre Mardal (kent-and) wrote :

On 28 November 2011 23:26, Marie Rognes <email address hidden> wrote:

> 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
>
>
Sorry about that. Martin has fixed it now.

Kent

Revision history for this message
Marie Rognes (meg-simula) wrote :

On 11/29/2011 02:50 PM, Kent-Andre Mardal wrote:
> On 28 November 2011 23:26, Marie Rognes<email address hidden>
> wrote:
>
>> 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
>>
>>
> Sorry about that. Martin has fixed it now.

Great, thanks!

--
Marie

Revision history for this message
Garth Wells (garth-wells) wrote :

Try using

  parameters["form_compiler"]["cpp_optimize"] = True
  ffc_options = {"quadrature_degree": 1, \
                "optimize": True, \
                "eliminate_zeros": True, \
                "precompute_basis_const": True}

and

   solve(L==0, u, bcs, J=a, form_compiler_parameters=ffc_options)

It's pretty fast for me.

One reason why SFC is faster without setting options is that FFC uses a very conservative integration scheme.

Revision history for this message
Kristian B. Ølgaard (k.b.oelgaard) wrote :
Download full text (7.9 KiB)

On 29 November 2011 08:22, Martin Sandve Alnæs
<email address hidden> wrote:
> Kristian: I think you mentioned somewhere that arguments to mathfunctions
> are not optimized well, that could be it.

That sounds very likely, there must be quite a few ending up in the
code. Unfortunately, some infrastructure changes are needed to handle
this in the quadrature representation.

> Martin
> Den 29. nov. 2011 00.15 skrev "Kristian B. Ølgaard" <
> <email address hidden>> følgende:
>
>> 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
>>
>> OK. Not much more you can do then in terms of FFC optimisations.
>>
>> > 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
>>
>> OK. So no chance of an easy solution to this bug.
>>
>> Kristian
>>
>> > # 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.
>> >
>> > 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 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   = Cons...

Read more...

Revision history for this message
Kristian B. Ølgaard (k.b.oelgaard) wrote : Re: [Bug 897372] [NEW] FFC is extremely slow compared to SFC for this Fung-type material law
Download full text (4.9 KiB)

On 28 November 2011 20:47, Anders E. Johansen <email address hidden> 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
>
> --
> 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*...

Read more...

Revision history for this message
Anders Logg (logg) wrote :
Download full text (5.4 KiB)

On Wed, Nov 30, 2011 at 02:16:33PM -0000, Kristian B. Ølgaard wrote:
> On 28 November 2011 20:47, Anders E. Johansen <email address hidden> 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
> >
> >
> > 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]*DOL...

Read more...

Revision history for this message
Kristian B. Ølgaard (k.b.oelgaard) wrote :
Download full text (7.9 KiB)

On 30 November 2011 15:29, Anders Logg <email address hidden> wrote:
> On Wed, Nov 30, 2011 at 02:16:33PM -0000, Kristian B. Ølgaard wrote:
>> On 28 November 2011 20:47, Anders E. Johansen <email address hidden> 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
>> >
>> >
>> > 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...

Read more...

Revision history for this message
Anders Logg (logg) wrote :
Download full text (8.3 KiB)

On Wed, Nov 30, 2011 at 03:12:04PM -0000, Kristian B. Ølgaard wrote:
> On 30 November 2011 15:29, Anders Logg <email address hidden> wrote:
> > On Wed, Nov 30, 2011 at 02:16:33PM -0000, Kristian B. Ølgaard wrote:
> >> On 28 November 2011 20:47, Anders E. Johansen <email address hidden> 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
> >> >
> >> >
> >> > 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_bo...

Read more...

Revision history for this message
Anders E. Johansen (andersej) wrote :

Ok, I understand. I can confirm that the option

ffc_options = {"quadrature_degree": 2}

made the program run in approx. the times you mentioned. I'm sorry, I was not aware of the high number of integration points.

But I agree that a warning would be a good idea.

Anders

Revision history for this message
Kristian B. Ølgaard (k.b.oelgaard) wrote :
Download full text (10.7 KiB)

On 30 November 2011 17:23, Anders Logg <email address hidden> wrote:
> On Wed, Nov 30, 2011 at 03:12:04PM -0000, Kristian B. Ølgaard wrote:
>> On 30 November 2011 15:29, Anders Logg <email address hidden> wrote:
>> > On Wed, Nov 30, 2011 at 02:16:33PM -0000, Kristian B. Ølgaard wrote:
>> >> On 28 November 2011 20:47, Anders E. Johansen <email address hidden> 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
>> >> >
>> >> >
>> >> > 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 *
>> >> >...

Revision history for this message
Kristian B. Ølgaard (k.b.oelgaard) wrote : Re: [Bug 897372] Re: FFC is extremely slow compared to SFC for this Fung-type material law

On 30 November 2011 19:05, Anders E. Johansen <email address hidden> wrote:
> Ok, I understand. I can confirm that the option
>
> ffc_options = {"quadrature_degree": 2}
>
> made the program run in approx. the times you mentioned.

Excellent.

I'm sorry, I
> was not aware of the high number of integration points.

Only Garth spotted the problem immediately, so you're excused.

> But I agree that a warning would be a good idea.

I added a warning, need to test if it is caught in PyDOLFIN though.

>
> Anders
>
> --
> 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

Changed in ffc:
status: New → Invalid
Revision history for this message
Johan Hake (johan-hake) wrote :

This is still a huge problem for some more complicated hyperelasticity problems. I profiled FFc and found that most of the ffc time was spent in split_expression doing:

  prods.pop(0)

prods is a list, which is a stack and you do not do a pop(0) on a stack...

So the data structure was changed to a deque and that bottle neck disappeared.

However, Harish is using some even more evil forms than Anders (Johansen) is using, generating an .h file which is 48M big. With two lines basically filling the whole file. One within tabulate tensor which is 40M characters long(!?) and the signature line which is _only_ 3.4M characters long. It has been compiling now for 1.5h, still not finished.

There has to be optimizations, like grouped finiteelement method to reduce the complexity of the tabulate tensor function. Because essentially it boils down to the expansion of coefficient operations, right?

Changed in ffc:
status: Invalid → Confirmed
importance: Undecided → High
Revision history for this message
Marie Rognes (meg-simula) wrote :

Johan, this is a separate issue. Please open a new bug.

Johan Hake (johan-hake)
Changed in ffc:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.