LCOV - code coverage report
Current view: top level - src/actions - CoupledPressureAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 35 36 97.2 %
Date: 2024-02-27 11:53:14 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://www.mooseframework.org
       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 "CoupledPressureAction.h"
      11             : #include "Factory.h"
      12             : #include "FEProblem.h"
      13             : #include "Conversion.h"
      14             : 
      15             : registerMooseAction("TensorMechanicsApp", CoupledPressureAction, "add_bc");
      16             : 
      17             : InputParameters
      18           6 : CoupledPressureAction::validParams()
      19             : {
      20           6 :   InputParameters params = Action::validParams();
      21           6 :   params.addClassDescription("Set up Coupled Pressure boundary conditions");
      22             : 
      23          12 :   params.addRequiredParam<std::vector<BoundaryName>>(
      24             :       "boundary", "The list of boundary IDs from the mesh where the pressure will be applied");
      25             : 
      26          12 :   params.addParam<std::vector<VariableName>>(
      27             :       "displacements",
      28             :       {},
      29             :       "The displacements appropriate for the simulation geometry and coordinate system");
      30             : 
      31          12 :   params.addParam<bool>("use_displaced_mesh", true, "Whether to use the displaced mesh.");
      32          12 :   params.addParam<std::vector<AuxVariableName>>(
      33             :       "save_in_disp_x", {}, "The save_in variables for x displacement");
      34          12 :   params.addParam<std::vector<AuxVariableName>>(
      35             :       "save_in_disp_y", {}, "The save_in variables for y displacement");
      36          12 :   params.addParam<std::vector<AuxVariableName>>(
      37             :       "save_in_disp_z", {}, "The save_in variables for z displacement");
      38             : 
      39          12 :   params.addParam<VariableName>("pressure", "The variable that contains the pressure");
      40           6 :   return params;
      41           0 : }
      42             : 
      43           6 : CoupledPressureAction::CoupledPressureAction(const InputParameters & params) : Action(params)
      44             : {
      45          12 :   _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_x"));
      46          12 :   _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_y"));
      47          12 :   _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_z"));
      48             : 
      49           6 :   _has_save_in_vars.push_back(params.isParamValid("save_in_disp_x"));
      50           6 :   _has_save_in_vars.push_back(params.isParamValid("save_in_disp_y"));
      51           6 :   _has_save_in_vars.push_back(params.isParamValid("save_in_disp_z"));
      52           6 : }
      53             : 
      54             : void
      55           6 : CoupledPressureAction::act()
      56             : {
      57           6 :   const std::string kernel_name = "CoupledPressureBC";
      58             : 
      59          12 :   std::vector<VariableName> displacements = getParam<std::vector<VariableName>>("displacements");
      60             : 
      61             :   // Create pressure BCs
      62          24 :   for (unsigned int i = 0; i < displacements.size(); ++i)
      63             :   {
      64             :     // Create unique kernel name for each of the components
      65          54 :     std::string unique_kernel_name = kernel_name + "_" + _name + "_" + Moose::stringify(i);
      66             : 
      67          18 :     InputParameters params = _factory.getValidParams(kernel_name);
      68          36 :     params.applySpecificParameters(parameters(), {"boundary"});
      69          54 :     params.set<std::vector<VariableName>>("pressure") = {getParam<VariableName>("pressure")};
      70          18 :     params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
      71          18 :     params.set<unsigned int>("component") = i;
      72          36 :     params.set<NonlinearVariableName>("variable") = displacements[i];
      73             : 
      74          18 :     if (_has_save_in_vars[i])
      75          36 :       params.set<std::vector<AuxVariableName>>("save_in") = _save_in_vars[i];
      76             : 
      77          18 :     _problem->addBoundaryCondition(kernel_name, unique_kernel_name, params);
      78          18 :   }
      79          66 : }

Generated by: LCOV version 1.14