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
22using namespace libMesh;
23
25
28{
30
31 params.addRangeCheckedParam<unsigned short>(
32 "layers",
33 1,
34 "element_side_neighbor_layers>=1 & element_side_neighbor_layers<=10",
35 "The number of additional geometric elements to make available when "
36 "using distributed mesh. No effect with replicated mesh.");
37 params.addParam<bool>("use_point_neighbors",
38 false,
39 "Whether to use point neighbors, which introduces additional ghosting to "
40 "that used for simple face neighbors.");
41
42 return params;
43}
44
46 : FunctorRelationshipManager(parameters),
47 _layers(getParam<unsigned short>("layers")),
48 _use_point_neighbors(getParam<bool>("use_point_neighbors"))
49{
50}
51
54 _layers(other._layers),
55 _use_point_neighbors(other._use_point_neighbors)
56{
57}
58
59std::unique_ptr<GhostingFunctor>
61{
62 return _app.getFactory().copyConstruct(*this);
63}
64
65std::string
67{
68 std::ostringstream oss;
69 std::string layers = _layers == 1 ? "layer" : "layers";
70
71 oss << "ElementSideNeighborLayers (" << _layers << " " << layers << ')';
72
73 return oss.str();
74}
75
76// the LHS ("this" object) in MooseApp::addRelationshipManager is the existing RelationshipManager
77// object to which we are comparing the rhs to determine whether it should get added
78bool
80{
81 const auto * rm = dynamic_cast<const ElementSideNeighborLayers *>(&rhs);
82 if (!rm)
83 return false;
84 else
85 // We use a >= comparison instead of == for _layers because if we already have more ghosting
86 // than the new RM provides, then that's an indication that we should *not* add the new one
87 return (_layers >= rm->_layers) && (_use_point_neighbors == rm->_use_point_neighbors) &&
89}
90
91template <typename Functor>
92void
94{
95 functor.set_n_levels(_layers);
96
97 if (_dof_map)
98 {
99 // Need to see if there are periodic BCs - if so we need to dig them out
100 auto periodic_boundaries_ptr = _dof_map->get_periodic_boundaries();
101
102 mooseAssert(periodic_boundaries_ptr, "Periodic Boundaries Pointer is nullptr");
103
104 functor.set_periodic_boundaries(periodic_boundaries_ptr);
105 functor.set_dof_coupling(_dof_map->_dof_coupling);
106 }
107}
108
109void
111{
113 {
114 auto functor = std::make_unique<PointNeighborCoupling>();
115 initFunctor(*functor);
116 _functor = std::move(functor);
117 }
118 else
119 {
120 auto functor = std::make_unique<DefaultCoupling>();
121 initFunctor(*functor);
122 _functor = std::move(functor);
123 }
124}
125
126void
128{
129 if (_dof_map)
130 {
132 static_cast<PointNeighborCoupling *>(_functor.get())
133 ->set_dof_coupling(_dof_map->_dof_coupling);
134 else
135 static_cast<DefaultCoupling *>(_functor.get())->set_dof_coupling(_dof_map->_dof_coupling);
136 }
137}
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 void internalInitWithMesh(const MeshBase &) override
Called before this RM is attached.
virtual std::unique_ptr< GhostingFunctor > clone() const override
According to the base class docs, "We call mesh_reinit() whenever the relevant Mesh has changed,...
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).
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
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...