OGS
CoupledSolutionsForStaggeredScheme.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6#include <numeric>
7
9
10namespace ProcessLib
11{
12std::vector<double> getCoupledLocalSolutions(
13 std::vector<GlobalVector*> const& global_solutions,
14 std::vector<std::vector<GlobalIndexType>> const& indices)
15{
16 if (global_solutions.empty())
17 {
18 return {};
19 }
20
21 std::size_t const local_solutions_size =
22 std::accumulate(cbegin(indices),
23 cend(indices),
24 std::size_t(0),
25 [](GlobalIndexType const size,
26 std::vector<GlobalIndexType> const& process_indices)
27 { return size + process_indices.size(); });
28 std::vector<double> local_solutions;
29 local_solutions.reserve(local_solutions_size);
30
31 int number_of_processes = static_cast<int>(global_solutions.size());
32 for (int process_id = 0; process_id < number_of_processes; ++process_id)
33 {
34 auto values = global_solutions[process_id]->get(indices[process_id]);
35 local_solutions.insert(cend(local_solutions),
36 std::make_move_iterator(begin(values)),
37 std::make_move_iterator(end(values)));
38 }
39 return local_solutions;
40}
41} // namespace ProcessLib
GlobalMatrix::IndexType GlobalIndexType
std::vector< double > getCoupledLocalSolutions(std::vector< GlobalVector * > const &global_solutions, std::vector< std::vector< GlobalIndexType > > const &indices)