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

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

#include <Q2PBorehole.h>

Inheritance diagram for Q2PBorehole:
[legend]

Public Member Functions

 Q2PBorehole (const InputParameters &parameters)
 Creates a new Q2PBorehole This sets all the variables, but also reads the file containing the lines of the form radius x y z that defines the borehole geometry. More...
 
virtual void computeResidual ()
 Computes the residual. More...
 
virtual Real computeQpResidual ()
 Computes the Qp residual. More...
 
virtual void computeJacobian ()
 Computes the Jacobian. More...
 
virtual Real computeQpJacobian ()
 Computes the diagonal part of the jacobian. More...
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar)
 Computes the off-diagonal part of the jacobian. More...
 

Protected Member Functions

void prepareNodalValues ()
 calculates the nodal values of pressure, mobility, and derivatives thereof More...
 
Real jac (unsigned int jvar)
 Calculates Jacobian. More...
 
virtual void addPoints ()
 Add Dirac Points to the borehole. More...
 
bool parseNextLineReals (std::ifstream &ifs, std::vector< Real > &myvec)
 reads a space-separated line of floats from ifs and puts in myvec More...
 
Real wellConstant (const RealTensorValue &perm, const RealTensorValue &rot, const Real &half_len, const Elem *ele, const Real &rad)
 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...
 

Protected Attributes

const RichardsDensity_density
 fluid density More...
 
const RichardsRelPerm_relperm
 fluid relative permeability More...
 
const VariableValue & _other_var_nodal
 the other variable in the 2-phase system (this is saturation if Variable=porepressure, and viceversa) More...
 
const unsigned int _other_var_num
 the variable number of the other variable More...
 
const bool _var_is_pp
 whether the Variable for this BC is porepressure or not More...
 
const Real _viscosity
 viscosity More...
 
const MaterialProperty< RealTensorValue > & _permeability
 permeability More...
 
unsigned int _num_nodes
 number of nodes in this element. More...
 
std::vector< Real > _pp
 nodal porepressure More...
 
std::vector< Real > _sat
 nodal saturation More...
 
std::vector< Real > _mobility
 nodal mobility More...
 
std::vector< Real > _dmobility_dp
 nodal d(mobility)/d(porepressure) More...
 
std::vector< Real > _dmobility_ds
 nodal d(mobility)/d(saturation) More...
 
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...
 
RichardsSumQuantity_total_outflow_mass
 This is used to hold the total fluid flowing into the borehole Hence, it is positive for production wells where fluid is flowing from porespace into the borehole and removed from the model. 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...
 
std::vector< RealTensorValue > _rot_matrix
 rotation matrix used in well_constant calculation More...
 

Detailed Description

Approximates a borehole by a sequence of Dirac Points.

This is for use by a Q2P model.

Definition at line 27 of file Q2PBorehole.h.

Constructor & Destructor Documentation

◆ Q2PBorehole()

Q2PBorehole::Q2PBorehole ( const InputParameters &  parameters)

Creates a new Q2PBorehole This sets all the variables, but also 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 44 of file Q2PBorehole.C.

