-
Notifications
You must be signed in to change notification settings - Fork 3
Use AutoDiffScalar Concept and fix checkFESByAutoDiff test #329
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #329 +/- ##
==========================================
- Coverage 86.66% 80.86% -5.80%
==========================================
Files 69 68 -1
Lines 2234 2299 +65
==========================================
- Hits 1936 1859 -77
- Misses 298 440 +142
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
8ee9668
to
28c7f15
Compare
c8c0d6a
to
ba9070e
Compare
to be included along with #330
This action still failed irrespective of the fact that no floating-point exceptions were raised in this commit(note that this failure is not attributed from this PR). |
The 3d test does not touch the vanishing stress code or did you find out something different? The test now runs locally without any exceptions from the floating point? |
No, it doesn't. At least for this commit, all the actions were successful. |
This reverts commit c37e4c7.
This can be the cause of error due to non-linearity of NeoHooke
OBSERVATIONS:
The test fails irrespective of the number of minimum iterations (see here) allowed and presence of perturbation the stresses (see here) in Further debugging is necessary!! !!! UPDATE |
Since it only fails if the tests are executed simultaneously, it sound still like an uninitialized memory problem or similar. I would suggest, the following procedure, if the 3D-test would fail independently
|
use FloatCmp and change tolerance remove noexcept
66e4dad
to
dee9f3a
Compare
I think I found the source of the error. I ran the tests 7 times and it always works now (see this action run).
|
@@ -28,8 +28,8 @@ int main(int argc, char** argv) { | |||
t.subTest(NonLinearElasticityLoadControlNRandTR<Grids::Yasp>(matNH1)); | |||
t.subTest(NonLinearElasticityLoadControlNRandTR<Grids::IgaSurfaceIn2D>(matNH1)); | |||
|
|||
autoDiffTest<2>(t, planeStressMat1, " nu != 0"); | |||
autoDiffTest<2>(t, planeStressMat2, " nu = 0"); | |||
autoDiffTest<2>(t, planeStressMat1, " nu != 0", 1e-7); |
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.
This tolerance isn't always necessary but only for certain cases depending on the randomness in the element geometry and the displacement vector (see comment). I am not sure if this is good enough or it could be resolved in a better way? May be fixing the random displacement vector in checkFESByAutoDiff
such that this tolerance can be reduced further? We can also fix the tolerance while working on the Issue #211. Do you think increasing minIter
to 2 or 3 for NewtonRaphson
in VanishingStress
would help here?
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.
Increasing minIter might help but I'm not sure here. But using tolerances here is not to bad. But I think there is no nice way to fix this. We might refactor isApproxSame
which then uses the objects to compute something reasonable: Maybe something like that https://godbolt.org/z/xEPraWKEf
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.
Okay then I leave the tolerance here as such and we can refactor isApproxSame
while perhaps working on #211
that makes a lot of sense. I will look into it tomorrow. |
The code coverage is also behaving randomly, I don't know why. Before I committed the change from |
const auto detC = C.determinant(); | ||
if (Dune::FloatCmp::lt(static_cast<double>(detC), 0.0, 1e-10)) | ||
DUNE_THROW(Dune::InvalidStateException, | ||
"Determinant of right Cauchy Green tensor C must be greater than or equal to zero. detC = " + |
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.
It should be equal to zero. It should really be bigger. From theory.
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.
You mean it shouldn't be equal to zero? So change FloatCmp::lt
to FloatCmp::le
?
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.
Ah sorry. I missed a word. It should not be equal to zero. Therefore detC>0
. The statement in the if statement is fine but the exception text is saying detC>=0
.
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.
I fixed it
@@ -96,7 +101,12 @@ struct NeoHookeT : public Material<NeoHookeT<ST>> | |||
static_assert(Concepts::EigenMatrixOrVoigtNotation3<Derived>); | |||
if constexpr (!voigt) { | |||
if constexpr (!Concepts::EigenVector<Derived>) { | |||
const auto logdetF = log(sqrt(C.determinant())); | |||
const auto detC = C.determinant(); | |||
if (Dune::FloatCmp::lt(static_cast<double>(detC), 0.0, 1e-10)) |
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.
Since you are repeating that functionality I would move it to a private member function and call it check positive determinant of C.
if constexpr (std::is_same_v<ScalarType, double>) | ||
return mat_.template tangentModuli<strainType, voigt>(strain); | ||
else { | ||
if constexpr (Concepts::AutodiffScalar<ScalarType>) { |
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.
Maybe we also want a private function getmaterial, which does this compile time if statement and returns the correct material object. Make sure that decltype(auto)
is placed everywhere to not introduce copies
tests/src/testmaterial.cpp
Outdated
|
||
t.checkThrow<Dune::InvalidStateException>( | ||
[&]() { | ||
const auto moduli = (planeStress(matNH, 1e-8).template tangentModuli<StrainTags::greenLagrangian, true>(E)); |
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.
Maybe not repeat planeStress(matNH, 1e-8)
but use the same object all the time?
This is also a mystery for me, therefore I take these changes always with a grain of salt. We might remove that even or change to another provider |
In total for me this looks quite fine and the comments might also happen in another PR except for the code duplication stuff. Still you can quickly look into if you have an idea that can be done fast. |
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.
Ok this is fine for me.
No description provided.