https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GhostBoundary.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
11#include "GhostBoundary.h"
12#include "Executioner.h"
13#include "FEProblemBase.h"
14#include "MooseApp.h"
15
16// libMesh includes
17#include "libmesh/elem.h"
18#include "libmesh/mesh_base.h"
19#include "libmesh/boundary_info.h"
20
22
23using namespace libMesh;
24
27{
29 params.addRequiredParam<std::vector<BoundaryName>>("boundary",
30 "The name of the primary boundary sideset.");
31 params.addClassDescription("This class constructs a relationship manager system' "
32 "to communicate ghost elements on a boundary.");
33 return params;
34}
35
37 : RelationshipManager(params), _boundary_name(getParam<std::vector<BoundaryName>>("boundary"))
38{
39}
40
42 : RelationshipManager(other), _boundary_name(other._boundary_name)
43{
44}
45
46void
50
51std::string
53{
54 std::ostringstream oss;
55 oss << "GhostBoundary";
56 return oss.str();
57}
58
59void
61 const MeshBase::const_element_iterator & /*range_end*/,
62 const processor_id_type p,
63 map_type & coupled_elements)
64{
65 // We ask the user to pass boundary names instead of ids to our constraint object. However, We
66 // are unable to get the boundary ids from boundary names until we've attached the MeshBase object
67 // to the MooseMesh
68 const bool generating_mesh = !_moose_mesh->getMeshPtr();
69 const auto boundary_ids = generating_mesh ? std::vector<BoundaryID>{Moose::INVALID_BOUNDARY_ID}
71
72 for (const Elem * const elem : _mesh->active_element_ptr_range())
73 {
74 if (generating_mesh)
75 { // We are still generating the mesh, so it's possible we don't even have the right boundary
76 // ids created yet! So we actually ghost all boundary elements and all lower dimensional
77 // elements who have parents on a boundary
78 if (elem->on_boundary())
79 coupled_elements.insert(std::make_pair(elem, _null_mat));
80 }
81 else
82 {
83 // We've finished generating our mesh so we can be selective and only ghost elements lying on
84 // our boundary
85 const BoundaryInfo & binfo = _mesh->get_boundary_info();
86 for (auto side : elem->side_index_range())
87 for (auto boundary_id : boundary_ids)
88 if ((elem->processor_id() != p) && (binfo.has_boundary_id(elem, side, boundary_id)))
89 {
90 coupled_elements.insert(std::make_pair(elem, _null_mat));
91 goto countBreak;
92 }
93 countBreak:;
94 }
95 }
96}
97
98bool
100{
101 if (auto asoi = dynamic_cast<const GhostBoundary *>(&other); asoi && baseGreaterEqual(*asoi))
102 {
103 std::set<BoundaryName> our_set(_boundary_name.begin(), _boundary_name.end());
104 std::set<BoundaryName> their_set(asoi->_boundary_name.begin(), asoi->_boundary_name.end());
105 std::set<BoundaryName> difference;
106 std::set_difference(their_set.begin(),
107 their_set.end(),
108 our_set.begin(),
109 our_set.end(),
110 std::inserter(difference, difference.end()));
111 if (difference.empty())
112 return true;
113 }
114 return false;
115}
116
117std::unique_ptr<GhostingFunctor>
119{
120 return _app.getFactory().copyConstruct(*this);
121}
registerMooseObject("MooseApp", GhostBoundary)
GhostBoundary is used to ghost elements on a boundary.
const std::vector< BoundaryName > & _boundary_name
The boundary for which we will ghost elements.
GhostBoundary(const InputParameters &)
std::string getInfo() const override
Method for returning relationship manager information (suitable for console output).
static InputParameters validParams()
const CouplingMatrix *const _null_mat
null matrix for generating full variable coupling
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.
virtual void internalInitWithMesh(const MeshBase &) override
virtual std::unique_ptr< GhostingFunctor > clone() const override
virtual void operator()(const MeshBase::const_element_iterator &, const MeshBase::const_element_iterator &, processor_id_type p, map_type &coupled_elements) override
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...
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
Definition MooseApp.h:407
const MeshBase * getMeshPtr() const
Definition MooseMesh.C:3543
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
Returns a vector of boundary IDs for the requested element on the requested side.
Definition MooseMesh.C:3027
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...
virtual bool baseGreaterEqual(const RelationshipManager &rhs) const
Whether the base class provides more or the same amount and type of ghosting as the rhs.
static InputParameters validParams()
MooseMesh * _moose_mesh
Pointer to the MooseMesh object.
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
std::map< const Elem *, const CouplingMatrix *, CompareDofObjectsByPIDAndThenID > map_type
const MeshBase * _mesh
const BoundaryInfo & get_boundary_info() const
const BoundaryID INVALID_BOUNDARY_ID
Definition MooseTypes.C:22
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
uint8_t processor_id_type