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

Applies a fully-upwinded flux sink to a boundary The sink is a piecewise linear function of porepressure at the quad points. More...

#include <Q2PPiecewiseLinearSink.h>

Inheritance diagram for Q2PPiecewiseLinearSink:
[legend]

Public Member Functions

 Q2PPiecewiseLinearSink (const InputParameters &parameters)
 

Protected Member Functions

virtual void computeResidual ()
 
virtual Real computeQpResidual ()
 
virtual void computeJacobian ()
 
virtual Real computeQpJacobian ()
 
virtual void computeJacobianBlock (unsigned int jvar)
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar)
 
void prepareNodalValues ()
 calculates the nodal values of pressure, mobility, and derivatives thereof More...
 
Real jac (unsigned int wrt_num)
 derivative of residual wrt the wrt_num variable More...
 

Protected Attributes

bool _use_mobility
 whether to multiply the sink flux by permeability*density/viscosity More...
 
bool _use_relperm
 whether to multiply the sink flux by relative permeability More...
 
LinearInterpolation _sink_func
 piecewise-linear function of porepressure (this defines the strength of the sink) More...
 
Function & _m_func
 sink flux gets multiplied by this function More...
 
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...
 
unsigned int _other_var_num
 the variable number of the other variable More...
 
bool _var_is_pp
 whether the Variable for this BC is porepressure or not More...
 
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 values of porepressure More...
 
std::vector< Real > _sat
 nodal values of saturation More...
 
std::vector< Real > _nodal_density
 nodal values of fluid density More...
 
std::vector< Real > _dnodal_density_dp
 d(_nodal_density)/d(porepressure) More...
 
std::vector< Real > _nodal_relperm
 nodal values of relative permeability More...
 
std::vector< Real > _dnodal_relperm_ds
 d(_nodal_relperm)/d(saturation) More...
 

Detailed Description

Applies a fully-upwinded flux sink to a boundary The sink is a piecewise linear function of porepressure at the quad points.

This is specified by _sink_func. In addition, this sink can be multiplied by: (1) the relative permeability of the fluid at the quad point. (2) perm_nn*density/viscosity, where perm_nn is the permeability tensor projected in the normal direction. (3) a Function (which can be time-dependent, for instance) This is for use in Q2P models

Definition at line 35 of file Q2PPiecewiseLinearSink.h.

Constructor & Destructor Documentation

Q2PPiecewiseLinearSink::Q2PPiecewiseLinearSink ( const InputParameters &  parameters)

Definition at line 71 of file Q2PPiecewiseLinearSink.C.

72  : IntegratedBC(parameters),
73  _use_mobility(getParam<bool>("use_mobility")),
74  _use_relperm(getParam<bool>("use_relperm")),
75  _sink_func(getParam<std::vector<Real>>("pressures"),
76  getParam<std::vector<Real>>("bare_fluxes")),
77  _m_func(getFunction("multiplying_fcn")),
78  _density(getUserObject<RichardsDensity>("fluid_density")),
79  _relperm(getUserObject<RichardsRelPerm>("fluid_relperm")),
80  _other_var_nodal(coupledNodalValue("other_var")),
81  _other_var_num(coupled("other_var")),
82  _var_is_pp(getParam<bool>("var_is_porepressure")),
83  _viscosity(getParam<Real>("fluid_viscosity")),
84  _permeability(getMaterialProperty<RealTensorValue>("permeability")),
85  _num_nodes(0),
86  _pp(0),
87  _sat(0),
88  _nodal_density(0),
90  _nodal_relperm(0),
92 {
93 }
Function & _m_func
sink flux gets multiplied by this function
std::vector< Real > _nodal_density
nodal values of fluid density
LinearInterpolation _sink_func
piecewise-linear function of porepressure (this defines the strength of the sink) ...
bool _use_mobility
whether to multiply the sink flux by permeability*density/viscosity
unsigned int _other_var_num
the variable number of the other variable
bool _var_is_pp
whether the Variable for this BC is porepressure or not
std::vector< Real > _dnodal_density_dp
d(_nodal_density)/d(porepressure)
std::vector< Real > _pp
nodal values of porepressure
const RichardsRelPerm & _relperm
fluid relative permeability
const MaterialProperty< RealTensorValue > & _permeability
permeability
bool _use_relperm
whether to multiply the sink flux by relative permeability
std::vector< Real > _dnodal_relperm_ds
d(_nodal_relperm)/d(saturation)
unsigned int _num_nodes
number of nodes in this element.
std::vector< Real > _nodal_relperm
nodal values of relative permeability
std::vector< Real > _sat
nodal values of saturation
const RichardsDensity & _density
fluid density
const VariableValue & _other_var_nodal
the other variable in the 2-phase system (this is saturation if Variable=porepressure, and viceversa)

