20 params.addClassDescription(
"Base class for piecewise linear slope reconstruction to get the "
21 "slopes of element average variables.");
27 _rslope(declareRestartableData<std::map<dof_id_type, std::vector<
RealGradient>>>(
28 "reconstructed_slopes")),
29 _avars(declareRestartableData<std::map<dof_id_type, std::vector<Real>>>(
"avg_var_values")),
31 declareRestartableData<std::map<std::pair<dof_id_type, unsigned int>, std::vector<Real>>>(
32 "avg_bnd_var_values")),
33 _side_centroid(declareRestartableData<std::map<std::pair<dof_id_type, dof_id_type>, Point>>(
36 declareRestartableData<std::map<std::pair<dof_id_type, unsigned int>, Point>>(
37 "bnd_side_centroid")),
39 declareRestartableData<std::map<std::pair<dof_id_type, dof_id_type>, Real>>(
"side_area")),
40 _bnd_side_area(declareRestartableData<std::map<std::pair<dof_id_type, unsigned int>, Real>>(
42 _side_normal(declareRestartableData<std::map<std::pair<dof_id_type, dof_id_type>, Point>>(
44 _bnd_side_normal(declareRestartableData<std::map<std::pair<dof_id_type, unsigned int>, Point>>(
46 _q_point_face(_assembly.qPointsFace()),
47 _qrule_face(_assembly.qRuleFace()),
48 _JxW_face(_assembly.JxWFace()),
49 _normals_face(_assembly.normals()),
50 _side(_assembly.side()),
51 _side_elem(_assembly.sideElem()),
52 _side_volume(_assembly.sideElemVolume()),
53 _neighbor_elem(_assembly.neighbor()),
54 _side_geoinfo_cached(false)
72 if (_app.n_processors() > 1)
76 std::vector<std::string> send_buffers(1);
77 std::vector<std::string> recv_buffers;
79 recv_buffers.reserve(_app.n_processors());
81 comm().allgather_packed_range((
void *)(
nullptr),
84 std::back_inserter(recv_buffers));
103 const std::vector<RealGradient> &
106 Threads::spin_mutex::scoped_lock lock(
_mutex);
107 std::map<dof_id_type, std::vector<RealGradient>>::const_iterator pos =
_rslope.find(elementid);
111 "Reconstructed slope is not cached for element id '", elementid,
"' in ", __FUNCTION__);
116 const std::vector<Real> &
119 Threads::spin_mutex::scoped_lock lock(
_mutex);
120 std::map<dof_id_type, std::vector<Real>>::const_iterator pos =
_avars.find(elementid);
123 mooseError(
"Average variable values are not cached for element id '",
131 const std::vector<Real> &
134 Threads::spin_mutex::scoped_lock lock(
_mutex);
135 std::map<std::pair<dof_id_type, unsigned int>, std::vector<Real>>::const_iterator pos =
136 _bnd_avars.find(std::pair<dof_id_type, unsigned int>(elementid, side));
139 mooseError(
"Average variable values are not cached for element id '",
152 Threads::spin_mutex::scoped_lock lock(
_mutex);
153 std::map<std::pair<dof_id_type, dof_id_type>, Point>::const_iterator pos =
154 _side_centroid.find(std::pair<dof_id_type, dof_id_type>(elementid, neighborid));
157 mooseError(
"Side centroid values are not cached for element id '",
159 "' and neighbor id '",
170 Threads::spin_mutex::scoped_lock lock(
_mutex);
171 std::map<std::pair<dof_id_type, unsigned int>, Point>::const_iterator pos =
175 mooseError(
"Boundary side centroid values are not cached for element id '",
188 Threads::spin_mutex::scoped_lock lock(
_mutex);
189 std::map<std::pair<dof_id_type, dof_id_type>, Point>::const_iterator pos =
190 _side_normal.find(std::pair<dof_id_type, dof_id_type>(elementid, neighborid));
193 mooseError(
"Side normal values are not cached for element id '",
195 "' and neighbor id '",
206 Threads::spin_mutex::scoped_lock lock(
_mutex);
207 std::map<std::pair<dof_id_type, unsigned int>, Point>::const_iterator pos =
208 _bnd_side_normal.find(std::pair<dof_id_type, unsigned int>(elementid, side));
211 mooseError(
"Boundary side normal values are not cached for element id '",
224 Threads::spin_mutex::scoped_lock lock(
_mutex);
225 std::map<std::pair<dof_id_type, dof_id_type>, Real>::const_iterator pos =
226 _side_area.find(std::pair<dof_id_type, dof_id_type>(elementid, neighborid));
229 mooseError(
"Side area values are not cached for element id '",
231 "' and neighbor id '",
242 Threads::spin_mutex::scoped_lock lock(
_mutex);
243 std::map<std::pair<dof_id_type, unsigned int>, Real>::const_iterator pos =
244 _bnd_side_area.find(std::pair<dof_id_type, unsigned int>(elementid, side));
247 mooseError(
"Boundary side area values are not cached for element id '",
266 std::ostringstream oss;
270 oss.write((
char *)&size,
sizeof(size));
274 storeHelper(oss, *it,
this);
275 storeHelper(oss,
_rslope[*it],
this);
279 serialized_buffer.assign(oss.str());
286 std::istringstream iss;
288 mooseAssert(serialized_buffers.size() == _app.n_processors(),
289 "Unexpected size of serialized_buffers: " << serialized_buffers.size());
291 for (
auto rank = decltype(_app.n_processors())(0); rank < serialized_buffers.size(); ++rank)
293 if (rank == processor_id())
296 iss.str(serialized_buffers[rank]);
301 unsigned int size = 0;
302 iss.read((
char *)&size,
sizeof(size));
304 for (
unsigned int i = 0; i < size; i++)
307 loadHelper(iss, key,
this);
309 std::vector<RealGradient> value;
310 loadHelper(iss, value,
this);
313 _rslope.insert(std::pair<dof_id_type, std::vector<RealGradient>>(key, value));