On patched variational principles with application to elliptic and mixed elliptic-hyperbolic problems