We establish the existence of a global heat flow u :where Ω is a bounded domain in R n , n 2, and K is a nonconvex (possibly, noncompact) set in R N with the smooth boundary of class C 2 . For any smooth initial function φ such that φ(Ω) ⊂ K we prove the existence of a global weak solution to the problem such that it is smooth on the set Ω × [0, ∞) \ Σ. We also estimate the Hausdorff dimension of the closed singular set Σ. It is shown that u(x, t) → u ∞ (x), t → ∞, where u ∞ is the extremal of the corresponding stationary problem with an obstacle outgoing to the boundary of the domain. A similar result holds for an obstacle given on a smooth hypersurface in R N . Bibliography: 31 titles.