By far I have seen, in convex analysis and optimization literature, a coercive function $f: \mathbb{R}^n \to \mathbb R$ is defined as \begin{align*} f(x) \to +\infty \text{ as } \|x\| \to \infty. \end{align*} We can also replace $\mathbb R^n$ by a real Banach space $X$. In finite-dimensional space, a continuous coercive function is equivalent to say the sublevel sets are compact.
Now I am wondering which reference defines coercive function on an open subset of $\mathbb R^n$. That is $f : U \to \mathbb R$ where $U$ is an open subset of $\mathbb R^n$. Apparently, the definition should be adjusted: (1) If $U$ is bounded \begin{align*} f(x) \to \infty \text{ as } U \ni x \to \partial U. \end{align*} (2) If $U$ is unbounded, \begin{align*} f(x) \to \infty \text{ as } U \ni x \to \partial U \text{ and } f(x) \to \infty \text{ as } \|x\| \to \infty. \end{align*} If I am not mistaken, using this definition should also give the equivalence of continuous coercivity and compactness of sublevel set. I am writing a note and if there is some reference on this, I would not have prove this rather trivial fact.