J. Applying the functional

Let us see how the Bubnov–Galerkin functional from Appendix I works in practice: we go through a one-dimensional example from start to finish — from the test functions to the system of linear equations in matrix form.

We solve the heat equation L[u]L[u] =f= f, where the parabolic operator LL =ut= \frac{\partial u}{\partial t} a2Δu- a^2 \Delta u, on the segment [x0,x4][x_0, x_4]. At the ends we impose Neumann boundary conditions (1.14) — the fluxes unx=x0\frac{\partial u}{\partial n}\bigg|_{x=x_0} =g0= g_0 and unx=x4\frac{\partial u}{\partial n}\bigg|_{x=x_4} =g4= g_4 are prescribed. We bring the Bubnov–Galerkin functional to matrix form and substitute these conditions.

A one-dimensional mesh of four simplex segments s₁…s₄ and five nodes
Fig. J.1. The example mesh: four simplex segments s1,,s4s_1, \ldots, s_4 and five nodes x0,,x4x_0, \ldots, x_4; the segment lengths are denoted l(i)(i+1)l_{(i)(i+1)}.

Take four simplex segments s1,s2,s3,s4s_1, s_2, s_3, s_4, three interior points x1,x2,x3x_1, x_2, x_3 and two boundary points x0,x4x_0, x_4 (Figure J.1). The test functions on the simplex segments take the form

υ(0)(1)(x)=q0ϕ0(x)+q1ϕ1(x)υ(1)(2)(x)=q1ϕ1(x)+q2ϕ2(x)υ(2)(3)(x)=q2ϕ2(x)+q3ϕ3(x)υ(3)(4)(x)=q3ϕ3(x)+q4ϕ4(x)\begin{split} &\upsilon_{(0)(1)}(x) = q_0 \cdot \phi_0(x) + q_1 \cdot \phi_1(x) \\ &\upsilon_{(1)(2)}(x) = q_1 \cdot \phi_1(x) + q_2 \cdot \phi_2(x) \\ &\upsilon_{(2)(3)}(x) = q_2 \cdot \phi_2(x) + q_3 \cdot \phi_3(x) \\ &\upsilon_{(3)(4)}(x) = q_3 \cdot \phi_3(x) + q_4 \cdot \phi_4(x) \\ \end{split}

The “hat” functions and their derivatives for the segment simplices are

ϕ0(x)=a0+b0xϕ0(x)=b0ϕ1(x)=a1+b1xϕ1(x)=b1ϕ2(x)=a2+b2xϕ2(x)=b2ϕ3(x)=a3+b3xϕ3(x)=b3ϕ4(x)=a4+b4xϕ4(x)=b4\begin{split} &\phi_0(x) = a_0 + b_0 \cdot x \quad \phi_0'(x) = b_0 \\ &\phi_1(x) = a_1 + b_1 \cdot x \quad \phi_1'(x) = b_1 \\ &\phi_2(x) = a_2 + b_2 \cdot x \quad \phi_2'(x) = b_2 \\ &\phi_3(x) = a_3 + b_3 \cdot x \quad \phi_3'(x) = b_3 \\ &\phi_4(x) = a_4 + b_4 \cdot x \quad \phi_4'(x) = b_4 \\ \end{split}

The coefficients take the following values. Let us introduce the notation l(i)(i+1)l_{(i)(i+1)} =xi+1= x_{i+1} xi- x_i for the length of the simplex between points xix_i and xi+1x_{i+1}.

The hat-function coefficients for an arbitrary simplex between the points xix_i and xi+1x_{i+1} are derived exactly as in the “Test functions” section and equal

ai=xi+1l(i)(i+1)bi=1l(i)(i+1)ai+1=xil(i)(i+1)bi+1=1l(i)(i+1)\begin{split} &a_i = \frac{\displaystyle x_{i+1}}{\displaystyle l_{(i)(i+1)}} \quad b_i = \frac{\displaystyle -1}{\displaystyle l_{(i)(i+1)}} \\ &a_{i+1} = \frac{\displaystyle -x_i}{\displaystyle l_{(i)(i+1)}} \quad b_{i+1} = \frac{\displaystyle 1}{\displaystyle l_{(i)(i+1)}} \end{split}

For the boundary hats ϕ0\phi_0 and ϕ4\phi_4 one takes the corresponding half. Substituting these coefficients, we write the test functions on each simplex directly.

