https://mooseframework.inl.gov
GhostingFromUOAux.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 #include "GhostingFromUOAux.h"
11 #include "GhostingUserObject.h"
12 
14 registerMooseObjectRenamed("MooseApp", GhostingAux, "04/01/2025 00:00", GhostingFromUOAux);
15 
18 {
20 
21  params.addRequiredParam<processor_id_type>("pid", "The PID to see the ghosting for");
22 
23  MooseEnum functor_type("geometric algebraic", "geometric");
24  params.addParam<MooseEnum>("functor_type", functor_type, "The type of ghosting functor to use");
25 
26  params.addParam<bool>("include_local_elements",
27  false,
28  "Whether or not to include local elements as part of the ghosting set");
29 
30  params.addRequiredParam<UserObjectName>(
31  "ghost_uo", "The GhostUserObject from which to obtain ghosting information from.");
32 
33  params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END};
34 
35  params.addClassDescription("Colors the elements ghosted to the chosen PID.");
36  return params;
37 }
38 
40  : AuxKernel(parameters),
41  _pid(getParam<processor_id_type>("pid")),
42  _rm_type(getParam<MooseEnum>("functor_type") == "geometric"
43  ? Moose::RelationshipManagerType::GEOMETRIC
44  : Moose::RelationshipManagerType::ALGEBRAIC),
45  _include_local(getParam<bool>("include_local_elements")),
46  _value(0.),
47  _ghost_uo(getUserObject<GhostingUserObject>("ghost_uo"))
48 {
49  if (isNodal())
50  mooseError("GhostingFromUOAux only works on elemental fields.");
51 }
52 
53 void
55 {
56  if (_current_elem->processor_id() == _pid && _include_local)
57  _value = 1;
58  else if (_current_elem->processor_id() != _pid)
60  else
61  _value = 0.;
62 }
63 
64 Real
66 {
67  return _value;
68 }
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
Moose::RelationshipManagerType _rm_type
The type of ghosting functor to get.
registerMooseObjectRenamed("MooseApp", GhostingAux, "04/01/2025 00:00", GhostingFromUOAux)
RelationshipManagerType
Main types of Relationship Managers.
Definition: MooseTypes.h:964
const GhostingUserObject & _ghost_uo
The reference to the ghosting user object.
GhostingFromUOAux(const InputParameters &parameters)
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
bool _include_local
Whether or not to include local elements in the display field.
Real getElementalValue(const Elem *elem, Moose::RelationshipManagerType rm_type, processor_id_type pid) const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const ExecFlagType EXEC_TIMESTEP_END
Definition: Moose.C:36
registerMooseObject("MooseApp", GhostingFromUOAux)
This object loops over all of the underlying ghosting functors added by libMesh or MOOSE through Rela...
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...
Real _value
precalculated element value
static InputParameters validParams()
processor_id_type _pid
The PID to show the ghosting for.
Outputs to an auxiliary variable the ghosting of a GhostingUserObject.
uint8_t processor_id_type
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
virtual Real computeValue() override
Compute and return the value of the aux variable.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:204
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...
static InputParameters validParams()
Definition: AuxKernel.C:27
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:36
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
virtual void precalculateValue() override
This callback is used for AuxKernelTempls that need to perform a per-element calculation.
bool isNodal() const
Nodal or elemental kernel?
Definition: AuxKernel.h:86
const ExecFlagType EXEC_INITIAL
Definition: Moose.C:30