Repository navigation
Expand file tree
/
Copy pathSimpleGF2Job.h
More file actions
101 lines (90 loc) · 2.6 KB
/
Copy pathSimpleGF2Job.h
File metadata and controls
101 lines (90 loc) · 2.6 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Copyright (c) 2018 Sergei Iskakov.
*
* This program is free software: you can redistribute it and/or modify..
* it under the terms of the GNU General Public License as published by..
* the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but.
* WITHOUT ANY WARRANTY; without even the implied warranty of.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU.
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GF2_SIMPLEDFGF2JOB_H
#define GF2_SIMPLEDFGF2JOB_H
#include <array>
#include <algorithm>
/**
* @brief SimpleGF2Job class defines job portion for self-energy evaluation.
*
* Simple multi-dimensional GF2 job. Each job's dimension corresponds to the index used in MPI-parallelization.
* We will fill queue object with jobs, that contains set of indices for current part of the self-energy evaluation.
*
* @tparam D - job dimension
*/
template<int D = 2>
class SimpleGF2Job {
public:
/// Job dimension
static constexpr int SIZE = D;
/**
* Fill job indices with specified value
*
* @param value - value for all job indices
*/
SimpleGF2Job(int value) {
std::fill(_data.begin(), _data.end(), value);
}
/**
* Construct job from array
*
* @param data - indices array
*/
SimpleGF2Job(const std::array<int, 2> & data) : _data(data) {}
SimpleGF2Job(std::array<int, 2> && data) : _data(data) {}
/**
* @return job indices array
*/
const std::array<int, 2>& data() const {
return _data;
}
/**
* Pointer to the underlying data structure. We need to have this raw pointer to pass Job over MPI send-receive.
*
* @return pointer to the underlying data structure
*/
int* rawdata() {
return _data.data();
}
/**
* @return size of job
*/
size_t size() const {
return _data.size();
}
/**
* Check job for validness. We assume that job is valid when all its indices are not negative
*
* @return true if job is valid
*/
bool valid() {
return (*std::min_element(_data.begin(), _data.end()) ) >= 0;
}
/**
* Print job into std stream
*
* @param stream - output stream
* @param job - job to print
*/
friend std::ostream & operator <<(std::ostream& stream, const SimpleGF2Job<D> & job) {
for(int i = 0; i<D; ++i)stream<<(i==0? "":" ")<<job._data[i];
return stream;
}
private:
// min and max index to process within the job
std::array<int, 2> _data;
};
#endif //GF2_SIMPLEDFGF2JOB_H