Member Function Documentation

void Q2PPiecewiseLinearSink::computeJacobian ( )
protectedvirtual

Definition at line 174 of file Q2PPiecewiseLinearSink.C.

175 {
177  IntegratedBC::computeJacobian();
178 }
void prepareNodalValues()
calculates the nodal values of pressure, mobility, and derivatives thereof
void Q2PPiecewiseLinearSink::computeJacobianBlock ( unsigned int  jvar)
protectedvirtual

Definition at line 187 of file Q2PPiecewiseLinearSink.C.

188 {
190  IntegratedBC::computeJacobianBlock(jvar);
191 }
void prepareNodalValues()
calculates the nodal values of pressure, mobility, and derivatives thereof
Real Q2PPiecewiseLinearSink::computeQpJacobian ( )
protectedvirtual

Definition at line 181 of file Q2PPiecewiseLinearSink.C.

182 {
183  return jac(_var.number());
184 }
Real jac(unsigned int wrt_num)
derivative of residual wrt the wrt_num variable
Real Q2PPiecewiseLinearSink::computeQpOffDiagJacobian ( unsigned int  jvar)
protectedvirtual

Definition at line 194 of file Q2PPiecewiseLinearSink.C.

195 {
196  if (jvar == _var.number() || jvar == _other_var_num)
197  return jac(jvar);
198 
199  return 0.0;
200 }
Real jac(unsigned int wrt_num)
derivative of residual wrt the wrt_num variable
unsigned int _other_var_num
the variable number of the other variable
Real Q2PPiecewiseLinearSink::computeQpResidual ( )
protectedvirtual

Definition at line 152 of file Q2PPiecewiseLinearSink.C.

153 {
154  Real flux = 0;
155  Real k = 0;
156 
157  flux = _test[_i][_qp] * _sink_func.sample(_pp[_i]);
158  if (_use_mobility)
159  {
160  k = (_permeability[0] * _normals[_qp]) * _normals[_qp]; // assume that _permeability is constant
161  // throughout element so doesn't need to
162  // be upwinded
163  flux *= _nodal_density[_i] * k / _viscosity;
164  }
165  if (_use_relperm)
166  flux *= _nodal_relperm[_i];
167 
168  flux *= _m_func.value(_t, _q_point[_qp]);
169 
170  return flux;
171 }
Function & _m_func
sink flux gets multiplied by this function
std::vector< Real > _nodal_density
nodal values of fluid density
LinearInterpolation _sink_func
piecewise-linear function of porepressure (this defines the strength of the sink) ...
bool _use_mobility
whether to multiply the sink flux by permeability*density/viscosity
std::vector< Real > _pp
nodal values of porepressure
const MaterialProperty< RealTensorValue > & _permeability
permeability
bool _use_relperm
whether to multiply the sink flux by relative permeability
std::vector< Real > _nodal_relperm
nodal values of relative permeability
void Q2PPiecewiseLinearSink::computeResidual ( )
protectedvirtual

Definition at line 145 of file Q2PPiecewiseLinearSink.C.

146 {
148  IntegratedBC::computeResidual();
149 }
void prepareNodalValues()
calculates the nodal values of pressure, mobility, and derivatives thereof
Real Q2PPiecewiseLinearSink::jac ( unsigned int  wrt_num)
protected

derivative of residual wrt the wrt_num variable

Definition at line 203 of file Q2PPiecewiseLinearSink.C.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

