From bcfcfdc93043f9921ee4bc127d128eeb5a91a778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Mon, 5 Nov 2012 15:37:14 +0100 Subject: [PATCH 1/4] Use minimum 5 digits for step numbers in output file names. Was 3 digits, created trouble for certain scripts reading the files when more than 1000 steps were taken. --- opm/polymer/SimulatorCompressiblePolymer.cpp | 4 ++-- opm/polymer/SimulatorPolymer.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/opm/polymer/SimulatorCompressiblePolymer.cpp b/opm/polymer/SimulatorCompressiblePolymer.cpp index 2d9217b2a..220d58e64 100644 --- a/opm/polymer/SimulatorCompressiblePolymer.cpp +++ b/opm/polymer/SimulatorCompressiblePolymer.cpp @@ -541,7 +541,7 @@ namespace Opm catch (...) { THROW("Creating directories failed: " << fpath); } - vtkfilename << "/output-" << std::setw(3) << std::setfill('0') << step << ".vtu"; + vtkfilename << "/output-" << std::setw(5) << std::setfill('0') << step << ".vtu"; std::ofstream vtkfile(vtkfilename.str().c_str()); if (!vtkfile) { THROW("Failed to open " << vtkfilename.str()); @@ -584,7 +584,7 @@ namespace Opm catch (...) { THROW("Creating directories failed: " << fpath); } - fname << "/" << std::setw(3) << std::setfill('0') << step << ".txt"; + fname << "/" << std::setw(5) << std::setfill('0') << step << ".txt"; std::ofstream file(fname.str().c_str()); if (!file) { THROW("Failed to open " << fname.str()); diff --git a/opm/polymer/SimulatorPolymer.cpp b/opm/polymer/SimulatorPolymer.cpp index bd533506b..9a2d1e58b 100644 --- a/opm/polymer/SimulatorPolymer.cpp +++ b/opm/polymer/SimulatorPolymer.cpp @@ -532,7 +532,7 @@ namespace Opm catch (...) { THROW("Creating directories failed: " << fpath); } - vtkfilename << "/output-" << std::setw(3) << std::setfill('0') << step << ".vtu"; + vtkfilename << "/output-" << std::setw(5) << std::setfill('0') << step << ".vtu"; std::ofstream vtkfile(vtkfilename.str().c_str()); if (!vtkfile) { THROW("Failed to open " << vtkfilename.str()); @@ -573,7 +573,7 @@ namespace Opm catch (...) { THROW("Creating directories failed: " << fpath); } - fname << "/" << std::setw(3) << std::setfill('0') << step << ".txt"; + fname << "/" << std::setw(5) << std::setfill('0') << step << ".txt"; std::ofstream file(fname.str().c_str()); if (!file) { THROW("Failed to open " << fname.str()); From 2f521169c5610249c2abcfc6a640e1674de2b174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Mon, 26 Nov 2012 10:58:18 +0100 Subject: [PATCH 2/4] Add ert-detecting macro for building with ert support. This is primarily intended for enabling eclipse-format output from simulators. Also add missing header to Makefile.am, to fix 'make distcheck'. --- Makefile.am | 19 ++++++++------- configure.ac | 2 ++ m4/ert.m4 | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 m4/ert.m4 diff --git a/Makefile.am b/Makefile.am index 919c312e6..0a4b61d4a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,28 +7,29 @@ SUBDIRS = . examples lib_LTLIBRARIES = libopmpolymer.la libopmpolymer_la_SOURCES = \ -opm/polymer/IncompTpfaPolymer.cpp \ opm/polymer/CompressibleTpfaPolymer.cpp \ -opm/polymer/SimulatorPolymer.cpp \ -opm/polymer/SimulatorCompressiblePolymer.cpp \ -opm/polymer/TransportModelPolymer.cpp \ -opm/polymer/TransportModelCompressiblePolymer.cpp \ +opm/polymer/IncompTpfaPolymer.cpp \ opm/polymer/PolymerInflow.cpp \ opm/polymer/PolymerProperties.cpp \ +opm/polymer/SimulatorCompressiblePolymer.cpp \ +opm/polymer/SimulatorPolymer.cpp \ +opm/polymer/TransportModelCompressiblePolymer.cpp \ +opm/polymer/TransportModelPolymer.cpp \ opm/polymer/polymerUtilities.cpp nobase_include_HEADERS = \ +opm/polymer/CompressibleTpfaPolymer.hpp \ opm/polymer/GravityColumnSolverPolymer.hpp \ opm/polymer/GravityColumnSolverPolymer_impl.hpp \ opm/polymer/IncompPropertiesDefaultPolymer.hpp \ opm/polymer/IncompTpfaPolymer.hpp \ -opm/polymer/CompressibleTpfaPolymer.hpp \ +opm/polymer/PolymerBlackoilState.hpp \ opm/polymer/PolymerInflow.hpp \ opm/polymer/PolymerProperties.hpp \ opm/polymer/PolymerState.hpp \ -opm/polymer/SinglePointUpwindTwoPhasePolymer.hpp \ -opm/polymer/SimulatorPolymer.hpp \ opm/polymer/SimulatorCompressiblePolymer.hpp \ +opm/polymer/SimulatorPolymer.hpp \ +opm/polymer/SinglePointUpwindTwoPhasePolymer.hpp \ +opm/polymer/TransportModelCompressiblePolymer.hpp \ opm/polymer/TransportModelPolymer.hpp \ -opm/polymer/TransportModelCompressiblePolymer.hpp \ opm/polymer/polymerUtilities.hpp diff --git a/configure.ac b/configure.ac index 7f8f32c6c..c52b7f62c 100644 --- a/configure.ac +++ b/configure.ac @@ -39,6 +39,8 @@ AX_BOOST_DATE_TIME AX_BOOST_FILESYSTEM AX_BOOST_UNIT_TEST_FRAMEWORK +ERT + # Checks for header files. AC_CHECK_HEADERS([opm/core/grid.h], [], [AC_MSG_ERROR( diff --git a/m4/ert.m4 b/m4/ert.m4 new file mode 100644 index 000000000..b1ea21a69 --- /dev/null +++ b/m4/ert.m4 @@ -0,0 +1,67 @@ +AC_DEFUN([_ERT_SOURCE_TEXT], +[ +AC_LANG_PROGRAM( +[[ +#include +#include +]],dnl +[[ +int sz; +sz = ecl_util_get_sizeof_ctype(ECL_INT_TYPE); +]])[]dnl +])[]dnl + +# ---------------------------------------------------------------------- + +AC_DEFUN([ERT], +[ +AC_ARG_WITH([ert], + [AS_HELP_STRING([--with-ert=], [Use ERT libraries])], + [], [with_ert=no]) + +use_ert=no + +AS_IF([test x"${with_ert}" != x"no"], +[ + _ert_LDFLAGS_SAVE="${LDFLAGS}" + _ert_LIBS_SAVE="${LIBS}" + _ert_CPPFLAGS_SAVE="${CPPFLAGS}" + _ert_CFLAGS_SAVE="${CFLAGS}" + + ERT_CPPFLAGS= + ERT_LDFLAGS= + ERT_LIBS="-lecl -lgeometry -lert_util -lpthread -lz -lgomp" + AS_IF([test x"${with_ert}" != x"yes"], + [ERT_LDFLAGS="-L${with_ert}/lib" + ERT_CPPFLAGS="-I${with_ert}/include"], [:])[]dnl + + CFLAGS="-std=gnu99" + CPPFLAGS="${ERT_CPPFLAGS} ${CPPFLAGS}" + LDFLAGS="${ERT_LDFLAGS} ${LDFLAGS}" + LIBS="${ERT_LIBS} ${LIBS}" + + AC_LINK_IFELSE([_ERT_SOURCE_TEXT], + [use_ert=yes], [use_ert=no]) + + LIBS="${_ert_LIBS_SAVE}" + CPPFLAGS="${_ert_CPPFLAGS_SAVE}" + LDFLAGS="${_ert_LDFLAGS_SAVE}" + CFLAGS="${_ert_CFLAGS_SAVE}" + + AS_IF([test x"${use_ert}" = x"yes"], + [AC_SUBST([ERT_CPPFLAGS]) + AC_SUBST([ERT_LDFLAGS]) + AC_SUBST([ERT_LIBS]) + AC_DEFINE([HAVE_ERT], [1], + [Are the ERT libraries available for reading and writing ECLIPSE files.])],dnl + [:])[]dnl +], [:])[]dnl + +AM_CONDITIONAL([HAVE_ERT], [test x"${use_ert}" != x"no"]) + +# AC_MSG_ERROR( +# [**** ERT_CPPFLAGS = ${ERT_CPPFLAGS} **** +# **** ERT_LDFLAGS = ${ERT_LDFLAGS} **** +# **** ERT_LIBS = ${ERT_LIBS} **** +# ]) +]) From b6b59918e16a0e1a8a12130e4452d489f2ffd0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Mon, 26 Nov 2012 11:00:20 +0100 Subject: [PATCH 3/4] Suppress output of multi-cell-block sizes and #iterations. --- opm/polymer/TransportModelCompressiblePolymer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opm/polymer/TransportModelCompressiblePolymer.cpp b/opm/polymer/TransportModelCompressiblePolymer.cpp index e9660e48f..8e3d51e56 100644 --- a/opm/polymer/TransportModelCompressiblePolymer.cpp +++ b/opm/polymer/TransportModelCompressiblePolymer.cpp @@ -1028,8 +1028,8 @@ namespace Opm THROW("In solveMultiCell(), we did not converge after " << num_iters << " iterations. Delta c = " << max_c_change); } - std::cout << "Solved " << num_cells << " cell multicell problem in " - << num_iters << " iterations." << std::endl; + // std::cout << "Solved " << num_cells << " cell multicell problem in " + // << num_iters << " iterations." << std::endl; } void TransportModelCompressiblePolymer::fracFlow(double s, double c, double cmax, From b4d5e03c61469ac40cfedfc00a0dbe7b8e3376c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Mon, 26 Nov 2012 11:01:23 +0100 Subject: [PATCH 4/4] Add eclipse output to simulator. Note: so far only for incompressible fluid simulator. --- opm/polymer/SimulatorPolymer.cpp | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/opm/polymer/SimulatorPolymer.cpp b/opm/polymer/SimulatorPolymer.cpp index 9a2d1e58b..c7d86b283 100644 --- a/opm/polymer/SimulatorPolymer.cpp +++ b/opm/polymer/SimulatorPolymer.cpp @@ -59,6 +59,10 @@ #include #include +#ifdef HAVE_ERT +#include +#endif + namespace Opm { @@ -71,6 +75,10 @@ namespace Opm const Opm::PolymerState& state, const int step, const std::string& output_dir); + void outputStateBinary(const UnstructuredGrid& grid, + const Opm::PolymerState& state, + const SimulatorTimer& simtimer, + const std::string& output_dir); void outputStateMatlab(const UnstructuredGrid& grid, const Opm::PolymerState& state, const int step, @@ -111,6 +119,7 @@ namespace Opm // Parameters for output. bool output_; bool output_vtk_; + bool output_binary_; std::string output_dir_; int output_interval_; // Parameters for well control @@ -207,6 +216,12 @@ namespace Opm output_ = param.getDefault("output", true); if (output_) { output_vtk_ = param.getDefault("output_vtk", true); + output_binary_ = param.getDefault("output_binary", false); +#ifndef HAVE_ERT + if (output_binary_) { + THROW("Cannot make binary output without ert library support. Reconfigure opm-core and opm-polymer with --with-ert and recompile."); + } +#endif output_dir_ = param.getDefault("output_dir", std::string("output")); // Ensure that output dir exists boost::filesystem::path fpath(output_dir_); @@ -307,6 +322,9 @@ namespace Opm if (output_vtk_) { outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_); } + if (output_binary_) { + outputStateBinary(grid_, state, timer, output_dir_); + } outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_); } @@ -492,6 +510,9 @@ namespace Opm if (output_vtk_) { outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_); } + if (output_binary_) { + outputStateBinary(grid_, state, timer, output_dir_); + } outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_); outputWaterCut(watercut, output_dir_); if (wells_) { @@ -583,6 +604,28 @@ namespace Opm } } + void outputStateBinary(const UnstructuredGrid& grid, + const Opm::PolymerState& state, + const SimulatorTimer& simtimer, + const std::string& output_dir) + { +#ifdef HAVE_ERT + Opm::DataMap dm; + dm["saturation"] = &state.saturation(); + dm["pressure"] = &state.pressure(); + dm["concentration"] = &state.concentration(); + dm["cmax"] = &state.maxconcentration(); + std::vector cell_velocity; + Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity); + dm["velocity"] = &cell_velocity; + + writeECLData(grid, dm, simtimer.currentStepNum(), simtimer.currentTime(), simtimer.currentDateTime(), + output_dir, "polymer_ecl"); +#else + THROW("Cannot call outputStateBinary() without ert library support. Reconfigure with --with-ert and recompile."); +#endif + } + void outputWaterCut(const Opm::Watercut& watercut, const std::string& output_dir) {