45  : PeacemanBorehole(parameters),
46  _density(getUserObject<RichardsDensity>("fluid_density")),
47  _relperm(getUserObject<RichardsRelPerm>("fluid_relperm")),
48  _other_var_nodal(coupledNodalValue("other_var")),
49  _other_var_num(coupled("other_var")),
50  _var_is_pp(getParam<bool>("var_is_porepressure")),
51  _viscosity(getParam<Real>("fluid_viscosity")),
52  _permeability(getMaterialProperty<RealTensorValue>("permeability")),
53  _num_nodes(0),
54  _pp(0),
55  _sat(0),
56  _mobility(0),
57  _dmobility_dp(0),
58  _dmobility_ds(0)
59 {
60 }
unsigned int _num_nodes
number of nodes in this element.
Definition: Q2PBorehole.h:93
const RichardsRelPerm & _relperm
fluid relative permeability
Definition: Q2PBorehole.h:75
PeacemanBorehole(const InputParameters &parameters)
Creates a new PeacemanBorehole This reads the file containing the lines of the form radius x y z that...
std::vector< Real > _dmobility_dp
nodal d(mobility)/d(porepressure)
Definition: Q2PBorehole.h:105
const unsigned int _other_var_num
the variable number of the other variable
Definition: Q2PBorehole.h:81
const VariableValue & _other_var_nodal
the other variable in the 2-phase system (this is saturation if Variable=porepressure, and viceversa)
Definition: Q2PBorehole.h:78
std::vector< Real > _mobility
nodal mobility
Definition: Q2PBorehole.h:102
const Real _viscosity
viscosity
Definition: Q2PBorehole.h:87
std::vector< Real > _sat
nodal saturation
Definition: Q2PBorehole.h:99
const RichardsDensity & _density
fluid density
Definition: Q2PBorehole.h:72
std::vector< Real > _dmobility_ds
nodal d(mobility)/d(saturation)
Definition: Q2PBorehole.h:108
const bool _var_is_pp
whether the Variable for this BC is porepressure or not
Definition: Q2PBorehole.h:84
const MaterialProperty< RealTensorValue > & _permeability
permeability
Definition: Q2PBorehole.h:90
std::vector< Real > _pp
nodal porepressure
Definition: Q2PBorehole.h:96

Member Function Documentation

◆ addPoints()

void PeacemanBorehole::addPoints ( )
protectedvirtualinherited

Add Dirac Points to the borehole.

Definition at line 180 of file PeacemanBorehole.C.

181 {
182  // This function gets called just before the DiracKernel is evaluated
183  // so this is a handy place to zero this out.
185 
186  // Add point using the unique ID "i", let the DiracKernel take
187  // care of the caching. This should be fast after the first call,
188  // as long as the points don't move around.
189  for (unsigned int i = 0; i < _zs.size(); i++)
190  addPoint(Point(_xs[i], _ys[i], _zs[i]), i);
191 }
std::vector< Real > _xs
x points of the borehole
std::vector< Real > _ys
y points of the borehole
void zero()
sets _total = 0
RichardsSumQuantity & _total_outflow_mass
This is used to hold the total fluid flowing into the borehole Hence, it is positive for production w...
std::vector< Real > _zs
z points of borehole

◆ computeJacobian()

void Q2PBorehole::computeJacobian ( )
virtual

Computes the Jacobian.

This just calls prepareNodalValues then calls DiracKernel::computeJacobian

Definition at line 171 of file Q2PBorehole.C.

172 {
174  DiracKernel::computeJacobian();
175 }
void prepareNodalValues()
calculates the nodal values of pressure, mobility, and derivatives thereof
Definition: Q2PBorehole.C:63

◆ computeQpJacobian()

Real Q2PBorehole::computeQpJacobian ( )
virtual

Computes the diagonal part of the jacobian.

Definition at line 178 of file Q2PBorehole.C.

179 {
180  return jac(_var.number());
181 }
Real jac(unsigned int jvar)
Calculates Jacobian.
Definition: Q2PBorehole.C:192

◆ computeQpOffDiagJacobian()

Real Q2PBorehole::computeQpOffDiagJacobian ( unsigned int  jvar)
virtual

Computes the off-diagonal part of the jacobian.

Definition at line 184 of file Q2PBorehole.C.

185 {
186  if (jvar == _other_var_num || jvar == _var.number())
187  return jac(jvar);
188  return 0.0;
189 }
const unsigned int _other_var_num
the variable number of the other variable
Definition: Q2PBorehole.h:81
Real jac(unsigned int jvar)
Calculates Jacobian.
Definition: Q2PBorehole.C:192

◆ computeQpResidual()

Real Q2PBorehole::computeQpResidual ( )
virtual

