Hello Everyone,
Please use: ffc -l dolfin filename.ufl
to run the following form file.
I have the following UFL. The UFL used to compile successfully before I added a damping term in it. You can observe that the damping term is the one with constant "eta", in both the RHS and LHS. If you remove that, it will compile. So don't worry about understanding other terms in RHS/ LHS. The problem I am solving is a dynamic problem using predictor-corrector Newmark Beta scheme. The issue is with the way "v_pred" is defined. It is the predicted velocity containing the initial velocity "v" and initial accn "a". I understand that to find trace, you at least need a matrix (i.e. a tensor of rank 2).
degree = 2
elementA = VectorElement("Lagrange", triangle, degree)
elementT = VectorElement("Quadrature", triangle, degree, 9)
elementS = VectorElement("Quadrature", triangle, degree, 3)
w = TestFunction(elementA)
du = TrialFunction(elementA)
u = Coefficient(elementA) # current displacement
f = Coefficient(elementA) # body force
g = Coefficient(elementA) # surface traction
t = Coefficient(elementT) # vectorized tangent matrix
s = Coefficient(elementS) # vectorized stress matrix
u0 = Coefficient(elementA) # displacement prediction
v = Coefficient(elementA) #velocity
a = Coefficient(elementA) #accn
rho = Constant(triangle) # density
beta = Constant(triangle) # beta-parameter in the Newmark time stepping
dt = Constant(triangle) # time increment
eta = Constant(triangle) # Damping
def eps(u):
return as_vector([u[i].dx(i) for i in range(2)] + [u[i].dx(j) + u[j].dx(i) for i, j in [(0, 1)]])
def sigma(s):
return as_matrix([[s[0], s[2]], [s[2], s[1]]])
def tangent(t):
return as_matrix([[t[i*3 + j] for j in range(3)] for i in range(3)])
#def v_pred(): # velocity prediction
# return (v+(dt/2)*a)
# Nonlinear elastoplastic dynamic equation after discretization (with a damping term)
L += eta*tr((grad(u)/2*beta*dt)+grad(v_pred)-(grad(u0)/2*beta*dt))*tr(grad(w))*dx #damping
# Jacobian (with the damping term)
J += eta*tr(eps(du)/2*beta*dt)*tr(grad(w))*dx #damping