https://mooseframework.inl.gov
AugmentSparsityBetweenElements.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 #include "libmesh/elem.h"
12 
14 
15 using namespace libMesh;
16 
19 {
21  params.addRequiredParam<std::map<dof_id_type, std::vector<dof_id_type>> *>(
22  "_elem_map", "Element to element augmentation map");
23  return params;
24 }
25 
27  : RelationshipManager(params),
28  _elem_map(*getParam<std::map<dof_id_type, std::vector<dof_id_type>> *>("_elem_map"))
29 {
30 }
31 
33  const AugmentSparsityBetweenElements & other)
34  : RelationshipManager(other), _elem_map(other._elem_map)
35 {
36 }
37 
38 std::unique_ptr<GhostingFunctor>
40 {
41  return _app.getFactory().clone(*this);
42 }
43 
44 void
46 {
48 }
49 
50 void
52 {
53 }
54 
55 void
57 {
58 }
59 
60 std::string
62 {
63  std::ostringstream oss;
64  oss << "AugmentSparsityBetweenElements";
65  return oss.str();
66 }
67 
68 void
69 AugmentSparsityBetweenElements::operator()(const MeshBase::const_element_iterator & range_begin,
70  const MeshBase::const_element_iterator & range_end,
72  map_type & coupled_elements)
73 {
74  const CouplingMatrix * const null_mat = libmesh_nullptr;
75  for (const auto & elem : as_range(range_begin, range_end))
76  {
77  auto it = _elem_map.find(elem->id());
78  if (it != _elem_map.end())
79  {
80  for (auto & coupled_elem_id : it->second)
81  {
82  auto coupled_elem = _moose_mesh->elemPtr(coupled_elem_id);
83  if (coupled_elem->processor_id() != p)
84  coupled_elements.insert(std::make_pair(coupled_elem, null_mat));
85  }
86  }
87  }
88 }
89 
90 bool
92 {
93  const auto * const rm = dynamic_cast<const AugmentSparsityBetweenElements *>(&rhs);
94  if (!rm)
95  return false;
96 
97  return (_elem_map == rm->_elem_map) && baseGreaterEqual(rhs);
98 }
virtual void mesh_reinit()
virtual bool operator>=(const RelationshipManager &rhs) const override
virtual Elem * elemPtr(const dof_id_type i)
MooseMesh * _moose_mesh
std::map< const Elem *, const CouplingMatrix *, CompareDofObjectsByPIDAndThenID > map_type
virtual void internalInitWithMesh(const MeshBase &) override
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
void addRequiredParam(const std::string &name, const std::string &doc_string)
Factory & getFactory()
uint8_t processor_id_type
registerMooseObject("ThermalHydraulicsApp", AugmentSparsityBetweenElements)
const std::map< dof_id_type, std::vector< dof_id_type > > & _elem_map
Map of element ghosting. Element IDs linked to list of element IDs that they are connected to...
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
AugmentSparsityBetweenElements(const InputParameters &)
virtual void operator()(const MeshBase::const_element_iterator &range_begin, const MeshBase::const_element_iterator &range_end, processor_id_type p, map_type &coupled_elements) override
virtual bool baseGreaterEqual(const RelationshipManager &rhs) const
static InputParameters validParams()
virtual std::unique_ptr< GhostingFunctor > clone() const override
Relationship manager to add ghosting between elements.
uint8_t dof_id_type