# dirichlet for y&z-direction of boundary, but not for x-direction

Hi,

in my code i want to compress a beam by a unit force. The left side is clamped and the right side (where the force is applied) should only move in x direction and not in y&z-direction.

I tried:

uLeft = CoefficientFunction((0.0, 0.0, 0.0))
uRight = CoefficientFunction((1, 0.0, 0.0))

gfu.Set(mesh.BoundaryCF({ “left” : uLeft, “right” : x*uRight}), definedon=mesh.Boundaries(“left|right”))

but this did not work.

Can you guys help me how to define boundaries that way?
Thanks https://ngsolve.org/media/kunena/attachments/1620/nonlin-elasti.ipynb

Hi joey,

I don’t know much about elasticity problems, but here are a couple of principles which might help:

-Dirichlet boundary conditions are easiest set in the FE space. If you use the VectorH1 space, there are the option “dirichletx”, “dirichlety”… with which you can set the Dirichlet flags for components of the boundaries. Best in this case is probably, if you construct the product space by defining the individual component spaces first.

``````fes1 = H1(mesh, order=2, dirichlet="left")
fes2 = H1(mesh, order=2, dirichlet="left|right")
fes3 = H1(mesh, order=2, dirichlet="left|right")
fes = fes1 * fes2 * fes3``````

-If you only have non-homogeneous Dirichlet conditions on one boundary, then you don’t need to set anything on the other Dirichlet boundary, as the dofs on that boundary will not be touched due to the freedofs=fes.FreeDofs() in the construction of the “inverse”.

Best wishes,
Henry