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 256 : AbaqusUExternalDB::validParams() 20 : { 21 256 : InputParameters params = ThreadedGeneralUserObject::validParams(); 22 256 : params.addClassDescription("Coupling user object to use Abaqus UEXTERNALDB subroutines in MOOSE"); 23 512 : params.addRequiredParam<FileName>( 24 : "plugin", "The path to the compiled dynamic library for the plugin you want to use"); 25 512 : params.addParam<UserObjectName>( 26 : "analysis_step_user_object", 27 : "The AnalysisStepUserObject that provides times from simulation loading steps."); 28 256 : 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 152 : AbaqusUExternalDB::AbaqusUExternalDB(const InputParameters & parameters) 36 : : ThreadedGeneralUserObject(parameters), 37 304 : _plugin(getParam<FileName>("plugin")), 38 304 : _library(_plugin + std::string("-") + QUOTE(METHOD) + ".plugin"), 39 152 : _uexternaldb(_library.getFunction<uexternaldb_t>("uexternaldb_")), 40 152 : _aqSTEP(0), 41 304 : _current_execute_on_flag(_fe_problem.getCurrentExecuteOnFlag()) 42 : { 43 152 : AbaqusUtils::setInputFile(_app.getLastInputFileName()); 44 152 : AbaqusUtils::setCommunicator(&_communicator); 45 152 : } 46 : 47 : void 48 152 : 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 304 : if (!isParamSetByUser("analysis_step_user_object")) 53 152 : getAnalysisStepUserObject(_fe_problem, _step_user_object, name()); 54 : else 55 0 : _step_user_object = &getUserObject<AnalysisStepUserObject>("analysis_step_user_object"); 56 152 : } 57 : 58 : void 59 568 : AbaqusUExternalDB::execute() 60 : { 61 : // Obtain step number if user object was coupled (beginning of increment) 62 568 : if (_step_user_object) 63 118 : _aqSTEP = _step_user_object->getStep(_t - _dt); 64 : 65 568 : if (_current_execute_on_flag == EXEC_INITIAL) 66 120 : callPlugin(0); 67 : 68 : // TODO support 2 -> trigger saving for restart 69 : 70 568 : if (_current_execute_on_flag == EXEC_FINAL) 71 102 : callPlugin(3); 72 : 73 568 : if (_current_execute_on_flag == EXEC_TIMESTEP_BEGIN) 74 150 : callPlugin(1); 75 : 76 568 : if (_current_execute_on_flag == EXEC_TIMESTEP_END) 77 196 : callPlugin(2); 78 566 : } 79 : 80 : void 81 568 : AbaqusUExternalDB::callPlugin(int lop) 82 : { 83 568 : Real time[2] = {_t, _t - _dt}; 84 568 : int lrestart = 0; 85 : 86 : // call plugin function 87 568 : _uexternaldb(&lop, &lrestart, time, &_dt, &_aqSTEP, &_t_step); 88 566 : }