LCOV - code coverage report
Current view: top level - src/actions - PressureAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 25 25 100.0 %
Date: 2025-07-25 05:00:39 Functions: 2 2 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 "PressureAction.h"
      11             : #include "Factory.h"
      12             : #include "FEProblem.h"
      13             : #include "Conversion.h"
      14             : 
      15         872 : PressureActionBase::PressureActionBase(const InputParameters & params,
      16             :                                        const std::string & non_ad_pressure_bc_type,
      17         872 :                                        const std::string & ad_pressure_bc_type)
      18             :   : Action(params),
      19         872 :     _non_ad_pressure_bc_type(non_ad_pressure_bc_type),
      20         872 :     _ad_pressure_bc_type(ad_pressure_bc_type),
      21        1744 :     _use_ad(getParam<bool>("use_automatic_differentiation")),
      22        4360 :     _save_in_vars({getParam<std::vector<AuxVariableName>>("save_in_disp_x"),
      23             :                    getParam<std::vector<AuxVariableName>>("save_in_disp_y"),
      24             :                    getParam<std::vector<AuxVariableName>>("save_in_disp_z")}),
      25        1744 :     _has_save_in_vars({params.isParamValid("save_in_disp_x"),
      26        1744 :                        params.isParamValid("save_in_disp_y"),
      27        2616 :                        params.isParamValid("save_in_disp_z")})
      28             : {
      29        5232 : }
      30             : 
      31             : void
      32         866 : PressureActionBase::act()
      33             : {
      34         866 :   const auto bc_type = _use_ad ? _ad_pressure_bc_type : _non_ad_pressure_bc_type;
      35             : 
      36        1732 :   std::vector<VariableName> displacements = getParam<std::vector<VariableName>>("displacements");
      37             :   // Create pressure BCs
      38        3238 :   for (unsigned int i = 0; i < displacements.size(); ++i)
      39             :   {
      40             :     // Create unique kernel name for each of the components
      41        7116 :     std::string bc_name = bc_type + "_" + _name + "_" + Moose::stringify(i);
      42             : 
      43        2372 :     InputParameters params = _factory.getValidParams(bc_type);
      44        2372 :     params.applyParameters(parameters());
      45             : 
      46        4744 :     params.set<NonlinearVariableName>("variable") = displacements[i];
      47        2372 :     if (_has_save_in_vars[i])
      48        4744 :       params.set<std::vector<AuxVariableName>>("save_in") = _save_in_vars[i];
      49             : 
      50        2372 :     _problem->addBoundaryCondition(bc_type, bc_name, params);
      51             : 
      52             :     // The three BCs can no longer be controlled independently.
      53             :     // We agreed on PR#29603 that this was not a problem
      54        4744 :     if (isParamValid("enable"))
      55        4744 :       connectControllableParams("enable", bc_type, bc_name, "enable");
      56        2372 :   }
      57        1732 : }

Generated by: LCOV version 1.14