Skip to content

Commit

Permalink
Merge pull request #168 from UCBoulder/feat/add-unknown-vector-initia…
Browse files Browse the repository at this point in the history
…lization-micromorphic

FEAT: Added custom unknown vector initialization
  • Loading branch information
NateAM authored Sep 5, 2024
2 parents 816fe3e + f1dd7ea commit 20526ba
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/sphinx/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Internal Changes
- Removed set_varname and replaced with setDataStorage for hydra mass-change rate (:pull:`162`). By `Nathan Miller`_.
- Enabled passing the tests when higher levels of optimization are used (:pull:`163`). By `Nathan Miller`_.
- Added an active set solver for quadratic problems (:pull:`167`). By `Nathan Miller`_.
- Allow for initial values to be set for the micromorphic hydra base class (:pull:`168`). By `Nathan Miller`_.

Bug Fixes
=========
Expand Down
33 changes: 32 additions & 1 deletion src/cpp/tardigrade_hydraMicromorphic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,38 @@ namespace tardigradeHydra{

std::copy( std::begin( *nonLinearSolveStateVariables ), std::end( *nonLinearSolveStateVariables ), std::begin( X ) + offset );

setX( X );
bool resetRequired = false;

for ( auto residual_ptr = getResidualClasses( )->begin( ); residual_ptr != getResidualClasses( )->end( ); residual_ptr++ ){

std::vector< unsigned int > indices;

std::vector< floatType > values;

( *residual_ptr )->suggestInitialIterateValues( indices, values );

if ( indices.size( ) > 0 ){
resetRequired = true;
}

for ( auto i = indices.begin( ); i != indices.end( ); i++ ){

X[ *i ] = values[ ( unsigned int )( i - indices.begin( ) ) ];

}

}

if ( resetRequired ){

updateUnknownVector( X );

}
else{

setX( X );

}

}

Expand Down

0 comments on commit 20526ba

Please sign in to comment.