Skip to content

Commit

Permalink
FEAT: Added the Jacobians of the cohesion w.r.t. the state variables
Browse files Browse the repository at this point in the history
  • Loading branch information
NateAM committed Jan 5, 2024
1 parent bde5faa commit 372d775
Show file tree
Hide file tree
Showing 3 changed files with 375 additions and 2 deletions.
154 changes: 154 additions & 0 deletions src/cpp/tardigrade_hydraMicromorphicDruckerPragerPlasticity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,160 @@ namespace tardigradeHydra{

}

void residual::setdMacroCohesiondStateVariables( ){
/*!
* Set the jacobian of the macro cohesion w.r.t. the nonlinear state variables
*/

setCohesionsJacobians( false );

}

void residual::setdMicroCohesiondStateVariables( ){
/*!
* Set the jacobian of the micro cohesion w.r.t. the nonlinear state variables
*/

setCohesionsJacobians( false );

}

void residual::setdMicroGradientCohesiondStateVariables( ){
/*!
* Set the jacobian of the micro gradient cohesion w.r.t. the nonlinear state variables
*/

setCohesionsJacobians( false );

}

void residual::setPreviousdMacroCohesiondStateVariables( ){
/*!
* Set the jacobians of the previous macro cohesion w.r.t. the nonlinear state variables
*/

setCohesionsJacobians( true );

}

void residual::setPreviousdMicroCohesiondStateVariables( ){
/*!
* Set the jacobians of the previous macro cohesion w.r.t. the nonlinear state variables
*/

setCohesionsJacobians( true );

}

void residual::setPreviousdMicroGradientCohesiondStateVariables( ){
/*!
* Set the jacobians of the micro gradient cohesion w.r.t. the nonlinear state variables
*/

setCohesionsJacobians( true );

}

