From 5743225be2e769463e733ffd0f946cf81793fcea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halvor=20M=C3=B8ll=20Nilsen?= Date: Tue, 21 Aug 2012 15:23:46 +0200 Subject: [PATCH 1/2] added writing of reorder iterations for each cell --- opm/core/transport/reorder/TransportModelTwophase.cpp | 11 +++++++---- opm/core/transport/reorder/TransportModelTwophase.hpp | 10 ++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/opm/core/transport/reorder/TransportModelTwophase.cpp b/opm/core/transport/reorder/TransportModelTwophase.cpp index b3630ea73..49cafa49a 100644 --- a/opm/core/transport/reorder/TransportModelTwophase.cpp +++ b/opm/core/transport/reorder/TransportModelTwophase.cpp @@ -52,6 +52,7 @@ namespace Opm source_(0), dt_(0.0), saturation_(grid.number_of_cells, -1.0), + reorder_iterations_(grid.number_of_cells, 0), fractionalflow_(grid.number_of_cells, -1.0), mob_(2*grid.number_of_cells, -1.0) #ifdef EXPERIMENT_GAUSS_SEIDEL @@ -101,7 +102,7 @@ namespace Opm &seq[0], &comp[0], &ncomp, &ia_downw_[0], &ja_downw_[0]); #endif - + std::fill(reorder_iterations_.begin(),reorder_iterations_.end(),0); reorderAndTransport(grid_, darcyflux); toBothSat(saturation_, saturation); } @@ -170,9 +171,11 @@ namespace Opm // if (std::fabs(r0) < tol_) { // return; // } - int iters_used; + int iters_used=0; // saturation_[cell] = modifiedRegulaFalsi(res, smin_[2*cell], smax_[2*cell], maxit_, tol_, iters_used); saturation_[cell] = RootFinder::solve(res, saturation_[cell], 0.0, 1.0, maxit_, tol_, iters_used); + // add if it is iteration on an out loop + reorder_iterations_[cell] = reorder_iterations_[cell] + iters_used; fractionalflow_[cell] = fracFlow(saturation_[cell], cell); } @@ -544,8 +547,9 @@ namespace Opm const int cell = cells[pos]; GravityResidual res(*this, cells, pos, gravflux); if (std::fabs(res(saturation_[cell])) > tol_) { - int iters_used; + int iters_used=0; saturation_[cell] = RootFinder::solve(res, smin_[2*cell], smax_[2*cell], maxit_, tol_, iters_used); + reorder_iterations_[cell] = reorder_iterations_[cell] + iters_used; } saturation_[cell] = std::min(std::max(saturation_[cell], smin_[2*cell]), smax_[2*cell]); mobility(saturation_[cell], cell, &mob_[2*cell]); @@ -641,7 +645,6 @@ namespace Opm toBothSat(saturation_, saturation); } - } // namespace Opm diff --git a/opm/core/transport/reorder/TransportModelTwophase.hpp b/opm/core/transport/reorder/TransportModelTwophase.hpp index 74ed2bfe4..692976079 100644 --- a/opm/core/transport/reorder/TransportModelTwophase.hpp +++ b/opm/core/transport/reorder/TransportModelTwophase.hpp @@ -23,7 +23,7 @@ #include #include #include - +#include struct UnstructuredGrid; namespace Opm @@ -74,7 +74,8 @@ namespace Opm const double* porevolume, const double dt, std::vector& saturation); - + void reportIterations(std::ostream &os); + const std::vector& getReorderIterations(){return reorder_iterations_;}; private: virtual void solveSingleCell(const int cell); virtual void solveMultiCell(const int num_cells, const int* cells); @@ -83,8 +84,7 @@ namespace Opm const int pos, const double* gravflux); int solveGravityColumn(const std::vector& cells); - - private: + private: const UnstructuredGrid& grid_; const IncompPropertiesInterface& props_; const double* visc_; @@ -99,6 +99,8 @@ namespace Opm double dt_; std::vector saturation_; // one per cell, only water saturation! std::vector fractionalflow_; // = m[0]/(m[0] + m[1]) per cell + std::vector reorder_iterations_; + //std::vector reorder_fval_; // For gravity segregation. std::vector gravflux_; std::vector mob_; From a26c6779c64f6e227e0d6d705e2ca42f45c50067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halvor=20M=C3=B8ll=20Nilsen?= Date: Fri, 24 Aug 2012 12:52:41 +0200 Subject: [PATCH 2/2] Corrected typing pointed out by atgeirr in respose to pullrequest --- opm/core/transport/reorder/TransportModelTwophase.cpp | 8 ++++++-- opm/core/transport/reorder/TransportModelTwophase.hpp | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/opm/core/transport/reorder/TransportModelTwophase.cpp b/opm/core/transport/reorder/TransportModelTwophase.cpp index 49cafa49a..b6451809b 100644 --- a/opm/core/transport/reorder/TransportModelTwophase.cpp +++ b/opm/core/transport/reorder/TransportModelTwophase.cpp @@ -171,7 +171,7 @@ namespace Opm // if (std::fabs(r0) < tol_) { // return; // } - int iters_used=0; + int iters_used = 0; // saturation_[cell] = modifiedRegulaFalsi(res, smin_[2*cell], smax_[2*cell], maxit_, tol_, iters_used); saturation_[cell] = RootFinder::solve(res, saturation_[cell], 0.0, 1.0, maxit_, tol_, iters_used); // add if it is iteration on an out loop @@ -547,7 +547,7 @@ namespace Opm const int cell = cells[pos]; GravityResidual res(*this, cells, pos, gravflux); if (std::fabs(res(saturation_[cell])) > tol_) { - int iters_used=0; + int iters_used = 0; saturation_[cell] = RootFinder::solve(res, smin_[2*cell], smax_[2*cell], maxit_, tol_, iters_used); reorder_iterations_[cell] = reorder_iterations_[cell] + iters_used; } @@ -645,6 +645,10 @@ namespace Opm toBothSat(saturation_, saturation); } + void TransportModelTwophase::getReorderIterations() + { + return reorder_iterations_; + }; } // namespace Opm diff --git a/opm/core/transport/reorder/TransportModelTwophase.hpp b/opm/core/transport/reorder/TransportModelTwophase.hpp index 692976079..358baaa31 100644 --- a/opm/core/transport/reorder/TransportModelTwophase.hpp +++ b/opm/core/transport/reorder/TransportModelTwophase.hpp @@ -74,7 +74,9 @@ namespace Opm const double* porevolume, const double dt, std::vector& saturation); - void reportIterations(std::ostream &os); + //// Return reorder iterations + //// + //// \param[out] vector of iteration per cell const std::vector& getReorderIterations(){return reorder_iterations_;}; private: virtual void solveSingleCell(const int cell);