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

goal function defenition of auto-adaptive problem in ufl: use the hyperelasticity as an example

0 votes

Hi all,

I am trying to solve the hyperelastic problem with adaptive meshes, and started with the Hyperelasticity demo. Here's the ufl file

# 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)

 M=inner(u, u)*dx

I added

M=inner(u, u)*dx

as the Goal function for error estimation, following the undocumented demo auto-adaptive-navier-stokes. And compiled the form use:

ffc -l dolfin -e  HyperElasticity.ufl

The output:

This is FFC, the FEniCS Form Compiler, version 1.6.0.
For further information, visit http://www.fenics.org/ffc/.
Traceback (most recent call last):
  File "/usr/bin/ffc", line 213, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/usr/bin/ffc", line 182, in main
    parameters)
  File "/usr/lib/python2.7/dist-packages/ffc/errorcontrol/errorcontrol.py", line 65, in compile_with_error_control
    F, M, u = prepare_input_arguments(forms, object_names, reserved_objects)
  File "/usr/lib/python2.7/dist-packages/ffc/errorcontrol/errorcontrol.py", line 156, in prepare_input_arguments
    assert(len(arguments) == 2)
AssertionError

Any ideas? Cheers!

asked Oct 16, 2016 by qiangzini FEniCS Novice (760 points)
...