Skip to content
Snippets Groups Projects
Commit c462da9c authored by Norbert Grunwald's avatar Norbert Grunwald Committed by Dmitri Naumov
Browse files

changed deviator trace assertion

Used diagonal of tensor and fixed norm
parent 0cbfc9af
No related branches found
No related tags found
No related merge requests found
......@@ -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()));
5e-14 * diagonal(deviatoric_v).norm());
return std::sqrt(3 * J2(deviatoric_v));
}
......@@ -25,7 +25,7 @@ double Invariants<KelvinVectorSize>::J2(
Eigen::Matrix<double, KelvinVectorSize, 1> const& deviatoric_v)
{
assert(std::abs(trace(deviatoric_v)) <=
1e-16 * std::abs(deviatoric_v.squaredNorm()));
5e-14 * diagonal(deviatoric_v).norm());
return 0.5 * deviatoric_v.transpose() * deviatoric_v;
}
......@@ -36,16 +36,23 @@ double Invariants<KelvinVectorSize>::J3(
Eigen::Matrix<double, KelvinVectorSize, 1> const& deviatoric_v)
{
assert(std::abs(trace(deviatoric_v)) <=
1e-16 * std::abs(deviatoric_v.squaredNorm()));
5e-14 * diagonal(deviatoric_v).norm());
return determinant(deviatoric_v);
}
template <int KelvinVectorSize>
Eigen::Vector3d Invariants<KelvinVectorSize>::diagonal(
Eigen::Matrix<double, KelvinVectorSize, 1> const& v)
{
return v.template topLeftCorner<3, 1>();
}
/// 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();
}
//
......
......@@ -99,6 +99,11 @@ struct Invariants final
/// Trace of the corresponding tensor.
static double trace(Eigen::Matrix<double, KelvinVectorSize, 1> const& v);
/// Diagonal of the corresponding tensor which is always of length 3 in 2D
/// and 3D cases.
static Eigen::Vector3d diagonal(
Eigen::Matrix<double, KelvinVectorSize, 1> const& v);
};
//
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment