www.mooseframework.org
AdvectiveFluxCalculatorBase.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "ElementUserObject.h"
14 
16 
17 template <>
19 
33 class AdvectiveFluxCalculatorBase : public ElementUserObject
34 {
35 public:
36  AdvectiveFluxCalculatorBase(const InputParameters & parameters);
37 
38  virtual void timestepSetup() override;
39 
40  virtual void meshChanged() override;
41 
42  virtual void initialize() override;
43 
44  virtual void threadJoin(const UserObject & uo) override;
45 
46  virtual void finalize() override;
47 
48  virtual void execute() override;
49 
60  virtual void executeOnElement(
61  dof_id_type global_i, dof_id_type global_j, unsigned local_i, unsigned local_j, unsigned qp);
62 
68  Real getFluxOut(dof_id_type node_i) const;
69 
76  const std::map<dof_id_type, Real> & getdFluxOutdu(dof_id_type node_i) const;
77 
84  const std::vector<std::vector<Real>> & getdFluxOutdKjk(dof_id_type node_i) const;
85 
94  unsigned getValence(dof_id_type node_i) const;
95 
96 protected:
105  virtual void buildCommLists();
106 
111  virtual void exchangeGhostedInfo();
112 
121  virtual Real computeVelocity(unsigned i, unsigned j, unsigned qp) const = 0;
122 
127  virtual Real computeU(unsigned i) const = 0;
128 
131 
139  void limitFlux(Real a, Real b, Real & limited, Real & dlimited_db) const;
140 
149  Real rPlus(dof_id_type sequential_i,
150  std::vector<Real> & dlimited_du,
151  std::vector<Real> & dlimited_dk) const;
152 
161  Real rMinus(dof_id_type sequential_i,
162  std::vector<Real> & dlimited_du,
163  std::vector<Real> & dlimited_dk) const;
164 
170 
176  std::vector<std::vector<Real>> _kij;
177 
179  std::vector<Real> _flux_out;
180 
183  std::vector<std::map<dof_id_type, Real>> _dflux_out_du;
184 
190  std::vector<std::vector<std::vector<Real>>> _dflux_out_dKjk;
191 
195  std::vector<unsigned> _valence;
196 
198  std::vector<Real> _u_nodal;
199 
201  std::vector<bool> _u_nodal_computed_by_thread;
202 
205 
207  std::size_t _number_of_nodes;
208 
210  processor_id_type _my_pid;
211 
218  std::map<processor_id_type, std::vector<dof_id_type>> _nodes_to_receive;
219 
226  std::map<processor_id_type, std::vector<dof_id_type>> _nodes_to_send;
227 
235  std::map<processor_id_type, std::vector<std::pair<dof_id_type, dof_id_type>>> _pairs_to_receive;
236 
244  std::map<processor_id_type, std::vector<std::pair<dof_id_type, dof_id_type>>> _pairs_to_send;
245 
253 
255  enum class PQPlusMinusEnum
256  {
257  PPlus,
258  PMinus,
259  QPlus,
260  QMinus
261  };
262 
274  Real PQPlusMinus(dof_id_type sequential_i,
275  const PQPlusMinusEnum pq_plus_minus,
276  std::vector<Real> & derivs,
277  std::vector<Real> & dpq_dk) const;
278 
285  void zeroedConnection(std::map<dof_id_type, Real> & the_map, dof_id_type node_i) const;
286 };
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 ...
std::vector< bool > _u_nodal_computed_by_thread
_u_nodal_computed_by_thread(i) = true if _u_nodal[i] has been computed in execute() by the thread on ...
FluxLimiterTypeEnum
Determines Flux Limiter type (Page 135 of Kuzmin and Turek) "None" means that limitFlux=0 always...
Real getFluxOut(dof_id_type node_i) const
Returns the flux out of lobal node id.
void limitFlux(Real a, Real b, Real &limited, Real &dlimited_db) const
flux limiter, L, on Page 135 of Kuzmin and Turek
std::vector< std::map< dof_id_type, Real > > _dflux_out_du
_dflux_out_du[i][j] = d(flux_out[i])/d(u[j]).
Real rMinus(dof_id_type sequential_i, std::vector< Real > &dlimited_du, std::vector< Real > &dlimited_dk) const
Returns the value of R_{i}^{-}, Eqn (49) of KT.
virtual void executeOnElement(dof_id_type global_i, dof_id_type global_j, unsigned local_i, unsigned local_j, unsigned qp)
This is called by multiple times in execute() in a double loop over _current_elem&#39;s nodes (local_i an...
std::size_t _number_of_nodes
Number of nodes held by the _connections object.
std::vector< Real > _flux_out
_flux_out[i] = flux of "heat" from sequential node i
std::vector< std::vector< std::vector< Real > > > _dflux_out_dKjk
_dflux_out_dKjk[sequential_i][j][k] = d(flux_out[sequential_i])/d(K[j][k]).
Real PQPlusMinus(dof_id_type sequential_i, const PQPlusMinusEnum pq_plus_minus, std::vector< Real > &derivs, std::vector< Real > &dpq_dk) const
Returns the value of P_{i}^{+}, P_{i}^{-}, Q_{i}^{+} or Q_{i}^{-} (depending on pq_plus_minus) which ...
Base class to compute Advective fluxes.
enum AdvectiveFluxCalculatorBase::FluxLimiterTypeEnum _flux_limiter_type
PorousFlowConnectedNodes _connections
Holds the sequential and global nodal IDs, and info regarding mesh connections between them...
bool _resizing_needed
whether _kij, etc, need to be sized appropriately (and valence recomputed) at the start of the timest...
std::map< processor_id_type, std::vector< dof_id_type > > _nodes_to_send
_nodes_to_send[proc_id] = list of sequential nodal IDs.
const std::map< dof_id_type, Real > & getdFluxOutdu(dof_id_type node_i) const
Returns r where r[j] = d(flux out of global node i)/du(global node j) used in Jacobian computations...
const std::vector< std::vector< Real > > & getdFluxOutdKjk(dof_id_type node_i) const
Returns r where r[j][k] = d(flux out of global node i)/dK[connected node j][connected node k] used in...
Real rPlus(dof_id_type sequential_i, std::vector< Real > &dlimited_du, std::vector< Real > &dlimited_dk) const
Returns the value of R_{i}^{+}, Eqn (49) of KT.
std::map< processor_id_type, std::vector< std::pair< dof_id_type, dof_id_type > > > _pairs_to_send
_pairs_to_send[proc_id] indicates the k(i, j) pairs that we will send to proc_id _pairs_to_send is fi...
std::vector< Real > _u_nodal
_u_nodal[i] = value of _u at sequential node number i
processor_id_type _my_pid
processor ID of this object
virtual void exchangeGhostedInfo()
Sends and receives multi-processor information regarding u_nodal and k_ij.
const Real _allowable_MB_wastage
A mooseWarning is issued if mb_wasted = (_connections.sizeSequential() - _connections.numNodes()) * 4 / 1048576 > _allowable_MB_wastage.
virtual Real computeVelocity(unsigned i, unsigned j, unsigned qp) const =0
Computes the transfer velocity between current node i and current node j at the current qp in the cur...
virtual Real computeU(unsigned i) const =0
Computes the value of u at the local node id of the current element (_current_elem) ...
InputParameters validParams< AdvectiveFluxCalculatorBase >()
AdvectiveFluxCalculatorBase(const InputParameters &parameters)
Class designed to hold node ID information and information about nodal connectivity.
virtual void buildCommLists()
When using multiple processors, other processors will compute:
std::vector< std::vector< Real > > _kij
Kuzmin-Turek K_ij matrix.
std::map< processor_id_type, std::vector< dof_id_type > > _nodes_to_receive
_nodes_to_receive[proc_id] = list of sequential nodal IDs.
PQPlusMinusEnum
Signals to the PQPlusMinus method what should be computed.
std::map< processor_id_type, std::vector< std::pair< dof_id_type, dof_id_type > > > _pairs_to_receive
_pairs_to_receive[proc_id] indicates the k(i, j) pairs that will be sent to us from proc_id _pairs_to...
void zeroedConnection(std::map< dof_id_type, Real > &the_map, dof_id_type node_i) const
Clears the_map, then, using _kij, constructs the_map so that the_map[node_id] = 0.0 for all node_id connected with node_i.
std::vector< unsigned > _valence
_valence[i] = number of times, in a loop over elements seen by this processor (viz, including ghost elements) and are part of the block-restricted blocks of this UserObject, that the sequential node i is encountered
virtual void threadJoin(const UserObject &uo) override