Skip to content
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

Merged
merged 1 commit into from
Feb 20, 2018

Conversation

Scinopode
Copy link
Contributor

Used diagonal of tensor and fixed norm

Copy link
Member

@endJunction endJunction left a 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()));
Copy link
Collaborator

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?

Copy link
Member

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

Used diagonal of tensor and fixed norm
@endJunction
Copy link
Member

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();
Copy link
Collaborator

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.

Copy link
Member

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.

Copy link
Member

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.

@endJunction endJunction merged commit 1f91368 into ufz:master Feb 20, 2018
@ogsbot
Copy link
Member

ogsbot commented Jun 19, 2020

OpenGeoSys development has been moved to GitLab.

See this pull request on GitLab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants