Skip to content

Commit

Permalink
MAINT: Moved the computation of the determinants from tardigradeVecto…
Browse files Browse the repository at this point in the history
…rTools to Eigen::Map
  • Loading branch information
NateAM committed Mar 27, 2024
1 parent 9a27fb5 commit ce114ab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/sphinx/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Internal Changes
================
- Changed the fuzzyEquals in the tests to use BOOST_TEST (:pull:`7`). By `Nathan Miller`_.
- Completed first pass of improving the computational efficiency (:pull:`9`). By `Nathan Miller`_.
- Moved the computation of the determinants to exposed Eigen::Map rather than tardigradeVectorTools (:pull:`10`). By `Nathan Miller`_.

Breaking changes
================
Expand Down
18 changes: 12 additions & 6 deletions src/cpp/tardigrade_micromorphic_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,8 @@ namespace tardigradeMicromorphicTools{

microStress = variableVector( dim * dim, 0 );

detF = tardigradeVectorTools::determinant( deformationGradient, dim, dim );
Eigen::Map< const Eigen::Matrix< variableType, dim, dim, Eigen::RowMajor > > map( deformationGradient.data( ), dim, dim );
detF = map.determinant( );

microStress = tardigradeVectorTools::matrixMultiply( deformationGradient, referenceMicroStress, dim, dim, dim, dim );
microStress = tardigradeVectorTools::matrixMultiply( microStress, deformationGradient, dim, dim, dim, dim, false, true );
Expand Down Expand Up @@ -724,7 +725,7 @@ namespace tardigradeMicromorphicTools{
return result;
}

//Assemble the jacobian of the determinant of the deformation gradient
//Assemble the inverse deformation gradient
variableVector inverseDeformationGradient = deformationGradient;
Eigen::Map< Eigen::Matrix< variableType, dim, dim, Eigen::RowMajor > > map( inverseDeformationGradient.data( ), dim, dim );
map = map.inverse( ).eval( );
Expand Down Expand Up @@ -826,7 +827,9 @@ namespace tardigradeMicromorphicTools{

referenceMicroStress = variableVector( dim * dim, 0 );

detF = tardigradeVectorTools::determinant( deformationGradient, dim, dim );
Eigen::Map< const Eigen::Matrix< variableType, dim, dim, Eigen::RowMajor > > cmap( deformationGradient.data( ), dim, dim );
detF = cmap.determinant( );

inverseDeformationGradient = deformationGradient;
Eigen::Map< Eigen::Matrix< variableType, dim, dim, Eigen::RowMajor > > map( inverseDeformationGradient.data( ), dim, dim );
map = map.inverse( ).eval( );
Expand Down Expand Up @@ -1025,7 +1028,8 @@ namespace tardigradeMicromorphicTools{
return new errorNode( "pushForwardHigherOrderStress", "The micro-deformation doesn't have the correct size" );
}

detF = tardigradeVectorTools::determinant( deformationGradient, dim, dim );
Eigen::Map< const Eigen::Matrix< variableType, dim, dim, Eigen::RowMajor > > map( deformationGradient.data( ), dim, dim );
detF = map.determinant( );

higherOrderStress = variableVector( dim * dim * dim, 0 );

Expand Down Expand Up @@ -1176,7 +1180,7 @@ namespace tardigradeMicromorphicTools{
return result;
}

//Assemble the jacobian of the determinant of the deformation gradient
//Assemble the inverse of the deformation gradient
variableVector inverseDeformationGradient = deformationGradient;
Eigen::Map< Eigen::Matrix< variableType, dim, dim, Eigen::RowMajor > > map( inverseDeformationGradient.data( ), dim, dim );
map = map.inverse( ).eval( );
Expand Down Expand Up @@ -1299,7 +1303,9 @@ namespace tardigradeMicromorphicTools{
return new errorNode( "pushForwardHigherOrderStress", "The micro-deformation doesn't have the correct size" );
}

detF = tardigradeVectorTools::determinant( deformationGradient, dim, dim );
Eigen::Map< const Eigen::Matrix< variableType, dim, dim, Eigen::RowMajor > > cmap( deformationGradient.data( ), dim, dim );
detF = cmap.determinant( );

inverseDeformationGradient = deformationGradient;
Eigen::Map< Eigen::Matrix< variableType, dim, dim, Eigen::RowMajor > > map( inverseDeformationGradient.data( ), dim, dim );
map = map.inverse( ).eval( );
Expand Down

0 comments on commit ce114ab

Please sign in to comment.