← Back to team overview

ffc team mailing list archive

Re: [Bug 426512] Re: Problems parsing form file with diff and derivative

 

Quoting Garth Wells <gnw20@xxxxxxxxx>:

>
> oelgaard wrote:
> > I have fixed the issues with variable and exponents != IntValue, so the
> > above form should compile with FFC now.
> >
> > I can confirm that it takes 2m46s (166s) to compile the form on my
> > machine and the bottlenecks are:
> >
> > expand_indices, time = 114.66s
> > visit integrand, time =    36.59s
> >
> > expand_indices is a UFL algorithm, so to make things faster we will have to
> generate code without calling this.
> > The time spent in visit integrand might be reduced if we don't call
> expand_indices on the integrand.
> >
> > This bug should be fixed and I'm going to close it unless anyone has
> > objections. We can create an appropriate blueprint to take care of the
> > compile time issue.
> >
>
> Is there an explanation why SFC only takes a few seconds?

I don't think sfc (or I should say newsfc) uses expand_indices, it just operates
directly on the free indices in the expression. I think the first
implementations of sfc used expand_indices (according to grep) but Martin must
have figured out a better way to generate code without this call.
I tried to compile using sfc just to measure the difference, but I ran into
trouble with ginac/swiginac.

Kristian

> Garth
>
> --
> Problems parsing form file with diff and derivative
> https://bugs.launchpad.net/bugs/426512
> You received this bug notification because you are subscribed to FFC.
>
> Status in FEniCS Form Compiler: Confirmed
>
> Bug description:
> FFC has problems parsing the following form file. As I have pointed out in
> the code, I need to use the following:
>
> from ufl.algorithms import expand_derivatives, strip_variables
> L = strip_variables(expand_derivatives(L_temp))
> a = strip_variables(expand_derivatives(a_temp))
>
> to get it to compile via FFC. This is not needed for SFC, and while SFC takes
> a few seconds (without these lines), FFC takes 6m 25s)
>
> Also, FFC doesn't like fractional exponents which is pointed out in bug
> #423398.
>
> # Finite strain elasticity
>
> # Function space
> vector = VectorElement("Lagrange", "tetrahedron", 1)
>
> # Functions
> v  = TestFunction(vector)   # Test function
> du = TrialFunction(vector)  # Incremental displacement
> B  = Function(vector)       # Body force
> u  = Function(vector)       # Displacement at previous iteration
>
> # Kinematics
> I = Identity(3)
> F = I + grad(u).T
> C = F.T*F
> J = sqrt(det(C))
> Fbar = J**(-1./3.)*F  # Does not like fractional exponents
> Cbar = J**(-2./3.)*C  # Does not like fractional exponents
>
> E = (J*C - I)/2       # Want to try Cbar here, but using J*C instead
> E = variable(E)
>
> # Material law
> mu    = Constant("tetrahedron")
> lmbda = Constant("tetrahedron")
>
> psi = lmbda/2*(tr(E)**2) + mu*tr(E*E)
> S = diff(psi, E)
> P = F*S
>
> # Balance of momentum in the reference configuration
> L_temp = inner(P, grad(v).T)*dx - inner(B, v)*dx
> a_temp = derivative(L_temp, u, du)
>
> # FIXME: Shouldn't need to do the following
> from ufl.algorithms import expand_derivatives, strip_variables
> L = strip_variables(expand_derivatives(L_temp))
> a = strip_variables(expand_derivatives(a_temp))
> _______________________________________________
> FFC-dev mailing list
> FFC-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/ffc-dev
>

-- 
Problems parsing form file with diff and derivative
https://bugs.launchpad.net/bugs/426512
You received this bug notification because you are subscribed to FFC.

Status in FEniCS Form Compiler: Confirmed

Bug description:
FFC has problems parsing the following form file. As I have pointed out in the code, I need to use the following:

from ufl.algorithms import expand_derivatives, strip_variables
L = strip_variables(expand_derivatives(L_temp))
a = strip_variables(expand_derivatives(a_temp))

to get it to compile via FFC. This is not needed for SFC, and while SFC takes a few seconds (without these lines), FFC takes 6m 25s)

Also, FFC doesn't like fractional exponents which is pointed out in bug #423398.

# Finite strain elasticity

# Function space
vector = VectorElement("Lagrange", "tetrahedron", 1)

# Functions
v  = TestFunction(vector)   # Test function
du = TrialFunction(vector)  # Incremental displacement
B  = Function(vector)       # Body force
u  = Function(vector)       # Displacement at previous iteration

# Kinematics
I = Identity(3)
F = I + grad(u).T
C = F.T*F
J = sqrt(det(C))
Fbar = J**(-1./3.)*F  # Does not like fractional exponents
Cbar = J**(-2./3.)*C  # Does not like fractional exponents

E = (J*C - I)/2       # Want to try Cbar here, but using J*C instead
E = variable(E)

# Material law
mu    = Constant("tetrahedron")
lmbda = Constant("tetrahedron")

psi = lmbda/2*(tr(E)**2) + mu*tr(E*E)
S = diff(psi, E)
P = F*S

# Balance of momentum in the reference configuration
L_temp = inner(P, grad(v).T)*dx - inner(B, v)*dx
a_temp = derivative(L_temp, u, du)

# FIXME: Shouldn't need to do the following
from ufl.algorithms import expand_derivatives, strip_variables
L = strip_variables(expand_derivatives(L_temp))
a = strip_variables(expand_derivatives(a_temp))


References