LCOV - code coverage report
Current view: top level - src/userobjects - AbaqusUExternalDB.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #32971 (54bef8) with base c6cf66 Lines: 36 38 94.7 %
Date: 2026-05-29 20:40:07 Functions: 5 5 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             : #include "AbaqusUExternalDB.h"
      11             : #include "AbaqusUtils.h"
      12             : #include "AnalysisStepUserObject.h"
      13             : 
      14             : #define QUOTE(macro) stringifyName(macro)
      15             : 
      16             : registerMooseObject("SolidMechanicsApp", AbaqusUExternalDB);
      17             : 
      18             : InputParameters
      19         128 : AbaqusUExternalDB::validParams()
      20             : {
      21         128 :   InputParameters params = ThreadedGeneralUserObject::validParams();
      22         128 :   params.addClassDescription("Coupling user object to use Abaqus UEXTERNALDB subroutines in MOOSE");
      23         256 :   params.addRequiredParam<FileName>(
      24             :       "plugin", "The path to the compiled dynamic library for the plugin you want to use");
      25         256 :   params.addParam<UserObjectName>(
      26             :       "analysis_step_user_object",
      27             :       "The AnalysisStepUserObject that provides times from simulation loading steps.");
      28         128 :   return params;
      29           0 : }
      30             : 
      31             : #ifndef METHOD
      32             : #error "The METHOD preprocessor symbol must be supplied by the build system."
      33             : #endif
      34             : 
      35          76 : AbaqusUExternalDB::AbaqusUExternalDB(const InputParameters & parameters)
      36             :   : ThreadedGeneralUserObject(parameters),
      37         152 :     _plugin(getParam<FileName>("plugin")),
      38         152 :     _library(_plugin + std::string("-") + QUOTE(METHOD) + ".plugin"),
      39          76 :     _uexternaldb(_library.getFunction<uexternaldb_t>("uexternaldb_")),
      40          76 :     _aqSTEP(0),
      41         152 :     _current_execute_on_flag(_fe_problem.getCurrentExecuteOnFlag())
      42             : {
      43          76 :   AbaqusUtils::setInputFile(_app.getLastInputFileName());
      44          76 :   AbaqusUtils::setCommunicator(&_communicator);
      45          76 : }
      46             : 
      47             : void
      48          76 : AbaqusUExternalDB::initialSetup()
      49             : {
      50             :   // Let's automatically detect uos and identify the one we are interested in.
      51             :   // If there is more than one, we assume something is off and error out.
      52         152 :   if (!isParamSetByUser("analysis_step_user_object"))
      53          76 :     getAnalysisStepUserObject(_fe_problem, _step_user_object, name());
      54             :   else
      55           0 :     _step_user_object = &getUserObject<AnalysisStepUserObject>("analysis_step_user_object");
      56          76 : }
      57             : 
      58             : void
      59         284 : AbaqusUExternalDB::execute()
      60             : {
      61             :   // Obtain step number if user object was coupled (beginning of increment)
      62         284 :   if (_step_user_object)
      63          59 :     _aqSTEP = _step_user_object->getStep(_t - _dt);
      64             : 
      65         284 :   if (_current_execute_on_flag == EXEC_INITIAL)
      66          60 :     callPlugin(0);
      67             : 
      68             :   // TODO support 2 -> trigger saving for restart
      69             : 
      70         284 :   if (_current_execute_on_flag == EXEC_FINAL)
      71          51 :     callPlugin(3);
      72             : 
      73         284 :   if (_current_execute_on_flag == EXEC_TIMESTEP_BEGIN)
      74          75 :     callPlugin(1);
      75             : 
      76         284 :   if (_current_execute_on_flag == EXEC_TIMESTEP_END)
      77          98 :     callPlugin(2);
      78         283 : }
      79             : 
      80             : void
      81         284 : AbaqusUExternalDB::callPlugin(int lop)
      82             : {
      83         284 :   Real time[2] = {_t, _t - _dt};
      84         284 :   int lrestart = 0;
      85             : 
      86             :   // call plugin function
      87         284 :   _uexternaldb(&lop, &lrestart, time, &_dt, &_aqSTEP, &_t_step);
      88         283 : }

Generated by: LCOV version 1.14