Computes the Qp residual.

Definition at line 114 of file Q2PBorehole.C.

115 {
116  const Real character = _character.value(_t, _q_point[_qp]);
117  if (character == 0.0)
118  return 0.0;
119 
120  const Real bh_pressure =
121  _p_bot +
122  _unit_weight *
123  (_q_point[_qp] -
124  _bottom_point); // really want to use _q_point instaed of _current_point, i think?!
125 
126  // Get the ID we initially assigned to this point
127  const unsigned current_dirac_ptid = currentPointCachedID();
128 
129  // If getting the ID failed, fall back to the old bodge!
130  // if (current_dirac_ptid == libMesh::invalid_uint)
131  // current_dirac_ptid = (_zs.size() > 2) ? 1 : 0;
132 
133  Real outflow(0.0); // this is the flow rate from porespace out of the system
134 
135  Real wc(0.0);
136  if (current_dirac_ptid > 0)
137  // contribution from half-segment "behind" this point (must have >1 point for
138  // current_dirac_ptid>0)
139  {
140  wc = wellConstant(_permeability[0],
141  _rot_matrix[current_dirac_ptid - 1],
142  _half_seg_len[current_dirac_ptid - 1],
143  _current_elem,
144  _rs[current_dirac_ptid]);
145  if ((character < 0.0 && _pp[_i] < bh_pressure) || (character > 0.0 && _pp[_i] > bh_pressure))
146  // injection, so outflow<0 || // production, so outflow>0
147  outflow +=
148  _test[_i][_qp] * std::abs(character) * wc * _mobility[_i] * (_pp[_i] - bh_pressure);
149  }
150 
151  if (current_dirac_ptid + 1 < _zs.size() || _zs.size() == 1)
152  // contribution from half-segment "ahead of" this point, or we only have one point
153  {
154  wc = wellConstant(_permeability[0],
155  _rot_matrix[current_dirac_ptid],
156  _half_seg_len[current_dirac_ptid],
157  _current_elem,
158  _rs[current_dirac_ptid]);
159  if ((character < 0.0 && _pp[_i] < bh_pressure) || (character > 0.0 && _pp[_i] > bh_pressure))
160  // injection, so outflow<0 || // production, so outflow>0
161  outflow +=
162  _test[_i][_qp] * std::abs(character) * wc * _mobility[_i] * (_pp[_i] - bh_pressure);
163  }
164 
166  outflow * _dt); // this is not thread safe, but DiracKernel's aren't currently threaded
167  return outflow;
168 }
Real wellConstant(const RealTensorValue &perm, const RealTensorValue &rot, const Real &half_len, const Elem *ele, const Real &rad)
Calculates Peaceman&#39;s form of the borehole well constant Z Chen, Y Zhang, Well flow models for variou...
std::vector< Real > _rs
radii of the borehole
std::vector< Real > _mobility
nodal mobility
Definition: Q2PBorehole.h:102
const RealVectorValue _unit_weight
unit weight of fluid in borehole (for calculating bottomhole pressure at each Dirac Point) ...
void add(Real contrib)
adds contrib to _total
RichardsSumQuantity & _total_outflow_mass
This is used to hold the total fluid flowing into the borehole Hence, it is positive for production w...
const Real _p_bot
bottomhole pressure of borehole
const MaterialProperty< RealTensorValue > & _permeability
permeability
Definition: Q2PBorehole.h:90
Point _bottom_point
the bottom point of the borehole (where bottom_pressure is defined)
std::vector< RealTensorValue > _rot_matrix
rotation matrix used in well_constant calculation
std::vector< Real > _half_seg_len
0.5*(length of polyline segments between points)
std::vector< Real > _zs
z points of borehole
std::vector< Real > _pp
nodal porepressure
Definition: Q2PBorehole.h:96
Function & _character
If positive then the borehole acts as a sink (producion well) for porepressure > borehole pressure...