Let us substitute the coefficients into the test functions and express them in terms of xx:

For simplex s1s_1:

υ(0)(1)(x)\displaystyle \upsilon_{(0)(1)}(x) =q0ϕ0(x)\displaystyle = q_0 \cdot \phi_0(x) +q1ϕ1(x)\displaystyle + q_1 \cdot \phi_1(x) =q0(x1l(0)(1)xl(0)(1))\displaystyle = q_0 \cdot \left(\frac{\displaystyle x_1}{\displaystyle l_{(0)(1)}} - \frac{\displaystyle x}{\displaystyle l_{(0)(1)}}\right) +q1(x0l(0)(1)+xl(0)(1))\displaystyle + q_1 \cdot \left(\frac{\displaystyle -x_0}{\displaystyle l_{(0)(1)}} + \frac{\displaystyle x}{\displaystyle l_{(0)(1)}}\right) =1l(0)(1)[q0(x1x)+q1(xx0)]\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(0)(1)}} \left[q_0 \cdot (x_1 - x) + q_1 \cdot (x - x_0)\right]

For simplex s2s_2:

υ(1)(2)(x)\displaystyle \upsilon_{(1)(2)}(x) =q1ϕ1(x)\displaystyle = q_1 \cdot \phi_1(x) +q2ϕ2(x)\displaystyle + q_2 \cdot \phi_2(x) =q1(x2l(1)(2)xl(1)(2))\displaystyle = q_1 \cdot \left(\frac{\displaystyle x_2}{\displaystyle l_{(1)(2)}} - \frac{\displaystyle x}{\displaystyle l_{(1)(2)}}\right) +q2(x1l(1)(2)+xl(1)(2))\displaystyle + q_2 \cdot \left(\frac{\displaystyle -x_1}{\displaystyle l_{(1)(2)}} + \frac{\displaystyle x}{\displaystyle l_{(1)(2)}}\right) =1l(1)(2)[q1(x2x)+q2(xx1)]\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(1)(2)}} \left[q_1 \cdot (x_2 - x) + q_2 \cdot (x - x_1)\right]

For simplex s3s_3:

υ(2)(3)(x)\displaystyle \upsilon_{(2)(3)}(x) =q2ϕ2(x)\displaystyle = q_2 \cdot \phi_2(x) +q3ϕ3(x)\displaystyle + q_3 \cdot \phi_3(x) =q2(x3l(2)(3)xl(2)(3))\displaystyle = q_2 \cdot \left(\frac{\displaystyle x_3}{\displaystyle l_{(2)(3)}} - \frac{\displaystyle x}{\displaystyle l_{(2)(3)}}\right) +q3(x2l(2)(3)+xl(2)(3))\displaystyle + q_3 \cdot \left(\frac{\displaystyle -x_2}{\displaystyle l_{(2)(3)}} + \frac{\displaystyle x}{\displaystyle l_{(2)(3)}}\right) =1l(2)(3)[q2(x3x)+q3(xx2)]\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(2)(3)}} \left[q_2 \cdot (x_3 - x) + q_3 \cdot (x - x_2)\right]

For simplex s4s_4:

υ(3)(4)(x)\displaystyle \upsilon_{(3)(4)}(x) =q3ϕ3(x)\displaystyle = q_3 \cdot \phi_3(x) +q4ϕ4(x)\displaystyle + q_4 \cdot \phi_4(x) =q3(x4l(3)(4)xl(3)(4))\displaystyle = q_3 \cdot \left(\frac{\displaystyle x_4}{\displaystyle l_{(3)(4)}} - \frac{\displaystyle x}{\displaystyle l_{(3)(4)}}\right) +q4(x3l(3)(4)+xl(3)(4))\displaystyle + q_4 \cdot \left(\frac{\displaystyle -x_3}{\displaystyle l_{(3)(4)}} + \frac{\displaystyle x}{\displaystyle l_{(3)(4)}}\right) =1l(3)(4)[q3(x4x)+q4(xx3)]\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(3)(4)}} \left[q_3 \cdot (x_4 - x) + q_4 \cdot (x - x_3)\right]

Let us find the derivatives of the test functions with respect to xx:

For simplex s1s_1:

υ(0)(1)(x)\displaystyle \upsilon'_{(0)(1)}(x) =1l(0)(1)(q1q0)\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(0)(1)}} (q_1 - q_0)

For simplex s2s_2:

