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