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
 PorousFlow 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 21 of file PorousFlowPeacemanBorehole.h.

Member Enumeration Documentation

enum PorousFlowLineSink::PorTchoice
strongprotectedinherited

whether the flux is a function of pressure or temperature

Enumerator
pressure 
temperature 

Definition at line 91 of file PorousFlowLineSink.h.

const std::string temperature
Definition: NS.h:25
const std::string pressure
Definition: NS.h:24
enum PorousFlowLineSink::PorTchoice _p_or_t

Constructor & Destructor Documentation

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 61 of file PorousFlowPeacemanBorehole.C.

62  : PorousFlowLineSink(parameters),
63  _character(getFunction("character")),
64  _p_bot(getParam<Real>("bottom_p_or_t")),
65  _unit_weight(getParam<RealVectorValue>("unit_weight")),
66  _re_constant(getParam<Real>("re_constant")),
67  _well_constant(getParam<Real>("well_constant")),
69  hasMaterialProperty<RealTensorValue>("PorousFlow_permeability_qp") &&
70  hasMaterialProperty<std::vector<RealTensorValue>>("dPorousFlow_permeability_qp_dvar")),
72  hasMaterialProperty<RealTensorValue>("PorousFlow_thermal_conductivity_qp") &&
73  hasMaterialProperty<std::vector<RealTensorValue>>(
74  "dPorousFlow_thermal_conductivity_qp_dvar")),
76  ? getMaterialProperty<RealTensorValue>("PorousFlow_permeability_qp")
77  : getMaterialProperty<RealTensorValue>("PorousFlow_thermal_conductivity_qp")),
80  ? getMaterialProperty<std::vector<RealTensorValue>>("dPorousFlow_permeability_qp_dvar")
81  : getMaterialProperty<std::vector<RealTensorValue>>(
82  "dPorousFlow_thermal_conductivity_qp_dvar"))
83 {
85  mooseError("PorousFlowPeacemanBorehole: You have specified function_of=porepressure, but you "
86  "do not have a quadpoint permeability material");
88  mooseError("PorousFlowPeacemanBorehole: You have specified function_of=temperature, but you do "
89  "not have a quadpoint thermal_conductivity material");
90 
91  // construct the rotation matrix needed to rotate the permeability
92  const unsigned int num_pts = _zs.size();
93  _rot_matrix.resize(std::max(num_pts - 1, (unsigned)1));
94  for (unsigned int i = 0; i + 1 < num_pts; ++i)
95  {
96  const RealVectorValue v2(_xs[i + 1] - _xs[i], _ys[i + 1] - _ys[i], _zs[i + 1] - _zs[i]);
97  _rot_matrix[i] = RotationMatrix::rotVecToZ(v2);
98  }
99  if (num_pts == (unsigned)1)
100  _rot_matrix[0] = RotationMatrix::rotVecToZ(_line_direction);
101 }
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

void PorousFlowLineSink::addPoints ( )
overrideprotectedvirtualinherited

Add Dirac Points to the borehole.

Reimplemented from PorousFlowLineGeometry.

Definition at line 206 of file PorousFlowLineSink.C.

207 {
208  // This function gets called just before the DiracKernel is evaluated
209  // so this is a handy place to zero this out.
211 
213 }
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.
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 208 of file PorousFlowPeacemanBorehole.C.

