LCOV - code coverage report
Current view: top level - src/kernels - PorousFlowFullySaturatedDarcyBase.C (source / functions) Hit Total Coverage
Test: porous_flow Test Coverage Lines: 61 62 98.4 %
Date: 2017-11-20 12:14:45 Functions: 9 9 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /****************************************************************/
       2             : /* MOOSE - Multiphysics Object Oriented Simulation Environment  */
       3             : /*                                                              */
       4             : /*          All contents are licensed under LGPL V2.1           */
       5             : /*             See LICENSE for full restrictions                */
       6             : /****************************************************************/
       7             : 
       8             : #include "PorousFlowFullySaturatedDarcyBase.h"
       9             : 
      10             : // MOOSE includes
      11             : #include "MooseVariable.h"
      12             : 
      13             : template <>
      14             : InputParameters
      15          34 : validParams<PorousFlowFullySaturatedDarcyBase>()
      16             : {
      17          34 :   InputParameters params = validParams<Kernel>();
      18         102 :   params.addRequiredParam<RealVectorValue>("gravity",
      19          34 :                                            "Gravitational acceleration vector downwards (m/s^2)");
      20         102 :   params.addParam<bool>("multiply_by_density",
      21             :                         true,
      22             :                         "If true, then this Kernel is the fluid mass "
      23             :                         "flux.  If false, then this Kernel is the "
      24             :                         "fluid volume flux (which is common in "
      25          34 :                         "poro-mechanics)");
      26         102 :   params.addRequiredParam<UserObjectName>(
      27          34 :       "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names");
      28          68 :   params.addClassDescription("Darcy flux suitable for models involving a fully-saturated, single "
      29          34 :                              "phase, single component fluid.  No upwinding is used");
      30          34 :   return params;
      31             : }
      32             : 
      33          35 : PorousFlowFullySaturatedDarcyBase::PorousFlowFullySaturatedDarcyBase(
      34          35 :     const InputParameters & parameters)
      35             :   : Kernel(parameters),
      36         105 :     _multiply_by_density(getParam<bool>("multiply_by_density")),
      37          70 :     _permeability(getMaterialProperty<RealTensorValue>("PorousFlow_permeability_qp")),
      38             :     _dpermeability_dvar(
      39          70 :         getMaterialProperty<std::vector<RealTensorValue>>("dPorousFlow_permeability_qp_dvar")),
      40             :     _dpermeability_dgradvar(getMaterialProperty<std::vector<std::vector<RealTensorValue>>>(
      41          70 :         "dPorousFlow_permeability_qp_dgradvar")),
      42          70 :     _density(getMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_qp")),
      43             :     _ddensity_dvar(getMaterialProperty<std::vector<std::vector<Real>>>(
      44          70 :         "dPorousFlow_fluid_phase_density_qp_dvar")),
      45          70 :     _viscosity(getMaterialProperty<std::vector<Real>>("PorousFlow_viscosity_qp")),
      46             :     _dviscosity_dvar(
      47          70 :         getMaterialProperty<std::vector<std::vector<Real>>>("dPorousFlow_viscosity_qp_dvar")),
      48          70 :     _pp(getMaterialProperty<std::vector<Real>>("PorousFlow_porepressure_qp")),
      49          70 :     _grad_p(getMaterialProperty<std::vector<RealGradient>>("PorousFlow_grad_porepressure_qp")),
      50             :     _dgrad_p_dgrad_var(getMaterialProperty<std::vector<std::vector<Real>>>(
      51          70 :         "dPorousFlow_grad_porepressure_qp_dgradvar")),
      52             :     _dgrad_p_dvar(getMaterialProperty<std::vector<std::vector<RealGradient>>>(
      53          70 :         "dPorousFlow_grad_porepressure_qp_dvar")),
      54          70 :     _porousflow_dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
      55         595 :     _gravity(getParam<RealVectorValue>("gravity"))
      56             : {
      57          35 :   if (_porousflow_dictator.numPhases() != 1)
      58             :     mooseError("PorousFlowFullySaturatedDarcyBase should not be used for multi-phase scenarios as "
      59           0 :                "it does no upwinding and does not include relative-permeability effects");
      60          35 : }
      61             : 
      62             : Real
      63     2119608 : PorousFlowFullySaturatedDarcyBase::computeQpResidual()
      64             : {
      65             :   const unsigned ph = 0;
      66     2119608 :   const Real mob = mobility();
      67             :   const RealVectorValue flow =
      68    10598040 :       _permeability[_qp] * (_grad_p[_qp][ph] - _density[_qp][ph] * _gravity);
      69     4239216 :   return _grad_test[_i][_qp] * mob * flow;
      70             : }
      71             : 
      72             : Real
      73     6376672 : PorousFlowFullySaturatedDarcyBase::computeQpJacobian()
      74             : {
      75     6376672 :   return computeQpOffDiagJacobian(_var.number());
      76             : }
      77             : 
      78             : Real
      79    27648768 : PorousFlowFullySaturatedDarcyBase::computeQpOffDiagJacobian(unsigned int jvar)
      80             : {
      81    27648768 :   if (_porousflow_dictator.notPorousFlowVariable(jvar))
      82             :     return 0.0;
      83             : 
      84             :   const unsigned ph = 0;
      85    27648768 :   const unsigned pvar = _porousflow_dictator.porousFlowVariableNum(jvar);
      86             : 
      87    27648768 :   const Real mob = mobility();
      88    55297536 :   const Real dmob = dmobility(pvar) * _phi[_j][_qp];
      89             :   ;
      90             : 
      91             :   const RealVectorValue flow =
      92   138243840 :       _permeability[_qp] * (_grad_p[_qp][ph] - _density[_qp][ph] * _gravity);
      93    55297536 :   RealVectorValue dflow = _dpermeability_dvar[_qp][pvar] * _phi[_j][_qp] *
      94    27648768 :                           (_grad_p[_qp][ph] - _density[_qp][ph] * _gravity);
      95   193541376 :   for (unsigned i = 0; i < LIBMESH_DIM; ++i)
      96   248838912 :     dflow += _dpermeability_dgradvar[_qp][i][pvar] * _grad_phi[_j][_qp](i) *
      97    82946304 :              (_grad_p[_qp][ph] - _density[_qp][ph] * _gravity);
      98    82946304 :   dflow += _permeability[_qp] * (_grad_phi[_j][_qp] * _dgrad_p_dgrad_var[_qp][ph][pvar] -
      99    55297536 :                                  _phi[_j][_qp] * _ddensity_dvar[_qp][ph][pvar] * _gravity);
     100    55297536 :   dflow += _permeability[_qp] * (_dgrad_p_dvar[_qp][ph][pvar] * _phi[_j][_qp]);
     101    27648768 :   return _grad_test[_i][_qp] * (dmob * flow + mob * dflow);
     102             : }
     103             : 
     104             : Real
     105    36953464 : PorousFlowFullySaturatedDarcyBase::mobility() const
     106             : {
     107             :   const unsigned ph = 0;
     108    73906928 :   Real mob = 1.0 / _viscosity[_qp][ph];
     109    36953464 :   if (_multiply_by_density)
     110    40968688 :     mob *= _density[_qp][ph];
     111    36953464 :   return mob;
     112             : }
     113             : 
     114             : Real
     115    27648768 : PorousFlowFullySaturatedDarcyBase::dmobility(unsigned pvar) const
     116             : {
     117             :   const unsigned ph = 0;
     118   110595072 :   Real dmob = -_dviscosity_dvar[_qp][ph][pvar] / std::pow(_viscosity[_qp][ph], 2);
     119    27648768 :   if (_multiply_by_density)
     120    49318912 :     dmob = _density[_qp][ph] * dmob + _ddensity_dvar[_qp][ph][pvar] / _viscosity[_qp][ph];
     121    27648768 :   return dmob;
     122        2499 : }

Generated by: LCOV version 1.11