https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PorousFlowVolumetricStrain.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#include "MooseMesh.h"
12
13#include "libmesh/quadrature.h"
14
17
18template <bool is_ad>
21{
23 params.addParam<std::string>("base_name",
24 "This should be the same base_name as given to the TensorMechanics "
25 "object that computes strain");
27 "displacements",
28 "The displacements appropriate for the simulation geometry and coordinate system");
30 "Compute volumetric strain and the volumetric_strain rate, for use in PorousFlow.");
31 params.set<std::string>("pf_material_type") = "volumetric_strain";
32 params.set<bool>("stateful_displacements") = true;
33 params.set<bool>("at_nodes") = false;
34 return params;
35}
36
37template <bool is_ad>
39 const InputParameters & parameters)
40 : PorousFlowMaterialVectorBase(parameters),
41 _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
42 _total_strain(getGenericMaterialProperty<RankTwoTensor, is_ad>(_base_name + "total_strain")),
43 _total_strain_old(getMaterialPropertyOld<RankTwoTensor>(_base_name + "total_strain")),
44 _ndisp(coupledComponents("displacements")),
45 _disp_var_num(coupledIndices("displacements")),
46
47 _vol_strain_rate_qp(
48 declareGenericProperty<Real, is_ad>("PorousFlow_volumetric_strain_rate_qp")),
49 _dvol_strain_rate_qp_dvar(is_ad ? nullptr
50 : &declareProperty<std::vector<RealGradient>>(
51 "dPorousFlow_volumetric_strain_rate_qp_dvar")),
52 _vol_total_strain_qp(
53 declareGenericProperty<Real, is_ad>("PorousFlow_total_volumetric_strain_qp")),
54 _dvol_total_strain_qp_dvar(is_ad ? nullptr
55 : &declareProperty<std::vector<RealGradient>>(
56 "dPorousFlow_total_volumetric_strain_qp_dvar"))
57{
58 if (_ndisp != _mesh.dimension())
59 paramError("displacements", "The number of variables supplied must match the mesh dimension.");
60
61 if (_nodal_material)
62 mooseError("PorousFlowVolumetricStrain classes are only defined for at_nodes = false");
63}
64
65template <bool is_ad>
66void
68{
69 _vol_total_strain_qp[_qp] = 0.0;
70}
71
72template <bool is_ad>
73void
75{
76 _vol_total_strain_qp[_qp] = _total_strain[_qp].trace();
77 _vol_strain_rate_qp[_qp] = (_vol_total_strain_qp[_qp] - _total_strain_old[_qp].trace()) / _dt;
78
79 if constexpr (!is_ad)
80 {
81 // The AD path carries the derivatives with respect to the displacement variables inside the
82 // AD strain, so only the non-AD path needs to fill in these derivative material properties.
83 (*_dvol_strain_rate_qp_dvar)[_qp].resize(_num_var, RealGradient());
84 (*_dvol_total_strain_qp_dvar)[_qp].resize(_num_var, RealGradient());
85 for (unsigned i = 0; i < _ndisp; ++i)
86 if (_dictator.isPorousFlowVariable(_disp_var_num[i]))
87 {
88 // the i_th displacement is a PorousFlow variable
89 const unsigned int pvar = _dictator.porousFlowVariableNum(_disp_var_num[i]);
90 (*_dvol_strain_rate_qp_dvar)[_qp][pvar](i) = 1.0 / _dt;
91 (*_dvol_total_strain_qp_dvar)[_qp][pvar](i) = 1.0;
92 }
93 }
94}
95
void mooseError(Args &&... args)
registerMooseObject("PorousFlowApp", PorousFlowVolumetricStrain)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
Base class for all PorousFlow vector materials.
PorousFlowVolumetricStrain computes volumetric strains, and derivatives thereof.
const unsigned int _ndisp
Number of displacements supplied (1 in 1D, 2 in 2D, 3 in 3D)
PorousFlowVolumetricStrainTempl(const InputParameters &parameters)
virtual void initQpStatefulProperties() override