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 "MooseArray.h" 13 : #include "MooseTypes.h" 14 : #include "MeshChangedInterface.h" 15 : #include "MooseVariableDataBase.h" 16 : #include "TheWarehouse.h" 17 : 18 : #include "libmesh/tensor_tools.h" 19 : #include "libmesh/vector_value.h" 20 : #include "libmesh/tensor_value.h" 21 : #include "libmesh/type_n_tensor.h" 22 : #include "libmesh/fe_type.h" 23 : #include "libmesh/dof_map.h" 24 : #include "libmesh/enum_fe_family.h" 25 : #include "SubProblem.h" 26 : #include "MooseVariableDataFV.h" 27 : 28 : #include <functional> 29 : #include <vector> 30 : 31 : class FaceInfo; 32 : class SystemBase; 33 : class TimeIntegrator; 34 : class Assembly; 35 : 36 : template <typename> 37 : class MooseVariableFV; 38 : 39 : namespace libMesh 40 : { 41 : class QBase; 42 : } 43 : 44 : /** 45 : * Class holding the data members for linear finite volume variables. 46 : * At the moment, this is only used when the user wants to use linear 47 : * finite volume variables in the postprocessor/userobject and auxiliary 48 : * systems. The solver-related functionalities rely on a different machinery. 49 : */ 50 : template <typename OutputType> 51 : class MooseVariableDataLinearFV : public MooseVariableDataBase<OutputType> 52 : { 53 : public: 54 : // type for gradient, second and divergence of template class OutputType 55 : typedef typename libMesh::TensorTools::IncrementRank<OutputType>::type OutputGradient; 56 : typedef typename libMesh::TensorTools::IncrementRank<OutputGradient>::type OutputSecond; 57 : typedef typename libMesh::TensorTools::DecrementRank<OutputType>::type OutputDivergence; 58 : 59 : // shortcut for types storing values on quadrature points 60 : typedef MooseArray<OutputType> FieldVariableValue; 61 : typedef MooseArray<OutputGradient> FieldVariableGradient; 62 : typedef MooseArray<OutputSecond> FieldVariableSecond; 63 : typedef MooseArray<OutputType> FieldVariableCurl; 64 : typedef MooseArray<OutputDivergence> FieldVariableDivergence; 65 : 66 : // shape function type for the template class OutputType 67 : typedef typename Moose::ShapeType<OutputType>::type OutputShape; 68 : 69 : // type for gradient, second and divergence of shape functions of template class OutputType 70 : typedef typename libMesh::TensorTools::IncrementRank<OutputShape>::type OutputShapeGradient; 71 : typedef typename libMesh::TensorTools::IncrementRank<OutputShapeGradient>::type OutputShapeSecond; 72 : typedef typename libMesh::TensorTools::DecrementRank<OutputShape>::type OutputShapeDivergence; 73 : 74 : // DoF value type for the template class OutputType 75 : typedef typename Moose::DOFType<OutputType>::type OutputData; 76 : typedef MooseArray<OutputData> DoFValue; 77 : 78 : MooseVariableDataLinearFV(const MooseLinearVariableFV<OutputType> & var, 79 : SystemBase & sys, 80 : THREAD_ID tid, 81 : Moose::ElementType element_type, 82 : const Elem * const & elem); 83 : 84 0 : bool isNodal() const override { return false; } 85 0 : bool hasDoFsOnNodes() const override { return false; } 86 0 : libMesh::FEContinuity getContinuity() const override { return libMesh::DISCONTINUOUS; } 87 : 88 : /** 89 : * Set the geometry type before calculating variables values. 90 : * @param gm_type The type type of geometry; either Volume or Face 91 : */ 92 : void setGeometry(Moose::GeometryType gm_type); 93 : 94 : /** 95 : * Compute the variable values. 96 : */ 97 : void computeValues(); 98 : 99 : /** 100 : * Set local DOF values to the entries of \p values . 101 : */ 102 : void setDofValues(const DenseVector<OutputData> & values); 103 : 104 : /** 105 : * Set local DOF value at \p index to \p value . 106 : */ 107 : void setDofValue(const OutputData & value, unsigned int index); 108 : 109 : /** 110 : * Get the dof indices for an element. 111 : * @param elem The element on which the dof indices shall be queried 112 : * @param dof_indices The container in which the dof indices will be copied 113 : */ 114 : void getDofIndices(const Elem * elem, std::vector<dof_id_type> & dof_indices) const; 115 : 116 : /** 117 : * Get the dof indices of the current element. 118 : */ 119 : const std::vector<dof_id_type> & dofIndices() const; 120 : 121 : /** 122 : * Get the number of dofs on the current element. 123 : */ 124 : unsigned int numberOfDofs() const; 125 : 126 : /** 127 : * Clear the dof indices in the cache. 128 : */ 129 7846 : void clearDofIndices() 130 : { 131 7846 : _dof_indices.clear(); 132 7846 : _prev_elem = nullptr; 133 7846 : } 134 : 135 : protected: 136 : /** 137 : * Get the corresponding variable. 138 : */ 139 : virtual const MooseLinearVariableFV<OutputType> & var() const override; 140 : 141 : private: 142 : void initializeSolnVars(); 143 : 144 : /// A const reference to the owning MooseLinearVariableFV object 145 : const MooseLinearVariableFV<OutputType> & _var; 146 : 147 : /// Reference to the variable's finite element type 148 : const libMesh::FEType & _fe_type; 149 : 150 : /// The index of the variable in the system 151 : const unsigned int _var_num; 152 : 153 : /// Reference to the system assembly of the variable 154 : const Assembly & _assembly; 155 : 156 : /// The element type this object is storing data for. This is either Element, Neighbor, or Lower 157 : Moose::ElementType _element_type; 158 : 159 : /// Pointer to time integrator 160 : const TimeIntegrator * const _time_integrator; 161 : 162 : /// The current elem. This has to be a reference because the current elem will be constantly 163 : /// changing. If we initialized this to point to one elem, then in the next calculation we would 164 : /// be pointing to the wrong place! 165 : const Elem * const & _elem; 166 : 167 : /// used to keep track of when dof indices are out of date 168 : mutable const Elem * _prev_elem = nullptr; 169 : 170 : /** 171 : * Fetch and return the dof indices of this variable on the current element. 172 : */ 173 : const std::vector<dof_id_type> & initDofIndices(); 174 : 175 : /// Whether this variable is being calculated on a displaced system 176 : const bool _displaced; 177 : 178 : /// Pointer to the quadrature rule 179 : const libMesh::QBase * _qrule; 180 : 181 : using MooseVariableDataBase<OutputType>::_sys; 182 : using MooseVariableDataBase<OutputType>::_subproblem; 183 : using MooseVariableDataBase<OutputType>::_need_vector_tag_dof_u; 184 : using MooseVariableDataBase<OutputType>::_need_matrix_tag_dof_u; 185 : using MooseVariableDataBase<OutputType>::_vector_tags_dof_u; 186 : using MooseVariableDataBase<OutputType>::_matrix_tags_dof_u; 187 : using MooseVariableDataBase<OutputType>::_vector_tag_u; 188 : using MooseVariableDataBase<OutputType>::_need_vector_tag_u; 189 : using MooseVariableDataBase<OutputType>::_vector_tag_grad; 190 : using MooseVariableDataBase<OutputType>::_need_vector_tag_grad; 191 : using MooseVariableDataBase<OutputType>::_matrix_tag_u; 192 : using MooseVariableDataBase<OutputType>::_need_matrix_tag_u; 193 : using MooseVariableDataBase<OutputType>::_dof_indices; 194 : using MooseVariableDataBase<OutputType>::_has_dof_values; 195 : using MooseVariableDataBase<OutputType>::fetchDoFValues; 196 : using MooseVariableDataBase<OutputType>::assignNodalValue; 197 : using MooseVariableDataBase<OutputType>::zeroSizeDofValues; 198 : using MooseVariableDataBase<OutputType>::_solution_tag; 199 : using MooseVariableDataBase<OutputType>::_old_solution_tag; 200 : using MooseVariableDataBase<OutputType>::_older_solution_tag; 201 : using MooseVariableDataBase<OutputType>::_previous_nl_solution_tag; 202 : using MooseVariableDataBase<OutputType>::_dof_map; 203 : using MooseVariableDataBase<OutputType>::_need_u_dot; 204 : using MooseVariableDataBase<OutputType>::_need_u_dotdot; 205 : using MooseVariableDataBase<OutputType>::_need_u_dot_old; 206 : using MooseVariableDataBase<OutputType>::_need_u_dotdot_old; 207 : using MooseVariableDataBase<OutputType>::_need_du_dot_du; 208 : using MooseVariableDataBase<OutputType>::_need_du_dotdot_du; 209 : using MooseVariableDataBase<OutputType>::_need_grad_dot; 210 : using MooseVariableDataBase<OutputType>::_need_grad_dotdot; 211 : using MooseVariableDataBase<OutputType>::_need_dof_values_dot; 212 : using MooseVariableDataBase<OutputType>::_need_dof_values_dotdot; 213 : using MooseVariableDataBase<OutputType>::_need_dof_values_dot_old; 214 : using MooseVariableDataBase<OutputType>::_need_dof_values_dotdot_old; 215 : using MooseVariableDataBase<OutputType>::_need_dof_du_dot_du; 216 : using MooseVariableDataBase<OutputType>::_need_dof_du_dotdot_du; 217 : using MooseVariableDataBase<OutputType>::_dof_values_dot; 218 : using MooseVariableDataBase<OutputType>::_dof_values_dotdot; 219 : using MooseVariableDataBase<OutputType>::_dof_values_dot_old; 220 : using MooseVariableDataBase<OutputType>::_dof_values_dotdot_old; 221 : using MooseVariableDataBase<OutputType>::_dof_du_dot_du; 222 : using MooseVariableDataBase<OutputType>::_dof_du_dotdot_du; 223 : using MooseVariableDataBase<OutputType>::_tid; 224 : using MooseVariableDataBase<OutputType>::_nodal_value_dot; 225 : using MooseVariableDataBase<OutputType>::_nodal_value_dotdot; 226 : using MooseVariableDataBase<OutputType>::_nodal_value_dot_old; 227 : using MooseVariableDataBase<OutputType>::_nodal_value_dotdot_old; 228 : using MooseVariableDataBase<OutputType>::_required_vector_tags; 229 : 230 : friend void Moose::initDofIndices<>(MooseVariableDataLinearFV<OutputType> &, const Elem &); 231 : }; 232 : 233 : /////////////////////// General template definitions ////////////////////////////////////// 234 : 235 : template <typename OutputType> 236 : const std::vector<dof_id_type> & 237 0 : MooseVariableDataLinearFV<OutputType>::dofIndices() const 238 : { 239 0 : return const_cast<MooseVariableDataLinearFV<OutputType> *>(this)->initDofIndices(); 240 : } 241 : 242 : template <typename OutputType> 243 : unsigned int 244 0 : MooseVariableDataLinearFV<OutputType>::numberOfDofs() const 245 : { 246 0 : return dofIndices().size(); 247 : }