https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PorousFlowPorosityBase.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
12template <bool is_ad>
15{
17 params.addPrivateParam<std::string>("pf_material_type", "porosity");
18 params.addParam<Real>(
19 "porosity_min",
20 0.0,
21 "Minimum allowed value of the porosity: if the computed porosity is less than this value, "
22 "porosity is set to this value instead. The default of zero means porosity is never "
23 "negative. A negative value may be used, for instance, when comparing with analytical "
24 "solutions of linear poroelasticity in which porosity can become negative");
25 params.addRangeCheckedParam<Real>(
26 "zero_modifier",
27 1E-3,
28 "zero_modifier >= 0",
29 "If the porosity_min floor is active, the porosity derivatives are set to zero_modifier "
30 "times their unfloored values (rather than exactly zero) to hint to the nonlinear solver "
31 "that porosity is not strictly constant, which aids convergence");
32 params.addParamNamesToGroup("zero_modifier", "Advanced");
33 params.addClassDescription("Base class Material for porosity");
34 return params;
35}
36
37template <bool is_ad>
39 : PorousFlowMaterialVectorBase(parameters),
40 _porosity(_nodal_material ? declareGenericProperty<Real, is_ad>("PorousFlow_porosity_nodal")
41 : declareGenericProperty<Real, is_ad>("PorousFlow_porosity_qp")),
42 _dporosity_dvar(is_ad ? nullptr
43 : _nodal_material
44 ? &declareProperty<std::vector<Real>>("dPorousFlow_porosity_nodal_dvar")
45 : &declareProperty<std::vector<Real>>("dPorousFlow_porosity_qp_dvar")),
46 _dporosity_dgradvar(
47 is_ad ? nullptr
48 : _nodal_material
49 ? &declareProperty<std::vector<RealGradient>>("dPorousFlow_porosity_nodal_dgradvar")
50 : &declareProperty<std::vector<RealGradient>>("dPorousFlow_porosity_qp_dgradvar")),
51 _porosity_min(getParam<Real>("porosity_min")),
52 _zero_modifier(getParam<Real>("zero_modifier"))
53{
54}
55
56template <bool is_ad>
57void
59{
60 if (MetaPhysicL::raw_value(_porosity[_qp]) >= _porosity_min)
61 return;
62
63 if constexpr (!is_ad)
64 {
65 _porosity[_qp] = _porosity_min;
66 for (unsigned int v = 0; v < _num_var; ++v)
67 {
68 (*_dporosity_dvar)[_qp][v] *= _zero_modifier;
69 (*_dporosity_dgradvar)[_qp][v] *= _zero_modifier;
70 }
71 }
72 else
73 {
74 // The AD path carries its derivatives inside the value and has no derivative material
75 // properties, so the value and the derivatives are softened separately. Assigning
76 // _porosity_min to the ADReal would instead discard the derivatives entirely.
77 _porosity[_qp].value() = _porosity_min;
78 _porosity[_qp].derivatives() *= _zero_modifier;
79 }
80}
81
const double v
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
void addPrivateParam(const std::string &name, const T &value)
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)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
Base class for all PorousFlow vector materials.
Base class Material designed to provide the porosity.
PorousFlowPorosityBaseTempl(const InputParameters &parameters)
void applyPorosityMin()
If _porosity[_qp] < porosity_min, set _porosity[_qp] = porosity_min and multiply the derivatives of p...
static InputParameters validParams()
auto raw_value(const Eigen::Map< T > &in)