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