υ(1)(2)(x)\displaystyle \upsilon'_{(1)(2)}(x) =1l(1)(2)(q2q1)\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(1)(2)}} (q_2 - q_1)

For simplex s3s_3:

υ(2)(3)(x)\displaystyle \upsilon'_{(2)(3)}(x) =1l(2)(3)(q3q2)\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(2)(3)}} (q_3 - q_2)

For simplex s4s_4:

υ(3)(4)(x)\displaystyle \upsilon'_{(3)(4)}(x) =1l(3)(4)(q4q3)\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(3)(4)}} (q_4 - q_3)

Let us compute the squares of the test functions:

For simplex s1s_1:

υ(0)(1)2(x)\displaystyle \upsilon_{(0)(1)}^2(x) =1l(0)(1)2[q0(x1x)+q1(xx0)]2\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(0)(1)}^2} \left[q_0 \cdot (x_1 - x) + q_1 \cdot (x - x_0)\right]^2 =1l(0)(1)2[q02(x1x)2+2q0q1(x1x)(xx0)+q12(xx0)2]\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(0)(1)}^2} \left[q_0^2(x_1 - x)^2 + 2q_0q_1(x_1 - x)(x - x_0) + q_1^2(x - x_0)^2\right]

For simplex s2s_2:

υ(1)(2)2(x)\displaystyle \upsilon_{(1)(2)}^2(x) =1l(1)(2)2[q1(x2x)+q2(xx1)]2\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(1)(2)}^2} \left[q_1 \cdot (x_2 - x) + q_2 \cdot (x - x_1)\right]^2 =1l(1)(2)2[q12(x2x)2+2q1q2(x2x)(xx1)+q22(xx1)2]\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(1)(2)}^2} \left[q_1^2(x_2 - x)^2 + 2q_1q_2(x_2 - x)(x - x_1) + q_2^2(x - x_1)^2\right]

For simplex s3s_3:

υ(2)(3)2(x)\displaystyle \upsilon_{(2)(3)}^2(x) =1l(2)(3)2[q2(x3x)+q3(xx2)]2\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(2)(3)}^2} \left[q_2 \cdot (x_3 - x) + q_3 \cdot (x - x_2)\right]^2 =1l(2)(3)2[q22(x3x)2+2q2q3(x3x)(xx2)+q32(xx2)2]\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(2)(3)}^2} \left[q_2^2(x_3 - x)^2 + 2q_2q_3(x_3 - x)(x - x_2) + q_3^2(x - x_2)^2\right]

For simplex s4s_4:

υ(3)(4)2(x)\displaystyle \upsilon_{(3)(4)}^2(x) =1l(3)(4)2[q3(x4x)+q4(xx3)]2\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(3)(4)}^2} \left[q_3 \cdot (x_4 - x) + q_4 \cdot (x - x_3)\right]^2 =1l(3)(4)2[q32(x4x)2+2q3q4(x4x)(xx3)+q42(xx3)2]\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(3)(4)}^2} \left[q_3^2(x_4 - x)^2 + 2q_3q_4(x_4 - x)(x - x_3) + q_4^2(x - x_3)^2\right]

Let us compute the squares of the derivatives of the test functions:

For simplex s1s_1:

