From 4a8047478236b4664054c042e4cd7b409f16e300 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 23 Jan 2015 14:56:15 +0100 Subject: [PATCH] Fixes formatting according to Atgeirr's coding style. --- opm/core/linalg/ParallelIstlInformation.hpp | 57 +++++++++++++++------ 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/opm/core/linalg/ParallelIstlInformation.hpp b/opm/core/linalg/ParallelIstlInformation.hpp index 479f4be98..4a3504d44 100644 --- a/opm/core/linalg/ParallelIstlInformation.hpp +++ b/opm/core/linalg/ParallelIstlInformation.hpp @@ -130,8 +130,10 @@ public: OwnerOverlapSet sourceFlags; AllSet destFlags; Dune::Interface interface(communicator_); - if(!remoteIndices_->isSynced()) + if( !remoteIndices_->isSynced() ) + { remoteIndices_->rebuild(); + } interface.build(*remoteIndices_,sourceFlags,destFlags); Dune::BufferedCommunicator communicator; communicator.template build(interface); @@ -141,14 +143,20 @@ public: template void updateOwnerMask(const T& container) { - if(! indexSet_) + if( ! indexSet_ ) + { 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.); - 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) + { ownerMask_[i->local().local()] = 0.; + } + } } }; /// \brief Compute one or more global reductions. @@ -207,8 +215,10 @@ private: static_assert(std::tuple_size >::value== std::tuple_size >::value, "We need the same number of containers and return values"); - if(std::tuple_size >::value==0) + if( std::tuple_size >::value==0 ) + { return; + } // Copy the initial values. std::tuple init=values; updateOwnerMask(std::get<0>(containers)); @@ -217,9 +227,11 @@ private: std::vector > receivedValues(communicator_.size()); communicator_.allgather(&values, 1, &(receivedValues[0])); values=init; - for(auto rvals=receivedValues.begin(), endvals=receivedValues.end(); rvals!=endvals; - ++rvals) + for( auto rvals=receivedValues.begin(), endvals=receivedValues.end(); rvals!=endvals; + ++rvals ) + { computeGlobalReduction(*rvals, operators, values); + } } /// \brief TMP for computing the the global reduction after receiving the local ones. /// @@ -257,7 +269,7 @@ private: std::tuple& values) { const auto& container = std::get(containers); - if(container.size()) + if( container.size() ) { auto& reduceOperator = std::get(operators); auto newVal = container.begin(); @@ -267,9 +279,11 @@ private: ++mask; ++newVal; - for(auto endVal=container.end(); newVal!=endVal; - ++newVal, ++mask) - value = reduceOperator(value, *newVal, *mask); + for( auto endVal=container.end(); newVal!=endVal; + ++newVal, ++mask ) + { + value = reduceOperator(value, *newVal, *mask); + } } computeLocalReduction(containers, operators, values); } @@ -369,16 +383,23 @@ private: template T maskValue(const T& t, const T1& mask) { - if(mask) + if( mask ) + { return t; - else{ + } + else + { //g++-4.4 does not support std::numeric_limits::lowest(); // we rely on IEE 754 for floating point values and use min() // for integral types. - if(std::is_integral::value) + if( std::is_integral::value ) + { return -std::numeric_limits::min(); + } else + { return -std::numeric_limits::max(); + } } } /// \brief Get the underlying binary operator. @@ -408,15 +429,19 @@ private: template T operator()(const T& t1, const T& t2, const T1& mask) { - b_(t1, maskValue(t2, mask)); + return b_(t1, maskValue(t2, mask)); } template T maskValue(const T& t, const T1& mask) { - if(mask) + if( mask ) + { return t; + } else + { return std::numeric_limits::max(); + } } BinaryOperator& localOperator() {