LCOV - code coverage report
Current view: top level - src/actions - AddTensorComputeAction.C (source / functions) Hit Total Coverage
Test: idaholab/swift: #92 (25e020) with base b3cd84 Lines: 34 37 91.9 %
Date: 2025-09-10 17:10:32 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /**********************************************************************/
       2             : /*                    DO NOT MODIFY THIS HEADER                       */
       3             : /*             Swift, a Fourier spectral solver for MOOSE             */
       4             : /*                                                                    */
       5             : /*            Copyright 2024 Battelle Energy Alliance, LLC            */
       6             : /*                        ALL RIGHTS RESERVED                         */
       7             : /**********************************************************************/
       8             : 
       9             : #include "AddTensorComputeAction.h"
      10             : #include "TensorProblem.h"
      11             : #include "hit/parse.h"
      12             : #include "LatticeBoltzmannProblem.h"
      13             : 
      14             : registerMooseAction("SwiftApp", AddTensorComputeAction, "add_tensor_ic");
      15             : registerMooseAction("SwiftApp", AddTensorComputeAction, "add_tensor_bc");
      16             : registerMooseAction("SwiftApp", AddTensorComputeAction, "add_tensor_compute");
      17             : registerMooseAction("SwiftApp", AddTensorComputeAction, "add_tensor_postprocessor");
      18             : 
      19             : InputParameters
      20         996 : AddTensorComputeAction::validParams()
      21             : {
      22         996 :   InputParameters params = MooseObjectAction::validParams();
      23             : 
      24         996 :   params.set<std::string>("type") = "";
      25        1992 :   params.addParam<bool>("skip_param_construction", true, "Allow for empty type default.");
      26         996 :   params.suppressParameter<bool>("skip_param_construction");
      27             : 
      28         996 :   params.addClassDescription("Add an TensorOperator object to the simulation.");
      29         996 :   return params;
      30           0 : }
      31             : 
      32         996 : AddTensorComputeAction::AddTensorComputeAction(const InputParameters & parameters)
      33         996 :   : MooseObjectAction(parameters)
      34             : {
      35         996 :   if (_type == "")
      36             :     _type = "ComputeGroup";
      37         996 :   _moose_object_pars = _factory.getValidParams(_type);
      38        1992 :   _moose_object_pars.blockFullpath() = parameters.blockFullpath();
      39         996 : }
      40             : 
      41             : void
      42         996 : AddTensorComputeAction::act()
      43             : {
      44         996 :   auto tensor_problem = std::dynamic_pointer_cast<TensorProblem>(_problem);
      45         996 :   auto lb_poblem = std::dynamic_pointer_cast<LatticeBoltzmannProblem>(_problem);
      46             : 
      47         996 :   if (!tensor_problem)
      48           0 :     mooseError("Tensor objects are only supported if the problem class is set to `TensorProblem`");
      49             : 
      50             :   // use addObject<Tensorxxxxxx>(_type, _name, _moose_object_pars, /* threaded = */ false) ?
      51             : 
      52             :   // automatically populate `computes` parameter with subblocks
      53         996 :   if (_type == "ComputeGroup")
      54             :   {
      55         100 :     auto & computes = _moose_object_pars.set<std::vector<TensorComputeName>>("computes");
      56          50 :     std::set<TensorComputeName> computes_set(computes.begin(), computes.end());
      57             : 
      58             :     // Node::children should be marked const. using this as a temporary workaround.
      59             :     auto * node = const_cast<hit::Node *>(_moose_object_pars.getHitNode());
      60          50 :     const auto children = node->children(hit::NodeType::Section);
      61         190 :     for (const auto child : children)
      62         280 :       computes_set.insert(child->path());
      63             : 
      64          50 :     computes.clear();
      65          50 :     std::copy(computes_set.begin(), computes_set.end(), std::back_inserter(computes));
      66          50 :   }
      67             : 
      68         996 :   if (_current_task == "add_tensor_ic")
      69         512 :     tensor_problem->addTensorComputeInitialize(_type, _name, _moose_object_pars);
      70             : 
      71         996 :   if (_current_task == "add_tensor_compute")
      72         454 :     tensor_problem->addTensorComputeSolve(_type, _name, _moose_object_pars);
      73             : 
      74         996 :   if (_current_task == "add_tensor_postprocessor")
      75          30 :     tensor_problem->addTensorComputePostprocess(_type, _name, _moose_object_pars);
      76             : 
      77         996 :   if (_current_task == "add_tensor_bc")
      78           0 :     lb_poblem->addTensorBoundaryCondition(_type, _name, _moose_object_pars);
      79         996 : }

Generated by: LCOV version 1.14