www.mooseframework.org
PorousFlowJoiner.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "PorousFlowJoiner.h"
9 #include "Conversion.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<PorousFlowMaterialVectorBase>();
16  params.addRequiredParam<std::string>("material_property",
17  "The property that you want joined into a std::vector");
18  params.addParam<bool>(
19  "include_old", false, "Join old properties into vectors as well as the current properties");
20  params.addClassDescription("This Material forms a std::vector of properties, old properties "
21  "(optionally), and derivatives, out of the individual phase "
22  "properties");
23  return params;
24 }
25 
26 PorousFlowJoiner::PorousFlowJoiner(const InputParameters & parameters)
27  : PorousFlowMaterialVectorBase(parameters),
28 
29  _pressure_variable_name(_dictator.pressureVariableNameDummy()),
30  _saturation_variable_name(_dictator.saturationVariableNameDummy()),
31  _temperature_variable_name(_dictator.temperatureVariableNameDummy()),
32  _mass_fraction_variable_name(_dictator.massFractionVariableNameDummy()),
33  _pf_prop(getParam<std::string>("material_property")),
34  _include_old(getParam<bool>("include_old")),
35 
36  _dporepressure_dvar(!_nodal_material ? getMaterialProperty<std::vector<std::vector<Real>>>(
37  "dPorousFlow_porepressure_qp_dvar")
38  : getMaterialProperty<std::vector<std::vector<Real>>>(
39  "dPorousFlow_porepressure_nodal_dvar")),
40  _dsaturation_dvar(!_nodal_material ? getMaterialProperty<std::vector<std::vector<Real>>>(
41  "dPorousFlow_saturation_qp_dvar")
42  : getMaterialProperty<std::vector<std::vector<Real>>>(
43  "dPorousFlow_saturation_nodal_dvar")),
44  _dtemperature_dvar(
45  !_nodal_material
46  ? getMaterialProperty<std::vector<Real>>("dPorousFlow_temperature_qp_dvar")
47  : getMaterialProperty<std::vector<Real>>("dPorousFlow_temperature_nodal_dvar")),
48 
49  _property(declareProperty<std::vector<Real>>(_pf_prop)),
50  _dproperty_dvar(declareProperty<std::vector<std::vector<Real>>>("d" + _pf_prop + "_dvar"))
51 {
56 
57  for (unsigned int ph = 0; ph < _num_phases; ++ph)
58  {
59  std::string phase = Moose::stringify(ph);
60  _phase_property[ph] = &getMaterialProperty<Real>(_pf_prop + phase);
62  &getMaterialPropertyDerivative<Real>(_pf_prop + phase, _pressure_variable_name);
64  &getMaterialPropertyDerivative<Real>(_pf_prop + phase, _saturation_variable_name);
66  &getMaterialPropertyDerivative<Real>(_pf_prop + phase, _temperature_variable_name);
67  }
68 }
69 
70 void
72 {
73  _property[_qp].resize(_num_phases);
74 
75  for (unsigned int ph = 0; ph < _num_phases; ++ph)
76  _property[_qp][ph] = (*_phase_property[ph])[_qp];
77 }
78 
79 void
81 {
83 
84  _dproperty_dvar[_qp].resize(_num_phases);
85  for (unsigned int ph = 0; ph < _num_phases; ++ph)
86  {
87  _dproperty_dvar[_qp][ph].resize(_num_var);
88  for (unsigned v = 0; v < _num_var; ++v)
89  {
90  // the "if" conditions in the following are because a nodal_material's derivatives might
91  // not have been defined. If that is the case, then DerivativeMaterial passes back a
92  // MaterialProperty with zeroes (for the derivatives), but that property will be sized
93  // by the number of quadpoints in the element, which may be smaller than the number of
94  // nodes!
95  _dproperty_dvar[_qp][ph][v] = 0.0;
96  if ((*_dphase_property_dp[ph]).size() > _qp)
97  _dproperty_dvar[_qp][ph][v] +=
98  (*_dphase_property_dp[ph])[_qp] * _dporepressure_dvar[_qp][ph][v];
99  if ((*_dphase_property_ds[ph]).size() > _qp)
100  _dproperty_dvar[_qp][ph][v] +=
101  (*_dphase_property_ds[ph])[_qp] * _dsaturation_dvar[_qp][ph][v];
102  if ((*_dphase_property_dt[ph]).size() > _qp)
103  _dproperty_dvar[_qp][ph][v] += (*_dphase_property_dt[ph])[_qp] * _dtemperature_dvar[_qp][v];
104  }
105  }
106 }
std::vector< const MaterialProperty< Real > * > _dphase_property_dt
d(property of each phase)/d(temperature)
const unsigned int _num_phases
Number of phases.
MaterialProperty< std::vector< Real > > & _property
computed property of the phase
const MaterialProperty< std::vector< std::vector< Real > > > & _dporepressure_dvar
Derivatives of porepressure variable wrt PorousFlow variables at the qps or nodes.
std::vector< const MaterialProperty< Real > * > _dphase_property_ds
d(property of each phase)/d(saturation)
const std::string _pf_prop
Name of material property to be joined.
InputParameters validParams< PorousFlowMaterialVectorBase >()
Base class for all PorousFlow vector materials.
const VariableName _pressure_variable_name
Name of (dummy) pressure variable.
virtual void initQpStatefulProperties() override
const VariableName _saturation_variable_name
Name of (dummy) saturation variable.
const unsigned int _num_var
Number of PorousFlow variables.
InputParameters validParams< PorousFlowJoiner >()
std::vector< const MaterialProperty< Real > * > _phase_property
property of each phase
const VariableName _temperature_variable_name
Name of (dummy) temperature variable.
virtual void computeQpProperties() override
const MaterialProperty< std::vector< Real > > & _dtemperature_dvar
Derivatives of temperature variable wrt PorousFlow variables at the qps or nodes. ...
PorousFlowJoiner(const InputParameters &parameters)
std::vector< const MaterialProperty< Real > * > _dphase_property_dp
d(property of each phase)/d(pressure)
MaterialProperty< std::vector< std::vector< Real > > > & _dproperty_dvar
d(property)/d(PorousFlow variable)
const MaterialProperty< std::vector< std::vector< Real > > > & _dsaturation_dvar
Derivatives of saturation variable wrt PorousFlow variables at the qps or nodes.