https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
17{
19 params.addRequiredParam<std::map<dof_id_type, std::vector<dof_id_type>> *>(
20 "_elem_map", "Element to element augmentation map");
21 return params;
22}
23
25 : RelationshipManager(params),
26 _elem_map(*getParam<std::map<dof_id_type, std::vector<dof_id_type>> *>("_elem_map"))
27{
28}
29
35
36std::unique_ptr<libMesh::GhostingFunctor>
38{
39 return _app.getFactory().clone(*this);
40}
41
42void
47
48void
52
53void
57
58std::string
60{
61 std::ostringstream oss;
62 oss << "AugmentSparsityBetweenElements";
63 return oss.str();
64}
65
66void
67AugmentSparsityBetweenElements::operator()(const MeshBase::const_element_iterator & range_begin,
68 const MeshBase::const_element_iterator & range_end,
69 processor_id_type p,
70 map_type & coupled_elements)
71{
72 const libMesh::CouplingMatrix * const null_mat = libmesh_nullptr;
73 for (const auto & elem : as_range(range_begin, range_end))
74 {
75 auto it = _elem_map.find(elem->id());
76 if (it != _elem_map.end())
77 {
78 for (auto & coupled_elem_id : it->second)
79 {
80 auto coupled_elem = _moose_mesh->elemPtr(coupled_elem_id);
81 if (coupled_elem->processor_id() != p)
82 coupled_elements.insert(std::make_pair(coupled_elem, null_mat));
83 }
84 }
85 }
86}
87
88bool
90{
91 const auto * const rm = dynamic_cast<const AugmentSparsityBetweenElements *>(&rhs);
92 if (!rm)
93 return false;
94
95 return (_elem_map == rm->_elem_map) && baseGreaterEqual(rhs);
96}
registerMooseObject("ThermalHydraulicsApp", AugmentSparsityBetweenElements)
const Real p
Relationship manager to add ghosting between elements.
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
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.
AugmentSparsityBetweenElements(const InputParameters &)
virtual void internalInitWithMesh(const MeshBase &) override
virtual std::unique_ptr< GhostingFunctor > clone() const override
virtual bool operator>=(const RelationshipManager &rhs) const override
std::unique_ptr< T > clone(const T &object)
void addRequiredParam(const std::string &name, const std::string &doc_string)
Factory & getFactory()
virtual Elem * elemPtr(const dof_id_type i)
virtual bool baseGreaterEqual(const RelationshipManager &rhs) const
static InputParameters validParams()
MooseMesh * _moose_mesh
std::map< const Elem *, const CouplingMatrix *, CompareDofObjectsByPIDAndThenID > map_type
virtual void mesh_reinit()