-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNumGy_LV12E1.qmd
158 lines (110 loc) · 5.01 KB
/
NumGy_LV12E1.qmd
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
---
title: "Numerical Simulation Methods in Geophysics, Part 6: Finite Elements"
subtitle: "1. MGPY+MGIN"
author: "[email protected]"
title-slide-attributes:
data-background-image: pics/tubaf-logo.png
data-background-size: 20%
data-background-position: 10% 95%
format:
tubaf-revealjs:
html-math-method: mathjax
chalkboard: true
include-in-header:
- text: |
<script>
window.MathJax = {
loader: {
load: ['[tex]/physics']
},
tex: {
packages: {'[+]': ['physics']}
}
};
</script>
slide-number: c/t
transition: slide
transition-speed: fast
menu:
side: left
# jupyter: python3
---
## Variational formulation of Diffusion equation
$$ \pdv{u}{t} - \div a \grad u = f $$
::: {.fragment}
Multiplication with test function $w$ and integration $\Rightarrow$ weak form
$$ -\int_\Omega w \div a \grad u \dd\Omega = \int_\Omega w f \dd\Omega $$
:::
::: {.fragment}
$$ \div(b\vb c) = b\div \vb c + \grad b \cdot \vb c $$
:::
::: {.fragment}
$$ \int_\Omega a \grad w \cdot \grad u \dd\Omega - \int_\Omega \div(w a \grad u) \dd\Omega = \int_\Omega w f \dd\Omega $$
:::
## Variational formulation of Poisson equation
$$ \int_\Omega a \grad w \cdot \grad u \dd\Omega - \int_\Omega \div(w a \grad u) \dd\Omega = \int_\Omega w f \dd\Omega $$
::: {.fragment}
use Gauss' law $\int_\Omega \div \vb A = \int_\Gamma \vb A \cdot \vb n$
$$ \int_\Omega a \grad w \cdot \grad u \dd\Omega - \int_\Gamma a w \grad u \cdot \vb n \dd\Gamma = \int_\Omega fw \dd\Omega $$
:::
::: {.fragment}
Let $u$ be constructed by shape functions $v$: $u=\sum_i u_i v_i$
$$ \int_\Omega a \grad w \cdot \grad v_i \dd\Omega - \int_\Gamma a w \grad v_i \cdot \vb n \dd\Gamma = \int_\Omega fw \dd\Omega $$
:::
## Galerkin's method
$$ \int_\Omega a \grad w \vdot \grad v_i \dd\Omega - \int_\Gamma a w \grad v_i \cdot \vb n \dd\Gamma = \int_\Omega fw \dd\Omega $$
::: {.fragment}
Test functions the same as shape (trial) functions $w\in v_i$
$$ \int_\Omega a \grad v_j \vdot \grad v_i \dd\Omega - \int_\Gamma a v_j \grad v_i \vdot \vb n \dd\Gamma = \int_\Omega f v_j \dd\Omega $$
:::
::: {.fragment}
* choose $v_i$ so that $\grad v_i$ is simple and $\grad v_i \vdot \grad v_j$ mostly 0
* divide subsurface in sub-volumes $\Omega_i$ with constant $a_i$ (& $\grad v_j$)
:::
## Hat functions
{width="100%"}
## Gradients for hat functions
Every element is surrounded by two nodes "carrying" a hat.
The gradients are piece-wise constant $\pm 1/\Delta x_i$
Neighboring functions $v_i$ & $v_{i+1}$ only meet between $x_i$ & $x_{i+1}$
$$ \int_\Omega a \grad v_i \vdot \grad v_{i+1} \dd\Omega = \int_{x_i}^{x_{i+1}} a \grad v_i \vdot \grad v_{i+1} \dd\Omega = -\frac{a_i}{\Delta x_i^2} \Delta x_i = -\frac{a_i}{\Delta x_i}$$
$$ -\int_\Omega a \grad v_i \vdot \grad v_i \dd\Omega = \frac{a_{i-1}}{\Delta x_{i-1}^2}\Delta x_{i-1} + \frac{a_i}{\Delta x_i^2}\Delta x_i = \frac{a_{i-1}}{\Delta x_{i-1}} + \frac{a_i}{\Delta x_i} $$
<!-- $$ -\int_\Omega a \grad v_i \vdot \grad v_{i+2} \dd\Omega = 0 $$ -->
## Integration
Let's write it up for the first
$$ \int u_0 a v_0' v_0' + \int u_1 a v_0' v_1' = \int v_0 f $$
$$ \int u_0 a v_0' v_1' + \int u_1 a v_1' v_1' + \int a u_2 v_2' v_1' = \int v_1 f $$
<!-- $$ \int u_1 v_1' v_2' + \int u_2 v_2' v_2' + \int u_3 v_3' v_2' = \int v_1 f $$ -->
$$ u_{i-1} a_{i-1} \int\limits_{x_{i-1}}^{x_{i}} v_i' v_{i-1}' +
u_i a_{i-1} \int\limits_{x_{i-1}}^{x_{i}} v_i' v_i' +
u_i a_i \int\limits_{x_{i}}^{x_{i+1}} v_i' v_i' +
u_{i+1} a_{i} \int\limits_{x_{i}}^{x_{i+1}} v_i' v_{i+1}' $$
# System (stiffness) matrix
Matrix integrating gradient of base functions for neighbors
$A$
$$ \vb A_{i, i+1} = -\frac{a_i}{\Delta x_i^2} \vdot \Delta x_i = -\frac{a_i}{\Delta x_i} $$
$$ A_{i,i} = \int_\Omega a \grad v_i \cdot \grad v_i \dd\Omega = -A_{i,i+1} - A_{i+1,i} $$
$\Rightarrow$ matrix-vector equation $\vb A \vb u = \vb b$ with conductances in $\vb A$
<!-- $\Rightarrow$ -->
## Boundary conditions
second term
$$ - \int_\Gamma a v_j \grad v_i \cdot \vb n \dd\Gamma $$
$$ [a v_i v_j']_{x_0}^{x_N} = a_{N-1} u_N v'_N - a_0 u_0 v'_0 $$
Homogeneous Neumann automatically
## Right-hand side vector
The right-hand-side vector $b=\int v_i f \dd\Omega$ also scales with $\Delta x$
e.g. $f=\div \vb j_s$ $\Rightarrow$
$b=\int v_i \div \vb j_s \dd\Omega = \int_\Gamma v_i \vb j_S \cdot \vb n$
system identical to FD for $\Delta x=$const
:::{.callout-tip icon="false" title="Difference of FE to FD"}
Any source function $f(x)$ can be integrated on the whole space!
:::
## Solution
$\vb u$ holds the coefficient $u_i$ creating $u(x)=\sum u_i v_i(x)$
:::{.callout-tip icon="false" title="Difference of FE to FD"}
$u$ is described on the whole space and approximates the solution, not the PDE!
:::
Hat functions: $u_i$ potentials on nodes, $u$ piece-wise linear
:::{.callout-tip icon="false" title="Generality of FE"}
Arbitrary base functions $v_i$ can be used to describe $u$
:::