11 #include "libmesh/utility.h"
18 MooseEnum p_or_t_choice(
"pressure=0 temperature=1",
"pressure");
19 params.addParam<MooseEnum>(
"function_of",
21 "Modifying functions will be a function of either pressure and "
22 "permeability (eg, for boreholes that pump fluids) or "
23 "temperature and thermal conductivity (eg, for boreholes that "
24 "pump pure heat with no fluid flow)");
25 params.addRequiredParam<UserObjectName>(
27 "User Object of type=PorousFlowSumQuantity in which to place the total "
28 "outflow from the line sink for each time step.");
29 params.addRequiredParam<UserObjectName>(
30 "PorousFlowDictator",
"The UserObject that holds the list of PorousFlow variable names");
31 params.addParam<
unsigned int>(
34 "The fluid phase whose pressure (and potentially mobility, enthalpy, etc) "
35 "controls the flux to the line sink. For p_or_t=temperature, and without "
36 "any use_*, this parameter is irrelevant");
37 params.addParam<
unsigned int>(
"mass_fraction_component",
38 "The index corresponding to a fluid "
39 "component. If supplied, the flux will "
40 "be multiplied by the nodal mass "
41 "fraction for the component");
42 params.addParam<
bool>(
43 "use_relative_permeability",
false,
"Multiply the flux by the fluid relative permeability");
44 params.addParam<
bool>(
"use_mobility",
false,
"Multiply the flux by the fluid mobility");
45 params.addParam<
bool>(
"use_enthalpy",
false,
"Multiply the flux by the fluid enthalpy");
46 params.addParam<
bool>(
47 "use_internal_energy",
false,
"Multiply the flux by the fluid internal energy");
48 params.addClassDescription(
"Approximates a line sink in the mesh by a sequence of weighted Dirac "
49 "points whose positions are read from a file");
60 hasMaterialProperty<std::vector<Real>>(
"PorousFlow_porepressure_qp") &&
61 hasMaterialProperty<std::vector<std::vector<Real>>>(
"dPorousFlow_porepressure_qp_dvar")),
62 _has_temperature(hasMaterialProperty<Real>(
"PorousFlow_temperature_qp") &&
63 hasMaterialProperty<std::vector<Real>>(
"dPorousFlow_temperature_qp_dvar")),
65 hasMaterialProperty<std::vector<std::vector<Real>>>(
"PorousFlow_mass_frac_nodal") &&
66 hasMaterialProperty<std::vector<std::vector<std::vector<Real>>>>(
67 "dPorousFlow_mass_frac_nodal_dvar")),
68 _has_relative_permeability(
69 hasMaterialProperty<std::vector<Real>>(
"PorousFlow_relative_permeability_nodal") &&
70 hasMaterialProperty<std::vector<std::vector<Real>>>(
71 "dPorousFlow_relative_permeability_nodal_dvar")),
73 hasMaterialProperty<std::vector<Real>>(
"PorousFlow_relative_permeability_nodal") &&
74 hasMaterialProperty<std::vector<std::vector<Real>>>(
75 "dPorousFlow_relative_permeability_nodal_dvar") &&
76 hasMaterialProperty<std::vector<Real>>(
"PorousFlow_fluid_phase_density_nodal") &&
77 hasMaterialProperty<std::vector<std::vector<Real>>>(
78 "dPorousFlow_fluid_phase_density_nodal_dvar") &&
79 hasMaterialProperty<std::vector<Real>>(
"PorousFlow_viscosity_nodal") &&
80 hasMaterialProperty<std::vector<std::vector<Real>>>(
"dPorousFlow_viscosity_nodal_dvar")),
81 _has_enthalpy(hasMaterialProperty<std::vector<Real>>(
"PorousFlow_fluid_phase_enthalpy_nodal") &&
82 hasMaterialProperty<std::vector<std::vector<Real>>>(
83 "dPorousFlow_fluid_phase_enthalpy_nodal_dvar")),
85 hasMaterialProperty<std::vector<Real>>(
"PorousFlow_fluid_phase_internal_energy_nodal") &&
86 hasMaterialProperty<std::vector<std::vector<Real>>>(
87 "dPorousFlow_fluid_phase_internal_energy_nodal_dvar")),
89 _p_or_t(getParam<MooseEnum>(
"function_of").getEnum<
PorTchoice>()),
90 _use_mass_fraction(isParamValid(
"mass_fraction_component")),
91 _use_relative_permeability(getParam<bool>(
"use_relative_permeability")),
92 _use_mobility(getParam<bool>(
"use_mobility")),
93 _use_enthalpy(getParam<bool>(
"use_enthalpy")),
94 _use_internal_energy(getParam<bool>(
"use_internal_energy")),
96 _ph(getParam<unsigned int>(
"fluid_phase")),
97 _sp(_use_mass_fraction ? getParam<unsigned int>(
"mass_fraction_component") : 0),
100 ? &getMaterialProperty<std::vector<Real>>(
"PorousFlow_porepressure_qp")
103 ? &getMaterialProperty<std::vector<std::vector<Real>>>(
104 "dPorousFlow_porepressure_qp_dvar")
107 ? &getMaterialProperty<Real>(
"PorousFlow_temperature_qp")
111 ? &getMaterialProperty<std::vector<Real>>(
"dPorousFlow_temperature_qp_dvar")
114 (_use_mobility && _has_mobility)
115 ? &getMaterialProperty<std::vector<Real>>(
"PorousFlow_fluid_phase_density_nodal")
117 _dfluid_density_node_dvar((_use_mobility && _has_mobility)
118 ? &getMaterialProperty<std::vector<std::vector<Real>>>(
119 "dPorousFlow_fluid_phase_density_nodal_dvar")
121 _fluid_viscosity((_use_mobility && _has_mobility)
122 ? &getMaterialProperty<std::vector<Real>>(
"PorousFlow_viscosity_nodal")
124 _dfluid_viscosity_dvar((_use_mobility && _has_mobility)
125 ? &getMaterialProperty<std::vector<std::vector<Real>>>(
126 "dPorousFlow_viscosity_nodal_dvar")
128 _relative_permeability(
129 ((_use_mobility && _has_mobility) ||
130 (_use_relative_permeability && _has_relative_permeability))
131 ? &getMaterialProperty<std::vector<Real>>(
"PorousFlow_relative_permeability_nodal")
133 _drelative_permeability_dvar(((_use_mobility && _has_mobility) ||
134 (_use_relative_permeability && _has_relative_permeability))
135 ? &getMaterialProperty<std::vector<std::vector<Real>>>(
136 "dPorousFlow_relative_permeability_nodal_dvar")
139 (_use_mass_fraction && _has_mass_fraction)
140 ? &getMaterialProperty<std::vector<std::vector<Real>>>(
"PorousFlow_mass_frac_nodal")
142 _dmass_fractions_dvar((_use_mass_fraction && _has_mass_fraction)
143 ? &getMaterialProperty<std::vector<std::vector<std::vector<Real>>>>(
144 "dPorousFlow_mass_frac_nodal_dvar")
146 _enthalpy(_has_enthalpy ? &getMaterialPropertyByName<std::vector<Real>>(
147 "PorousFlow_fluid_phase_enthalpy_nodal")
149 _denthalpy_dvar(_has_enthalpy ? &getMaterialPropertyByName<std::vector<std::vector<Real>>>(
150 "dPorousFlow_fluid_phase_enthalpy_nodal_dvar")
152 _internal_energy(_has_internal_energy ? &getMaterialPropertyByName<std::vector<Real>>(
153 "PorousFlow_fluid_phase_internal_energy_nodal")
155 _dinternal_energy_dvar(_has_internal_energy
156 ? &getMaterialPropertyByName<std::vector<std::vector<Real>>>(
157 "dPorousFlow_fluid_phase_internal_energy_nodal_dvar")
164 paramError(
"fluid_phase",
165 "The Dictator proclaims that the maximum phase index in this simulation is ",
167 " whereas you have used ",
169 ". Remember that indexing starts at 0. You must try harder.");
173 "mass_fraction_component",
174 "The Dictator proclaims that the maximum fluid component index in this simulation is ",
176 " whereas you have used ",
178 ". Remember that indexing starts at 0. Please be assured that the Dictator has noted your "
182 mooseError(
"PorousFlowLineSink: You have specified function_of=porepressure, but you do not "
183 "have a quadpoint porepressure material");
186 mooseError(
"PorousFlowLineSink: You have specified function_of=temperature, but you do not "
187 "have a quadpoint temperature material");
190 mooseError(
"PorousFlowLineSink: You have specified a fluid component, but do not have a nodal "
191 "mass-fraction material");
194 mooseError(
"PorousFlowLineSink: You have set use_relative_permeability=true, but do not have a "
195 "nodal relative permeability material");
198 mooseError(
"PorousFlowLineSink: You have set use_mobility=true, but do not have nodal density, "
199 "relative permeability or viscosity material");
202 mooseError(
"PorousFlowLineSink: You have set use_enthalpy=true, but do not have a nodal "
203 "enthalpy material");
206 mooseError(
"PorousFlowLineSink: You have set use_internal_energy=true, but do not have a nodal "
207 "internal-energy material");
211 const std::vector<MooseVariableFEBase *> & coupled_vars =
_dictator.getCoupledMooseVars();
212 for (
unsigned int i = 0; i < coupled_vars.size(); i++)
213 addMooseVariableDependency(coupled_vars[i]);
230 const unsigned current_dirac_ptid = currentPointCachedID();
236 outflow *= (*_relative_permeability)[_i][
_ph];
239 outflow *= (*_relative_permeability)[_i][
_ph] * (*_fluid_density_node)[_i][
_ph] /
240 (*_fluid_viscosity)[_i][
_ph];
243 outflow *= (*_mass_fractions)[_i][
_ph][
_sp];
246 outflow *= (*_enthalpy)[_i][
_ph];
249 outflow *= (*_internal_energy)[_i][
_ph];
260 return jac(_var.number());
278 const unsigned current_dirac_ptid = currentPointCachedID();
280 if (outflow == 0.0 && outflowp == 0.0)
285 const Real relperm_prime = (_i != _j ? 0.0 : (*_drelative_permeability_dvar)[_i][
_ph][pvar]);
286 outflowp = (*_relative_permeability)[_i][
_ph] * outflowp + relperm_prime * outflow;
287 outflow *= (*_relative_permeability)[_i][
_ph];
292 const Real mob = (*_relative_permeability)[_i][
_ph] * (*_fluid_density_node)[_i][
_ph] /
293 (*_fluid_viscosity)[_i][
_ph];
294 const Real mob_prime =
297 : (*_drelative_permeability_dvar)[_i][
_ph][pvar] * (*_fluid_density_node)[_i][
_ph] /
298 (*_fluid_viscosity)[_i][
_ph] +
299 (*_relative_permeability)[_i][
_ph] *
300 (*_dfluid_density_node_dvar)[_i][
_ph][pvar] / (*_fluid_viscosity)[_i][
_ph] -
301 (*_relative_permeability)[_i][
_ph] * (*_fluid_density_node)[_i][
_ph] *
302 (*_dfluid_viscosity_dvar)[_i][
_ph][pvar] /
304 outflowp = mob * outflowp + mob_prime * outflow;
310 const Real mass_fractions_prime =
311 (_i != _j ? 0.0 : (*_dmass_fractions_dvar)[_i][
_ph][
_sp][pvar]);
312 outflowp = (*_mass_fractions)[_i][
_ph][
_sp] * outflowp + mass_fractions_prime * outflow;
313 outflow *= (*_mass_fractions)[_i][
_ph][
_sp];
318 const Real enthalpy_prime = (_i != _j ? 0.0 : (*_denthalpy_dvar)[_i][
_ph][pvar]);
319 outflowp = (*_enthalpy)[_i][
_ph] * outflowp + enthalpy_prime * outflow;
320 outflow *= (*_enthalpy)[_i][
_ph];
325 const Real internal_energy_prime = (_i != _j ? 0.0 : (*_dinternal_energy_dvar)[_i][
_ph][pvar]);
326 outflowp = (*_internal_energy)[_i][
_ph] * outflowp + internal_energy_prime * outflow;