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 "InclinedNoDisplacementBCAction.h" 11 : #include "Factory.h" 12 : #include "FEProblem.h" 13 : #include "Conversion.h" 14 : 15 : registerMooseAction("SolidMechanicsApp", InclinedNoDisplacementBCAction, "add_bc"); 16 : 17 : InputParameters 18 54 : InclinedNoDisplacementBCAction::validParams() 19 : { 20 54 : InputParameters params = Action::validParams(); 21 54 : params.addClassDescription("Set up inclined no displacement boundary conditions"); 22 : 23 108 : params.addRequiredParam<std::vector<BoundaryName>>( 24 : "boundary", "The list of boundary IDs from the mesh where the pressure will be applied"); 25 : 26 108 : params.addParam<std::vector<VariableName>>( 27 : "displacements", 28 : {}, 29 : "The displacements appropriate for the simulation geometry and coordinate system"); 30 108 : params.addParam<std::vector<AuxVariableName>>("save_in", {}, "The displacement residuals"); 31 : 32 108 : params.addRequiredParam<Real>("penalty", "Penalty parameter"); 33 108 : params.addParam<bool>("use_automatic_differentiation", 34 108 : false, 35 : "Flag to use automatic differentiation (AD) objects when possible"); 36 54 : return params; 37 0 : } 38 : 39 54 : InclinedNoDisplacementBCAction::InclinedNoDisplacementBCAction(const InputParameters & params) 40 : : Action(params), 41 54 : _use_ad(getParam<bool>("use_automatic_differentiation")), 42 162 : _displacements(getParam<std::vector<VariableName>>("displacements")), 43 54 : _ndisp(_displacements.size()), 44 162 : _save_in(getParam<std::vector<AuxVariableName>>("save_in")) 45 : { 46 54 : if (_ndisp == 1) 47 0 : mooseError("InclinedNoDisplacementBC is specific to 2D and 3D models."); 48 : 49 54 : if (_save_in.size() != 0 && _save_in.size() != _ndisp) 50 0 : mooseError("Number of save_in variables should equal to the number of displacement variables ", 51 0 : _displacements.size()); 52 54 : } 53 : 54 : void 55 54 : InclinedNoDisplacementBCAction::act() 56 : { 57 54 : std::string ad_prepend = ""; 58 54 : if (_use_ad) 59 : ad_prepend = "AD"; 60 54 : const std::string kernel_name = ad_prepend + "PenaltyInclinedNoDisplacementBC"; 61 : 62 : // Create pressure BCs 63 204 : for (unsigned int i = 0; i < _ndisp; ++i) 64 : { 65 : // Create unique kernel name for each of the components 66 450 : std::string unique_kernel_name = kernel_name + "_" + _name + "_" + Moose::stringify(i); 67 : 68 150 : InputParameters params = _factory.getValidParams(kernel_name); 69 150 : params.applyParameters(parameters()); 70 150 : params.set<bool>("use_displaced_mesh") = false; 71 150 : params.set<unsigned int>("component") = i; 72 300 : params.set<NonlinearVariableName>("variable") = _displacements[i]; 73 : 74 150 : if (_save_in.size() == _ndisp) 75 0 : params.set<std::vector<AuxVariableName>>("save_in") = {_save_in[i]}; 76 : 77 150 : _problem->addBoundaryCondition(kernel_name, unique_kernel_name, params); 78 150 : } 79 54 : }