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 "MaterialVectorBodyForceAction.h" 11 : #include "Factory.h" 12 : #include "FEProblem.h" 13 : #include "Conversion.h" 14 : 15 : registerMooseAction("SolidMechanicsApp", MaterialVectorBodyForceAction, "add_kernel"); 16 : 17 : InputParameters 18 12 : MaterialVectorBodyForceAction::validParams() 19 : { 20 12 : InputParameters params = Action::validParams(); 21 12 : params.addClassDescription("Set up volumetric body force kernels"); 22 : 23 24 : params.addParam<std::vector<SubdomainName>>("block", 24 : "The block ids where the body force will be applied"); 25 : 26 24 : params.addParam<std::vector<VariableName>>( 27 : "displacements", 28 : {}, 29 : "The displacements appropriate for the simulation geometry and coordinate system"); 30 : 31 24 : params.addParam<FunctionName>( 32 : "function", "1", "Function to scale the coupled body force vector property"); 33 24 : params.addParam<Real>( 34 24 : "hht_alpha", 0.0, "alpha parameter required for HHT time integration scheme"); 35 24 : params.addRequiredParam<MaterialPropertyName>("body_force", "Force per unit volume vector"); 36 12 : return params; 37 0 : } 38 : 39 12 : MaterialVectorBodyForceAction::MaterialVectorBodyForceAction(const InputParameters & params) 40 12 : : Action(params) 41 : { 42 12 : } 43 : 44 : void 45 12 : MaterialVectorBodyForceAction::act() 46 : { 47 12 : std::string kernel_type = "MaterialVectorBodyForce"; 48 : 49 36 : auto displacements = getParam<std::vector<VariableName>>("displacements"); 50 42 : for (const auto & disp : displacements) 51 : { 52 30 : InputParameters params = _factory.getValidParams(kernel_type); 53 30 : params.applyParameters(parameters()); 54 60 : params.set<NonlinearVariableName>("variable") = disp; 55 30 : _problem->addKernel(kernel_type, _name + "_" + disp, params); 56 30 : } 57 24 : }