22 std::unordered_map<
const DofObject *, std::pair<ADReal, Real>> & dof_to_weighted_gap,
25 const bool normalize_c,
26 const Parallel::Communicator & communicator,
27 const bool send_data_back)
29 libmesh_parallel_only(communicator);
30 const auto our_proc_id = communicator.rank();
33 using Datum = std::tuple<dof_id_type, ADReal, Real>;
34 std::unordered_map<processor_id_type, std::vector<Datum>> push_data;
36 for (
auto & pr : dof_to_weighted_gap)
38 const auto *
const dof_object = pr.first;
39 const auto proc_id = dof_object->processor_id();
40 if (proc_id == our_proc_id)
43 push_data[proc_id].push_back(
44 std::make_tuple(dof_object->id(), std::move(pr.second.first), pr.second.second));
47 const auto & lm_mesh =
mesh.getMesh();
48 std::unordered_map<processor_id_type, std::vector<const DofObject *>>
49 pid_to_dof_object_for_sending_back;
57 &pid_to_dof_object_for_sending_back,
58 send_data_back](
const processor_id_type pid,
const std::vector<Datum> & sent_data)
60 mooseAssert(pid != our_proc_id,
"We do not send messages to ourself here");
61 libmesh_ignore(our_proc_id);
63 for (
auto & [dof_id, weighted_gap, normalization] : sent_data)
65 const auto *
const dof_object = nodal ? cast_ptr<const DofObject *>(lm_mesh.node_ptr(dof_id))
66 : cast_ptr<const DofObject *>(lm_mesh.elem_ptr(dof_id));
67 mooseAssert(dof_object,
"This should be non-null");
69 pid_to_dof_object_for_sending_back[pid].push_back(dof_object);
70 auto & [our_weighted_gap, our_normalization] = dof_to_weighted_gap[dof_object];
71 our_weighted_gap += weighted_gap;
73 our_normalization += normalization;
83 std::unordered_map<processor_id_type, std::vector<Datum>> push_back_data;
85 for (
const auto & [pid, dof_objects] : pid_to_dof_object_for_sending_back)
87 auto & pid_send_data = push_back_data[pid];
88 pid_send_data.reserve(dof_objects.size());
89 for (
const DofObject *
const dof_object : dof_objects)
91 const auto & [our_weighted_gap, our_normalization] =
92 libmesh_map_find(dof_to_weighted_gap, dof_object);
93 pid_send_data.push_back(
94 std::make_tuple(dof_object->id(), our_weighted_gap, our_normalization));
98 auto sent_back_action_functor =
99 [nodal, our_proc_id, &lm_mesh, &dof_to_weighted_gap, &normalize_c](
100 const processor_id_type libmesh_dbg_var(pid),
const std::vector<Datum> & sent_data)
102 mooseAssert(pid != our_proc_id,
"We do not send messages to ourself here");
103 libmesh_ignore(our_proc_id);
105 for (
auto & [dof_id, weighted_gap, normalization] : sent_data)
107 const auto *
const dof_object = nodal ? cast_ptr<const DofObject *>(lm_mesh.node_ptr(dof_id))
108 : cast_ptr<const DofObject *>(lm_mesh.elem_ptr(dof_id));
109 mooseAssert(dof_object,
"This should be non-null");
110 auto & [our_weighted_gap, our_normalization] = dof_to_weighted_gap[dof_object];
111 our_weighted_gap = weighted_gap;
113 our_normalization = normalization;