◆ computeResidual()

void Q2PBorehole::computeResidual ( )
virtual

Computes the residual.

This just calls prepareNodalValues then calls DiracKernel::computeResidual

Definition at line 107 of file Q2PBorehole.C.

108 {
110  DiracKernel::computeResidual();
111 }
void prepareNodalValues()
calculates the nodal values of pressure, mobility, and derivatives thereof
Definition: Q2PBorehole.C:63

◆ jac()

Real Q2PBorehole::jac ( unsigned int  jvar)
protected

Calculates Jacobian.

Parameters
jvardifferentiate the residual wrt this variable

Definition at line 192 of file Q2PBorehole.C.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

193 {
194  if (_i != _j)
195  return 0.0;
196 
197  const Real character = _character.value(_t, _q_point[_qp]);
198  if (character == 0.0)
199  return 0.0;
200 
201  const Real bh_pressure =
202  _p_bot +
203  _unit_weight *
204  (_q_point[_qp] -
205  _bottom_point); // really want to use _q_point instaed of _current_point, i think?!
206 
207  const Real phi = 1;
208 
209  // Get the ID we initially assigned to this point
210  const unsigned current_dirac_ptid = currentPointCachedID();
211 
212  // If getting the ID failed, fall back to the old bodge!
213  // if (current_dirac_ptid == libMesh::invalid_uint)
214  // current_dirac_ptid = (_zs.size() > 2) ? 1 : 0;
215 
216  Real outflowp(0.0);
217 
218  const bool deriv_wrt_pp =
219  (_var_is_pp && (jvar == _var.number())) || (!_var_is_pp && (jvar == _other_var_num));
220 
221  Real wc(0.0);
222  if (current_dirac_ptid > 0)
223  // contribution from half-segment "behind" this point
224  {
225  wc = wellConstant(_permeability[0],
226  _rot_matrix[current_dirac_ptid - 1],
227  _half_seg_len[current_dirac_ptid - 1],
228  _current_elem,
229  _rs[current_dirac_ptid]);
230  if ((character < 0.0 && _pp[_i] < bh_pressure) || (character > 0.0 && _pp[_i] > bh_pressure))
231  {
232  // injection, so outflow<0 || // production, so outflow>0
233  if (deriv_wrt_pp)
234  outflowp += std::abs(character) * wc *
235  (_mobility[_i] * phi + _dmobility_dp[_i] * phi * (_pp[_i] - bh_pressure));
236  else
237  outflowp += std::abs(character) * wc * _dmobility_ds[_i] * phi * (_pp[_i] - bh_pressure);
238  }
239  }
240 
241  if (current_dirac_ptid < _zs.size() - 1 || _zs.size() == 1)
242  // contribution from half-segment "ahead of" this point
243  {
244  wc = wellConstant(_permeability[0],
245  _rot_matrix[current_dirac_ptid],
246  _half_seg_len[current_dirac_ptid],
247  _current_elem,
248  _rs[current_dirac_ptid]);
249  if ((character < 0.0 && _pp[_i] < bh_pressure) || (character > 0.0 && _pp[_i] > bh_pressure))
250  {
251  // injection, so outflow<0 || // production, so outflow>0
252  if (deriv_wrt_pp)
253  outflowp += std::abs(character) * wc *
254  (_mobility[_i] * phi + _dmobility_dp[_i] * phi * (_pp[_i] - bh_pressure));
255  else
256  outflowp += std::abs(character) * wc * _dmobility_ds[_i] * phi * (_pp[_i] - bh_pressure);
257  }
258  }
259 
260  return _test[_i][_qp] * outflowp;
261 }
std::vector< Real > _dmobility_dp
nodal d(mobility)/d(porepressure)
Definition: Q2PBorehole.h:105
Real wellConstant(const RealTensorValue &perm, const RealTensorValue &rot, const Real &half_len, const Elem *ele, const Real &rad)
Calculates Peaceman&#39;s form of the borehole well constant Z Chen, Y Zhang, Well flow models for variou...
const unsigned int _other_var_num
the variable number of the other variable
Definition: Q2PBorehole.h:81
std::vector< Real > _rs
radii of the borehole
std::vector< Real > _mobility
nodal mobility
Definition: Q2PBorehole.h:102
const RealVectorValue _unit_weight
unit weight of fluid in borehole (for calculating bottomhole pressure at each Dirac Point) ...
const Real _p_bot
bottomhole pressure of borehole
std::vector< Real > _dmobility_ds
nodal d(mobility)/d(saturation)
Definition: Q2PBorehole.h:108
const bool _var_is_pp
whether the Variable for this BC is porepressure or not
Definition: Q2PBorehole.h:84
const MaterialProperty< RealTensorValue > & _permeability
permeability
Definition: Q2PBorehole.h:90
Point _bottom_point
the bottom point of the borehole (where bottom_pressure is defined)
std::vector< RealTensorValue > _rot_matrix
rotation matrix used in well_constant calculation
std::vector< Real > _half_seg_len
0.5*(length of polyline segments between points)
std::vector< Real > _zs
z points of borehole
std::vector< Real > _pp
nodal porepressure
Definition: Q2PBorehole.h:96
Function & _character
If positive then the borehole acts as a sink (producion well) for porepressure > borehole pressure...

