I. The Bubnov–Galerkin functional

Let us write once more the functional for the Euler equation (5.4)

I(υ)\displaystyle I(\upsilon) =(L[υ],υ)\displaystyle {} = (L[\upsilon], \upsilon)​−2⋅(f,υ).\displaystyle {} - 2 \cdot (f, \upsilon).

The linear operator L[υ]L[\upsilon] for the parabolic equation we are interested in has the form

L[υ]\displaystyle L[\upsilon] =∂υ∂t\displaystyle {} = \frac{\displaystyle \partial \upsilon}{\displaystyle \partial t}​−a2⋅Δυ.\displaystyle {} - a^2 \cdot \Delta \upsilon.

The scalar product (L[υ],υ)(L[\upsilon], \upsilon) has the form

(L[υ],υ)\displaystyle (L[\upsilon], \upsilon) =∫M(∂υ∂t−a2⋅Δυ)⋅υ dM\displaystyle {} = \int_M \left( \frac{\displaystyle \partial \upsilon}{\displaystyle \partial t} - a^2 \cdot \Delta \upsilon \right) \cdot \upsilon \,dM​=∫M∂υ∂t⋅υ dM\displaystyle {} = \int_M \frac{\displaystyle \partial \upsilon}{\displaystyle \partial t} \cdot \upsilon \,dM​−a2⋅∫MΔυ⋅υ dM.\displaystyle {} - a^2 \cdot \int_M \Delta \upsilon \cdot \upsilon \,dM.

The scalar product (f,υ)(f, \upsilon) has the form

(f,υ)\displaystyle (f, \upsilon) =∫Mf⋅υ dM.\displaystyle {} = \int_M f \cdot \upsilon \,dM.

The Ostrogradsky formula for the Laplace operator is known

∫MΔυ dM\displaystyle \int_M \Delta \upsilon \,dM =∫S∇υ dS,\displaystyle {} = \int_S \nabla \upsilon \,dS,
(I.1)

where SS is the boundary of the submanifold MM, and dSdS is its vector element directed along the outward normal. Let us integrate the second integral by parts

∫MΔυ⋅υ dM\displaystyle \int_M \Delta \upsilon \cdot \upsilon \,dM =∫Sυ⋅∇υ dS\displaystyle {} = \int_S \upsilon \cdot \nabla \upsilon \,dS​−∫M∇υ⋅∇υ dM.\displaystyle {} - \int_M \nabla \upsilon \cdot \nabla \upsilon \,dM.
(I.2)

Thus, the original functional can be written as

I(υ)\displaystyle I(\upsilon) =∫M∂υ∂t⋅υ dM\displaystyle {} = \int_M \frac{\displaystyle \partial \upsilon}{\displaystyle \partial t} \cdot \upsilon \,dM​−a2⋅∫Sυ⋅∇υ dS\displaystyle {} - a^2 \cdot \int_S \upsilon \cdot \nabla \upsilon \,dS​+a2⋅∫M∇υ⋅∇υ dM\displaystyle {} + a^2 \cdot \int_M \nabla \upsilon \cdot \nabla \upsilon \,dM​−2⋅∫Mf⋅υ dM.\displaystyle {} - 2 \cdot \int_M f \cdot \upsilon \,dM.

Let us give the increment υ^\widehat{\upsilon}​+ϵ⋅υ{} + \epsilon \cdot \upsilon, where υ^\widehat{\upsilon} is the exact solution, and ϵ\epsilon is some small number. The full increment of the functional can be written as

