www.mooseframework.org
DisplayGhostingAction.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 
10 #include "DisplayGhostingAction.h"
11 #include "FEProblemBase.h"
12 
13 registerMooseAction("MooseApp", DisplayGhostingAction, "add_aux_variable");
14 
15 registerMooseAction("MooseApp", DisplayGhostingAction, "add_aux_kernel");
16 
17 registerMooseAction("MooseApp", DisplayGhostingAction, "add_user_object");
18 
19 template <>
22 {
24  params.addParam<bool>("output_ghosting", false, "Boolean to turn on ghosting auxiliary fields");
25  params.addParam<bool>("include_local_in_ghosting",
26  false,
27  "Boolean used to toggle on the inclusion of local elements along with the "
28  "ghost elements for a complete partition map");
29 
30  params.addClassDescription(
31  "Action to setup AuxVariables and AuxKernels to display ghosting when running in parallel");
32 
33  return params;
34 }
35 
37  : Action(params),
38  _display_ghosting(getParam<bool>("output_ghosting")),
39  _include_local(getParam<bool>("include_local_in_ghosting"))
40 {
41 }
42 
43 void
45 {
46  if (_display_ghosting == false)
47  return;
48 
49  auto n_procs = _app.n_processors();
50 
51  if (_current_task == "add_aux_variable")
52  {
53  FEType fe_type(CONSTANT, MONOMIAL);
54 
55  for (unsigned int i = 0; i < 2; ++i)
56  {
57  std::string var_name_base = (i == 0 ? "geometric" : "algebraic");
58  for (decltype(n_procs) proc_id = 0; proc_id < n_procs; ++proc_id)
59  _problem->addAuxVariable(var_name_base + std::to_string(proc_id), fe_type);
60  }
61  }
62  else if (_current_task == "add_aux_kernel")
63  {
64  for (unsigned int i = 0; i < 2; ++i)
65  {
66  std::string aux_kernel_name_base = i == 0 ? "geometric" : "algebraic";
67  for (decltype(n_procs) proc_id = 0; proc_id < n_procs; ++proc_id)
68  {
69  std::string name = aux_kernel_name_base + std::to_string(proc_id);
70 
71  auto params = _factory.getValidParams("GhostingAux");
72  params.set<processor_id_type>("pid") = proc_id;
73  params.set<MooseEnum>("functor_type") = aux_kernel_name_base;
74  params.set<UserObjectName>("ghost_uo") = "ghost_uo";
75  params.set<AuxVariableName>("variable") = name;
76  params.set<bool>("include_local_elements") = _include_local;
77 
78  _problem->addAuxKernel("GhostingAux", name, params);
79  }
80  }
81  }
82  else if (_current_task == "add_user_object")
83  {
84  auto params = _factory.getValidParams("GhostingUserObject");
85  _problem->addUserObject("GhostingUserObject", "ghost_uo", params);
86  }
87 }
registerMooseAction("MooseApp", DisplayGhostingAction, "add_aux_variable")
const std::string & name() const
The name of the action.
Definition: Action.h:76
InputParameters getValidParams(const std::string &name)
Get valid parameters for the object.
Definition: Factory.C:67
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
Factory & _factory
The Factory associated with the MooseApp.
Definition: Action.h:186
Base class for actions.
Definition: Action.h:35
InputParameters validParams< DisplayGhostingAction >()
Class to setup multiple AuxVariables and AuxKernels to display the ghosting when running in parallel...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
const std::string & _current_task
The current action (even though we have seperate instances for each action)
Definition: Action.h:210
DisplayGhostingAction(InputParameters params)
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...
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:216
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
MooseApp & _app
The MOOSE application this is associated with.
Definition: Action.h:183
InputParameters validParams< Action >()
Definition: Action.C:22