在弹性动力学问题中,我将应力定义为
def sigma(v):
return 2.0*mu*sym(grad(v)) + lmbda*tr(sym(grad(v)))*Identity(v.cell().d)
我已经计算了节点处的位移。现在我想逐元素计算应力。任何人都可以帮忙吗?
在弹性动力学问题中,我将应力定义为
def sigma(v):
return 2.0*mu*sym(grad(v)) + lmbda*tr(sym(grad(v)))*Identity(v.cell().d)
我已经计算了节点处的位移。现在我想逐元素计算应力。任何人都可以帮忙吗?
以下编译:
from dolfin import *
from random import random
lmbda = Constant(1.0)
mu = Constant(1.0)
def sigma(v):
return 2.0*mu*sym(grad(v)) + lmbda*tr(sym(grad(v)))*Identity(v.cell().d)
mesh = UnitCubeMesh(8,8,8)
V = VectorFunctionSpace(mesh, "CG", 1)
# Create random displacement vector
displacement = Function(V)
for i in xrange(V.dim()):
displacement.vector()[i] = random()
T = TensorFunctionSpace(mesh, "DG", 0)
form = inner(sigma(displacement),TestFunction(T))*dx
scaling = 1.0/CellSize(mesh)
stress = Function(T)
assemble(scaling*form, tensor=stress.vector())