Hello,
I am trying to solve a simple elasticity problem where a cantilever beam is subjected to a constant displacement at one end. I am having trouble with defining the constant displacement at a particular node. I did find an old question for legacy FEniCS, but that does not work now.
Here is the code
l= 1
h = 0.1
E=130e9
nu=0.22
E=E/(1-nu*nu)
lambda_=nu*E/(1+nu)/(1-2*nu)
mu=E/2/(1+nu)
w= 1e6
I= h**3/12
import numpy as np
import ufl
from mpi4py import MPI
from petsc4py.PETSc import ScalarType
from dolfinx import mesh, fem, plot, io
model='plane_strain'
domain = mesh.create_rectangle(MPI.COMM_WORLD, [np.array([0,0]), np.array([l, h])],
[200,20], cell_type=mesh.CellType.quadrilateral)
V = fem.VectorFunctionSpace(domain, ("CG", 1))
def clamped_boundary(x):
return np.isclose(x[0], 0)
def load_point(x):
return (np.isclose(x[0],l) and np.isclose(x[1],h/2))
fdim = domain.topology.dim - 1
boundary_facets = mesh.locate_entities_boundary(domain, fdim, clamped_boundary)
load_point_= mesh.locate_entities_boundary(domain, fdim-1, load_point)
u_D1 = np.array([0,0], dtype=ScalarType)
bc1 = fem.dirichletbc(u_D1, fem.locate_dofs_topological(V, fdim, boundary_facets), V)
u_D2= np.array([0,-1e-2], dtype=ScalarType)
bc2= fem.dirichletbc(u_D2, fem.locate_dofs_topological(V, fdim-1, load_point_), V)
bc=[bc1,bc2]
Here is the error message
Traceback (most recent call last):
File "/Users/aaquib/Desktop/fenics/test2.py", line 32, in <module>
load_point_= mesh.locate_entities_boundary(domain, fdim-1, load_point)
File "/Users/aaquib/opt/anaconda3/envs/fenicsx-env/lib/python3.10/site-packages/dolfinx/mesh.py", line 110, in locate_entities_boundary
return _cpp.mesh.locate_entities_boundary(mesh, dim, marker)
File "/Users/aaquib/Desktop/fenics/test2.py", line 27, in load_point
return (np.isclose(x[0],l) and np.isclose(x[1],h/2))
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I am also wondering how would I find the reaction force at that loading point.
Please help!