mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-02 12:36:54 -06:00
Add operator+=
This simplifies updating residuals.
This commit is contained in:
parent
e2b5586b31
commit
2621283f1d
@ -98,6 +98,24 @@ namespace AutoDiff
|
||||
return vars;
|
||||
}
|
||||
|
||||
/// Operator +=
|
||||
ForwardBlock& operator+=(const ForwardBlock& rhs)
|
||||
{
|
||||
assert (numBlocks() == rhs.numBlocks());
|
||||
assert (value().size() == rhs.value().size());
|
||||
|
||||
const int num_blocks = numBlocks();
|
||||
for (int block = 0; block < num_blocks; ++block) {
|
||||
assert(jac_[block].rows() == rhs.jac_[block].rows());
|
||||
assert(jac_[block].cols() == rhs.jac_[block].cols());
|
||||
jac_[block] += rhs.jac_[block];
|
||||
}
|
||||
|
||||
val_ += rhs.val_;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Operator +
|
||||
ForwardBlock operator+(const ForwardBlock& rhs) const
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user