OGS
CoupledSolutionsForStaggeredScheme.cpp
Go to the documentation of this file.
1
14
15#include <numeric>
16
18#include "Process.h"
19
20namespace ProcessLib
21{
23 std::vector<GlobalVector*> const& coupled_xs_)
24 : coupled_xs(coupled_xs_)
25{
26 for (auto const* coupled_x : coupled_xs)
27 {
29 }
30}
31
32std::vector<double> getCoupledLocalSolutions(
33 std::vector<GlobalVector*> const& global_solutions,
34 std::vector<std::vector<GlobalIndexType>> const& indices)
35{
36 if (global_solutions.empty())
37 {
38 return {};
39 }
40
41 std::size_t const local_solutions_size =
42 std::accumulate(cbegin(indices),
43 cend(indices),
44 std::size_t(0),
45 [](GlobalIndexType const size,
46 std::vector<GlobalIndexType> const& process_indices)
47 { return size + process_indices.size(); });
48 std::vector<double> local_solutions;
49 local_solutions.reserve(local_solutions_size);
50
51 int number_of_processes = static_cast<int>(global_solutions.size());
52 for (int process_id = 0; process_id < number_of_processes; ++process_id)
53 {
54 auto values = global_solutions[process_id]->get(indices[process_id]);
55 local_solutions.insert(cend(local_solutions),
56 std::make_move_iterator(begin(values)),
57 std::make_move_iterator(end(values)));
58 }
59 return local_solutions;
60}
61} // namespace ProcessLib
GlobalMatrix::IndexType GlobalIndexType
void setLocalAccessibleVector(PETScVector const &x)
Definition: LinAlg.cpp:27
std::vector< double > getCoupledLocalSolutions(std::vector< GlobalVector * > const &global_solutions, std::vector< std::vector< GlobalIndexType > > const &indices)
std::vector< GlobalVector * > const & coupled_xs
References to the current solutions of the coupled processes.
CoupledSolutionsForStaggeredScheme(std::vector< GlobalVector * > const &coupled_xs_)