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 : virtual void timestepSetup() override;
91 :
92 : virtual void initialize() override final;
93 : virtual void execute() override;
94 1731 : virtual void finalize() override final {}
95 :
96 : /// getters for the loop class
97 1731 : const std::vector<const MooseVariableFieldBase *> & getVariables() const { return _variables; }
98 : const std::vector<const MooseVariableFieldBase *> & getAuxVariables() const
99 : {
100 1731 : return _aux_variables;
101 : }
102 :
103 1731 : const uel_t & getPlugin() const { return _uel; }
104 :
105 : protected:
106 : /// setup the range of elements this object operates on
107 : void setupElemRange();
108 :
109 : /// The plugin file name
110 : FileName _plugin;
111 :
112 : /// The plugin library wrapper
113 : DynamicLibraryLoader _library;
114 :
115 : /// Function pointer to the dynamically loaded function
116 : const uel_t _uel;
117 :
118 : /// The \p MooseMesh that this user object operates on
119 : MooseMesh & _moose_mesh;
120 :
121 : /// The \p libMesh mesh that this object acts on
122 : const libMesh::MeshBase & _mesh;
123 :
124 : /// The dimension of the mesh, e.g. 3 for hexes and tets, 2 for quads and tris
125 : const unsigned int _dim;
126 :
127 : /// coupled variables to provide the DOF values
128 : std::vector<NonlinearVariableName> _variable_names;
129 :
130 : /// Auxiliary variable names
131 : std::vector<AuxVariableName> _aux_variable_names;
132 :
133 : /// pointers to the variable objects
134 : std::vector<const MooseVariableFieldBase *> _variables;
135 :
136 : /// pointers to the auxiliary variable objects
137 : std::vector<const MooseVariableFieldBase *> _aux_variables;
138 :
139 : /// The subdomain ids this object operates on
140 : const std::set<SubdomainID> _sub_ids;
141 :
142 : /// All the active and elements local to this process that exist on this object's subdomains
143 : std::unique_ptr<ConstElemRange> _elem_range;
144 :
145 : /// props
146 : std::vector<Real> _props;
147 : int _nprops;
148 :
149 : /// stateful data
150 : int _nstatev;
151 : std::array<std::map<dof_id_type, std::vector<Real>>, 2> _statev;
152 : std::size_t _statev_index_current;
153 : std::size_t _statev_index_old;
154 : int & _t_step_old;
155 :
156 : /// Abaqus element type
157 : const int _jtype;
158 :
159 : friend class UELThread;
160 : };
|