204 {
205  Real flux = 0;
206  Real deriv = 0;
207  Real k = 0;
208  Real mob = 0;
209  Real mobp = 0;
210  Real phi = 1;
211 
212  if (_i != _j)
213  return 0.0; // residual at node _i only depends on variables at that node
214 
215  flux = _sink_func.sample(_pp[_i]);
216 
217  if (_var_is_pp)
218  {
219  // derivative of the _sink_func
220  if (wrt_num == _var.number())
221  deriv = _sink_func.sampleDerivative(_pp[_i]);
222  else
223  deriv = 0;
224 
225  // add derivative of the mobility
226  if (_use_mobility)
227  {
228  k = (_permeability[0] * _normals[_qp]) * _normals[_qp];
229  mob = _nodal_density[_i] * k / _viscosity;
230  if (wrt_num == _var.number())
231  mobp = _dnodal_density_dp[_i] * k / _viscosity; // else mobp = 0
232  deriv = mob * deriv + mobp * flux;
233  flux *= mob;
234  }
235 
236  // add derivative of the relperm
237  if (_use_relperm)
238  {
239  if (wrt_num == _other_var_num)
240  deriv = _nodal_relperm[_i] * deriv + _dnodal_relperm_ds[_i] * flux;
241  else
242  deriv = _nodal_relperm[_i] * deriv;
243  }
244  }
245  else
246  {
247  // derivative of the _sink_func
248  if (wrt_num == _other_var_num)
249  deriv = _sink_func.sampleDerivative(_pp[_i]);
250  else
251  deriv = 0;
252 
253  // add derivative of the mobility
254  if (_use_mobility)
255  {
256  k = (_permeability[0] * _normals[_qp]) * _normals[_qp];
257  mob = _nodal_density[_i] * k / _viscosity;
258  if (wrt_num == _other_var_num)
259  mobp = _dnodal_density_dp[_i] * k / _viscosity; // else mobp = 0
260  deriv = mob * deriv + mobp * flux;
261  flux *= mob;
262  }
263 
264  // add derivative of the relperm
265  if (_use_relperm)
266  {
267  if (wrt_num == _var.number())
268  deriv = _nodal_relperm[_i] * deriv + _dnodal_relperm_ds[_i] * flux;
269  else
270  deriv = _nodal_relperm[_i] * deriv;
271  }
272  }
273 
274  deriv *= _m_func.value(_t, _q_point[_qp]);
275 
276  return _test[_i][_qp] * deriv * phi;
277 }
Function & _m_func
sink flux gets multiplied by this function
std::vector< Real > _nodal_density
nodal values of fluid density
LinearInterpolation _sink_func
piecewise-linear function of porepressure (this defines the strength of the sink) ...
bool _use_mobility
whether to multiply the sink flux by permeability*density/viscosity
unsigned int _other_var_num
the variable number of the other variable
bool _var_is_pp
whether the Variable for this BC is porepressure or not
std::vector< Real > _dnodal_density_dp
d(_nodal_density)/d(porepressure)
std::vector< Real > _pp
nodal values of porepressure
const MaterialProperty< RealTensorValue > & _permeability
permeability
bool _use_relperm
whether to multiply the sink flux by relative permeability
std::vector< Real > _dnodal_relperm_ds
d(_nodal_relperm)/d(saturation)
std::vector< Real > _nodal_relperm
nodal values of relative permeability
void Q2PPiecewiseLinearSink::prepareNodalValues ( )
protected

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

Definition at line 96 of file Q2PPiecewiseLinearSink.C.

Referenced by computeJacobian(), computeJacobianBlock(), and computeResidual().

97 {
99 
100  // set _pp and _sat variables
101  _pp.resize(_num_nodes);
102  _sat.resize(_num_nodes);
103  if (_var_is_pp)
104  {
105  for (unsigned int nodenum = 0; nodenum < _num_nodes; ++nodenum)
106  {
107  _pp[nodenum] = _var.nodalSln()[nodenum];
108  _sat[nodenum] = _other_var_nodal[nodenum];
109  }
110  }
111  else
112  {
113  for (unsigned int nodenum = 0; nodenum < _num_nodes; ++nodenum)
114  {
115  _pp[nodenum] = _other_var_nodal[nodenum];
116  _sat[nodenum] = _var.nodalSln()[nodenum];
117  }
118  }
119 
120  // calculate derived things
121  if (_use_mobility)
122  {
123  _nodal_density.resize(_num_nodes);
124  _dnodal_density_dp.resize(_num_nodes);
125  for (unsigned int nodenum = 0; nodenum < _num_nodes; ++nodenum)
126  {
127  _nodal_density[nodenum] = _density.density(_pp[nodenum]);
128  _dnodal_density_dp[nodenum] = _density.ddensity(_pp[nodenum]);
129  }
130  }
131 
132  if (_use_relperm)
133  {
134  _nodal_relperm.resize(_num_nodes);
135  _dnodal_relperm_ds.resize(_num_nodes);
136  for (unsigned int nodenum = 0; nodenum < _num_nodes; ++nodenum)
137  {
138  _nodal_relperm[nodenum] = _relperm.relperm(_sat[nodenum]);
139  _dnodal_relperm_ds[nodenum] = _relperm.drelperm(_sat[nodenum]);
140  }
141  }
142 }
std::vector< Real > _nodal_density
nodal values of fluid density
virtual Real drelperm(Real seff) const =0
derivative of relative permeability wrt effective saturation This must be over-ridden in your derived...
bool _use_mobility
whether to multiply the sink flux by permeability*density/viscosity
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...
bool _var_is_pp
whether the Variable for this BC is porepressure or not
std::vector< Real > _dnodal_density_dp
d(_nodal_density)/d(porepressure)
std::vector< Real > _pp
nodal values of porepressure
const RichardsRelPerm & _relperm
fluid relative permeability
virtual Real ddensity(Real p) const =0
derivative of fluid density wrt porepressure This must be over-ridden in derived classes to provide a...
virtual Real relperm(Real seff) const =0
relative permeability as a function of effective saturation This must be over-ridden in your derived ...
bool _use_relperm
whether to multiply the sink flux by relative permeability
std::vector< Real > _dnodal_relperm_ds
d(_nodal_relperm)/d(saturation)
unsigned int _num_nodes
number of nodes in this element.
std::vector< Real > _nodal_relperm
nodal values of relative permeability
std::vector< Real > _sat
nodal values of saturation
const RichardsDensity & _density
fluid density
const VariableValue & _other_var_nodal
the other variable in the 2-phase system (this is saturation if Variable=porepressure, and viceversa)

