LCOV - code coverage report
Current view: top level - src/actions - DisplayGhostingAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 44 45 97.8 %
Date: 2025-08-08 20:01:16 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       67239 : DisplayGhostingAction::validParams()
      21             : {
      22       67239 :   InputParameters params = Action::validParams();
      23       67239 :   params.addParam<bool>("output_ghosting", false, "Boolean to turn on ghosting auxiliary fields");
      24      201717 :   params.addParam<bool>("include_local_in_ghosting",
      25      134478 :                         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       67239 :   params.addClassDescription(
      30             :       "Action to setup AuxVariables and AuxKernels to display ghosting when running in parallel");
      31             : 
      32       67239 :   return params;
      33           0 : }
      34             : 
      35       67001 : DisplayGhostingAction::DisplayGhostingAction(const InputParameters & params)
      36             :   : Action(params),
      37       67001 :     _display_ghosting(getParam<bool>("output_ghosting")),
      38      134002 :     _include_local(getParam<bool>("include_local_in_ghosting"))
      39             : {
      40       67001 : }
      41             : 
      42             : void
      43      185237 : DisplayGhostingAction::act()
      44             : {
      45      185237 :   if (_display_ghosting == false)
      46      184904 :     return;
      47             : 
      48         333 :   auto n_procs = _app.n_processors();
      49             : 
      50         333 :   if (_current_task == "add_aux_variable")
      51             :   {
      52         111 :     auto params = _factory.getValidParams("MooseVariableConstMonomial");
      53         111 :     params.set<MooseEnum>("order") = "CONSTANT";
      54         111 :     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         882 :         auto params = _factory.getValidParams("GhostingAux");
      74         882 :         params.set<processor_id_type>("pid") = proc_id;
      75         882 :         params.set<MooseEnum>("functor_type") = aux_kernel_name_base;
      76         882 :         params.set<UserObjectName>("ghost_uo") = "ghost_uo";
      77         882 :         params.set<AuxVariableName>("variable") = name;
      78         882 :         params.set<bool>("include_local_elements") = _include_local;
      79             : 
      80         882 :         _problem->addAuxKernel("GhostingAux", name, params);
      81         882 :       }
      82         222 :     }
      83             :   }
      84         111 :   else if (_current_task == "add_user_object")
      85             :   {
      86         111 :     auto params = _factory.getValidParams("GhostingUserObject");
      87         111 :     _problem->addUserObject("GhostingUserObject", "ghost_uo", params);
      88         111 :   }
      89             : }

Generated by: LCOV version 1.14