I(υ^+ϵ⋅υ)\displaystyle I(\widehat{\upsilon} + \epsilon \cdot \upsilon)​−I(υ^)\displaystyle {} - I(\widehat{\upsilon})​=∫M∂(υ^+ϵ⋅υ)∂t\displaystyle {} = \int_M \frac{\displaystyle \partial (\widehat{\upsilon} + \epsilon \cdot \upsilon)}{\displaystyle \partial t}​⋅(υ^+ϵ⋅υ) dM\displaystyle {} \cdot (\widehat{\upsilon} + \epsilon \cdot \upsilon) \,dM​−a2\displaystyle {} - a^2​⋅∫S(υ^+ϵ⋅υ)\displaystyle {} \cdot \int_S (\widehat{\upsilon} + \epsilon \cdot \upsilon)​⋅∇(υ^+ϵ⋅υ) dS\displaystyle {} \cdot \nabla (\widehat{\upsilon} + \epsilon \cdot \upsilon) \,dS​+a2\displaystyle {} + a^2​⋅∫M∇(υ^+ϵ⋅υ)\displaystyle {} \cdot \int_M \nabla (\widehat{\upsilon} + \epsilon \cdot \upsilon)​⋅∇(υ^+ϵ⋅υ) dM\displaystyle {} \cdot \nabla (\widehat{\upsilon} + \epsilon \cdot \upsilon) \,dM​−2⋅∫Mf⋅(υ^+ϵ⋅υ) dM\displaystyle {} - 2 \cdot \int_M f \cdot (\widehat{\upsilon} + \epsilon \cdot \upsilon) \,dM​−∫M∂υ^∂t⋅υ^ dM\displaystyle {} - \int_M \frac{\displaystyle \partial \widehat{\upsilon}}{\displaystyle \partial t} \cdot \widehat{\upsilon} \,dM​+a2⋅∫Sυ^⋅∇υ^ dS\displaystyle {} + a^2 \cdot \int_S \widehat{\upsilon} \cdot \nabla \widehat{\upsilon} \,dS​−a2⋅∫M∇υ^⋅∇υ^ dM\displaystyle {} - a^2 \cdot \int_M \nabla \widehat{\upsilon} \cdot \nabla \widehat{\upsilon} \,dM​+2⋅∫Mf⋅υ^ dM.\displaystyle {} + 2 \cdot \int_M f \cdot \widehat{\upsilon} \,dM.

Neglecting the second-order terms proportional to ϵ2\epsilon^2, we obtain

I(υ^+ϵ⋅υ)\displaystyle I(\widehat{\upsilon} + \epsilon \cdot \upsilon)​−I(υ^)\displaystyle {} - I(\widehat{\upsilon})​=ϵ\displaystyle {} = \epsilon​⋅∫M[∂υ^∂t⋅υ+∂υ∂t⋅υ^] dM\displaystyle {} \cdot \int_M \left[ \frac{\displaystyle \partial \widehat{\upsilon}}{\displaystyle \partial t} \cdot \upsilon + \frac{\displaystyle \partial \upsilon}{\displaystyle \partial t} \cdot \widehat{\upsilon} \right] \,dM​−ϵ\displaystyle {} - \epsilon​⋅a2\displaystyle {} \cdot a^2​⋅∫S[υ^⋅∇υ+υ⋅∇υ^] dS\displaystyle {} \cdot \int_S \left[ \widehat{\upsilon} \cdot \nabla \upsilon + \upsilon \cdot \nabla \widehat{\upsilon} \right] \,dS​+2⋅ϵ⋅a2⋅∫M∇υ^⋅∇υ dM\displaystyle {} + 2 \cdot \epsilon \cdot a^2 \cdot \int_M \nabla \widehat{\upsilon} \cdot \nabla \upsilon \,dM​−2⋅ϵ⋅∫Mf⋅υ dM.\displaystyle {} - 2 \cdot \epsilon \cdot \int_M f \cdot \upsilon \,dM.

If we take ϵ\epsilon out of the brackets and take into account that ϵ\epsilon can be negative, while the increment of the functional is always positive, since υ^\widehat{\upsilon} is the exact solution, we obtain as a mandatory condition

∫M[∂υ^∂t⋅υ+∂υ∂t⋅υ^] dM\displaystyle \int_M \left[ \frac{\displaystyle \partial \widehat{\upsilon}}{\displaystyle \partial t} \cdot \upsilon + \frac{\displaystyle \partial \upsilon}{\displaystyle \partial t} \cdot \widehat{\upsilon} \right] \,dM​−a2⋅∫S[υ^⋅∇υ+υ⋅∇υ^] dS\displaystyle {} - a^2 \cdot \int_S \left[ \widehat{\upsilon} \cdot \nabla \upsilon + \upsilon \cdot \nabla \widehat{\upsilon} \right] \,dS​+2⋅a2⋅∫M∇υ^⋅∇υ dM\displaystyle {} + 2 \cdot a^2 \cdot \int_M \nabla \widehat{\upsilon} \cdot \nabla \upsilon \,dM​−2⋅∫Mf⋅υ dM\displaystyle {} - 2 \cdot \int_M f \cdot \upsilon \,dM​=0.\displaystyle {} = 0.

