@@ -18,25 +18,84 @@ void Parallel_LRI_Equally<TA,Tcell,Ndim,Tdata>::set_parallel(
1818 const MPI_Comm &mpi_comm_in,
1919 const std::map<TA,Tatom_pos> &atoms_pos,
2020 const std::array<Tatom_pos,Ndim> &latvec,
21- const std::array<Tcell,Ndim> &period_in)
21+ const std::array<Tcell,Ndim> &period_in,
22+ const std::set<Label::Aab_Aab> &labels)
2223{
2324 this ->mpi_comm = mpi_comm_in;
2425 this ->period = period_in;
26+ const std::vector<TA> atoms_vec = Global_Func::map_key_to_vec (atoms_pos);
27+
28+ this ->set_parallel_loop4 (atoms_vec);
29+ this ->set_parallel_loop3 (atoms_vec, labels);
30+ }
2531
32+ template <typename TA, typename Tcell, std::size_t Ndim, typename Tdata>
33+ void Parallel_LRI_Equally<TA,Tcell,Ndim,Tdata>::set_parallel_loop4(
34+ const std::vector<TA> &atoms_vec)
35+ {
2636 constexpr std::size_t num_index = 4 ;
27- const std::vector<TA> atoms_vec = Global_Func::map_key_to_vec (atoms_pos);
2837
29- std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA,TC>>>>
38+ const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA,TC>>>>
3039 atoms_split_list = Distribute_Equally::distribute_atoms_periods (
31- mpi_comm, atoms_vec, period, num_index, false );
40+ this -> mpi_comm , atoms_vec, this -> period , num_index, false );
3241
3342 this ->list_Aa01 = atoms_split_list.first ;
3443 this ->list_Aa2 = atoms_split_list.second [0 ];
3544 this ->list_Ab01 = atoms_split_list.second [1 ];
3645 this ->list_Ab2 = atoms_split_list.second [2 ];
3746}
3847
48+ template <typename TA, typename Tcell, std::size_t Ndim, typename Tdata>
49+ void Parallel_LRI_Equally<TA,Tcell,Ndim,Tdata>::set_parallel_loop3(
50+ const std::vector<TA> &atoms_vec,
51+ const std::set<Label::Aab_Aab> &labels)
52+ {
53+ constexpr std::size_t num_index = 2 ;
54+ const std::vector<TAC> atoms_period_vec = Divide_Atoms::traversal_atom_period (atoms_vec, this ->period );
55+
56+ const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA,TC>>>>
57+ atoms_split_list1 = Distribute_Equally::distribute_atoms_periods (
58+ this ->mpi_comm , atoms_vec, this ->period , num_index, false );
59+ const std::vector<std::vector<std::pair<TA,TC>>>
60+ atoms_split_list2 = Distribute_Equally::distribute_periods (
61+ this ->mpi_comm , atoms_vec, this ->period , num_index, false );
62+ for (const Label::Aab_Aab &label : labels)
63+ {
64+ typename Parallel_LRI_Equally<TA,Tcell,Ndim,Tdata>::List_A &atoms = this ->list_A [label];
65+ atoms.a01 = atoms_vec;
66+ atoms.a2 = atoms_period_vec;
67+ atoms.b01 = atoms_period_vec;
68+ atoms.b2 = atoms_period_vec;
69+ switch (label)
70+ {
71+ case Label::Aab_Aab::a01b01_a01b01:
72+ atoms.a2 = atoms_split_list2[0 ];
73+ atoms.b01 = atoms_split_list2[1 ];
74+ break ;
75+ case Label::Aab_Aab::a01b01_a2b01:
76+ atoms.a01 = atoms_split_list1.first ;
77+ atoms.b01 = atoms_split_list1.second [0 ];
78+ break ;
79+ case Label::Aab_Aab::a01b01_a01b2:
80+ atoms.b01 = atoms_split_list1.second [0 ];
81+ atoms.a01 = atoms_split_list1.first ;
82+ break ;
83+ case Label::Aab_Aab::a01b01_a2b2:
84+ atoms.a01 = atoms_split_list1.first ;
85+ atoms.b2 = atoms_split_list1.second [0 ];
86+ break ;
87+ case Label::Aab_Aab::a01b2_a2b01:
88+ atoms.a01 = atoms_split_list1.first ;
89+ atoms.b01 = atoms_split_list1.second [0 ];
90+ break ;
91+ default :
92+ throw std::invalid_argument (std::string (__FILE__)+" line " +std::to_string (__LINE__));
93+ }
94+ }
95+ }
96+
3997
98+ /*
4099template<typename TA, typename Tcell, std::size_t Ndim, typename Tdata>
41100auto Parallel_LRI_Equally<TA,Tcell,Ndim,Tdata>::comm_tensors_map2(
42101 const Label::ab &label,
@@ -62,6 +121,7 @@ auto Parallel_LRI_Equally<TA,Tcell,Ndim,Tdata>::comm_tensors_map2(
62121 throw std::invalid_argument(std::string(__FILE__)+" line "+std::to_string(__LINE__));
63122 }
64123}
124+ */
65125
66126template <typename TA, typename Tcell, std::size_t Ndim, typename Tdata>
67127auto Parallel_LRI_Equally<TA,Tcell,Ndim,Tdata>::comm_tensors_map2(
@@ -97,6 +157,18 @@ auto Parallel_LRI_Equally<TA,Tcell,Ndim,Tdata>::comm_tensors_map2(
97157 }
98158 }
99159
160+ // used in loop3
161+ for (const auto &list_atom : this ->list_A )
162+ {
163+ if (flags[0 ]) std::get<0 >(s_list).push_back (std::make_tuple ( Global_Func::to_set (list_atom.second .a01 ), Global_Func::to_set (list_atom.second .a2 ) ));
164+ if (flags[1 ]) std::get<1 >(s_list).push_back (std::make_tuple ( Global_Func::to_set (list_atom.second .b01 ), Global_Func::to_set (list_atom.second .b2 ) ));
165+ if (flags[2 ]) std::get<0 >(s_list).push_back (std::make_tuple ( Global_Func::to_set (list_atom.second .a01 ), Global_Func::to_set (list_atom.second .b01 ) ));
166+ if (flags[3 ]) std::get<0 >(s_list).push_back (std::make_tuple ( Global_Func::to_set (list_atom.second .a01 ), Global_Func::to_set (list_atom.second .b2 ) ));
167+ if (flags[4 ]) std::get<1 >(s_list).push_back (std::make_tuple ( Global_Func::to_set (list_atom.second .a2 ), Global_Func::to_set (list_atom.second .b01 ) ));
168+ if (flags[5 ]) std::get<1 >(s_list).push_back (std::make_tuple ( Global_Func::to_set (list_atom.second .a2 ), Global_Func::to_set (list_atom.second .b2 ) ));
169+ }
170+
171+ // used in loop4
100172 if (flags[0 ]) std::get<0 >(s_list).push_back (std::make_tuple ( Global_Func::to_set (this ->list_Aa01 ), Global_Func::to_set (this ->list_Aa2 ) ));
101173 if (flags[1 ]) std::get<1 >(s_list).push_back (std::make_tuple ( Global_Func::to_set (this ->list_Ab01 ), Global_Func::to_set (this ->list_Ab2 ) ));
102174 if (flags[2 ]) std::get<0 >(s_list).push_back (std::make_tuple ( Global_Func::to_set (this ->list_Aa01 ), Global_Func::to_set (this ->list_Ab01 ) ));
0 commit comments