Loading...
Searching...
No Matches
UDQActive.hpp
/*
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 UDQ_USAGE_HPP
#define UDQ_USAGE_HPP
#include <opm/input/eclipse/EclipseState/Phase.hpp>
#include <opm/input/eclipse/Schedule/UDQ/UDQEnums.hpp>
#include <opm/input/eclipse/Deck/UDAValue.hpp>
#include <cstddef>
#include <cstdlib>
#include <optional>
#include <string>
#include <vector>
namespace Opm {
class UDQConfig;
class UnitSystem;
} // namespace Opm
namespace Opm::RestartIO {
struct RstState;
} // namespace Opm::RestartIO
namespace Opm {
class UDQActive
{
public:
struct RstRecord
{
RstRecord(const UDAControl control_arg,
const UDAValue& value_arg,
const std::string& wgname_arg)
: control { control_arg }
, value { value_arg }
, wgname { wgname_arg }
{}
RstRecord(const UDAControl control_arg,
const UDAValue& value_arg,
const std::string& wgname_arg,
const Phase phase)
: RstRecord { control_arg, value_arg, wgname_arg }
{
this->ig_phase = phase;
}
UDAControl control;
UDAValue value;
std::string wgname;
std::optional<Phase> ig_phase{};
};
class OutputRecord
{
public:
OutputRecord();
OutputRecord(const std::string& udq_arg,
const std::size_t input_index_arg,
const std::string& wgname_arg,
const UDAControl control_arg);
bool operator==(const OutputRecord& other) const;
bool operator!=(const OutputRecord& other) const
{
return ! (*this == other);
}
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(udq);
serializer(input_index);
serializer(wgname);
serializer(control);
serializer(uda_code);
serializer(use_count);
}
std::string udq;
std::size_t input_index;
UDAControl control;
int uda_code{};
const std::string& wg_name() const
{
return this->wgname;
}
std::size_t use_count{};
private:
std::string wgname{};
};
class InputRecord
{
public:
InputRecord();
InputRecord(const std::size_t input_index_arg,
const std::string& udq_arg,
const std::string& wgname_arg,
const UDAControl control_arg);
bool operator==(const InputRecord& other) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(input_index);
serializer(udq);
serializer(wgname);
serializer(control);
}
std::size_t input_index;
std::string udq;
std::string wgname;
UDAControl control;
};
static UDQActive serializationTestObject();
UDQActive() = default;
static std::vector<RstRecord>
load_rst(const UnitSystem& units,
const UDQConfig& udq_config,
const RestartIO::RstState& rst_state,
const std::vector<std::string>& well_names,
const std::vector<std::string>& group_names);
int update(const UDQConfig& udq_config,
const UDAValue& uda,
const std::string& wgname,
const UDAControl control);
explicit operator bool() const;
const std::vector<OutputRecord>& iuad() const;
std::vector<InputRecord> iuap() const;
bool operator==(const UDQActive& data) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(input_data);
serializer(output_data);
}
private:
std::vector<InputRecord> input_data{};
mutable std::vector<OutputRecord> output_data{};
void constructOutputRecords() const;
};
} // namespace Opm
#endif // UDQ_USAGE_HPP
Opm::Serializer
Class for (de-)serializing.
Definition Serializer.hpp:94
Opm::UDAValue
Definition UDAValue.hpp:31
Opm::UDQActive::InputRecord::serializeOp
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition UDQActive.hpp:262
Opm::UDQActive::InputRecord::control
UDAControl control
Constraint keyword and item/limit for which this UDA supplies the numeric value.
Definition UDQActive.hpp:282
Opm::UDQActive::InputRecord::wgname
std::string wgname
Well or group affected by this UDA.
Definition UDQActive.hpp:278
Opm::UDQActive::InputRecord::udq
std::string udq
Name of the UDQ used in this UDA.
Definition UDQActive.hpp:275
Opm::UDQActive::InputRecord::input_index
std::size_t input_index
Zero-based index in order of appearance of the UDQ use for this UDA.
Definition UDQActive.hpp:272
Opm::UDQActive::InputRecord::InputRecord
InputRecord()
Default constructor.
Definition UDQActive.cpp:239
Opm::UDQActive::InputRecord::operator==
bool operator==(const InputRecord &other) const
Equality predicate.
Definition UDQActive.cpp:254
Opm::UDQActive::OutputRecord::operator!=
bool operator!=(const OutputRecord &other) const
Inequality predicate.
Definition UDQActive.hpp:165
Opm::UDQActive::OutputRecord::uda_code
int uda_code
Restart file integer representation of control.
Definition UDQActive.hpp:198
Opm::UDQActive::OutputRecord::input_index
std::size_t input_index
Zero-based index in order of appearance of the UDQ use for this UDA.
Definition UDQActive.hpp:191
Opm::UDQActive::OutputRecord::wg_name
const std::string & wg_name() const
Name of well/group affected by this UDA.
Definition UDQActive.hpp:203
Opm::UDQActive::OutputRecord::control
UDAControl control
Constraint keyword and item/limit for which this UDA supplies the numeric value.
Definition UDQActive.hpp:195
Opm::UDQActive::OutputRecord::udq
std::string udq
Name of UDQ from which this UDA derives its numeric value.
Definition UDQActive.hpp:187
Opm::UDQActive::OutputRecord::serializeOp
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition UDQActive.hpp:176
Opm::UDQActive::OutputRecord::operator==
bool operator==(const OutputRecord &other) const
Equality predicate.
Definition UDQActive.cpp:226
Opm::UDQActive::OutputRecord::use_count
std::size_t use_count
Number of times this UDA is mentioned in this particular combination of constraint keyword and item/l...
Definition UDQActive.hpp:211
Opm::UDQActive::OutputRecord::OutputRecord
OutputRecord()
Default constructor.
Definition UDQActive.cpp:207
Opm::UDQActive::iuad
const std::vector< OutputRecord > & iuad() const
Retrieve current set of UDAs, condensed by use counts and IUAP offsets.
Definition UDQActive.cpp:409
Opm::UDQActive::update
int update(const UDQConfig &udq_config, const UDAValue &uda, const std::string &wgname, const UDAControl control)
Amend collection of input UDAs to account for a new entry.
Definition UDQActive.cpp:344
Opm::UDQActive::serializeOp
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition UDQActive.hpp:377
Opm::UDQActive::load_rst
static std::vector< RstRecord > load_rst(const UnitSystem &units, const UDQConfig &udq_config, const RestartIO::RstState &rst_state, const std::vector< std::string > &well_names, const std::vector< std::string > &group_names)
Load UDAs from restart file.
Definition UDQActive.cpp:276
Opm::UDQActive::UDQActive
UDQActive()=default
Default constructor.
Opm::UDQActive::iuap
std::vector< InputRecord > iuap() const
Retrieve current set of UDAs from which to form IUAP restart file array.
Definition UDQActive.cpp:418
Opm::UDQActive::operator==
bool operator==(const UDQActive &data) const
Equality predicate.
Definition UDQActive.cpp:448
Opm::UDQActive::serializationTestObject
static UDQActive serializationTestObject()
Create a serialisation test object.
Definition UDQActive.cpp:265
Opm::UDQConfig
Collection of all user-defined quantities in the current simulation run.
Definition UDQConfig.hpp:69
Opm::UnitSystem
Definition UnitSystem.hpp:34
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Opm::RestartIO::RstState
Definition state.hpp:57
Opm::UDQActive::RstRecord::value
UDAValue value
UDA value.
Definition UDQActive.hpp:104
Opm::UDQActive::RstRecord::wgname
std::string wgname
Name of well/group affected by this UDA.
Definition UDQActive.hpp:107
Opm::UDQActive::RstRecord::RstRecord
RstRecord(const UDAControl control_arg, const UDAValue &value_arg, const std::string &wgname_arg, const Phase phase)
Constructor.
Definition UDQActive.hpp:88
Opm::UDQActive::RstRecord::ig_phase
std::optional< Phase > ig_phase
Injected phase in group level injection.
Definition UDQActive.hpp:112
Opm::UDQActive::RstRecord::RstRecord
RstRecord(const UDAControl control_arg, const UDAValue &value_arg, const std::string &wgname_arg)
Constructor.
Definition UDQActive.hpp:67
Opm::UDQActive::RstRecord::control
UDAControl control
Item/limit of constraint keyword for which this UDA supplies the numeric value.
Definition UDQActive.hpp:99