Skip to content

Commit

Permalink
Merge pull request #41 from UCBoulder/feat/add-cohesion-calculation
Browse files Browse the repository at this point in the history
Feat/add cohesion calculation
  • Loading branch information
NateAM committed Jan 5, 2024
2 parents bc8bbaa + 372d775 commit 6eb4a9c
Show file tree
Hide file tree
Showing 4 changed files with 749 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/sphinx/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Internal Changes
- Added the calculation of the driving stress for the micromorphic Drucker-Prager plasticity residual (:pull:`38`). By `Nathan Miller`_.
- Added the decomposition of the parameter vector (:pull:`39`). By `Nathan Miller`_.
- Added the extraction of the nonlinear state variables (:pull:`40`). By `Nathan Miller`_.
- Added the calculation of the cohesion (:pull:`41`). By `Nathan Miller`_.

******************
0.3.0 (01-03-2023)
Expand Down
289 changes: 289 additions & 0 deletions src/cpp/tardigrade_hydraMicromorphicDruckerPragerPlasticity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,23 @@ namespace tardigradeHydra{
*
* :param const std::vector< double > &parameters: The incoming parameter vector
* :param parameterVector &macroHardeningParameters: The parameters used in the hardening of the macro Strain ISV
* (initial cohesion, hardening modulus)
* :param parameterVector &microHardeningParameters: The parameters used in the hardening of the micro Strain ISV
* (initial cohesion, hardening modulus)
* :param parameterVector &microGradientHardeningParameters: The parameters used in the hardening of the micro Gradient Strain ISV
* (initial cohesion, hardening modulus)
* :param parameterVector &macroFlowParameters: The parameters used in the macro flow direction computation.
* (friction angle, beta )
* :param parameterVector &microFlowParameters: The parameters used in the micro flow direction computation
* (friction angle, beta )
* :param parameterVector &microGradientFlowParameters: The parameters used in the micro Gradient flow direction computation.
* (friction angle, beta )
* :param parameterVector &macroYieldParameters: The parameters used in the macro yielding computation.
* (friction angle, beta )
* :param parameterVector &microYieldParameters: The parameters used in the micro yielding computation
* (friction angle, beta )
* :param parameterVector &microGradientYieldParameters: The parameters used in the micro Gradient yielding computation.
* (friction angle, beta )
*/

if ( parameters.size() == 0 ){
Expand Down Expand Up @@ -832,6 +841,286 @@ namespace tardigradeHydra{

}

void residual::setMacroCohesion( ){
/*!
* Set the macro cohesion
*/

setCohesions( false );

}

void residual::setMicroCohesion( ){
/*!
* Set the micro cohesion
*/

setCohesions( false );

}

void residual::setMicroGradientCohesion( ){
/*!
* Set the micro gradient cohesion
*/

setCohesions( false );

}

void residual::setPreviousMacroCohesion( ){
/*!
* Set the previous macro cohesion
*/

setCohesions( true );

}

void residual::setPreviousMicroCohesion( ){
/*!
* Set the previous macro cohesion
*/

setCohesions( true );

}

void residual::setPreviousMicroGradientCohesion( ){
/*!
* Set the micro gradient cohesion
*/

setCohesions( true );

}

void residual::setCohesions( const bool isPrevious ){
/*!
* Set the values of the cohesion
*
* \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( ) ) );

}
)

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

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

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

if ( isPrevious ){

set_previousMacroCohesion( macroCohesion );

set_previousMicroCohesion( microCohesion );

set_previousMicroGradientCohesion( microGradientCohesion );

}
else{

set_macroCohesion( macroCohesion );

set_microCohesion( microCohesion );

set_microGradientCohesion( microGradientCohesion );

}

}

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 );

}

}

}

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

virtual void setPlasticStrainLikeISVs( const bool isPrevious );

virtual void setMacroCohesion( );

virtual void setMicroCohesion( );

virtual void setMicroGradientCohesion( );

virtual void setPreviousMacroCohesion( );

virtual void setPreviousMicroCohesion( );

virtual void setPreviousMicroGradientCohesion( );

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 @@ -295,6 +323,30 @@ namespace tardigradeHydra{

TARDIGRADE_HYDRA_DECLARE_PREVIOUS_STORAGE( private, previousPlasticStateVariables, floatVector, setPreviousPlasticStateVariables )

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 6eb4a9c

Please sign in to comment.