-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathadv_diff1D.tex
More file actions
366 lines (332 loc) · 11.6 KB
/
adv_diff1D.tex
File metadata and controls
366 lines (332 loc) · 11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
\index{general}{Advection-Diffusion Equation}
\begin{flushright} {\tiny {\color{gray} adv\_diff1D.tex}} \end{flushright}
We start with the 1D advection-diffusion equation
\begin{equation}
\rho C_p \left( \frac{\partial T}{\partial t}
+ u \frac{\partial T}{\partial x}
\right)
= \frac{\partial }{\partial x} \left( k \frac{\partial T}{\partial x} \right)
+H
\end{equation}
This is the {\color{olive}strong form} of the ODE to solve.
As in the previous section, I multiply this equation by a function $f(x)$ and integrate it over
the domain $\Omega$:
\[
\int_{\Omega} f(x) \rho C_p\frac{\partial T}{\partial t} dx
+
\int_{\Omega} f(x) \rho C_p u \frac{\partial T}{\partial x} dx
\!=\!
\int_{\Omega} f(x) \frac{\partial }{\partial x}\! \left(\! k\! \frac{\partial T}{\partial x}\! \right)\! dx
+
\int_{\Omega} f(x) H dx
\]
As in the previous section I integrate the r.h.s. by parts:
\[
\int_{\Omega} f(x) \frac{\partial }{\partial x} \left( k \frac{\partial T}{\partial x} \right) dx
=
\left[
f(x) k \frac{\partial T}{\partial x}
\right]_{\partial \Omega}
-
\int_{\Omega} \frac{\partial f}{\partial x} k \frac{\partial T}{\partial x} dx
\]
Disregarding the boundary term for now,
we then obtain the {\color{olive}weak form} of the diffusion equation in 1D:
\[
\boxed{
\int_{\Omega} f(x) \rho C_p \frac{\partial T}{\partial t} dx
+
\int_{\Omega} f(x) \rho C_p u \frac{\partial T}{\partial x} dx
+
\int_{\Omega} \frac{\partial f}{\partial x} k \frac{\partial T}{\partial x} dx =
\int_{\Omega} f(x) H dx
}
\]
We then use the additive property of the integral $\int_\Omega \dots = \sum_{elts} \int_{\Omega_e} \dots$
\[
\sum_{elts} \left(
\underbrace{ \int_{\Omega_e} f(x) \rho C_p \frac{\partial T}{\partial t} dx }_{{\Lambda}_f^e}
+
\underbrace{ \int_{\Omega_e} f(x) \rho C_p u \frac{\partial T}{\partial x} dx }_{{\Sigma}_f^e}
+
\underbrace{\int_{\Omega_e} \frac{\partial f}{\partial x} k \frac{\partial T}{\partial x} dx}_{{\Upsilon}_f^e}
-
\underbrace{\int_{\Omega_e} f(x) H dx }_{{\Omega}_f^e}
\right) = 0
\]
\todo[inline]{replace omega by other letter for source term}
In the element, we have seen that the temperature can be written:
\[
T^h(x)
= {\color{violet}N}^\theta_{k}(x) T_k + {\color{violet}N}^\theta_{k+1}(x) T_{k+1}
\]
In the previous presentation we have computed ${\Lambda}_f^e$ and ${\Upsilon}_f^e$.
Let us now turn to ${\Sigma}_f^e$ and ${\Omega}_f^e$.
\begin{eqnarray}
{\Sigma}_f^e
&=&\int_{x_k}^{x_{k+1}} f(x) \rho C_p u\frac{\partial T^h}{\partial x} dx \nn\\
&=&\int_{x_k}^{x_{k+1}} f(x) \rho C_p u\frac{\partial
[ {\color{violet}N}_{k}^\theta(x) {T}_k + {\color{violet}N}_{k+1}^\theta(x) {T}_{k+1} ] }{\partial x} dx \nn\\
&=&\int_{x_k}^{x_{k+1}} f(x) \rho C_p u\frac{\partial {\color{violet}N}_{k}^\theta }{\partial x} T_k dx
+ \int_{x_k}^{x_{k+1}} f(x) \rho C_p u\frac{\partial {\color{violet}N}_{k+1}^\theta }{\partial x} T_{k+1} dx \nn\\
&=& \left( \int_{x_k}^{x_{k+1}} f(x) \rho C_p u\frac{\partial {\color{violet}N}_{k}^\theta }{\partial x} dx \right) T_k
+ \left( \int_{x_k}^{x_{k+1}} f(x) \rho C_p u\frac{\partial {\color{violet}N}_{k+1}^\theta }{\partial x} dx \right)T_{k+1} \nn
%&=& \int_{x_k}^{x_{k+1}} {\color{blue}f}(x) \rho C_p \;\; [ {\color{blue}N}_{k}(x) \dot{T}_k + {\color{blue}N}_{k+1}(x) \dot{T}_{k+1} ] \;\; dx \nn\\
%&=& \int_{x_k}^{x_{k+1}} {\color{blue}f}(x) \rho C_p {\color{blue}N}_{k}(x) \dot{T}_k dx + \int_{x_k}^{x_{k+1}} {\color{blue}f}(x) \rho C_p {\color{blue}N}_{k+1}(x) \dot{T}_{k+1} dx \nn\\
%&=& \left( \int_{x_k}^{x_{k+1}} {\color{blue}f}(x) \rho C_p {\color{blue}N}_{k}(x) dx \right) \dot{T}_k
%+ \left( \int_{x_k}^{x_{k+1}} {\color{blue}f}(x) \rho C_p {\color{blue}N}_{k+1}(x) dx \right) \dot{T}_{k+1} \nn
\end{eqnarray}
Taking ${\color{violet}f}(x)={\color{violet}N}_k^\theta(x)$ and omitting '$(x)$' in the rhs:
\[
{\Sigma}_{N_k^\theta}^e=
\left( \int_{x_k}^{x_{k+1}} \rho C_p u {\color{violet}N}_k^\theta \frac{\partial {\color{violet}N}_{k}^\theta }{\partial x} dx \right) T_k
+
\left( \int_{x_k}^{x_{k+1}} \rho C_p u {\color{violet}N}_k^\theta \frac{\partial {\color{violet}N}_{k+1}^\theta }{\partial x} dx \right)T_{k+1} \nn
\]
Taking ${\color{violet}f}(x)={\color{violet}N}_{k+1}^\theta(x)$ and omitting '$(x)$' in the rhs:
\[
{\Sigma}_{N_{k+1}^\theta}^e=
\left( \int_{x_k}^{x_{k+1}} \rho C_p u {\color{violet}N}_{k+1}^\theta \frac{\partial {\color{violet}N}_{k}^\theta }{\partial x} dx \right) T_k +
\left( \int_{x_k}^{x_{k+1}} \rho C_p u {\color{violet}N}_{k+1}^\theta \frac{\partial {\color{violet}N}_{k+1}^\theta }{\partial x} dx \right)T_{k+1} \nn
\]
\[
\left(
\begin{array}{c}
{\Sigma}_{N_k^\theta} \\ \\ {\Sigma}_{N_{k+1}^\theta}
\end{array}
\right)
\!=\!
\left(
\begin{array}{cc}
\int_{x_k}^{x_{k+1}} \rho C_p u {\color{violet}N}_k^\theta \frac{\partial {\color{violet}N}_{k}^\theta }{\partial x} dx &
\int_{x_k}^{x_{k+1}} \rho C_p u {\color{violet}N}_k^\theta \frac{\partial {\color{violet}N}_{k+1}^\theta }{\partial x} dx \\ \\
\int_{x_k}^{x_{k+1}} \rho C_p u {\color{violet}N}_{k+1}^\theta \frac{\partial {\color{violet}N}_{k}^\theta }{\partial x} dx &
\int_{x_k}^{x_{k+1}} \rho C_p u {\color{violet}N}_{k+1}^\theta \frac{\partial {\color{violet}N}_{k+1}^\theta }{\partial x} dx
\end{array}
\right)
\!\cdot\!
\left(
\begin{array}{c}
{T}_k \\ \\
{T}_{k+1}
\end{array}
\right)
\]
or,
\[
\left(
\begin{array}{c}
{\Sigma}_{N_k^\theta} \\ \\ {\Sigma}_{N_{k+1}^\theta}
\end{array}
\right)
\!=\!
\left[
\int_{x_k}^{x_{k+1}}
\rho C_p u
\left(
\begin{array}{cc}
{\color{violet}N}_k^\theta \frac{\partial {\color{violet}N}_{k}^\theta }{\partial x} &
{\color{violet}N}_k^\theta \frac{\partial {\color{violet}N}_{k+1}^\theta }{\partial x} \\ \\
{\color{violet}N}_{k+1}^\theta \frac{\partial {\color{violet}N}_{k}^\theta }{\partial x} &
{\color{violet}N}_{k+1}^\theta \frac{\partial {\color{violet}N}_{k+1}^\theta }{\partial x}
\end{array}
\right)
dx
\right]
\cdot
\left(
\begin{array}{c}
{T}_k \\ \\
{T}_{k+1}
\end{array}
\right)
\]
Finally, we have already defined the vectors
\[
{\vec N}^T =
\left(
\begin{array}{c}
{\color{violet}N}_k^\theta(x) \\ \\ {\color{violet}N}_{k+1}^\theta (x)
\end{array}
\right)
\quad\quad
{\vec B}^T=
\left(
\begin{array}{cc}
\frac{\partial {\color{violet}N}_k^\theta}{\partial x} \\ \\
\frac{\partial {\color{violet}N}_{k+1}^\theta}{\partial x}
\end{array}
\right)
\quad
\quad
{\vec T}^e =
\left(
\begin{array}{c}
T_k \\ \\ T_{k+1}
\end{array}
\right)
\]
so that
\[
\left(
\begin{array}{c}
{\Sigma}_{N_k^\theta} \\ \\ {\Sigma}_{N_{k+1}^\theta}
\end{array}
\right)
=
\left( \int_{x_k}^{x_{k+1}} {\vec {\color{violet}N}}^T \rho C_p u {\vec {\color{violet}B}} dx \right) \cdot {\vec T}^e
= {\bm K}_a \cdot \vec T^e
\]
One can easily show that
\[
{\bm K}_a^e=
\rho C_p u
\left(
\begin{array}{cc}
-1/2 & 1/2 \\ \\
-1/2 & 1/2
\end{array}
\right)
\]
Note that the matrix ${\bm K}_a^e$ is {\sl not} symmetric.
Let us now look at the source term:
\begin{eqnarray}
{\Omega}_f^e &=&
\int_{x_k}^{x^{k+1}} f(x) H(x) dx \nn
\end{eqnarray}
Taking ${\color{violet}f}(x)={\color{violet}N}_k^\theta(x)$:
\[
{\Omega}_{N_k^\theta}=
\int_{x_k}^{x^{k+1}} {\color{violet}N}_k^\theta(x) H(x) dx \nn
\]
Taking ${\color{violet}f}(x)={\color{violet}N}_{k+1}^\theta(x)$:
\[
{\Omega}_{N_{k+1}^\theta}=
\int_{x_k}^{x^{k+1}} {\color{violet}N}_{k+1}^\theta(x) H(x) dx \nn
\]
We can rearrange both equations as follows:
\[
\left(
\begin{array}{cc}
{\Omega}_{N_k^\theta} \\ \\ {\Omega}_{N_{k+1}^\theta}
\end{array}
\right)
=
\left(
\begin{array}{cc}
\int_{x_k}^{x^{k+1}} {\color{violet}N}_k^\theta(x) H(x) dx \nn \\ \\
\int_{x_k}^{x^{k+1}} {\color{violet}N}_{k+1}^\theta(x) H(x) dx \nn
\end{array}
\right)
\]
or,
\[
\left(
\begin{array}{cc}
{\Omega}_{N_k^\theta} \\ \\ {\Omega}_{N_{k+1}^\theta}
\end{array}
\right)
=
\int_{x_k}^{x^{k+1}}
\left(
\begin{array}{cc}
{\color{violet}N}_k^\theta(x) H(x) \nn \\ \\
{\color{violet}N}_{k+1}^\theta(x) H(x) \nn
\end{array}
\right)
dx
=
\left(
\int_{x_k}^{x^{k+1}}
{\vec {\color{violet}N}}^T H(x) dx
\right)
\]
The weak form discretised over 1 element becomes
\begin{eqnarray}
&&\underbrace{\left( \int_{x_k}^{x_{k+1}} {\vec {\color{violet}N}}^T \rho C_p {\vec {\color{violet}N}} dx \right) }_{\bm M^e} \cdot \dot{\vec T}^e
+
\underbrace{\left( \int_{x_k}^{x_{k+1}} {\vec {\color{violet}N}}^T \rho C_p u {\vec {\color{violet}B}} dx \right)}_{{\bm K}_a^e} \cdot {\vec T}^e
+
\underbrace{\left( \int_{x_k}^{x_{k+1}} {\vec {\color{violet}B}}^T k {\vec {\color{violet}B}} dx \right)}_{{\bm K}_d^e} \cdot {\vec T}^e
=
\underbrace{\left( \int_{x_k}^{x_{k+1}} {\vec {\color{violet}N}}^T H(x) dx \right)}_{{\vec F}^e} \nn
\end{eqnarray}
or,
\[
\boxed{
{\bm M}^e \cdot \dot{\vec T}^e + ({\bm K}_d^e + {\bm K}_a^e)\cdot {\vec T}^e = {\vec F}^e
}
\]
or,
\[
\boxed{
{\bm M}^e \cdot \frac{\partial {\vec T}^e}{\partial t} + ({\bm K}_a^e + {\bm K}_d^e) \cdot {\vec T}^e = {\vec F}^e
}
\]
As in the diffusion case of the previous section these matrices and vectors will need to be
assembled into ${\bm M}$, ${\bm K}_a$, ${\bm K}_d$, $\vec{T}$ and $\vec{F}$:
\[
{\bm M} \cdot \frac{\partial {\vec T}}{\partial t} + ({\bm K}_a + {\bm K}_d) \cdot {\vec T} = {\vec F}
\]
We can revisit the time discretisation again, assuming for simplicity that the coefficients of the PDE are not time-dependent.
Choosing a fully explicit approach would have us write
\begin{equation}
{\bm M} \cdot \frac{{\vec T}^{n+1}-{\vec T}^n}{\delta t} + ({\bm K}_a + {\bm K}_d) \cdot {\vec T}^{n} = {\vec F}
\quad
\Rightarrow
\quad
{\bm M} \cdot {\vec T}^{n+1} = [{\bm M} - ({\bm K}_a + {\bm K}_d) \delta t] \cdot {\vec T}^{n} = {\vec F}
\end{equation}
while choosing a fully implicit approach would have us write
\begin{equation}
{\bm M} \cdot \frac{{\vec T}^{n+1}-{\vec T}^n}{\delta t} + ({\bm K}_a + {\bm K}_d) \cdot {\vec T}^{n+1} = {\vec F}
\quad
\Rightarrow
\quad
[{\bm M} + ({\bm K}_a + {\bm K}_d) \delta t] \cdot {\vec T}^{n+1}
={\bm M}\cdot {\vec T}^n+ {\vec F} \delta t
\end{equation}
We can also consider a more generic approach and write:
\begin{equation}
{\bm M} \cdot \frac{{\vec T}^{n+1}-{\vec T}^n}{\delta t} + ({\bm K}_a + {\bm K}_d) \cdot (\alpha {\vec T}^{n+1}+(1-\alpha)\vec{T}^{n}) = {\vec F}
\end{equation}
\begin{equation}
[{\bm M} + \alpha({\bm K}_a + {\bm K}_d) \delta t] \cdot {\vec T}^{n+1}
=
[{\bm M} - (1-\alpha)({\bm K}_a + {\bm K}_d) \delta t] \cdot {\vec T}^{n} + {\vec F}\delta t
\end{equation}
When $\alpha=0$ we recover the explicit scheme, when $\alpha=1$ we recover
the implicit one, and when $\alpha=1/2$ we get a so-called
mid-point algorithm (Crank-Nicolson).
\todo[inline]{Write about SUPG}
%-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
\begin{center}
\begin{minipage}[t]{0.77\textwidth}
\par\noindent\rule{\textwidth}{0.4pt}
\begin{center}
\includegraphics[width=0.8cm]{images/garftr} \\
{\color{orange}Exercise FEM-2}
\end{center}
Let us consider the domain $[0,1]$. The temperature field at $t=0$ is
given by $T=1$ for $x<0.25$ and $T=0$ otherwise. The prescribed
velocity is $u=1$ and we set $nnx=51$.
Boundary conditions are $T=1$ at $x=0$ and $T=0$ at $x=1$.
Only advection is present, no heat source nor diffusion.
\begin{center}
\input{tikz/tikz_fdm1Df}
\end{center}
Set $\rho=C_p=1$.
Run the model for 250 time steps with $\delta t=0.002$.
Implement a fully implicit, explicit and Crank-Nicolson
time discretisation.
When using Crank-Nicolson, you should then be able to recover the green line of the
following figure:
\begin{center}
\includegraphics[width=8cm]{images/fem_exercises/fantom3.png} \\
{\captionfont Taken from Thieulot (2011) \cite{thie11}. Note that $\tau=\gamma h/u$.}
\end{center}
Finally, implement the SUPG method and recover the red and turquoise lines.
\par\noindent\rule{\textwidth}{0.4pt}
\end{minipage}
\end{center}
%-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/