(υ(0)(1)(x))2\displaystyle \left(\upsilon'_{(0)(1)}(x)\right)^2 =1l(0)(1)2(q1q0)2\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(0)(1)}^2} (q_1 - q_0)^2 =1l(0)(1)2(q022q0q1+q12)\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(0)(1)}^2} \left(q_0^2 - 2q_0q_1 + q_1^2\right)

For simplex s2s_2:

(υ(1)(2)(x))2\displaystyle \left(\upsilon'_{(1)(2)}(x)\right)^2 =1l(1)(2)2(q2q1)2\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(1)(2)}^2} (q_2 - q_1)^2 =1l(1)(2)2(q122q1q2+q22)\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(1)(2)}^2} \left(q_1^2 - 2q_1q_2 + q_2^2\right)

For simplex s3s_3:

(υ(2)(3)(x))2\displaystyle \left(\upsilon'_{(2)(3)}(x)\right)^2 =1l(2)(3)2(q3q2)2\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(2)(3)}^2} (q_3 - q_2)^2 =1l(2)(3)2(q222q2q3+q32)\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(2)(3)}^2} \left(q_2^2 - 2q_2q_3 + q_3^2\right)

For simplex s4s_4:

(υ(3)(4)(x))2\displaystyle \left(\upsilon'_{(3)(4)}(x)\right)^2 =1l(3)(4)2(q4q3)2\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(3)(4)}^2} (q_4 - q_3)^2 =1l(3)(4)2(q322q3q4+q42)\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(3)(4)}^2} \left(q_3^2 - 2q_3q_4 + q_4^2\right)

Let us write the linear approximation of the source function f(x)f(x) on each simplex according to (6.36). In our example the source acts only on the interior simplices: on the outer ones it is identically zero.

For simplex s1s_1 (between x0x_0 and x1x_1):

Since the heat source density function is identically zero on this interval:

f~(0)(1)(x)\displaystyle \widetilde{f}_{(0)(1)}(x) =0.\displaystyle = 0.

For simplex s2s_2 (between x1x_1 and x2x_2):

f~(1)(2)(x)\displaystyle \widetilde{f}_{(1)(2)}(x) =e1(1)(2)\displaystyle = e_1^{(1)(2)} +e2(1)(2)x,\displaystyle + e_2^{(1)(2)} \cdot x,

where:

e1(1)(2)=f1x2f2x1x2x1=f1x2f2x1l(1)(2)e2(1)(2)=f2f1x2x1=f2f1l(1)(2)\begin{split} &e_1^{(1)(2)} = \frac{\displaystyle f_1 \cdot x_2 - f_2 \cdot x_1}{\displaystyle x_2 - x_1} = \frac{\displaystyle f_1 \cdot x_2 - f_2 \cdot x_1}{\displaystyle l_{(1)(2)}} \\ &e_2^{(1)(2)} = \frac{\displaystyle f_2 - f_1}{\displaystyle x_2 - x_1} = \frac{\displaystyle f_2 - f_1}{\displaystyle l_{(1)(2)}} \end{split}

For simplex s3s_3 (between x2x_2 and x3x_3):

f~(2)(3)(x)\displaystyle \widetilde{f}_{(2)(3)}(x) =e1(2)(3)\displaystyle = e_1^{(2)(3)} +e2(2)(3)x,\displaystyle + e_2^{(2)(3)} \cdot x,

where:

e1(2)(3)=f2x3f3x2x3x2=f2x3f3x2l(2)(3)e2(2)(3)=f3f2x3x2=f3f2l(2)(3)\begin{split} &e_1^{(2)(3)} = \frac{\displaystyle f_2 \cdot x_3 - f_3 \cdot x_2}{\displaystyle x_3 - x_2} = \frac{\displaystyle f_2 \cdot x_3 - f_3 \cdot x_2}{\displaystyle l_{(2)(3)}} \\ &e_2^{(2)(3)} = \frac{\displaystyle f_3 - f_2}{\displaystyle x_3 - x_2} = \frac{\displaystyle f_3 - f_2}{\displaystyle l_{(2)(3)}} \end{split}

For simplex s4s_4 (between x3x_3 and x4x_4):

Since the heat source density function is identically zero on this interval:

f~(3)(4)(x)\displaystyle \widetilde{f}_{(3)(4)}(x) =0.\displaystyle = 0.

Now let us write the product of the source function and the corresponding test function for each simplex.

For simplex s1s_1:

Since f~(0)(1)(x)\widetilde{f}_{(0)(1)}(x) =0= 0, we have:

f~(0)(1)(x)υ(0)(1)(x)\displaystyle \widetilde{f}_{(0)(1)}(x) \cdot \upsilon_{(0)(1)}(x) =0.\displaystyle = 0.

For simplex s2s_2:

f~(1)(2)(x)υ(1)(2)(x)\displaystyle \widetilde{f}_{(1)(2)}(x) \cdot \upsilon_{(1)(2)}(x) =(e1(1)(2)+e2(1)(2)x)1l(1)(2)[q1(x2x)+q2(xx1)].\displaystyle = \left(e_1^{(1)(2)} + e_2^{(1)(2)} \cdot x\right) \quad \cdot \frac{\displaystyle 1}{\displaystyle l_{(1)(2)}} \left[q_1 \cdot (x_2 - x) + q_2 \cdot (x - x_1)\right].

Substituting the values of e1(1)(2)e_1^{(1)(2)} and e2(1)(2)e_2^{(1)(2)}:

f~(1)(2)(x)υ(1)(2)(x)\displaystyle \widetilde{f}_{(1)(2)}(x) \cdot \upsilon_{(1)(2)}(x) =1l(1)(2)2[(f1x2f2x1)+(f2f1)x][q1(x2x)+q2(xx1)].\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(1)(2)}^2} \left[(f_1 \cdot x_2 - f_2 \cdot x_1) + (f_2 - f_1) \cdot x\right] \quad \cdot \left[q_1 \cdot (x_2 - x) + q_2 \cdot (x - x_1)\right].

Let us transform the first factor:

(f1x2f2x1)\displaystyle (f_1 \cdot x_2 - f_2 \cdot x_1) +(f2f1)x\displaystyle + (f_2 - f_1) \cdot x =f1(x2x)\displaystyle = f_1 \cdot (x_2 - x) +f2(xx1).\displaystyle + f_2 \cdot (x - x_1).

Therefore:

f~(1)(2)(x)υ(1)(2)(x)\displaystyle \widetilde{f}_{(1)(2)}(x) \cdot \upsilon_{(1)(2)}(x) =1l(1)(2)2[f1(x2x)+f2(xx1)][q1(x2x)+q2(xx1)].\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(1)(2)}^2} \left[f_1 \cdot (x_2 - x) + f_2 \cdot (x - x_1)\right] \quad \cdot \left[q_1 \cdot (x_2 - x) + q_2 \cdot (x - x_1)\right].