◆ parseNextLineReals()

bool PeacemanBorehole::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 158 of file PeacemanBorehole.C.

Referenced by PeacemanBorehole::PeacemanBorehole().

160 {
161  std::string line;
162  myvec.clear();
163  bool gotline(false);
164  if (getline(ifs, line))
165  {
166  gotline = true;
167 
168  // Harvest floats separated by whitespace
169  std::istringstream iss(line);
170  Real f;
171  while (iss >> f)
172  {
173  myvec.push_back(f);
174  }
175  }
176  return gotline;
177 }

◆ prepareNodalValues()

void Q2PBorehole::prepareNodalValues ( )
protected

calculates the nodal values of pressure, mobility, and derivatives thereof

Definition at line 63 of file Q2PBorehole.C.

Referenced by computeJacobian(), and computeResidual().

64 {
66 
67  // set _pp and _sat variables
68  _pp.resize(_num_nodes);
69  _sat.resize(_num_nodes);
70  if (_var_is_pp)
71  {
72  for (unsigned int nodenum = 0; nodenum < _num_nodes; ++nodenum)
73  {
74  _pp[nodenum] = _var.dofValues()[nodenum];
75  _sat[nodenum] = _other_var_nodal[nodenum];
76  }
77  }
78  else
79  {
80  for (unsigned int nodenum = 0; nodenum < _num_nodes; ++nodenum)
81  {
82  _pp[nodenum] = _other_var_nodal[nodenum];
83  _sat[nodenum] = _var.dofValues()[nodenum];
84  }
85  }
86 
87  Real density;
88  Real ddensity_dp;
89  Real relperm;
90  Real drelperm_ds;
91  _mobility.resize(_num_nodes);
92  _dmobility_dp.resize(_num_nodes);
93  _dmobility_ds.resize(_num_nodes);
94  for (unsigned int nodenum = 0; nodenum < _num_nodes; ++nodenum)
95  {
96  density = _density.density(_pp[nodenum]);
97  ddensity_dp = _density.ddensity(_pp[nodenum]);
98  relperm = _relperm.relperm(_sat[nodenum]);
99  drelperm_ds = _relperm.drelperm(_sat[nodenum]);
100  _mobility[nodenum] = density * relperm / _viscosity;
101  _dmobility_dp[nodenum] = ddensity_dp * relperm / _viscosity;
102  _dmobility_ds[nodenum] = density * drelperm_ds / _viscosity;
103  }
104 }
unsigned int _num_nodes
number of nodes in this element.
Definition: Q2PBorehole.h:93
const RichardsRelPerm & _relperm
fluid relative permeability
Definition: Q2PBorehole.h:75
virtual Real drelperm(Real seff) const =0
derivative of relative permeability wrt effective saturation This must be over-ridden in your derived...
virtual Real ddensity(Real p) const =0
derivative of fluid density wrt porepressure This must be over-ridden in derived classes to provide a...
std::vector< Real > _dmobility_dp
nodal d(mobility)/d(porepressure)
Definition: Q2PBorehole.h:105
const std::string density
Definition: NS.h:17
const VariableValue & _other_var_nodal
the other variable in the 2-phase system (this is saturation if Variable=porepressure, and viceversa)
Definition: Q2PBorehole.h:78
std::vector< Real > _mobility
nodal mobility
Definition: Q2PBorehole.h:102
virtual Real density(Real p) const =0
fluid density as a function of porepressure This must be over-ridden in derived classes to provide an...
const Real _viscosity
viscosity
Definition: Q2PBorehole.h:87
std::vector< Real > _sat
nodal saturation
Definition: Q2PBorehole.h:99
virtual Real relperm(Real seff) const =0
relative permeability as a function of effective saturation This must be over-ridden in your derived ...
const RichardsDensity & _density
fluid density
Definition: Q2PBorehole.h:72
std::vector< Real > _dmobility_ds
nodal d(mobility)/d(saturation)
Definition: Q2PBorehole.h:108
const bool _var_is_pp
whether the Variable for this BC is porepressure or not
Definition: Q2PBorehole.h:84
std::vector< Real > _pp
nodal porepressure
Definition: Q2PBorehole.h:96

