03.12.2012 Views

C++ for Scientists - Technische Universität Dresden

C++ for Scientists - Technische Universität Dresden

C++ for Scientists - Technische Universität Dresden

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

230 CHAPTER 8. FINITE WORLD OF COMPUTERS<br />

8.2.5 Finite Element Integration<br />

In the theory of finite elements [?, ?], a continuous function space is projected onto a finite<br />

function space P k , where the space P k is the space of polynomials up to the total order of k.<br />

For many special cases, finite element integrals can be computed manually and added into<br />

the source code of an application. This results in excellent run time per<strong>for</strong>mance but lacks<br />

flexibility. For more general cases, e.g., general coefficients, they must be computed by numerical<br />

integration at run-time. To prevent an ill-conditioned system matrix, orthogonal polynomials<br />

have to be chosen as numerical integration weights. One possible type of polynomial is a<br />

normalized Legendre polynomial [?]. Coefficients <strong>for</strong> such a polynomial Pk of order k can be<br />

efficiently evaluated by using the recursion procedure:<br />

P0(x) = 1 (8.1)<br />

P1(x) = x<br />

2j − 1<br />

Pk(x) = x Pk−1(x) −<br />

j<br />

j − 1<br />

j Pk−2(x) k ≥ 2<br />

To use arbitrary p-finite elements (polynomial order [?, ?]) the numerical coefficients have to<br />

be calculated either manually and inserted into the source code or determined numerically at<br />

run time.<br />

The polynomial library presented here is then used to store manually pre-calculated integration<br />

tables at compile time (order 1-5). If the user requires higher order finite elements, numerical<br />

coefficients are calculated at run time to any order.<br />

8.3 A Loop and More<br />

One of the important parts in computer science is repetation. A computer was made to do<br />

exactly like this, programmable operations and repetations. To give a simple example, a <strong>for</strong><br />

loop is expressed by:<br />

<strong>for</strong> (long i = 0; i < max counter; ++i)<br />

{}<br />

To give a real application of this concept, integration is used.<br />

� b<br />

a<br />

f(x)dx<br />

Several approximation schemes are also available:<br />

� b<br />

a<br />

� b<br />

a<br />

f(x)dx ≈<br />

f(x)dx ≈<br />

b − a<br />

6<br />

f(a) + f(b)<br />

2<br />

�<br />

f(a) + 4f<br />

· (b − a)<br />

� a + b<br />

2<br />

� �<br />

+ f(b)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!