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 "PressureAction.h" 11 : #include "Factory.h" 12 : #include "FEProblem.h" 13 : #include "Conversion.h" 14 : 15 : registerMooseAction("TensorMechanicsApp", PressureAction, "add_bc"); 16 : 17 : InputParameters 18 403 : PressureAction::validParams() 19 : { 20 403 : InputParameters params = Action::validParams(); 21 403 : params.addClassDescription("Set up Pressure boundary conditions"); 22 : 23 806 : params.addRequiredParam<std::vector<BoundaryName>>( 24 : "boundary", "The list of boundary IDs from the mesh where the pressure will be applied"); 25 : 26 806 : params.addRequiredParam<std::vector<VariableName>>( 27 : "displacements", 28 : "The displacements appropriate for the simulation geometry and coordinate system"); 29 : 30 806 : params.addParam<std::vector<AuxVariableName>>( 31 : "save_in_disp_x", {}, "The save_in variables for x displacement"); 32 806 : params.addParam<std::vector<AuxVariableName>>( 33 : "save_in_disp_y", {}, "The save_in variables for y displacement"); 34 806 : params.addParam<std::vector<AuxVariableName>>( 35 : "save_in_disp_z", {}, "The save_in variables for z displacement"); 36 : 37 806 : params.addParam<Real>("factor", 1.0, "The factor to use in computing the pressure"); 38 806 : params.addParam<bool>("use_displaced_mesh", true, "Whether to use the displaced mesh."); 39 806 : params.addParam<Real>("hht_alpha", 40 806 : 0, 41 : "alpha parameter for mass dependent numerical damping induced " 42 : "by HHT time integration scheme"); 43 806 : params.addDeprecatedParam<Real>( 44 : "alpha", "alpha parameter for HHT time integration", "Please use hht_alpha"); 45 806 : params.addParam<FunctionName>("function", "The function that describes the pressure"); 46 806 : params.addParam<bool>("use_automatic_differentiation", 47 806 : false, 48 : "Flag to use automatic differentiation (AD) objects when possible"); 49 806 : params.addParam<std::vector<TagName>>("extra_vector_tags", 50 : "The extra tags for the vectors this Kernel should fill"); 51 806 : params.addParam<std::vector<TagName>>( 52 : "absolute_value_vector_tags", 53 : "The tags for the vectors this residual object should fill with the " 54 : "absolute value of the residual contribution"); 55 403 : return params; 56 0 : } 57 : 58 403 : PressureAction::PressureAction(const InputParameters & params) 59 806 : : Action(params), _use_ad(getParam<bool>("use_automatic_differentiation")) 60 : { 61 806 : _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_x")); 62 806 : _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_y")); 63 806 : _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_z")); 64 : 65 403 : _has_save_in_vars.push_back(params.isParamValid("save_in_disp_x")); 66 403 : _has_save_in_vars.push_back(params.isParamValid("save_in_disp_y")); 67 403 : _has_save_in_vars.push_back(params.isParamValid("save_in_disp_z")); 68 403 : } 69 : 70 : void 71 403 : PressureAction::act() 72 : { 73 403 : std::string ad_prepend = ""; 74 403 : if (_use_ad) 75 : ad_prepend = "AD"; 76 : 77 403 : std::string kernel_name = ad_prepend + "Pressure"; 78 : 79 806 : std::vector<VariableName> displacements = getParam<std::vector<VariableName>>("displacements"); 80 : 81 : // Create pressure BCs 82 1504 : for (unsigned int i = 0; i < displacements.size(); ++i) 83 : { 84 : // Create unique kernel name for each of the components 85 3303 : std::string unique_kernel_name = kernel_name + "_" + _name + "_" + Moose::stringify(i); 86 : 87 1101 : InputParameters params = _factory.getValidParams(kernel_name); 88 2202 : params.applyParameters(parameters(), {"factor"}); 89 1101 : params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh"); 90 1101 : params.set<Real>("alpha") = 91 5505 : isParamValid("alpha") ? getParam<Real>("alpha") : getParam<Real>("hht_alpha"); 92 : 93 2202 : params.set<NonlinearVariableName>("variable") = displacements[i]; 94 : 95 1101 : if (_has_save_in_vars[i]) 96 2202 : params.set<std::vector<AuxVariableName>>("save_in") = _save_in_vars[i]; 97 : 98 2202 : params.set<Real>("factor") = getParam<Real>("factor"); 99 1101 : _problem->addBoundaryCondition(kernel_name, unique_kernel_name, params); 100 1101 : } 101 3008 : }