LCOV - code coverage report
Current view: top level - src/actions - PoroMechanicsAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #32971 (54bef8) with base c6cf66 Lines: 26 28 92.9 %
Date: 2026-05-29 20:40:07 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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           4 : PoroMechanicsAction::validParams()
      25             : {
      26           4 :   InputParameters params = QuasiStaticSolidMechanicsPhysics::validParams();
      27           8 :   params.addRequiredParam<VariableName>("porepressure", "The pore pressure variable");
      28           4 :   params.addClassDescription("Adds the poro-mechanics coupling term");
      29           4 :   return params;
      30           0 : }
      31             : 
      32           4 : PoroMechanicsAction::PoroMechanicsAction(const InputParameters & params)
      33           4 :   : QuasiStaticSolidMechanicsPhysics(params)
      34             : {
      35           4 :   if (_use_ad)
      36           0 :     paramError("use_ad", "AD not setup for use with PoroMechanicsAction");
      37           4 : }
      38             : 
      39             : void
      40          12 : PoroMechanicsAction::act()
      41             : {
      42          12 :   QuasiStaticSolidMechanicsPhysics::act();
      43             : 
      44          12 :   if (_current_task == "add_kernel")
      45             :   {
      46             :     // Prepare displacements and set value for dim
      47          12 :     std::vector<VariableName> displacements = getParam<std::vector<VariableName>>("displacements");
      48           4 :     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           4 :     std::string type("PoroMechanicsCoupling");
      53           4 :     InputParameters params = _factory.getValidParams(type);
      54           4 :     VariableName pp_var(getParam<VariableName>("porepressure"));
      55           8 :     params.addCoupledVar("porepressure", "");
      56          12 :     params.set<std::vector<VariableName>>("porepressure") = {pp_var};
      57             : 
      58             :     // now add the kernels
      59          16 :     for (unsigned int i = 0; i < dim; ++i)
      60             :     {
      61          12 :       std::string kernel_name = "PoroMechanics" + Moose::stringify(i);
      62             : 
      63          12 :       params.set<unsigned int>("component") = i;
      64          24 :       params.set<NonlinearVariableName>("variable") = displacements[i];
      65             : 
      66          12 :       _problem->addKernel(type, kernel_name, params);
      67             :     }
      68           8 :   }
      69          12 : }

Generated by: LCOV version 1.14