LCOV - code coverage report
Current view: top level - src/actions - PoroMechanicsAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 26 28 92.9 %
Date: 2025-07-25 05:00:39 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           6 : PoroMechanicsAction::validParams()
      25             : {
      26           6 :   InputParameters params = QuasiStaticSolidMechanicsPhysics::validParams();
      27          12 :   params.addRequiredParam<VariableName>("porepressure", "The pore pressure variable");
      28           6 :   params.addClassDescription("Adds the poro-mechanics coupling term");
      29           6 :   return params;
      30           0 : }
      31             : 
      32           6 : PoroMechanicsAction::PoroMechanicsAction(const InputParameters & params)
      33           6 :   : QuasiStaticSolidMechanicsPhysics(params)
      34             : {
      35           6 :   if (_use_ad)
      36           0 :     paramError("use_ad", "AD not setup for use with PoroMechanicsAction");
      37           6 : }
      38             : 
      39             : void
      40          18 : PoroMechanicsAction::act()
      41             : {
      42          18 :   QuasiStaticSolidMechanicsPhysics::act();
      43             : 
      44          18 :   if (_current_task == "add_kernel")
      45             :   {
      46             :     // Prepare displacements and set value for dim
      47          18 :     std::vector<VariableName> displacements = getParam<std::vector<VariableName>>("displacements");
      48           6 :     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           6 :     std::string type("PoroMechanicsCoupling");
      53           6 :     InputParameters params = _factory.getValidParams(type);
      54           6 :     VariableName pp_var(getParam<VariableName>("porepressure"));
      55          12 :     params.addCoupledVar("porepressure", "");
      56          18 :     params.set<std::vector<VariableName>>("porepressure") = {pp_var};
      57             : 
      58             :     // now add the kernels
      59          24 :     for (unsigned int i = 0; i < dim; ++i)
      60             :     {
      61          18 :       std::string kernel_name = "PoroMechanics" + Moose::stringify(i);
      62             : 
      63          18 :       params.set<unsigned int>("component") = i;
      64          36 :       params.set<NonlinearVariableName>("variable") = displacements[i];
      65             : 
      66          18 :       _problem->addKernel(type, kernel_name, params);
      67             :     }
      68          12 :   }
      69          18 : }

Generated by: LCOV version 1.14