◆ wellConstant()

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

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 194 of file PeacemanBorehole.C.

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

200 {
201  if (_well_constant > 0)
202  return _well_constant;
203 
204  // rot_perm has its "2" component lying along the half segment
205  // we want to determine the eigenvectors of rot(0:1, 0:1), since, when
206  // rotated back to the original frame we will determine the element
207  // lengths along these directions
208  const RealTensorValue rot_perm = (rot * perm) * rot.transpose();
209  const Real trace2D = rot_perm(0, 0) + rot_perm(1, 1);
210  const Real det2D = rot_perm(0, 0) * rot_perm(1, 1) - rot_perm(0, 1) * rot_perm(1, 0);
211  const Real sq = std::sqrt(std::max(0.25 * trace2D * trace2D - det2D,
212  0.0)); // the std::max accounts for wierdo precision loss
213  const Real eig_val1 = 0.5 * trace2D + sq;
214  const Real eig_val2 = 0.5 * trace2D - sq;
215  RealVectorValue eig_vec1, eig_vec2;
216  if (sq > std::abs(trace2D) * 1E-7) // matrix is not a multiple of the identity (1E-7 accounts for
217  // precision in a crude way)
218  {
219  if (rot_perm(1, 0) != 0)
220  {
221  eig_vec1(0) = eig_val1 - rot_perm(1, 1);
222  eig_vec1(1) = rot_perm(1, 0);
223  eig_vec2(0) = eig_val2 - rot_perm(1, 1);
224  eig_vec2(1) = rot_perm(1, 0);
225  }
226  else if (rot_perm(0, 1) != 0)
227  {
228  eig_vec1(0) = rot_perm(0, 1);
229  eig_vec1(1) = eig_val1 - rot_perm(0, 0);
230  eig_vec2(0) = rot_perm(0, 1);
231  eig_vec2(1) = eig_val2 - rot_perm(0, 0);
232  }
233  else // off diagonal terms are both zero
234  {
235  eig_vec1(0) = 1;
236  eig_vec2(1) = 1;
237  }
238  }
239  else // matrix is basically a multiple of the identity
240  {
241  eig_vec1(0) = 1;
242  eig_vec2(1) = 1;
243  }
244 
245  // finally, rotate these to original frame and normalise
246  eig_vec1 = rot.transpose() * eig_vec1;
247  eig_vec1 /= std::sqrt(eig_vec1 * eig_vec1);
248  eig_vec2 = rot.transpose() * eig_vec2;
249  eig_vec2 /= std::sqrt(eig_vec2 * eig_vec2);
250 
251  // find the "length" of the element in these directions
252  // TODO - probably better to use variance than max&min
253  Real max1 = eig_vec1 * ele->point(0);
254  Real max2 = eig_vec2 * ele->point(0);
255  Real min1 = max1;
256  Real min2 = max2;
257  Real proj;
258  for (unsigned int i = 1; i < ele->n_nodes(); i++)
259  {
260  proj = eig_vec1 * ele->point(i);
261  max1 = (max1 < proj) ? proj : max1;
262  min1 = (min1 < proj) ? min1 : proj;
263 
264  proj = eig_vec2 * ele->point(i);
265  max2 = (max2 < proj) ? proj : max2;
266  min2 = (min2 < proj) ? min2 : proj;
267  }
268  const Real ll1 = max1 - min1;
269  const Real ll2 = max2 - min2;
270 
271  const Real r0 = _re_constant * std::sqrt(std::sqrt(eig_val1 / eig_val2) * std::pow(ll2, 2) +
272  std::sqrt(eig_val2 / eig_val1) * std::pow(ll1, 2)) /
273  (std::pow(eig_val1 / eig_val2, 0.25) + std::pow(eig_val2 / eig_val1, 0.25));
274 
275  const Real effective_perm = std::sqrt(det2D);
276 
277  const Real halfPi = acos(0.0);
278 
279  if (r0 <= rad)
280  mooseError("The effective element size (about 0.2-times-true-ele-size) for an element "
281  "containing a Peaceman-type borehole must be (much) larger than the borehole radius "
282  "for the Peaceman formulation to be correct. Your element has effective size ",
283  r0,
284  " and the borehole radius is ",
285  rad,
286  "\n");
287 
288  return 4 * halfPi * effective_perm * half_len / std::log(r0 / rad);
289 }
const Real _well_constant
well constant
const Real _re_constant
borehole constant
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)

