www.mooseframework.org
PorousFlowJoiner.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 
10 #include "PorousFlowJoiner.h"
11 #include "Conversion.h"
12 
13 registerMooseObject("PorousFlowApp", PorousFlowJoiner);
14 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<PorousFlowMaterialVectorBase>();
20  params.addRequiredParam<std::string>("material_property",
21  "The property that you want joined into a std::vector");
22  params.set<std::string>("pf_material_type") = "joiner";
23  params.addClassDescription("This Material forms a std::vector of properties, old properties "
24  "(optionally), and derivatives, out of the individual phase "
25  "properties");
26  return params;
27 }
28 
29 PorousFlowJoiner::PorousFlowJoiner(const InputParameters & parameters)
30  : PorousFlowMaterialVectorBase(parameters),
31  _pf_prop(getParam<std::string>("material_property")),
32  _dporepressure_dvar(!_nodal_material ? getMaterialProperty<std::vector<std::vector<Real>>>(
33  "dPorousFlow_porepressure_qp_dvar")
34  : getMaterialProperty<std::vector<std::vector<Real>>>(
35  "dPorousFlow_porepressure_nodal_dvar")),
36  _dsaturation_dvar(!_nodal_material ? getMaterialProperty<std::vector<std::vector<Real>>>(
37  "dPorousFlow_saturation_qp_dvar")
38  : getMaterialProperty<std::vector<std::vector<Real>>>(
39  "dPorousFlow_saturation_nodal_dvar")),
40  _dtemperature_dvar(
41  !_nodal_material
42  ? getMaterialProperty<std::vector<Real>>("dPorousFlow_temperature_qp_dvar")
43  : getMaterialProperty<std::vector<Real>>("dPorousFlow_temperature_nodal_dvar")),
44  _property(declareProperty<std::vector<Real>>(_pf_prop)),
45  _dproperty_dvar(declareProperty<std::vector<std::vector<Real>>>("d" + _pf_prop + "_dvar"))
46 {
51 
52  for (unsigned int ph = 0; ph < _num_phases; ++ph)
53  {
54  std::string phase = Moose::stringify(ph);
55  _phase_property[ph] = &getMaterialProperty<Real>(_pf_prop + phase);
57  &getMaterialPropertyDerivative<Real>(_pf_prop + phase, _pressure_variable_name);
59  &getMaterialPropertyDerivative<Real>(_pf_prop + phase, _saturation_variable_name);
61  &getMaterialPropertyDerivative<Real>(_pf_prop + phase, _temperature_variable_name);
62  }
63 }
64 
65 void
67 {
68  _property[_qp].resize(_num_phases);
69 
70  for (unsigned int ph = 0; ph < _num_phases; ++ph)
71  _property[_qp][ph] = (*_phase_property[ph])[_qp];
72 }
73 
74 void
76 {
78 
79  _dproperty_dvar[_qp].resize(_num_phases);
80  for (unsigned int ph = 0; ph < _num_phases; ++ph)
81  {
82  _dproperty_dvar[_qp][ph].resize(_num_var);
83  for (unsigned v = 0; v < _num_var; ++v)
84  {
85  // the "if" conditions in the following are because a nodal_material's derivatives might
86  // not have been defined. If that is the case, then DerivativeMaterial passes back a
87  // MaterialProperty with zeroes (for the derivatives), but that property will be sized
88  // by the number of quadpoints in the element, which may be smaller than the number of
89  // nodes!
90  _dproperty_dvar[_qp][ph][v] = 0.0;
91  if ((*_dphase_property_dp[ph]).size() > _qp)
92  _dproperty_dvar[_qp][ph][v] +=
93  (*_dphase_property_dp[ph])[_qp] * _dporepressure_dvar[_qp][ph][v];
94  if ((*_dphase_property_ds[ph]).size() > _qp)
95  _dproperty_dvar[_qp][ph][v] +=
96  (*_dphase_property_ds[ph])[_qp] * _dsaturation_dvar[_qp][ph][v];
97  if ((*_dphase_property_dt[ph]).size() > _qp)
98  _dproperty_dvar[_qp][ph][v] += (*_dphase_property_dt[ph])[_qp] * _dtemperature_dvar[_qp][v];
99  }
100  }
101 }
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.
Material designed to form a std::vector of property and derivatives of these wrt the nonlinear variab...
virtual void initQpStatefulProperties() override
const unsigned int _num_var
Number of PorousFlow variables.
InputParameters validParams< PorousFlowJoiner >()
std::vector< const MaterialProperty< Real > * > _phase_property
Property of each phase.
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)
registerMooseObject("PorousFlowApp", PorousFlowJoiner)
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.