https://mooseframework.inl.gov
Loading...
Searching...
No Matches
DisplayGhostingAction.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 "FEProblemBase.h"
12
13registerMooseAction("MooseApp", DisplayGhostingAction, "add_aux_variable");
14
15registerMooseAction("MooseApp", DisplayGhostingAction, "add_aux_kernel");
16
17registerMooseAction("MooseApp", DisplayGhostingAction, "add_user_object");
18
21{
23 params.addParam<bool>("output_ghosting", false, "Boolean to turn on ghosting auxiliary fields");
24 params.addParam<bool>("include_local_in_ghosting",
25 false,
26 "Boolean used to toggle on the inclusion of local elements along with the "
27 "ghost elements for a complete partition map");
28
30 "Action to setup AuxVariables and AuxKernels to display ghosting when running in parallel");
31
32 return params;
33}
34
36 : Action(params),
37 _display_ghosting(getParam<bool>("output_ghosting")),
38 _include_local(getParam<bool>("include_local_in_ghosting"))
39{
40}
41
42void
44{
45 if (_display_ghosting == false)
46 return;
47
48 auto n_procs = _app.n_processors();
49
50 if (_current_task == "add_aux_variable")
51 {
52 auto params = _factory.getValidParams("MooseVariableConstMonomial");
53 params.set<MooseEnum>("order") = "CONSTANT";
54 params.set<MooseEnum>("family") = "MONOMIAL";
55
56 for (unsigned int i = 0; i < 2; ++i)
57 {
58 std::string var_name_base = (i == 0 ? "geometric" : "algebraic");
59 for (decltype(n_procs) proc_id = 0; proc_id < n_procs; ++proc_id)
60 _problem->addAuxVariable(
61 "MooseVariableConstMonomial", var_name_base + std::to_string(proc_id), params);
62 }
63 }
64 else if (_current_task == "add_aux_kernel")
65 {
66 for (unsigned int i = 0; i < 2; ++i)
67 {
68 std::string aux_kernel_name_base = i == 0 ? "geometric" : "algebraic";
69 for (decltype(n_procs) proc_id = 0; proc_id < n_procs; ++proc_id)
70 {
71 std::string name = aux_kernel_name_base + std::to_string(proc_id);
72
73 auto params = _factory.getValidParams("GhostingAux");
74 params.set<processor_id_type>("pid") = proc_id;
75 params.set<MooseEnum>("functor_type") = aux_kernel_name_base;
76 params.set<UserObjectName>("ghost_uo") = "ghost_uo";
77 params.set<AuxVariableName>("variable") = name;
78 params.set<bool>("include_local_elements") = _include_local;
79
80 _problem->addAuxKernel("GhostingAux", name, params);
81 }
82 }
83 }
84 else if (_current_task == "add_user_object")
85 {
86 auto params = _factory.getValidParams("GhostingUserObject");
87 _problem->addUserObject("GhostingUserObject", "ghost_uo", params);
88 }
89}
registerMooseAction("MooseApp", DisplayGhostingAction, "add_aux_variable")
Base class for actions.
Definition Action.h:38
static InputParameters validParams()
Definition Action.C:26
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition Action.h:178
const std::string & _current_task
The current action (even though we have separate instances for each action)
Definition Action.h:172
Class to setup multiple AuxVariables and AuxKernels to display the ghosting when running in parallel.
DisplayGhostingAction(const InputParameters &params)
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
static InputParameters validParams()
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Definition Factory.C:68
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 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.
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
Factory & _factory
The Factory associated with the MooseApp.
processor_id_type n_processors() const