From f6153f8133fa5335ec30cb23a13ba783e1a8d5ab Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 24 Mar 2017 11:40:37 +0100 Subject: [PATCH 01/12] Factor out ewoms typetag system to separate header. We will need the typetag information also for the wells. If it is not in a separate header we get problems with recursive inclusion of the headers (BlackoilEbos.hpp includes the header that also needs the typetag information). --- CMakeLists_files.cmake | 1 + opm/autodiff/BlackoilModelEbos.hpp | 11 +------ opm/autodiff/BlackoilModelEbosTypeTags.hpp | 38 ++++++++++++++++++++++ 3 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 opm/autodiff/BlackoilModelEbosTypeTags.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 45b8d3414..38fd28871 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -157,6 +157,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/autodiff/BlackoilModelBase.hpp opm/autodiff/BlackoilModelBase_impl.hpp opm/autodiff/BlackoilModelEnums.hpp + opm/autodiff/BlackoilModelEbosTypeTags.hpp opm/autodiff/BlackoilModelParameters.hpp opm/autodiff/BlackoilPressureModel.hpp opm/autodiff/BlackoilPropsAdFromDeck.hpp diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index b56cd2e25..0da1a38e5 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -24,6 +24,7 @@ #ifndef OPM_BLACKOILMODELEBOS_HEADER_INCLUDED #define OPM_BLACKOILMODELEBOS_HEADER_INCLUDED +#include #include #include @@ -79,16 +80,6 @@ -namespace Ewoms { -namespace Properties { -NEW_TYPE_TAG(EclFlowProblem, INHERITS_FROM(BlackOilModel, EclBaseProblem)); -SET_BOOL_PROP(EclFlowProblem, DisableWells, true); -SET_BOOL_PROP(EclFlowProblem, EnableDebuggingChecks, false); - -// SWATINIT is done by the flow part of flow_ebos. this can be removed once the legacy -// code for fluid and satfunc handling gets fully retired. -SET_BOOL_PROP(EclFlowProblem, EnableSwatinit, false); -}} namespace Opm { diff --git a/opm/autodiff/BlackoilModelEbosTypeTags.hpp b/opm/autodiff/BlackoilModelEbosTypeTags.hpp new file mode 100644 index 000000000..7d33294ed --- /dev/null +++ b/opm/autodiff/BlackoilModelEbosTypeTags.hpp @@ -0,0 +1,38 @@ +#ifndef OPM_BLACKOILMODELEBOSTYPETAGS_HEADER_INCLUDED +#define OPM_BLACKOILMODELEBOSTYPETAGS_HEADER_INCLUDED +/* + Copyright 2013, 2015 SINTEF ICT, Applied Mathematics. + Copyright 2014, 2015 Statoil ASA. + Copyright 2015 NTNU + Copyright 2015 IRIS AS + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#include + +namespace Ewoms { +namespace Properties { +NEW_TYPE_TAG(EclFlowProblem, INHERITS_FROM(BlackOilModel, EclBaseProblem)); +SET_BOOL_PROP(EclFlowProblem, DisableWells, true); +SET_BOOL_PROP(EclFlowProblem, EnableDebuggingChecks, false); + +// SWATINIT is done by the flow part of flow_ebos. this can be removed once the legacy +// code for fluid and satfunc handling gets fully retired. +SET_BOOL_PROP(EclFlowProblem, EnableSwatinit, false); +}} + +#endif From 4768bc9e90500454f4431ddb1d6c6cd38de9d508 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 24 Mar 2017 11:58:54 +0100 Subject: [PATCH 02/12] Remove usage of cachedIntensiveQuantities from getWellConvergence --- opm/autodiff/StandardWellsDense.hpp | 6 +++++- opm/autodiff/StandardWellsDense_impl.hpp | 21 +++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/opm/autodiff/StandardWellsDense.hpp b/opm/autodiff/StandardWellsDense.hpp index 50285c64e..b9c2a522c 100644 --- a/opm/autodiff/StandardWellsDense.hpp +++ b/opm/autodiff/StandardWellsDense.hpp @@ -23,6 +23,8 @@ #ifndef OPM_STANDARDWELLSDENSE_HEADER_INCLUDED #define OPM_STANDARDWELLSDENSE_HEADER_INCLUDED +#include + #include #include @@ -69,7 +71,9 @@ enum WellVariablePositions { template class StandardWellsDense { public: - + // --------- Ebos property system stuff ------- + typedef typename TTAG(EclFlowProblem) TypeTag; + typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext; // --------- Types --------- typedef WellStateFullyImplicitBlackoilDense WellState; typedef BlackoilModelParameters ModelParameters; diff --git a/opm/autodiff/StandardWellsDense_impl.hpp b/opm/autodiff/StandardWellsDense_impl.hpp index d3a951574..7cd4dc582 100644 --- a/opm/autodiff/StandardWellsDense_impl.hpp +++ b/opm/autodiff/StandardWellsDense_impl.hpp @@ -934,15 +934,24 @@ namespace Opm { std::vector< Vector > B( np, Vector( nc ) ); std::vector< Vector > R2( np, Vector( nc ) ); std::vector< Vector > tempV( np, Vector( nc ) ); + auto& grid = ebosSimulator.gridManager().grid(); + const auto& gridView = grid.leafGridView(); + ElementContext elemCtx(ebosSimulator); + const auto& elemEndIt = gridView.template end(); - for ( int idx = 0; idx < np; ++idx ) + for (auto elemIt = gridView.template begin(); + elemIt != elemEndIt; ++elemIt) { - Vector& B_idx = B[ idx ]; - const int ebosPhaseIdx = flowPhaseToEbosPhaseIdx(idx); + elemCtx.updatePrimaryStencil(*elemIt); + elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0); - for (int cell_idx = 0; cell_idx < nc; ++cell_idx) { - const auto& intQuants = *(ebosSimulator.model().cachedIntensiveQuantities(cell_idx, /*timeIdx=*/0)); - const auto& fs = intQuants.fluidState(); + const auto& intQuants = elemCtx.intensiveQuantities(/*spaceIdx=*/0, /*timeIdx=*/0); + const auto& fs = intQuants.fluidState(); + + for ( int idx = 0; idx < np; ++idx ) + { + Vector& B_idx = B[ idx ]; + const int ebosPhaseIdx = flowPhaseToEbosPhaseIdx(idx); B_idx [cell_idx] = 1 / fs.invB(ebosPhaseIdx).value(); } From 0e834967409ca99625234d1932ff2310d6d1f7bc Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 24 Mar 2017 12:12:06 +0100 Subject: [PATCH 03/12] Make getWellConvergence parallel and omit unnecessary computations. detail::getConvergence computes a lot more than we actually need. We only need the average over B and the maximum of the well residual. Therefore we now compute these quantities in getWellConvergence and do the global reductions manually. --- opm/autodiff/StandardWellsDense_impl.hpp | 37 +++++++++++++++--------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/opm/autodiff/StandardWellsDense_impl.hpp b/opm/autodiff/StandardWellsDense_impl.hpp index 7cd4dc582..60a62ae1b 100644 --- a/opm/autodiff/StandardWellsDense_impl.hpp +++ b/opm/autodiff/StandardWellsDense_impl.hpp @@ -919,21 +919,17 @@ namespace Opm { getWellConvergence(Simulator& ebosSimulator, const int iteration) const { - typedef std::vector< double > Vector; + typedef double Scalar; + typedef std::vector< Scalar > Vector; const int np = numPhases(); const int nc = numCells(); const double tol_wells = param_.tolerance_wells_; const double maxResidualAllowed = param_.max_residual_allowed_; - Vector R_sum(np); - Vector B_avg(np); - Vector maxCoeff(np); - Vector maxNormWell(np); + std::vector< Scalar > B_avg( np, Scalar() ); + std::vector< Scalar > maxNormWell(np, Scalar() ); - std::vector< Vector > B( np, Vector( nc ) ); - std::vector< Vector > R2( np, Vector( nc ) ); - std::vector< Vector > tempV( np, Vector( nc ) ); auto& grid = ebosSimulator.gridManager().grid(); const auto& gridView = grid.leafGridView(); ElementContext elemCtx(ebosSimulator); @@ -950,20 +946,33 @@ namespace Opm { for ( int idx = 0; idx < np; ++idx ) { - Vector& B_idx = B[ idx ]; + auto& B = B_avg[ idx ]; const int ebosPhaseIdx = flowPhaseToEbosPhaseIdx(idx); - B_idx [cell_idx] = 1 / fs.invB(ebosPhaseIdx).value(); + B += 1 / fs.invB(ebosPhaseIdx).value(); } } - detail::convergenceReduction(B, tempV, R2, - R_sum, maxCoeff, B_avg, maxNormWell, - nc, np, pv_, residual() ); + // compute global average + grid.comm().sum(B_avg.data(), B_avg.size()); + for(auto& bval: B_avg) + bval/=nc; + + auto res = residual(); + const int nw = res.size() / np; + + for ( int idx = 0; idx < np; ++idx ) + { + for ( int w = 0; w < nw; ++w ) { + maxNormWell[idx] = std::max(maxNormWell[idx], std::abs(res[nw*idx + w])); + } + } + + grid.comm().max(maxNormWell.data(), maxNormWell.size()); Vector well_flux_residual(np); - bool converged_Well = true; + // Finish computation for ( int idx = 0; idx < np; ++idx ) { From 781eadb561e43c36888d978fd8e1bc06cabae011 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 24 Mar 2017 12:18:57 +0100 Subject: [PATCH 04/12] Removed unused method detail::convergenceReduction --- opm/autodiff/BlackoilDetails.hpp | 43 -------------------------------- 1 file changed, 43 deletions(-) diff --git a/opm/autodiff/BlackoilDetails.hpp b/opm/autodiff/BlackoilDetails.hpp index 411fe9dd1..ebe03c84b 100644 --- a/opm/autodiff/BlackoilDetails.hpp +++ b/opm/autodiff/BlackoilDetails.hpp @@ -155,7 +155,6 @@ namespace detail { return product; } } - /// \brief Get the number of local interior cells in a grid. /// \tparam The type of the DUNE grid. /// \param grid The grid which cells we count @@ -198,48 +197,6 @@ namespace detail { } - template - inline - double - convergenceReduction(const std::vector< std::vector< Scalar > >& B, - const std::vector< std::vector< Scalar > >& tempV, - const std::vector< std::vector< Scalar > >& R, - std::vector< Scalar >& R_sum, - std::vector< Scalar >& maxCoeff, - std::vector< Scalar >& B_avg, - std::vector< Scalar >& maxNormWell, - const int nc, - const int np, - const std::vector< Scalar >& pv, - const std::vector< Scalar >& residual_well) - { - const int nw = residual_well.size() / np; - assert(nw * np == int(residual_well.size())); - - // Do the global reductions - { - B_avg.resize(np); - maxCoeff.resize(np); - R_sum.resize(np); - maxNormWell.resize(np); - for ( int idx = 0; idx < np; ++idx ) - { - B_avg[idx] = std::accumulate( B[ idx ].begin(), B[ idx ].end(), 0.0 ) / nc; - R_sum[idx] = std::accumulate( R[ idx ].begin(), R[ idx ].end(), 0.0 ); - maxCoeff[idx] = *(std::max_element( tempV[ idx ].begin(), tempV[ idx ].end() )); - - assert(np >= np); - if (idx < np) { - maxNormWell[idx] = 0.0; - for ( int w = 0; w < nw; ++w ) { - maxNormWell[idx] = std::max(maxNormWell[idx], std::abs(residual_well[nw*idx + w])); - } - } - } - // Compute total pore volume - return std::accumulate(pv.begin(), pv.end(), 0.0); - } - } } // namespace detail } // namespace Opm From 29fb281406b59bb3fb1efac1f934dd20e71a0400 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 24 Mar 2017 12:19:11 +0100 Subject: [PATCH 05/12] Updated Copyright stuff --- opm/autodiff/StandardWellsDense.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opm/autodiff/StandardWellsDense.hpp b/opm/autodiff/StandardWellsDense.hpp index b9c2a522c..98153d637 100644 --- a/opm/autodiff/StandardWellsDense.hpp +++ b/opm/autodiff/StandardWellsDense.hpp @@ -1,6 +1,7 @@ /* Copyright 2016 SINTEF ICT, Applied Mathematics. - Copyright 2016 Statoil ASA. + Copyright 2016 - 2017 Statoil ASA. + Copyright 2017 Dr. Blatt - HPC-Simulation-Software & Services Copyright 2016 IRIS AS This file is part of the Open Porous Media project (OPM). From a6f6e4806e1e765ca81fd9aecd58b88618fa1124 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 24 Mar 2017 14:20:31 +0100 Subject: [PATCH 06/12] Moved copyright notice to top of header BlackoilModelEbosTypeTags.hpp --- opm/autodiff/BlackoilModelEbosTypeTags.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opm/autodiff/BlackoilModelEbosTypeTags.hpp b/opm/autodiff/BlackoilModelEbosTypeTags.hpp index 7d33294ed..1dfc9aa0e 100644 --- a/opm/autodiff/BlackoilModelEbosTypeTags.hpp +++ b/opm/autodiff/BlackoilModelEbosTypeTags.hpp @@ -1,5 +1,3 @@ -#ifndef OPM_BLACKOILMODELEBOSTYPETAGS_HEADER_INCLUDED -#define OPM_BLACKOILMODELEBOSTYPETAGS_HEADER_INCLUDED /* Copyright 2013, 2015 SINTEF ICT, Applied Mathematics. Copyright 2014, 2015 Statoil ASA. @@ -22,6 +20,9 @@ along with OPM. If not, see . */ +#ifndef OPM_BLACKOILMODELEBOSTYPETAGS_HEADER_INCLUDED +#define OPM_BLACKOILMODELEBOSTYPETAGS_HEADER_INCLUDED + #include namespace Ewoms { From cde162b3d600dfd8cba1f1dd168475adb1abd8e6 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 24 Mar 2017 15:12:42 +0100 Subject: [PATCH 07/12] Use the global number of cells for the average. This number is still wrong in master but well become correct once PR #1107 is merged. --- opm/autodiff/BlackoilModelEbos.hpp | 7 +++++-- opm/autodiff/StandardWellsDense.hpp | 5 ++++- opm/autodiff/StandardWellsDense_impl.hpp | 9 ++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index 0da1a38e5..f32f62447 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -179,11 +179,14 @@ namespace Opm { const double gravity = detail::getGravity(geo_.gravity(), UgGridHelpers::dimensions(grid_)); const std::vector pv(geo_.poreVolume().data(), geo_.poreVolume().data() + geo_.poreVolume().size()); const std::vector depth(geo_.z().data(), geo_.z().data() + geo_.z().size()); - well_model_.init(fluid_.phaseUsage(), active_, &vfp_properties_, gravity, depth, pv, &rate_converter_); + // Wells are active if they are active wells on at least + // one process. + int wellsActive = localWellsActive() ? 1 : 0; + wellsActive = grid_.comm().max(wellsActive); wellModel().setWellsActive( localWellsActive() ); // compute global sum of number of cells global_nc_ = detail::countGlobalCells(grid_); - + well_model_.init(fluid_.phaseUsage(), active_, &vfp_properties_, gravity, depth, pv, &rate_converter_, global_nc_); if (!istlSolver_) { OPM_THROW(std::logic_error,"solver down cast to ISTLSolver failed"); diff --git a/opm/autodiff/StandardWellsDense.hpp b/opm/autodiff/StandardWellsDense.hpp index 98153d637..edbf886e6 100644 --- a/opm/autodiff/StandardWellsDense.hpp +++ b/opm/autodiff/StandardWellsDense.hpp @@ -103,7 +103,8 @@ enum WellVariablePositions { const double gravity_arg, const std::vector& depth_arg, const std::vector& pv_arg, - const RateConverterType* rate_converter); + const RateConverterType* rate_converter, + long int global_nc); template @@ -299,6 +300,8 @@ enum WellVariablePositions { BVector resWell_; + long int global_nc_; + mutable BVector Cx_; mutable BVector invDrw_; mutable BVector scaleAddRes_; diff --git a/opm/autodiff/StandardWellsDense_impl.hpp b/opm/autodiff/StandardWellsDense_impl.hpp index 60a62ae1b..2414ce82f 100644 --- a/opm/autodiff/StandardWellsDense_impl.hpp +++ b/opm/autodiff/StandardWellsDense_impl.hpp @@ -41,8 +41,12 @@ namespace Opm { const double gravity_arg, const std::vector& depth_arg, const std::vector& pv_arg, - const RateConverterType* rate_converter) + const RateConverterType* rate_converter, + long int global_nc) { + // has to be set always for the convergence check! + global_nc_ = global_nc; + if ( ! localWellsActive() ) { return; } @@ -923,7 +927,6 @@ namespace Opm { typedef std::vector< Scalar > Vector; const int np = numPhases(); - const int nc = numCells(); const double tol_wells = param_.tolerance_wells_; const double maxResidualAllowed = param_.max_residual_allowed_; @@ -956,7 +959,7 @@ namespace Opm { // compute global average grid.comm().sum(B_avg.data(), B_avg.size()); for(auto& bval: B_avg) - bval/=nc; + bval/=global_nc_; auto res = residual(); const int nw = res.size() / np; From 6b8b8b971ec6161e3edb541f53e153a698833746 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Tue, 4 Apr 2017 09:54:27 +0200 Subject: [PATCH 08/12] Use global wellsActive to see whether wells are active at all. This bug must have sneaked in during rebasing. Kudos to Atgeirr for spotting this. --- opm/autodiff/BlackoilModelEbos.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index f32f62447..89468011b 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -183,7 +183,7 @@ namespace Opm { // one process. int wellsActive = localWellsActive() ? 1 : 0; wellsActive = grid_.comm().max(wellsActive); - wellModel().setWellsActive( localWellsActive() ); + wellModel().setWellsActive( wellsActive ); // compute global sum of number of cells global_nc_ = detail::countGlobalCells(grid_); well_model_.init(fluid_.phaseUsage(), active_, &vfp_properties_, gravity, depth, pv, &rate_converter_, global_nc_); From e56e2cae152bd058b22093ea9a45d2c306eb0d9c Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Tue, 4 Apr 2017 09:58:49 +0200 Subject: [PATCH 09/12] Added requested braces. --- opm/autodiff/StandardWellsDense_impl.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opm/autodiff/StandardWellsDense_impl.hpp b/opm/autodiff/StandardWellsDense_impl.hpp index 2414ce82f..87ff8375d 100644 --- a/opm/autodiff/StandardWellsDense_impl.hpp +++ b/opm/autodiff/StandardWellsDense_impl.hpp @@ -959,8 +959,10 @@ namespace Opm { // compute global average grid.comm().sum(B_avg.data(), B_avg.size()); for(auto& bval: B_avg) + { bval/=global_nc_; - + } + auto res = residual(); const int nw = res.size() / np; From 2bf7f8efa79d15c9c03465e42a5bfa40ef6d95f2 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Tue, 4 Apr 2017 10:45:58 +0200 Subject: [PATCH 10/12] Revert "Moved copyright notice to top of header BlackoilModelEbosTypeTags.hpp" This reverts commit d341de0d8b796b66f7bd6d871c84e1c2db265ff1. --- opm/autodiff/BlackoilModelEbosTypeTags.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/opm/autodiff/BlackoilModelEbosTypeTags.hpp b/opm/autodiff/BlackoilModelEbosTypeTags.hpp index 1dfc9aa0e..7d33294ed 100644 --- a/opm/autodiff/BlackoilModelEbosTypeTags.hpp +++ b/opm/autodiff/BlackoilModelEbosTypeTags.hpp @@ -1,3 +1,5 @@ +#ifndef OPM_BLACKOILMODELEBOSTYPETAGS_HEADER_INCLUDED +#define OPM_BLACKOILMODELEBOSTYPETAGS_HEADER_INCLUDED /* Copyright 2013, 2015 SINTEF ICT, Applied Mathematics. Copyright 2014, 2015 Statoil ASA. @@ -20,9 +22,6 @@ along with OPM. If not, see . */ -#ifndef OPM_BLACKOILMODELEBOSTYPETAGS_HEADER_INCLUDED -#define OPM_BLACKOILMODELEBOSTYPETAGS_HEADER_INCLUDED - #include namespace Ewoms { From 312aa24f866d7cfcf9f45503d920aee3a6470166 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Tue, 4 Apr 2017 10:46:25 +0200 Subject: [PATCH 11/12] Revert "Factor out ewoms typetag system to separate header." This reverts commit 05c70491257a615472e68fb44776bcd7effb60b8. --- CMakeLists_files.cmake | 1 - opm/autodiff/BlackoilModelEbos.hpp | 11 ++++++- opm/autodiff/BlackoilModelEbosTypeTags.hpp | 38 ---------------------- 3 files changed, 10 insertions(+), 40 deletions(-) delete mode 100644 opm/autodiff/BlackoilModelEbosTypeTags.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 38fd28871..45b8d3414 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -157,7 +157,6 @@ list (APPEND PUBLIC_HEADER_FILES opm/autodiff/BlackoilModelBase.hpp opm/autodiff/BlackoilModelBase_impl.hpp opm/autodiff/BlackoilModelEnums.hpp - opm/autodiff/BlackoilModelEbosTypeTags.hpp opm/autodiff/BlackoilModelParameters.hpp opm/autodiff/BlackoilPressureModel.hpp opm/autodiff/BlackoilPropsAdFromDeck.hpp diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index 89468011b..b80c9802e 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -24,7 +24,6 @@ #ifndef OPM_BLACKOILMODELEBOS_HEADER_INCLUDED #define OPM_BLACKOILMODELEBOS_HEADER_INCLUDED -#include #include #include @@ -80,6 +79,16 @@ +namespace Ewoms { +namespace Properties { +NEW_TYPE_TAG(EclFlowProblem, INHERITS_FROM(BlackOilModel, EclBaseProblem)); +SET_BOOL_PROP(EclFlowProblem, DisableWells, true); +SET_BOOL_PROP(EclFlowProblem, EnableDebuggingChecks, false); + +// SWATINIT is done by the flow part of flow_ebos. this can be removed once the legacy +// code for fluid and satfunc handling gets fully retired. +SET_BOOL_PROP(EclFlowProblem, EnableSwatinit, false); +}} namespace Opm { diff --git a/opm/autodiff/BlackoilModelEbosTypeTags.hpp b/opm/autodiff/BlackoilModelEbosTypeTags.hpp deleted file mode 100644 index 7d33294ed..000000000 --- a/opm/autodiff/BlackoilModelEbosTypeTags.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef OPM_BLACKOILMODELEBOSTYPETAGS_HEADER_INCLUDED -#define OPM_BLACKOILMODELEBOSTYPETAGS_HEADER_INCLUDED -/* - Copyright 2013, 2015 SINTEF ICT, Applied Mathematics. - Copyright 2014, 2015 Statoil ASA. - Copyright 2015 NTNU - Copyright 2015 IRIS AS - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#include - -namespace Ewoms { -namespace Properties { -NEW_TYPE_TAG(EclFlowProblem, INHERITS_FROM(BlackOilModel, EclBaseProblem)); -SET_BOOL_PROP(EclFlowProblem, DisableWells, true); -SET_BOOL_PROP(EclFlowProblem, EnableDebuggingChecks, false); - -// SWATINIT is done by the flow part of flow_ebos. this can be removed once the legacy -// code for fluid and satfunc handling gets fully retired. -SET_BOOL_PROP(EclFlowProblem, EnableSwatinit, false); -}} - -#endif From 30f3d4e2d050810d44166b8fe8b1e2c4e3e9ad86 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Tue, 4 Apr 2017 10:56:26 +0200 Subject: [PATCH 12/12] Get rid off TypeTag system in StandardWellsDense. Previously, we kind of hard coded the problem using the TypeTag system. Instead of this we now simply pass the only additional thing needed, the ElementContext, as an additional template parameter. Removes the include of removed header BlackoilModelEbosTypeTags.hpp. --- opm/autodiff/BlackoilModelEbos.hpp | 10 +- .../SimulatorFullyImplicitBlackoilEbos.hpp | 2 +- opm/autodiff/StandardWellsDense.hpp | 7 +- opm/autodiff/StandardWellsDense_impl.hpp | 244 +++++++++--------- 4 files changed, 130 insertions(+), 133 deletions(-) diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index b80c9802e..f5e93dba5 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -163,7 +163,7 @@ namespace Opm { const ModelParameters& param, const BlackoilPropsAdFromDeck& fluid, const DerivedGeology& geo , - const StandardWellsDense& well_model, + const StandardWellsDense& well_model, const NewtonIterationBlackoilInterface& linsolver, const bool terminal_output) : ebosSimulator_(ebosSimulator) @@ -1423,7 +1423,7 @@ namespace Opm { ModelParameters param_; // Well Model - StandardWellsDense well_model_; + StandardWellsDense well_model_; /// \brief Whether we print something to std::cout bool terminal_output_; @@ -1441,8 +1441,10 @@ namespace Opm { public: /// return the StandardWells object - StandardWellsDense& wellModel() { return well_model_; } - const StandardWellsDense& wellModel() const { return well_model_; } + StandardWellsDense& + wellModel() { return well_model_; } + const StandardWellsDense& + wellModel() const { return well_model_; } /// return the Well struct in the StandardWells const Wells& wells() const { return well_model_.wells(); } diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp index b9eac6531..a965c4a76 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp @@ -64,7 +64,7 @@ public: typedef BlackoilModelEbos Model; typedef BlackoilModelParameters ModelParameters; typedef NonlinearSolver Solver; - typedef StandardWellsDense WellModel; + typedef StandardWellsDense WellModel; /// Initialise from parameters and objects to observe. diff --git a/opm/autodiff/StandardWellsDense.hpp b/opm/autodiff/StandardWellsDense.hpp index edbf886e6..3c13344e2 100644 --- a/opm/autodiff/StandardWellsDense.hpp +++ b/opm/autodiff/StandardWellsDense.hpp @@ -24,8 +24,6 @@ #ifndef OPM_STANDARDWELLSDENSE_HEADER_INCLUDED #define OPM_STANDARDWELLSDENSE_HEADER_INCLUDED -#include - #include #include @@ -69,12 +67,9 @@ enum WellVariablePositions { /// Class for handling the standard well model. - template + template class StandardWellsDense { public: - // --------- Ebos property system stuff ------- - typedef typename TTAG(EclFlowProblem) TypeTag; - typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext; // --------- Types --------- typedef WellStateFullyImplicitBlackoilDense WellState; typedef BlackoilModelParameters ModelParameters; diff --git a/opm/autodiff/StandardWellsDense_impl.hpp b/opm/autodiff/StandardWellsDense_impl.hpp index 87ff8375d..7d1d811c7 100644 --- a/opm/autodiff/StandardWellsDense_impl.hpp +++ b/opm/autodiff/StandardWellsDense_impl.hpp @@ -3,8 +3,8 @@ namespace Opm { - template - StandardWellsDense:: + template + StandardWellsDense:: StandardWellsDense(const Wells* wells_arg, WellCollection* well_collection, const ModelParameters& param, @@ -32,9 +32,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: init(const PhaseUsage phase_usage_arg, const std::vector& active_arg, const VFPProperties* vfp_properties_arg, @@ -120,10 +120,10 @@ namespace Opm { - template + template template SimulatorReport - StandardWellsDense:: + StandardWellsDense:: assemble(Simulator& ebosSimulator, const int iterationIdx, const double dt, @@ -162,10 +162,10 @@ namespace Opm { - template + template template void - StandardWellsDense:: + StandardWellsDense:: assembleWellEq(Simulator& ebosSimulator, const double dt, WellState& well_state, @@ -252,10 +252,10 @@ namespace Opm { - template + template template bool - StandardWellsDense:: + StandardWellsDense:: allow_cross_flow(const int w, Simulator& ebosSimulator) const { if (wells().allow_cf[w]) { @@ -290,9 +290,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: localInvert(Mat& istlA) const { for (auto row = istlA.begin(), rowend = istlA.end(); row != rowend; ++row ) { @@ -307,9 +307,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: print(Mat& istlA) const { for (auto row = istlA.begin(), rowend = istlA.end(); row != rowend; ++row ) { @@ -323,9 +323,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: apply( BVector& r) const { if ( ! localWellsActive() ) { @@ -342,9 +342,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: apply(const BVector& x, BVector& Ax) { if ( ! localWellsActive() ) { @@ -365,9 +365,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: applyScaleAdd(const Scalar alpha, const BVector& x, BVector& Ax) { if ( ! localWellsActive() ) { @@ -387,9 +387,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: recoverVariable(const BVector& x, BVector& xw) const { if ( ! localWellsActive() ) { @@ -404,9 +404,9 @@ namespace Opm { - template + template int - StandardWellsDense:: + StandardWellsDense:: flowPhaseToEbosCompIdx( const int phaseIdx ) const { const int phaseToComp[ 3 ] = { FluidSystem::waterCompIdx, FluidSystem::oilCompIdx, FluidSystem::gasCompIdx }; @@ -417,9 +417,9 @@ namespace Opm { - template + template int - StandardWellsDense:: + StandardWellsDense:: flowToEbosPvIdx( const int flowPv ) const { const int flowToEbos[ 3 ] = { @@ -434,9 +434,9 @@ namespace Opm { - template + template int - StandardWellsDense:: + StandardWellsDense:: flowPhaseToEbosPhaseIdx( const int phaseIdx ) const { const int flowToEbos[ 3 ] = { FluidSystem::waterPhaseIdx, FluidSystem::oilPhaseIdx, FluidSystem::gasPhaseIdx }; @@ -447,9 +447,9 @@ namespace Opm { - template + template int - StandardWellsDense:: + StandardWellsDense:: ebosCompToFlowPhaseIdx( const int compIdx ) const { const int compToPhase[ 3 ] = { Oil, Water, Gas }; @@ -460,9 +460,9 @@ namespace Opm { - template + template std::vector - StandardWellsDense:: + StandardWellsDense:: extractPerfData(const std::vector& in) const { const int nw = wells().number_of_wells; @@ -481,9 +481,9 @@ namespace Opm { - template + template int - StandardWellsDense:: + StandardWellsDense:: numPhases() const { return wells().number_of_phases; @@ -493,9 +493,9 @@ namespace Opm { - template + template int - StandardWellsDense:: + StandardWellsDense:: numCells() const { return pv_.size(); @@ -505,9 +505,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: resetWellControlFromState(WellState xw) const { const int nw = wells_->number_of_wells; @@ -521,9 +521,9 @@ namespace Opm { - template + template const Wells& - StandardWellsDense:: + StandardWellsDense:: wells() const { assert(wells_ != 0); @@ -534,9 +534,9 @@ namespace Opm { - template + template const Wells* - StandardWellsDense:: + StandardWellsDense:: wellsPointer() const { return wells_; @@ -546,9 +546,9 @@ namespace Opm { - template + template bool - StandardWellsDense:: + StandardWellsDense:: wellsActive() const { return wells_active_; @@ -558,9 +558,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: setWellsActive(const bool wells_active) { wells_active_ = wells_active; @@ -570,9 +570,9 @@ namespace Opm { - template + template bool - StandardWellsDense:: + StandardWellsDense:: localWellsActive() const { return wells_ ? (wells_->number_of_wells > 0 ) : false; @@ -582,9 +582,9 @@ namespace Opm { - template + template int - StandardWellsDense:: + StandardWellsDense:: numWellVars() const { if ( !localWellsActive() ) { @@ -600,9 +600,9 @@ namespace Opm { - template + template const std::vector& - StandardWellsDense:: + StandardWellsDense:: wellPerforationDensities() const { return well_perforation_densities_; @@ -612,9 +612,9 @@ namespace Opm { - template + template const std::vector& - StandardWellsDense:: + StandardWellsDense:: wellPerforationPressureDiffs() const { return well_perforation_pressure_diffs_; @@ -624,9 +624,9 @@ namespace Opm { - template - typename StandardWellsDense::EvalWell - StandardWellsDense:: + template + typename StandardWellsDense::EvalWell + StandardWellsDense:: extendEval(Eval in) const { EvalWell out = 0.0; out.setValue(in.value()); @@ -640,9 +640,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: setWellVariables(const WellState& xw) { const int np = wells().number_of_phases; @@ -660,9 +660,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: print(EvalWell in) const { std::cout << in.value() << std::endl; @@ -675,9 +675,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: computeAccumWells() { const int np = wells().number_of_phases; @@ -693,10 +693,10 @@ namespace Opm { - template + template template void - StandardWellsDense:: + StandardWellsDense:: computeWellFlux(const int& w, const double& Tw, const intensiveQuants& intQuants, const EvalWell& bhp, const double& cdp, @@ -823,10 +823,10 @@ namespace Opm { - template + template template SimulatorReport - StandardWellsDense:: + StandardWellsDense:: solveWellEq(Simulator& ebosSimulator, const double dt, WellState& well_state) @@ -875,9 +875,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: printIf(const int c, const double x, const double y, const double eps, const std::string type) const { if (std::abs(x-y) > eps) { @@ -889,9 +889,9 @@ namespace Opm { - template + template std::vector - StandardWellsDense:: + StandardWellsDense:: residual() const { if( ! wellsActive() ) @@ -916,10 +916,10 @@ namespace Opm { - template + template template bool - StandardWellsDense:: + StandardWellsDense:: getWellConvergence(Simulator& ebosSimulator, const int iteration) const { @@ -1029,10 +1029,10 @@ namespace Opm { - template + template template void - StandardWellsDense:: + StandardWellsDense:: computeWellConnectionPressures(const Simulator& ebosSimulator, const WellState& xw) { @@ -1053,10 +1053,10 @@ namespace Opm { - template + template template void - StandardWellsDense:: + StandardWellsDense:: computePropertiesForWellConnectionPressures(const Simulator& ebosSimulator, const WellState& xw, std::vector& b_perf, @@ -1156,9 +1156,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: updateWellState(const BVector& dwells, WellState& well_state) const { @@ -1428,9 +1428,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: updateWellControls(WellState& xw) const { if( !localWellsActive() ) return ; @@ -1524,9 +1524,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: updateListEconLimited(const Schedule& schedule, const int current_step, const Wells* wells_struct, @@ -1632,9 +1632,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: computeWellConnectionDensitesPressures(const WellState& xw, const std::vector& b_perf, const std::vector& rsmax_perf, @@ -1659,10 +1659,10 @@ namespace Opm { - template + template template void - StandardWellsDense:: + StandardWellsDense:: computeWellPotentials(const Simulator& ebosSimulator, WellState& well_state) const { @@ -1793,9 +1793,9 @@ namespace Opm { - template + template WellCollection* - StandardWellsDense:: + StandardWellsDense:: wellCollection() const { return well_collection_; @@ -1804,9 +1804,9 @@ namespace Opm { - template + template const std::vector& - StandardWellsDense:: + StandardWellsDense:: wellPerfEfficiencyFactors() const { return well_perforation_efficiency_factors_; @@ -1816,9 +1816,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: calculateEfficiencyFactors() { if ( !localWellsActive() ) { @@ -1844,9 +1844,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: computeWellVoidageRates(const WellState& well_state, std::vector& well_voidage_rates, std::vector& voidage_conversion_coeffs) const @@ -1904,9 +1904,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: applyVREPGroupControl(WellState& well_state) const { if ( wellCollection()->havingVREPGroups() ) { @@ -1929,9 +1929,9 @@ namespace Opm { - template - typename StandardWellsDense::EvalWell - StandardWellsDense:: + template + typename StandardWellsDense::EvalWell + StandardWellsDense:: getBhp(const int wellIdx) const { const WellControls* wc = wells().ctrls[wellIdx]; if (well_controls_get_current_type(wc) == BHP) { @@ -1985,9 +1985,9 @@ namespace Opm { - template - typename StandardWellsDense::EvalWell - StandardWellsDense:: + template + typename StandardWellsDense::EvalWell + StandardWellsDense:: getQs(const int wellIdx, const int phaseIdx) const { EvalWell qs = 0.0; @@ -2088,9 +2088,9 @@ namespace Opm { - template - typename StandardWellsDense::EvalWell - StandardWellsDense:: + template + typename StandardWellsDense::EvalWell + StandardWellsDense:: wellVolumeFraction(const int wellIdx, const int phaseIdx) const { const int nw = wells().number_of_wells; @@ -2118,9 +2118,9 @@ namespace Opm { - template - typename StandardWellsDense::EvalWell - StandardWellsDense:: + template + typename StandardWellsDense::EvalWell + StandardWellsDense:: wellVolumeFractionScaled(const int wellIdx, const int phaseIdx) const { const WellControls* wc = wells().ctrls[wellIdx]; @@ -2136,9 +2136,9 @@ namespace Opm { - template - typename StandardWellsDense::EvalWell - StandardWellsDense:: + template + typename StandardWellsDense::EvalWell + StandardWellsDense:: wellSurfaceVolumeFraction(const int well_index, const int phase) const { EvalWell sum_volume_fraction_scaled = 0.; @@ -2156,9 +2156,9 @@ namespace Opm { - template + template bool - StandardWellsDense:: + StandardWellsDense:: checkRateEconLimits(const WellEconProductionLimits& econ_production_limits, const WellState& well_state, const int well_number) const @@ -2207,9 +2207,9 @@ namespace Opm { - template - typename StandardWellsDense::RatioCheckTuple - StandardWellsDense:: + template + typename StandardWellsDense::RatioCheckTuple + StandardWellsDense:: checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits, const WellState& well_state, const WellMapEntryType& map_entry) const @@ -2265,9 +2265,9 @@ namespace Opm { - template - typename StandardWellsDense::RatioCheckTuple - StandardWellsDense:: + template + typename StandardWellsDense::RatioCheckTuple + StandardWellsDense:: checkMaxWaterCutLimit(const WellEconProductionLimits& econ_production_limits, const WellState& well_state, const WellMapEntryType& map_entry) const @@ -2345,9 +2345,9 @@ namespace Opm { - template + template void - StandardWellsDense:: + StandardWellsDense:: updateWellStateWithTarget(const WellControls* wc, const int current, const int well_index,