Taking into account that υ^\widehat{\upsilon}​≈υ{} \approx \upsilon, and cancelling the common factor, we return to the original equation. This means that the numerical solution of the boundary value problem reduces to the minimization of the functional

I(υ)\displaystyle I(\upsilon) =∫M∂υ∂t⋅υ dM\displaystyle {} = \int_M \frac{\displaystyle \partial \upsilon}{\displaystyle \partial t} \cdot \upsilon \,dM​−a2⋅∫Sυ⋅∇υ dS\displaystyle {} - a^2 \cdot \int_S \upsilon \cdot \nabla \upsilon \,dS​+a2⋅∫M∇υ⋅∇υ dM\displaystyle {} + a^2 \cdot \int_M \nabla \upsilon \cdot \nabla \upsilon \,dM​−2⋅∫Mf⋅υ dM\displaystyle {} - 2 \cdot \int_M f \cdot \upsilon \,dM​→min⁡.\displaystyle {} \rightarrow \min.
(I.3)

The factor 22 in front of the linear term ∫Mf⋅υdM\int_M f \cdot \upsilon dM is kept deliberately: it is precisely what ensures that the minimum condition δI\delta I​=0{} = 0 returns the original equation rather than an equation with an extra factor of 1/21/2 (when differentiating, the quadratic terms produce a factor of 22, and the linear term must have the same one).

Let us proceed to the separation into stationary and nonstationary problems. It is fundamentally important to perform this separation and the subsequent time discretization at the level of the equation, not of the functional: the time derivative is not a self-adjoint operator, so direct substitution of υ\upsilon​=ψ(M)⋅ϕ(t){} = \psi(M) \cdot \phi(t) into the functional would lead to incorrect coefficients. Let us write the weak form of the equation L[u]L[u]​=f{} = f, obtained above by integration by parts

∫M∂u∂t⋅υ dM\displaystyle \int_M \frac{\displaystyle \partial u}{\displaystyle \partial t} \cdot \upsilon \,dM​+a2⋅∫M∇u⋅∇υ dM\displaystyle {} + a^2 \cdot \int_M \nabla u \cdot \nabla \upsilon \,dM​−a2⋅∫Sυ⋅∇u dS\displaystyle {} - a^2 \cdot \int_S \upsilon \cdot \nabla u \,dS​=∫Mf⋅υ dM,\displaystyle {} = \int_M f \cdot \upsilon \,dM,
(I.4)

which must hold for an arbitrary trial function υ\upsilon.

The stationary equation with Dirichlet and/or Neumann boundary conditions

If ∂u∂t\frac{\displaystyle \partial u}{\displaystyle \partial t}​=0{} = 0, the time term disappears, and due to the symmetry of the spatial operator the weak form (I.4) is equivalent to the minimization of the functional

a2⋅∫M∇υ⋅∇υ dM\displaystyle a^2 \cdot \int_M \nabla \upsilon \cdot \nabla \upsilon \,dM​−2⋅∫Mf⋅υ dM\displaystyle {} - 2 \cdot \int_M f \cdot \upsilon \,dM​−a2⋅∫Sυ⋅∇υ dS\displaystyle {} - a^2 \cdot \int_S \upsilon \cdot \nabla \upsilon \,dS​→min⁡.\displaystyle {} \rightarrow \min.
(I.5)

The nonstationary equation with Dirichlet and/or Neumann boundary conditions

We discretize the time derivative by the implicit Euler scheme with step Δt\Delta t, applying it to the weak form of the equation: ∂u∂t\frac{\displaystyle \partial u}{\displaystyle \partial t}​≈un−un−1Δt{} \approx \frac{\displaystyle u_n - u_{n-1}}{\displaystyle \Delta t}, where unu_n is the solution on the current time layer, and un−1u_{n-1} on the previous one. Substituting this into (I.4) and multiplying by Δt\Delta t, we obtain the equation for the time step

∫M(un−un−1)⋅υ dM\displaystyle \int_M (u_n - u_{n-1}) \cdot \upsilon \,dM​+Δt⋅a2⋅∫M∇un⋅∇υ dM\displaystyle {} + \Delta t \cdot a^2 \cdot \int_M \nabla u_n \cdot \nabla \upsilon \,dM​−Δt⋅a2⋅∫Sυ⋅∇un dS\displaystyle {} - \Delta t \cdot a^2 \cdot \int_S \upsilon \cdot \nabla u_n \,dS​=Δt⋅∫Mf⋅υ dM.\displaystyle {} = \Delta t \cdot \int_M f \cdot \upsilon \,dM.

