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
25{
27 params.addRequiredParam<std::vector<BoundaryName>>("boundary",
28 "The name of the primary boundary sideset.");
29 params.addClassDescription("This class constructs a relationship manager system' "
30 "to communicate ghost elements on a boundary.");
31 return params;
32}
33
35 : RelationshipManager(params), _boundary_name(getParam<std::vector<BoundaryName>>("boundary"))
36{
37}
38
40 : RelationshipManager(other), _boundary_name(other._boundary_name)
41{
42}
43
44void
46{
47}
48
49std::string
51{
52 std::ostringstream oss;
53 oss << "GhostBoundary";
54 return oss.str();
55}
56
57void
58GhostBoundary::operator()(const MeshBase::const_element_iterator & /*range_begin*/,
59 const MeshBase::const_element_iterator & /*range_end*/,
60 const processor_id_type p,
61 map_type & coupled_elements)
62{
63 // We ask the user to pass boundary names instead of ids to our constraint object. However, We
64 // are unable to get the boundary ids from boundary names until we've attached the MeshBase object
65 // to the MooseMesh
66 const bool generating_mesh = !_moose_mesh->getMeshPtr();
67 const auto boundary_ids = generating_mesh ? std::vector<BoundaryID>{Moose::INVALID_BOUNDARY_ID}
69
70 for (const Elem * const elem : _mesh->active_element_ptr_range())
71 {
72 if (generating_mesh)
73 { // We are still generating the mesh, so it's possible we don't even have the right boundary
74 // ids created yet! So we actually ghost all boundary elements and all lower dimensional
75 // elements who have parents on a boundary
76 if (elem->on_boundary())
77 coupled_elements.insert(std::make_pair(elem, _null_mat));
78 }
79 else
80 {
81 // We've finished generating our mesh so we can be selective and only ghost elements lying on
82 // our boundary
83 const BoundaryInfo & binfo = _mesh->get_boundary_info();
84 for (auto side : elem->side_index_range())
85 for (auto boundary_id : boundary_ids)
86 if ((elem->processor_id() != p) && (binfo.has_boundary_id(elem, side, boundary_id)))
87 {
88 coupled_elements.insert(std::make_pair(elem, _null_mat));
89 goto countBreak;
90 }
91 countBreak:;
92 }
93 }
94}
95
96bool
98{
99 if (auto asoi = dynamic_cast<const GhostBoundary *>(&other); asoi && baseGreaterEqual(*asoi))
100 {
101 std::set<BoundaryName> our_set(_boundary_name.begin(), _boundary_name.end());
102 std::set<BoundaryName> their_set(asoi->_boundary_name.begin(), asoi->_boundary_name.end());
103 std::set<BoundaryName> difference;
104 std::set_difference(their_set.begin(),
105 their_set.end(),
106 our_set.begin(),
107 our_set.end(),
108 std::inserter(difference, difference.end()));
109 if (difference.empty())
110 return true;
111 }
112 return false;
113}
114
115std::unique_ptr<GhostingFunctor>
117{
118 return _app.getFactory().copyConstruct(*this);
119}
registerMooseObject("MooseApp", GhostBoundary)
std::unique_ptr< T > copyConstruct(const T &object)
Copy constructs the object object.
Definition Factory.h:358
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
Called before this RM is attached.
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:3551
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:3035
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.
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