  We present a unified hard-constraint framework for solving geometrically
complex PDEs with neural networks, where the most commonly used Dirichlet,
Neumann, and Robin boundary conditions (BCs) are considered. Specifically, we
first introduce the "extra fields" from the mixed finite element method to
reformulate the PDEs so as to equivalently transform the three types of BCs
into linear equations. Based on the reformulation, we derive the general
solutions of the BCs analytically, which are employed to construct an ansatz
that automatically satisfies the BCs. With such a framework, we can train the
neural networks without adding extra loss terms and thus efficiently handle
geometrically complex PDEs, alleviating the unbalanced competition between the
loss terms corresponding to the BCs and PDEs. We theoretically demonstrate that
the "extra fields" can stabilize the training process. Experimental results on
real-world geometrically complex PDEs showcase the effectiveness of our method
compared with state-of-the-art baselines.
