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 : using typename MooseVariableDataBase<OutputType>::DofValue; 75 : using typename MooseVariableDataBase<OutputType>::DofValues; 76 : 77 : MooseVariableDataLinearFV(const MooseLinearVariableFV<OutputType> & var, 78 : SystemBase & sys, 79 : THREAD_ID tid, 80 : Moose::ElementType element_type, 81 : const Elem * const & elem); 82 : 83 0 : bool isNodal() const override { return false; } 84 0 : bool hasDoFsOnNodes() const override { return false; } 85 0 : libMesh::FEContinuity getContinuity() const override { return libMesh::DISCONTINUOUS; } 86 : 87 : /** 88 : * Set the geometry type before calculating variables values. 89 : * @param gm_type The type type of geometry; either Volume or Face 90 : */ 91 : void setGeometry(Moose::GeometryType gm_type); 92 : 93 : /** 94 : * Compute the variable values. 95 : */ 96 : void computeValues(); 97 : 98 : /** 99 : * Set local DOF values to the entries of \p values . 100 : */ 101 : void setDofValues(const DenseVector<DofValue> & values); 102 : 103 : /** 104 : * Set local DOF value at \p index to \p value . 105 : */ 106 : void setDofValue(const DofValue & value, unsigned int index); 107 : 108 : /** 109 : * Get the dof indices for an element. 110 : * @param elem The element on which the dof indices shall be queried 111 : * @param dof_indices The container in which the dof indices will be copied 112 : */ 113 : void getDofIndices(const Elem * elem, std::vector<dof_id_type> & dof_indices) const; 114 : 115 : /** 116 : * Get the dof indices of the current element. 117 : */ 118 : const std::vector<dof_id_type> & dofIndices() const; 119 : 120 : /** 121 : * Get the number of dofs on the current element. 122 : */ 123 : unsigned int numberOfDofs() const; 124 : 125 : /** 126 : * Clear the dof indices in the cache. 127 : */ 128 11958 : void clearDofIndices() 129 : { 130 11958 : _dof_indices.clear(); 131 11958 : _prev_elem = nullptr; 132 11958 : } 133 : 134 : protected: 135 : /** 136 : * Get the corresponding variable. 137 : */ 138 : virtual const MooseLinearVariableFV<OutputType> & var() const override; 139 : 140 : private: 141 : void initializeSolnVars(); 142 : 143 : /// A const reference to the owning MooseLinearVariableFV object 144 : const MooseLinearVariableFV<OutputType> & _var; 145 : 146 : /// Reference to the variable's finite element type 147 : const libMesh::FEType & _fe_type; 148 : 149 : /// The index of the variable in the system 150 : const unsigned int _var_num; 151 : 152 : /// Reference to the system assembly of the variable 153 : const Assembly & _assembly; 154 : 155 : /// The element type this object is storing data for. This is either Element, Neighbor, or Lower 156 : Moose::ElementType _element_type; 157 : 158 : /// Pointer to time integrator 159 : const TimeIntegrator * const _time_integrator; 160 : 161 : /// The current elem. This has to be a reference because the current elem will be constantly 162 : /// changing. If we initialized this to point to one elem, then in the next calculation we would 163 : /// be pointing to the wrong place! 164 : const Elem * const & _elem; 165 : 166 : /// used to keep track of when dof indices are out of date 167 : mutable const Elem * _prev_elem = nullptr; 168 : 169 : /** 170 : * Fetch and return the dof indices of this variable on the current element. 171 : */ 172 : const std::vector<dof_id_type> & initDofIndices(); 173 : 174 : /// Whether this variable is being calculated on a displaced system 175 : const bool _displaced; 176 : 177 : /// Pointer to the quadrature rule 178 : const libMesh::QBase * _qrule; 179 : 180 : using MooseVariableDataBase<OutputType>::_sys; 181 : using MooseVariableDataBase<OutputType>::_subproblem; 182 : using MooseVariableDataBase<OutputType>::_need_vector_tag_dof_u; 183 : using MooseVariableDataBase<OutputType>::_need_matrix_tag_dof_u; 184 : using MooseVariableDataBase<OutputType>::_vector_tags_dof_u; 185 : using MooseVariableDataBase<OutputType>::_matrix_tags_dof_u; 186 : using MooseVariableDataBase<OutputType>::_vector_tag_u; 187 : using MooseVariableDataBase<OutputType>::_need_vector_tag_u; 188 : using MooseVariableDataBase<OutputType>::_vector_tag_grad; 189 : using MooseVariableDataBase<OutputType>::_need_vector_tag_grad; 190 : using MooseVariableDataBase<OutputType>::_matrix_tag_u; 191 : using MooseVariableDataBase<OutputType>::_need_matrix_tag_u; 192 : using MooseVariableDataBase<OutputType>::_dof_indices; 193 : using MooseVariableDataBase<OutputType>::_has_dof_values; 194 : using MooseVariableDataBase<OutputType>::fetchDofValues; 195 : using MooseVariableDataBase<OutputType>::assignNodalValue; 196 : using MooseVariableDataBase<OutputType>::zeroSizeDofValues; 197 : using MooseVariableDataBase<OutputType>::_solution_tag; 198 : using MooseVariableDataBase<OutputType>::_old_solution_tag; 199 : using MooseVariableDataBase<OutputType>::_older_solution_tag; 200 : using MooseVariableDataBase<OutputType>::_previous_nl_solution_tag; 201 : using MooseVariableDataBase<OutputType>::_dof_map; 202 : using MooseVariableDataBase<OutputType>::_need_u_dot; 203 : using MooseVariableDataBase<OutputType>::_need_u_dotdot; 204 : using MooseVariableDataBase<OutputType>::_need_u_dot_old; 205 : using MooseVariableDataBase<OutputType>::_need_u_dotdot_old; 206 : using MooseVariableDataBase<OutputType>::_need_du_dot_du; 207 : using MooseVariableDataBase<OutputType>::_need_du_dotdot_du; 208 : using MooseVariableDataBase<OutputType>::_need_grad_dot; 209 : using MooseVariableDataBase<OutputType>::_need_grad_dotdot; 210 : using MooseVariableDataBase<OutputType>::_need_dof_values_dot; 211 : using MooseVariableDataBase<OutputType>::_need_dof_values_dotdot; 212 : using MooseVariableDataBase<OutputType>::_need_dof_values_dot_old; 213 : using MooseVariableDataBase<OutputType>::_need_dof_values_dotdot_old; 214 : using MooseVariableDataBase<OutputType>::_need_dof_du_dot_du; 215 : using MooseVariableDataBase<OutputType>::_need_dof_du_dotdot_du; 216 : using MooseVariableDataBase<OutputType>::_dof_values_dot; 217 : using MooseVariableDataBase<OutputType>::_dof_values_dotdot; 218 : using MooseVariableDataBase<OutputType>::_dof_values_dot_old; 219 : using MooseVariableDataBase<OutputType>::_dof_values_dotdot_old; 220 : using MooseVariableDataBase<OutputType>::_dof_du_dot_du; 221 : using MooseVariableDataBase<OutputType>::_dof_du_dotdot_du; 222 : using MooseVariableDataBase<OutputType>::_tid; 223 : using MooseVariableDataBase<OutputType>::_nodal_value_dot; 224 : using MooseVariableDataBase<OutputType>::_nodal_value_dotdot; 225 : using MooseVariableDataBase<OutputType>::_nodal_value_dot_old; 226 : using MooseVariableDataBase<OutputType>::_nodal_value_dotdot_old; 227 : using MooseVariableDataBase<OutputType>::_required_vector_tags; 228 : 229 : friend void Moose::initDofIndices<>(MooseVariableDataLinearFV<OutputType> &, const Elem &); 230 : }; 231 : 232 : /////////////////////// General template definitions ////////////////////////////////////// 233 : 234 : template <typename OutputType> 235 : const std::vector<dof_id_type> & 236 0 : MooseVariableDataLinearFV<OutputType>::dofIndices() const 237 : { 238 0 : return const_cast<MooseVariableDataLinearFV<OutputType> *>(this)->initDofIndices(); 239 : } 240 : 241 : template <typename OutputType> 242 : unsigned int 243 0 : MooseVariableDataLinearFV<OutputType>::numberOfDofs() const 244 : { 245 0 : return dofIndices().size(); 246 : }