We establish the existence of a global heat flow u : $ \bar{\Omega } \times {\mathbb{R}^{+} } \to {\mathbb{R}^N} $ , N > 1 such that $ u\left( {\bar{\Omega } \times {\mathbb{R}^{+} }} \right) \subset \mathcal{K} $ , where Ω is a bounded domain in ℝ n , n ≥ 2, and $ \mathcal{K} $ is a nonconvex (possibly, noncompact) set in ℝ N with the smooth boundary of class C 2. For any smooth initial function ϕ such that $ \phi \left( {\bar{\Omega }} \right) \subset \mathcal{K} $ we prove the existence of a global weak solution to the problem such that it is smooth on the set $ \bar{\Omega } \times \left[ {0,\infty } \right)\backslash \Sigma $ . 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 ℝ N . Bibliography: 31 titles.