209 {
210  const Real character = _character.value(_t, _q_point[_qp]);
211  if (character == 0.0)
212  return 0.0;
213 
214  const Real bh_pressure = _p_bot + _unit_weight * (_q_point[_qp] - _bottom_point);
215  const Real pp = ptqp();
216 
217  Real outflow = 0.0; // this is the flow rate from porespace out of the system
218 
219  if (current_dirac_ptid > 0)
220  // contribution from half-segment "behind" this point (must have >1 point for
221  // current_dirac_ptid>0)
222  {
223  if ((character < 0.0 && pp < bh_pressure) || (character > 0.0 && pp > bh_pressure))
224  {
225  // injection, so outflow<0 || production, so outflow>0
226  const Real wc = wellConstant(_perm_or_cond[_qp],
227  _rot_matrix[current_dirac_ptid - 1],
228  _half_seg_len[current_dirac_ptid - 1],
229  _current_elem,
230  _rs[current_dirac_ptid]);
231  outflow += wc * (pp - bh_pressure);
232  }
233  }
234 
235  if (current_dirac_ptid + 1 < _zs.size() || _zs.size() == 1)
236  // contribution from half-segment "ahead of" this point, or we only have one point
237  {
238  if ((character < 0.0 && pp < bh_pressure) || (character > 0.0 && pp > bh_pressure))
239  {
240  // injection, so outflow<0 || // production, so outflow>0
241  const Real wc = wellConstant(_perm_or_cond[_qp],
242  _rot_matrix[current_dirac_ptid],
243  _half_seg_len[current_dirac_ptid],
244  _current_elem,
245  _rs[current_dirac_ptid]);
246  outflow += wc * (pp - bh_pressure);
247  }
248  }
249 
250  return outflow * _test[_i][_qp] * std::abs(character);
251 }
const Real _p_bot
bottomhole pressure of borehole
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...
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 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) ...
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 254 of file PorousFlowPeacemanBorehole.C.

258 {
259  outflow = 0.0;
260  outflowp = 0.0;
261 
262  const Real character = _character.value(_t, _q_point[_qp]);
263  if (character == 0.0)
264  return;
265 
267  return;
268  const unsigned pvar = _dictator.porousFlowVariableNum(jvar);
269 
270  const Real bh_pressure = _p_bot + _unit_weight * (_q_point[_qp] - _bottom_point);
271  const Real pp = ptqp();
272  const Real pp_prime = dptqp(pvar) * _phi[_j][_qp];
273 
274  if (current_dirac_ptid > 0)
275  // contribution from half-segment "behind" this point
276  {
277  if ((character < 0.0 && pp < bh_pressure) || (character > 0.0 && pp > bh_pressure))
278  {
279  // injection, so outflow<0 || // production, so outflow>0
280  const Real wc = wellConstant(_perm_or_cond[_qp],
281  _rot_matrix[current_dirac_ptid - 1],
282  _half_seg_len[current_dirac_ptid - 1],
283  _current_elem,
284  _rs[current_dirac_ptid]);
285  outflowp += wc * pp_prime;
286  outflow += wc * (pp - bh_pressure);
287  }
288  }
289 
290  if (current_dirac_ptid < _zs.size() - 1 || _zs.size() == 1)
291  // contribution from half-segment "ahead of" this point
292  {
293  if ((character < 0.0 && pp < bh_pressure) || (character > 0.0 && pp > bh_pressure))
294  {
295  // injection, so outflow<0 || // production, so outflow>0
296  const Real wc = wellConstant(_perm_or_cond[_qp],
297  _rot_matrix[current_dirac_ptid],
298  _half_seg_len[current_dirac_ptid],
299  _current_elem,
300  _rs[current_dirac_ptid]);
301  outflowp += wc * pp_prime;
302  outflow += wc * (pp - bh_pressure);
303  }
304  }
305 
306  outflowp *= _test[_i][_qp] * std::abs(character);
307  outflow *= _test[_i][_qp] * std::abs(character);
308 }
const PorousFlowDictator & _dictator
PorousFlow UserObject.
const Real _p_bot
bottomhole pressure of borehole
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...
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 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.
Real dptqp(unsigned pvar) const
If _p_or_t==0, then returns d(quadpoint porepressure)/d(PorousFlow variable), else returns d(quadpoin...
std::vector< Real > _rs
radii of the borehole
bool notPorousFlowVariable(unsigned int moose_var_num) const
returns true if moose_var_num is not a porous flow variabe
Point _bottom_point
the bottom point of the borehole (where bottom_pressure is defined)
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
the PorousFlow variable number
const RealVectorValue _unit_weight
unit weight of fluid in borehole (for calculating bottomhole pressure at each Dirac Point) ...
Real PorousFlowLineSink::computeQpJacobian ( )
overrideprotectedvirtualinherited

Definition at line 247 of file PorousFlowLineSink.C.

248 {
249  return jac(_var.number());
250 }
Real jac(unsigned int jvar)
Jacobian contribution for the derivative wrt the variable jvar.
Real PorousFlowLineSink::computeQpOffDiagJacobian ( unsigned int  jvar)
overrideprotectedvirtualinherited

Definition at line 253 of file PorousFlowLineSink.C.

254 {
255  return jac(jvar);
256 }
Real jac(unsigned int jvar)
Jacobian contribution for the derivative wrt the variable jvar.
Real PorousFlowLineSink::computeQpResidual ( )
overrideprotectedvirtualinherited

Definition at line 216 of file PorousFlowLineSink.C.

217 {
218  // Get the ID we initially assigned to this point
219  const unsigned current_dirac_ptid = currentPointCachedID();
220  Real outflow = computeQpBaseOutflow(current_dirac_ptid);
221  if (outflow == 0.0)
222  return 0.0;
223 
225  outflow *= (*_relative_permeability)[_i][_ph];
226 
227  if (_use_mobility)
228  outflow *= (*_relative_permeability)[_i][_ph] * (*_fluid_density_node)[_i][_ph] /
229  (*_fluid_viscosity)[_i][_ph];
230 
231  if (_use_mass_fraction)
232  outflow *= (*_mass_fractions)[_i][_ph][_sp];
233 
234  if (_use_enthalpy)
235  outflow *= (*_enthalpy)[_i][_ph];
236 
238  outflow *= (*_internal_energy)[_i][_ph];
239 
241  outflow * _dt); // this is not thread safe, but DiracKernel's aren't currently threaded
242 
243  return outflow;
244 }
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.
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 330 of file PorousFlowLineSink.C.

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

