Solution (source code)

= Solution

Work to first order in the <slope> $w'$ and take $B$ constant. The <elastic beam> is slender, its cross-sections remain plane and normal to its centreline, transverse shear deformation is neglected, and the loading is quasi-static. There are no distributed couples. In a non-contact interval the distributed <force> is $-p\mathbf e_z$ and there is no axial distributed <force>. These are the assumptions of the small-deformation <Euler-Bernoulli beam equation>, with an optional prescribed <tension> retained in transverse <force balance>.

Choose the internal section resultant on the right face of a segment as
$$
\mathbf F=T\mathbf e_x+(Tw'+N)\mathbf e_z,
$$
where $N$ is the <transverse shear force>, and take the section <bending moment> as $M\mathbf e_y$. Longitudinal and transverse <force balance> on a segment of length $dx$ give $T'=0$ and $(Tw'+N)'=p$. Balancing the <torques> about its left end gives $M'=N$: the <torque> from the transverse section resultant is $-N\,dx\,\mathbf e_y$. Therefore
$$
\boxed{T'=0,\qquad Tw''+N'=p,\qquad M'=N.}
$$
With this positive-$y$ <bending moment> convention, the linear relation between <bending moment> and <curvature> is $M=-Bw''$. Thus $N=-Bw'''$, and substitution gives
$$
\boxed{Bw''''-Tw''+p=0.}
$$
The <tension> need not be small compared with the transverse restoring terms, but products arising solely from finite deformation, such as the change of axial extension proportional to $(w')^2$, are outside this linear model. A separate axial constitutive constraint would be required to determine an unknown <tension> from fixed end positions.

In an open contact interval, the upward distributed <normal contact force> is $R$. At this order the smooth obstacle supplies no axial <force>; its vertical resultant changes the downward load to $p-R$. Hence
$$
\boxed{Bw''''-Tw''+p=R.}
$$
For nonadhesive <unilateral beam contact>, the obstacle can push but cannot pull, so $R\geq0$. The accompanying constraints are $w\geq f$ and $(w-f)R=0$. A negative $R$ would require adhesion and would invalidate the proposed contact region. If $f$ is four times differentiable, the distributed <normal contact force> inside an open contact interval is $R=Bf''''-Tf''+p$.