-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathCBF.tex
More file actions
400 lines (334 loc) · 13.1 KB
/
CBF.tex
File metadata and controls
400 lines (334 loc) · 13.1 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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
\begin{flushright} {\tiny {\color{gray} cbf.tex}} \end{flushright}
The Consistent Boundary Flux technique was devised to
alleviate the problem of the accuracy of primary variables
derivatives (mainly velocity and temperature) on boundaries.
These derivatives are important since they are needed to compute
the heat flux (and therefore the Nusselt number) or
dynamic topography and geoid.
The idea was first introduced in Mizukami (1986) \cite{mizu86} and later used
in geodynamics in Zhong \etal (1993) \cite{zhgh93}. It was finally implemented
in the \citcoms code \cite{zhmt08,mole97} and more recently
in the \aspect code (dynamic topography postprocessor).
Note that the CBF should be seen as a post-processor step
as it does not alter the primary variables values.
The CBF method is implemented and used in \stone~27.
It is also discussed but not explicitely named in Reddy's book \cite[p309]{reddybook2}.
Also see Larock \& Herrmann (1976) \cite{lahe76}, Gresho \etal (1987) \cite{grls87}, Marshall \etal \cite{mahz78}.
%---------------------------------------------------------------
\subsection{The CBF applied to the Stokes equation}
We start from the strong form:
\begin{equation}
{\vec \nabla}\cdot {\bm \sigma} + {\vec b} = {\vec 0}
\end{equation}
and then write the weak form on an element $e$:
\begin{equation}
\int_{\Omega_e} N_i^\upnu {\vec \nabla}\cdot {\bm \sigma}\; dV
+ \int_{\Omega_e} N_i^\upnu {\vec b} \; dV
= \vec 0
\end{equation}
We then use the two equations:
\index{general}{Chain Rule}
\index{general}{Divergence Theorem}
\[
\vec \nabla \cdot ( N \bm \sigma ) = N \vec{\nabla} \cdot \bm \sigma + \vec{\nabla} N \cdot \bm \sigma
\qquad \text{(chain rule)}
\]
\[
\int_\Omega (\vec \nabla \cdot {\bm \sigma} )\; dV = \int_\Gamma {\bm \sigma} \cdot \vec{n} \; dS
\qquad \text{(divergence theorem)}
\]
and integrate by parts in order to obtain:
\begin{eqnarray}
\int_\Gamma N_i^\upnu {\bm \sigma}\cdot\vec{n} \; dS -
\int_{\Omega_e} {\vec \nabla } N_i^\upnu \cdot {\bm \sigma} \; dV
+ \int_{\Omega_e} N_i^\upnu {\vec b} \; dV =\vec{0}
\end{eqnarray}
and since the traction vector ${\vec t}$ is given by $\vec{t}={\bm \sigma}\cdot\vec{n}$ we have:
\begin{eqnarray}
\int_{\Gamma_e} N_i^\upnu {\vec t} \; dS
&=& \int_{\Omega_e} {\vec \nabla } N_i^\upnu \cdot {\bm \sigma}\; dV
- \int_{\Omega_e} N_i^\upnu {\vec b} \; dV \label{eq:cbf1}
\end{eqnarray}
The core idea of the method lies in considering the traction vector as an unknown
living on the nodes on the boundary, and assuming we have already solved the Stokes
equation and therefore have obtained the velocity and pressure.
Finally, since the traction vector can be expressed as a function of the velocity
basis functions on the edge i.e.
\[
\vec{t} = \sum_{i=1}^m N_i^\upnu \vec{t}_i
\]
the left hand term yields an edge (1D) mass matrix $\M'$ (see Section~\ref{app:mm}).
\begin{remark}
In \stone~27 an alternative to equation \ref{eq:cbf1} is used. Although
somewhat inefficient, the elemental matrices $\K$ and $\G$ and the corresponding
body force rhs are built and the rhs of the traction equation is computed as follows:
\[
\M' \cdot \vec{\cal T} = -\K \cdot \vec{\cal V} - \G \cdot\vec{\cal P} + \vec{f}
\]
where $\vec{\cal T}$ is the vector of assembled tractions which we want to compute
and $\vec{\cal V}$ and $\vec{\cal T}$ are the solutions of the Stokes problem.
\end{remark}
\begin{remark}
The assembled mass matrix is tri-diagonal and can be easily solved with
a Conjugate Gradient method.
\end{remark}
\begin{remark}
With a trapezoidal integration rule
(i.e. Gauss-Lobatto - see Section~\ref{sec:loba}) the matrix can even be diagonalised and the resulting
matrix is simply diagonal, which results in a very cheap solve as mentioned in Zhong \etal (1993) \cite{zhgh93}.
\end{remark}
\subsubsection{Some implementation details for the Stokes equation}
What follows is relevant for \stone~27 which relies on $Q_1$ shape
functions for the velocity.
Let us start with a small example, a 3x2 element FE grid:
\begin{center}
\begin{tikzpicture}
%\draw[step=0.5cm,gray,very thin] (0,0) grid (8,6); %background grid
\draw[thick] (1,1) -- (3,1) -- (3,3) -- (1,3) -- cycle;
\draw[thick] (3,1) -- (5,1) -- (5,3) -- (3,3) -- cycle;
\draw[thick] (5,1) -- (7,1) -- (7,3) -- (5,3) -- cycle;
\draw[thick] (1,3) -- (3,3) -- (3,5) -- (1,5) -- cycle;
\draw[thick] (3,3) -- (5,3) -- (5,5) -- (3,5) -- cycle;
\draw[thick] (5,3) -- (7,3) -- (7,5) -- (5,5) -- cycle;
\node[draw] at (2,2) {0};
\node[draw] at (4,2) {1};
\node[draw] at (6,2) {2};
\node[draw] at (2,4) {3};
\node[draw] at (4,4) {4};
\node[draw] at (6,4) {5};
%pressure dofs
\node at (0.9,0.9) {\tiny 0};
\node at (2.9,0.9) {\tiny 1};
\node at (4.9,0.9) {\tiny 2};
\node at (6.9,0.9) {\tiny 3};
\node at (0.9,2.9) {\tiny 4};
\node at (2.9,2.9) {\tiny 5};
\node at (4.9,2.9) {\tiny 6};
\node at (6.9,2.9) {\tiny 7};
\node at (0.9,4.9) {\tiny 8};
\node at (2.9,4.9) {\tiny 9};
\node at (4.9,4.9) {\tiny 10};
\node at (6.9,4.9) {\tiny 11};
%velocity dofs
\node[red] at (1.1,1.1) {\tiny 0}; \node[blue] at (1.25,1.1) {\tiny 1};
\node[red] at (3.1,1.1) {\tiny 2}; \node[blue] at (3.25,1.1) {\tiny 3};
\node[red] at (5.1,1.1) {\tiny 4}; \node[blue] at (5.25,1.1) {\tiny 5};
\node[red] at (7.1,1.1) {\tiny 6}; \node[blue] at (7.25,1.1) {\tiny 7};
\node[red] at (1.1,3.1) {\tiny 8}; \node[blue] at (1.25,3.1) {\tiny 9};
\node[red] at (3.1,3.1) {\tiny 10}; \node[blue] at (3.35,3.1) {\tiny 11};
\node[red] at (5.1,3.1) {\tiny 12}; \node[blue] at (5.35,3.1) {\tiny 13};
\node[red] at (7.1,3.1) {\tiny 14}; \node[blue] at (7.35,3.1) {\tiny 15};
\node[red] at (1.,5.1) {\tiny 16}; \node[blue] at (1.3,5.1) {\tiny 17};
\node[red] at (3.,5.1) {\tiny 18}; \node[blue] at (3.3,5.1) {\tiny 19};
\node[red] at (5.,5.1) {\tiny 20}; \node[blue] at (5.3,5.1) {\tiny 21};
\node[red] at (7.,5.1) {\tiny 22}; \node[blue] at (7.3,5.1) {\tiny 23};
\end{tikzpicture}\\
{\tiny Red color corresponds to the dofs in the x direction, blue color indicates a dof in the y direction.}
\end{center}
We have nnp=12, nel=6, NfemV=24. Let us assume that free slip boundary conditions are applied.
The boundary conditions {\tt fix\_bc} array is then:
\begin{center}
\begin{tikzpicture}
%\draw[step=0.5cm,gray,very thin] (0,0) grid (9,0.7); %background grid
\node at (0.45,.1) {\tiny bc\_fix=[};
\node[red] at (1.00,.1) {\tiny T};
\node[blue] at (1.25,.1) {\tiny T};
\node[red] at (1.50,.1) {\tiny T};
\node[blue] at (1.75,.1) {\tiny T};
\node[red] at (2.00,.1) {\tiny T};
\node[blue] at (2.25,.1) {\tiny T};
\node[red] at (2.50,.1) {\tiny T};
\node[blue] at (2.75,.1) {\tiny T};
\node[red] at (3.00,.1) {\tiny T};
\node[blue] at (3.25,.1) {\tiny T};
\node[red] at (3.50,.1) {\tiny T};
\node[blue] at (3.75,.1) {\tiny T};
\node[red] at (4.00,.1) {\tiny T};
\node[blue] at (4.25,.1) {\tiny T};
\node[red] at (4.50,.1) {\tiny T};
\node[blue] at (4.75,.1) {\tiny T};
\node[red] at (5.00,.1) {\tiny T};
\node[blue] at (5.25,.1) {\tiny T};
\node[red] at (5.50,.1) {\tiny T};
\node[blue] at (5.75,.1) {\tiny T};
\node[red] at (6.00,.1) {\tiny T};
\node[blue] at (6.25,.1) {\tiny T};
\node[red] at (6.50,.1) {\tiny T};
\node[blue] at (6.75,.1) {\tiny T};
\node at (7,.1) {\tiny ]};
\end{tikzpicture}\\
\end{center}
Note that since corners belong to two edges, we effectively prescribed
no-slip boundary conditions on those.
\todo[inline]{why does array contain only T??}
We wish to compute the tractions on the boundaries, and more precisely for the dofs for which
a Dirichlet velocity boundary condition has been prescribed.
The number of (traction) unknowns NfemTr is then the number of {\tt T} in the {\tt bc\_fix} array.
In our specific case, we wave NfemTr= .
\todo{finish}
This means that we need for each targeted dof to be able to find its identity/number
between 0 and NfemTr-1. We therefore create the array {\tt bc\_nb} which is
filled as follows:
\begin{center}
\begin{tikzpicture}
\draw[step=0.5cm,gray,very thin] (0,0) grid (9,0.7); %background grid
\node at (0.5,.1) {\tiny bc\_nb=[};
\node[red] at (1.00,.1) {\tiny T};
\node[blue] at (1.25,.1) {\tiny T};
\node[red] at (1.50,.1) {\tiny T};
\node[blue] at (1.75,.1) {\tiny T};
\node[red] at (2.00,.1) {\tiny T};
\node[blue] at (2.25,.1) {\tiny T};
\node[red] at (2.50,.1) {\tiny T};
\node[blue] at (2.75,.1) {\tiny T};
\node[red] at (3.00,.1) {\tiny T};
\node[blue] at (3.25,.1) {\tiny T};
\node[red] at (3.50,.1) {\tiny T};
\node[blue] at (3.75,.1) {\tiny T};
\node[red] at (4.00,.1) {\tiny T};
\node[blue] at (4.25,.1) {\tiny T};
\node[red] at (4.50,.1) {\tiny T};
\node[blue] at (4.75,.1) {\tiny T};
\node[red] at (5.00,.1) {\tiny T};
\node[blue] at (5.25,.1) {\tiny T};
\node[red] at (5.50,.1) {\tiny T};
\node[blue] at (5.75,.1) {\tiny T};
\node[red] at (6.00,.1) {\tiny T};
\node[blue] at (6.25,.1) {\tiny T};
\node[red] at (6.50,.1) {\tiny T};
\node[blue] at (6.75,.1) {\tiny T};
\node at (7,.1) {\tiny ]};
\end{tikzpicture}\\
\end{center}
This translates as follows in the code:
\begin{lstlisting}
NfemTr=np.sum(bc_fix)
bc_nb=np.zeros(NfemV,dtype=np.int32)
counter=0
for i in range(0,NfemV):
if (bc_fix[i]):
bc_nb[i]=counter
counter+=1
\end{lstlisting}
The algorithm is then as follows
\begin{itemize}
\item[A] Prepare two arrays to store the matrix $M_{cbf}$ and its right hand side $rhs_{cbf}$
\item[B]
Loop over all elements
\item[C]
For each element touching a boundary, compute the residual vector
$R_{el}=-f_{el} + \K_{el}{\cal V}_{el} + \G_{el} {\cal P}_{el}$
\item[D]
Loop over the four edges of the element using the connectivity array
\item[E]
For each edge loop over the number of degrees of freedom (2 in 2D)
\item[F]
For each edge assess whether the dofs on both ends are target dofs.
\item[G]
If so, compute the mass matrix $M_{edge}$ for this edge
\item[H] extract the 2 values off the element residual vector and assemble these
in $rhs_{cbf}$
\item[I] Assemble $M_{edge}$ into NfemTrxNfemTr matrix using bc\_nb
\end{itemize}
\begin{lstlisting}
M_cbf = np.zeros((NfemTr,NfemTr),np.float64) # A
rhs_cbf = np.zeros(NfemTr,np.float64)
for iel in range(0,nel): # B
... compute elemental residual ... # C
#boundary 0-1 # D
for i in range(0,ndofV): # E
idof0=2*icon[0,iel]+i
idof1=2*icon[1,iel]+i
if (bc_fix[idof0] and bc_fix[idof1]): # F
idofTr0=bc_nb[idof0]
idofTr1=bc_nb[idof1]
rhs_cbf[idofTr0]+=res_el[0+i] # H
rhs_cbf[idofTr1]+=res_el[2+i]
M_cbf[idofTr0,idofTr0]+=M_edge[0,0] #
M_cbf[idofTr0,idofTr1]+=M_edge[0,1] # I
M_cbf[idofTr1,idofTr0]+=M_edge[1,0] #
M_cbf[idofTr1,idofTr1]+=M_edge[1,1] #
#boundary 1-2 #[D]
...
#boundary 2-3 #[D]
...
#boundary 3-0 #[D]
...
\end{lstlisting}
%---------------------------------------------------------------
\subsection{The CBF applied to the heat transport equation}
We start from the strong form of the heat transfer equation (without the source terms for simplicity):
\[
\rho C_p
\left(\frac{\partial T}{\partial t} + \vec{\upnu}\cdot \vec{\nabla}T\right)
=
\vec{\nabla} \cdot k\vec{\nabla} T
\]
The weak form then writes:
\[
\int_\Omega \bN^\uptheta
\rho C_p
\frac{\partial T}{\partial t} dV
+
\int_\Omega \bN^\uptheta
\rho C_p
\vec{\upnu}\cdot \vec{\nabla}T dV
=
\int_\Omega \bN^\uptheta
\vec{\nabla} \cdot k\vec{\nabla} T dV
\]
Using once again integration by parts and divergence theorem:
\[
\int_\Omega \bN^\uptheta
\rho C_p
\frac{\partial T}{\partial t} dV
+
\int_\Omega \bN^\uptheta
\rho C_p
\vec{\upnu}\cdot \vec{\nabla}T dV
=
\int_\Gamma \bN^\uptheta k \vec{\nabla} T \cdot \vec{n} d\Gamma
-
\int_\Omega \vec{\nabla} \bN^\uptheta \cdot k \vec{\nabla} T dV
\]
On the boundary we are interested in the heat flux $\vec{q}=-k \vec{\nabla} T$
\[
\int_\Omega \bN^\uptheta
\rho C_p
\frac{\partial T}{\partial t} dV
+
\int_\Omega \bN^\uptheta
\rho C_p
\vec{\upnu}\cdot \vec{\nabla} T dV
=
-\int_\Gamma \bN^\uptheta {\bm q} \cdot {\bm n} d\Gamma
- \int_\Omega \vec{\nabla} \bN^\uptheta \cdot k \vec{\nabla} T dV
\]
or,
\[
\int_\Gamma \bN^\uptheta {\bm q} \cdot {\bm n} d\Gamma
=
-\int_\Omega \bN^\uptheta
\rho C_p
\frac{\partial T}{\partial t} dV
-
\int_\Omega \bN^\uptheta
\rho C_p {\bm v}\cdot \vec{\nabla} T dV
- \int_\Omega \vec{\nabla} \bN^\uptheta \cdot k \vec{\nabla} T dV
\]
Considering the normal heat flux $q_n = \vec{q} \cdot \vec{n}$ as an unknown
living on the nodes on the boundary,
\[
q_n = \sum_{i=1}^2 q_{n|i} N_i
\]
so that the left hand term becomes a mass matrix for the basis functions living on
the boundary.
We have already covered the right hand side terms when building the FE system
to solve the heat transport equation, so that in the end
\[
\M' \cdot \vec{\cal Q}_n =
- \M \cdot \frac{\partial \bm T}{\partial t} -K_a \cdot {\bm T} - K_d \cdot {\bm T}
\]
where $\vec{\cal Q}_n$ is the assembled vector of normal heat flux components.
Note that in all terms the assembly only takes place over the elements along the boundary.
Note that the resulting matrix is symmetric.