www.mooseframework.org
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
PorousFlowPeacemanBorehole Class Reference

Approximates a borehole by a sequence of Dirac Points. More...

#include <PorousFlowPeacemanBorehole.h>

Inheritance diagram for PorousFlowPeacemanBorehole:
[legend]

Public Member Functions

 PorousFlowPeacemanBorehole (const InputParameters &parameters)
 Creates a new PorousFlowPeacemanBorehole This reads the file containing the lines of the form radius x y z that defines the borehole geometry. More...
 

Protected Types

enum  PorTchoice { PorTchoice::pressure, PorTchoice::temperature }
 whether the flux is a function of pressure or temperature More...
 

Protected Member Functions

Real wellConstant (const RealTensorValue &perm, const RealTensorValue &rot, const Real &half_len, const Elem *ele, const Real &rad) const
 Calculates Peaceman's form of the borehole well constant Z Chen, Y Zhang, Well flow models for various numerical methods, Int J Num Analysis and Modeling, 3 (2008) 375-388. More...
 
Real computeQpBaseOutflow (unsigned current_dirac_ptid) const override
 Returns the flux from the line sink (before modification by mobility, etc). Derived classes should override this. More...
 
void computeQpBaseOutflowJacobian (unsigned jvar, unsigned current_dirac_ptid, Real &outflow, Real &outflowp) const override
 Calculates the BaseOutflow as well as its derivative wrt jvar. Derived classes should override this. More...
 
virtual Real computeQpResidual () override
 
virtual Real computeQpJacobian () override
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar) override
 
virtual void addPoints () override
 Add Dirac Points to the borehole. More...
 
Real jac (unsigned int jvar)
 Jacobian contribution for the derivative wrt the variable jvar. More...
 
Real ptqp () const
 If _p_or_t==0, then returns the quadpoint porepressure, else returns the quadpoint temperature. More...
 
Real dptqp (unsigned pvar) const
 If _p_or_t==0, then returns d(quadpoint porepressure)/d(PorousFlow variable), else returns d(quadpoint temperature)/d(PorousFlow variable) More...
 
bool parseNextLineReals (std::ifstream &ifs, std::vector< Real > &myvec)
 Reads a space-separated line of floats from ifs and puts in myvec. More...
 

Protected Attributes

Function & _character
 If positive then the borehole acts as a sink (producion well) for porepressure > borehole pressure, and does nothing otherwise If negative then the borehole acts as a source (injection well) for porepressure < borehole pressure, and does nothing otherwise The flow rate to/from the borehole is multiplied by |character|, so usually character = +/- 1. More...
 
const Real _p_bot
 Bottomhole pressure of borehole. More...
 
const RealVectorValue _unit_weight
 Unit weight of fluid in borehole (for calculating bottomhole pressure at each Dirac Point) More...
 
const Real _re_constant
 Borehole constant. More...
 
const Real _well_constant
 Well constant. More...
 
const bool _has_permeability
 Whether there is a quadpoint permeability material (for error checking) More...
 
const bool _has_thermal_conductivity
 Whether there is a quadpoint thermal conductivity material (for error checking) More...
 
const MaterialProperty< RealTensorValue > & _perm_or_cond
 Permeability or conductivity of porous material. More...
 
const MaterialProperty< std::vector< RealTensorValue > > & _dperm_or_cond_dvar
 d(Permeability)/d(PorousFlow variable) More...
 
std::vector< RealTensorValue > _rot_matrix
 Rotation matrix used in well_constant calculation. More...
 
const PorousFlowDictator_dictator
 PorousFlowDictator UserObject. More...
 
PorousFlowSumQuantity_total_outflow_mass
 This is used to hold the total fluid flowing into the line sink for each time step. More...
 
const bool _has_porepressure
 Whether a quadpoint porepressure material exists (for error checking) More...
 
const bool _has_temperature
 Whether a quadpoint temperature material exists (for error checking) More...
 
const bool _has_mass_fraction
 Whether a mass_fraction material exists (for error checking) More...
 
const bool _has_relative_permeability
 Whether a relative permeability material exists (for error checking) More...
 
const bool _has_mobility
 Whether enough materials exist to form the mobility (for error checking) More...
 
const bool _has_enthalpy
 Whether an enthalpy material exists (for error checking) More...
 
const bool _has_internal_energy
 Whether an internal-energy material exists (for error checking) More...
 
enum PorousFlowLineSink::PorTchoice _p_or_t
 
const bool _use_mass_fraction
 Whether the flux will be multiplied by the mass fraction. More...
 
const bool _use_relative_permeability
 Whether the flux will be multiplied by the relative permeability. More...
 
const bool _use_mobility
 Whether the flux will be multiplied by the mobility. More...
 
const bool _use_enthalpy
 Whether the flux will be multiplied by the enthalpy. More...
 
const bool _use_internal_energy
 Whether the flux will be multiplied by the internal-energy. More...
 
const unsigned int _ph
 The phase number. More...
 
const unsigned int _sp
 The component number (only used if _use_mass_fraction==true) More...
 
const MaterialProperty< std::vector< Real > > *const _pp
 Quadpoint pore pressure in each phase. More...
 
const MaterialProperty< std::vector< std::vector< Real > > > *const _dpp_dvar
 d(quadpoint pore pressure in each phase)/d(PorousFlow variable) More...
 
const MaterialProperty< Real > *const _temperature
 Quadpoint temperature. More...
 
const MaterialProperty< std::vector< Real > > *const _dtemperature_dvar
 d(quadpoint temperature)/d(PorousFlow variable) More...
 
const MaterialProperty< std::vector< Real > > *const _fluid_density_node
 Fluid density for each phase (at the node) More...
 
const MaterialProperty< std::vector< std::vector< Real > > > *const _dfluid_density_node_dvar
 d(Fluid density for each phase (at the node))/d(PorousFlow variable) More...
 
