https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GhostAllPointNeighbors.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
10// App includes
12#include "Executioner.h"
13#include "FEProblemBase.h"
14#include "MooseApp.h"
15#include "GhostLowerDElems.h"
17
18// libMesh includes
19#include "libmesh/elem.h"
20#include "libmesh/mesh_base.h"
21#include "libmesh/boundary_info.h"
22
24
27{
29 params.set<bool>("attach_geometric_early") = false;
30 return params;
31}
32
37
42
43std::string
45{
46 std::ostringstream oss;
47 oss << "GhostAllPointNeighbors";
48 return oss.str();
49}
50
51void
52GhostAllPointNeighbors::operator()(const MeshBase::const_element_iterator & range_begin,
53 const MeshBase::const_element_iterator & range_end,
54 const processor_id_type p,
55 map_type & coupled_elements)
56{
57 mooseAssert(_moose_mesh,
58 "The MOOSE mesh must be non-null in order for this relationship manager to work.");
59 const auto & node_to_elem_map = _moose_mesh->nodeToElemMap();
60
61 static const CouplingMatrix * const null_mat = nullptr;
62 std::unordered_set<dof_id_type> visited_nodes;
63
64 for (const Elem * const elem : as_range(range_begin, range_end))
65 for (const auto & node : elem->node_ref_range())
66 {
67 // We want to ghost the point neighbors if the node hasn't been partitioned yet
68 // (e.g. we don't know what processes it will be) or if its processor id matches our
69 // processes's id
70 const auto node_pid = node.processor_id();
71 if (node_pid == p || node_pid == DofObject::invalid_processor_id)
72 {
73 const auto [_, inserted] = visited_nodes.insert(node.id());
74 if (!inserted)
75 // We've already considered this node
76 continue;
77
78 const auto & elem_node_neighbors = libmesh_map_find(node_to_elem_map, node.id());
79 for (const auto elem_id : elem_node_neighbors)
80 {
81 const Elem * const elem_node_neighbor = _mesh->elem_ptr(elem_id);
82 if (elem_node_neighbor->processor_id() != p)
83 coupled_elements.emplace(elem_node_neighbor, null_mat);
84 }
85 }
86 }
87}
88
89bool
91{
92 return dynamic_cast<const GhostAllPointNeighbors *>(&other) ||
93 dynamic_cast<const GhostLowerDElems *>(&other) ||
94 dynamic_cast<const GhostHigherDLowerDPointNeighbors *>(&other);
95}
96
97std::unique_ptr<libMesh::GhostingFunctor>
99{
100 return _app.getFactory().copyConstruct(*this);
101}
registerMooseObject("MooseApp", GhostAllPointNeighbors)
std::unique_ptr< T > copyConstruct(const T &object)
Copy constructs the object object.
Definition Factory.h:358
Ghosts all point neighbors (not including periodic neighbors) regardless of the dimensionality of the...
std::unique_ptr< GhostingFunctor > clone() const override
GhostAllPointNeighbors(const InputParameters &)
std::string getInfo() const override
Method for returning relationship manager information (suitable for console output).
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
static InputParameters validParams()
virtual bool operator>=(const RelationshipManager &other) const override
Whether this relationship manager provides more or the same amount and type of ghosting as the rhs.
Ghosts lower-D point neighbors of higher-D elements.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
Definition MooseApp.h:407
const std::unordered_map< dof_id_type, std::vector< dof_id_type > > & nodeToElemMap()
If not already created, creates a map from every node to all elements to which they are connected.
Definition MooseMesh.C:1239
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
RelationshipManagers are used for describing what kinds of non-local resources are needed for an obje...
static InputParameters validParams()
MooseMesh * _moose_mesh
Pointer to the MooseMesh object.
std::map< const Elem *, const CouplingMatrix *, CompareDofObjectsByPIDAndThenID > map_type
const MeshBase * _mesh
virtual const Elem * elem_ptr(const dof_id_type i) const=0