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 () override
 
virtual Real computeQpResidual () override
 
virtual void computeJacobian () override
 
virtual Real computeQpJacobian () override
 
virtual void computeJacobianBlock (MooseVariableFEBase &jvar) override
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar) override
 
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 37 of file Q2PPiecewiseLinearSink.h.

Constructor & Destructor Documentation

◆ Q2PPiecewiseLinearSink()

Q2PPiecewiseLinearSink::Q2PPiecewiseLinearSink ( const InputParameters &  parameters)

Definition at line 75 of file Q2PPiecewiseLinearSink.C.

76  : IntegratedBC(parameters),
77  _use_mobility(getParam<bool>("use_mobility")),
78  _use_relperm(getParam<bool>("use_relperm")),
79  _sink_func(getParam<std::vector<Real>>("pressures"),
80  getParam<std::vector<Real>>("bare_fluxes")),
81  _m_func(getFunction("multiplying_fcn")),
82  _density(getUserObject<RichardsDensity>("fluid_density")),
83  _relperm(getUserObject<RichardsRelPerm>("fluid_relperm")),
84  _other_var_nodal(coupledNodalValue("other_var")),
85  _other_var_num(coupled("other_var")),
86  _var_is_pp(getParam<bool>("var_is_porepressure")),
87  _viscosity(getParam<Real>("fluid_viscosity")),
88  _permeability(getMaterialProperty<RealTensorValue>("permeability")),
89  _num_nodes(0),
90  _pp(0),
91  _sat(0),
92  _nodal_density(0),
94  _nodal_relperm(0),
96 {
97 }
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

◆ computeJacobian()

void Q2PPiecewiseLinearSink::computeJacobian ( )
overrideprotectedvirtual

Definition at line 178 of file Q2PPiecewiseLinearSink.C.

179 {
181  IntegratedBC::computeJacobian();
182 }
void prepareNodalValues()
calculates the nodal values of pressure, mobility, and derivatives thereof

◆ computeJacobianBlock()

void Q2PPiecewiseLinearSink::computeJacobianBlock ( MooseVariableFEBase &  jvar)
overrideprotectedvirtual

Definition at line 191 of file Q2PPiecewiseLinearSink.C.

192 {
194  IntegratedBC::computeJacobianBlock(jvar);
195 }
void prepareNodalValues()
calculates the nodal values of pressure, mobility, and derivatives thereof

◆ computeQpJacobian()

Real Q2PPiecewiseLinearSink::computeQpJacobian ( )
overrideprotectedvirtual

Definition at line 185 of file Q2PPiecewiseLinearSink.C.

186 {
187  return jac(_var.number());
188 }
Real jac(unsigned int wrt_num)
derivative of residual wrt the wrt_num variable

◆ computeQpOffDiagJacobian()

Real Q2PPiecewiseLinearSink::computeQpOffDiagJacobian ( unsigned int  jvar)
overrideprotectedvirtual

Definition at line 198 of file Q2PPiecewiseLinearSink.C.

199 {
200  if (jvar == _var.number() || jvar == _other_var_num)
201  return jac(jvar);
202 
203  return 0.0;
204 }
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

◆ computeQpResidual()

Real Q2PPiecewiseLinearSink::computeQpResidual ( )
overrideprotectedvirtual

Definition at line 156 of file Q2PPiecewiseLinearSink.C.

157 {
158  Real flux = 0;
159  Real k = 0;
160 
161  flux = _test[_i][_qp] * _sink_func.sample(_pp[_i]);
162  if (_use_mobility)
163  {
164  k = (_permeability[0] * _normals[_qp]) * _normals[_qp]; // assume that _permeability is constant
165  // throughout element so doesn't need to
166  // be upwinded
167  flux *= _nodal_density[_i] * k / _viscosity;
168  }
169  if (_use_relperm)
170  flux *= _nodal_relperm[_i];
171 
172  flux *= _m_func.value(_t, _q_point[_qp]);
173 
174  return flux;
175 }
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

◆ computeResidual()

void Q2PPiecewiseLinearSink::computeResidual ( )
overrideprotectedvirtual

Definition at line 149 of file Q2PPiecewiseLinearSink.C.

150 {
152  IntegratedBC::computeResidual();
153 }
void prepareNodalValues()
calculates the nodal values of pressure, mobility, and derivatives thereof

◆ jac()

Real Q2PPiecewiseLinearSink::jac ( unsigned int  wrt_num)
protected

derivative of residual wrt the wrt_num variable

Definition at line 207 of file Q2PPiecewiseLinearSink.C.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