const MaterialProperty< std::vector< Real > > *const _fluid_viscosity
 Viscosity of each component in each phase. More...
 
const MaterialProperty< std::vector< std::vector< Real > > > *const _dfluid_viscosity_dvar
 d(Viscosity of each component in each phase)/d(PorousFlow variable) More...
 
const MaterialProperty< std::vector< Real > > *const _relative_permeability
 Relative permeability of each phase. More...
 
const MaterialProperty< std::vector< std::vector< Real > > > *const _drelative_permeability_dvar
 d(Relative permeability of each phase)/d(PorousFlow variable) More...
 
const MaterialProperty< std::vector< std::vector< Real > > > *const _mass_fractions
 Mass fraction of each component in each phase. More...
 
const MaterialProperty< std::vector< std::vector< std::vector< Real > > > > *const _dmass_fractions_dvar
 d(Mass fraction of each component in each phase)/d(PorousFlow variable) More...
 
const MaterialProperty< std::vector< Real > > *const _enthalpy
 Enthalpy of each phase. More...
 
const MaterialProperty< std::vector< std::vector< Real > > > *const _denthalpy_dvar
 d(enthalpy of each phase)/d(PorousFlow variable) More...
 
const MaterialProperty< std::vector< Real > > *const _internal_energy
 Internal_Energy of each phase. More...
 
const MaterialProperty< std::vector< std::vector< Real > > > *const _dinternal_energy_dvar
 d(internal_energy of each phase)/d(PorousFlow variable) More...
 
const Real _line_length
 Line length. This is only used if there is only one borehole point. More...
 
const RealVectorValue _line_direction
 Line direction. This is only used if there is only one borehole point. More...
 
const std::string _point_file
 File defining the geometry of the borehole. More...
 
std::vector< Real > _rs
 Radii of the borehole. More...
 
std::vector< Real > _xs
 x points of the borehole More...
 
std::vector< Real > _ys
 y points of the borehole More...
 
std::vector< Real > _zs
 z points of borehole More...
 
Point _bottom_point
 The bottom point of the borehole (where bottom_pressure is defined) More...
 
std::vector< Real > _half_seg_len
 0.5*(length of polyline segments between points) More...
 

Detailed Description

Approximates a borehole by a sequence of Dirac Points.

Definition at line 23 of file PorousFlowPeacemanBorehole.h.

Member Enumeration Documentation

◆ PorTchoice

enum PorousFlowLineSink::PorTchoice
strongprotectedinherited

whether the flux is a function of pressure or temperature

Enumerator
pressure 
temperature 

Definition at line 92 of file PorousFlowLineSink.h.

const std::string temperature
Definition: NS.h:27
const std::string pressure
Definition: NS.h:26
enum PorousFlowLineSink::PorTchoice _p_or_t

Constructor & Destructor Documentation

◆ PorousFlowPeacemanBorehole()

PorousFlowPeacemanBorehole::PorousFlowPeacemanBorehole ( const InputParameters &  parameters)

Creates a new PorousFlowPeacemanBorehole This reads the file containing the lines of the form radius x y z that defines the borehole geometry.

It also calculates segment-lengths and rotation matrices needed for computing the borehole well constant

Definition at line 65 of file PorousFlowPeacemanBorehole.C.

66  : PorousFlowLineSink(parameters),
67  _character(getFunction("character")),
68  _p_bot(getParam<Real>("bottom_p_or_t")),
69  _unit_weight(getParam<RealVectorValue>("unit_weight")),
70  _re_constant(getParam<Real>("re_constant")),
71  _well_constant(getParam<Real>("well_constant")),
73  hasMaterialProperty<RealTensorValue>("PorousFlow_permeability_qp") &&
74  hasMaterialProperty<std::vector<RealTensorValue>>("dPorousFlow_permeability_qp_dvar")),
76  hasMaterialProperty<RealTensorValue>("PorousFlow_thermal_conductivity_qp") &&
77  hasMaterialProperty<std::vector<RealTensorValue>>(
78  "dPorousFlow_thermal_conductivity_qp_dvar")),
80  ? getMaterialProperty<RealTensorValue>("PorousFlow_permeability_qp")
81  : getMaterialProperty<RealTensorValue>("PorousFlow_thermal_conductivity_qp")),
84  ? getMaterialProperty<std::vector<RealTensorValue>>("dPorousFlow_permeability_qp_dvar")
85  : getMaterialProperty<std::vector<RealTensorValue>>(
86  "dPorousFlow_thermal_conductivity_qp_dvar"))
87 {
89  mooseError("PorousFlowPeacemanBorehole: You have specified function_of=porepressure, but you "
90  "do not have a quadpoint permeability material");
92  mooseError("PorousFlowPeacemanBorehole: You have specified function_of=temperature, but you do "
93  "not have a quadpoint thermal_conductivity material");
94 
95  // construct the rotation matrix needed to rotate the permeability
96  const unsigned int num_pts = _zs.size();
97  _rot_matrix.resize(std::max(num_pts - 1, (unsigned)1));
98  for (unsigned int i = 0; i + 1 < num_pts; ++i)
99  {
100  const RealVectorValue v2(_xs[i + 1] - _xs[i], _ys[i + 1] - _ys[i], _zs[i + 1] - _zs[i]);
101  _rot_matrix[i] = RotationMatrix::rotVecToZ(v2);
102  }
103  if (num_pts == (unsigned)1)
104  _rot_matrix[0] = RotationMatrix::rotVecToZ(_line_direction);
105 }
const Real _p_bot
Bottomhole pressure of borehole.
const bool _has_permeability
Whether there is a quadpoint permeability material (for error checking)
std::vector< Real > _ys
y points of the borehole
const MaterialProperty< std::vector< RealTensorValue > > & _dperm_or_cond_dvar
d(Permeability)/d(PorousFlow variable)
Function & _character
If positive then the borehole acts as a sink (producion well) for porepressure > borehole pressure...
const RealVectorValue _line_direction
Line direction. This is only used if there is only one borehole point.
const Real _well_constant
Well constant.
std::vector< Real > _zs
z points of borehole
std::vector< RealTensorValue > _rot_matrix
Rotation matrix used in well_constant calculation.
const MaterialProperty< RealTensorValue > & _perm_or_cond
Permeability or conductivity of porous material.
PorousFlowLineSink(const InputParameters &parameters)
std::vector< Real > _xs
x points of the borehole
const Real _re_constant
Borehole constant.
const bool _has_thermal_conductivity
Whether there is a quadpoint thermal conductivity material (for error checking)
enum PorousFlowLineSink::PorTchoice _p_or_t
const RealVectorValue _unit_weight
Unit weight of fluid in borehole (for calculating bottomhole pressure at each Dirac Point) ...

