How to create a custom mesh domain?

A mesh is defined with a finite element because a mesh can consist of non-affine cells (higher order triangles/tets with curved edges, or quad/hex elements). Thus you need a set of basis functions mapping from the reference element to the physical element (to for instance compute jacobians in integrals).

The vector space used in the mesh initialization does not limit what function spaces one can use in variational problems.

A trivial one cell example is recently posted: Computing element-wise spatial derivatives of the solution - #4 by dokken