https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
18
21{
23
24 params.addRequiredParam<System *>("other_system",
25 "The libMesh system to mirror the ghosting from");
26
27 return params;
28}
29
31 : RelationshipManager(parameters), _other_system(getCheckedPointerParam<System *>("other_system"))
32{
33}
34
36 : RelationshipManager(others), _other_system(others._other_system)
37{
38}
39
40void
41ProxyRelationshipManager::operator()(const MeshBase::const_element_iterator & /*range_begin*/,
42 const MeshBase::const_element_iterator & /*range_end*/,
43 processor_id_type p,
44 map_type & coupled_elements)
45{
46 auto & other_mesh = _other_system->get_mesh();
47
48 auto other_elements_begin = other_mesh.active_local_elements_begin();
49 auto other_elements_end = other_mesh.active_local_elements_end();
50
51 map_type other_coupled_elements;
52
53 // If we're geometric - run all the geometric ghosting functors from the other system
55 {
56 auto gf_it = other_mesh.ghosting_functors_begin();
57 const auto gf_end = other_mesh.ghosting_functors_end();
58
59 for (; gf_it != gf_end; ++gf_it)
60 if (!dynamic_cast<ProxyRelationshipManager *>(*gf_it)) // Don't recurse!
61 (*(*gf_it))(other_elements_begin, other_elements_end, p, other_coupled_elements);
62 }
63
64 // If we're algebraic - run all the algebraic ghosting functors from the other system
66 {
69
70 for (; gf_it != gf_end; ++gf_it)
71 if (!dynamic_cast<ProxyRelationshipManager *>(*gf_it)) // Don't recurse!
72 (*(*gf_it))(other_elements_begin, other_elements_end, p, other_coupled_elements);
73 }
74
75 // Build unique_id to elem map
76 std::map<dof_id_type, const Elem *> unique_id_to_elem_map;
77
78 for (auto elem_it = _moose_mesh->getMesh().active_elements_begin();
79 elem_it != _moose_mesh->getMesh().active_elements_end();
80 ++elem_it)
81 unique_id_to_elem_map[(*elem_it)->unique_id()] = *elem_it;
82
83 // Now translate those back into elements in this system
84 for (auto other_coupled_it = other_coupled_elements.begin();
85 other_coupled_it != other_coupled_elements.end();
86 ++other_coupled_it)
87 {
88 auto other_system_elem = other_coupled_it->first;
89
90 auto unique_id_to_elem_map_it = unique_id_to_elem_map.find(other_system_elem->unique_id());
91 mooseAssert(unique_id_to_elem_map_it != unique_id_to_elem_map.end(), "no matching unique id");
92
93 coupled_elements.emplace(unique_id_to_elem_map_it->second, other_coupled_it->second);
94 }
95}
96
97std::string
99{
100 std::string info = std::string("Proxy for ") + _other_system->name();
101
102 if (useDisplacedMesh())
103 info = info + " on displaced";
104
105 return info;
106}
107
108bool
110{
111 // There isn't a need to determine these because only the correct ones will be added
112 return false;
113}
114
115std::unique_ptr<libMesh::GhostingFunctor>
117{
118 return _app.getFactory().copyConstruct(*this);
119}
registerMooseObject("MooseApp", ProxyRelationshipManager)
std::unique_ptr< T > copyConstruct(const T &object)
Copy constructs the object object.
Definition Factory.h:358
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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:407
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3557
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
Intermediate base class for RelationshipManagers that are simply built using ghosting functors.
virtual std::string getInfo() const override
Method for returning relationship manager information (suitable for console output).
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.
virtual void operator()(const MeshBase::const_element_iterator &, const MeshBase::const_element_iterator &, processor_id_type p, map_type &coupled_elements) override
static InputParameters validParams()
virtual bool operator>=(const RelationshipManager &) const override
Whether this relationship manager provides more or the same amount and type of ghosting as the rhs.
RelationshipManagers are used for describing what kinds of non-local resources are needed for an obje...
bool isType(const Moose::RelationshipManagerType &type) const
Check to see if an RM is of a given type.
static InputParameters validParams()
bool useDisplacedMesh() const
Whether this should be placed on the undisplaced or displaced systems.
MooseMesh * _moose_mesh
Pointer to the MooseMesh object.
GhostingFunctorIterator algebraic_ghosting_functors_end() const
GhostingFunctorIterator algebraic_ghosting_functors_begin() const
std::map< const Elem *, const CouplingMatrix *, CompareDofObjectsByPIDAndThenID > map_type
GhostingFunctorIterator ghosting_functors_begin() const
const std::string & name() const
const DofMap & get_dof_map() const
const MeshBase & get_mesh() const