Member Function Documentation

◆ addPoints()

void PorousFlowLineSink::addPoints ( )
overrideprotectedvirtualinherited

Add Dirac Points to the borehole.

Reimplemented from PorousFlowLineGeometry.

Definition at line 217 of file PorousFlowLineSink.C.

218 {
219  // This function gets called just before the DiracKernel is evaluated
220  // so this is a handy place to zero this out.
222 
224 }
virtual void addPoints() override
Add Dirac Points to the line sink.
void zero()
Sets _total = 0.
PorousFlowSumQuantity & _total_outflow_mass
This is used to hold the total fluid flowing into the line sink for each time step.

◆ computeQpBaseOutflow()

Real PorousFlowPeacemanBorehole::computeQpBaseOutflow ( unsigned  current_dirac_ptid) const
overrideprotectedvirtual

Returns the flux from the line sink (before modification by mobility, etc). Derived classes should override this.

Implements PorousFlowLineSink.

Definition at line 212 of file PorousFlowPeacemanBorehole.C.

213 {
214  const Real character = _character.value(_t, _q_point[_qp]);
215  if (character == 0.0)
216  return 0.0;
217 
218  const Real bh_pressure = _p_bot + _unit_weight * (_q_point[_qp] - _bottom_point);
219  const Real pp = ptqp();
220 
221  Real outflow = 0.0; // this is the flow rate from porespace out of the system
222 
223  if (current_dirac_ptid > 0)
224  // contribution from half-segment "behind" this point (must have >1 point for
225  // current_dirac_ptid>0)
226  {
227  if ((character < 0.0 && pp < bh_pressure) || (character > 0.0 && pp > bh_pressure))
228  {
229  // injection, so outflow<0 || production, so outflow>0
230  const Real wc = wellConstant(_perm_or_cond[_qp],
231  _rot_matrix[current_dirac_ptid - 1],
232  _half_seg_len[current_dirac_ptid - 1],
233  _current_elem,
234  _rs[current_dirac_ptid]);
235  outflow += wc * (pp - bh_pressure);
236  }
237  }
238 
239  if (current_dirac_ptid + 1 < _zs.size() || _zs.size() == 1)
240  // contribution from half-segment "ahead of" this point, or we only have one point
241  {
242  if ((character < 0.0 && pp < bh_pressure) || (character > 0.0 && pp > bh_pressure))
243  {
244  // injection, so outflow<0 || // production, so outflow>0
245  const Real wc = wellConstant(_perm_or_cond[_qp],
246  _rot_matrix[current_dirac_ptid],
247  _half_seg_len[current_dirac_ptid],
248  _current_elem,
249  _rs[current_dirac_ptid]);
250  outflow += wc * (pp - bh_pressure);
251  }
252  }
253 
254  return outflow * _test[_i][_qp] * std::abs(character);
255 }
const Real _p_bot
Bottomhole pressure of borehole.
Function & _character
If positive then the borehole acts as a sink (producion well) for porepressure > borehole pressure...
std::vector< Real > _half_seg_len
0.5*(length of polyline segments between points)
Real wellConstant(const RealTensorValue &perm, const RealTensorValue &rot, const Real &half_len, const Elem *ele, const Real &rad) const
Calculates Peaceman&#39;s form of the borehole well constant Z Chen, Y Zhang, Well flow models for variou...
Real ptqp() const
If _p_or_t==0, then returns the quadpoint porepressure, else returns the quadpoint temperature...
std::vector< Real > _zs
z points of borehole
std::vector< RealTensorValue > _rot_matrix
Rotation matrix used in well_constant calculation.
const MaterialProperty< RealTensorValue > & _perm_or_cond
Permeability or conductivity of porous material.
std::vector< Real > _rs
Radii of the borehole.
Point _bottom_point
The bottom point of the borehole (where bottom_pressure is defined)
const RealVectorValue _unit_weight
Unit weight of fluid in borehole (for calculating bottomhole pressure at each Dirac Point) ...

◆ computeQpBaseOutflowJacobian()

void PorousFlowPeacemanBorehole::computeQpBaseOutflowJacobian ( unsigned  jvar,
unsigned  current_dirac_ptid,
Real &  outflow,
Real &  outflowp 
) const
overrideprotectedvirtual

Calculates the BaseOutflow as well as its derivative wrt jvar. Derived classes should override this.

Implements PorousFlowLineSink.

Definition at line 258 of file PorousFlowPeacemanBorehole.C.

