  For a homotopically energy-minimizing map $u: N^3\to S^1$ on a compact,
oriented $3$-manifold $N$ with boundary, we establish an identity relating the
average Euler characteristic of the level sets $u^{-1}\{\theta\}$ to the scalar
curvature of $N$ and the mean curvature of the boundary $\partial N$. As an
application, we obtain some natural geometric estimates for the Thurston norm
on $3$-manifolds with boundary, generalizing results of Kronheimer-Mrowka and
the second named author from the closed setting. By combining these techniques
with results from minimal surface theory, we obtain moreover a characterization
of the Thurston norm via scalar curvature and the harmonic norm for general
closed, oriented three-manifolds, extending Kronheimer and Mrowka's
characterization for irreducible manifolds to arbitrary topologies.
