mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #291 from blattms/fixes-issue-290
Fixes raisal of assertion in Eigen because of empty vector and matrices. Fixes #290
This commit is contained in:
commit
e6a053a392
@ -148,9 +148,21 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
// ... then set the one corrresponding to this variable to identity.
|
// ... then set the one corrresponding to this variable to identity.
|
||||||
assert(blocksizes[index] == num_elem);
|
assert(blocksizes[index] == num_elem);
|
||||||
jac[index].reserve(Eigen::VectorXi::Constant(val.size(), 1));
|
if(val.size()>0)
|
||||||
for (typename M::Index row = 0; row < val.size(); ++row) {
|
{
|
||||||
jac[index].insert(row, row) = Scalar(1.0);
|
// if val is empty the following will run into an assertion
|
||||||
|
// with Eigen
|
||||||
|
jac[index].reserve(Eigen::VectorXi::Constant(val.size(), 1));
|
||||||
|
for (typename M::Index row = 0; row < val.size(); ++row) {
|
||||||
|
jac[index].insert(row, row) = Scalar(1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Do some check. Empty jacobian only make sense for empty val.
|
||||||
|
for (int i = 0; i < num_blocks; ++i) {
|
||||||
|
assert(jac[i].size()==0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return AutoDiffBlock(val, jac);
|
return AutoDiffBlock(val, jac);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user