https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PorousFlowVariableBase.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", "pressure_saturation");
18 params.addClassDescription("Base class for thermophysical variable materials. Provides pressure "
19 "and saturation material properties for all phases as required");
20 return params;
21}
22
23template <bool is_ad>
26
27 _num_phases(_dictator.numPhases()),
28 _num_components(_dictator.numComponents()),
29 _num_pf_vars(_dictator.numVariables()),
30
31 _porepressure(
32 _nodal_material
33 ? declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_porepressure_nodal")
34 : declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_porepressure_qp")),
35 _dporepressure_dvar(is_ad ? nullptr
36 : _nodal_material ? &declareProperty<std::vector<std::vector<Real>>>(
37 "dPorousFlow_porepressure_nodal_dvar")
38 : &declareProperty<std::vector<std::vector<Real>>>(
39 "dPorousFlow_porepressure_qp_dvar")),
40 _gradp_qp(_nodal_material ? nullptr
41 : &declareGenericProperty<std::vector<RealGradient>, is_ad>(
42 "PorousFlow_grad_porepressure_qp")),
43 _dgradp_qp_dgradv((_nodal_material || is_ad)
44 ? nullptr
45 : &declareProperty<std::vector<std::vector<Real>>>(
46 "dPorousFlow_grad_porepressure_qp_dgradvar")),
47 _dgradp_qp_dv((_nodal_material || is_ad)
48 ? nullptr
49 : &declareProperty<std::vector<std::vector<RealGradient>>>(
50 "dPorousFlow_grad_porepressure_qp_dvar")),
51
52 _saturation(
53 _nodal_material
54 ? declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_saturation_nodal")
55 : declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_saturation_qp")),
56 _dsaturation_dvar(
57 is_ad ? nullptr
58 : _nodal_material
59 ? &declareProperty<std::vector<std::vector<Real>>>("dPorousFlow_saturation_nodal_dvar")
60 : &declareProperty<std::vector<std::vector<Real>>>("dPorousFlow_saturation_qp_dvar")),
61 _grads_qp(_nodal_material ? nullptr
62 : &declareGenericProperty<std::vector<RealGradient>, is_ad>(
63 "PorousFlow_grad_saturation_qp")),
64 _dgrads_qp_dgradv((_nodal_material || is_ad) ? nullptr
65 : &declareProperty<std::vector<std::vector<Real>>>(
66 "dPorousFlow_grad_saturation_qp_dgradvar")),
67 _dgrads_qp_dv((_nodal_material || is_ad)
68 ? nullptr
69 : &declareProperty<std::vector<std::vector<RealGradient>>>(
70 "dPorousFlow_grad_saturation_qp_dvar"))
71{
72}
73
74template <bool is_ad>
75void
77{
78 _porepressure[_qp].resize(_num_phases);
79 _saturation[_qp].resize(_num_phases);
80 // the porepressure and saturation values get set by derived classes
81}
82
83template <bool is_ad>
84void
86{
87 // do we really need this stuff here? it seems very inefficient to keep resizing everything!
88 _porepressure[_qp].resize(_num_phases);
89 _saturation[_qp].resize(_num_phases);
90
91 if (!is_ad)
92 {
93 (*_dporepressure_dvar)[_qp].resize(_num_phases);
94 (*_dsaturation_dvar)[_qp].resize(_num_phases);
95 }
96
97 if (!_nodal_material)
98 {
99 (*_gradp_qp)[_qp].resize(_num_phases);
100 (*_grads_qp)[_qp].resize(_num_phases);
101
102 if (!is_ad)
103 {
104 (*_dgradp_qp_dgradv)[_qp].resize(_num_phases);
105 (*_dgradp_qp_dv)[_qp].resize(_num_phases);
106
107 (*_dgrads_qp_dgradv)[_qp].resize(_num_phases);
108 (*_dgrads_qp_dv)[_qp].resize(_num_phases);
109 }
110 }
111
112 // Prepare the derivative matrices with zeroes
113 if (!is_ad)
114 for (unsigned phase = 0; phase < _num_phases; ++phase)
115 {
116
117 (*_dporepressure_dvar)[_qp][phase].assign(_num_pf_vars, 0.0);
118 (*_dsaturation_dvar)[_qp][phase].assign(_num_pf_vars, 0.0);
119 if (!_nodal_material)
120 {
121 (*_dgradp_qp_dgradv)[_qp][phase].assign(_num_pf_vars, 0.0);
122 (*_dgradp_qp_dv)[_qp][phase].assign(_num_pf_vars, RealGradient());
123 (*_dgrads_qp_dgradv)[_qp][phase].assign(_num_pf_vars, 0.0);
124 (*_dgrads_qp_dv)[_qp][phase].assign(_num_pf_vars, RealGradient());
125 }
126 }
127}
128
void addPrivateParam(const std::string &name, const T &value)
void addClassDescription(const std::string &doc_string)
PorousFlowMaterial is the base class for all PorousFlow Materials It allows users to specify that the...
static InputParameters validParams()
Base class for thermophysical variable materials, which assemble materials for primary variables such...
virtual void computeQpProperties() override
static InputParameters validParams()
virtual void initQpStatefulProperties() override
PorousFlowVariableBaseTempl(const InputParameters &parameters)