208 {
209  Real flux = 0;
210  Real deriv = 0;
211  Real k = 0;
212  Real mob = 0;
213  Real mobp = 0;
214  Real phi = 1;
215 
216  if (_i != _j)
217  return 0.0; // residual at node _i only depends on variables at that node
218 
219  flux = _sink_func.sample(_pp[_i]);
220 
221  if (_var_is_pp)
222  {
223  // derivative of the _sink_func
224  if (wrt_num == _var.number())
225  deriv = _sink_func.sampleDerivative(_pp[_i]);
226  else
227  deriv = 0;
228 
229  // add derivative of the mobility
230  if (_use_mobility)
231  {
232  k = (_permeability[0] * _normals[_qp]) * _normals[_qp];
233  mob = _nodal_density[_i] * k / _viscosity;
234  if (wrt_num == _var.number())
235  mobp = _dnodal_density_dp[_i] * k / _viscosity; // else mobp = 0
236  deriv = mob * deriv + mobp * flux;
237  flux *= mob;
238  }
239 
240  // add derivative of the relperm
241  if (_use_relperm)
242  {
243  if (wrt_num == _other_var_num)
244  deriv = _nodal_relperm[_i] * deriv + _dnodal_relperm_ds[_i] * flux;
245  else
246  deriv = _nodal_relperm[_i] * deriv;
247  }
248  }
249  else
250  {
251  // derivative of the _sink_func
252  if (wrt_num == _other_var_num)
253  deriv = _sink_func.sampleDerivative(_pp[_i]);
254  else
255  deriv = 0;
256 
257  // add derivative of the mobility
258  if (_use_mobility)
259  {
260  k = (_permeability[0] * _normals[_qp]) * _normals[_qp];
261  mob = _nodal_density[_i] * k / _viscosity;
262  if (wrt_num == _other_var_num)
263  mobp = _dnodal_density_dp[_i] * k / _viscosity; // else mobp = 0
264  deriv = mob * deriv + mobp * flux;
265  flux *= mob;
266  }
267 
268  // add derivative of the relperm
269  if (_use_relperm)
270  {
271  if (wrt_num == _var.number())
272  deriv = _nodal_relperm[_i] * deriv + _dnodal_relperm_ds[_i] * flux;
273  else
274  deriv = _nodal_relperm[_i] * deriv;
275  }
276  }
277 
278  deriv *= _m_func.value(_t, _q_point[_qp]);
279 
280  return _test[_i][_qp] * deriv * phi;
281 }
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

◆ prepareNodalValues()

void Q2PPiecewiseLinearSink::prepareNodalValues ( )
protected

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

Definition at line 100 of file Q2PPiecewiseLinearSink.C.

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

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

◆ _density

const RichardsDensity& Q2PPiecewiseLinearSink::_density
protected

fluid density

Definition at line 69 of file Q2PPiecewiseLinearSink.h.

Referenced by prepareNodalValues().

◆ _dnodal_density_dp

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

d(_nodal_density)/d(porepressure)

Definition at line 102 of file Q2PPiecewiseLinearSink.h.

Referenced by jac(), and prepareNodalValues().

◆ _dnodal_relperm_ds

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

d(_nodal_relperm)/d(saturation)

Definition at line 108 of file Q2PPiecewiseLinearSink.h.

Referenced by jac(), and prepareNodalValues().

◆ _m_func

Function& Q2PPiecewiseLinearSink::_m_func
protected

sink flux gets multiplied by this function

Definition at line 66 of file Q2PPiecewiseLinearSink.h.

Referenced by computeQpResidual(), and jac().

◆ _nodal_density

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

nodal values of fluid density

Definition at line 99 of file Q2PPiecewiseLinearSink.h.

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

◆ _nodal_relperm

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

nodal values of relative permeability

Definition at line 105 of file Q2PPiecewiseLinearSink.h.

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

◆ _num_nodes

unsigned int Q2PPiecewiseLinearSink::_num_nodes
protected

number of nodes in this element.

Definition at line 90 of file Q2PPiecewiseLinearSink.h.

Referenced by prepareNodalValues().

◆ _other_var_nodal

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 75 of file Q2PPiecewiseLinearSink.h.

Referenced by prepareNodalValues().

◆ _other_var_num

unsigned int Q2PPiecewiseLinearSink::_other_var_num
protected

the variable number of the other variable

Definition at line 78 of file Q2PPiecewiseLinearSink.h.

Referenced by computeQpOffDiagJacobian(), and jac().

◆ _permeability

const MaterialProperty<RealTensorValue>& Q2PPiecewiseLinearSink::_permeability
protected

permeability

Definition at line 87 of file Q2PPiecewiseLinearSink.h.

Referenced by computeQpResidual(), and jac().

◆ _pp

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

nodal values of porepressure

Definition at line 93 of file Q2PPiecewiseLinearSink.h.

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

◆ _relperm

const RichardsRelPerm& Q2PPiecewiseLinearSink::_relperm
protected

fluid relative permeability

Definition at line 72 of file Q2PPiecewiseLinearSink.h.

Referenced by prepareNodalValues().

◆ _sat

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

nodal values of saturation

Definition at line 96 of file Q2PPiecewiseLinearSink.h.

Referenced by prepareNodalValues().

◆ _sink_func

LinearInterpolation Q2PPiecewiseLinearSink::_sink_func
protected

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

Definition at line 63 of file Q2PPiecewiseLinearSink.h.

Referenced by computeQpResidual(), and jac().

◆ _use_mobility

bool Q2PPiecewiseLinearSink::_use_mobility
protected

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

Definition at line 57 of file Q2PPiecewiseLinearSink.h.

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

◆ _use_relperm

bool Q2PPiecewiseLinearSink::_use_relperm
protected

whether to multiply the sink flux by relative permeability

Definition at line 60 of file Q2PPiecewiseLinearSink.h.

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

◆ _var_is_pp

bool Q2PPiecewiseLinearSink::_var_is_pp
protected

whether the Variable for this BC is porepressure or not

Definition at line 81 of file Q2PPiecewiseLinearSink.h.

Referenced by jac(), and prepareNodalValues().

◆ _viscosity

Real Q2PPiecewiseLinearSink::_viscosity
protected

viscosity

Definition at line 84 of file Q2PPiecewiseLinearSink.h.

Referenced by computeQpResidual(), and jac().


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