mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Avoid infinite loop with two constant operands.
This commit is contained in:
parent
1eec8b16d6
commit
258d8e0e24
@ -197,6 +197,9 @@ namespace Opm
|
||||
/// Elementwise operator +
|
||||
AutoDiffBlock operator+(const AutoDiffBlock& rhs) const
|
||||
{
|
||||
if (jac_.empty() && rhs.jac_.empty()) {
|
||||
return constant(val_ + rhs.val_);
|
||||
}
|
||||
if (jac_.empty()) {
|
||||
return val_ + rhs;
|
||||
}
|
||||
@ -217,6 +220,9 @@ namespace Opm
|
||||
/// Elementwise operator -
|
||||
AutoDiffBlock operator-(const AutoDiffBlock& rhs) const
|
||||
{
|
||||
if (jac_.empty() && rhs.jac_.empty()) {
|
||||
return constant(val_ - rhs.val_);
|
||||
}
|
||||
if (jac_.empty()) {
|
||||
return val_ - rhs;
|
||||
}
|
||||
@ -237,6 +243,9 @@ namespace Opm
|
||||
/// Elementwise operator *
|
||||
AutoDiffBlock operator*(const AutoDiffBlock& rhs) const
|
||||
{
|
||||
if (jac_.empty() && rhs.jac_.empty()) {
|
||||
return constant(val_ * rhs.val_);
|
||||
}
|
||||
if (jac_.empty()) {
|
||||
return val_ * rhs;
|
||||
}
|
||||
@ -260,6 +269,9 @@ namespace Opm
|
||||
/// Elementwise operator /
|
||||
AutoDiffBlock operator/(const AutoDiffBlock& rhs) const
|
||||
{
|
||||
if (jac_.empty() && rhs.jac_.empty()) {
|
||||
return constant(val_ / rhs.val_);
|
||||
}
|
||||
if (jac_.empty()) {
|
||||
return val_ / rhs;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user