331 {
332  return (_p_or_t == PorTchoice::pressure ? (*_dpp_dvar)[_qp][_ph][pvar]
333  : (*_dtemperature_dvar)[_qp][pvar]);
334 }
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
Real PorousFlowLineSink::jac ( unsigned int  jvar)
protectedinherited

Jacobian contribution for the derivative wrt the variable jvar.

Definition at line 259 of file PorousFlowLineSink.C.

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

260 {
262  return 0.0;
263  const unsigned pvar = _dictator.porousFlowVariableNum(jvar);
264 
265  Real outflow;
266  Real outflowp;
267  const unsigned current_dirac_ptid = currentPointCachedID();
268  computeQpBaseOutflowJacobian(jvar, current_dirac_ptid, outflow, outflowp);
269  if (outflow == 0.0 && outflowp == 0.0)
270  return 0.0;
271 
273  {
274  const Real relperm_prime = (_i != _j ? 0.0 : (*_drelative_permeability_dvar)[_i][_ph][pvar]);
275  outflowp = (*_relative_permeability)[_i][_ph] * outflowp + relperm_prime * outflow;
276  outflow *= (*_relative_permeability)[_i][_ph];
277  }
278 
279  if (_use_mobility)
280  {
281  const Real mob = (*_relative_permeability)[_i][_ph] * (*_fluid_density_node)[_i][_ph] /
282  (*_fluid_viscosity)[_i][_ph];
283  const Real mob_prime =
284  (_i != _j
285  ? 0.0
286  : (*_drelative_permeability_dvar)[_i][_ph][pvar] * (*_fluid_density_node)[_i][_ph] /
287  (*_fluid_viscosity)[_i][_ph] +
288  (*_relative_permeability)[_i][_ph] *
289  (*_dfluid_density_node_dvar)[_i][_ph][pvar] / (*_fluid_viscosity)[_i][_ph] -
290  (*_relative_permeability)[_i][_ph] * (*_fluid_density_node)[_i][_ph] *
291  (*_dfluid_viscosity_dvar)[_i][_ph][pvar] /
292  Utility::pow<2>((*_fluid_viscosity)[_i][_ph]));
293  outflowp = mob * outflowp + mob_prime * outflow;
294  outflow *= mob;
295  }
296 
297  if (_use_mass_fraction)
298  {
299  const Real mass_fractions_prime =
300  (_i != _j ? 0.0 : (*_dmass_fractions_dvar)[_i][_ph][_sp][pvar]);
301  outflowp = (*_mass_fractions)[_i][_ph][_sp] * outflowp + mass_fractions_prime * outflow;
302  outflow *= (*_mass_fractions)[_i][_ph][_sp];
303  }
304 
305  if (_use_enthalpy)
306  {
307  const Real enthalpy_prime = (_i != _j ? 0.0 : (*_denthalpy_dvar)[_i][_ph][pvar]);
308  outflowp = (*_enthalpy)[_i][_ph] * outflowp + enthalpy_prime * outflow;
309  outflow *= (*_enthalpy)[_i][_ph];
310  }
311 
313  {
314  const Real internal_energy_prime = (_i != _j ? 0.0 : (*_dinternal_energy_dvar)[_i][_ph][pvar]);
315  outflowp = (*_internal_energy)[_i][_ph] * outflowp + internal_energy_prime * outflow;
316  // this multiplication was performed, but the code does not need to know: outflow *=
317  // (*_internal_energy)[_i][_ph];
318  }
319 
320  return outflowp;
321 }
const bool _use_enthalpy
Whether the flux will be multiplied by the enthalpy.
const unsigned int _ph
The phase number.
const PorousFlowDictator & _dictator
PorousFlow UserObject.
const bool _use_relative_permeability
Whether the flux will be multiplied by the relative permeability.
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_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)
bool notPorousFlowVariable(unsigned int moose_var_num) const
returns true if moose_var_num is not a porous flow variabe
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
the PorousFlow variable number
const bool _use_mobility
Whether the flux will be multiplied by the mobility.
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 101 of file PorousFlowLineGeometry.C.