This equation, in turn, is the minimum condition of the functional

∫Mυn2 dM\displaystyle \int_M \upsilon_n^2 \,dM​+Δt⋅a2⋅∫M∇υn⋅∇υn dM\displaystyle {} + \Delta t \cdot a^2 \cdot \int_M \nabla \upsilon_n \cdot \nabla \upsilon_n \,dM​−2⋅∫M[Δt⋅f+υn−1]⋅υn dM\displaystyle {} - 2 \cdot \int_M \left[ \Delta t \cdot f + \upsilon_{n-1} \right] \cdot \upsilon_n \,dM​−Δt⋅a2⋅∫Sυn⋅∇υn dS\displaystyle {} - \Delta t \cdot a^2 \cdot \int_S \upsilon_n \cdot \nabla \upsilon_n \,dS​→min⁡.\displaystyle {} \rightarrow \min.
(I.6)

Thus, the nonstationary equation has been reduced to successively solving stationary problems: at each step, from the known υn−1\upsilon_{n-1} is found υn\upsilon_n.

Matrix form

We discretize the trial function over the mesh nodes: υ\upsilon​=∑iqi⋅ϕi(M){} = \sum_i q_i \cdot \phi_i(M), where ϕi(M)\phi_i(M) are the basis functions, and q→\overrightarrow{q}​=(q0,…,qn)T{} = (q_0, \ldots, q_n)^T is the vector of nodal values. The substitution turns each integral of the functional into a quadratic or linear form in q→\overrightarrow{q}, and their coefficients are assembled into matrices:

∫M∇υ⋅∇υ dM\displaystyle \int_M \nabla \upsilon \cdot \nabla \upsilon \,dM =q→T⋅K⋅q→,\displaystyle {} = \overrightarrow{q}^T \cdot K \cdot \overrightarrow{q},∫Mυ⋅υ dM\displaystyle \int_M \upsilon \cdot \upsilon \,dM =q→T⋅D⋅q→,\displaystyle {} = \overrightarrow{q}^T \cdot D \cdot \overrightarrow{q},∫Mf⋅υ dM\displaystyle \int_M f \cdot \upsilon \,dM =F→T⋅q→\displaystyle {} = \overrightarrow{F}^T \cdot \overrightarrow{q}
(I.7)

where KK is the stiffness matrix (the integral of the product of the gradients), DD is the damping matrix (the integral of the product of the trial functions), F→\overrightarrow{F} is the load vector (the integral of the source); the matrices KK and DD are symmetric. The boundary integral −a2∫Sυ⋅∇υ dS{} -a^2 \int_S \upsilon \cdot \nabla \upsilon \,dS does not collapse into a matrix: it is a surface term that, in discrete form, enters only the equations of the boundary nodes (for an interior node the trial function vanishes on the boundary) and is determined by the boundary condition itself.

The discrete system is obtained by the Bubnov–Galerkin method: we substitute υ\upsilon​=∑iqiϕi{} = \sum_i q_i \phi_i into the weak form (I.4) and successively take the trial functions ϕj\phi_j. For the stationary equation this gives the system

a2K⋅q→\displaystyle a^2 K \cdot \overrightarrow{q} =F→\displaystyle {} = \overrightarrow{F}​+a2s→,\displaystyle {} + a^2 \overrightarrow{s},
(I.8)

where s→\overrightarrow{s} is the vector of nodal boundary fluxes. The flux itself is not specified here — what to do with it is determined by the type of boundary condition. Accounting for boundary conditions is a nontrivial task, and it is discussed in detail in separate appendices: “Accounting for Dirichlet boundary conditions” and “Accounting for Neumann boundary conditions”.

For the nonstationary equation (implicit Euler scheme, see (I.6)) the system at the time step takes the form

[D+Δt⋅a2K]⋅q→n\displaystyle \left[ D + \Delta t \cdot a^2 K \right] \cdot \overrightarrow{q}_n =Δt⋅F→\displaystyle {} = \Delta t \cdot \overrightarrow{F}​+D⋅q→n−1\displaystyle {} + D \cdot \overrightarrow{q}_{n-1}​+Δt⋅a2s→.\displaystyle {} + \Delta t \cdot a^2 \overrightarrow{s}.
(I.9)