Member Data Documentation

const RichardsDensity& Q2PPiecewiseLinearSink::_density
protected

fluid density

Definition at line 66 of file Q2PPiecewiseLinearSink.h.

Referenced by prepareNodalValues().

std::vector<Real> Q2PPiecewiseLinearSink::_dnodal_density_dp
protected

d(_nodal_density)/d(porepressure)

Definition at line 99 of file Q2PPiecewiseLinearSink.h.

Referenced by jac(), and prepareNodalValues().

std::vector<Real> Q2PPiecewiseLinearSink::_dnodal_relperm_ds
protected

d(_nodal_relperm)/d(saturation)

Definition at line 105 of file Q2PPiecewiseLinearSink.h.

Referenced by jac(), and prepareNodalValues().

Function& Q2PPiecewiseLinearSink::_m_func
protected

sink flux gets multiplied by this function

Definition at line 63 of file Q2PPiecewiseLinearSink.h.

Referenced by computeQpResidual(), and jac().

std::vector<Real> Q2PPiecewiseLinearSink::_nodal_density
protected

nodal values of fluid density

Definition at line 96 of file Q2PPiecewiseLinearSink.h.

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

std::vector<Real> Q2PPiecewiseLinearSink::_nodal_relperm
protected

nodal values of relative permeability

Definition at line 102 of file Q2PPiecewiseLinearSink.h.

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

unsigned int Q2PPiecewiseLinearSink::_num_nodes
protected

number of nodes in this element.

Definition at line 87 of file Q2PPiecewiseLinearSink.h.

Referenced by prepareNodalValues().

const VariableValue& Q2PPiecewiseLinearSink::_other_var_nodal
protected

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

Definition at line 72 of file Q2PPiecewiseLinearSink.h.

Referenced by prepareNodalValues().

unsigned int Q2PPiecewiseLinearSink::_other_var_num
protected

the variable number of the other variable

Definition at line 75 of file Q2PPiecewiseLinearSink.h.

Referenced by computeQpOffDiagJacobian(), and jac().

const MaterialProperty<RealTensorValue>& Q2PPiecewiseLinearSink::_permeability
protected

permeability

Definition at line 84 of file Q2PPiecewiseLinearSink.h.

Referenced by computeQpResidual(), and jac().

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

nodal values of porepressure

Definition at line 90 of file Q2PPiecewiseLinearSink.h.

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

const RichardsRelPerm& Q2PPiecewiseLinearSink::_relperm
protected

fluid relative permeability

Definition at line 69 of file Q2PPiecewiseLinearSink.h.

Referenced by prepareNodalValues().

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

nodal values of saturation

Definition at line 93 of file Q2PPiecewiseLinearSink.h.

Referenced by prepareNodalValues().

LinearInterpolation Q2PPiecewiseLinearSink::_sink_func
protected

piecewise-linear function of porepressure (this defines the strength of the sink)

Definition at line 60 of file Q2PPiecewiseLinearSink.h.

Referenced by computeQpResidual(), and jac().

bool Q2PPiecewiseLinearSink::_use_mobility
protected

whether to multiply the sink flux by permeability*density/viscosity

Definition at line 54 of file Q2PPiecewiseLinearSink.h.

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

bool Q2PPiecewiseLinearSink::_use_relperm
protected

whether to multiply the sink flux by relative permeability

Definition at line 57 of file Q2PPiecewiseLinearSink.h.

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

bool Q2PPiecewiseLinearSink::_var_is_pp
protected

whether the Variable for this BC is porepressure or not

Definition at line 78 of file Q2PPiecewiseLinearSink.h.

Referenced by jac(), and prepareNodalValues().

Real Q2PPiecewiseLinearSink::_viscosity
protected

viscosity

Definition at line 81 of file Q2PPiecewiseLinearSink.h.

Referenced by computeQpResidual(), and jac().


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