13#include <range/v3/view/enumerate.hpp>
14#include <range/v3/view/for_each.hpp>
15#include <range/v3/view/transform.hpp>
16#include <range/v3/view/zip.hpp>
17#include <unordered_set>
27 std::vector<std::vector<std::string>>
const& per_process_residuum_names,
29 std::vector<std::reference_wrapper<ProcessLib::ProcessVariable>>>
const&
32 if (per_process_pvs.size() != per_process_residuum_names.size())
35 "The number of passed residuum names ({}) does not match the "
36 "number of processes ({}).",
37 per_process_residuum_names.size(), per_process_pvs.size());
40 auto check_sizes = [](std::size_t
const process_id,
auto const& rns_pvs)
42 auto const& [rns, pvs] = rns_pvs;
44 if (rns.size() != pvs.size())
47 "The number of passed residuum names ({}) does not match the "
48 "number of process variables ({}) for process {}.",
49 rns.size(), pvs.size(), process_id);
52 for (
auto const& [process_id, rns_pvs] :
53 ranges::views::zip(per_process_residuum_names, per_process_pvs) |
54 ranges::views::enumerate)
56 check_sizes(process_id, rns_pvs);
61 std::vector<std::reference_wrapper<MeshLib::PropertyVector<double>>>>
64 std::vector<std::vector<std::string>>
const& per_process_residuum_names,
66 std::vector<std::reference_wrapper<ProcessLib::ProcessVariable>>>
const&
72 auto create_mesh_property_for_residuum =
73 [&mesh](std::pair<std::string
const&,
75 residuum_name_process_variable)
78 auto const& [rn, pv] = residuum_name_process_variable;
81 pv.getNumberOfGlobalComponents());
84 auto create_mesh_properties =
85 [&create_mesh_property_for_residuum](
auto const& rns_pvs)
87 auto const& [rns, pvs] = rns_pvs;
88 return ranges::views::zip(rns, pvs) |
89 ranges::views::transform(create_mesh_property_for_residuum) |
90 ranges::to<std::vector<
91 std::reference_wrapper<MeshLib::PropertyVector<double>>>>;
94 return ranges::views::zip(per_process_residuum_names, per_process_pvs) |
95 ranges::views::transform(create_mesh_properties) |
96 ranges::to<std::vector<std::vector<
97 std::reference_wrapper<MeshLib::PropertyVector<double>>>>>;
108 : bulk_element_ids{*
MeshLib::bulkElementIDs(mesh)},
109 bulk_node_ids{*
MeshLib::bulkNodeIDs(mesh)},
110 residuum_vectors{std::move(residuum_vectors)}
116 std::vector<std::reference_wrapper<MeshLib::Mesh>>
const& submeshes,
117 std::vector<std::vector<std::string>>
const& residuum_names,
118 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
const&
121 DBUG(
"AssemblyMixinBase initializeSubmeshOutput().");
124 for (
auto& mesh_ref : submeshes)
126 auto& mesh = mesh_ref.get();
129 mesh, createResiduumVectors(mesh, residuum_names, pvs));
133 createResiduumVectors(bulk_mesh, residuum_names, pvs);
138 DBUG(
"AssemblyMixin updateActiveElements().");
169 DBUG(
"AssemblyMixinBase updateActiveElementsImpl().");
174 active_element_ids.empty()
185 sad.active_element_ids = sad.bulk_element_ids;
192 std::unordered_set<std::size_t> active_element_ids_set(
193 active_element_ids.begin(), active_element_ids.end());
197 auto& aeis = sad.active_element_ids;
198 auto& beis = sad.bulk_element_ids;
200 aeis.reserve(beis.getNumberOfTuples());
202 for (
auto bei : beis)
204 if (active_element_ids_set.contains(bei))
221 for (std::size_t variable_id = 0; variable_id < residuum_vectors.size();
224 transformVariableFromGlobalVector(
225 rhs, variable_id, local_to_global_index_map,
226 residuum_vectors[variable_id].get(), std::negate<double>());
231 int const process_id,
237 for (std::size_t variable_id = 0; variable_id < residuum_vectors.size();
240 transformVariableFromGlobalVector(
241 rhs, variable_id, local_to_global_index_map,
243 std::negate<double>());
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Global vector based on Eigen vector.
void initializeAssemblyOnSubmeshes(MeshLib::Mesh &bulk_mesh, std::vector< std::reference_wrapper< MeshLib::Mesh > > const &submeshes, std::vector< std::vector< std::string > > const &residuum_names, std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > const &pvs)
static void copyResiduumVectorsToBulkMesh(GlobalVector const &rhs, NumLib::LocalToGlobalIndexMap const &local_to_global_index_map, std::vector< std::reference_wrapper< MeshLib::PropertyVector< double > > > residuum_vectors)
@ NO_DEACTIVATED_SUBDOMAINS
@ HAS_DEACTIVATED_SUBDOMAINS
void updateActiveElementsImpl(Process const &process)
ActiveElementIDsState ids_state_
void updateActiveElements(ProcessLib::Process const &process)
static void copyResiduumVectorsToSubmesh(int const process_id, GlobalVector const &rhs, NumLib::LocalToGlobalIndexMap const &local_to_global_index_map, SubmeshAssemblyData const &sad)
std::vector< SubmeshAssemblyData > submesh_assembly_data_
std::vector< std::vector< std::reference_wrapper< MeshLib::PropertyVector< double > > > > residuum_vectors_bulk_
std::vector< std::size_t > const & getActiveElementIDs() const
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)
void checkResiduumNamesVsProcessVariables(std::vector< std::vector< std::string > > const &per_process_residuum_names, std::vector< std::vector< std::reference_wrapper< ProcessLib::ProcessVariable > > > const &per_process_pvs)
std::vector< std::vector< std::reference_wrapper< MeshLib::PropertyVector< double > > > > createResiduumVectors(MeshLib::Mesh &mesh, std::vector< std::vector< std::string > > const &per_process_residuum_names, std::vector< std::vector< std::reference_wrapper< ProcessLib::ProcessVariable > > > const &per_process_pvs)
std::vector< std::vector< std::reference_wrapper< MeshLib::PropertyVector< double > > > > residuum_vectors
MeshLib::PropertyVector< std::size_t > const & bulk_node_ids
SubmeshAssemblyData(MeshLib::Mesh const &mesh, std::vector< std::vector< std::reference_wrapper< MeshLib::PropertyVector< double > > > > &&residuum_vectors)