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

Advection of a quantity with velocity set in the PorousFlowAdvectiveFluxCalculator Depending on the PorousFlowAdvectiveFluxCalculator, the quantity may be either a fluid component in a fluid phase, or heat energy in a fluid phase. More...

#include <PorousFlowFluxLimitedTVDAdvection.h>

Inheritance diagram for PorousFlowFluxLimitedTVDAdvection:
[legend]

Public Member Functions

 PorousFlowFluxLimitedTVDAdvection (const InputParameters &parameters)
 

Protected Member Functions

virtual Real computeQpResidual () override
 
virtual void computeResidual () override
 
virtual void computeJacobian () override
 

Protected Attributes

const PorousFlowDictator_dictator
 PorousFlowDictator UserObject. More...
 
const PorousFlowAdvectiveFluxCalculatorBase_fluo
 The user object that computes Kuzmin and Turek's K_ij, R+ and R-, etc quantities. More...
 

Detailed Description

Advection of a quantity with velocity set in the PorousFlowAdvectiveFluxCalculator Depending on the PorousFlowAdvectiveFluxCalculator, the quantity may be either a fluid component in a fluid phase, or heat energy in a fluid phase.

This implements the flux-limited TVD scheme detailed in D Kuzmin and S Turek "High-resolution FEM-TVD schemes based on a fully multidimensional flux limiter" Journal of Computational Physics 198 (2004) 131-158

This is a simple class: it simply uses the quantities built and cached by PorousFlowAdvectiveFluxCalculator to build the residual and Jacobian

Definition at line 33 of file PorousFlowFluxLimitedTVDAdvection.h.

Constructor & Destructor Documentation

◆ PorousFlowFluxLimitedTVDAdvection()

PorousFlowFluxLimitedTVDAdvection::PorousFlowFluxLimitedTVDAdvection ( const InputParameters &  parameters)

Definition at line 33 of file PorousFlowFluxLimitedTVDAdvection.C.

35  : Kernel(parameters),
36  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
37  _fluo(getUserObject<PorousFlowAdvectiveFluxCalculatorBase>("advective_flux_calculator"))
38 {
39 }

Member Function Documentation

◆ computeJacobian()

void PorousFlowFluxLimitedTVDAdvection::computeJacobian ( )
overrideprotectedvirtual

Definition at line 72 of file PorousFlowFluxLimitedTVDAdvection.C.

73 {
74  prepareMatrixTag(_assembly, _var.number(), _var.number());
75  precalculateJacobian();
76 
77  // Run through the nodes of this element using "i", getting the Jacobian contributions
78  // d(residual_i)/du(node_j) for all nodes j that can have a nonzero Jacobian contribution. Some
79  // of these node_j will live in this element, but some will live in other elements connected with
80  // node "i", and some will live in the next layer of nodes (eg, in 1D residual_3 could have
81  // contributions from node1, node2, node3, node4 and node5).
82  for (unsigned i = 0; i < _current_elem->n_nodes(); ++i)
83  {
84  // global id of node "i"
85  const dof_id_type node_id_i = _current_elem->node_id(i);
86  // dof number of _var on node "i"
87  std::vector<dof_id_type> idof_indices(
88  1, _current_elem->node_ref(i).dof_number(_sys.number(), _var.number(), 0));
89  // number of times node "i" is encountered in a sweep over elements
90  const unsigned valence = _fluo.getValence(node_id_i);
91 
92  // retrieve the derivative information from _fluo
93  const std::map<dof_id_type, std::vector<Real>> derivs = _fluo.getdFluxOut_dvars(node_id_i);
94 
95  // now build up the dof numbers of all the "j" nodes and the derivative matrix
96  // d(residual_i)/d(var_j)
97  for (unsigned pvar = 0; pvar < _dictator.numVariables(); ++pvar)
98  {
99  const unsigned varnum = _dictator.mooseVariableNum(pvar);
100  std::vector<dof_id_type> jdof_indices(derivs.size());
101  DenseMatrix<Number> deriv_matrix(1, derivs.size());
102  unsigned j = 0;
103  for (const auto & node_j_deriv : derivs)
104  {
105  // global id of j:
106  const dof_id_type node_id_j = node_j_deriv.first;
107  // dof of pvar at node j:
108  jdof_indices[j] = _mesh.getMesh().node_ref(node_id_j).dof_number(_sys.number(), varnum, 0);
109  // derivative must be divided by valence, otherwise the loop over elements will
110  // multiple-count
111  deriv_matrix(0, j) = node_j_deriv.second[pvar] / valence;
112  j++;
113  }
114  // Add the result to the system's Jacobian matrix
115  _assembly.cacheJacobianBlock(deriv_matrix, idof_indices, jdof_indices, _var.scalingFactor());
116  }
117  }
118 }

