Continuous monotone real functions of several real variables Let $O$ be an open bounded connected set in $R^n$ and K its boundary. Given a continuous real function $f$ defined on $K$, I would like to extend $f$ to a continuous real function $g$ (i.e. $g$ restricted to $K$ equals $f$) defined in the closure of $O$, in such a way that g is also monotone (e.g. the min and max of $g$ on each closed ball contained in $O$ is attained on the boundary of the ball). 
In case $K$ has the extra property of being Holder-continuous, there exists a harmonic function $g$ as intended; in particular $g$ is real-analytic in $O$ and is monotonic by the min and max principles.
What about if no extra property of $K$ is known, can one still find a monotonic $g$ as intended?
 A: I believe there must be an elementary answer to this question, but I could not find one. While the following is not a complete answer, here is what I would try.

Consider the operator $$L u(x) = \nabla \cdot (a(x) \nabla u(x)),$$ where $$a(x) = (\operatorname{dist}(x, \partial \Omega))^{-p}$$ for some $p > 0$. By general arguments there is a `solution' to the Dirichlet problem $$\begin{cases} Lu = 0 & \text{in $\Omega$,} \\ u = f & \text{on $\partial \Omega$,} \end{cases} $$ in an appropriate sense. On the stochastic processes side the argument might be the following: there is a diffusion process $X_t$ with values in $\Omega$ corresponding to $L$, and $u(x)$ is simply the expected value of $f(X_{\tau-})$, where $\tau$ is the life-time of $X$.
Clearly $u$ satisfies the (strong) maximum principle, so it has no local extrema in $\Omega$, unless constant. The question is whether $u$ is continuous at the boundary.
A standard approach in potential theory is to find barriers: superharmonic functions which vanish continuously at the boundary. In our case $$h(x) = \operatorname{dist}(x, \partial \Omega)$$ appears to be a barrier at every boundary point. It clearly vanishes continuously at the boundary, so let us see if it is superharmonic.
Fix $x \in \Omega$ and choose $z \in \partial \Omega$ so that $|x - z| = \operatorname{dist}(x, \partial \Omega)$. Define $v(y) = |y - z|$. Then $h(y) \le v(y)$ for all $y$ and $h(x) = v(x)$, so $L h(x) \le L v(x)$. However, $L v(x) \le 0$ if $p > n/2 - 1$ (if I am not mistaken; in any case, for $p$ large enough), as desired.

Now why this is not a complete solution:


*

*The coefficient $a(x)$ is singular near the boundary, so one needs to be careful when showing the existence of the harmonic measure (the `solution' of the Dirichlet problem).

*The coefficient $a(x)$ is not smooth, so extra care is needed when showing that $h$ is a barrier.


Perhaps some day I will find time to fill in these gaps, maybe someone else does that, or perhaps someone will come up with a simpler solution.
A: To precise better: under no extra assumption on K, I would need just a continuous monotonic g, no need for extra regularity.