Expanding the brackets:

f~(1)(2)(x)υ(1)(2)(x)\displaystyle \widetilde{f}_{(1)(2)}(x) \cdot \upsilon_{(1)(2)}(x) =1l(1)(2)2[f1q1(x2x)2+f1q2(x2x)(xx1)+f2q1(xx1)(x2x)+f2q2(xx1)2].\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(1)(2)}^2} \Big[ f_1 q_1 (x_2 - x)^2 + f_1 q_2 (x_2 - x)(x - x_1) + f_2 q_1 (x - x_1)(x_2 - x) + f_2 q_2 (x - x_1)^2 \Big].

For simplex s3s_3:

f~(2)(3)(x)υ(2)(3)(x)\displaystyle \widetilde{f}_{(2)(3)}(x) \cdot \upsilon_{(2)(3)}(x) =(e1(2)(3)+e2(2)(3)x)1l(2)(3)[q2(x3x)+q3(xx2)].\displaystyle = \left(e_1^{(2)(3)} + e_2^{(2)(3)} \cdot x\right) \quad \cdot \frac{\displaystyle 1}{\displaystyle l_{(2)(3)}} \left[q_2 \cdot (x_3 - x) + q_3 \cdot (x - x_2)\right].

By analogy with simplex s2s_2:

f~(2)(3)(x)υ(2)(3)(x)\displaystyle \widetilde{f}_{(2)(3)}(x) \cdot \upsilon_{(2)(3)}(x) =1l(2)(3)2[f2(x3x)+f3(xx2)][q2(x3x)+q3(xx2)].\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(2)(3)}^2} \left[f_2 \cdot (x_3 - x) + f_3 \cdot (x - x_2)\right] \quad \cdot \left[q_2 \cdot (x_3 - x) + q_3 \cdot (x - x_2)\right].

Expanding the brackets:

f~(2)(3)(x)υ(2)(3)(x)\displaystyle \widetilde{f}_{(2)(3)}(x) \cdot \upsilon_{(2)(3)}(x) =1l(2)(3)2[f2q2(x3x)2+f2q3(x3x)(xx2)+f3q2(xx2)(x3x)+f3q3(xx2)2].\displaystyle = \frac{\displaystyle 1}{\displaystyle l_{(2)(3)}^2} \Big[ f_2 q_2 (x_3 - x)^2 + f_2 q_3 (x_3 - x)(x - x_2) + f_3 q_2 (x - x_2)(x_3 - x) + f_3 q_3 (x - x_2)^2 \Big].

For simplex s4s_4:

Since f~(3)(4)(x)\widetilde{f}_{(3)(4)}(x) =0= 0, we have:

f~(3)(4)(x)υ(3)(4)(x)\displaystyle \widetilde{f}_{(3)(4)}(x) \cdot \upsilon_{(3)(4)}(x) =0.\displaystyle = 0.

Now consider the boundary term. The boundary of the one-dimensional domain consists of two points x0x_0 and x4x_4, so the surface integral reduces to a sum over the boundary nodes:

