Add method to get filtered UDQ assignment types

This commit is contained in:
Joakim Hove 2019-02-22 09:34:06 +01:00
parent a91d47f191
commit 6bf64b18fe
4 changed files with 21 additions and 0 deletions

View File

@ -34,6 +34,7 @@ public:
UDQAssign(const std::string& keyword, const std::vector<std::string>& selector, double value);
const std::string& keyword() const;
double value() const;
UDQVarType var_type() const;
const std::vector<std::string>& selector() const;
UDQWellSet eval_wells(const std::vector<std::string>& wells) const;
private:

View File

@ -26,6 +26,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQExpression.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQAssign.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
namespace Opm {
@ -38,6 +39,7 @@ namespace Opm {
const std::string& unit(const std::string& key) const;
void assign_unit(const std::string& keyword, const std::string& unit);
const std::vector<UDQAssign>& assignments() const;
std::vector<UDQAssign> assignments(UDQVarType var_type) const;
private:
std::vector<UDQExpression> m_expressions;
std::vector<UDQAssign> m_assignments;

View File

@ -42,6 +42,10 @@ double UDQAssign::value() const {
return this->m_value;
}
UDQVarType UDQAssign::var_type() const {
return this->m_var_type;
}
UDQWellSet UDQAssign::eval_wells(const std::vector<std::string>& wells) const {
UDQWellSet ws(m_keyword, wells);

View File

@ -17,6 +17,8 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <algorithm>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.hpp>
@ -59,6 +61,18 @@ namespace Opm {
}
std::vector<UDQAssign> UDQInput::assignments(UDQVarType var_type) const {
std::vector<UDQAssign> filtered_assignments;
std::copy_if(this->m_assignments.begin(),
this->m_assignments.end(),
std::back_inserter(filtered_assignments),
[&var_type](const UDQAssign& assignment) { return assignment.var_type() == var_type; });
return filtered_assignments;
}
const std::string& UDQInput::unit(const std::string& key) const {
const auto pair_ptr = this->units.find(key);
if (pair_ptr == this->units.end())