LCOV - code coverage report
Current view: top level - include/userobjects - ProjectedStatefulMaterialNodalPatchRecovery.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 3 3 100.0 %
Date: 2025-07-17 01:28:37 Functions: 1 1 100.0 %
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             : // MOOSE includes
      13             : #include "ElementUserObject.h"
      14             : #include "SerialAccess.h"
      15             : 
      16             : #include <unordered_map>
      17             : 
      18             : class ProjectedStatefulMaterialNodalPatchRecoveryBase : public ElementUserObject
      19             : {
      20             : public:
      21             :   static InputParameters validParams();
      22             : 
      23          52 :   ProjectedStatefulMaterialNodalPatchRecoveryBase(const InputParameters & parameters)
      24          52 :     : ElementUserObject(parameters)
      25             :   {
      26          52 :   }
      27             : 
      28             :   virtual Real nodalPatchRecovery(const Point & p,
      29             :                                   const std::vector<dof_id_type> & elem_ids,
      30             :                                   std::size_t component) const = 0;
      31             : };
      32             : 
      33             : template <typename T, bool is_ad>
      34             : class ProjectedStatefulMaterialNodalPatchRecoveryTempl
      35             :   : public ProjectedStatefulMaterialNodalPatchRecoveryBase
      36             : {
      37             : public:
      38             :   static InputParameters validParams();
      39             : 
      40             :   ProjectedStatefulMaterialNodalPatchRecoveryTempl(const InputParameters & parameters);
      41             : 
      42             :   /**
      43             :    * Solve the least-squares problem. Use the fitted coefficients to calculate the value at the
      44             :    * requested point.
      45             :    *
      46             :    * @param p           Point at which to compute the fitted value
      47             :    * @param elem_ids    Ids of the elements in the patch
      48             :    * @param component   Index of the component to compute the fitted value of
      49             :    * @return The fitted value
      50             :    */
      51             :   virtual Real nodalPatchRecovery(const Point & p,
      52             :                                   const std::vector<dof_id_type> & elem_ids,
      53             :                                   std::size_t component) const override;
      54             : 
      55             :   virtual void initialSetup() override;
      56             : 
      57             :   virtual void initialize() override;
      58             :   virtual void execute() override;
      59             :   virtual void threadJoin(const UserObject &) override;
      60             :   virtual void finalize() override;
      61             : 
      62             : private:
      63             :   /**
      64             :    * Compute the P vector at a given point
      65             :    * i.e. given dim = 2, order = 2, polynomial P has the following terms:
      66             :    * 1
      67             :    * x
      68             :    * y
      69             :    * x^2
      70             :    * xy
      71             :    * y^2
      72             :    *
      73             :    * @param q_point point at which to evaluate the polynomial basis
      74             :    */
      75             :   RealEigenVector evaluateBasisFunctions(const Point & q_point) const;
      76             : 
      77             :   /// data type stored for each element
      78             :   typedef std::pair<RealEigenMatrix, std::vector<RealEigenVector>> ElementData;
      79             : 
      80             :   /// current quadrature point
      81             :   unsigned int _qp;
      82             : 
      83             :   /// number of scalar components in the recovered type
      84             :   std::size_t _n_components;
      85             : 
      86             :   /// The polynomial order, default is variable order
      87             :   const unsigned int _patch_polynomial_order;
      88             : 
      89             :   /// The multi-index table
      90             :   const std::vector<std::vector<unsigned int>> _multi_index;
      91             : 
      92             :   /// Number of basis functions
      93             :   const unsigned int _q;
      94             : 
      95             :   /// stored property
      96             :   const GenericMaterialProperty<T, is_ad> & _prop;
      97             : 
      98             :   /// The element-level A matrix and the element-level b vectors for each component
      99             :   std::unordered_map<dof_id_type, ElementData> _abs;
     100             : 
     101             :   /// Current subdomain
     102             :   const SubdomainID & _current_subdomain_id;
     103             : 
     104             :   /// list of required materials that need to be explicitly initialized at step zero
     105             :   std::unordered_map<SubdomainID, std::vector<MaterialBase *>> _required_materials;
     106             : };
     107             : 
     108             : typedef ProjectedStatefulMaterialNodalPatchRecoveryTempl<Real, false>
     109             :     ProjectedStatefulMaterialNodalPatchRecoveryReal;
     110             : typedef ProjectedStatefulMaterialNodalPatchRecoveryTempl<Real, true>
     111             :     ADProjectedStatefulMaterialNodalPatchRecoveryReal;
     112             : typedef ProjectedStatefulMaterialNodalPatchRecoveryTempl<RealVectorValue, false>
     113             :     ProjectedStatefulMaterialNodalPatchRecoveryRealVectorValue;
     114             : typedef ProjectedStatefulMaterialNodalPatchRecoveryTempl<RealVectorValue, true>
     115             :     ADProjectedStatefulMaterialNodalPatchRecoveryRealVectorValue;
     116             : typedef ProjectedStatefulMaterialNodalPatchRecoveryTempl<RankTwoTensor, false>
     117             :     ProjectedStatefulMaterialNodalPatchRecoveryRankTwoTensor;
     118             : typedef ProjectedStatefulMaterialNodalPatchRecoveryTempl<RankTwoTensor, true>
     119             :     ADProjectedStatefulMaterialNodalPatchRecoveryRankTwoTensor;
     120             : typedef ProjectedStatefulMaterialNodalPatchRecoveryTempl<RankFourTensor, false>
     121             :     ProjectedStatefulMaterialNodalPatchRecoveryRankFourTensor;
     122             : typedef ProjectedStatefulMaterialNodalPatchRecoveryTempl<RankFourTensor, true>
     123             :     ADProjectedStatefulMaterialNodalPatchRecoveryRankFourTensor;
     124             : 
     125             : // Prevent implicit instantiation in other translation units where these classes are used
     126             : extern template class ProjectedStatefulMaterialNodalPatchRecoveryTempl<Real, false>;
     127             : extern template class ProjectedStatefulMaterialNodalPatchRecoveryTempl<Real, true>;
     128             : extern template class ProjectedStatefulMaterialNodalPatchRecoveryTempl<RealVectorValue, false>;
     129             : extern template class ProjectedStatefulMaterialNodalPatchRecoveryTempl<RealVectorValue, true>;
     130             : extern template class ProjectedStatefulMaterialNodalPatchRecoveryTempl<RankTwoTensor, false>;
     131             : extern template class ProjectedStatefulMaterialNodalPatchRecoveryTempl<RankTwoTensor, true>;
     132             : extern template class ProjectedStatefulMaterialNodalPatchRecoveryTempl<RankFourTensor, false>;
     133             : extern template class ProjectedStatefulMaterialNodalPatchRecoveryTempl<RankFourTensor, true>;

Generated by: LCOV version 1.14