Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
ProxyRelationshipManager.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 "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 
20 
23 {
25 
26  params.addRequiredParam<System *>("other_system",
27  "The libMesh system to mirror the ghosting from");
28 
29  return params;
30 }
31 
33  : RelationshipManager(parameters), _other_system(getCheckedPointerParam<System *>("other_system"))
34 {
35 }
36 
38  : RelationshipManager(others), _other_system(others._other_system)
39 {
40 }
41 
42 void
43 ProxyRelationshipManager::operator()(const MeshBase::const_element_iterator & /*range_begin*/,
44  const MeshBase::const_element_iterator & /*range_end*/,
46  map_type & coupled_elements)
47 {
48  auto & other_mesh = _other_system->get_mesh();
49 
50  auto other_elements_begin = other_mesh.active_local_elements_begin();
51  auto other_elements_end = other_mesh.active_local_elements_end();
52 
53  map_type other_coupled_elements;
54 
55  // If we're geometric - run all the geometric ghosting functors from the other system
57  {
58  auto gf_it = other_mesh.ghosting_functors_begin();
59  const auto gf_end = other_mesh.ghosting_functors_end();
60 
61  for (; gf_it != gf_end; ++gf_it)
62  if (!dynamic_cast<ProxyRelationshipManager *>(*gf_it)) // Don't recurse!
63  (*(*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
68  {
71 
72  for (; gf_it != gf_end; ++gf_it)
73  if (!dynamic_cast<ProxyRelationshipManager *>(*gf_it)) // Don't recurse!
74  (*(*gf_it))(other_elements_begin, other_elements_end, p, other_coupled_elements);
75  }
76 
77  // Build unique_id to elem map
78  std::map<dof_id_type, const Elem *> unique_id_to_elem_map;
79 
80  for (auto elem_it = _moose_mesh->getMesh().active_elements_begin();
81  elem_it != _moose_mesh->getMesh().active_elements_end();
82  ++elem_it)
83  unique_id_to_elem_map[(*elem_it)->unique_id()] = *elem_it;
84 
85  // Now translate those back into elements in this system
86  for (auto other_coupled_it = other_coupled_elements.begin();
87  other_coupled_it != other_coupled_elements.end();
88  ++other_coupled_it)
89  {
90  auto other_system_elem = other_coupled_it->first;
91 
92  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  coupled_elements.emplace(unique_id_to_elem_map_it->second, other_coupled_it->second);
96  }
97 }
98 
99 std::string
101 {
102  std::string info = std::string("Proxy for ") + _other_system->name();
103 
104  if (useDisplacedMesh())
105  info = info + " on displaced";
106 
107  return info;
108 }
109 
110 bool
112 {
113  // There isn't a need to determine these because only the correct ones will be added
114  return false;
115 }
116 
117 std::unique_ptr<GhostingFunctor>
119 {
120  return _app.getFactory().copyConstruct(*this);
121 }
MPI_Info info
MooseMesh * _moose_mesh
Pointer to the MooseMesh object.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::map< const Elem *, const CouplingMatrix *, CompareDofObjectsByPIDAndThenID > map_type
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
const MeshBase & get_mesh() const
registerMooseObject("MooseApp", ProxyRelationshipManager)
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
Definition: MooseApp.h:434
virtual void operator()(const MeshBase::const_element_iterator &, const MeshBase::const_element_iterator &, processor_id_type p, map_type &coupled_elements) override
uint8_t processor_id_type
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3417
virtual bool operator>=(const RelationshipManager &) const override
Whether this relationship manager provides more or the same amount and type of ghosting as the rhs...
ProxyRelationshipManager(const InputParameters &parameters)
virtual std::unique_ptr< GhostingFunctor > clone() const override
A clone() is needed because GhostingFunctor can not be shared between different meshes.
bool isType(const Moose::RelationshipManagerType &type) const
Check to see if an RM is of a given type.
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:84
virtual std::string getInfo() const override
Method for returning relationship manager information (suitable for console output).
std::set< GhostingFunctor *>::const_iterator algebraic_ghosting_functors_end() const
std::set< GhostingFunctor *>::const_iterator ghosting_functors_begin() const
RelationshipManagers are used for describing what kinds of non-local resources are needed for an obje...
static InputParameters validParams()
static InputParameters validParams()
bool useDisplacedMesh() const
Whether this should be placed on the undisplaced or displaced systems.
const std::string & name() const
std::set< GhostingFunctor *>::const_iterator algebraic_ghosting_functors_begin() const
const DofMap & get_dof_map() const
Intermediate base class for RelationshipManagers that are simply built using ghosting functors...