mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-18 21:43:27 -06:00
Do not rely on begin()/end() of the containers to compute reductions.
One would think that such an assumption is safe in any case, wouldn't one? But foen Eigen'S container this does not hold. They do not provide STL compliant iterators, and access to them. With this patch make the even stricter assumption that the containers are random access and use operator[] instead of iterators.
This commit is contained in:
parent
2a3adf7591
commit
2caaca4160
@ -276,17 +276,22 @@ private:
|
||||
if( container.size() )
|
||||
{
|
||||
auto& reduceOperator = std::get<I>(operators);
|
||||
auto newVal = container.begin();
|
||||
// Eigen:Block does not support STL iterators!!!!
|
||||
// Therefore we need to rely on the harder random-access
|
||||
// property of the containers. But this should be save, too.
|
||||
// Just commenting out code in the hope that Eigen might improve
|
||||
// in this regard in the future.
|
||||
//auto newVal = container.begin();
|
||||
auto mask = ownerMask_.begin();
|
||||
auto& value = std::get<I>(values);
|
||||
value = reduceOperator.maskValue(*newVal, *mask);
|
||||
value = reduceOperator.maskValue(container[0], *mask);
|
||||
++mask;
|
||||
++newVal;
|
||||
//++newVal;
|
||||
|
||||
for( auto endVal=container.end(); newVal!=endVal;
|
||||
++newVal, ++mask )
|
||||
for( auto endVal=ownerMask_.end(); mask!=endVal;
|
||||
/*++newVal,*/ ++mask )
|
||||
{
|
||||
value = reduceOperator(value, *newVal, *mask);
|
||||
value = reduceOperator(value, container[mask-ownerMask_.begin()], *mask);
|
||||
}
|
||||
}
|
||||
computeLocalReduction<I+1>(containers, operators, values);
|
||||
|
Loading…
Reference in New Issue
Block a user