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 : * Abstract base class for computing and caching internal or boundary fluxes for 16 : * 1D conservation law systems. 17 : */ 18 : class NumericalFlux1D : public ThreadedGeneralUserObject 19 : { 20 : public: 21 : static InputParameters validParams(); 22 : 23 : NumericalFlux1D(const InputParameters & parameters); 24 : 25 : virtual void execute() override; 26 : virtual void initialize() override; 27 : virtual void finalize() override; 28 : virtual void threadJoin(const UserObject &) override; 29 : 30 : /** 31 : * Gets the 1D flux vector for an element/side combination 32 : * 33 : * If the element/side is cached, the cached values are used. Otherwise the 34 : * values are computed, cached, and returned. 35 : * 36 : * @param[in] iside local index of current side 37 : * @param[in] ielem global index of the current element 38 : * @param[in] res_side_is_left getting flux on the left ("elem") side? 39 : * @param[in] UL_1d vector of 1D flux inputs on the "left" 40 : * @param[in] UR_1d vector of 1D flux inputs on the "right" 41 : * @param[in] nLR_dot_d Dot product of direction from "left" to "right" with 42 : * the flow channel direction 43 : * 44 : * @return flux vector for an element/side combination 45 : */ 46 : virtual const std::vector<ADReal> & getFlux(const unsigned int iside, 47 : const dof_id_type ielem, 48 : bool res_side_is_left, 49 : const std::vector<ADReal> & UL_1d, 50 : const std::vector<ADReal> & UR_1d, 51 : Real nLR_dot_d) const; 52 : 53 : /** 54 : * Gets the 3D flux vector for an element/side combination on the left side 55 : * 56 : * If the element/side is cached, the cached values are used. Otherwise the 57 : * values are computed, cached, and returned. 58 : * 59 : * @param[in] iside local index of current side 60 : * @param[in] ielem global index of the current element 61 : * @param[in] UL_3d vector of 3D flux inputs on the "left" 62 : * @param[in] UR_3d vector of 3D flux inputs on the "right" 63 : * @param[in] nLR Direction from "left" to "right" 64 : * @param[in] t1 1st tangent direction 65 : * @param[in] t2 2nd tangent direction 66 : * 67 : * @return flux vector for an element/side combination 68 : */ 69 : virtual const std::vector<ADReal> & getFlux3D(const unsigned int iside, 70 : const dof_id_type ielem, 71 : const std::vector<ADReal> & UL_3d, 72 : const std::vector<ADReal> & UR_3d, 73 : const RealVectorValue & nLR, 74 : const RealVectorValue & t1, 75 : const RealVectorValue & t2) const; 76 : 77 : /** 78 : * Calculates the 3D flux vectors given "left" and "right" states 79 : * 80 : * This function is called only if the values are not already cached. 81 : * 82 : * @param[in] UL_3d Vector of 3D flux inputs on the "left" 83 : * @param[in] UR_3d Vector of 3D flux inputs on the "right" 84 : * @param[in] nLR Direction from "left" to "right" 85 : * @param[in] t1 1st tangent direction 86 : * @param[in] t2 2nd tangent direction 87 : * @param[out] FL Flux vector to be added to "left" side 88 : * @param[out] FR Flux vector to be added to "right" side 89 : */ 90 : virtual void calcFlux(const std::vector<ADReal> & UL_3d, 91 : const std::vector<ADReal> & UR_3d, 92 : const RealVectorValue & nLR, 93 : const RealVectorValue & t1, 94 : const RealVectorValue & t2, 95 : std::vector<ADReal> & FL, 96 : std::vector<ADReal> & FR) const = 0; 97 : 98 : /** 99 : * Returns the index of the region last entered 100 : * 101 : * Here "region" refers to a code path taken. For some fluxes, such as centered 102 : * fluxes, there is just a single code path, but for others, such as those 103 : * using an approximate Riemann solver, there are multiple. Riemann solvers 104 : * have "regions" defined by the characteristic waves. 105 : */ 106 10 : unsigned int getLastRegionIndex() const { return _last_region_index; } 107 : 108 : /** 109 : * Returns the total possible number of regions 110 : * 111 : * Here "region" refers to a code path taken. For some fluxes, such as centered 112 : * fluxes, there is just a single code path, but for others, such as those 113 : * using an approximate Riemann solver, there are multiple. Riemann solvers 114 : * have "regions" defined by the characteristic waves. 115 : */ 116 : virtual unsigned int getNumberOfRegions() const = 0; 117 : 118 : protected: 119 : /** 120 : * Converts a 1D flux input vector to a 3D flux input vector 121 : * 122 : * @param[in] U_1d 1D flux input vector 123 : */ 124 : virtual std::vector<ADReal> convert1DInputTo3D(const std::vector<ADReal> & U_1d) const = 0; 125 : 126 : /** 127 : * Converts a 3D flux vector to a 1D flux vector 128 : * 129 : * @param[in] F_3d 3D flux vector 130 : */ 131 : virtual std::vector<ADReal> convert3DFluxTo1D(const std::vector<ADReal> & F_3d) const = 0; 132 : 133 : /** 134 : * Applies direction transformation to a 3D flux vector 135 : * 136 : * @param[inout] F_3d 3D flux vector 137 : * @param[in] nLR_dot_d Dot product of direction from "left" to "right" with 138 : * the flow channel direction 139 : */ 140 : virtual void transform3DFluxDirection(std::vector<ADReal> & F_3d, Real nLR_dot_d) const = 0; 141 : 142 : /// element ID of the cached flux values 143 : mutable unsigned int _cached_flux_elem_id; 144 : /// side ID of the cached flux values 145 : mutable unsigned int _cached_flux_side_id; 146 : 147 : /// flux vector for the "left" cell for 3D 148 : mutable std::vector<ADReal> _FL_3d; 149 : /// flux vector for the "right" cell for 3D 150 : mutable std::vector<ADReal> _FR_3d; 151 : /// flux vector for the "left" cell for 1D 152 : mutable std::vector<ADReal> _FL_1d; 153 : /// flux vector for the "right" cell for 1D 154 : mutable std::vector<ADReal> _FR_1d; 155 : 156 : /// Index describing the region last entered, which is useful for testing and debugging 157 : mutable unsigned int _last_region_index; 158 : };