www.mooseframework.org
PorousFlowPlasticHeatEnergy.C
Go to the documentation of this file.
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 
11 
12 #include "MooseMesh.h"
13 #include "MooseVariable.h"
14 
16 
19 {
21  params.addParam<bool>("strain_at_nearest_qp",
22  false,
23  "When calculating nodal porosity that depends on strain, use the strain at "
24  "the nearest quadpoint. This adds a small extra computational burden, and "
25  "is not necessary for simulations involving only linear lagrange elements. "
26  " If you set this to true, you will also want to set the same parameter to "
27  "true for related Kernels and Materials");
28  params.addRequiredParam<UserObjectName>(
29  "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names.");
30  params.addClassDescription(
31  "Plastic heat energy density source = (1 - porosity) * coeff * stress * plastic_strain_rate");
32  return params;
33 }
34 
36  : PlasticHeatEnergy(parameters),
37  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
38  _strain_at_nearest_qp(getParam<bool>("strain_at_nearest_qp")),
39  _nearest_qp(_strain_at_nearest_qp
40  ? &getMaterialProperty<unsigned int>("PorousFlow_nearestqp_nodal")
41  : nullptr),
42  _porosity(getMaterialProperty<Real>("PorousFlow_porosity_nodal")),
43  _dporosity_dvar(getMaterialProperty<std::vector<Real>>("dPorousFlow_porosity_nodal_dvar")),
44  _dporosity_dgradvar(
45  getMaterialProperty<std::vector<RealGradient>>("dPorousFlow_porosity_nodal_dgradvar"))
46 {
47 }
48 
49 Real
51 {
53 }
54 
55 Real
57 {
59 }
60 
61 Real
63 {
64  // If the variable is not a PorousFlow variable, the Jacobian terms are 0
66  return 0.0;
67 
68  const Real res_no_porosity = PlasticHeatEnergy::computeQpResidual();
69  const Real jac_no_porosity = PlasticHeatEnergy::computeQpOffDiagJacobian(jvar);
70 
71  const unsigned pvar = _dictator.porousFlowVariableNum(jvar);
72  const unsigned nearest_qp = (_strain_at_nearest_qp ? (*_nearest_qp)[_i] : _i);
73 
74  Real jac = (1.0 - _porosity[_i]) * jac_no_porosity -
75  _dporosity_dgradvar[_i][pvar] * _grad_phi[_j][nearest_qp] * res_no_porosity;
76  if (_i != _j)
77  return jac;
78 
79  return jac - _dporosity_dvar[_i][pvar] * res_no_porosity;
80 }
bool notPorousFlowVariable(unsigned int moose_var_num) const
Returns true if moose_var_num is not a porous flow variabe.
MooseVariable & _var
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
unsigned int number() const
const MaterialProperty< Real > & _porosity
Porosity at the nodes, but it can depend on grad(variables) which are actually evaluated at the qps...
const VariablePhiGradient & _grad_phi
const PorousFlowDictator & _dictator
PorousFlowDictator UserObject.
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
virtual Real computeQpResidual() override
void addRequiredParam(const std::string &name, const std::string &doc_string)
const bool _strain_at_nearest_qp
Whether the porosity uses the volumetric strain at the closest quadpoint.
Provides a heat source from plastic deformation: coeff * stress * plastic_strain_rate.
unsigned int _i
unsigned int _j
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...
virtual Real computeQpJacobian() override
const MaterialProperty< std::vector< Real > > & _dporosity_dvar
d(porosity)/d(PorousFlow variable) - these derivatives will be wrt variables at the nodes ...
static InputParameters validParams()
Provides a heat source (J/m^3/s) from plastic deformation: (1 - porosity) * coeff * stress * plastic_...
PorousFlowPlasticHeatEnergy(const InputParameters &parameters)
void addClassDescription(const std::string &doc_string)
virtual Real computeQpResidual() override
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
The PorousFlow variable number.
static InputParameters validParams()
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
const MaterialProperty< std::vector< RealGradient > > & _dporosity_dgradvar
d(porosity)/d(grad PorousFlow variable) - remember these derivatives will be wrt grad(vars) at qps ...
registerMooseObject("PorousFlowApp", PorousFlowPlasticHeatEnergy)
void ErrorVector unsigned int