I am putting together a little FEM code at the moment. It is just meant to let me play around with some toy problems (e.g. Laplace, etc.) My rather daft question is this: do the formulations for an element's local stiffness and mass matrices change with the problem? By 'problem', I am referring to the governing equation, not to the type of finite element being used.
I (vaguely) recall from undergraduate days assembling the global mass and stiffness matrices for the Laplace problem in 2 dimensions with linear triangular elements. I didn't re-use the function that computed the local matrix for an element in other governing equations (for example, using the same mesh with the heat equation, as my intention is to move up to evolution problems with this code). Is this a reasonable thing to do, or do I need a different local-matrix-maker for each type of problem?
Yes they do. For example, consider the Poisson problem with spatially varying material parameter: Find $u : \Omega \rightarrow \mathbb{R}$ such that $$\begin{aligned} -\nabla\cdot(a(x,y)\nabla u)&=f\quad \text{inside $\Omega$,}\\ u&=0\quad \text{on the boundary $\partial \Omega$.} \end{aligned}$$ for some $f \in L^2(\Omega)$ and where $\Omega$ is the computational domain.
In this case the local stiffness matrix depends on the location of the integration points in the global space through $a(x,y)$.