-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjacobi.h
More file actions
executable file
·72 lines (52 loc) · 1.41 KB
/
jacobi.h
File metadata and controls
executable file
·72 lines (52 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef _JACOBI_H
#define _JACOBI_H
#include <vector>
#include <chrono>
#include <string>
struct JacobiData
{
// types
using time_point = decltype(std::chrono::high_resolution_clock::now());
// functions
JacobiData();
auto& get_u( size_t j, size_t i ){
return U[((j)-first_row) * n_cols + (i)];
}
auto& get_f( size_t j, size_t i ){
return F[((j)-first_row) * n_cols + (i)];
}
void init_matrix();
std::string iter2filename(std::string pre_iter, int iter, std::string post_iter);
void out(std::vector<double> out_array, std::string filename);
// data
/* input data */
int n_rows;
int n_cols;
int first_row;
int last_row;
int max_iterations;
int out_iter;
double relax;
double tolerance;
/* calculated dx & dy */
double dx;
double dy;
std::vector<double> U;
std::vector<double> F;
void run();
/* start and end timestamps */
time_point start_timepoint;
time_point end_timepoint;
/* calculated residual (output jacobi) */
double residual;
/* effective interation count (output jacobi) */
int effective_iter_count;
/* calculated error (output error_check) */
double calculated_error;
/* MPI-Variables */
int my_rank; /* current process rank (number) */
int n_processes; /* how many processes */
long total;
int max_threads;
};
#endif