Skip to content

Commit

Permalink
MAINT: Removed all calls to errorOut
Browse files Browse the repository at this point in the history
  • Loading branch information
NateAM committed Nov 25, 2024
1 parent f2dc1cb commit e821924
Show file tree
Hide file tree
Showing 5 changed files with 360 additions and 376 deletions.
80 changes: 34 additions & 46 deletions src/cpp/tardigrade_hydra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1315,13 +1315,10 @@ namespace tardigradeHydra{

/// Say hello
/// @param message The message to print
errorOut sayHello( std::string message ) {
if ( message.compare( "George" ) == 0 ){
errorOut result = new errorNode( __func__, "ERROR: George is a wolf in sheep's clothing!");
return result;
}
void sayHello( std::string message ) {
TARDIGRADE_ERROR_TOOLS_CHECK( ( message.compare( "George" ) != 0 ), "ERROR: George is a wolf in sheep's clothing!");
std::cout << "Hello " << message << std::endl;
return NULL;
return;
}

const floatVector* hydraBase::getStress( ){
Expand Down Expand Up @@ -2915,31 +2912,24 @@ namespace tardigradeHydra{

}

errorOut dummyMaterialModel( floatVector &stress, floatVector &statev, floatMatrix &ddsdde, floatType &SSE, floatType &SPD,
floatType &SCD, floatType &RPL, floatVector &ddsddt, floatVector &drplde, floatType &DRPLDT,
const floatVector &strain, const floatVector &dstrain, const floatVector &time, const floatType &DTIME, const floatType &TEMP,
const floatType &DTEMP, const floatVector &predef, const floatVector &dpred, const std::string &cmname, const int &NDI,
const int &NSHR, const int &NTENS, const int &NSTATV, const floatVector &props, const int &NPROPS,
const floatVector &coords, const floatMatrix &drot, floatType &PNEWDT, const floatType &CELENT, const floatMatrix &dfgrd0,
const floatMatrix &dfgrd1, const int &NOEL, const int &NPT, const int &LAYER, const int &KSPT,
const std::vector< int > &jstep, const int &KINC ){
void dummyMaterialModel( floatVector &stress, floatVector &statev, floatMatrix &ddsdde, floatType &SSE, floatType &SPD,
floatType &SCD, floatType &RPL, floatVector &ddsddt, floatVector &drplde, floatType &DRPLDT,
const floatVector &strain, const floatVector &dstrain, const floatVector &time, const floatType &DTIME, const floatType &TEMP,
const floatType &DTEMP, const floatVector &predef, const floatVector &dpred, const std::string &cmname, const int &NDI,
const int &NSHR, const int &NTENS, const int &NSTATV, const floatVector &props, const int &NPROPS,
const floatVector &coords, const floatMatrix &drot, floatType &PNEWDT, const floatType &CELENT, const floatMatrix &dfgrd0,
const floatMatrix &dfgrd1, const int &NOEL, const int &NPT, const int &LAYER, const int &KSPT,
const std::vector< int > &jstep, const int &KINC ){
/*!
* A template Abaqus c++ UMAT using c++ STL types. Variables in all caps reference ABAQUS FORTRAN
* memory directly. Variables in lower case are native c++ type conversions stored separately from the original
* ABAQUS FORTRAN memory.
*/

//Call functions of constitutive model to do things
errorOut error = sayHello( "Abaqus" );

//Error handling
if ( error ){
errorOut result = new errorNode( __func__, "Error when calling sayHello" );
result->addNext( error );
return result;
}
TARDIGRADE_ERROR_TOOLS_CATCH( sayHello( "Abaqus" ) );

return NULL;
return;
}

void abaqusInterface( double *STRESS, double *STATEV, double *DDSDDE, double &SSE, double &SPD,
Expand All @@ -2955,9 +2945,6 @@ namespace tardigradeHydra{
* model's expected input, handles tensor shape changes, and calls a c++ material model.
*/

//Initialize error return codes
errorOut error = NULL;

//Provide a variable string message for error nodes
std::ostringstream message;

Expand Down Expand Up @@ -3001,26 +2988,27 @@ namespace tardigradeHydra{

//Call the constitutive model c++ interface
if ( KINC == 1 && NOEL == 1 && NPT == 1 ){
error = dummyMaterialModel( stress, statev, ddsdde, SSE, SPD,
SCD, RPL, ddsddt, drplde, DRPLDT,
strain, dstrain, time, DTIME, TEMP,
DTEMP, predef, dpred, cmname, NDI,
NSHR, NTENS, NSTATV, props, NPROPS,
coords, drot, PNEWDT, CELENT, dfgrd0,
dfgrd1, NOEL, NPT, LAYER, KSPT,
jstep, KINC );
}

//Error handling
if ( error ){
message.clear();
message << "ERROR:" << __FILENAME__ << "." << __func__ << ": Error when calling dummyMaterialModel.";
errorOut result = new errorNode( __func__, message.str( ) );
result->addNext( error );
error->print( true );
//If an error was thrown, but the ratio of new/current time increment is not updated, it was a fatal error.
if ( PNEWDT >= 1. ){
throw std::runtime_error( message.str( ) );

try{

dummyMaterialModel( stress, statev, ddsdde, SSE, SPD,
SCD, RPL, ddsddt, drplde, DRPLDT,
strain, dstrain, time, DTIME, TEMP,
DTEMP, predef, dpred, cmname, NDI,
NSHR, NTENS, NSTATV, props, NPROPS,
coords, drot, PNEWDT, CELENT, dfgrd0,
dfgrd1, NOEL, NPT, LAYER, KSPT,
jstep, KINC );

}
catch(std::exception &e){

if ( PNEWDT >= 1. ){

throw e;

}

}
}

Expand Down
6 changes: 2 additions & 4 deletions src/cpp/tardigrade_hydra.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ namespace tardigradeHydra{
const std::string __BASENAME__ = file_name(__FILE__); //!< The base filename which will be parsed
const std::string __FILENAME__ = __BASENAME__.substr(0, __BASENAME__.find_last_of(".")); //!< The parsed filename for error handling

typedef tardigradeErrorTools::Node errorNode; //!< Redefinition for the error node
typedef errorNode* errorOut; //!< Redefinition for a pointer to the error node
typedef double floatType; //!< Define the float values type.
typedef std::vector< floatType > floatVector; //!< Define a vector of floats
typedef std::vector< std::vector< floatType > > floatMatrix; //!< Define a matrix of floats
Expand Down Expand Up @@ -2046,7 +2044,7 @@ namespace tardigradeHydra{

/// Say hello
/// @param message The message to print
errorOut sayHello(std::string message);
void sayHello(std::string message);

void abaqusInterface( double *STRESS, double *STATEV, double *DDSDDE, double &SSE, double &SPD,
double &SCD, double &RPL, double *DDSDDT, double *DRPLDE, double &DRPLDT,
Expand All @@ -2057,7 +2055,7 @@ namespace tardigradeHydra{
const double *DFGRD1, const int &NOEL, const int &NPT, const int &LAYER, const int &KSPT,
const int *JSTEP, const int &KINC );

errorOut dummyMaterialModel( floatVector &stress, floatVector &statev, floatMatrix &ddsdde, floatType &SSE, floatType &SPD,
void dummyMaterialModel( floatVector &stress, floatVector &statev, floatMatrix &ddsdde, floatType &SSE, floatType &SPD,
floatType &SCD, floatType &RPL, floatVector &ddsddt, floatVector &drplde, floatType &DRPLDT,
const floatVector &strain, const floatVector &dstrain, const floatVector &time, const floatType &DTIME, const floatType &TEMP,
const floatType &DTEMP, const floatVector &predef, const floatVector &dpred, const std::string &cmname, const int &NDI,
Expand Down
Loading

0 comments on commit e821924

Please sign in to comment.