Line data Source code
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 : 10 : #include "AugmentSparsityBetweenElements.h" 11 : #include "libmesh/elem.h" 12 : 13 : registerMooseObject("ThermalHydraulicsApp", AugmentSparsityBetweenElements); 14 : 15 : using namespace libMesh; 16 : 17 : InputParameters 18 15431 : AugmentSparsityBetweenElements::validParams() 19 : { 20 15431 : InputParameters params = RelationshipManager::validParams(); 21 30862 : params.addRequiredParam<std::map<dof_id_type, std::vector<dof_id_type>> *>( 22 : "_elem_map", "Element to element augmentation map"); 23 15431 : return params; 24 0 : } 25 : 26 11531 : AugmentSparsityBetweenElements::AugmentSparsityBetweenElements(const InputParameters & params) 27 : : RelationshipManager(params), 28 23062 : _elem_map(*getParam<std::map<dof_id_type, std::vector<dof_id_type>> *>("_elem_map")) 29 : { 30 11531 : } 31 : 32 0 : AugmentSparsityBetweenElements::AugmentSparsityBetweenElements( 33 0 : const AugmentSparsityBetweenElements & other) 34 0 : : RelationshipManager(other), _elem_map(other._elem_map) 35 : { 36 0 : } 37 : 38 : std::unique_ptr<GhostingFunctor> 39 7631 : AugmentSparsityBetweenElements::clone() const 40 : { 41 15262 : return _app.getFactory().clone(*this); 42 : } 43 : 44 : void 45 3940 : AugmentSparsityBetweenElements::mesh_reinit() 46 : { 47 : RelationshipManager::mesh_reinit(); 48 3940 : } 49 : 50 : void 51 3952 : AugmentSparsityBetweenElements::redistribute() 52 : { 53 3952 : } 54 : 55 : void 56 11362 : AugmentSparsityBetweenElements::internalInitWithMesh(const MeshBase &) 57 : { 58 11362 : } 59 : 60 : std::string 61 0 : AugmentSparsityBetweenElements::getInfo() const 62 : { 63 0 : std::ostringstream oss; 64 0 : oss << "AugmentSparsityBetweenElements"; 65 0 : return oss.str(); 66 0 : } 67 : 68 : void 69 271681 : AugmentSparsityBetweenElements::operator()(const MeshBase::const_element_iterator & range_begin, 70 : const MeshBase::const_element_iterator & range_end, 71 : processor_id_type p, 72 : map_type & coupled_elements) 73 : { 74 : const CouplingMatrix * const null_mat = libmesh_nullptr; 75 1994826 : for (const auto & elem : as_range(range_begin, range_end)) 76 : { 77 725732 : auto it = _elem_map.find(elem->id()); 78 725732 : if (it != _elem_map.end()) 79 : { 80 145404 : for (auto & coupled_elem_id : it->second) 81 : { 82 81954 : auto coupled_elem = _moose_mesh->elemPtr(coupled_elem_id); 83 81954 : if (coupled_elem->processor_id() != p) 84 48708 : coupled_elements.insert(std::make_pair(coupled_elem, null_mat)); 85 : } 86 : } 87 271681 : } 88 271681 : } 89 : 90 : bool 91 7848 : AugmentSparsityBetweenElements::operator>=(const RelationshipManager & rhs) const 92 : { 93 7848 : const auto * const rm = dynamic_cast<const AugmentSparsityBetweenElements *>(&rhs); 94 7848 : if (!rm) 95 : return false; 96 : 97 0 : return (_elem_map == rm->_elem_map) && baseGreaterEqual(rhs); 98 : }