Updated opm-flowdiagnostics-applications to SHA afd3f6c454f52dcfa0a6aa96be9823176a6daa48

This commit is contained in:
Jacob Støren 2017-03-31 09:13:18 +02:00
parent feeb16fe70
commit 9a11949f67
8 changed files with 109 additions and 113 deletions

View File

@ -14,7 +14,7 @@ set(OPM_COMMON_GITHUB_SHA "1216bc052542f24ec6fcfbe1947d52e6300ff754")
set(OPM_PARSER_GITHUB_SHA "a3496df501a4369fd827fbf0ff893d03deff425f")
set(OPM_FLOWDIAGNOSTICS_SHA "a14dc4ba1302bcc1e0aeb35c5de6b4bd39bce98")
set(OPM_FLOWDIAGNOSTICS_APPLICATIONS_SHA "09057e5767e492fa44c5e9ae78e9e1fcc9694b6c")
set(OPM_FLOWDIAGNOSTICS_APPLICATIONS_SHA "afd3f6c454f52dcfa0a6aa96be9823176a6daa48")
# sha for Units.hpp 9a679071dd0066236154852c39a9e0b3c3ac4873

View File

@ -36,6 +36,7 @@ list (APPEND EXAMPLE_SOURCE_FILES
examples/computeLocalSolutions.cpp
examples/computeToFandTracers.cpp
examples/computeTracers.cpp
examples/extractFromRestart.cpp
tests/runAcceptanceTest.cpp
tests/runLinearisedCellDataTest.cpp
tests/runTransTest.cpp

View File

@ -33,6 +33,7 @@ try {
auto& fdTool = setup.toolbox;
// Create start sets from injector wells.
using ID = Opm::FlowDiagnostics::CellSetID;
std::vector<Opm::FlowDiagnostics::CellSet> start;
for (const auto& well : setup.well_fluxes) {
if (!well.is_injector_well) {
@ -48,19 +49,24 @@ try {
completion_cells.push_back(cell_index);
}
}
start.emplace_back(Opm::FlowDiagnostics::CellSetID(well.name), completion_cells);
start.emplace_back(ID(well.name), completion_cells);
}
// Solve for injection time of flight and tracers.
auto sol = fdTool.computeInjectionDiagnostics(start);
// Get local tof for first injector.
const auto& tof = sol.fd.timeOfFlight(start.front().id());
// Choose injector id, default to first injector.
const std::string id_string = setup.param.getDefault("id", start.front().id().to_string());
const ID id(id_string);
// Get local data for injector.
const bool tracer = setup.param.getDefault("tracer", false);
const auto& data = tracer ? sol.fd.concentration(id) : sol.fd.timeOfFlight(id);
// Write it to standard out.
std::cout.precision(16);
for (auto item : tof) {
for (auto item : data) {
std::cout << item.first << " " << item.second << '\n';
}
}

View File

@ -124,7 +124,12 @@ namespace example {
const auto& ijk = completion.ijk;
const int cell_index = G.activeCell(ijk, grid_index);
if (cell_index >= 0) {
inflow.emplace(cell_index, completion.reservoir_inflow_rate);
// Since inflow is a std::map, if the key was not
// already present operator[] will insert a
// value-initialized value (as in T() for a type
// T), which is zero for built-in numerical types,
// including double.
inflow[cell_index] += completion.reservoir_inflow_rate;
}
}
}

View File

@ -0,0 +1,74 @@
/*
Copyright 2017 SINTEF DIGITAL, Mathematics and Cybernetics.
Copyright 2016 Statoil ASA.
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 <http://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include <opm/core/utility/parameters/ParameterGroup.hpp>
#include <opm/utility/ECLResultData.hpp>
// Syntax (typical):
// extractFromRestart unrst=<ecl_unrst file> step=<report_number> keyword=<keyword to dump> grid_id=<grid number>
int main(int argc, char* argv[]) {
try {
Opm::parameter::ParameterGroup param(argc, argv,
/*verify_commandline_syntax=*/ true,
/*parameter_output=*/ false);
const std::string unrst_file = param.get<std::string>("unrst");
const int report_step = param.getDefault("step", int(0));
const int grid_id = param.getDefault("grid_id", int(0));
const std::string keyword = param.get<std::string>("keyword");
Opm::ECLResultData restart_file(unrst_file);
if (!restart_file.selectReportStep(report_step)) {
std::cerr << "Could not find report step " << report_step << "." << std::endl;
exit(-1);
}
if (restart_file.haveKeywordData(keyword, grid_id)) {
const std::vector<double>& data = restart_file.keywordData<double>(keyword, grid_id);
std::cout.precision(20);
// Write out to cout in a matlab-friendly fashion.
std::cout << "kw_" << keyword << " = {" << std::endl
<< "'unrst_file=" << unrst_file << "'," << std::endl
<< "'step=" << report_step << "'," << std::endl
<< "'grid_id=" << grid_id << "'," << std::endl;
std::cout << "[";
std::ostream_iterator<double> out_it(std::cout, ", ");
std::copy(data.begin(), --data.end(), out_it);
std::cout << data.back();
std::cout << "]" << std::endl;
std::cout << "};" << std::endl;
}
else {
std::cerr << "Could not find the keyword " << keyword
<< " in report step " << report_step << "." << std::endl;
exit(-1);
}
}
catch (const std::exception& e) {
std::cerr << "Caught exception: " << e.what() << '\n';
}
}

