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

Generated by: LCOV version 1.14