Hello everyone,
I am trying to use the assemble_scalar operation as show below in code.
from dolfinx import fem, plot, mesh, cpp , la
from mpi4py import MPI
import numpy as np
from ufl import TestFunction, TrialFunction,Measure, grad, dot, inner
import dolfinx
from dolfinx.fem import FunctionSpace, Function, locate_dofs_geometrical, dirichletbc, Constant
from petsc4py.PETSc import ScalarType
length = 200.
num_elem = 1
mesh = mesh.create_interval(MPI.COMM_WORLD,num_elem,[0., length])
V_u = FunctionSpace(mesh, ('Lagrange', 1))
u, du, v = Function(V_u), TrialFunction(V_u), TestFunction(V_u)
dx = Measure("dx",domain=mesh)
def on_boundary_L(x):
return np.isclose(x[0],0.0)
dof_left_u = locate_dofs_geometrical(V_u, on_boundary_L)
bcl = dirichletbc(ScalarType(0), dof_left_u, V_u)
E = Constant(mesh,ScalarType(30000.0))
def eps(u):
return grad(u)
def sigma(u):
return E*(eps(u))
f_ext = Constant(mesh,0.0)
external_work = dot(f_ext, u) * dx
elastic_energy = inner(sigma(u), eps(u))*dx
T_E = dolfinx.fem.assemble_scalar(elastic_energy)
I am getting the following error
Can someone please tell me, what I am doing wrong and how I can fix this error.
Thank you,
Manish