Skip to content

Commit

Permalink
Merge pull request #178 from UCBoulder/feat/add-subcycling-scale-factor
Browse files Browse the repository at this point in the history
FEAT: Added scale factor to the driving values
  • Loading branch information
NateAM authored Oct 8, 2024
2 parents e8d904e + a1a0f64 commit c7a77bc
Show file tree
Hide file tree
Showing 7 changed files with 567 additions and 12 deletions.
2 changes: 2 additions & 0 deletions docs/sphinx/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ New Features
- Added softened cohesion function (:pull:`169`). By `Nathan Miller`_.
- Added the minimum cohesion and softening ratio as optional parameters to the micromorphic Drucker-Prager plasticity (:pull:`171`). By `Nathan Miller`_.
- Added a relaxed solver as the default (:pull:`172`). By `Nathan Miller`_.
- Added ability to turn on additional messages for failed solves (:pull:`177`). By `Nathan Miller`_.
- Added the ability to scale the incoming load information by a scale factor (:pull:`178`). By `Nathan Miller`_.

Internal Changes
================
Expand Down
3 changes: 3 additions & 0 deletions src/cpp/tardigrade_hydra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ namespace tardigradeHydra{
* 0. A diagonal pre-conditioner populate by the inverse of the absolute largest entries of the Jacobian's rows
*/

// Initialize the scaled-quantities
setScaledQuantities( );

// Decompose the state variable vector initializing all of the configurations
decomposeStateVariableVector( );

Expand Down
53 changes: 48 additions & 5 deletions src/cpp/tardigrade_hydra.h
Original file line number Diff line number Diff line change
Expand Up @@ -1081,25 +1081,25 @@ namespace tardigradeHydra{
const unsigned int* getConfigurationUnknownCount( ){ return &_configuration_unknown_count; }

//! Get a reference to the current time
const floatType* getTime( ){ return &_time; }
const floatType* getTime( ){ return getScaledTime( ); }

//! Get a reference to the change in time
const floatType* getDeltaTime( ){ return &_deltaTime; }
const floatType* getDeltaTime( ){ return getScaledDeltaTime( ); }

//! Get a reference to the current temperature
const floatType* getTemperature( ){ return &_temperature; };
const floatType* getTemperature( ){ return getScaledTemperature( ); };

//! Get a reference to the previous temperature
const floatType* getPreviousTemperature( ){ return &_previousTemperature; };

//! Get a reference to the deformation gradient
const secondOrderTensor* getDeformationGradient( ){ return &_deformationGradient; }
const secondOrderTensor* getDeformationGradient( ){ return getScaledDeformationGradient( ); }

//! Get a reference to the previous deformation gradient
const secondOrderTensor* getPreviousDeformationGradient( ){ return &_previousDeformationGradient; }

//! Get a reference to the additional degrees of freedom
const floatVector* getAdditionalDOF( ){ return &_additionalDOF; }
const floatVector* getAdditionalDOF( ){ return getScaledAdditionalDOF( ); }

//! Get a reference to the previous additional degrees of freedom
const floatVector* getPreviousAdditionalDOF( ){ return &_previousAdditionalDOF; }
Expand Down Expand Up @@ -1491,6 +1491,22 @@ namespace tardigradeHydra{
//! Get the failure output string
const std::string getFailureOutput( ){ return _failure_output.str( ); }

//! Get a scale factor for the deformation
const floatType *getScaleFactor( ){ return &_scale_factor; }

//! Set the value of the scale factor. Will automatically re-calculate the deformation
const void setScaleFactor( const floatType &value ){ _scale_factor = value; setScaledQuantities( ); updateUnknownVector( *getUnknownVector( ) ); }

const floatType *getScaledTime( ){ return &_scaled_time; }

const floatType *getScaledDeltaTime( ){ return &_scaled_deltaTime; }

const floatType *getScaledTemperature( ){ return &_scaled_temperature; }

const floatVector *getScaledDeformationGradient( ){ return &_scaled_deformationGradient; }

const floatVector *getScaledAdditionalDOF( ){ return &_scaled_additionalDOF; }

protected:

// Setters that the user may need to access but not override
Expand Down Expand Up @@ -1536,6 +1552,21 @@ namespace tardigradeHydra{

virtual void performGradientStep( const floatVector &X0 );

//! Update the scaled quantities
virtual void setScaledQuantities( ){

_scaled_time = ( _scale_factor - 1 ) * _deltaTime + _time;

_scaled_deltaTime = _scale_factor * _deltaTime;

_scaled_temperature = _scale_factor * ( _temperature - _previousTemperature ) + _previousTemperature;

_scaled_deformationGradient = _scale_factor * ( _deformationGradient - _previousDeformationGradient ) + _previousDeformationGradient;

_scaled_additionalDOF = _scale_factor * ( _additionalDOF - _previousAdditionalDOF ) + _previousAdditionalDOF;

}

const floatType *get_baseResidualNorm( );

const floatVector *get_basedResidualNormdX( );
Expand Down Expand Up @@ -1765,6 +1796,16 @@ namespace tardigradeHydra{

floatVector _parameters; //!< The model parameters

floatType _scaled_time; //!< The current time scaled by the scaling factor

floatType _scaled_deltaTime; //!< The change in time scaled by the scaling factor

floatType _scaled_temperature; //!< The current temperature scaled by the scaling factor

secondOrderTensor _scaled_deformationGradient; //!< The current deformation gradient scaled by the scaling factor

floatVector _scaled_additionalDOF; //!< The current additional degrees of freedom scaled by the scaling factor

unsigned int _numConfigurations; //!< The number of configurations

unsigned int _numNonLinearSolveStateVariables; //!< The number of state variables which will be solved in the Newton-Raphson loop
Expand Down Expand Up @@ -1905,6 +1946,8 @@ namespace tardigradeHydra{

std::stringstream _failure_output; //!< Additional failure output information

floatType _scale_factor = 1.0; //!< A scale factor applied to the incoming loading (deformation, temperature, etc.)

TARDIGRADE_HYDRA_DECLARE_ITERATION_STORAGE( private, configurations, floatVector, passThrough )

TARDIGRADE_HYDRA_DECLARE_PREVIOUS_STORAGE( private, previousConfigurations, floatVector, passThrough )
Expand Down
2 changes: 2 additions & 0 deletions src/cpp/tardigrade_hydraMicromorphic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ namespace tardigradeHydra{
* \param &lsAlpha: The alpha term for the line search (defaults to 1e-4)
*/

setScaledQuantities( );

decomposeStateVariableVectorMicroConfigurations( );

}
Expand Down
25 changes: 23 additions & 2 deletions src/cpp/tardigrade_hydraMicromorphic.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ namespace tardigradeHydra{
const bool use_preconditioner=false, const unsigned int preconditioner_type=0 );

//! Get the current micro-deformation tensor
const secondOrderTensor *getMicroDeformation( ){ return &_microDeformation; }
const secondOrderTensor *getMicroDeformation( ){ return getScaledMicroDeformation( ); }

//! Get the previous micro-deformation tensor
const secondOrderTensor *getPreviousMicroDeformation( ){ return &_previousMicroDeformation; }

//! Get the current spatial gradient w.r.t. the reference configuration of the micro-deformation tensor
const thirdOrderTensor *getGradientMicroDeformation( ){ return &_gradientMicroDeformation; }
const thirdOrderTensor *getGradientMicroDeformation( ){ return getScaledGradientMicroDeformation( ); }

//! Get the previous spatial gradient w.r.t. the reference configuration of the micro-deformation tensor
const thirdOrderTensor *getPreviousGradientMicroDeformation( ){ return &_previousGradientMicroDeformation; }
Expand Down Expand Up @@ -78,6 +78,10 @@ namespace tardigradeHydra{

floatVector getPreviousFollowingMicroConfigurationJacobian( const unsigned int &index );

const secondOrderTensor *getScaledMicroDeformation( ){ return &_scaled_microDeformation; }

const thirdOrderTensor *getScaledGradientMicroDeformation( ){ return &_scaled_gradientMicroDeformation; }

const floatVector *getFlatdXdD( ){
/*!
* Get the total derivative of the unknown vector w.r.t. the deformation.
Expand All @@ -101,6 +105,19 @@ namespace tardigradeHydra{

virtual void decomposeStateVariableVectorMicroConfigurations( );

virtual void setScaledQuantities( ) override{
/*!
* Scale the current values by the scale factor
*/

hydraBase::hydraBase::setScaledQuantities( );

_scaled_microDeformation = ( *getScaleFactor( ) ) * ( _microDeformation - _previousMicroDeformation ) + _previousMicroDeformation;

_scaled_gradientMicroDeformation = ( *getScaleFactor( ) ) * ( _gradientMicroDeformation - _previousGradientMicroDeformation ) + _previousGradientMicroDeformation;

}

private:

secondOrderTensor _microDeformation; //!< The current micro-deformation
Expand All @@ -111,6 +128,10 @@ namespace tardigradeHydra{

thirdOrderTensor _previousGradientMicroDeformation; //!< The previous spatial gradient of the micro-deformation w.r.t. the reference coordinates

secondOrderTensor _scaled_microDeformation; //!< The current micro-deformation scaled by the scale factor

thirdOrderTensor _scaled_gradientMicroDeformation; //!< The spatial gradient of the micro-deformation w.r.t. the reference coordinates scaled by the scale factor

void setFirstMicroConfigurationJacobians( );

void setPreviousFirstMicroConfigurationJacobians( );
Expand Down
Loading

0 comments on commit c7a77bc

Please sign in to comment.