Member Data Documentation

◆ _bottom_point

Point PeacemanBorehole::_bottom_point
protectedinherited

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

Definition at line 95 of file PeacemanBorehole.h.

Referenced by computeQpResidual(), RichardsBorehole::computeQpResidual(), jac(), RichardsBorehole::jac(), and PeacemanBorehole::PeacemanBorehole().

◆ _character

Function& PeacemanBorehole::_character
protectedinherited

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

Referenced by RichardsBorehole::computeQpJacobian(), computeQpResidual(), RichardsBorehole::computeQpResidual(), jac(), and RichardsBorehole::jac().

◆ _density

const RichardsDensity& Q2PBorehole::_density
protected

fluid density

Definition at line 72 of file Q2PBorehole.h.

Referenced by prepareNodalValues().

◆ _dmobility_dp

std::vector<Real> Q2PBorehole::_dmobility_dp
protected

nodal d(mobility)/d(porepressure)

Definition at line 105 of file Q2PBorehole.h.

Referenced by jac(), and prepareNodalValues().

◆ _dmobility_ds

std::vector<Real> Q2PBorehole::_dmobility_ds
protected

nodal d(mobility)/d(saturation)

Definition at line 108 of file Q2PBorehole.h.

Referenced by jac(), and prepareNodalValues().

◆ _half_seg_len

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

0.5*(length of polyline segments between points)

Definition at line 98 of file PeacemanBorehole.h.

Referenced by computeQpResidual(), RichardsBorehole::computeQpResidual(), jac(), RichardsBorehole::jac(), and PeacemanBorehole::PeacemanBorehole().

◆ _mobility

