Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 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 "ThreadedGeneralUserObject.h" 13 : 14 : /** 15 : * A base class for computing/caching fluxes at boundaries 16 : * 17 : * Notes: 18 : * 19 : * 1. When systems of equations are being solved, the fluxes are treated as vectors. 20 : * To avoid recomputing the flux at the boundary, we compute it just once 21 : * and then when it is needed, we just return the cached value. 22 : * 23 : * 2. Derived classes need to override `calcFlux` and `calcJacobian`. 24 : */ 25 : class BoundaryFluxBase : public ThreadedGeneralUserObject 26 : { 27 : public: 28 : static InputParameters validParams(); 29 : 30 : BoundaryFluxBase(const InputParameters & parameters); 31 : 32 1100 : virtual void execute() override {} 33 : virtual void initialize() override; 34 816 : virtual void finalize() override {} 35 284 : virtual void threadJoin(const UserObject &) override {} 36 : 37 : /** 38 : * Get the boundary flux vector 39 : * @param[in] iside local index of current side 40 : * @param[in] ielem global index of the current element 41 : * @param[in] uvec1 vector of variables on the host side 42 : * @param[in] dwave vector of unit normal 43 : */ 44 : virtual const std::vector<Real> & getFlux(unsigned int iside, 45 : dof_id_type ielem, 46 : const std::vector<Real> & uvec1, 47 : const RealVectorValue & dwave) const; 48 : 49 : /** 50 : * Solve the Riemann problem on the boundary face 51 : * @param[in] iside local index of current side 52 : * @param[in] ielem global index of the current element 53 : * @param[in] uvec1 vector of variables on the host side 54 : * @param[in] dwave vector of unit normal 55 : * @param[out] flux flux vector for conservation equations 56 : */ 57 : virtual void calcFlux(unsigned int iside, 58 : dof_id_type ielem, 59 : const std::vector<Real> & uvec1, 60 : const RealVectorValue & dwave, 61 : std::vector<Real> & flux) const = 0; 62 : 63 : /** 64 : * Get the boundary Jacobian matrix 65 : * @param[in] iside local index of current side 66 : * @param[in] ielem global index of the current element 67 : * @param[in] uvec1 vector of variables on the host side 68 : * @param[in] dwave vector of unit normal 69 : */ 70 : virtual const DenseMatrix<Real> & getJacobian(unsigned int iside, 71 : dof_id_type ielem, 72 : const std::vector<Real> & uvec1, 73 : const RealVectorValue & dwave) const; 74 : 75 : /** 76 : * Compute the Jacobian matrix on the boundary face 77 : * @param[in] iside local index of current side 78 : * @param[in] ielem global index of the current element 79 : * @param[in] uvec1 vector of variables on the host side 80 : * @param[in] dwave vector of unit normal 81 : * @param[out] jac1 Jacobian matrix contribution 82 : */ 83 : virtual void calcJacobian(unsigned int iside, 84 : dof_id_type ielem, 85 : const std::vector<Real> & uvec1, 86 : const RealVectorValue & dwave, 87 : DenseMatrix<Real> & jac1) const = 0; 88 : 89 : protected: 90 : /// element ID of the cached flux values 91 : mutable unsigned int _cached_flux_elem_id; 92 : /// side ID of the cached flux values 93 : mutable unsigned int _cached_flux_side_id; 94 : 95 : /// element ID of the cached Jacobian values 96 : mutable unsigned int _cached_jacobian_elem_id; 97 : /// side ID of the cached Jacobian values 98 : mutable unsigned int _cached_jacobian_side_id; 99 : 100 : /// Cached flux 101 : mutable std::vector<Real> _flux; 102 : 103 : /// Cached flux Jacobian 104 : mutable DenseMatrix<Real> _jac1; 105 : };