72 const processor_id_type pid =
mesh.processor_id();
83 std::set<const Elem *> elems_being_migrated;
85 if (mat_prop_store->hasStatefulProperties())
89 "This routine has not been implemented for threads. Please query this routine before "
90 "a threaded region or contact a MOOSE developer to discuss.");
92 for (
const auto state : mat_prop_store->stateIndexRange())
95 typedef std::unordered_map<unsigned int, std::string> stored_props_type;
96 typedef std::tuple<stored_props_type, dof_id_type, int> stored_elem_type;
97 std::map<processor_id_type, std::vector<stored_elem_type>> props_to_push;
100 for (
auto & [elem, elem_props_map] : props_map)
103 mooseAssert(elem,
"Null element found in material property map?");
107 mooseAssert(elem->id() <
mesh.max_elem_id(),
108 "Invalid (dangling? corrupted?) element in material property map?");
109 mooseAssert(elem->processor_id() <
mesh.n_processors(),
110 "Invalid (corrupted?) element in material property map?");
115 if (elem !=
mesh.query_elem_ptr(elem->id()))
118 std::set<processor_id_type> target_pids;
121 target_pids.insert(elem->processor_id());
122 else if (elem->subactive())
124 mooseAssert(elem->parent(),
125 "Invalid (corrupted?) subactive element in material property map");
126 mooseAssert(elem->parent()->refinement_flag() == Elem::JUST_COARSENED,
127 "Invalid (subactive child of not-just-coarsened) element in material "
129 target_pids.insert(elem->parent()->processor_id());
133 mooseAssert(elem->ancestor(),
134 "Unexpected relationship for element in material property map?");
135 mooseAssert(elem->has_children(),
136 "Ancestor element with no children in material property map?");
137 for (
const Elem & child : elem->child_ref_range())
138 target_pids.insert(child.processor_id());
143 bool remote_pid =
false, local_pid =
false;
144 for (processor_id_type target_pid : target_pids)
145 if (target_pid == pid)
151 stored_props_type stored_props;
152 unsigned int n_q_points = 0;
153 for (
auto & [prop_id, prop_vals] : elem_props_map)
155 mooseAssert(!prop_vals.empty(),
156 "Empty MaterialProperties in stateful properties map?");
158 for (
const auto & prop : prop_vals)
159 n_q_points = std::max(n_q_points, prop.size());
161 std::ostringstream oss;
163 stored_props[prop_id] = oss.str();
168 props_to_push[target_pid].emplace_back(
169 std::move(stored_props), elem->id(), n_q_points);
172 if (remote_pid && !local_pid)
173 elems_being_migrated.insert(elem);
176 auto recv_functor = [&, mat_prop_store_ptr = mat_prop_store](
177 processor_id_type,
const std::vector<stored_elem_type> & data)
179 for (
const auto & [elem_hash, elem_id, n_q_points] : data)
181 const Elem * elem =
mesh.elem_ptr(elem_id);
182 auto & elem_props = props_map[elem];
184 for (
const auto & [prop_id, prop_str] : elem_hash)
193 mat_prop_store_ptr->initProps(0, state, elem, prop_id, n_q_points);
195 mooseAssert(elem_props.contains(prop_id),
196 "Trying to load into a nonexistant property id?");
198 std::istringstream iss(prop_str);
204 Parallel::push_parallel_vector_data(
mesh.comm(), props_to_push, recv_functor);
208 for (
const Elem * elem : elems_being_migrated)
209 mat_prop_store->eraseProperty(elem);