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 "PoroMechanicsAction.h" 11 : 12 : #include "Factory.h" 13 : #include "FEProblem.h" 14 : #include "Parser.h" 15 : #include "Conversion.h" 16 : 17 : registerMooseAction("SolidMechanicsApp", PoroMechanicsAction, "setup_mesh_complete"); 18 : 19 : registerMooseAction("SolidMechanicsApp", PoroMechanicsAction, "validate_coordinate_systems"); 20 : 21 : registerMooseAction("SolidMechanicsApp", PoroMechanicsAction, "add_kernel"); 22 : 23 : InputParameters 24 7 : PoroMechanicsAction::validParams() 25 : { 26 7 : InputParameters params = QuasiStaticSolidMechanicsPhysics::validParams(); 27 14 : params.addRequiredParam<VariableName>("porepressure", "The pore pressure variable"); 28 7 : params.addClassDescription("Adds the poro-mechanics coupling term"); 29 7 : return params; 30 0 : } 31 : 32 7 : PoroMechanicsAction::PoroMechanicsAction(const InputParameters & params) 33 7 : : QuasiStaticSolidMechanicsPhysics(params) 34 : { 35 7 : if (_use_ad) 36 0 : paramError("use_ad", "AD not setup for use with PoroMechanicsAction"); 37 7 : } 38 : 39 : void 40 21 : PoroMechanicsAction::act() 41 : { 42 21 : QuasiStaticSolidMechanicsPhysics::act(); 43 : 44 21 : if (_current_task == "add_kernel") 45 : { 46 : // Prepare displacements and set value for dim 47 21 : std::vector<VariableName> displacements = getParam<std::vector<VariableName>>("displacements"); 48 7 : unsigned int dim = displacements.size(); 49 : 50 : // all the kernels added below have pore pressure as a coupled variable 51 : // add this to the kernel's params 52 7 : std::string type("PoroMechanicsCoupling"); 53 7 : InputParameters params = _factory.getValidParams(type); 54 7 : VariableName pp_var(getParam<VariableName>("porepressure")); 55 14 : params.addCoupledVar("porepressure", ""); 56 21 : params.set<std::vector<VariableName>>("porepressure") = {pp_var}; 57 : 58 : // now add the kernels 59 28 : for (unsigned int i = 0; i < dim; ++i) 60 : { 61 21 : std::string kernel_name = "PoroMechanics" + Moose::stringify(i); 62 : 63 21 : params.set<unsigned int>("component") = i; 64 42 : params.set<NonlinearVariableName>("variable") = displacements[i]; 65 : 66 21 : _problem->addKernel(type, kernel_name, params); 67 : } 68 14 : } 69 21 : }