# Applying force at one boundary

Hello. I’m trying to simulate tensile test.
at one end(y=0) of rectangular piece of material is fixed(u=0).
at the other end(y=L), tensile force is applied.
I guess force can be applied with traction T.
For example, T=nonzero constant at y=L
and T=0 at x=0 and L
My question is how to set different T values for different boundary?

I’m not sure but I may have found a solution.

``````boundaries = [(1, lambda x: np.isclose(x[0], 0)),
(2, lambda x: np.isclose(x[0], W)),
(3, lambda x: np.isclose(x[1], L))]

facet_indices, facet_markers = [], []
fdim = domain.topology.dim - 1
for (marker, locator) in boundaries:
facets = mesh.locate_entities(domain, fdim, locator)
facet_indices.append(facets)
facet_markers.append(np.full_like(facets, marker))
facet_indices = np.hstack(facet_indices).astype(np.int32)
facet_markers = np.hstack(facet_markers).astype(np.int32)
sorted_facets = np.argsort(facet_indices)
facet_tag = mesh.meshtags(domain, fdim, facet_indices[sorted_facets], facet_markers[sorted_facets])
ds = ufl.Measure("ds", domain=domain, subdomain_data=facet_tag)

T0 = fem.Constant(domain, default_scalar_type((0, 0)))
T1 = fem.Constant(domain, default_scalar_type((0, 1)))

L = ufl.dot(f, v) * ufl.dx + ufl.dot(T0, v) * ds(1) + ufl.dot(T0, v) * ds(2) + + ufl.dot(T1, v) * ds(3)

``````