www.mooseframework.org
ElementSideNeighborLayers.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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/dof_map.h"
20 
22 
23 template <>
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 
36  return params;
37 }
38 
40  : FunctorRelationshipManager(parameters), _layers(getParam<unsigned short>("layers"))
41 {
42 }
43 
44 std::string
46 {
47  std::ostringstream oss;
48  std::string layers = _layers == 1 ? "layer" : "layers";
49 
50  oss << "ElementSideNeighborLayers (" << _layers << " " << layers << ')';
51 
52  return oss.str();
53 }
54 
55 bool
57 {
58  const auto * rm = dynamic_cast<const ElementSideNeighborLayers *>(&rhs);
59  if (!rm)
60  return false;
61  else
62  return _layers == rm->_layers && isType(rm->_rm_type);
63 }
64 
65 void
67 {
68  auto functor = libmesh_make_unique<DefaultCoupling>();
69  functor->set_n_levels(_layers);
70 
71  // Need to see if there are periodic BCs - if so we need to dig them out
72  auto executioner_ptr = _app.getExecutioner();
73 
74  if (executioner_ptr)
75  {
76  auto & fe_problem = executioner_ptr->feProblem();
77  auto & nl_sys = fe_problem.getNonlinearSystem();
78  auto & dof_map = nl_sys.dofMap();
79  auto periodic_boundaries_ptr = dof_map.get_periodic_boundaries();
80 
81  mooseAssert(periodic_boundaries_ptr, "Periodic Boundaries Pointer is nullptr");
82 
83  functor->set_mesh(&_mesh.getMesh());
84  functor->set_periodic_boundaries(periodic_boundaries_ptr);
85  }
86 
87  _functor = std::move(functor);
88 }
virtual std::string getInfo() const override
Method for returning relationship manager information (suitable for console output).
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition: MooseApp.h:255
ElementSideNeighborLayers(const InputParameters &parameters)
unsigned short _layers
Size of the halo or stencil of elements available in each local processors partition.
virtual void internalInit() override
Called before this RM is attached.
InputParameters validParams< ElementSideNeighborLayers >()
MooseMesh & _mesh
Reference to the Mesh object.
FEProblemBase & feProblem()
Return a reference to this Executioner&#39;s FEProblemBase instance.
Definition: Executioner.C:68
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual bool operator==(const RelationshipManager &rhs) const override
registerMooseObject("MooseApp", ElementSideNeighborLayers)
std::unique_ptr< GhostingFunctor > _functor
ElementSideNeighborLayers is used to increase the halo or stencil depth of each processor&#39;s partition...
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2567
DofMap & dof_map
bool isType(const Moose::RelationshipManagerType &type) const
Check to see if an RM is of a given type.
InputParameters validParams< FunctorRelationshipManager >()
RelationshipManagers are used for describing what kinds of non-local resources are needed for an obje...
MooseApp & _app
The MooseApp this object is associated with.
Definition: MooseObject.h:177
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
virtual NonlinearSystem & getNonlinearSystem()
Intermediate base class for RelationshipManagers that are simply built using ghosting functors...