-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
changed deviator trace assertion #2044
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing the norms and using the diagonal is definitely better.
@@ -16,7 +16,7 @@ double Invariants<KelvinVectorSize>::equivalentStress( | |||
Eigen::Matrix<double, KelvinVectorSize, 1> const& deviatoric_v) | |||
{ | |||
assert(std::abs(trace(deviatoric_v)) <= | |||
1e-16 * std::abs(deviatoric_v.squaredNorm())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deviatoric_v
is a column vector, so deviatoric_v.diagonal()
is only the first entry of that vector. Is that intended?
Does this small check lead to failing tests/simulations and therefore has to be changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like I made a mistake ;)
8530d67
to
a91d074
Compare
Used diagonal of tensor and fixed norm
a91d074
to
c462da9
Compare
Rebased to the master having the Kelvin vectors in the MathLib. Fixed the getting of the diagonal. |
/// Trace of the corresponding tensor. | ||
template <int KelvinVectorSize> | ||
double Invariants<KelvinVectorSize>::trace( | ||
Eigen::Matrix<double, KelvinVectorSize, 1> const& v) | ||
{ | ||
return v.template topLeftCorner<3, 1>().sum(); | ||
return diagonal(v).sum(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The former solution might have been more efficient, because diagonal()
creates a temporary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I'll check this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there is no temporary. I made a small setup
KelvinVectorType<3> const kv = KelvinVectorType<3>::Random();
Invariants<6> const invariants;
volatile double t = invariants.trace(kv);
and changed the implementation of trace btw. topLeftCorner and diagonal. There is no difference in the assembly code (in release mode).
I'd guess that because the diagonal method is inline (being a template), or return value optimization works, or both....
Anyway no difference.
If there are no further comments, I'll merge it tonight.
OpenGeoSys development has been moved to GitLab. |
Used diagonal of tensor and fixed norm