Merge pull request #668 from joakim-hove/udq-fieldset

UDQ field and group variables
This commit is contained in:
Bård Skaflestad
2019-06-03 12:01:37 +02:00
committed by GitHub
25 changed files with 540 additions and 332 deletions

View File

@@ -24,7 +24,7 @@
#include <string>
#include <vector>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQWellSet.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
namespace Opm {
@@ -36,7 +36,7 @@ public:
double value() const;
UDQVarType var_type() const;
const std::vector<std::string>& selector() const;
UDQWellSet eval_wells(const std::vector<std::string>& wells) const;
UDQSet eval(const std::vector<std::string>& wells) const;
private:
std::string m_keyword;
UDQVarType m_var_type;

View File

@@ -35,9 +35,11 @@ namespace Opm {
UDQContext(const UDQFunctionTable& udqft, const SummaryState& summary_state);
double get(const std::string& key) const;
double get_well_var(const std::string& well, const std::string& var) const;
double get_group_var(const std::string& group, const std::string& var) const;
void add(const std::string& key, double value);
const UDQFunctionTable& function_table() const;
std::vector<std::string> wells() const;
std::vector<std::string> groups() const;
private:
const UDQFunctionTable& udqft;
const SummaryState& summary_state;

View File

@@ -25,7 +25,7 @@
#include <vector>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQWellSet.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp>
@@ -55,7 +55,6 @@ public:
T&& errors);
UDQWellSet eval_wells(const UDQContext& context) const;
UDQSet eval(const UDQContext& context) const;
const std::string& keyword() const;
const std::vector<std::string>& tokens() const;

View File

@@ -24,14 +24,16 @@
namespace Opm {
enum class UDQVarType {
WELL_VAR = 1,
CONNECTION_VAR= 2,
FIELD_VAR = 3,
GROUP_VAR = 4,
REGION_VAR = 5,
SEGMENT_VAR = 6,
AQUIFER_VAR = 7,
BLOCK_VAR = 8
NONE = 0,
SCALAR = 1,
WELL_VAR = 2,
CONNECTION_VAR= 3,
FIELD_VAR = 4,
GROUP_VAR = 5,
REGION_VAR = 6,
SEGMENT_VAR = 7,
AQUIFER_VAR = 8,
BLOCK_VAR = 9
};
@@ -101,6 +103,8 @@ enum class UDQAction {
namespace UDQ {
bool compatibleTypes(UDQVarType lhs, UDQVarType rhs);
UDQVarType targetType(const std::string& keyword);
UDQVarType varType(const std::string& keyword);
UDQAction actionType(const std::string& action_string);
UDQTokenType funcType(const std::string& func_name);
@@ -108,6 +112,7 @@ namespace UDQ {
bool elementalUnaryFunc(UDQTokenType token_type);
bool scalarFunc(UDQTokenType token_type);
bool cmpFunc(UDQTokenType token_type);
}
}

View File

@@ -44,22 +44,22 @@ private:
class UDQScalarFunction : public UDQFunction {
public:
UDQScalarFunction(const std::string&name, std::function<UDQScalar(const UDQSet& arg)> f);
UDQScalar eval(const UDQSet& arg) const;
UDQScalarFunction(const std::string&name, std::function<UDQSet(const UDQSet& arg)> f);
UDQSet eval(const UDQSet& arg) const;
static UDQScalar SUM(const UDQSet& arg);
static UDQScalar AVEA(const UDQSet& arg);
static UDQScalar AVEG(const UDQSet& arg);
static UDQScalar AVEH(const UDQSet& arg);
static UDQScalar MIN(const UDQSet& arg);
static UDQScalar MAX(const UDQSet& arg);
static UDQScalar NORM1(const UDQSet& arg);
static UDQScalar NORM2(const UDQSet& arg);
static UDQScalar NORMI(const UDQSet& arg);
static UDQScalar PROD(const UDQSet& arg);
static UDQSet SUM(const UDQSet& arg);
static UDQSet AVEA(const UDQSet& arg);
static UDQSet AVEG(const UDQSet& arg);
static UDQSet AVEH(const UDQSet& arg);
static UDQSet MIN(const UDQSet& arg);
static UDQSet MAX(const UDQSet& arg);
static UDQSet NORM1(const UDQSet& arg);
static UDQSet NORM2(const UDQSet& arg);
static UDQSet NORMI(const UDQSet& arg);
static UDQSet PROD(const UDQSet& arg);
private:
std::function<UDQScalar(const UDQSet& arg)> func;
std::function<UDQSet(const UDQSet& arg)> func;
};

View File

@@ -23,6 +23,9 @@
#include <stdexcept>
#include <vector>
#include <string>
#include <unordered_map>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
namespace Opm {
@@ -53,8 +56,17 @@ public:
class UDQSet {
public:
UDQSet(const std::string& name, std::size_t size);
static UDQSet scalar(const std::string& name, double value);
static UDQSet empty(const std::string& name);
static UDQSet wells(const std::string& name, const std::vector<std::string>& wells);
static UDQSet wells(const std::string& name, const std::vector<std::string>& wells, double scalar_value);
static UDQSet groups(const std::string& name, const std::vector<std::string>& groups);
static UDQSet groups(const std::string& name, const std::vector<std::string>& groups, double scalar_value);
static UDQSet field(const std::string& name, double scalar_value);
void assign(double value);
void assign(std::size_t index, double value);
void assign(const std::string& wgname, double value);
std::size_t size() const;
void operator+=(const UDQSet& rhs);
@@ -67,14 +79,22 @@ public:
void operator/=(double rhs);
const UDQScalar& operator[](std::size_t index) const;
const UDQScalar& operator[](const std::string& wgname) const;
std::vector<UDQScalar>::const_iterator begin() const;
std::vector<UDQScalar>::const_iterator end() const;
std::vector<double> defined_values() const;
std::size_t defined_size() const;
const std::string& name() const;
UDQVarType var_type() const;
private:
UDQSet() = default;
UDQSet(const std::string& name, UDQVarType var_type, std::size_t size);
std::string m_name;
UDQVarType m_var_type;
std::unordered_map<std::string, std::size_t> wgname_index;
std::vector<UDQScalar> values;
};

View File

@@ -1,50 +0,0 @@
/*
Copyright 2019 Equinor 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/>.
*/
#ifndef UDQWELLSET_HPP
#define UDQWELLSET_HPP
#include <vector>
#include <string>
#include <unordered_map>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.hpp>
namespace Opm {
class UDQWellSet : public UDQSet {
public:
UDQWellSet(const std::string& name, const std::vector<std::string>& wells);
UDQWellSet(const std::string& name, const std::vector<std::string>& wells, const UDQSet& values);
UDQWellSet(const std::string& name, const std::vector<std::string>& wells, double scalar_value);
void assign(const std::string& well, double value);
void assign(double value);
const UDQScalar& operator[](const std::string& well) const;
private:
std::size_t wellIndex(const std::string& well) const;
std::unordered_map<std::string, std::size_t> well_index;
};
}
#endif

View File

@@ -254,6 +254,7 @@ namespace Opm {
const static std::string UNSUPPORTED_TERMINATE_IF_BHP;
const static std::string UDQ_PARSE_ERROR;
const static std::string UDQ_TYPE_ERROR;
/*
If the third item in the THPRES keyword is defaulted the