Übungen zu Numerische Methoden für Partielle Differentialgleichungen
Lecturer: Dr. Clemens PechsteinThis tutorial will be given in english.
Time and Room: Thursday 13.45 – 15.15, T 212
Tutorial | Date | Assignment | |
---|---|---|---|
01 | 14 Oct. 2010 | ||
02 | 21 Oct. 2010 | ||
03 | 28 Oct. 2010 | C++ Hints | |
04 | 4 Nov. 2010 | results for f=2x+1 and 20 elements (to validate your program) | |
05 | 11 Nov. 2010 | plot hints results (to validate your program) | |
06 | 18 Nov. 2010 | richardson.hh (corrected since 12.Nov 8:30) | |
07 | 25 Nov. 2010 | cg.hh | |
08 | 2 Dec. 2010 | mds.hh | |
09 | 9 Dec. 2010 | pdf||
10 | 16 Dec. 2010 | ||
11 | 13 Jan. 2011 | ||
12 | 20 Jan. 2011 | ||
13 | 27 Jan. 2011 |
In the tutorials, we study the material in the lecture in more detail, which usually helps a lot in understanding. This is done in form of homework assignments (for the Austrian students: "Kreuzerlübung" style).
About half of the homeworks are theoretical assignments that you can solve with pencil and paper. In class, you should mark which exercises you have prepared, and be ready to present your solution on the blackboard. The solution needn't be 100% perfect to put a mark, but you should show that you investigated the problem and found a solution to the best of your knowledge. For many of the problems, I will give hints anyway.
Please present for the whole audience, not only to me. I would like to have a mathematical discussion among all of us.
In the remaining 50% we will implement some of the methods from the lecture on the computer, more precisely in C++ (basic knowledge of C should be enough to attend the tutorial). This will be guided and split into small assignments. Also these homeworks will be discussed in class.
C++ examples
- helloworld.cc - you should be able to compile and run this example
- vectors.cc - this example shows how to comfortably work with vectors
C++ Links / Literature
-
For beginners - learn things:
online C++ tutorial -
A good reference - finding things:
online C++ reference -
For advanced readers:
Scott Meyers: "Effective C++" (or "More Effective C++"), a collection of really good hints and advices
Bjarne Stroustrop: "The C++ Programming Language", a fat book by the inventor of C++ himself, where you should find almost everything.
Plot hints
If you would like to plot your solution, you can output
- the coordinates of the mesh
- the solution vector
#include <fstream>
using namespace std;
...
void FileOutput (const Mesh& mesh, const Vector& u, const char* file)
{
if (u.size() != mesh.numNodes())
{
cerr << "ERROR: size of vector doesn't match"
<< " with number of nodes in mesh" << endl;
abort();
}
ofstream ofs;
ofs.open (file);
for (int i=0; i<mesh.numNodes(); ++i)
{
ofs << mesh.coord (i) << "\t" << u[i] << endl;
}
ofs.close();
}
...
FileOutput (mesh, u, "u.dat");
Then you may use Mathematica, matlab
or gnuplot (there is even WGnuplot for Windows)
for plotting.
Example for matlab
Call matlab and type
data = load('u.dat');
plot (data(:,1), data(:,2));
Example for gnuplot
Call gnuplot and type
plot 'u.dat' using 1:2 w lp
You can also use a gnuplot script file: u.gp and type gnuplot u.gp from your shell.
top