Referenced by PorousFlowLineGeometry::PorousFlowLineGeometry().

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

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

Definition at line 324 of file PorousFlowLineSink.C.

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

325 {
326  return (_p_or_t == PorTchoice::pressure ? (*_pp)[_qp][_ph] : (*_temperature)[_qp]);
327 }
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.
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 104 of file PorousFlowPeacemanBorehole.C.

Referenced by computeQpBaseOutflow(), and computeQpBaseOutflowJacobian().

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

Member Data Documentation

Point PorousFlowLineGeometry::_bottom_point
protectedinherited

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

Definition at line 60 of file PorousFlowLineGeometry.h.

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

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 42 of file PorousFlowPeacemanBorehole.h.

Referenced by computeQpBaseOutflow(), and computeQpBaseOutflowJacobian().

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

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

Definition at line 154 of file PorousFlowLineSink.h.

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 130 of file PorousFlowLineSink.h.

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 136 of file PorousFlowLineSink.h.

const PorousFlowDictator& PorousFlowLineSink::_dictator
protectedinherited
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 160 of file PorousFlowLineSink.h.

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 148 of file PorousFlowLineSink.h.

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

d(Permeability)/d(PorousFlow variable)

Definition at line 66 of file PorousFlowPeacemanBorehole.h.

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 118 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::dptqp().

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 142 of file PorousFlowLineSink.h.

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

d(quadpoint temperature)/d(PorousFlow variable)

Definition at line 124 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::dptqp().

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

Enthalpy of each phase.

Definition at line 151 of file PorousFlowLineSink.h.

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

Fluid density for each phase (at the node)

Definition at line 127 of file PorousFlowLineSink.h.

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

Viscosity of each component in each phase.

Definition at line 133 of file PorousFlowLineSink.h.

std::vector<Real> PorousFlowLineGeometry::_half_seg_len
protectedinherited
const bool PorousFlowLineSink::_has_enthalpy
protectedinherited

Whether an enthalpy material exists (for error checking)

Definition at line 85 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::PorousFlowLineSink().

const bool PorousFlowLineSink::_has_internal_energy
protectedinherited

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

Definition at line 88 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::PorousFlowLineSink().

const bool PorousFlowLineSink::_has_mass_fraction
protectedinherited

Whether a mass_fraction material exists (for error checking)

Definition at line 76 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::PorousFlowLineSink().

const bool PorousFlowLineSink::_has_mobility
protectedinherited

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

Definition at line 82 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::PorousFlowLineSink().

const bool PorousFlowPeacemanBorehole::_has_permeability
protected

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

Definition at line 57 of file PorousFlowPeacemanBorehole.h.

Referenced by PorousFlowPeacemanBorehole().

const bool PorousFlowLineSink::_has_porepressure
protectedinherited

Whether a quadpoint porepressure material exists (for error checking)

Definition at line 70 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::PorousFlowLineSink().

const bool PorousFlowLineSink::_has_relative_permeability
protectedinherited

Whether a relative permeability material exists (for error checking)