262 {
263  outflow = 0.0;
264  outflowp = 0.0;
265 
266  const Real character = _character.value(_t, _q_point[_qp]);
267  if (character == 0.0)
268  return;
269 
271  return;
272  const unsigned pvar = _dictator.porousFlowVariableNum(jvar);
273 
274  const Real bh_pressure = _p_bot + _unit_weight * (_q_point[_qp] - _bottom_point);
275  const Real pp = ptqp();
276  const Real pp_prime = dptqp(pvar) * _phi[_j][_qp];
277 
278  if (current_dirac_ptid > 0)
279  // contribution from half-segment "behind" this point
280  {
281  if ((character < 0.0 && pp < bh_pressure) || (character > 0.0 && pp > bh_pressure))
282  {
283  // injection, so outflow<0 || // production, so outflow>0
284  const Real wc = wellConstant(_perm_or_cond[_qp],
285  _rot_matrix[current_dirac_ptid - 1],
286  _half_seg_len[current_dirac_ptid - 1],
287  _current_elem,
288  _rs[current_dirac_ptid]);
289  outflowp += wc * pp_prime;
290  outflow += wc * (pp - bh_pressure);
291  }
292  }
293 
294  if (current_dirac_ptid < _zs.size() - 1 || _zs.size() == 1)
295  // contribution from half-segment "ahead of" this point
296  {
297  if ((character < 0.0 && pp < bh_pressure) || (character > 0.0 && pp > bh_pressure))
298  {
299  // injection, so outflow<0 || // production, so outflow>0
300  const Real wc = wellConstant(_perm_or_cond[_qp],
301  _rot_matrix[current_dirac_ptid],
302  _half_seg_len[current_dirac_ptid],
303  _current_elem,
304  _rs[current_dirac_ptid]);
305  outflowp += wc * pp_prime;
306  outflow += wc * (pp - bh_pressure);
307  }
308  }
309 
310  outflowp *= _test[_i][_qp] * std::abs(character);
311  outflow *= _test[_i][_qp] * std::abs(character);
312 }
bool notPorousFlowVariable(unsigned int moose_var_num) const
Returns true if moose_var_num is not a porous flow variabe.
const PorousFlowDictator & _dictator
PorousFlowDictator UserObject.
const Real _p_bot
Bottomhole pressure of borehole.
Function & _character
If positive then the borehole acts as a sink (producion well) for porepressure > borehole pressure...
std::vector< Real > _half_seg_len
0.5*(length of polyline segments between points)
Real wellConstant(const RealTensorValue &perm, const RealTensorValue &rot, const Real &half_len, const Elem *ele, const Real &rad) const
Calculates Peaceman&#39;s form of the borehole well constant Z Chen, Y Zhang, Well flow models for variou...
Real ptqp() const
If _p_or_t==0, then returns the quadpoint porepressure, else returns the quadpoint temperature...
std::vector< Real > _zs
z points of borehole
std::vector< RealTensorValue > _rot_matrix
Rotation matrix used in well_constant calculation.
const MaterialProperty< RealTensorValue > & _perm_or_cond
Permeability or conductivity of porous material.
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
The PorousFlow variable number.
std::vector< Real > _rs
Radii of the borehole.
Point _bottom_point
The bottom point of the borehole (where bottom_pressure is defined)
Real dptqp(unsigned pvar) const
If _p_or_t==0, then returns d(quadpoint porepressure)/d(PorousFlow variable), else returns d(quadpoin...
const RealVectorValue _unit_weight
Unit weight of fluid in borehole (for calculating bottomhole pressure at each Dirac Point) ...

◆ computeQpJacobian()

Real PorousFlowLineSink::computeQpJacobian ( )
overrideprotectedvirtualinherited

Definition at line 258 of file PorousFlowLineSink.C.

259 {
260  return jac(_var.number());
261 }
Real jac(unsigned int jvar)
Jacobian contribution for the derivative wrt the variable jvar.

◆ computeQpOffDiagJacobian()

Real PorousFlowLineSink::computeQpOffDiagJacobian ( unsigned int  jvar)
overrideprotectedvirtualinherited

Definition at line 264 of file PorousFlowLineSink.C.

265 {
266  return jac(jvar);
267 }
Real jac(unsigned int jvar)
Jacobian contribution for the derivative wrt the variable jvar.

◆ computeQpResidual()

Real PorousFlowLineSink::computeQpResidual ( )
overrideprotectedvirtualinherited

Definition at line 227 of file PorousFlowLineSink.C.

228 {
229  // Get the ID we initially assigned to this point
230  const unsigned current_dirac_ptid = currentPointCachedID();
231  Real outflow = computeQpBaseOutflow(current_dirac_ptid);
232  if (outflow == 0.0)
233  return 0.0;
234 
236  outflow *= (*_relative_permeability)[_i][_ph];
237 
238  if (_use_mobility)
239  outflow *= (*_relative_permeability)[_i][_ph] * (*_fluid_density_node)[_i][_ph] /
240  (*_fluid_viscosity)[_i][_ph];
241 
242  if (_use_mass_fraction)
243  outflow *= (*_mass_fractions)[_i][_ph][_sp];
244 
245  if (_use_enthalpy)
246  outflow *= (*_enthalpy)[_i][_ph];
247 
249  outflow *= (*_internal_energy)[_i][_ph];
250 
252  outflow * _dt); // this is not thread safe, but DiracKernel's aren't currently threaded
253 
254  return outflow;
255 }
void add(Real contrib)
Adds contrib to _total.
const bool _use_enthalpy
Whether the flux will be multiplied by the enthalpy.
const unsigned int _ph
The phase number.
const bool _use_relative_permeability
Whether the flux will be multiplied by the relative permeability.
virtual Real computeQpBaseOutflow(unsigned current_dirac_ptid) const =0
Returns the flux from the line sink (before modification by mobility, etc). Derived classes should ov...
PorousFlowSumQuantity & _total_outflow_mass
This is used to hold the total fluid flowing into the line sink for each time step.
const bool _use_mass_fraction
Whether the flux will be multiplied by the mass fraction.
const bool _use_internal_energy
Whether the flux will be multiplied by the internal-energy.
const unsigned int _sp
The component number (only used if _use_mass_fraction==true)
const bool _use_mobility
Whether the flux will be multiplied by the mobility.

◆ dptqp()

Real PorousFlowLineSink::dptqp ( unsigned  pvar) const
protectedinherited

If _p_or_t==0, then returns d(quadpoint porepressure)/d(PorousFlow variable), else returns d(quadpoint temperature)/d(PorousFlow variable)

Parameters
pvarThe PorousFlow variable number

