Line data Source code
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 "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 : InputParameters 20 62387 : DisplayGhostingAction::validParams() 21 : { 22 62387 : InputParameters params = Action::validParams(); 23 62387 : params.addParam<bool>("output_ghosting", false, "Boolean to turn on ghosting auxiliary fields"); 24 187161 : params.addParam<bool>("include_local_in_ghosting", 25 124774 : false, 26 : "Boolean used to toggle on the inclusion of local elements along with the " 27 : "ghost elements for a complete partition map"); 28 : 29 62387 : params.addClassDescription( 30 : "Action to setup AuxVariables and AuxKernels to display ghosting when running in parallel"); 31 : 32 62387 : return params; 33 0 : } 34 : 35 62149 : DisplayGhostingAction::DisplayGhostingAction(const InputParameters & params) 36 : : Action(params), 37 62149 : _display_ghosting(getParam<bool>("output_ghosting")), 38 124298 : _include_local(getParam<bool>("include_local_in_ghosting")) 39 : { 40 62149 : } 41 : 42 : void 43 171676 : DisplayGhostingAction::act() 44 : { 45 171676 : if (_display_ghosting == false) 46 171379 : return; 47 : 48 297 : auto n_procs = _app.n_processors(); 49 : 50 297 : if (_current_task == "add_aux_variable") 51 : { 52 99 : auto params = _factory.getValidParams("MooseVariableConstMonomial"); 53 99 : params.set<MooseEnum>("order") = "CONSTANT"; 54 99 : params.set<MooseEnum>("family") = "MONOMIAL"; 55 : 56 297 : for (unsigned int i = 0; i < 2; ++i) 57 : { 58 198 : std::string var_name_base = (i == 0 ? "geometric" : "algebraic"); 59 984 : for (decltype(n_procs) proc_id = 0; proc_id < n_procs; ++proc_id) 60 1572 : _problem->addAuxVariable( 61 1572 : "MooseVariableConstMonomial", var_name_base + std::to_string(proc_id), params); 62 198 : } 63 99 : } 64 198 : else if (_current_task == "add_aux_kernel") 65 : { 66 297 : for (unsigned int i = 0; i < 2; ++i) 67 : { 68 198 : std::string aux_kernel_name_base = i == 0 ? "geometric" : "algebraic"; 69 984 : for (decltype(n_procs) proc_id = 0; proc_id < n_procs; ++proc_id) 70 : { 71 786 : std::string name = aux_kernel_name_base + std::to_string(proc_id); 72 : 73 786 : auto params = _factory.getValidParams("GhostingAux"); 74 786 : params.set<processor_id_type>("pid") = proc_id; 75 786 : params.set<MooseEnum>("functor_type") = aux_kernel_name_base; 76 786 : params.set<UserObjectName>("ghost_uo") = "ghost_uo"; 77 786 : params.set<AuxVariableName>("variable") = name; 78 786 : params.set<bool>("include_local_elements") = _include_local; 79 : 80 786 : _problem->addAuxKernel("GhostingAux", name, params); 81 786 : } 82 198 : } 83 : } 84 99 : else if (_current_task == "add_user_object") 85 : { 86 99 : auto params = _factory.getValidParams("GhostingUserObject"); 87 99 : _problem->addUserObject("GhostingUserObject", "ghost_uo", params); 88 99 : } 89 : }