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 "ProxyRelationshipManager.h" 11 : #include "MooseApp.h" 12 : 13 : #include "libmesh/system.h" 14 : #include "libmesh/elem.h" 15 : #include "libmesh/dof_map.h" 16 : 17 : using namespace libMesh; 18 : 19 : registerMooseObject("MooseApp", ProxyRelationshipManager); 20 : 21 : InputParameters 22 47273 : ProxyRelationshipManager::validParams() 23 : { 24 47273 : InputParameters params = RelationshipManager::validParams(); 25 : 26 47273 : params.addRequiredParam<System *>("other_system", 27 : "The libMesh system to mirror the ghosting from"); 28 : 29 47273 : return params; 30 0 : } 31 : 32 8252 : ProxyRelationshipManager::ProxyRelationshipManager(const InputParameters & parameters) 33 8252 : : RelationshipManager(parameters), _other_system(getCheckedPointerParam<System *>("other_system")) 34 : { 35 8252 : } 36 : 37 16504 : ProxyRelationshipManager::ProxyRelationshipManager(const ProxyRelationshipManager & others) 38 16504 : : RelationshipManager(others), _other_system(others._other_system) 39 : { 40 16504 : } 41 : 42 : void 43 15688 : ProxyRelationshipManager::operator()(const MeshBase::const_element_iterator & /*range_begin*/, 44 : const MeshBase::const_element_iterator & /*range_end*/, 45 : processor_id_type p, 46 : map_type & coupled_elements) 47 : { 48 15688 : auto & other_mesh = _other_system->get_mesh(); 49 : 50 15688 : auto other_elements_begin = other_mesh.active_local_elements_begin(); 51 15688 : auto other_elements_end = other_mesh.active_local_elements_end(); 52 : 53 15688 : map_type other_coupled_elements; 54 : 55 : // If we're geometric - run all the geometric ghosting functors from the other system 56 15688 : if (isType(Moose::RelationshipManagerType::GEOMETRIC)) 57 : { 58 0 : auto gf_it = other_mesh.ghosting_functors_begin(); 59 0 : const auto gf_end = other_mesh.ghosting_functors_end(); 60 : 61 0 : for (; gf_it != gf_end; ++gf_it) 62 0 : if (!dynamic_cast<ProxyRelationshipManager *>(*gf_it)) // Don't recurse! 63 0 : (*(*gf_it))(other_elements_begin, other_elements_end, p, other_coupled_elements); 64 : } 65 : 66 : // If we're algebraic - run all the algebraic ghosting functors from the other system 67 15688 : if (isType(Moose::RelationshipManagerType::ALGEBRAIC)) 68 : { 69 15688 : auto gf_it = _other_system->get_dof_map().algebraic_ghosting_functors_begin(); 70 15688 : const auto gf_end = _other_system->get_dof_map().algebraic_ghosting_functors_end(); 71 : 72 55404 : for (; gf_it != gf_end; ++gf_it) 73 39716 : if (!dynamic_cast<ProxyRelationshipManager *>(*gf_it)) // Don't recurse! 74 8340 : (*(*gf_it))(other_elements_begin, other_elements_end, p, other_coupled_elements); 75 : } 76 : 77 : // Build unique_id to elem map 78 15688 : std::map<dof_id_type, const Elem *> unique_id_to_elem_map; 79 : 80 15688 : for (auto elem_it = _moose_mesh->getMesh().active_elements_begin(); 81 3212736 : elem_it != _moose_mesh->getMesh().active_elements_end(); 82 3197048 : ++elem_it) 83 3212736 : unique_id_to_elem_map[(*elem_it)->unique_id()] = *elem_it; 84 : 85 : // Now translate those back into elements in this system 86 15688 : for (auto other_coupled_it = other_coupled_elements.begin(); 87 101072 : other_coupled_it != other_coupled_elements.end(); 88 85384 : ++other_coupled_it) 89 : { 90 85384 : auto other_system_elem = other_coupled_it->first; 91 : 92 85384 : auto unique_id_to_elem_map_it = unique_id_to_elem_map.find(other_system_elem->unique_id()); 93 : mooseAssert(unique_id_to_elem_map_it != unique_id_to_elem_map.end(), "no matching unique id"); 94 : 95 85384 : coupled_elements.emplace(unique_id_to_elem_map_it->second, other_coupled_it->second); 96 : } 97 15688 : } 98 : 99 : std::string 100 40 : ProxyRelationshipManager::getInfo() const 101 : { 102 40 : std::string info = std::string("Proxy for ") + _other_system->name(); 103 : 104 40 : if (useDisplacedMesh()) 105 20 : info = info + " on displaced"; 106 : 107 40 : return info; 108 0 : } 109 : 110 : bool 111 48344 : ProxyRelationshipManager::operator>=(const RelationshipManager & /*rhs*/) const 112 : { 113 : // There isn't a need to determine these because only the correct ones will be added 114 48344 : return false; 115 : } 116 : 117 : std::unique_ptr<GhostingFunctor> 118 16504 : ProxyRelationshipManager::clone() const 119 : { 120 16504 : return _app.getFactory().copyConstruct(*this); 121 : }