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

Retain an expression when using FFC

0 votes

Hello,

I would like to ask if there is an option to retain an intermediate expression when using FFC to convert a .ufl file to a .h file. For example, here is the HyperElasticity.ufl from FEniCS demo:

# Function spaces
element = VectorElement("Lagrange", tetrahedron, 1)

# Trial and test functions
du = TrialFunction(element)     # Incremental displacement
v  = TestFunction(element)      # Test function

# Functions
u = Coefficient(element)        # Displacement from previous iteration
B = Coefficient(element)        # Body force per unit volume
T = Coefficient(element)        # Traction force on the boundary

# Kinematics
d = u.geometric_dimension()
I = Identity(d)                 # Identity tensor
F = I + grad(u)                 # Deformation gradient
C = F.T*F                       # Right Cauchy-Green tensor

# Invariants of deformation tensors
Ic = tr(C)
J  = det(F)

# Elasticity parameters
mu    = Constant(tetrahedron)
lmbda = Constant(tetrahedron)

# Stored strain energy density (compressible neo-Hookean model)
psi = (mu/2)*(Ic - 3) - mu*ln(J) + (lmbda/2)*(ln(J))**2

# Total potential energy
Pi = psi*dx - inner(B, u)*dx - inner(T, u)*ds

# First variation of Pi (directional derivative about u in the direction of v)
F = derivative(Pi, u, v)

# Compute Jacobian of F
J = derivative(F, u, du)

After obtaining the HyperElasticity.h using FFC, I want to compute the value of psi, for example, then it seems that I have to define again the expression for psi in the main.cpp?

Thank you very much.
dtruong27

asked Mar 21, 2016 by duytruong27 FEniCS Novice (120 points)
...