Definition at line 79 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::PorousFlowLineSink().

const bool PorousFlowLineSink::_has_temperature
protectedinherited

Whether a quadpoint temperature material exists (for error checking)

Definition at line 73 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::PorousFlowLineSink().

const bool PorousFlowPeacemanBorehole::_has_thermal_conductivity
protected

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

Definition at line 60 of file PorousFlowPeacemanBorehole.h.

Referenced by PorousFlowPeacemanBorehole().

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

Internal_Energy of each phase.

Definition at line 157 of file PorousFlowLineSink.h.

const RealVectorValue PorousFlowLineGeometry::_line_direction
protectedinherited

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

Definition at line 38 of file PorousFlowLineGeometry.h.

Referenced by PorousFlowPeacemanBorehole().

const Real PorousFlowLineGeometry::_line_length
protectedinherited

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

Definition at line 35 of file PorousFlowLineGeometry.h.

Referenced by PorousFlowLineGeometry::PorousFlowLineGeometry().

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

Mass fraction of each component in each phase.

Definition at line 145 of file PorousFlowLineSink.h.

const Real PorousFlowPeacemanBorehole::_p_bot
protected

bottomhole pressure of borehole

Definition at line 45 of file PorousFlowPeacemanBorehole.h.

Referenced by computeQpBaseOutflow(), and computeQpBaseOutflowJacobian().

enum PorousFlowLineSink::PorTchoice PorousFlowLineSink::_p_or_t
protectedinherited
const MaterialProperty<RealTensorValue>& PorousFlowPeacemanBorehole::_perm_or_cond
protected

Permeability or conductivity of porous material.

Definition at line 63 of file PorousFlowPeacemanBorehole.h.

Referenced by computeQpBaseOutflow(), and computeQpBaseOutflowJacobian().

const unsigned int PorousFlowLineSink::_ph
protectedinherited
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 45 of file PorousFlowLineGeometry.h.

Referenced by PorousFlowLineGeometry::PorousFlowLineGeometry().

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

Quadpoint pore pressure in each phase.

Definition at line 115 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::ptqp().

const Real PorousFlowPeacemanBorehole::_re_constant
protected

borehole constant

Definition at line 51 of file PorousFlowPeacemanBorehole.h.

Referenced by wellConstant().

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

Relative permeability of each phase.

Definition at line 139 of file PorousFlowLineSink.h.

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

rotation matrix used in well_constant calculation

Definition at line 69 of file PorousFlowPeacemanBorehole.h.

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

std::vector<Real> PorousFlowLineGeometry::_rs
protectedinherited
const unsigned int PorousFlowLineSink::_sp
protectedinherited

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

Definition at line 112 of file PorousFlowLineSink.h.

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

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

Quadpoint temperature.

Definition at line 121 of file PorousFlowLineSink.h.

Referenced by PorousFlowLineSink::ptqp().

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 67 of file PorousFlowLineSink.h.

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

const RealVectorValue PorousFlowPeacemanBorehole::_unit_weight
protected

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

Definition at line 48 of file PorousFlowPeacemanBorehole.h.

Referenced by computeQpBaseOutflow(), and computeQpBaseOutflowJacobian().

const bool PorousFlowLineSink::_use_enthalpy
protectedinherited

Whether the flux will be multiplied by the enthalpy.

Definition at line 103 of file PorousFlowLineSink.h.

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

const bool PorousFlowLineSink::_use_internal_energy
protectedinherited

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

Definition at line 106 of file PorousFlowLineSink.h.

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

const bool PorousFlowLineSink::_use_mass_fraction
protectedinherited

Whether the flux will be multiplied by the mass fraction.

Definition at line 94 of file PorousFlowLineSink.h.

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

const bool PorousFlowLineSink::_use_mobility
protectedinherited

Whether the flux will be multiplied by the mobility.

Definition at line 100 of file PorousFlowLineSink.h.

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

const bool PorousFlowLineSink::_use_relative_permeability
protectedinherited

Whether the flux will be multiplied by the relative permeability.

Definition at line 97 of file PorousFlowLineSink.h.

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

const Real PorousFlowPeacemanBorehole::_well_constant
protected

well constant

Definition at line 54 of file PorousFlowPeacemanBorehole.h.

Referenced by wellConstant().

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

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