We present a computational alternative to probabilistic simulations for nonsmooth stochastic dynamical systems that are prevalent in engineering mechanics. As examples, we target (1) stochastic elasto-plastic problems, which involve transitions between elastic and plastic states, and (2) obstacle problems with noise, which involve discrete impulses due to collisions with an obstacle. We formally introduce a class of partial differential equations related to the Feynman-Kac formula, where the underlying stochastic processes satisfy variational inequalities modelling elasto-plastic and obstacle oscillators. We then focus on solving them numerically. The main challenge in solving these equations is the non-standard boundary conditions which describe the behavior of the underlying process on the boundary. We illustrate how to use our approach to compute expectations and other statistical quantities, such as the asymptotic growth rate of variance in asymptotic formulae for threshold crossing probabilities.Here and in the remainder of the paper, µ, λ are positive numbers, b is a given threshold, T ą 0 is a given time, h ě 0 and f, g, ϕ, ψ are continuous functions. For cases in which H " 0 and pF, Gq satisfy appropriate smoothness conditions, a natural setting for characterizing such quantities with partial differential equations (PDEs) is to use the Feynman-Kac formula (FKf) [45]. Furthermore, if in addition F and G can be written in terms of a Hamiltonian structure Hpx, yq, in the sense F px, yq fi BH Bx px, yq, Gpx, yq fi BH By px, yq`ηpx, yq BH Bx px, yq, px, yq P R 2 ,where η is a well behaved function, then the process pX t , Y t q belongs to the class of Stochastic Hamiltonian Systems (SHS) [48] for which quantities of type C and C 1 are well defined. Applications that make use of this framework abound in many areas of science and engineering, e.g., finance, chemistry, biology, neuroscience, economy and mechanics. 6