From 6c00cddb35a0b9dde7d0bc5e858315b7aa96369c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 8 Sep 2015 09:36:42 +0200 Subject: [PATCH 1/2] Whitespace fix. Made as a separate commit in order to make the next commit diff understandable. --- .../FullyImplicitCompressiblePolymerSolver.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp index cfe054ab5..c817a49f3 100644 --- a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp +++ b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp @@ -664,18 +664,18 @@ namespace { M rate_distr(nw, np*nw); for (int w = 0; w < nw; ++w) { const WellControls* wc = wells_.ctrls[w]; - if (well_controls_get_current_type(wc) == BHP) { - bhp_targets[w] = well_controls_get_current_target(wc); + if (well_controls_get_current_type(wc) == BHP) { + bhp_targets[w] = well_controls_get_current_target(wc); rate_targets[w] = -1e100; } else if (well_controls_get_current_type(wc) == SURFACE_RATE) { bhp_targets[w] = -1e100; - rate_targets[w] = well_controls_get_current_target(wc); - { - const double* distr = well_controls_get_current_distr(wc); + rate_targets[w] = well_controls_get_current_target(wc); + { + const double* distr = well_controls_get_current_distr(wc); for (int phase = 0; phase < np; ++phase) { - rate_distr.insert(w, phase*nw + w) = distr[phase]; - } - } + rate_distr.insert(w, phase*nw + w) = distr[phase]; + } + } } else { OPM_THROW(std::runtime_error, "Can only handle BHP and SURFACE_RATE type controls."); } From b3246060845e0987873c2ece895f2c011bec214a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 8 Sep 2015 09:57:17 +0200 Subject: [PATCH 2/2] Update to work with AutoDiffBlock::M now being AutoDiffMatrix. --- .../FullyImplicitCompressiblePolymerSolver.cpp | 11 ++++++----- .../FullyImplicitCompressiblePolymerSolver.hpp | 4 ++-- opm/polymer/fullyimplicit/PolymerPropsAd.cpp | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp index c817a49f3..b937ee422 100644 --- a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp +++ b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp @@ -81,7 +81,7 @@ namespace { template - AutoDiffBlock::M + Eigen::SparseMatrix gravityOperator(const UnstructuredGrid& grid, const HelperOps& ops , const GeoProps& geo ) @@ -123,7 +123,8 @@ namespace { grav.push_back(Tri(i, c2, - t * dG2)); } - M G(ni, nc); G.setFromTriplets(grav.begin(), grav.end()); + Eigen::SparseMatrix G(ni, nc); + G.setFromTriplets(grav.begin(), grav.end()); return G; } @@ -661,7 +662,7 @@ namespace { // Handling BHP and SURFACE_RATE wells. V bhp_targets(nw); V rate_targets(nw); - M rate_distr(nw, np*nw); + Eigen::SparseMatrix rate_distr(nw, np*nw); for (int w = 0; w < nw; ++w) { const WellControls* wc = wells_.ctrls[w]; if (well_controls_get_current_type(wc) == BHP) { @@ -981,7 +982,7 @@ namespace { pm[i] = rock_comp_props_->poroMult(p.value()[i]); dpm[i] = rock_comp_props_->poroMultDeriv(p.value()[i]); } - ADB::M dpm_diag = spdiag(dpm); + ADB::M dpm_diag(dpm.matrix().asDiagonal()); const int num_blocks = p.numBlocks(); std::vector jacs(num_blocks); for (int block = 0; block < num_blocks; ++block) { @@ -1008,7 +1009,7 @@ namespace { tm[i] = rock_comp_props_->transMult(p.value()[i]); dtm[i] = rock_comp_props_->transMultDeriv(p.value()[i]); } - ADB::M dtm_diag = spdiag(dtm); + ADB::M dtm_diag(dtm.matrix().asDiagonal()); const int num_blocks = p.numBlocks(); std::vector jacs(num_blocks); for (int block = 0; block < num_blocks; ++block) { diff --git a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp index 5823ff27a..c5a5ed266 100644 --- a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp +++ b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp @@ -123,8 +123,8 @@ namespace Opm { struct WellOps { WellOps(const Wells& wells); - M w2p; // well -> perf (scatter) - M p2w; // perf -> well (gather) + Eigen::SparseMatrix w2p; // well -> perf (scatter) + Eigen::SparseMatrix p2w; // perf -> well (gather) }; enum { Water = BlackoilPropsAdInterface::Water, diff --git a/opm/polymer/fullyimplicit/PolymerPropsAd.cpp b/opm/polymer/fullyimplicit/PolymerPropsAd.cpp index cad97caa2..5db5abb2e 100644 --- a/opm/polymer/fullyimplicit/PolymerPropsAd.cpp +++ b/opm/polymer/fullyimplicit/PolymerPropsAd.cpp @@ -179,7 +179,7 @@ namespace Opm { inv_mu_w_eff(i) = im; dinv_mu_w_eff(i) = dim; } - ADB::M dim_diag = spdiag(dinv_mu_w_eff); + ADB::M dim_diag(dinv_mu_w_eff.matrix().asDiagonal()); const int num_blocks = c.numBlocks(); std::vector jacs(num_blocks); for (int block = 0; block < num_blocks; ++block) { @@ -226,7 +226,7 @@ namespace Opm { dmc(i) = dm; } - ADB::M dmc_diag = spdiag(dmc); + ADB::M dmc_diag(dmc.matrix().asDiagonal()); const int num_blocks = c.numBlocks(); std::vector jacs(num_blocks); for (int block = 0; block < num_blocks; ++block) { @@ -274,7 +274,7 @@ namespace Opm { dads(i) = dc_ads; } - ADB::M dads_diag = spdiag(dads); + ADB::M dads_diag(dads.matrix().asDiagonal()); int num_blocks = c.numBlocks(); std::vector jacs(num_blocks); for (int block = 0; block < num_blocks; ++block) {