Solution (source code)

= Solution

For a sufficiently smooth <vector field> on an oriented piecewise-smooth <surface> $S$ with boundary $\partial S$, <Stokes theorem> states
$$
\oint_{\partial S}\mathbf F\cdot d\mathbf r=\iint_S(\nabla\times\mathbf F)\cdot\mathbf n\,dS.
$$
Here $\mathbf n$ is the chosen <unit normal>, $dS$ is the scalar surface-area element, and $d\mathbf r$ follows the positively oriented boundary. The <boundary orientation> is fixed by the right-hand rule: the fingers curl along $\partial S$ when the thumb points along $\mathbf n$.