OGS
CoupledSolutionsForStaggeredScheme.cpp
Go to the documentation of this file.
1
14
15#include <numeric>
16
18
19namespace ProcessLib
20{
21std::vector<double> getCoupledLocalSolutions(
22 std::vector<GlobalVector*> const& global_solutions,
23 std::vector<std::vector<GlobalIndexType>> const& indices)
24{
25 if (global_solutions.empty())
26 {
27 return {};
28 }
29
30 std::size_t const local_solutions_size =
31 std::accumulate(cbegin(indices),
32 cend(indices),
33 std::size_t(0),
34 [](GlobalIndexType const size,
35 std::vector<GlobalIndexType> const& process_indices)
36 { return size + process_indices.size(); });
37 std::vector<double> local_solutions;
38 local_solutions.reserve(local_solutions_size);
39
40 int number_of_processes = static_cast<int>(global_solutions.size());
41 for (int process_id = 0; process_id < number_of_processes; ++process_id)
42 {
43 auto values = global_solutions[process_id]->get(indices[process_id]);
44 local_solutions.insert(cend(local_solutions),
45 std::make_move_iterator(begin(values)),
46 std::make_move_iterator(end(values)));
47 }
48 return local_solutions;
49}
50} // namespace ProcessLib
GlobalMatrix::IndexType GlobalIndexType
std::vector< double > getCoupledLocalSolutions(std::vector< GlobalVector * > const &global_solutions, std::vector< std::vector< GlobalIndexType > > const &indices)