Definition at line 341 of file PorousFlowLineSink.C.

Referenced by PorousFlowPolyLineSink::computeQpBaseOutflowJacobian(), and computeQpBaseOutflowJacobian().

342 {
343  return (_p_or_t == PorTchoice::pressure ? (*_dpp_dvar)[_qp][_ph][pvar]
344  : (*_dtemperature_dvar)[_qp][pvar]);
345 }
const unsigned int _ph
The phase number.
const MaterialProperty< std::vector< Real > > *const _dtemperature_dvar
d(quadpoint temperature)/d(PorousFlow variable)
const MaterialProperty< std::vector< std::vector< Real > > > *const _dpp_dvar
d(quadpoint pore pressure in each phase)/d(PorousFlow variable)
enum PorousFlowLineSink::PorTchoice _p_or_t

◆ jac()

Real PorousFlowLineSink::jac ( unsigned int  jvar)
protectedinherited

Jacobian contribution for the derivative wrt the variable jvar.

Definition at line 270 of file PorousFlowLineSink.C.

Referenced by PorousFlowLineSink::computeQpJacobian(), and PorousFlowLineSink::computeQpOffDiagJacobian().

271 {
273  return 0.0;
274  const unsigned pvar = _dictator.porousFlowVariableNum(jvar);
275 
276  Real outflow;
277  Real outflowp;
278  const unsigned current_dirac_ptid = currentPointCachedID();
279  computeQpBaseOutflowJacobian(jvar, current_dirac_ptid, outflow, outflowp);
280  if (outflow == 0.0 && outflowp == 0.0)
281  return 0.0;
282 
284  {
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];
288  }
289 
290  if (_use_mobility)
291  {
292  const Real mob = (*_relative_permeability)[_i][_ph] * (*_fluid_density_node)[_i][_ph] /
293  (*_fluid_viscosity)[_i][_ph];
294  const Real mob_prime =
295  (_i != _j
296  ? 0.0
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] /
303  Utility::pow<2>((*_fluid_viscosity)[_i][_ph]));
304  outflowp = mob * outflowp + mob_prime * outflow;
305  outflow *= mob;
306  }
307 
308  if (_use_mass_fraction)
309  {
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];
314  }
315 
316  if (_use_enthalpy)
317  {
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];
321  }
322 
324  {
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;
327  // this multiplication was performed, but the code does not need to know: outflow *=
328  // (*_internal_energy)[_i][_ph];
329  }
330 
331  return outflowp;
332 }
const bool _use_enthalpy
Whether the flux will be multiplied by the enthalpy.
const unsigned int _ph
The phase number.
bool notPorousFlowVariable(unsigned int moose_var_num) const
Returns true if moose_var_num is not a porous flow variabe.
const PorousFlowDictator & _dictator
PorousFlowDictator UserObject.
const bool _use_relative_permeability
Whether the flux will be multiplied by the relative permeability.
const bool _use_mass_fraction
Whether the flux will be multiplied by the mass fraction.
const bool _use_internal_energy
Whether the flux will be multiplied by the internal-energy.
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
The PorousFlow variable number.
const unsigned int _sp
The component number (only used if _use_mass_fraction==true)
virtual void computeQpBaseOutflowJacobian(unsigned jvar, unsigned current_dirac_ptid, Real &outflow, Real &outflowp) const =0
Calculates the BaseOutflow as well as its derivative wrt jvar. Derived classes should override this...
const bool _use_mobility
Whether the flux will be multiplied by the mobility.

◆ parseNextLineReals()

bool PorousFlowLineGeometry::parseNextLineReals ( std::ifstream &  ifs,
std::vector< Real > &  myvec 
)
protectedinherited

Reads a space-separated line of floats from ifs and puts in myvec.

Definition at line 103 of file PorousFlowLineGeometry.C.

Referenced by PorousFlowLineGeometry::PorousFlowLineGeometry().

105 {
106  std::string line;
107  myvec.clear();
108  bool gotline(false);
109  if (getline(ifs, line))
110  {
111  gotline = true;
112 
113  // Harvest floats separated by whitespace
114  std::istringstream iss(line);
115  Real f;
116  while (iss >> f)
117  {
118  myvec.push_back(f);
119  }
120  }
121  return gotline;
122 }

◆ ptqp()

Real PorousFlowLineSink::ptqp ( ) const
protectedinherited

If _p_or_t==0, then returns the quadpoint porepressure, else returns the quadpoint temperature.

Definition at line 335 of file PorousFlowLineSink.C.

Referenced by PorousFlowPolyLineSink::computeQpBaseOutflow(), computeQpBaseOutflow(), PorousFlowPolyLineSink::computeQpBaseOutflowJacobian(), and computeQpBaseOutflowJacobian().

336 {
337  return (_p_or_t == PorTchoice::pressure ? (*_pp)[_qp][_ph] : (*_temperature)[_qp]);
338 }
const unsigned int _ph
The phase number.
const MaterialProperty< std::vector< Real > > *const _pp
Quadpoint pore pressure in each phase.
enum PorousFlowLineSink::PorTchoice _p_or_t
const MaterialProperty< Real > *const _temperature
Quadpoint temperature.

◆ wellConstant()

Real PorousFlowPeacemanBorehole::wellConstant ( const RealTensorValue &  perm,
const RealTensorValue &  rot,
const Real &  half_len,
const Elem *  ele,
const Real &  rad 
) const
protected

Calculates Peaceman's form of the borehole well constant Z Chen, Y Zhang, Well flow models for various numerical methods, Int J Num Analysis and Modeling, 3 (2008) 375-388.

Definition at line 108 of file PorousFlowPeacemanBorehole.C.

Referenced by computeQpBaseOutflow(), and computeQpBaseOutflowJacobian().