◆ computeQpResidual()

Real PorousFlowFluxLimitedTVDAdvection::computeQpResidual ( )
overrideprotectedvirtual

Definition at line 42 of file PorousFlowFluxLimitedTVDAdvection.C.

43 {
44  mooseError("PorousFlowFluxLimitedTVDAdvection::computeQpResidual() called\n");
45  return 0.0;
46 }

◆ computeResidual()

void PorousFlowFluxLimitedTVDAdvection::computeResidual ( )
overrideprotectedvirtual

Definition at line 49 of file PorousFlowFluxLimitedTVDAdvection.C.

50 {
51  prepareVectorTag(_assembly, _var.number());
52  precalculateResidual();
53 
54  // get the residual contributions from _fluo
55  for (unsigned i = 0; i < _current_elem->n_nodes(); ++i)
56  {
57  const dof_id_type node_id_i = _current_elem->node_id(i);
58  _local_re(i) = _fluo.getFluxOut(node_id_i) / _fluo.getValence(node_id_i);
59  }
60 
61  accumulateTaggedLocalResidual();
62 
63  if (_has_save_in)
64  {
65  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
66  for (unsigned int i = 0; i < _save_in.size(); i++)
67  _save_in[i]->sys().solution().add_vector(_local_re, _save_in[i]->dofIndices());
68  }
69 }

Member Data Documentation

◆ _dictator

const PorousFlowDictator& PorousFlowFluxLimitedTVDAdvection::_dictator
protected

PorousFlowDictator UserObject.

Definition at line 44 of file PorousFlowFluxLimitedTVDAdvection.h.

Referenced by computeJacobian().

◆ _fluo

const PorousFlowAdvectiveFluxCalculatorBase& PorousFlowFluxLimitedTVDAdvection::_fluo
protected

The user object that computes Kuzmin and Turek's K_ij, R+ and R-, etc quantities.

Definition at line 47 of file PorousFlowFluxLimitedTVDAdvection.h.

Referenced by computeJacobian(), and computeResidual().


The documentation for this class was generated from the following files:
PorousFlowDictator::mooseVariableNum
unsigned int mooseVariableNum(unsigned int porous_flow_var_num) const
The Moose variable number.
Definition: PorousFlowDictator.C:145
PorousFlowFluxLimitedTVDAdvection::_fluo
const PorousFlowAdvectiveFluxCalculatorBase & _fluo
The user object that computes Kuzmin and Turek's K_ij, R+ and R-, etc quantities.
Definition: PorousFlowFluxLimitedTVDAdvection.h:47
AdvectiveFluxCalculatorBase::getValence
unsigned getValence(dof_id_type node_i) const
Returns the valence of the global node i Valence is the number of times the node is encountered in a ...
Definition: AdvectiveFluxCalculatorBase.C:749
PorousFlowFluxLimitedTVDAdvection::_dictator
const PorousFlowDictator & _dictator
PorousFlowDictator UserObject.
Definition: PorousFlowFluxLimitedTVDAdvection.h:44
PorousFlowDictator::numVariables
unsigned int numVariables() const
The number of PorousFlow variables.
Definition: PorousFlowDictator.C:99
PorousFlowAdvectiveFluxCalculatorBase::getdFluxOut_dvars
const std::map< dof_id_type, std::vector< Real > > & getdFluxOut_dvars(unsigned node_id) const
Returns d(flux_out)/d(porous_flow_variables.
Definition: PorousFlowAdvectiveFluxCalculatorBase.C:247
AdvectiveFluxCalculatorBase::getFluxOut
Real getFluxOut(dof_id_type node_i) const
Returns the flux out of lobal node id.
Definition: AdvectiveFluxCalculatorBase.C:743