https://mooseframework.inl.gov
PorousFlowEffectiveStressCoupling.C
Go to the documentation of this file.
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 
11 
12 #include "Function.h"
13 #include "MooseMesh.h"
14 #include "MooseVariable.h"
15 
18 
19 template <bool is_ad>
22 {
24  params.addClassDescription("Implements the weak form of the expression biot_coefficient * "
25  "grad(effective fluid pressure)");
26  params.addRequiredParam<UserObjectName>(
27  "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names.");
28  params.addRangeCheckedParam<Real>(
29  "biot_coefficient", 1, "biot_coefficient>=0&biot_coefficient<=1", "Biot coefficient");
30  params.addRequiredParam<unsigned int>("component",
31  "The component (0 for x, 1 for y and 2 for z) of grad(P)");
32  return params;
33 }
34 
35 template <bool is_ad>
37  const InputParameters & parameters)
38  : GenericKernel<is_ad>(parameters),
39  _dictator(this->template getUserObject<PorousFlowDictator>("PorousFlowDictator")),
40  _coefficient(this->template getParam<Real>("biot_coefficient")),
41  _component(this->template getParam<unsigned int>("component")),
42  _pf(this->template getGenericMaterialProperty<Real, is_ad>(
43  "PorousFlow_effective_fluid_pressure_qp")),
44  _dpf_dvar(is_ad ? nullptr
45  : &this->template getMaterialProperty<std::vector<Real>>(
46  "dPorousFlow_effective_fluid_pressure_qp_dvar")),
47  _rz(this->getBlockCoordSystem() == Moose::COORD_RZ)
48 {
49  if (_component >= this->_mesh.dimension())
50  this->paramError("component", "The component cannot be greater than the mesh dimension");
51 }
52 
53 template <bool is_ad>
56 {
57  if (_rz && _component == 0)
58  return -_coefficient * _pf[_qp] * (_grad_test[_i][_qp](0) + _test[_i][_qp] / _q_point[_qp](0));
59  return -_coefficient * _pf[_qp] * _grad_test[_i][_qp](_component);
60 }
61 
62 template <bool is_ad>
63 Real
65 {
66  if constexpr (!is_ad)
67  {
68  if (_dictator.notPorousFlowVariable(_var.number()))
69  return 0.0;
70  const unsigned int pvar = _dictator.porousFlowVariableNum(_var.number());
71  if (_rz && _component == 0)
72  return -_coefficient * _phi[_j][_qp] * (*_dpf_dvar)[_qp][pvar] *
73  (_grad_test[_i][_qp](0) + _test[_i][_qp] / _q_point[_qp](0));
74  return -_coefficient * _phi[_j][_qp] * (*_dpf_dvar)[_qp][pvar] *
75  _grad_test[_i][_qp](_component);
76  }
77  return 0.0;
78 }
79 
80 template <bool is_ad>
81 Real
83 {
84  if constexpr (!is_ad)
85  {
86  if (_dictator.notPorousFlowVariable(jvar))
87  return 0.0;
88  const unsigned int pvar = _dictator.porousFlowVariableNum(jvar);
89  if (_rz && _component == 0)
90  return -_coefficient * _phi[_j][_qp] * (*_dpf_dvar)[_qp][pvar] *
91  (_grad_test[_i][_qp](0) + _test[_i][_qp] / _q_point[_qp](0));
92  return -_coefficient * _phi[_j][_qp] * (*_dpf_dvar)[_qp][pvar] *
93  _grad_test[_i][_qp](_component);
94  }
95  else
96  libmesh_ignore(jvar);
97  return 0.0;
98 }
99 
MooseMesh & _mesh
Moose::GenericType< Real, is_ad > GenericReal
registerMooseObject("PorousFlowApp", PorousFlowEffectiveStressCoupling)
void paramError(const std::string &param, Args... args) const
static InputParameters validParams()
PorousFlowEffectiveStressCouplingTempl(const InputParameters &parameters)
COORD_RZ
void addRequiredParam(const std::string &name, const std::string &doc_string)
void libmesh_ignore(const Args &...)
virtual unsigned int dimension() const
virtual GenericReal< is_ad > computeQpResidual() override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
PorousFlowEffectiveStressCoupling computes -coefficient*effective_porepressure*grad_component(test) w...
const unsigned int _component
The spatial component.
void addClassDescription(const std::string &doc_string)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
void ErrorVector unsigned int