OGS
AssemblyData.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
4#include "AssemblyData.h"
5
6#include <range/v3/algorithm/is_sorted.hpp>
7#include <range/v3/algorithm/set_algorithm.hpp>
8#include <range/v3/algorithm/sort.hpp>
9
11{
12std::shared_ptr<std::vector<std::size_t> const>
14 std::vector<std::size_t> const* const sorted_element_subset) const
15{
16 if (!sorted_element_subset)
17 {
19 }
20
21 assert(ranges::is_sorted(*sorted_element_subset));
22
24 {
25 // We do not own sorted_element_subset, so the returned data must not be
26 // deleted by us.
27 auto do_not_delete = [](auto*) {};
28 return {sorted_element_subset, do_not_delete};
29 }
30
31 // Final case: there are both some deactivated elements and a further
32 // subselection by sorted_element_subset.
33
34 // TODO frequent re-computations might occur here. Optimization potential.
35 auto aeis = std::make_shared<std::vector<std::size_t>>();
36 aeis->reserve(std::min(sorted_active_element_ids_->size(),
37 sorted_element_subset->size()));
38
39 ranges::set_intersection(*sorted_active_element_ids_,
40 *sorted_element_subset, std::back_inserter(*aeis));
41 return aeis;
42}
43
45{
46 // A nullptr means all elements are active.
48}
49
51 std::vector<std::size_t> const& sorted_active_element_ids_whole_mesh)
52{
53 assert(ranges::is_sorted(sorted_active_element_ids_whole_mesh));
54
56 std::make_shared<std::vector<std::size_t> const>(
57 sorted_active_element_ids_whole_mesh);
58}
59
61 MeshLib::Mesh const& submesh,
62 std::vector<
63 std::vector<std::reference_wrapper<MeshLib::PropertyVector<double>>>>&&
66 bulk_node_ids{*MeshLib::bulkNodeIDs(submesh)},
67 bulk_element_ids{*MeshLib::bulkElementIDs(submesh)}
68{
69}
70
72{
73 std::vector<std::size_t> aeis;
74 aeis.insert(aeis.end(), bulk_element_ids.begin(), bulk_element_ids.end());
75 ranges::sort(aeis);
77 std::make_shared<std::vector<std::size_t> const>(std::move(aeis));
78}
79
81 std::vector<std::size_t> const& sorted_active_element_ids_whole_mesh)
82{
83 assert(ranges::is_sorted(sorted_active_element_ids_whole_mesh));
84
85 std::vector<std::size_t> aeis;
86
87 ranges::set_intersection(bulk_element_ids,
88 sorted_active_element_ids_whole_mesh,
89 std::back_inserter(aeis));
90
92 std::make_shared<std::vector<std::size_t> const>(std::move(aeis));
93}
94} // namespace ProcessLib::Assembly
void setElementSelectionActive(std::vector< std::size_t > const &sorted_active_element_ids_whole_mesh)
Assembly should proceed on the passed element IDs only.
void setAllElementsActive()
Assembly should proceed on all mesh elements.
std::shared_ptr< std::vector< std::size_t > const > sorted_active_element_ids_
CommonAssemblyData(std::vector< std::vector< std::reference_wrapper< MeshLib::PropertyVector< double > > > > &&residuum_vectors)
std::shared_ptr< std::vector< std::size_t > const > activeElementIDsSorted(std::vector< std::size_t > const *const sorted_element_subset) const
std::vector< std::vector< std::reference_wrapper< MeshLib::PropertyVector< double > > > > residuum_vectors
Residuum vectors for each process ID.
SubmeshAssemblyData(MeshLib::Mesh const &submesh, std::vector< std::vector< std::reference_wrapper< MeshLib::PropertyVector< double > > > > &&residuum_vectors)
void setAllElementsActive()
Assembly should proceed on all elements of this submesh.
MeshLib::PropertyVector< std::size_t > const & bulk_element_ids
void setElementSelectionActive(std::vector< std::size_t > const &sorted_active_element_ids_whole_mesh)
MeshLib::PropertyVector< std::size_t > const & bulk_node_ids