LCOV - code coverage report
Current view: top level - include/actions - PressureAction.h (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 18 19 94.7 %
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             : #pragma once
      11             : 
      12             : #include "Action.h"
      13             : 
      14             : /**
      15             :  * Macro to create an action for a PressureBase derived pressure boundary condition.
      16             :  *  - use declareMoosePressureAction in the header file of your pressure bc
      17             :  *  - use registerMoosePressureAction in the source file of your pressure bc
      18             :  */
      19             : #define stringifyName(name) #name
      20             : #define registerMoosePressureAction(appname, bc_class, action_class)                               \
      21             :   action_class::action_class(const InputParameters & params)                                       \
      22             :     : PressureActionBase(params, stringifyName(bc_class), "AD" stringifyName(bc_class))            \
      23             :   {                                                                                                \
      24             :   }                                                                                                \
      25             :   InputParameters action_class::validParams()                                                      \
      26             :   {                                                                                                \
      27             :     auto params = PressureActionBase::validParams<bc_class>();                                     \
      28             :     params.addClassDescription(                                                                    \
      29             :         "Set up pressure boundary condition using the " stringifyName(bc_class) " object.");       \
      30             :     return params;                                                                                 \
      31             :   }                                                                                                \
      32             :   registerMooseAction(appname, action_class, "add_bc")
      33             : 
      34             : #define declareMoosePressureAction(bc_class, action_class)                                         \
      35             :   class action_class : public PressureActionBase                                                   \
      36             :   {                                                                                                \
      37             :   public:                                                                                          \
      38             :     action_class(const InputParameters & params);                                                  \
      39             :     static InputParameters validParams();                                                          \
      40             :   }
      41             : 
      42             : /**
      43             :  * Pressure boundary condition action template. The type T is used to get the
      44             :  * valid parameters through T::actionParams(). The two strings passed into the constructor are the
      45             :  * registred type names of teh MOOSE BC objects without and with automatic differentiation.
      46             :  */
      47             : class PressureActionBase : public Action
      48             : {
      49             : public:
      50             :   template <class T>
      51             :   static InputParameters validParams();
      52             : 
      53             :   PressureActionBase(const InputParameters & params,
      54             :                      const std::string & non_ad_pressure_bc_type,
      55             :                      const std::string & ad_pressure_bc_type);
      56             : 
      57             :   virtual void act() override;
      58             : 
      59             : protected:
      60             :   const std::string _non_ad_pressure_bc_type;
      61             :   const std::string _ad_pressure_bc_type;
      62             : 
      63             :   /// Flag to use automatic differentiation
      64             :   const bool _use_ad;
      65             : 
      66             :   const std::vector<std::vector<AuxVariableName>> _save_in_vars;
      67             :   const std::vector<bool> _has_save_in_vars;
      68             : };
      69             : 
      70             : template <class T>
      71             : InputParameters
      72         872 : PressureActionBase::validParams()
      73             : {
      74         872 :   InputParameters params = Action::validParams();
      75         872 :   params += T::actionParams();
      76             : 
      77        1744 :   params.addParam<std::vector<BoundaryName>>(
      78             :       "boundary", "The list of boundaries (ids or names) from the mesh where this object applies");
      79             : 
      80         872 :   params.addClassDescription("Set up Pressure boundary conditions");
      81        1744 :   params.addParam<bool>("use_automatic_differentiation",
      82        1744 :                         false,
      83             :                         "Flag to use automatic differentiation (AD) objects when possible");
      84             : 
      85             :   // To make controlling the Pressure BCs easier
      86        2616 :   params.addParam<bool>(
      87             :       "enable",
      88        1744 :       true,
      89             :       "Set the enabled status of the BCs created by the Pressure action (defaults to true).");
      90        1744 :   params.declareControllable("enable");
      91             : 
      92             :   // Residual output
      93        1744 :   params.addParam<std::vector<AuxVariableName>>(
      94             :       "save_in_disp_x", {}, "The save_in variables for x displacement");
      95        1744 :   params.addParam<std::vector<AuxVariableName>>(
      96             :       "save_in_disp_y", {}, "The save_in variables for y displacement");
      97        1744 :   params.addParam<std::vector<AuxVariableName>>(
      98             :       "save_in_disp_z", {}, "The save_in variables for z displacement");
      99        1744 :   params.addParam<std::vector<TagName>>("extra_vector_tags",
     100             :                                         "The extra tags for the vectors this Kernel should fill");
     101        1744 :   params.addParam<std::vector<TagName>>(
     102             :       "absolute_value_vector_tags",
     103             :       "The tags for the vectors this residual object should fill with the "
     104             :       "absolute value of the residual contribution");
     105             : 
     106        1744 :   params.addParam<bool>(
     107             :       "use_displaced_mesh",
     108             :       "Whether or not this object should use the displaced mesh for computation. Note that in "
     109             :       "the case this is true but no displacements are provided in the Mesh block the undisplaced "
     110             :       "mesh will still be used. For small strain formulations pressure should be applied to the "
     111             :       "undisplaced mesh to obtain agreement with analytical benchmark solutions.");
     112             : 
     113        1744 :   params.addParamNamesToGroup(
     114             :       "save_in_disp_x save_in_disp_y save_in_disp_z extra_vector_tags absolute_value_vector_tags",
     115             :       "Residual output");
     116         872 :   return params;
     117           0 : }

Generated by: LCOV version 1.14