114 {
115  if (_well_constant > 0)
116  return _well_constant;
117 
118  // rot_perm has its "2" component lying along the half segment.
119  // We want to determine the eigenvectors of rot(0:1, 0:1), since, when
120  // rotated back to the original frame we will determine the element
121  // lengths along these directions
122  const RealTensorValue rot_perm = (rot * perm) * rot.transpose();
123  const Real trace2D = rot_perm(0, 0) + rot_perm(1, 1);
124  const Real det2D = rot_perm(0, 0) * rot_perm(1, 1) - rot_perm(0, 1) * rot_perm(1, 0);
125  const Real sq = std::sqrt(std::max(0.25 * trace2D * trace2D - det2D,
126  0.0)); // the std::max accounts for wierdo precision loss
127  const Real eig_val1 = 0.5 * trace2D + sq;
128  const Real eig_val2 = 0.5 * trace2D - sq;
129  RealVectorValue eig_vec1, eig_vec2;
130  if (sq > std::abs(trace2D) * 1E-7) // matrix is not a multiple of the identity (1E-7 accounts for
131  // precision in a crude way)
132  {
133  if (rot_perm(1, 0) != 0)
134  {
135  eig_vec1(0) = eig_val1 - rot_perm(1, 1);
136  eig_vec1(1) = rot_perm(1, 0);
137  eig_vec2(0) = eig_val2 - rot_perm(1, 1);
138  eig_vec2(1) = rot_perm(1, 0);
139  }
140  else if (rot_perm(0, 1) != 0)
141  {
142  eig_vec1(0) = rot_perm(0, 1);
143  eig_vec1(1) = eig_val1 - rot_perm(0, 0);
144  eig_vec2(0) = rot_perm(0, 1);
145  eig_vec2(1) = eig_val2 - rot_perm(0, 0);
146  }
147  else // off diagonal terms are both zero
148  {
149  eig_vec1(0) = 1.0;
150  eig_vec2(1) = 1.0;
151  }
152  }
153  else // matrix is basically a multiple of the identity
154  {
155  eig_vec1(0) = 1.0;
156  eig_vec2(1) = 1.0;
157  }
158 
159  // finally, rotate these to original frame and normalise
160  eig_vec1 = rot.transpose() * eig_vec1;
161  eig_vec1 /= std::sqrt(eig_vec1 * eig_vec1);
162  eig_vec2 = rot.transpose() * eig_vec2;
163  eig_vec2 /= std::sqrt(eig_vec2 * eig_vec2);
164 
165  // find the "length" of the element in these directions
166  // TODO - maybe better to use variance than max&min
167  Real max1 = eig_vec1 * ele->point(0);
168  Real max2 = eig_vec2 * ele->point(0);
169  Real min1 = max1;
170  Real min2 = max2;
171  Real proj;
172  for (unsigned int i = 1; i < ele->n_nodes(); i++)
173  {
174  proj = eig_vec1 * ele->point(i);
175  max1 = (max1 < proj) ? proj : max1;
176  min1 = (min1 < proj) ? min1 : proj;
177 
178  proj = eig_vec2 * ele->point(i);
179  max2 = (max2 < proj) ? proj : max2;
180  min2 = (min2 < proj) ? min2 : proj;
181  }
182  const Real ll1 = max1 - min1;
183  const Real ll2 = max2 - min2;
184 
185  Real r0;
186  if (eig_val1 <= 0.0)
187  r0 = _re_constant * ll1;
188  else if (eig_val2 <= 0.0)
189  r0 = _re_constant * ll2;
190  else
191  r0 = _re_constant * std::sqrt(std::sqrt(eig_val1 / eig_val2) * std::pow(ll2, 2) +
192  std::sqrt(eig_val2 / eig_val1) * std::pow(ll1, 2)) /
193  (std::pow(eig_val1 / eig_val2, 0.25) + std::pow(eig_val2 / eig_val1, 0.25));
194 
195  const Real effective_perm = (det2D >= 0.0 ? std::sqrt(det2D) : 0.0);
196 
197  const Real halfPi = acos(0.0);
198 
199  if (r0 <= rad)
200  mooseError("The effective element size (about 0.2-times-true-ele-size) for an element "
201  "containing a Peaceman-type borehole must be (much) larger than the borehole radius "
202  "for the Peaceman formulation to be correct. Your element has effective size ",
203  r0,
204  " and the borehole radius is ",
205  rad,
206  "\n");
207 
208  return 4 * halfPi * effective_perm * half_len / std::log(r0 / rad);
209 }
const Real _well_constant
Well constant.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const Real _re_constant
Borehole constant.

Member Data Documentation

◆ _bottom_point

Point PorousFlowLineGeometry::_bottom_point
protectedinherited

The bottom point of the borehole (where bottom_pressure is defined)

Definition at line 62 of file PorousFlowLineGeometry.h.

Referenced by computeQpBaseOutflow(), computeQpBaseOutflowJacobian(), and PorousFlowLineGeometry::PorousFlowLineGeometry().

◆ _character

Function& PorousFlowPeacemanBorehole::_character
protected

If positive then the borehole acts as a sink (producion well) for porepressure > borehole pressure, and does nothing otherwise If negative then the borehole acts as a source (injection well) for porepressure < borehole pressure, and does nothing otherwise The flow rate to/from the borehole is multiplied by |character|, so usually character = +/- 1.

Definition at line 44 of file PorousFlowPeacemanBorehole.h.

Referenced by computeQpBaseOutflow(), and computeQpBaseOutflowJacobian().

◆ _denthalpy_dvar

const MaterialProperty<std::vector<std::vector<Real> > >* const PorousFlowLineSink::_denthalpy_dvar
protectedinherited

d(enthalpy of each phase)/d(PorousFlow variable)

Definition at line 155 of file PorousFlowLineSink.h.

◆ _dfluid_density_node_dvar

const MaterialProperty<std::vector<std::vector<Real> > >* const PorousFlowLineSink::_dfluid_density_node_dvar
protectedinherited

d(Fluid density for each phase (at the node))/d(PorousFlow variable)

