https://mooseframework.inl.gov
ElemSideNeighborLayersTester.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 
13 // invalid_processor_id
14 #include "libmesh/dof_object.h"
15 
17 
20 {
22  params.addParam<unsigned int>(
23  "rank",
25  "The rank for which the ghosted elements are recorded (Default: ALL)");
26 
27  params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_BEGIN;
28 
30  "ElementSideNeighborLayers",
32 
33  [](const InputParameters & obj_params, InputParameters & rm_params)
34  {
35  rm_params.set<unsigned short>("layers") =
36  obj_params.get<unsigned short>("element_side_neighbor_layers");
37  }
38 
39  );
40 
41  params.addRequiredParam<unsigned short>("element_side_neighbor_layers",
42  "Number of layers to ghost");
43 
44  params.addClassDescription("User object to calculate ghosted elements on a single processor or "
45  "the union across all processors.");
46  return params;
47 }
48 
50  : ElementUOProvider(parameters), _rank(getParam<unsigned int>("rank"))
51 {
52 }
53 
54 void
56 {
57  _ghost_data.clear();
58 }
59 
60 void
62 {
63  auto my_processor_id = processor_id();
64 
65  if (_rank == libMesh::DofObject::invalid_processor_id || my_processor_id == _rank)
66  {
67  for (const auto & current_elem : _fe_problem.getNonlinearEvaluableElementRange())
68  _evaluable_data.emplace(current_elem->id());
69 
70  const auto & mesh = _subproblem.mesh().getMesh();
71 
72  for (const auto & elem : mesh.active_element_ptr_range())
73  if (elem->processor_id() != my_processor_id)
74  _ghost_data.emplace(elem->id());
75  }
76 }
77 
78 void
80 {
83 }
84 
85 unsigned long
87  const std::string & field_name) const
88 {
89  if (field_name == "evaluable")
90  return _evaluable_data.find(element_id) != _evaluable_data.end();
91  else if (field_name == "ghosted")
92  return _ghost_data.find(element_id) != _ghost_data.end();
93 
95 }
virtual MooseMesh & mesh()=0
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
ElemSideNeighborLayersTester(const InputParameters &parameters)
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
MeshBase & mesh
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Parallel::Communicator & _communicator
void addRelationshipManager(const std::string &name, Moose::RelationshipManagerType rm_type, Moose::RelationshipManagerInputParameterCallback input_parameter_callback=nullptr)
Tells MOOSE about a RelationshipManager that this object needs.
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...
auto max(const L &left, const R &right)
SubProblem & _subproblem
Reference to the Subproblem for this user object.
Definition: UserObject.h:208
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3448
static const processor_id_type invalid_processor_id
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition: Moose.C:37
static InputParameters validParams()
User object intermediate base class that declares an interface for providing generic fields by name...
virtual void finalize() override
Finalize.
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Definition: UserObject.h:211
registerMooseObject("MooseApp", ElemSideNeighborLayersTester)
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...
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...
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
User object to show information about the ElemSideNeighborLayer object&#39;s "ghosting" behaviors...
processor_id_type processor_id() const
const libMesh::ConstElemRange & getNonlinearEvaluableElementRange()
void ErrorVector unsigned int
virtual void execute() override
Execute method.
virtual unsigned long getElementalValueLong(dof_id_type element_id, const std::string &field_name) const override
uint8_t dof_id_type
void set_union(T &data, const unsigned int root_id) const