From 097542a52714ca858aba646ffeb804b249f03108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 27 Aug 2015 10:03:59 +0200 Subject: [PATCH] Whitespace fixes. It turns out I accidentally used tabs for a while, this commit fixes that for all touched files. --- opm/autodiff/AutoDiffBlock.hpp | 12 +++++----- opm/autodiff/AutoDiffHelpers.hpp | 20 ++++++++-------- opm/autodiff/BlackoilModelBase.hpp | 2 +- opm/autodiff/BlackoilModelBase_impl.hpp | 14 +++++------ opm/autodiff/BlackoilPropsAdFromDeck.cpp | 22 ++++++++--------- .../NewtonIterationBlackoilInterleaved.cpp | 10 ++++---- .../NewtonIterationBlackoilSimple.cpp | 4 ++-- opm/autodiff/NewtonIterationUtilities.cpp | 20 ++++++++-------- opm/autodiff/fastSparseProduct.hpp | 24 +++++++++---------- tests/test_autodiffmatrix.cpp | 22 ++++++++--------- 10 files changed, 75 insertions(+), 75 deletions(-) diff --git a/opm/autodiff/AutoDiffBlock.hpp b/opm/autodiff/AutoDiffBlock.hpp index f733bc43d..453669ec5 100644 --- a/opm/autodiff/AutoDiffBlock.hpp +++ b/opm/autodiff/AutoDiffBlock.hpp @@ -158,7 +158,7 @@ namespace Opm } // ... then set the one corrresponding to this variable to identity. assert(blocksizes[index] == num_elem); - jac[index] = M(M::IdentityMatrix, val.size()); + jac[index] = M(M::IdentityMatrix, val.size()); // if(val.size()>0) // { // // if val is empty the following will run into an assertion @@ -343,7 +343,7 @@ namespace Opm // D D1 = val_.matrix().asDiagonal(); // D D2 = rhs.val_.matrix().asDiagonal(); M D1(val_.matrix().asDiagonal()); - M D2(rhs.val_.matrix().asDiagonal()); + M D2(rhs.val_.matrix().asDiagonal()); for (int block = 0; block < num_blocks; ++block) { assert(jac_[block].rows() == rhs.jac_[block].rows()); assert(jac_[block].cols() == rhs.jac_[block].cols()); @@ -382,8 +382,8 @@ namespace Opm // D D2 = rhs.val_.matrix().asDiagonal(); // D D3 = (1.0/(rhs.val_*rhs.val_)).matrix().asDiagonal(); M D1(val_.matrix().asDiagonal()); - M D2(rhs.val_.matrix().asDiagonal()); - M D3((1.0/(rhs.val_*rhs.val_)).matrix().asDiagonal()); + M D2(rhs.val_.matrix().asDiagonal()); + M D3((1.0/(rhs.val_*rhs.val_)).matrix().asDiagonal()); for (int block = 0; block < num_blocks; ++block) { assert(jac_[block].rows() == rhs.jac_[block].rows()); assert(jac_[block].cols() == rhs.jac_[block].cols()); @@ -412,8 +412,8 @@ namespace Opm int num_blocks = jac_.size(); os << "Value =\n" << val_ << "\n\nJacobian =\n"; for (int i = 0; i < num_blocks; ++i) { - Eigen::SparseMatrix m; - jac_[i].toSparse(m); + Eigen::SparseMatrix m; + jac_[i].toSparse(m); os << "Sub Jacobian #" << i << '\n' << m << "\n"; } return os; diff --git a/opm/autodiff/AutoDiffHelpers.hpp b/opm/autodiff/AutoDiffHelpers.hpp index 207d64656..689239dbc 100644 --- a/opm/autodiff/AutoDiffHelpers.hpp +++ b/opm/autodiff/AutoDiffHelpers.hpp @@ -251,7 +251,7 @@ struct HelperOps } private: - Eigen::SparseMatrix select_; + Eigen::SparseMatrix select_; }; @@ -460,15 +460,15 @@ collapseJacs(const AutoDiffBlock& x, Matrix& jacobian) int block_col_start = 0; for (int block = 0; block < nb; ++block) { const ADB::M& jac1 = x.derivative()[block]; - Eigen::SparseMatrix jac; - jac1.toSparse(jac); + Eigen::SparseMatrix jac; + jac1.toSparse(jac); for (Eigen::SparseMatrix::Index k = 0; k < jac.outerSize(); ++k) { for (Eigen::SparseMatrix::InnerIterator i(jac, k); i ; ++i) { - if (i.value() != 0.0) { - t.push_back(Tri(i.row(), - i.col() + block_col_start, - i.value())); - } + if (i.value() != 0.0) { + t.push_back(Tri(i.row(), + i.col() + block_col_start, + i.value())); + } } } block_col_start += jac.cols(); @@ -588,8 +588,8 @@ vertcatCollapseJacs(const std::vector >& x) if (!x[elem].derivative().empty()) { for (int block = 0; block < num_blocks; ++block) { // const ADB::M& jac = x[elem].derivative()[block]; - M jac; - x[elem].derivative()[block].toSparse(jac); + M jac; + x[elem].derivative()[block].toSparse(jac); for (M::Index k = 0; k < jac.outerSize(); ++k) { for (M::InnerIterator i(jac, k); i ; ++i) { t.push_back(Tri(i.row() + block_row_start, diff --git a/opm/autodiff/BlackoilModelBase.hpp b/opm/autodiff/BlackoilModelBase.hpp index 1d870fd8f..909dba6a6 100644 --- a/opm/autodiff/BlackoilModelBase.hpp +++ b/opm/autodiff/BlackoilModelBase.hpp @@ -230,7 +230,7 @@ namespace Opm { WellOps(const Wells* wells); // M w2p; // well -> perf (scatter) // M p2w; // perf -> well (gather) - Eigen::SparseMatrix w2p; // well -> perf (scatter) + Eigen::SparseMatrix w2p; // well -> perf (scatter) Eigen::SparseMatrix p2w; // perf -> well (gather) }; diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index 7120ef777..4ce673492 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -797,7 +797,7 @@ namespace detail { // get reasonable initial conditions for the wells updateWellControls(well_state); - // Create the primary variables. + // Create the primary variables. SolutionState state = asImpl().variableState(reservoir_state, well_state); if (initial_assembly) { @@ -978,7 +978,7 @@ namespace detail { selectInjectingPerforations[c] = 1; else selectProducingPerforations[c] = 1; - } + } // HANDLE FLOW INTO WELLBORE // compute phase volumetric rates at standard conditions @@ -1441,9 +1441,9 @@ namespace detail { eqs.push_back(residual_.well_eq); ADB total_residual = vertcatCollapseJacs(eqs); const std::vector& Jn = total_residual.derivative(); - typedef Eigen::SparseMatrix Sp; - Sp Jn0; - Jn[0].toSparse(Jn0); + typedef Eigen::SparseMatrix Sp; + Sp Jn0; + Jn[0].toSparse(Jn0); const Eigen::SparseLU< Sp > solver(Jn0); const Eigen::VectorXd& dx = solver.solve(total_residual.value().matrix()); assert(dx.size() == (well_state.numWells() * (well_state.numPhases()+1))); @@ -1520,7 +1520,7 @@ namespace detail { //Target vars ADB::V bhp_targets = ADB::V::Zero(nw); ADB::V rate_targets = ADB::V::Zero(nw); - Eigen::SparseMatrix rate_distr(nw, np*nw); + Eigen::SparseMatrix rate_distr(nw, np*nw); //Selection variables std::vector bhp_elems; @@ -1633,7 +1633,7 @@ namespace detail { // For wells that are dead (not flowing), and therefore not communicating // with the reservoir, we set the equation to be equal to the well's total // flow. This will be a solution only if the target rate is also zero. - Eigen::SparseMatrix rate_summer(nw, np*nw); + Eigen::SparseMatrix rate_summer(nw, np*nw); for (int w = 0; w < nw; ++w) { for (int phase = 0; phase < np; ++phase) { rate_summer.insert(w, phase*nw + w) = 1.0; diff --git a/opm/autodiff/BlackoilPropsAdFromDeck.cpp b/opm/autodiff/BlackoilPropsAdFromDeck.cpp index 7c18577d4..d59ec6a7d 100644 --- a/opm/autodiff/BlackoilPropsAdFromDeck.cpp +++ b/opm/autodiff/BlackoilPropsAdFromDeck.cpp @@ -432,7 +432,7 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck& ADB::M temp; fastSparseProduct(dmudr_diag, rs.derivative()[block], temp); // jacs[block] += temp; - jacs[block] = jacs[block] + temp; + jacs[block] = jacs[block] + temp; } return ADB::function(std::move(mu), std::move(jacs)); } @@ -474,7 +474,7 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck& ADB::M temp; fastSparseProduct(dmudr_diag, rv.derivative()[block], temp); // jacs[block] += temp; - jacs[block] = jacs[block] + temp; + jacs[block] = jacs[block] + temp; } return ADB::function(std::move(mu), std::move(jacs)); } @@ -555,7 +555,7 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck& ADB::M temp; fastSparseProduct(dbdr_diag, rs.derivative()[block], temp); // jacs[block] += temp; - jacs[block] = jacs[block] + temp; + jacs[block] = jacs[block] + temp; } return ADB::function(std::move(b), std::move(jacs)); } @@ -598,7 +598,7 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck& ADB::M temp; fastSparseProduct(dbdr_diag, rv.derivative()[block], temp); // jacs[block] += temp; - jacs[block] = jacs[block] + temp; + jacs[block] = jacs[block] + temp; } return ADB::function(std::move(b), std::move(jacs)); } @@ -822,7 +822,7 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck& } return adbCapPressures; } - + /// Saturation update for hysteresis behavior. /// \param[in] cells Array of n cell indices to be associated with the saturation values. void BlackoilPropsAdFromDeck::updateSatHyst(const std::vector& saturation, @@ -831,7 +831,7 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck& const int n = cells.size(); satprops_->updateSatHyst(n, cells.data(), saturation.data()); } - + /// Update for max oil saturation. void BlackoilPropsAdFromDeck::updateSatOilMax(const std::vector& saturation) { @@ -863,7 +863,7 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck& } } - + /// Apply correction to rs/rv according to kw VAPPARS /// \param[in/out] r Array of n rs/rv values. /// \param[in] so Array of n oil saturation values. @@ -874,7 +874,7 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck& const std::vector& cells, const double vap) const { - if (!satOilMax_.empty() && vap > 0.0) { + if (!satOilMax_.empty() && vap > 0.0) { const int n = cells.size(); V factor = V::Ones(n, 1); const double eps_sqrt = std::sqrt(std::numeric_limits::epsilon()); @@ -883,12 +883,12 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck& // guard against too small saturation values. const double so_i= std::max(so[i],eps_sqrt); factor[i] = std::pow(so_i/satOilMax_[cells[i]], vap); - } + } } r = factor*r; } } - + /// Apply correction to rs/rv according to kw VAPPARS /// \param[in/out] r Array of n rs/rv values. /// \param[in] so Array of n oil saturation values. @@ -899,7 +899,7 @@ BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const BlackoilPropsAdFromDeck& const std::vector& cells, const double vap) const { - if (!satOilMax_.empty() && vap > 0.0) { + if (!satOilMax_.empty() && vap > 0.0) { const int n = cells.size(); V factor = V::Ones(n, 1); const double eps_sqrt = std::sqrt(std::numeric_limits::epsilon()); diff --git a/opm/autodiff/NewtonIterationBlackoilInterleaved.cpp b/opm/autodiff/NewtonIterationBlackoilInterleaved.cpp index 163069757..fac537992 100644 --- a/opm/autodiff/NewtonIterationBlackoilInterleaved.cpp +++ b/opm/autodiff/NewtonIterationBlackoilInterleaved.cpp @@ -208,13 +208,13 @@ namespace Opm // Find sparsity structure as union of basic block sparsity structures, // corresponding to the jacobians with respect to pressure. // Use addition to get to the union structure. - typedef Eigen::SparseMatrix Sp; + typedef Eigen::SparseMatrix Sp; Sp structure; - eqs[0].derivative()[0].toSparse(structure); + eqs[0].derivative()[0].toSparse(structure); for (int phase = 1; phase < np; ++phase) { - Sp s0; - eqs[phase].derivative()[0].toSparse(s0); - structure += s0; + Sp s0; + eqs[phase].derivative()[0].toSparse(s0); + structure += s0; } Eigen::SparseMatrix s = structure; diff --git a/opm/autodiff/NewtonIterationBlackoilSimple.cpp b/opm/autodiff/NewtonIterationBlackoilSimple.cpp index 0adb17679..abdf31d9e 100644 --- a/opm/autodiff/NewtonIterationBlackoilSimple.cpp +++ b/opm/autodiff/NewtonIterationBlackoilSimple.cpp @@ -47,7 +47,7 @@ namespace Opm NewtonIterationBlackoilSimple::SolutionVector NewtonIterationBlackoilSimple::computeNewtonIncrement(const LinearisedBlackoilResidual& residual) const { - /* + /* typedef LinearisedBlackoilResidual::ADB ADB; const int np = residual.material_balance_eq.size(); ADB mass_res = residual.material_balance_eq[0]; @@ -74,7 +74,7 @@ namespace Opm "Linear solver convergence failure."); } return dx; - */ + */ } const boost::any& NewtonIterationBlackoilSimple::parallelInformation() const diff --git a/opm/autodiff/NewtonIterationUtilities.cpp b/opm/autodiff/NewtonIterationUtilities.cpp index 0d813ef7f..8919a31af 100644 --- a/opm/autodiff/NewtonIterationUtilities.cpp +++ b/opm/autodiff/NewtonIterationUtilities.cpp @@ -62,9 +62,9 @@ namespace Opm const std::vector& Jn = eqs[n].derivative(); // Use sparse LU to solve the block submatrices i.e compute inv(D) - typedef Eigen::SparseMatrix Sp; - Sp Jnn; - Jn[n].toSparse(Jnn); + typedef Eigen::SparseMatrix Sp; + Sp Jnn; + Jn[n].toSparse(Jnn); #if HAVE_UMFPACK const Eigen::UmfPackLU solver(Jnn); #else @@ -109,8 +109,8 @@ namespace Opm M Bu; fastSparseProduct(B, u, Bu); // J -= Bu; - Bu = Bu * -1.0; - J = J + Bu; + Bu = Bu * -1.0; + J = J + Bu; } } @@ -150,9 +150,9 @@ namespace Opm const M& C = eq_coll.derivative()[0]; // Use sparse LU to solve the block submatrices - typedef Eigen::SparseMatrix Sp; - Sp D; - D1.toSparse(D); + typedef Eigen::SparseMatrix Sp; + Sp D; + D1.toSparse(D); #if HAVE_UMFPACK const Eigen::UmfPackLU solver(D); #else @@ -198,7 +198,7 @@ namespace Opm Eigen::SparseMatrix& A, V& b) { - /* + /* if (num_phases != 3) { OPM_THROW(std::logic_error, "formEllipticSystem() requires 3 phases."); } @@ -278,7 +278,7 @@ namespace Opm // Create output as product of L with equations. A = L * total_residual.derivative()[0]; b = L * total_residual.value().matrix(); - */ + */ } diff --git a/opm/autodiff/fastSparseProduct.hpp b/opm/autodiff/fastSparseProduct.hpp index 0a9923e4a..c5ba0defe 100644 --- a/opm/autodiff/fastSparseProduct.hpp +++ b/opm/autodiff/fastSparseProduct.hpp @@ -144,18 +144,18 @@ void fastSparseProduct(const Lhs& lhs, const Rhs& rhs, ResultType& res) inline void fastDiagSparseProduct(// const Eigen::DiagonalMatrix& lhs, const std::vector& lhs, - const Eigen::SparseMatrix& rhs, - Eigen::SparseMatrix& res) + const Eigen::SparseMatrix& rhs, + Eigen::SparseMatrix& res) { res = rhs; // Multiply rows by diagonal lhs. int n = res.cols(); for (int col = 0; col < n; ++col) { - typedef Eigen::SparseMatrix::InnerIterator It; - for (It it(res, col); it; ++it) { - it.valueRef() *= lhs[it.row()]; // lhs.diagonal()(it.row()); - } + typedef Eigen::SparseMatrix::InnerIterator It; + for (It it(res, col); it; ++it) { + it.valueRef() *= lhs[it.row()]; // lhs.diagonal()(it.row()); + } } } @@ -163,19 +163,19 @@ inline void fastDiagSparseProduct(// const Eigen::DiagonalMatrix& lhs, - // const Eigen::DiagonalMatrix& rhs, + // const Eigen::DiagonalMatrix& rhs, const std::vector& rhs, - Eigen::SparseMatrix& res) + Eigen::SparseMatrix& res) { res = lhs; // Multiply columns by diagonal rhs. int n = res.cols(); for (int col = 0; col < n; ++col) { - typedef Eigen::SparseMatrix::InnerIterator It; - for (It it(res, col); it; ++it) { - it.valueRef() *= rhs[col]; // rhs.diagonal()(col); - } + typedef Eigen::SparseMatrix::InnerIterator It; + for (It it(res, col); it; ++it) { + it.valueRef() *= rhs[col]; // rhs.diagonal()(col); + } } } diff --git a/tests/test_autodiffmatrix.cpp b/tests/test_autodiffmatrix.cpp index 9b2bc2d8b..9daffb8f0 100644 --- a/tests/test_autodiffmatrix.cpp +++ b/tests/test_autodiffmatrix.cpp @@ -36,7 +36,7 @@ using namespace Opm; bool operator ==(const Eigen::SparseMatrix& A, - const Eigen::SparseMatrix& B) + const Eigen::SparseMatrix& B) { // Two SparseMatrices are equal if // 0) They have the same ordering (enforced by equal types) @@ -53,15 +53,15 @@ operator ==(const Eigen::SparseMatrix& A, eq = eq && (A.nonZeros() == B.nonZeros()); for (typename Eigen::SparseMatrix::Index - k0 = 0, kend = A.outerSize(); eq && (k0 < kend); ++k0) { - for (typename Eigen::SparseMatrix::InnerIterator - iA(A, k0), iB(B, k0); eq && (iA && iB); ++iA, ++iB) { - // 3) Sparsity structure - eq = (iA.row() == iB.row()) && (iA.col() == iB.col()); + k0 = 0, kend = A.outerSize(); eq && (k0 < kend); ++k0) { + for (typename Eigen::SparseMatrix::InnerIterator + iA(A, k0), iB(B, k0); eq && (iA && iB); ++iA, ++iB) { + // 3) Sparsity structure + eq = (iA.row() == iB.row()) && (iA.col() == iB.col()); - // 4) Equal non-zero elements - eq = eq && (iA.value() == iB.value()); - } + // 4) Equal non-zero elements + eq = eq && (iA.value() == iB.value()); + } } return eq; @@ -143,7 +143,7 @@ BOOST_AUTO_TEST_CASE(AdditionOps) s1 << 1.0, 0.0, 2.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 2.0; + 0.0, 0.0, 2.0; Sp ss(s1.sparseView()); Mat s = Mat(ss); @@ -191,7 +191,7 @@ BOOST_AUTO_TEST_CASE(MultOps) s1 << 1.0, 0.0, 2.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 2.0; + 0.0, 0.0, 2.0; Sp ss(s1.sparseView()); Mat s = Mat(ss);