# How to generate mesh for space-time FEM method in FEniCS?

suppose that I have a region called $$\Omega$$,suppose that this is a 2D or 3D region, how to generate the corresponding space-time mesh by using FEniCS? and how to extract the boundary and implement integration on boundary?

1. Full space-time FEM (sometimes also referred to as unstructured space-time) I assume that this is also what you are looking for. Here, you mesh the entire space-time domain by interpreting time as just another dimension. This is especially beneficial when you have a spatial domain that moves over time or you use adaptive refinement. The main downside is that you now need to have enough compute capabilities to solve a ($$d+1$$)-dimensional problem, where $$d$$ is the spatial dimension, and more importantly your FEM library needs to be able to work in ($$d+1$$)-dimensions. Especially for $$d=3$$, to the best of my knowledge, ($$d+1$$)-dimensional FEM, i.e. 4D FEM, is so far only implemented in in-house codes of some research groups. I am not aware of FEniCS being able to handle 4D problems natively, but this might change in the future, since e.g. the finite element library MFEM has support for 4D elements as one of their milestones. Nevertheless, if you are fine with just solving problems with $$d = 1$$ or $$d = 2$$ you can easily use FEniCS as shown in this notebook on full space-time FEM.
2. Tensor-product space-time FEM To use existing FEM libraries, you could create the space-time FEM basis as a tensor-product of a spatial ($$d$$-dimensional) and a temporal ($$1$$-dimensional) finite element basis. This then also works for $$d=3$$, but is a bit less flexible with the choice of space-time refinement. For linear problems with constant coefficients, the assembly of the system matrix is particularly easy, since the space-time system is just a linear combination of Kronecker products of temporal and spatial FEM matrices as shown in this notebook. For nonlinear problems, the system matrix is in general not easily seperable into temporal and spatial parts anymore, but one possible assembly for a nonlinear problem is explained in this notebook. Note that the last two examples where only $$1+1$$D but can with minimal effort be extended to $$3+1$$D.