sheet 4
This commit is contained in:
parent
c21fee7862
commit
65a23d88d6
67 changed files with 14385 additions and 0 deletions
6
sheet4/A/.vscode/settings.json
vendored
Normal file
6
sheet4/A/.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"files.associations": {
|
||||
"ostream": "cpp",
|
||||
"iostream": "cpp"
|
||||
}
|
||||
}
|
||||
0
sheet4/A/.vscode/settings.json:Zone - Kopie.Identifier
vendored
Normal file
0
sheet4/A/.vscode/settings.json:Zone - Kopie.Identifier
vendored
Normal file
0
sheet4/A/.vscode/settings.json:Zone - Kopie.Identifier:Zone.Identifier
vendored
Normal file
0
sheet4/A/.vscode/settings.json:Zone - Kopie.Identifier:Zone.Identifier
vendored
Normal file
0
sheet4/A/.vscode/settings.json:Zone - Kopie.Identifier:Zone.Identifier:Zone.Identifier
vendored
Normal file
0
sheet4/A/.vscode/settings.json:Zone - Kopie.Identifier:Zone.Identifier:Zone.Identifier
vendored
Normal file
0
sheet4/A/.vscode/settings.json:Zone.Identifier
vendored
Normal file
0
sheet4/A/.vscode/settings.json:Zone.Identifier
vendored
Normal file
0
sheet4/A/.vscode/settings.json:Zone.Identifier:Zone.Identifier
vendored
Normal file
0
sheet4/A/.vscode/settings.json:Zone.Identifier:Zone.Identifier
vendored
Normal file
BIN
sheet4/A/A.pdf
Normal file
BIN
sheet4/A/A.pdf
Normal file
Binary file not shown.
2563
sheet4/A/Doxyfile
Normal file
2563
sheet4/A/Doxyfile
Normal file
File diff suppressed because it is too large
Load diff
32
sheet4/A/Makefile
Normal file
32
sheet4/A/Makefile
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#
|
||||
# use GNU-Compiler tools
|
||||
COMPILER=GCC_
|
||||
# alternatively from the shell
|
||||
# export COMPILER=GCC_
|
||||
# or, alternatively from the shell
|
||||
# make COMPILER=GCC_
|
||||
|
||||
# use Intel compilers
|
||||
#COMPILER=ICC_
|
||||
|
||||
# use PGI compilers
|
||||
# COMPILER=PGI_
|
||||
|
||||
|
||||
SOURCES = main.cpp
|
||||
OBJECTS = $(SOURCES:.cpp=.o)
|
||||
|
||||
PROGRAM = main.${COMPILER}
|
||||
|
||||
# uncomment the next to lines for debugging and detailed performance analysis
|
||||
CXXFLAGS += -g
|
||||
LINKFLAGS += -g
|
||||
# do not use -pg with PGI compilers
|
||||
|
||||
ifndef COMPILER
|
||||
COMPILER=GCC_
|
||||
endif
|
||||
|
||||
include ../${COMPILER}default.mk
|
||||
$(PROGRAM): $(OBJECTS)
|
||||
$(CXX) $(CXXFLAGS) $(OBJECTS) -llapacke -lopenblas -o $(PROGRAM)
|
||||
53
sheet4/A/main.cpp
Normal file
53
sheet4/A/main.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <lapacke.h>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
int n = 10;
|
||||
unsigned int nodes = n+1;
|
||||
int rhs = 1;
|
||||
double a = 1.0;
|
||||
double alpha = 2.0;
|
||||
double gB = 1.0;
|
||||
|
||||
double d = n + a/3.0/n;
|
||||
double s = - n + a / 6.0 / n;
|
||||
|
||||
cout << d << endl;
|
||||
cout << s << endl;
|
||||
|
||||
//Lapacke overwrites upper/lower diagonal so store twice
|
||||
vector<double> upperdiagonal(n,s);
|
||||
vector<double> lowerdiagonal(n,s);
|
||||
vector<double> diagonal(nodes,2*d);
|
||||
vector<double> F(nodes,1.0/n);
|
||||
|
||||
diagonal[0]=1.0;
|
||||
diagonal[n]=d+alpha;
|
||||
|
||||
upperdiagonal[0] = 0.0;
|
||||
//
|
||||
|
||||
F[0] = 0;
|
||||
F[n]= 1.0/n/2.0 +alpha*gB;
|
||||
|
||||
|
||||
//Tridiagonal
|
||||
LAPACKE_dgtsv(LAPACK_COL_MAJOR,nodes,rhs,lowerdiagonal.data(),diagonal.data(),upperdiagonal.data(),F.data(),nodes);
|
||||
|
||||
|
||||
cout << "Solution u_h at nodes x_1..x_" << n << ":\n";
|
||||
for (unsigned int i = 0; i < nodes; ++i) {
|
||||
|
||||
double xi = double(i) /double(n);
|
||||
cout << "u_h(" << xi << ") = " << F[i] << "\n";
|
||||
// F will be overwritten with sol
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
BIN
sheet4/A/plot.png
Normal file
BIN
sheet4/A/plot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
1826
sheet4/A/small_Doxyfile
Normal file
1826
sheet4/A/small_Doxyfile
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue