-
Notifications
You must be signed in to change notification settings - Fork 116
Scalar dynamic evaluation #4673
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
|
jenkins build this please |
1 similar comment
|
jenkins build this please |
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.
Pull Request Overview
This PR adds support for scalar dynamic evaluation by implementing constant evaluation handling in the DynamicEvaluation class. The changes allow operations between evaluations with different derivative sizes, where one can be a constant (size 0).
- Adds a new constructor for creating constant evaluations with zero derivatives
- Implements logic to handle operations between evaluations of different sizes when one is constant
- Updates createConstant method to return a proper constant evaluation instead of throwing
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 12 comments.
| File | Description |
|---|---|
| opm/material/densead/DynamicEvaluation.hpp | Adds constant evaluation support and mixed-size operation handling |
| opm/material/common/FastSmallVector.hpp | Adds expandSize method to support dynamic resizing of evaluation storage |
| jenkins/pre-build.sh | Comments out code generation script (temporary test change) |
|
jenkins build this please |
558307a to
64de5a2
Compare
|
jenkins build this please |
|
It looks like some rounding error or other mistakes jumping in caused regression. Working on recovering it. |
|
jenkins build this please |
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.
Just commenting on the expandSize() method now.
I generally support the improved flexibility for the DynamicEvaluation, but have not looked at that yet.
935b81b to
1b92264
Compare
|
jenkins build this please |
1b92264 to
70c0f1e
Compare
|
jenkins build this please |
70c0f1e to
2e9da52
Compare
|
jenkins build this please |
|
With some discussion, it looks like this is an helpful/useful things to do. I am removing the @atgeirr , I have updated the PR, please have a look. I will migrate the implementation to the |
|
I have updated the genEvalSpecializations.py to generate the changes introduced in this PR and marking the PR is ready for review. I updated the description for this PR and mark it as ready for review. |
8e2c080 to
0796fd1
Compare
|
jenkins build this please |
|
I will make an accompanying PR in the opm-simulators to test how it works. Currently only test it with a development PR while not tested the usage in the master branch, so I am converting this PR to be draft again. |
|
The failure (https://ci.opm-project.org/job/opm-simulators-PR-builder/8802/testReport/junit/(root)/mpi/compareECLFiles_flow_GASCONDENSATE_VAPWAT_PRECSALT_REGRESSION/) is due to the following code
template <class EvalWell>
Eval restrictEval(const EvalWell& in) const
{
Eval out = 0.0;
out.setValue(in.value());
for (int eqIdx = 0; eqIdx < Indices::numEq; ++eqIdx) {
out.setDerivative(eqIdx, in.derivative(eqIdx));
}
return out;
} |
|
jenkins build this opm-simulators=6520 please |
3ae1a67 to
411dbf8
Compare
|
jenkins build this opm-simulators=6520 please |
6e29d46 to
2a6da66
Compare
|
jenkins build this opm-simulators=6520 please |
2a6da66 to
8bca924
Compare
|
jenkins build this opm-simulators=6520 please |
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 comment on the DynamicEvaluation is made in that source file because it was simpler for me, but you would have to make changes in the generating .py file instead.
| return *this; | ||
| } | ||
|
|
||
| if (thisSize == 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 think that instead of extending this object's derivatives with the appendDerivativesToConstant() function, you could do:
const T value_copy = value();
*this = other;
*this /= value_copy;
I think this pattern is a lot simpler, and should be done for all the arithmetic operations 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.
I think the original comment was wrong. if this is a constant, we divide all values and derivatives by the value.
I corrected the comment to be // if *this is a constant, extend to hold derivatives before division.
Sorry about that.
your suggestion will be the other way around,
other /= *thisLet me know if I read it wrong. I worked on it some time ago, I might be confused 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.
No you are right, sorry for adding confusion! I do think that for the other operators the pattern I suggested would work, but of course not for division, a/b is not equal to b/a, I do not know what hit me.
Such DyanmicEvaluation will have size() of zero.
it is renamed to a more general resize and the function is revised accordingly.
which does not allocate for derivatives yet.
8bca924 to
4e06dd4
Compare
|
jenkins build this opm-simulators=6520 please |
|
Thanks for the approval. The PR can go in independently. Let me test it only itself without the downstream PR. |
|
jenkins build this please |
1 similar comment
|
jenkins build this please |
e88d8bd to
78ec692
Compare
|
jenkins build this please |
|
the nonnull warming is silenced. |
|
jenkins build this please |
|
approved and jenkins passed. I am getting the PR in now. |
The main purpose of this PR is to be able to create a DynamicEvaluation directly/implicitly from a constant, like 0.0 or 1.0 or 0.5, without specifying the number of the derivatives.
For example, for the following code,
EvalWell cq_s_zfrac_effective{this->primary_variables_.numWellEq() + Indices::numEq, 0.0};now we can do
EvalWell cq_s_zfrac_effective{0.0};To do this, we represent constants with DynamicEvaluation without derivatives. And the operators are updated to incorporate this change.
The main motivation was that we have a lot of material related calculation using implicit conversion from scalar values. When we tried to do more material related calculation (similar to flash calculation for black oil) inside the wellbore in Standard Well, it appeared that lacking of implicit conversion caused issues. We can (tried to) update the material calculations to handle DyanmiceEvaluation, while it will affect many files and the approach introduced this PR is the more confined manner.