KASKADE 7 development version
Loading...
Searching...
No Matches
timestepping
extrapolation.hh
Go to the documentation of this file.
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2
/* */
3
/* This file is part of the library KASKADE 7 */
4
/* https://www.zib.de/research/projects/kaskade7-finite-element-toolbox */
5
/* */
6
/* Copyright (C) 2002-2011 Zuse Institute Berlin */
7
/* */
8
/* KASKADE 7 is distributed under the terms of the ZIB Academic License. */
9
/* see $KASKADE/academic.txt */
10
/* */
11
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13
#ifndef EXTRAPOLATION_HH
14
#define EXTRAPOLATION_HH
15
16
#include <vector>
17
18
namespace
Kaskade
19
{
27
template
<
class
T>
28
class
ExtrapolationTableau
29
{
30
public
:
31
typedef
T
value_type
;
32
33
explicit
ExtrapolationTableau
(
double
hTarget_): hTarget(hTarget_) {}
34
35
39
void
clear
() { data.clear(); }
40
46
T
const
&
back
()
const
{
return
data.back(); }
47
52
T
const
&
operator[]
(
int
i)
const
{
53
assert(0<=i && i<data.size());
54
return
data[i];
55
}
56
62
int
size
()
const
{
return
data.size(); }
63
64
68
void
push_back
(T t,
double
hnew)
69
{
70
T tmp(t);
71
72
for
(
int
i=0; i<data.size(); ++i) {
73
// at loop start: t = t(n+1,i), data[i] = t(n,i)
74
75
// compute coefficients, see Deuflhard/Hohmann 7.1.2
76
int
n = data.size()-1;
77
double
a = - (hTarget-hnew)/(hnew-h[n-i]);
78
double
b = (hTarget-h[n-i])/(hnew-h[n-i]);
79
// compute tmp = t(n+1,i+1) = a*t(n,i)+b*t(n+1,i)
80
tmp = t; tmp *= b;
81
data[i] *= a; tmp += data[i];
82
// store data[i] = t(n+1,i)
83
data[i] = t;
84
// maintain loop invariant: t = t(n+1,i+1)
85
t = tmp;
86
}
87
// store new t(n+1,n+1)
88
data.push_back(t);
89
h.push_back(hnew);
90
}
91
92
93
94
private
:
95
// The array data always contains a complete row of the extrapolation tableau.
96
std::vector<T> data;
97
std::vector<double> h;
98
double
hTarget;
99
};
100
}
// namespace Kaskade
101
102
#endif
Kaskade::ExtrapolationTableau::push_back
void push_back(T t, double hnew)
Definition
extrapolation.hh:68
Kaskade::ExtrapolationTableau::back
T const & back() const
Definition
extrapolation.hh:46
Kaskade::ExtrapolationTableau::clear
void clear()
Definition
extrapolation.hh:39
Kaskade::ExtrapolationTableau::value_type
T value_type
Definition
extrapolation.hh:31
Kaskade::ExtrapolationTableau::operator[]
T const & operator[](int i) const
Definition
extrapolation.hh:52
Kaskade::ExtrapolationTableau::ExtrapolationTableau
ExtrapolationTableau(double hTarget_)
Definition
extrapolation.hh:33
Kaskade::ExtrapolationTableau::size
int size() const
Definition
extrapolation.hh:62
Kaskade
Definition
advect.hh:24
Generated on
for KASKADE 7 development version by
1.14.0