https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
54void
59
60void
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
78void
84
85unsigned 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
94 return std::numeric_limits<unsigned long>::max();
95}
registerMooseObject("MooseApp", ElemSideNeighborLayersTester)
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition Moose.C:37
void ErrorVector unsigned int
User object to show information about the ElemSideNeighborLayer object's "ghosting" behaviors.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
ElemSideNeighborLayersTester(const InputParameters &parameters)
virtual unsigned long getElementalValueLong(dof_id_type element_id, const std::string &field_name) const override
virtual void finalize() override
Finalize.
virtual void execute() override
Execute method.
User object intermediate base class that declares an interface for providing generic fields by name.
static InputParameters validParams()
A MultiMooseEnum object to hold "execute_on" flags.
const libMesh::ConstElemRange & getNonlinearEvaluableElementRange()
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 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...
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.
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 addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3549
virtual MooseMesh & mesh()=0
void set_union(T &data, const unsigned int root_id) const
SubProblem & _subproblem
Reference to the Subproblem for this user object.
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
static constexpr processor_id_type invalid_processor_id
const Parallel::Communicator & _communicator
processor_id_type processor_id() const
MeshBase & mesh