void residual::setCohesionsJacobians( const bool isPrevious ){
/*!
* Set the values of the cohesion and their Jacobians
*
* \param isPrevious: Flag for whether to compute the current (false) or previous (true) cohesions
*/

const floatVector *plasticStrainLikeISVs;

if ( isPrevious ){

plasticStrainLikeISVs = get_previousPlasticStrainLikeISVs( );

}
else{

plasticStrainLikeISVs = get_plasticStrainLikeISVs( );

}

TARDIGRADE_ERROR_TOOLS_CATCH(
if ( get_macroHardeningParameters( )->size( ) != 2 ){

throw std::runtime_error( "The micro hardening parameters must have a length of 2 rather than " + std::to_string( get_macroHardeningParameters( )->size( ) ) );

}
)

TARDIGRADE_ERROR_TOOLS_CATCH(
if ( get_microHardeningParameters( )->size( ) != 2 ){

throw std::runtime_error( "The micro hardening parameters must have a length of 2 rather than " + std::to_string( get_microHardeningParameters( )->size( ) ) );

}
)

TARDIGRADE_ERROR_TOOLS_CATCH(
if ( get_microGradientHardeningParameters( )->size( ) != 2 ){

throw std::runtime_error( "The micro hardening parameters must have a length of 2 rather than " + std::to_string( get_microGradientHardeningParameters( )->size( ) ) );

}
)

floatVector dMacroCohesiondISVs( get_plasticStateVariables( )->size( ), 0 );

floatVector dMicroCohesiondISVs( get_plasticStateVariables( )->size( ), 0 );

floatMatrix dMicroGradientCohesiondISVs( get_plasticStrainLikeISVs( )->size( ) - 2, floatVector( get_plasticStateVariables( )->size( ), 0 ) );

floatType macroCohesion = ( *get_macroHardeningParameters( ) )[ 0 ] + ( *get_macroHardeningParameters( ) )[ 1 ] * ( *plasticStrainLikeISVs )[ 0 ];

dMacroCohesiondISVs[ get_plasticMultipliers( )->size( ) + 0 ] = ( *get_macroHardeningParameters( ) )[ 1 ];

floatType microCohesion = ( *get_microHardeningParameters( ) )[ 0 ] + ( *get_microHardeningParameters( ) )[ 1 ] * ( *plasticStrainLikeISVs )[ 1 ];

dMicroCohesiondISVs[ get_plasticMultipliers( )->size( ) + 1 ] = ( *get_microHardeningParameters( ) )[ 1 ];

floatVector microGradientCohesion = ( *get_microGradientHardeningParameters( ) )[ 0 ] + ( *get_microGradientHardeningParameters( ) )[ 1 ] * floatVector( plasticStrainLikeISVs->begin( ) + 2,
plasticStrainLikeISVs->end( ) );

for ( unsigned int i = 2; i < plasticStrainLikeISVs->size( ); i++ ){

dMicroGradientCohesiondISVs[ i - 2 ][ get_plasticMultipliers( )->size( ) + i ] = ( *get_microGradientHardeningParameters( ) )[ 1 ];

}

if ( isPrevious ){

set_previousMacroCohesion( macroCohesion );

set_previousMicroCohesion( microCohesion );

set_previousMicroGradientCohesion( microGradientCohesion );

set_previousdMacroCohesiondStateVariables( dMacroCohesiondISVs );

set_previousdMicroCohesiondStateVariables( dMicroCohesiondISVs );

set_previousdMicroGradientCohesiondStateVariables( dMicroGradientCohesiondISVs );

}
else{

set_macroCohesion( macroCohesion );

set_microCohesion( microCohesion );

set_microGradientCohesion( microGradientCohesion );

set_dMacroCohesiondStateVariables( dMacroCohesiondISVs );

set_dMicroCohesiondStateVariables( dMicroCohesiondISVs );

set_dMicroGradientCohesiondStateVariables( dMicroGradientCohesiondISVs );

}

}

}

}
26 changes: 26 additions & 0 deletions src/cpp/tardigrade_hydraMicromorphicDruckerPragerPlasticity.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@ namespace tardigradeHydra{

virtual void setCohesions( const bool isPrevious );

virtual void setdMacroCohesiondStateVariables( );

virtual void setdMicroCohesiondStateVariables( );

virtual void setdMicroGradientCohesiondStateVariables( );

virtual void setPreviousdMacroCohesiondStateVariables( );

virtual void setPreviousdMicroCohesiondStateVariables( );

virtual void setPreviousdMicroGradientCohesiondStateVariables( );

virtual void setCohesionsJacobians( const bool isPrevious );

private:

unsigned int _plasticConfigurationIndex; //! The index of the plastic configuration
Expand Down Expand Up @@ -311,16 +325,28 @@ namespace tardigradeHydra{

TARDIGRADE_HYDRA_DECLARE_ITERATION_STORAGE( private, macroCohesion, floatType, setMacroCohesion )

TARDIGRADE_HYDRA_DECLARE_ITERATION_STORAGE( private, dMacroCohesiondStateVariables, floatVector, setdMacroCohesiondStateVariables )

TARDIGRADE_HYDRA_DECLARE_ITERATION_STORAGE( private, microCohesion, floatType, setMicroCohesion )

TARDIGRADE_HYDRA_DECLARE_ITERATION_STORAGE( private, dMicroCohesiondStateVariables, floatVector, setdMicroCohesiondStateVariables )

TARDIGRADE_HYDRA_DECLARE_ITERATION_STORAGE( private, microGradientCohesion, floatVector, setMicroGradientCohesion )

TARDIGRADE_HYDRA_DECLARE_ITERATION_STORAGE( private, dMicroGradientCohesiondStateVariables, floatMatrix, setdMicroGradientCohesiondStateVariables )

TARDIGRADE_HYDRA_DECLARE_PREVIOUS_STORAGE( private, previousMacroCohesion, floatType, setPreviousMacroCohesion )

TARDIGRADE_HYDRA_DECLARE_PREVIOUS_STORAGE( private, previousdMacroCohesiondStateVariables, floatVector, setPreviousdMacroCohesiondStateVariables )

TARDIGRADE_HYDRA_DECLARE_PREVIOUS_STORAGE( private, previousMicroCohesion, floatType, setPreviousMicroCohesion )

TARDIGRADE_HYDRA_DECLARE_PREVIOUS_STORAGE( private, previousdMicroCohesiondStateVariables, floatVector, setPreviousdMicroCohesiondStateVariables )

TARDIGRADE_HYDRA_DECLARE_PREVIOUS_STORAGE( private, previousMicroGradientCohesion, floatVector, setPreviousMicroGradientCohesion )

TARDIGRADE_HYDRA_DECLARE_PREVIOUS_STORAGE( private, previousdMicroGradientCohesiondStateVariables, floatMatrix, setPreviousdMicroGradientCohesiondStateVariables )

};

}
Expand Down
Loading

0 comments on commit 372d775

Please sign in to comment.