mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Constified the compute reduction functions.
These should and have to be used with a const object.
This commit is contained in:
parent
d2dab23d60
commit
2a3adf7591
@ -142,7 +142,7 @@ public:
|
||||
communicator.free();
|
||||
}
|
||||
template<class T>
|
||||
void updateOwnerMask(const T& container)
|
||||
void updateOwnerMask(const T& container) const
|
||||
{
|
||||
if( ! indexSet_ )
|
||||
{
|
||||
@ -180,7 +180,7 @@ public:
|
||||
/// \param value The initial value or a tuple of them.
|
||||
template<typename Container, typename BinaryOperator, typename T>
|
||||
void computeReduction(const Container& container, BinaryOperator binaryOperator,
|
||||
T& value)
|
||||
T& value) const
|
||||
{
|
||||
computeReduction(container, binaryOperator, value, is_tuple<Container>());
|
||||
}
|
||||
@ -190,7 +190,7 @@ private:
|
||||
/// This is a helper function to prepare for calling computeTupleReduction.
|
||||
template<typename Container, typename BinaryOperator, typename T>
|
||||
void computeReduction(const Container& container, BinaryOperator binaryOperator,
|
||||
T& value, std::integral_constant<bool,true>)
|
||||
T& value, std::integral_constant<bool,true>) const
|
||||
{
|
||||
computeTupleReduction(container, binaryOperator, value);
|
||||
}
|
||||
@ -199,7 +199,7 @@ private:
|
||||
/// This is a helper function to prepare for calling computeTupleReduction.
|
||||
template<typename Container, typename BinaryOperator, typename T>
|
||||
void computeReduction(const Container& container, BinaryOperator binaryOperator,
|
||||
T& value, std::integral_constant<bool,false>)
|
||||
T& value, std::integral_constant<bool,false>) const
|
||||
{
|
||||
std::tuple<const Container&> containers=std::tuple<const Container&>(container);
|
||||
auto values=std::make_tuple(value);
|
||||
@ -211,7 +211,7 @@ private:
|
||||
template<typename... Containers, typename... BinaryOperators, typename... ReturnValues>
|
||||
void computeTupleReduction(const std::tuple<Containers...>& containers,
|
||||
std::tuple<BinaryOperators...>& operators,
|
||||
std::tuple<ReturnValues...>& values)
|
||||
std::tuple<ReturnValues...>& values) const
|
||||
{
|
||||
static_assert(std::tuple_size<std::tuple<Containers...> >::value==
|
||||
std::tuple_size<std::tuple<BinaryOperators...> >::value,
|
||||
@ -243,14 +243,14 @@ private:
|
||||
typename std::enable_if<I == sizeof...(BinaryOperators), void>::type
|
||||
computeGlobalReduction(const std::tuple<ReturnValues...>&,
|
||||
std::tuple<BinaryOperators...>&,
|
||||
std::tuple<ReturnValues...>&)
|
||||
std::tuple<ReturnValues...>&) const
|
||||
{}
|
||||
/// \brief TMP for computing the the global reduction after receiving the local ones.
|
||||
template<int I=0, typename... BinaryOperators, typename... ReturnValues>
|
||||
typename std::enable_if<I !=sizeof...(BinaryOperators), void>::type
|
||||
computeGlobalReduction(const std::tuple<ReturnValues...>& receivedValues,
|
||||
std::tuple<BinaryOperators...>& operators,
|
||||
std::tuple<ReturnValues...>& values)
|
||||
std::tuple<ReturnValues...>& values) const
|
||||
{
|
||||
auto& val=std::get<I>(values);
|
||||
val = std::get<I>(operators).localOperator()(val, std::get<I>(receivedValues));
|
||||
@ -263,14 +263,14 @@ private:
|
||||
typename std::enable_if<I==sizeof...(Containers), void>::type
|
||||
computeLocalReduction(const std::tuple<Containers...>&,
|
||||
std::tuple<BinaryOperators...>&,
|
||||
std::tuple<ReturnValues...>&)
|
||||
std::tuple<ReturnValues...>&) const
|
||||
{}
|
||||
/// \brief TMP for computing the the local reduction on the DOF that the process owns.
|
||||
template<int I=0, typename... Containers, typename... BinaryOperators, typename... ReturnValues>
|
||||
typename std::enable_if<I!=sizeof...(Containers), void>::type
|
||||
computeLocalReduction(const std::tuple<Containers...>& containers,
|
||||
std::tuple<BinaryOperators...>& operators,
|
||||
std::tuple<ReturnValues...>& values)
|
||||
std::tuple<ReturnValues...>& values) const
|
||||
{
|
||||
const auto& container = std::get<I>(containers);
|
||||
if( container.size() )
|
||||
|
Loading…
Reference in New Issue
Block a user