Definition at line 131 of file PorousFlowLineSink.h.

◆ _dfluid_viscosity_dvar

const MaterialProperty<std::vector<std::vector<Real> > >* const PorousFlowLineSink::_dfluid_viscosity_dvar
protectedinherited

d(Viscosity of each component in each phase)/d(PorousFlow variable)

Definition at line 137 of file PorousFlowLineSink.h.

◆ _dictator

const PorousFlowDictator& PorousFlowLineSink::_dictator
protectedinherited

◆ _dinternal_energy_dvar

const MaterialProperty<std::vector<std::vector<Real> > >* const PorousFlowLineSink::_dinternal_energy_dvar
protectedinherited

d(internal_energy of each phase)/d(PorousFlow variable)

Definition at line 161 of file PorousFlowLineSink.h.

◆ _dmass_fractions_dvar

const MaterialProperty<std::vector<std::vector<std::vector<Real> > > >* const PorousFlowLineSink::_dmass_fractions_dvar
protectedinherited

d(Mass fraction of each component in each phase)/d(PorousFlow variable)

Definition at line 149 of file PorousFlowLineSink.h.

◆ _dperm_or_cond_dvar

const MaterialProperty<std::vector<RealTensorValue> >& PorousFlowPeacemanBorehole::_dperm_or_cond_dvar
protected

d(Permeability)/d(PorousFlow variable)

Definition at line 68 of file PorousFlowPeacemanBorehole.h.

◆ _dpp_dvar

const MaterialProperty<std::vector<std::vector<Real> > >* const PorousFlowLineSink::_dpp_dvar
protectedinherited

d(quadpoint pore pressure in each phase)/d(PorousFlow variable)

Definition at line 119 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::dptqp().

◆ _drelative_permeability_dvar

const MaterialProperty<std::vector<std::vector<Real> > >* const PorousFlowLineSink::_drelative_permeability_dvar
protectedinherited

d(Relative permeability of each phase)/d(PorousFlow variable)

Definition at line 143 of file PorousFlowLineSink.h.

◆ _dtemperature_dvar

const MaterialProperty<std::vector<Real> >* const PorousFlowLineSink::_dtemperature_dvar
protectedinherited

d(quadpoint temperature)/d(PorousFlow variable)

Definition at line 125 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::dptqp().

◆ _enthalpy

const MaterialProperty<std::vector<Real> >* const PorousFlowLineSink::_enthalpy
protectedinherited

Enthalpy of each phase.

Definition at line 152 of file PorousFlowLineSink.h.

◆ _fluid_density_node

const MaterialProperty<std::vector<Real> >* const PorousFlowLineSink::_fluid_density_node
protectedinherited

Fluid density for each phase (at the node)

Definition at line 128 of file PorousFlowLineSink.h.

◆ _fluid_viscosity

const MaterialProperty<std::vector<Real> >* const PorousFlowLineSink::_fluid_viscosity
protectedinherited

Viscosity of each component in each phase.

Definition at line 134 of file PorousFlowLineSink.h.

◆ _half_seg_len

std::vector<Real> PorousFlowLineGeometry::_half_seg_len
protectedinherited

◆ _has_enthalpy

const bool PorousFlowLineSink::_has_enthalpy
protectedinherited

Whether an enthalpy material exists (for error checking)

Definition at line 86 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::PorousFlowLineSink().

◆ _has_internal_energy

const bool PorousFlowLineSink::_has_internal_energy
protectedinherited

Whether an internal-energy material exists (for error checking)

Definition at line 89 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::PorousFlowLineSink().

◆ _has_mass_fraction

const bool PorousFlowLineSink::_has_mass_fraction
protectedinherited

Whether a mass_fraction material exists (for error checking)

Definition at line 77 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::PorousFlowLineSink().

◆ _has_mobility

const bool PorousFlowLineSink::_has_mobility
protectedinherited

Whether enough materials exist to form the mobility (for error checking)

Definition at line 83 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::PorousFlowLineSink().

◆ _has_permeability

const bool PorousFlowPeacemanBorehole::_has_permeability
protected

Whether there is a quadpoint permeability material (for error checking)

Definition at line 59 of file PorousFlowPeacemanBorehole.h.

Referenced by PorousFlowPeacemanBorehole().

◆ _has_porepressure

const bool PorousFlowLineSink::_has_porepressure
protectedinherited

Whether a quadpoint porepressure material exists (for error checking)

Definition at line 71 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::PorousFlowLineSink().

◆ _has_relative_permeability

const bool PorousFlowLineSink::_has_relative_permeability
protectedinherited

Whether a relative permeability material exists (for error checking)

Definition at line 80 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::PorousFlowLineSink().

◆ _has_temperature

const bool PorousFlowLineSink::_has_temperature
protectedinherited

Whether a quadpoint temperature material exists (for error checking)

Definition at line 74 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::PorousFlowLineSink().

◆ _has_thermal_conductivity

const bool PorousFlowPeacemanBorehole::_has_thermal_conductivity
protected

Whether there is a quadpoint thermal conductivity material (for error checking)

Definition at line 62 of file PorousFlowPeacemanBorehole.h.

Referenced by PorousFlowPeacemanBorehole().

◆ _internal_energy

const MaterialProperty<std::vector<Real> >* const PorousFlowLineSink::_internal_energy
protectedinherited

Internal_Energy of each phase.

Definition at line 158 of file PorousFlowLineSink.h.

◆ _line_direction

const RealVectorValue PorousFlowLineGeometry::_line_direction
protectedinherited

Line direction. This is only used if there is only one borehole point.

Definition at line 40 of file PorousFlowLineGeometry.h.

Referenced by PorousFlowPeacemanBorehole().

◆ _line_length

const Real PorousFlowLineGeometry::_line_length
protectedinherited

Line length. This is only used if there is only one borehole point.

Definition at line 37 of file PorousFlowLineGeometry.h.