View File

@ -18,6 +18,7 @@
*/
#include <opm/utility/ECLFluxCalc.hpp>
#include <opm/parser/eclipse/Units/Units.hpp>
namespace Opm
{
@ -35,14 +36,15 @@ namespace Opm
std::vector<double> ECLFluxCalc::flux(const PhaseIndex /* phase */) const
{
// Obtain pressure vector.
std::vector<double> pressure = graph_.linearisedCellData("PRESSURE", &ECLUnits::UnitSystem::pressure);
// Obtain dynamic data.
DynamicData dyn_data;
dyn_data.pressure = graph_.linearisedCellData("PRESSURE", &ECLUnits::UnitSystem::pressure);
// Compute fluxes per connection.
const int num_conn = transmissibility_.size();
std::vector<double> fluxvec(num_conn);
for (int conn = 0; conn < num_conn; ++conn) {
fluxvec[conn] = singleFlux(conn, pressure);
fluxvec[conn] = singleFlux(conn, dyn_data);
}
return fluxvec;
}
@ -52,12 +54,15 @@ namespace Opm
double ECLFluxCalc::singleFlux(const int connection,
const std::vector<double>& pressure) const
const DynamicData& dyn_data) const
{
const int c1 = neighbours_[2*connection];
const int c2 = neighbours_[2*connection + 1];
const double t = transmissibility_[connection];
return t * (pressure[c1] - pressure[c2]);
const double transmissibility = transmissibility_[connection];
const double viscosity = 1.0 * prefix::centi * unit::Poise;
const double mobility = 1.0 / viscosity;
const auto& pressure = dyn_data.pressure;
return mobility * transmissibility * (pressure[c1] - pressure[c2]);
}

View File

@ -48,8 +48,13 @@ namespace Opm
std::vector<double> flux(const PhaseIndex phase) const;
private:
struct DynamicData
{
std::vector<double> pressure;
};
double singleFlux(const int connection,
const std::vector<double>& pressure) const;
const DynamicData& dyn_data) const;
const ECLGraph& graph_;
std::vector<int> neighbours_;

View File

@ -48,106 +48,6 @@
#include <ert/ecl/ecl_kw_magic.h>
#include <ert/util/ert_unique_ptr.hpp>
namespace StringUtils {
namespace {
std::string trim(const std::string& s)
{
const auto anchor_ws =
boost::regex(R"~~(^\s+([^\s]+)\s+$)~~");
auto m = boost::smatch{};
if (boost::regex_match(s, m, anchor_ws)) {
return m[1];
}
return s;
}
std::vector<std::string> split(const std::string& s)
{
if (s.empty()) {
// Single element vector whose only element is the empty
// string.
return { "" };
}
const auto sep = boost::regex(R"~~([\s,;.|]+)~~");
using TI = boost::sregex_token_iterator;
// vector<string>(begin, end)
//
// Range is every substring (i.e., token) in input string 's'
// that does NOT match 'sep'.
return{ TI(s.begin(), s.end(), sep, -1), TI{} };
}
} // namespace Anonymous
template <typename T>
struct StringTo;
template <>
struct StringTo<int>
{
static int value(const std::string& s);
};
template <>
struct StringTo<double>
{
static double value(const std::string& s);
};
template <>
struct StringTo<std::string>
{
static std::string value(const std::string& s);
};
int StringTo<int>::value(const std::string& s)
{
return std::stoi(s);
}
double StringTo<double>::value(const std::string& s)
{
return std::stod(s);
}
std::string StringTo<std::string>::value(const std::string& s)
{
return trim(s);
}
namespace VectorValue {
template <typename T>
std::vector<T> get(const std::string& s, std::true_type)
{
return split(s);
}
template <typename T>
std::vector<T> get(const std::string& s, std::false_type)
{
const auto tokens = split(s);
auto ret = std::vector<T>{};
ret.reserve(tokens.size());
for (const auto& token : tokens) {
ret.push_back(StringTo<T>::value(token));
}
return ret;
}
template <typename T>
std::vector<T> get(const std::string& s)
{
return get<T>(s, typename std::is_same<T, std::string>::type());
}
} // namespace VectorValue
} // namespace StringUtils
namespace {
struct PoreVolume