std::vector<Real> Q2PBorehole::_mobility
protected

nodal mobility

Definition at line 102 of file Q2PBorehole.h.

Referenced by computeQpResidual(), jac(), and prepareNodalValues().

◆ _num_nodes

unsigned int Q2PBorehole::_num_nodes
protected

number of nodes in this element.

Definition at line 93 of file Q2PBorehole.h.

Referenced by prepareNodalValues().

◆ _other_var_nodal

const VariableValue& Q2PBorehole::_other_var_nodal
protected

the other variable in the 2-phase system (this is saturation if Variable=porepressure, and viceversa)

Definition at line 78 of file Q2PBorehole.h.

Referenced by prepareNodalValues().

◆ _other_var_num

const unsigned int Q2PBorehole::_other_var_num
protected

the variable number of the other variable

Definition at line 81 of file Q2PBorehole.h.

Referenced by computeQpOffDiagJacobian(), and jac().

◆ _p_bot

const Real PeacemanBorehole::_p_bot
protectedinherited

bottomhole pressure of borehole

Definition at line 70 of file PeacemanBorehole.h.

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

◆ _permeability

const MaterialProperty<RealTensorValue>& Q2PBorehole::_permeability
protected

permeability

Definition at line 90 of file Q2PBorehole.h.

Referenced by computeQpResidual(), and jac().

◆ _pp

std::vector<Real> Q2PBorehole::_pp
protected

nodal porepressure

Definition at line 96 of file Q2PBorehole.h.

Referenced by computeQpResidual(), jac(), and prepareNodalValues().

◆ _relperm

const RichardsRelPerm& Q2PBorehole::_relperm
protected

fluid relative permeability

Definition at line 75 of file Q2PBorehole.h.

Referenced by prepareNodalValues().

◆ _rot_matrix

std::vector<RealTensorValue> PeacemanBorehole::_rot_matrix
protectedinherited

rotation matrix used in well_constant calculation

Definition at line 101 of file PeacemanBorehole.h.

Referenced by computeQpResidual(), RichardsBorehole::computeQpResidual(), jac(), RichardsBorehole::jac(), and PeacemanBorehole::PeacemanBorehole().

◆ _rs

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

◆ _sat

std::vector<Real> Q2PBorehole::_sat
protected

nodal saturation

Definition at line 99 of file Q2PBorehole.h.

Referenced by prepareNodalValues().

◆ _total_outflow_mass

RichardsSumQuantity& PeacemanBorehole::_total_outflow_mass
protectedinherited

This is used to hold the total fluid flowing into the borehole Hence, it is positive for production wells where fluid is flowing from porespace into the borehole and removed from the model.

Definition at line 80 of file PeacemanBorehole.h.

Referenced by PeacemanBorehole::addPoints(), computeQpResidual(), RichardsBorehole::computeQpResidual(), and PeacemanBorehole::PeacemanBorehole().

◆ _unit_weight

const RealVectorValue PeacemanBorehole::_unit_weight
protectedinherited

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

Definition at line 73 of file PeacemanBorehole.h.

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

◆ _var_is_pp

const bool Q2PBorehole::_var_is_pp
protected

whether the Variable for this BC is porepressure or not

Definition at line 84 of file Q2PBorehole.h.

Referenced by jac(), and prepareNodalValues().

◆ _viscosity

const Real Q2PBorehole::_viscosity
protected

viscosity

Definition at line 87 of file Q2PBorehole.h.

Referenced by prepareNodalValues().

◆ _xs

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

x points of the borehole

Definition at line 86 of file PeacemanBorehole.h.

Referenced by PeacemanBorehole::addPoints(), and PeacemanBorehole::PeacemanBorehole().

◆ _ys

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

y points of the borehole

Definition at line 89 of file PeacemanBorehole.h.

Referenced by PeacemanBorehole::addPoints(), and PeacemanBorehole::PeacemanBorehole().

◆ _zs

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

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