LCOV - code coverage report
Current view: top level - include/physics - QuasiStaticSolidMechanicsPhysics.h (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #33390 (250e9c) with base 846a5c Lines: 9 10 90.0 %
Date: 2026-07-31 18:20:40 Functions: 4 4 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             : #include "QuasiStaticSolidMechanicsPhysicsBase.h"
      13             : #include "libmesh/point.h"
      14             : 
      15             : class QuasiStaticSolidMechanicsPhysics : public QuasiStaticSolidMechanicsPhysicsBase
      16             : {
      17             : public:
      18             :   static InputParameters validParams();
      19             : 
      20             :   QuasiStaticSolidMechanicsPhysics(const InputParameters & params);
      21             : 
      22             :   virtual void act();
      23             : 
      24             : protected:
      25             :   void actSubdomainChecks();
      26             :   void actOutputGeneration();
      27             :   void actEigenstrainNames();
      28             :   void actOutputMatProp();
      29             :   void actGatherActionParameters();
      30             :   void verifyOrderAndFamilyOutputs();
      31             :   void actLagrangianKernelStrain();
      32             :   void actStressDivergenceTensorsStrain();
      33             : 
      34             :   virtual std::string getKernelType();
      35             :   virtual InputParameters getKernelParameters(std::string type);
      36             : 
      37             :   /// Apply `compatibility_mode` remapping to a property name pulled from the `_rank_two_*`
      38             :   /// output tables: in compat mode the NEW pipeline writes Cauchy stress + rotated mechanical
      39             :   /// strain under different names than the OLD pipeline. Outside compat mode this is the identity.
      40             :   std::string remapCompatOutputProp(const std::string & prop_name) const;
      41             : 
      42             :   /**
      43             :    * Helper function to decode `generate_outputs` options using a "table" of
      44             :    * scalar output quantities and a "setup" lambda that performs the input parameter
      45             :    * setup for the output material object.
      46             :    */
      47             :   template <typename T, typename T2>
      48             :   bool setupOutput(std::string out, T table, T2 setup);
      49             : 
      50             :   ///@{ displacement variables
      51             :   std::vector<VariableName> _displacements;
      52             : 
      53             :   /// Number of displacement variables
      54             :   unsigned int _ndisp;
      55             : 
      56             :   /// Coupled displacement variables
      57             :   std::vector<VariableName> _coupled_displacements;
      58             :   ///@}
      59             : 
      60             :   ///@{ residual debugging
      61             :   std::vector<AuxVariableName> _save_in;
      62             :   std::vector<AuxVariableName> _diag_save_in;
      63             :   ///@}
      64             : 
      65             :   Moose::CoordinateSystemType _coord_system;
      66             : 
      67             :   /// if this vector is not empty the variables, kernels and materials are restricted to these subdomains
      68             :   std::vector<SubdomainName> _subdomain_names;
      69             : 
      70             :   /// set generated from the passed in vector of subdomain names
      71             :   std::set<SubdomainID> _subdomain_ids;
      72             : 
      73             :   /// set generated from the combined block restrictions of all SolidMechanics/Master action blocks
      74             :   std::set<SubdomainID> _subdomain_id_union;
      75             : 
      76             :   /// strain formulation
      77             :   enum class Strain
      78             :   {
      79             :     Small,
      80             :     Finite
      81             :   } _strain;
      82             : 
      83             :   /// strain formulation
      84             :   enum class StrainAndIncrement
      85             :   {
      86             :     SmallTotal,
      87             :     FiniteTotal,
      88             :     SmallIncremental,
      89             :     FiniteIncremental
      90             :   } _strain_and_increment;
      91             : 
      92             :   /// use an out of plane stress/strain formulation
      93             :   enum class PlanarFormulation
      94             :   {
      95             :     None,
      96             :     WeakPlaneStress,
      97             :     PlaneStrain,
      98             :     GeneralizedPlaneStrain,
      99             :   } _planar_formulation;
     100             : 
     101             :   enum class OutOfPlaneDirection
     102             :   {
     103             :     x,
     104             :     y,
     105             :     z
     106             :   };
     107             : 
     108             :   const OutOfPlaneDirection _out_of_plane_direction;
     109             : 
     110             :   /// base name for the current master action block
     111             :   const std::string _base_name;
     112             : 
     113             :   /// use displaced mesh (true unless _strain is SMALL)
     114             :   bool _use_displaced_mesh;
     115             : 
     116             :   /// output materials to generate scalar stress/strain tensor quantities
     117             :   std::vector<std::string> _generate_output;
     118             :   MultiMooseEnum _material_output_order;
     119             :   MultiMooseEnum _material_output_family;
     120             : 
     121             :   /// booleans used to determine if cylindrical axis points are passed
     122             :   bool _cylindrical_axis_point1_valid;
     123             :   bool _cylindrical_axis_point2_valid;
     124             :   bool _direction_valid;
     125             :   bool _verbose;
     126             : 
     127             :   /// points used to determine axis of rotation for cylindrical stress/strain quantities
     128             :   Point _cylindrical_axis_point1;
     129             :   Point _cylindrical_axis_point2;
     130             :   Point _direction;
     131             : 
     132             :   /// booleans used to determine if spherical center point is passed
     133             :   bool _spherical_center_point_valid;
     134             : 
     135             :   /// center point for spherical stress/strain quantities
     136             :   Point _spherical_center_point;
     137             : 
     138             :   /// automatically gather names of eigenstrain tensors provided by simulation objects
     139             :   const bool _auto_eigenstrain;
     140             : 
     141             :   std::vector<MaterialPropertyName> _eigenstrain_names;
     142             : 
     143             :   /// OLD-compat shim: auto-configures the Lagrangian kernel system to reproduce
     144             :   /// `StressDivergenceTensors + ComputeFiniteStrain + ComputeStressBase` bit-for-bit when set.
     145             :   const bool _compatibility_mode;
     146             : 
     147             :   /// New or old kernel system. True if `new_system = true` OR `compatibility_mode = true`.
     148             :   const bool _lagrangian_kernels;
     149             : 
     150             :   /// Simplified flag for small/large deformations, Lagrangian kernel system
     151             :   const bool _lk_large_kinematics;
     152             : 
     153             :   /// New kernel system kinematics types
     154             :   enum class LKFormulation
     155             :   {
     156             :     Total,
     157             :     Updated
     158             :   };
     159             :   const LKFormulation _lk_formulation;
     160             : 
     161             :   /// Simplified volumetric locking correction flag for new kernels
     162             :   const bool _lk_locking;
     163             : 
     164             :   /// Flag indicating if the homogenization system is present for new kernels
     165             :   bool _lk_homogenization;
     166             : 
     167             :   // Helper to translate into MOOSE talk
     168             :   static const std::map<unsigned int, std::string> _order_mapper;
     169             :   // Name of the homogenization scalar variable
     170             :   const std::string _hname = "hvar";
     171             :   // Name of the integrator
     172             :   const std::string _integrator_name = "integrator";
     173             :   // Name of the homogenization strain
     174             :   const std::string _homogenization_strain_name = "homogenization_gradient";
     175             :   // Other homogenization info
     176             :   MultiMooseEnum _constraint_types;
     177             :   std::vector<FunctionName> _targets;
     178             :   /// Whether to use the off diagonal scalar jacobian for the homogenization system
     179             :   const bool _lk_h_off_jac;
     180             : };
     181             : 
     182             : template <typename T, typename T2>
     183             : bool
     184        2216 : QuasiStaticSolidMechanicsPhysics::setupOutput(std::string out, T table, T2 setup)
     185             : {
     186       13395 :   for (const auto & t1 : table)
     187             :   {
     188             :     // find the officially supported properties
     189       69278 :     for (const auto & t2 : t1.second.second)
     190      116190 :       if (t1.first + '_' + t2 == out)
     191             :       {
     192             :         const auto it = _rank_two_cartesian_component_table.find(t2);
     193        1037 :         if (it != _rank_two_cartesian_component_table.end())
     194             :         {
     195        2074 :           setup(it->second, t1.second.first);
     196             :           return true;
     197             :         }
     198             :         else
     199           0 :           mooseError("Internal error. The permitted tensor shortcuts must be keys in the "
     200             :                      "'_rank_two_cartesian_component_table'.");
     201             :       }
     202             : 
     203             :     // check for custom properties
     204       11183 :     auto prefix = t1.first + '_';
     205       11183 :     if (out.substr(0, prefix.length()) == prefix)
     206             :     {
     207           8 :       setup(out.substr(prefix.length()), t1.second.first);
     208             :       return true;
     209             :     }
     210             :   }
     211             : 
     212             :   return false;
     213             : }

Generated by: LCOV version 1.14