mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #1133 from blattms/parallel-accumulate
Added an accumulate method that allows to switch off non-owner entries.
This commit is contained in:
commit
15790ecb57
@ -663,6 +663,29 @@ inline void extractParallelGridInformationToISTL(boost::any& anyComm, const Unst
|
|||||||
{
|
{
|
||||||
(void)anyComm; (void)grid;
|
(void)anyComm; (void)grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Accumulates entries masked with 1.
|
||||||
|
/// \param container The container whose values to accumulate.
|
||||||
|
/// \param maskContainer null pointer or a pointer to a container
|
||||||
|
/// with entries 0 and 1. Only values at indices with a 1 stored
|
||||||
|
/// will be accumulated. If null then all values will be accumulated
|
||||||
|
/// \return the summ of all entries that should be represented.
|
||||||
|
template<class T1>
|
||||||
|
auto
|
||||||
|
accumulateMaskedValues(const T1& container, const std::vector<double>* maskContainer)
|
||||||
|
-> decltype(container[0]*(*maskContainer)[0])
|
||||||
|
{
|
||||||
|
decltype(container[0]*(*maskContainer)[0]) initial = 0;
|
||||||
|
|
||||||
|
if( maskContainer )
|
||||||
|
{
|
||||||
|
return std::inner_product(container.begin(), container.end(), maskContainer->begin(),
|
||||||
|
initial);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
return std::accumulate(container.begin(), container.end(), initial);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // end namespace Opm
|
} // end namespace Opm
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user