LCOV - code coverage report
Current view: top level - src/actions - DisplayGhostingAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31405 (292dce) with base fef103 Lines: 44 45 97.8 %
Date: 2025-09-04 07:52:05 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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       68144 : DisplayGhostingAction::validParams()
      21             : {
      22       68144 :   InputParameters params = Action::validParams();
      23      272576 :   params.addParam<bool>("output_ghosting", false, "Boolean to turn on ghosting auxiliary fields");
      24      204432 :   params.addParam<bool>("include_local_in_ghosting",
      25      136288 :                         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       68144 :   params.addClassDescription(
      30             :       "Action to setup AuxVariables and AuxKernels to display ghosting when running in parallel");
      31             : 
      32       68144 :   return params;
      33           0 : }
      34             : 
      35       67906 : DisplayGhostingAction::DisplayGhostingAction(const InputParameters & params)
      36             :   : Action(params),
      37       67906 :     _display_ghosting(getParam<bool>("output_ghosting")),
      38      203718 :     _include_local(getParam<bool>("include_local_in_ghosting"))
      39             : {
      40       67906 : }
      41             : 
      42             : void
      43      187546 : DisplayGhostingAction::act()
      44             : {
      45      187546 :   if (_display_ghosting == false)
      46      187213 :     return;
      47             : 
      48         333 :   auto n_procs = _app.n_processors();
      49             : 
      50         333 :   if (_current_task == "add_aux_variable")
      51             :   {
      52         333 :     auto params = _factory.getValidParams("MooseVariableConstMonomial");
      53         444 :     params.set<MooseEnum>("order") = "CONSTANT";
      54         333 :     params.set<MooseEnum>("family") = "MONOMIAL";
      55             : 
      56         333 :     for (unsigned int i = 0; i < 2; ++i)
      57             :     {
      58         222 :       std::string var_name_base = (i == 0 ? "geometric" : "algebraic");
      59        1104 :       for (decltype(n_procs) proc_id = 0; proc_id < n_procs; ++proc_id)
      60        1764 :         _problem->addAuxVariable(
      61        1764 :             "MooseVariableConstMonomial", var_name_base + std::to_string(proc_id), params);
      62         222 :     }
      63         111 :   }
      64         222 :   else if (_current_task == "add_aux_kernel")
      65             :   {
      66         333 :     for (unsigned int i = 0; i < 2; ++i)
      67             :     {
      68         222 :       std::string aux_kernel_name_base = i == 0 ? "geometric" : "algebraic";
      69        1104 :       for (decltype(n_procs) proc_id = 0; proc_id < n_procs; ++proc_id)
      70             :       {
      71         882 :         std::string name = aux_kernel_name_base + std::to_string(proc_id);
      72             : 
      73        1764 :         auto params = _factory.getValidParams("GhostingAux");
      74        2646 :         params.set<processor_id_type>("pid") = proc_id;
      75         882 :         params.set<MooseEnum>("functor_type") = aux_kernel_name_base;
      76        2646 :         params.set<UserObjectName>("ghost_uo") = "ghost_uo";
      77        2646 :         params.set<AuxVariableName>("variable") = name;
      78        1764 :         params.set<bool>("include_local_elements") = _include_local;
      79             : 
      80        1764 :         _problem->addAuxKernel("GhostingAux", name, params);
      81         882 :       }
      82         222 :     }
      83             :   }
      84         111 :   else if (_current_task == "add_user_object")
      85             :   {
      86         222 :     auto params = _factory.getValidParams("GhostingUserObject");
      87         444 :     _problem->addUserObject("GhostingUserObject", "ghost_uo", params);
      88         111 :   }
      89             : }

Generated by: LCOV version 1.14