Skip to content

Commit 60fd877

Browse files
committed
Clean up work_data
1 parent 0a49338 commit 60fd877

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

c++/triqs_ctseg/work_data.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ work_data_t::work_data_t(params_t const &p, inputs_t const &inputs, mpi::communi
2222
gf_struct = p.gf_struct;
2323
n_color = count_colors(gf_struct);
2424

25-
// Compute gf_block_size_partial_sum
26-
{ // to make acc local
27-
long acc = 0;
28-
for (auto const &[s, l] : gf_struct) {
29-
if (l > 1) offdiag_delta = true;
30-
gf_block_size_partial_sum.push_back(acc);
31-
acc += l;
32-
}
33-
}
34-
3525
// Compute color/block conversion tables
3626
for (auto const &color : range(n_color)) {
3727
block_number.push_back(find_block_number(color));
@@ -57,6 +47,8 @@ work_data_t::work_data_t(params_t const &p, inputs_t const &inputs, mpi::communi
5747
spdlog::info("Orbital energies: mu - eps = {}", mu);
5848
}
5949

50+
// FIXME: Convert here Block2Gf to matrix Gf.
51+
6052
// Do we have D(tau) and J_perp(tau)? Yes, unless the data is 0
6153
has_Dt = max_element(abs(inputs.d0t.data())) > 1.e-13;
6254
has_jperp = max_element(abs(inputs.jperpt.data())) > 1.e-13;
@@ -156,6 +148,11 @@ work_data_t::work_data_t(params_t const &p, inputs_t const &inputs, mpi::communi
156148
if (c.rank() == 0) { spdlog::info("Delta(tau) is 0, running only spin moves."); }
157149
}
158150

151+
// Does gf_struct allow for off-diagonal Delta?
152+
for (auto const &[s, l] : gf_struct) {
153+
if (l > 1) offdiag_delta = true;
154+
}
155+
159156
// Take the real part of Delta(tau)
160157
delta = map([](gf_const_view<imtime> d) { return real(d); }, inputs.delta);
161158
for (auto const &bl : range(delta.size())) {
@@ -169,6 +166,16 @@ work_data_t::work_data_t(params_t const &p, inputs_t const &inputs, mpi::communi
169166
}
170167
} // work_data constructor
171168

169+
int work_data_t::block_to_color(int block, int idx) const {
170+
std::vector<long> gf_block_size_partial_sum;
171+
long acc = 0;
172+
for (auto const &[s, l] : gf_struct) {
173+
gf_block_size_partial_sum.push_back(acc);
174+
acc += l;
175+
}
176+
return gf_block_size_partial_sum[block] + idx;
177+
}
178+
172179
long work_data_t::find_block_number(int color) const {
173180
long bl = 0;
174181
long colors_so_far = 0;

c++/triqs_ctseg/work_data.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,13 @@ struct work_data_t {
3838
std::vector<long> block_number; // block numbers corresponding to colors
3939
std::vector<long> index_in_block; // index in block of a given color
4040

41-
// Map (block, idx) of gf to a color
42-
std::vector<long> gf_block_size_partial_sum; // data for block_to_color method
43-
int block_to_color(int block, int idx) const { return gf_block_size_partial_sum[block] + idx; }
41+
// Find color corresponding to (block, idx)
42+
int block_to_color(int block, int idx) const;
4443

4544
// Find block of color
4645
long find_block_number(int color) const;
4746

48-
// Find index of color in block
47+
// Find index of color in its block
4948
long find_index_in_block(int color) const;
5049
};
5150

0 commit comments

Comments
 (0)