Referenced by PorousFlowLineGeometry::PorousFlowLineGeometry().

◆ _mass_fractions

const MaterialProperty<std::vector<std::vector<Real> > >* const PorousFlowLineSink::_mass_fractions
protectedinherited

Mass fraction of each component in each phase.

Definition at line 146 of file PorousFlowLineSink.h.

◆ _p_bot

const Real PorousFlowPeacemanBorehole::_p_bot
protected

Bottomhole pressure of borehole.

Definition at line 47 of file PorousFlowPeacemanBorehole.h.

Referenced by computeQpBaseOutflow(), and computeQpBaseOutflowJacobian().

◆ _p_or_t

enum PorousFlowLineSink::PorTchoice PorousFlowLineSink::_p_or_t
protectedinherited

◆ _perm_or_cond

const MaterialProperty<RealTensorValue>& PorousFlowPeacemanBorehole::_perm_or_cond
protected

Permeability or conductivity of porous material.

Definition at line 65 of file PorousFlowPeacemanBorehole.h.

Referenced by computeQpBaseOutflow(), and computeQpBaseOutflowJacobian().

◆ _ph

const unsigned int PorousFlowLineSink::_ph
protectedinherited

◆ _point_file

const std::string PorousFlowLineGeometry::_point_file
protectedinherited

File defining the geometry of the borehole.

Each row has format weight x y z and the list of such points defines a polyline that is the line sink

Definition at line 47 of file PorousFlowLineGeometry.h.

Referenced by PorousFlowLineGeometry::PorousFlowLineGeometry().

◆ _pp

const MaterialProperty<std::vector<Real> >* const PorousFlowLineSink::_pp
protectedinherited

Quadpoint pore pressure in each phase.

Definition at line 116 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::ptqp().

◆ _re_constant

const Real PorousFlowPeacemanBorehole::_re_constant
protected

Borehole constant.

Definition at line 53 of file PorousFlowPeacemanBorehole.h.

◆ _relative_permeability

const MaterialProperty<std::vector<Real> >* const PorousFlowLineSink::_relative_permeability
protectedinherited

Relative permeability of each phase.

Definition at line 140 of file PorousFlowLineSink.h.

◆ _rot_matrix

std::vector<RealTensorValue> PorousFlowPeacemanBorehole::_rot_matrix
protected

Rotation matrix used in well_constant calculation.

Definition at line 71 of file PorousFlowPeacemanBorehole.h.

Referenced by computeQpBaseOutflow(), computeQpBaseOutflowJacobian(), and PorousFlowPeacemanBorehole().

◆ _rs

std::vector<Real> PorousFlowLineGeometry::_rs
protectedinherited

◆ _sp

const unsigned int PorousFlowLineSink::_sp
protectedinherited

The component number (only used if _use_mass_fraction==true)

Definition at line 113 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::computeQpResidual(), PorousFlowLineSink::jac(), and PorousFlowLineSink::PorousFlowLineSink().

◆ _temperature

const MaterialProperty<Real>* const PorousFlowLineSink::_temperature
protectedinherited

Quadpoint temperature.

Definition at line 122 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::ptqp().

◆ _total_outflow_mass

PorousFlowSumQuantity& PorousFlowLineSink::_total_outflow_mass
protectedinherited

This is used to hold the total fluid flowing into the line sink for each time step.

Hence, it is positive for production wells where fluid is flowing from porespace into the line sink (and hence removed from the model)

Definition at line 68 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::addPoints(), PorousFlowLineSink::computeQpResidual(), and PorousFlowLineSink::PorousFlowLineSink().

◆ _unit_weight

const RealVectorValue PorousFlowPeacemanBorehole::_unit_weight
protected

Unit weight of fluid in borehole (for calculating bottomhole pressure at each Dirac Point)

Definition at line 50 of file PorousFlowPeacemanBorehole.h.

Referenced by computeQpBaseOutflow(), and computeQpBaseOutflowJacobian().

◆ _use_enthalpy

const bool PorousFlowLineSink::_use_enthalpy
protectedinherited

Whether the flux will be multiplied by the enthalpy.

Definition at line 104 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::computeQpResidual(), PorousFlowLineSink::jac(), and PorousFlowLineSink::PorousFlowLineSink().

◆ _use_internal_energy

const bool PorousFlowLineSink::_use_internal_energy
protectedinherited

Whether the flux will be multiplied by the internal-energy.

Definition at line 107 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::computeQpResidual(), PorousFlowLineSink::jac(), and PorousFlowLineSink::PorousFlowLineSink().

◆ _use_mass_fraction

const bool PorousFlowLineSink::_use_mass_fraction
protectedinherited

Whether the flux will be multiplied by the mass fraction.

Definition at line 95 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::computeQpResidual(), PorousFlowLineSink::jac(), and PorousFlowLineSink::PorousFlowLineSink().

◆ _use_mobility

const bool PorousFlowLineSink::_use_mobility
protectedinherited

Whether the flux will be multiplied by the mobility.

Definition at line 101 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::computeQpResidual(), PorousFlowLineSink::jac(), and PorousFlowLineSink::PorousFlowLineSink().

◆ _use_relative_permeability

const bool PorousFlowLineSink::_use_relative_permeability
protectedinherited

Whether the flux will be multiplied by the relative permeability.

Definition at line 98 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::computeQpResidual(), PorousFlowLineSink::jac(), and PorousFlowLineSink::PorousFlowLineSink().

◆ _well_constant

const Real PorousFlowPeacemanBorehole::_well_constant
protected

Well constant.

Definition at line 56 of file PorousFlowPeacemanBorehole.h.

◆ _xs

std::vector<Real> PorousFlowLineGeometry::_xs
protectedinherited

◆ _ys

std::vector<Real> PorousFlowLineGeometry::_ys
protectedinherited

◆ _zs

std::vector<Real> PorousFlowLineGeometry::_zs
protectedinherited

The documentation for this class was generated from the following files: