https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ElementSideNeighborLayers.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 "MooseMesh.h"
12#include "Conversion.h"
13#include "MooseApp.h"
14#include "Executioner.h"
15#include "FEProblemBase.h"
16#include "NonlinearSystem.h"
17
18#include "libmesh/default_coupling.h"
19#include "libmesh/point_neighbor_coupling.h"
20#include "libmesh/dof_map.h"
21
23
26{
28
29 params.addRangeCheckedParam<unsigned short>(
30 "layers",
31 1,
32 "element_side_neighbor_layers>=1 & element_side_neighbor_layers<=10",
33 "The number of additional geometric elements to make available when "
34 "using distributed mesh. No effect with replicated mesh.");
35 params.addParam<bool>("use_point_neighbors",
36 false,
37 "Whether to use point neighbors, which introduces additional ghosting to "
38 "that used for simple face neighbors.");
39
40 return params;
41}
42
44 : FunctorRelationshipManager(parameters),
45 _layers(getParam<unsigned short>("layers")),
46 _use_point_neighbors(getParam<bool>("use_point_neighbors"))
47{
48}
49
52 _layers(other._layers),
53 _use_point_neighbors(other._use_point_neighbors)
54{
55}
56
57std::unique_ptr<libMesh::GhostingFunctor>
62
63std::string
65{
66 std::ostringstream oss;
67 std::string layers = _layers == 1 ? "layer" : "layers";
68
69 oss << "ElementSideNeighborLayers (" << _layers << " " << layers << ')';
70
71 return oss.str();
72}
73
74// the LHS ("this" object) in MooseApp::addRelationshipManager is the existing RelationshipManager
75// object to which we are comparing the rhs to determine whether it should get added
76bool
78{
79 const auto * rm = dynamic_cast<const ElementSideNeighborLayers *>(&rhs);
80 if (!rm)
81 return false;
82 else
83 // We use a >= comparison instead of == for _layers because if we already have more ghosting
84 // than the new RM provides, then that's an indication that we should *not* add the new one
85 return (_layers >= rm->_layers) && (_use_point_neighbors == rm->_use_point_neighbors) &&
87}
88
89template <typename Functor>
90void
92{
93 functor.set_n_levels(_layers);
94
95 if (_dof_map)
96 {
97 // Need to see if there are periodic BCs - if so we need to dig them out
98 auto periodic_boundaries_ptr = _dof_map->get_periodic_boundaries();
99
100 mooseAssert(periodic_boundaries_ptr, "Periodic Boundaries Pointer is nullptr");
101
102 functor.set_periodic_boundaries(periodic_boundaries_ptr);
103 functor.set_dof_coupling(_dof_map->_dof_coupling);
104 }
105}
106
107void
109{
111 {
112 auto functor = std::make_unique<libMesh::PointNeighborCoupling>();
113 initFunctor(*functor);
114 _functor = std::move(functor);
115 }
116 else
117 {
118 auto functor = std::make_unique<libMesh::DefaultCoupling>();
119 initFunctor(*functor);
120 _functor = std::move(functor);
121 }
122}
123
124void
126{
127 if (_dof_map)
128 {
130 cast_ptr<libMesh::PointNeighborCoupling *>(_functor.get())
131 ->set_dof_coupling(_dof_map->_dof_coupling);
132 else
133 cast_ptr<libMesh::DefaultCoupling *>(_functor.get())
134 ->set_dof_coupling(_dof_map->_dof_coupling);
135 }
136}
registerMooseObject("MooseApp", ElementSideNeighborLayers)
ElementSideNeighborLayers is used to increase the halo or stencil depth of each processor's partition...
virtual bool operator>=(const RelationshipManager &rhs) const override
Whether this relationship manager provides more or the same amount and type of ghosting as the rhs.
ElementSideNeighborLayers(const InputParameters &parameters)
static InputParameters validParams()
virtual std::unique_ptr< GhostingFunctor > clone() const override
According to the base class docs, "We call mesh_reinit() whenever the relevant Mesh has changed,...
virtual void internalInitWithMesh(const MeshBase &) override
Called before this RM is attached.
void initFunctor(Functor &functor)
Helper for initing.
unsigned short _layers
Size of the halo or stencil of elements available in each local processors partition.
virtual std::string getInfo() const override
Method for returning relationship manager information (suitable for console output).
std::unique_ptr< T > copyConstruct(const T &object)
Copy constructs the object object.
Definition Factory.h:358
Intermediate base class for RelationshipManagers that are simply built using ghosting functors.
static InputParameters validParams()
std::unique_ptr< GhostingFunctor > _functor
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
Definition MooseApp.h:407
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.
const libMesh::DofMap * _dof_map
Pointer to DofMap (may be null if this is geometric only).
PeriodicBoundaries * get_periodic_boundaries()
CouplingMatrix * _dof_coupling