LCOV - code coverage report
Current view: top level - include/userobjects - AbaqusUserElement.h (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 4 4 100.0 %
Date: 2025-07-25 05:00:39 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             : #include "GeneralUserObject.h"
      13             : #include "BlockRestrictable.h"
      14             : #include "TaggingInterface.h"
      15             : #include "DynamicLibraryLoader.h"
      16             : 
      17             : class MooseMesh;
      18             : namespace libMesh
      19             : {
      20             : class Elem;
      21             : class MeshBase;
      22             : }
      23             : 
      24             : /**
      25             :  * This user-object is a testbed for implementing a custom element.
      26             :  */
      27             : class AbaqusUserElement : public GeneralUserObject,
      28             :                           public BlockRestrictable,
      29             :                           public TaggingInterface
      30             : {
      31             : public:
      32             :   /// function type for the external UMAT function
      33             :   typedef void (*uel_t)(
      34             :       Real RHS[],    // (MLVARX,*)      Residual vector contribution for the current element
      35             :       Real AMATRX[], // (NDOFEL,NDOFEL) Jacobian contribution for the current element
      36             :       Real SVARS[],  // (NSVARS)        Persistent state variable values for the current element
      37             :       Real ENERGY[], // (8)             Energy quantities at the start of the current
      38             :                      //                 increment (to be updated by the UEL routine)
      39             :       int * NDOFEL,  // Number of degrees of freedom (DOFs) for the current element
      40             :       int * NRHS,    // NRHS=1: RHS should contain the residual vector,
      41             :                      // NRHS=2: not implemented (modified Riks static procedure)
      42             :       int * NSVARS,  // Number of persistent state variables for the element
      43             :       Real PROPS[],  // (NPROPS) Static property values (parameters) defined for use with this
      44             :                      // element.
      45             :       int * NPROPS,  //
      46             :       Real COORDS[], // (MCRD,NNODE) Undisplaced coordinates of the element nodes
      47             :                      //              COORDS(K1,K2) is the K1th coordinate of the
      48             :                      //              K2th node of the element
      49             :       int * MCRD,  // Maximum number of coordinates needed at any node point (COORDINATES keyword -
      50             :                    // unsupported)
      51             :       int * NNODE, // Number of nodes in the current element
      52             :       Real U[],    // (NDOFEL)   Total values of the variables
      53             :       Real DU[],   // (MLVARX,*) Incremental values of the variables for the current increment
      54             :                    //            for right-hand-side
      55             :       Real V[],    // (NDOFEL) Time rate of change of the variables (velocities,
      56             :                    //          rates of rotation). Defined for implicit dynamics only (LFLAGS(1)
      57             :                    //          11 or 12)
      58             :       Real A[],    // (NDOFEL) Accelerations of the variables. Defined for implicit dynamics
      59             :                    //          only (LFLAGS(1) 11 or 12).
      60             :       int * JTYPE, // Integer defining the element type. This is the user-defined integer value n in
      61             :                    // element type Un
      62             :       Real TIME[], // (2) step time and total time
      63             :       Real * DTIME,  // Time increment
      64             :       int * KSTEP,   // Step number (as per Abaqus definition) can be set by the user
      65             :       int * KINC,    // Increment number (MOOSE time step)
      66             :       int * JELEM,   // User-defined element number
      67             :       Real PRAMS[],  // (*) parameters associated with the solution procedure
      68             :       int * NDLOAD,  // Number of applied loads to the element (unused)
      69             :       int JDLTYP[],  // (MDLOAD, *) array containing the integers used to define distributed load
      70             :                      //             types for the element
      71             :       Real ADLMAG[], // (MDLOAD,*)
      72             :       Real PREDEF[], // (2,NPREDF,NNODE) predefined field variables, such as temperature in an
      73             :                      //                  uncoupled stress/displacement analysis
      74             :       int * NPREDF,  // Number of predefined field (auxiliary) variables, including temperature
      75             :       int LFLAGS[],  // (*) flags that define the current solution procedure
      76             :       int * MLVARX,  // used when several displacement or right-hand-side vectors are used
      77             :       Real DDLMAG[], // (MDLOAD,*)
      78             :       int * MDLOAD,  // Total number of distributed loads and/or fluxes defined on this element
      79             :       Real * PNEWDT, // Recommended new timestep (unused)
      80             :       int JPROPS[],  // (NJPROP) NJPROP integer property values defined for the current element
      81             :       int * NJPROP,  // Number of user defined integer properties
      82             :       Real * PERIOD  // Current step time period (unused)
      83             :   );
      84             : 
      85             :   static InputParameters validParams();
      86             :   AbaqusUserElement(const InputParameters & params);
      87             : 
      88             :   virtual void initialSetup() override;
      89             :   virtual void meshChanged() override;
      90             : 
      91             :   virtual void initialize() override final;
      92             :   virtual void execute() override;
      93        1874 :   virtual void finalize() override final {}
      94             : 
      95             :   /// getters for the loop class
      96        1424 :   const std::vector<const MooseVariableFieldBase *> & getVariables() const { return _variables; }
      97             :   const std::vector<const MooseVariableFieldBase *> & getAuxVariables() const
      98             :   {
      99        1424 :     return _aux_variables;
     100             :   }
     101             : 
     102        1424 :   const uel_t & getPlugin() const { return _uel; }
     103             : 
     104             : protected:
     105             :   /// setup the range of elements this object operates on
     106             :   void setupElemRange();
     107             : 
     108             :   /// The plugin file name
     109             :   FileName _plugin;
     110             : 
     111             :   /// The plugin library wrapper
     112             :   DynamicLibraryLoader _library;
     113             : 
     114             :   /// Function pointer to the dynamically loaded function
     115             :   const uel_t _uel;
     116             : 
     117             :   /// The \p MooseMesh that this user object operates on
     118             :   MooseMesh & _moose_mesh;
     119             : 
     120             :   /// The \p libMesh mesh that this object acts on
     121             :   const libMesh::MeshBase & _mesh;
     122             : 
     123             :   /// The dimension of the mesh, e.g. 3 for hexes and tets, 2 for quads and tris
     124             :   const unsigned int _dim;
     125             : 
     126             :   /// coupled variables to provide the DOF values
     127             :   std::vector<NonlinearVariableName> _variable_names;
     128             : 
     129             :   /// Auxiliary variable names
     130             :   std::vector<AuxVariableName> _aux_variable_names;
     131             : 
     132             :   /// pointers to the variable objects
     133             :   std::vector<const MooseVariableFieldBase *> _variables;
     134             : 
     135             :   /// pointers to the auxiliary variable objects
     136             :   std::vector<const MooseVariableFieldBase *> _aux_variables;
     137             : 
     138             :   /// The subdomain ids this object operates on
     139             :   const std::set<SubdomainID> _sub_ids;
     140             : 
     141             :   /// All the active and elements local to this process that exist on this object's subdomains
     142             :   std::unique_ptr<ConstElemRange> _elem_range;
     143             : 
     144             :   /// props
     145             :   std::vector<Real> _props;
     146             :   int _nprops;
     147             : 
     148             :   /// stateful data
     149             :   int _nstatev;
     150             :   std::array<std::map<dof_id_type, std::vector<Real>>, 2> _statev;
     151             :   std::size_t _statev_index_current;
     152             :   std::size_t _statev_index_old;
     153             : 
     154             :   /// Abaqus element type
     155             :   const int _jtype;
     156             : 
     157             :   friend class UELThread;
     158             : };

Generated by: LCOV version 1.14