LCOV - code coverage report
Current view: top level - include/variables - MooseVariableDataLinearFV.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #33416 (b10b36) with base 9fbd27 Lines: 4 11 36.4 %
Date: 2026-07-23 16:15:30 Functions: 1 6 16.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14