  In 2000, Cohn, Kenyon and Propp studied uniformly random perfect matchings of
large induced subgraphs of $\mathbb Z^2$ (a.k.a. dimer configurations or domino
tilings) and developed a large deviation theory for the associated height
functions. We establish similar results for large induced subgraphs of $\mathbb
Z^3$. To formulate these results, recall that a perfect matching on a bipartite
graph induces a flow that sends one unit of current from each even vertex to
its odd partner. One can then subtract a "reference flow'' to obtain a
divergence-free flow.
  We show that the flow induced by a uniformly random dimer configuration
converges in law (when boundary conditions on a bounded $R \subset \mathbb R^3$
are controlled and the mesh size tends to zero) to the deterministic
divergence-free flow $g$ on $R$ that maximizes
  $$\int_{R} \text{ent}(g(x)) \,dx$$ given the boundary data, where
$\text{ent}(s)$ is the maximal specific entropy obtained by an ergodic Gibbs
measure with mean current $s$. The function $\text{ent}$ is not known
explicitly, but we prove that it is continuous and {\em strictly concave} on
the octahedron $\mathcal O$ of possible mean currents (except on the edges of
$\mathcal O$) which implies (under reasonable boundary conditions) that the
maximizer is uniquely determined. We further establish two versions of a large
deviation principle, using the integral above to quantify how exponentially
unlikely the discrete random flows are to approximate other deterministic
flows.
  The planar dimer model is mathematically rich and well-studied, but many of
the most powerful tools do not seem readily adaptable to higher dimensions. Our
analysis begins with a smaller set of tools, which include Hall's matching
theorem, the ergodic theorem, non-intersecting-lattice-path formulations, and
double-dimer cycle swaps.