SυυdS\displaystyle \int_S \upsilon \cdot \nabla \upsilon \,dS =q0unx=x0\displaystyle = q_0 \cdot \frac{\partial u}{\partial n}\bigg|_{x=x_0} +q4unx=x4.\displaystyle + q_4 \cdot \frac{\partial u}{\partial n}\bigg|_{x=x_4}.

Since this example uses Neumann conditions, the normal derivative at the boundary is known: unx=x0\frac{\partial u}{\partial n}\bigg|_{x=x_0} =g0= g_0, unx=x4\frac{\partial u}{\partial n}\bigg|_{x=x_4} =g4= g_4. This term enters only the equations of the boundary nodes and is moved to the right-hand side as a flux vector; it does not enter the system matrix.

The stiffness integral for each simplex is the integral of the squared derivative of the test function. Since these derivatives are constants, integration reduces to multiplication by the simplex length.

By the local formula from the “Stiffness matrix 1D” section, on each simplex this integral equals 1l(i)(i+1)\frac{1}{l_{(i)(i+1)}}.

The total stiffness integral over the whole domain MM is the sum of the integrals over all simplices:

M(υ)2dM=i=14si(υ(x))2dx=1l(0)(1)(q022q0q1+q12)+1l(1)(2)(q122q1q2+q22)+1l(2)(3)(q222q2q3+q32)+1l(3)(4)(q322q3q4+q42).\begin{aligned} \int_M (\nabla \upsilon)^2 \,dM &= \sum_{i=1}^{4} \int_{s_i} \left(\upsilon'(x)\right)^2 \,dx \\ &= \frac{\displaystyle 1}{\displaystyle l_{(0)(1)}} \left(q_0^2 - 2q_0q_1 + q_1^2\right) + \frac{\displaystyle 1}{\displaystyle l_{(1)(2)}} \left(q_1^2 - 2q_1q_2 + q_2^2\right) \\ &\quad + \frac{\displaystyle 1}{\displaystyle l_{(2)(3)}} \left(q_2^2 - 2q_2q_3 + q_3^2\right) + \frac{\displaystyle 1}{\displaystyle l_{(3)(4)}} \left(q_3^2 - 2q_3q_4 + q_4^2\right). \end{aligned}

The damping integral for each simplex is the integral of the squared test function.

By the local formula from the “Damping matrix 1D” section, the integral of the squared test function on a simplex equals l(i)(i+1)3(qi2+qiqi+1+qi+12)\frac{l_{(i)(i+1)}}{3}\left(q_i^2 + q_i q_{i+1} + q_{i+1}^2\right).

The total damping integral over the whole domain MM is the sum of the integrals over all simplices:

Mυ2dM=i=14siυ2(x)dx=l(0)(1)3(q02+q0q1+q12)+l(1)(2)3(q12+q1q2+q22)+l(2)(3)3(q22+q2q3+q32)+l(3)(4)3(q32+q3q4+q42).\begin{aligned} \int_M \upsilon^2 \,dM &= \sum_{i=1}^{4} \int_{s_i} \upsilon^2(x) \,dx \\ &= \frac{\displaystyle l_{(0)(1)}}{\displaystyle 3} \left(q_0^2 + q_0q_1 + q_1^2\right) + \frac{\displaystyle l_{(1)(2)}}{\displaystyle 3} \left(q_1^2 + q_1q_2 + q_2^2\right) \\ &\quad + \frac{\displaystyle l_{(2)(3)}}{\displaystyle 3} \left(q_2^2 + q_2q_3 + q_3^2\right) + \frac{\displaystyle l_{(3)(4)}}{\displaystyle 3} \left(q_3^2 + q_3q_4 + q_4^2\right). \end{aligned}

The load integral for each simplex is the integral of the product of the source function and the test function.

By the local formula from the “Load vector 1D” section, the integral vanishes on the boundary simplices s1s_1 and s4s_4 (the source is identically zero there), while on s2s_2 and s3s_3 it equals the corresponding local load-vector contribution.

The total load integral over the whole domain MM is the sum of the integrals over all simplices:

Mf~(x)υ(x)dM=i=14sif~(x)υ(x)dx=0+l(1)(2)6(2f1q1+f1q2+f2q1+2f2q2)+l(2)(3)6(2f2q2+f2q3+f3q2+2f3q3)+0.\begin{aligned} \int_M \widetilde{f}(x) \cdot \upsilon(x) \,dM &= \sum_{i=1}^{4} \int_{s_i} \widetilde{f}(x) \cdot \upsilon(x) \,dx \\ &= 0 + \frac{\displaystyle l_{(1)(2)}}{\displaystyle 6} \left(2f_1 q_1 + f_1 q_2 + f_2 q_1 + 2f_2 q_2\right) \\ &\quad + \frac{\displaystyle l_{(2)(3)}}{\displaystyle 6} \left(2f_2 q_2 + f_2 q_3 + f_3 q_2 + 2f_3 q_3\right) + 0. \end{aligned}

Simplifying:

Mf~(x)υ(x)dM\displaystyle \int_M \widetilde{f}(x) \cdot \upsilon(x) \,dM =l(1)(2)6(2f1q1+f1q2+f2q1+2f2q2)\displaystyle = \frac{\displaystyle l_{(1)(2)}}{\displaystyle 6} \left(2f_1 q_1 + f_1 q_2 + f_2 q_1 + 2f_2 q_2\right) \quad +l(2)(3)6(2f2q2+f2q3+f3q2+2f3q3).\displaystyle + \frac{\displaystyle l_{(2)(3)}}{\displaystyle 6} \left(2f_2 q_2 + f_2 q_3 + f_3 q_2 + 2f_3 q_3\right).

Let us write all the integrals obtained in matrix form. Introduce the vector of unknowns q\vec{q} =(q0q1q2q3q4)T= \begin{pmatrix} q_0 & q_1 & q_2 & q_3 & q_4 \end{pmatrix}^T.

The stiffness integral can be written in matrix form:

M(υ)2dM\displaystyle \int_M (\nabla \upsilon)^2 \,dM =qTKq,\displaystyle = \vec{q}^T \cdot K \cdot \vec{q},

where KK is the stiffness matrix of size 5×55 \times 5:

K\displaystyle K =(1l(0)(1)1l(0)(1)0001l(0)(1)1l(0)(1)+1l(1)(2)1l(1)(2)0001l(1)(2)1l(1)(2)+1l(2)(3)1l(2)(3)0001l(2)(3)1l(2)(3)+1l(3)(4)1l(3)(4)0001l(3)(4)1l(3)(4)).\displaystyle = \begin{pmatrix} \frac{1}{l_{(0)(1)}} & -\frac{1}{l_{(0)(1)}} & 0 & 0 & 0 \\ -\frac{1}{l_{(0)(1)}} & \frac{1}{l_{(0)(1)}} + \frac{1}{l_{(1)(2)}} & -\frac{1}{l_{(1)(2)}} & 0 & 0 \\ 0 & -\frac{1}{l_{(1)(2)}} & \frac{1}{l_{(1)(2)}} + \frac{1}{l_{(2)(3)}} & -\frac{1}{l_{(2)(3)}} & 0 \\ 0 & 0 & -\frac{1}{l_{(2)(3)}} & \frac{1}{l_{(2)(3)}} + \frac{1}{l_{(3)(4)}} & -\frac{1}{l_{(3)(4)}} \\ 0 & 0 & 0 & -\frac{1}{l_{(3)(4)}} & \frac{1}{l_{(3)(4)}} \end{pmatrix}.
(J.1)

Matrix KK is symmetric and tridiagonal.

The damping integral can be written in matrix form:

Mυ2dM\displaystyle \int_M \upsilon^2 \,dM =qTDq,\displaystyle = \vec{q}^T \cdot D \cdot \vec{q},

where DD is the damping matrix of size 5×55 \times 5:

D\displaystyle D =(l(0)(1)3l(0)(1)6000l(0)(1)6l(0)(1)3+l(1)(2)3l(1)(2)6000l(1)(2)6l(1)(2)3+l(2)(3)3l(2)(3)6000l(2)(3)6l(2)(3)3+l(3)(4)3l(3)(4)6000l(3)(4)6l(3)(4)3).\displaystyle = \begin{pmatrix} \frac{l_{(0)(1)}}{3} & \frac{l_{(0)(1)}}{6} & 0 & 0 & 0 \\ \frac{l_{(0)(1)}}{6} & \frac{l_{(0)(1)}}{3} + \frac{l_{(1)(2)}}{3} & \frac{l_{(1)(2)}}{6} & 0 & 0 \\ 0 & \frac{l_{(1)(2)}}{6} & \frac{l_{(1)(2)}}{3} + \frac{l_{(2)(3)}}{3} & \frac{l_{(2)(3)}}{6} & 0 \\ 0 & 0 & \frac{l_{(2)(3)}}{6} & \frac{l_{(2)(3)}}{3} + \frac{l_{(3)(4)}}{3} & \frac{l_{(3)(4)}}{6} \\ 0 & 0 & 0 & \frac{l_{(3)(4)}}{6} & \frac{l_{(3)(4)}}{3} \end{pmatrix}.

Matrix DD is also symmetric and tridiagonal.

The load integral can be written in matrix form:

Mf~(x)υ(x)dM\displaystyle \int_M \widetilde{f}(x) \cdot \upsilon(x) \,dM =FTq,\displaystyle = \vec{F}^T \cdot \vec{q},

where F\vec{F} is the load vector of size 5×15 \times 1:

F\displaystyle \vec{F} =(02f1l(1)(2)6+f2l(1)(2)6f1l(1)(2)6+2f2l(1)(2)6+2f2l(2)(3)6+f3l(2)(3)6f2l(2)(3)6+2f3l(2)(3)60).\displaystyle = \begin{pmatrix} 0 \\ \frac{2f_1 \cdot l_{(1)(2)}}{6} + \frac{f_2 \cdot l_{(1)(2)}}{6} \\ \frac{f_1 \cdot l_{(1)(2)}}{6} + \frac{2f_2 \cdot l_{(1)(2)}}{6} + \frac{2f_2 \cdot l_{(2)(3)}}{6} + \frac{f_3 \cdot l_{(2)(3)}}{6} \\ \frac{f_2 \cdot l_{(2)(3)}}{6} + \frac{2f_3 \cdot l_{(2)(3)}}{6} \\ 0 \end{pmatrix}.

After simplification:

F\displaystyle \vec{F} =(0l(1)(2)6(2f1+f2)f1l(1)(2)6+f2(l(1)(2)+l(2)(3))3+f3l(2)(3)6l(2)(3)6(f2+2f3)0).\displaystyle = \begin{pmatrix} 0 \\ \frac{l_{(1)(2)}}{6} \left(2f_1 + f_2\right) \\ \frac{f_1 \cdot l_{(1)(2)}}{6} + \frac{f_2 (l_{(1)(2)} + l_{(2)(3)})}{3} + \frac{f_3 \cdot l_{(2)(3)}}{6} \\ \frac{l_{(2)(3)}}{6} \left(f_2 + 2f_3\right) \\ 0 \end{pmatrix}.

The boundary integral, as shown above, does not fold into a matrix — it gives a flux vector on the right-hand side, nonzero only at the boundary nodes:

a2s\displaystyle a^2 \vec{s} =a2(g0000g4).\displaystyle = a^2 \begin{pmatrix} g_0 \\ 0 \\ 0 \\ 0 \\ g_4 \end{pmatrix}.

Stationary equation

By (I.8), the stationary system has the form

a2Kq\displaystyle a^2 K \cdot \vec{q} =F\displaystyle = \vec{F} +a2s.\displaystyle + a^2 \vec{s}.

Non-stationary equation

By (I.9), the nonstationary system:

[D+Δta2K]qn\displaystyle \left[D + \Delta t \cdot a^2 K\right] \cdot \vec{q}_n =ΔtF\displaystyle = \Delta t \cdot \vec{F} +Dqn1\displaystyle + D \cdot \vec{q}_{n-1} +Δta2s.\displaystyle + \Delta t \cdot a^2 \vec{s}.

Notation:

  • KK — the stiffness matrix 5×55 \times 5,
  • DD — the damping matrix 5×55 \times 5,
  • F\vec{F} — the load vector 5×15 \times 1,
  • q\vec{q} — the vector of unknowns 5×15 \times 1 for the stationary case,
  • qn,qn1\vec{q}_n, \vec{q}_{n-1} — the vectors of unknowns on the current and previous time layers,
  • aa — the thermal diffusivity coefficient,
  • Δt\Delta t — the time step.

The matrices KK and DD are symmetric and sparse (tridiagonal). The operator of the stationary system is the full stiffness matrix a2Ka^2 K; for a pure Neumann problem it is singular (K1K\cdot\vec{1} =0=0), so the solution is defined up to an additive constant and is closed by a normalization condition. The treatment of Neumann conditions is detailed in the appendix on Neumann boundary conditions.