|
Programmierpraktikum NPDGL I
|
#include "model.hh"#include "finite_difference.hh"Funktionen | |
| double | solve (Model &model, Grid &grid) |
| ode solver for finite_difference example | |
| void | main (int argc, char **argv) |
| main file of finite_difference.cc | |
This file implements a finite difference/finite volume scheme solving the PDE:
\begin{align} \partial_t u(x,t) + \partial_x f(u(x,t)) &= 0 & \text{in }&\Omega\times[0,T] \\ u(x,0) &= u_0(x) &\text{in }&\Omega \\ u(x,t) &= u_{dir}(x,t) &\text{auf }&\Gamma_{in} \times [0,T] \end{align}
The numerical scheme is implemented as a finite volume scheme on a numerical 1D grid \({\cal T}_h = \{e_i\}_{i=0}^H\) with grid cells (intervals) \(e_i\) such that \(\cup_{i=0}^H {\bar e}_i = \Omega:= [a,b]\).
A finite volume discrete function in space \(u_h:\Omega \to \mathbb{R}\) is then given by
\[ u_h(x) = \sum_{i=0}^H U_i \chi_{e_i}(x) \]
with indicator functions \(\chi_{e_i}\) which are one on grid cells and zero otherwise, and a Dof vector \(U:= \{U_i\}_{i=0}^H \in \mathbb{R}^H\).
For the numerical scheme we consider three steps:
\[ u_h^0 = {\cal P}_h[u_0] \]
\[ {\cal L}_h[u_h] \approx \partial_x f(u_h) \]
and\[ u_h^{k+1} = u_h^{k} + \Delta t^k {\cal L}_h[u_h^k] \]
.| void main | ( | int | argc, |
| char ** | argv | ||
| ) |
main file of finite_difference.cc
Usage: ./finite_difference a b N
1.7.3