mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Fixes formatting according to Atgeirr's coding style.
This commit is contained in:
parent
7bce15c04b
commit
4a80474782
@ -130,8 +130,10 @@ public:
|
|||||||
OwnerOverlapSet sourceFlags;
|
OwnerOverlapSet sourceFlags;
|
||||||
AllSet destFlags;
|
AllSet destFlags;
|
||||||
Dune::Interface interface(communicator_);
|
Dune::Interface interface(communicator_);
|
||||||
if(!remoteIndices_->isSynced())
|
if( !remoteIndices_->isSynced() )
|
||||||
|
{
|
||||||
remoteIndices_->rebuild<false>();
|
remoteIndices_->rebuild<false>();
|
||||||
|
}
|
||||||
interface.build(*remoteIndices_,sourceFlags,destFlags);
|
interface.build(*remoteIndices_,sourceFlags,destFlags);
|
||||||
Dune::BufferedCommunicator communicator;
|
Dune::BufferedCommunicator communicator;
|
||||||
communicator.template build<T>(interface);
|
communicator.template build<T>(interface);
|
||||||
@ -141,14 +143,20 @@ public:
|
|||||||
template<class T>
|
template<class T>
|
||||||
void updateOwnerMask(const T& container)
|
void updateOwnerMask(const T& container)
|
||||||
{
|
{
|
||||||
if(! indexSet_)
|
if( ! indexSet_ )
|
||||||
|
{
|
||||||
OPM_THROW(std::runtime_error, "Trying to update owner mask without parallel information!");
|
OPM_THROW(std::runtime_error, "Trying to update owner mask without parallel information!");
|
||||||
if(container.size()!= ownerMask_.size())
|
}
|
||||||
|
if( container.size()!= ownerMask_.size() )
|
||||||
{
|
{
|
||||||
ownerMask_.resize(container.size(), 1.);
|
ownerMask_.resize(container.size(), 1.);
|
||||||
for(auto i=indexSet_->begin(), end=indexSet_->end(); i!=end; ++i)
|
for( auto i=indexSet_->begin(), end=indexSet_->end(); i!=end; ++i )
|
||||||
|
{
|
||||||
if (i->local().attribute()!=Dune::OwnerOverlapCopyAttributeSet::owner)
|
if (i->local().attribute()!=Dune::OwnerOverlapCopyAttributeSet::owner)
|
||||||
|
{
|
||||||
ownerMask_[i->local().local()] = 0.;
|
ownerMask_[i->local().local()] = 0.;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/// \brief Compute one or more global reductions.
|
/// \brief Compute one or more global reductions.
|
||||||
@ -207,8 +215,10 @@ private:
|
|||||||
static_assert(std::tuple_size<std::tuple<Containers...> >::value==
|
static_assert(std::tuple_size<std::tuple<Containers...> >::value==
|
||||||
std::tuple_size<std::tuple<ReturnValues...> >::value,
|
std::tuple_size<std::tuple<ReturnValues...> >::value,
|
||||||
"We need the same number of containers and return values");
|
"We need the same number of containers and return values");
|
||||||
if(std::tuple_size<std::tuple<Containers...> >::value==0)
|
if( std::tuple_size<std::tuple<Containers...> >::value==0 )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
// Copy the initial values.
|
// Copy the initial values.
|
||||||
std::tuple<ReturnValues...> init=values;
|
std::tuple<ReturnValues...> init=values;
|
||||||
updateOwnerMask(std::get<0>(containers));
|
updateOwnerMask(std::get<0>(containers));
|
||||||
@ -217,9 +227,11 @@ private:
|
|||||||
std::vector<std::tuple<ReturnValues...> > receivedValues(communicator_.size());
|
std::vector<std::tuple<ReturnValues...> > receivedValues(communicator_.size());
|
||||||
communicator_.allgather(&values, 1, &(receivedValues[0]));
|
communicator_.allgather(&values, 1, &(receivedValues[0]));
|
||||||
values=init;
|
values=init;
|
||||||
for(auto rvals=receivedValues.begin(), endvals=receivedValues.end(); rvals!=endvals;
|
for( auto rvals=receivedValues.begin(), endvals=receivedValues.end(); rvals!=endvals;
|
||||||
++rvals)
|
++rvals )
|
||||||
|
{
|
||||||
computeGlobalReduction(*rvals, operators, values);
|
computeGlobalReduction(*rvals, operators, values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// \brief TMP for computing the the global reduction after receiving the local ones.
|
/// \brief TMP for computing the the global reduction after receiving the local ones.
|
||||||
///
|
///
|
||||||
@ -257,7 +269,7 @@ private:
|
|||||||
std::tuple<ReturnValues...>& values)
|
std::tuple<ReturnValues...>& values)
|
||||||
{
|
{
|
||||||
const auto& container = std::get<I>(containers);
|
const auto& container = std::get<I>(containers);
|
||||||
if(container.size())
|
if( container.size() )
|
||||||
{
|
{
|
||||||
auto& reduceOperator = std::get<I>(operators);
|
auto& reduceOperator = std::get<I>(operators);
|
||||||
auto newVal = container.begin();
|
auto newVal = container.begin();
|
||||||
@ -267,9 +279,11 @@ private:
|
|||||||
++mask;
|
++mask;
|
||||||
++newVal;
|
++newVal;
|
||||||
|
|
||||||
for(auto endVal=container.end(); newVal!=endVal;
|
for( auto endVal=container.end(); newVal!=endVal;
|
||||||
++newVal, ++mask)
|
++newVal, ++mask )
|
||||||
value = reduceOperator(value, *newVal, *mask);
|
{
|
||||||
|
value = reduceOperator(value, *newVal, *mask);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
computeLocalReduction<I+1>(containers, operators, values);
|
computeLocalReduction<I+1>(containers, operators, values);
|
||||||
}
|
}
|
||||||
@ -369,16 +383,23 @@ private:
|
|||||||
template<class T, class T1>
|
template<class T, class T1>
|
||||||
T maskValue(const T& t, const T1& mask)
|
T maskValue(const T& t, const T1& mask)
|
||||||
{
|
{
|
||||||
if(mask)
|
if( mask )
|
||||||
|
{
|
||||||
return t;
|
return t;
|
||||||
else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//g++-4.4 does not support std::numeric_limits<T>::lowest();
|
//g++-4.4 does not support std::numeric_limits<T>::lowest();
|
||||||
// we rely on IEE 754 for floating point values and use min()
|
// we rely on IEE 754 for floating point values and use min()
|
||||||
// for integral types.
|
// for integral types.
|
||||||
if(std::is_integral<T>::value)
|
if( std::is_integral<T>::value )
|
||||||
|
{
|
||||||
return -std::numeric_limits<float>::min();
|
return -std::numeric_limits<float>::min();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return -std::numeric_limits<float>::max();
|
return -std::numeric_limits<float>::max();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// \brief Get the underlying binary operator.
|
/// \brief Get the underlying binary operator.
|
||||||
@ -408,15 +429,19 @@ private:
|
|||||||
template<class T, class T1>
|
template<class T, class T1>
|
||||||
T operator()(const T& t1, const T& t2, const T1& mask)
|
T operator()(const T& t1, const T& t2, const T1& mask)
|
||||||
{
|
{
|
||||||
b_(t1, maskValue(t2, mask));
|
return b_(t1, maskValue(t2, mask));
|
||||||
}
|
}
|
||||||
template<class T, class T1>
|
template<class T, class T1>
|
||||||
T maskValue(const T& t, const T1& mask)
|
T maskValue(const T& t, const T1& mask)
|
||||||
{
|
{
|
||||||
if(mask)
|
if( mask )
|
||||||
|
{
|
||||||
return t;
|
return t;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return std::numeric_limits<T>::max();
|
return std::numeric_limits<T>::max();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
BinaryOperator& localOperator()
|
BinaryOperator& localOperator()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user