Implemented Events with DynamicVector.
As a side side effect the m_events member in the Schedule class has become a shared pointer.
This commit is contained in:
@@ -22,26 +22,22 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
Events::Events() {
|
||||
Events::Events(std::shared_ptr<const TimeMap> timeMap)
|
||||
: m_events( DynamicVector<uint64_t>( timeMap , 0 ) )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool Events::hasEvent(ScheduleEvents::Events event, size_t reportStep) const {
|
||||
if (reportStep < m_events.size()) {
|
||||
uint64_t eventSum = m_events[reportStep];
|
||||
if (eventSum & event)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
} else
|
||||
uint64_t eventSum = m_events[reportStep];
|
||||
if (eventSum & event)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Events::addEvent(ScheduleEvents::Events event, size_t reportStep) {
|
||||
if (m_events.size() <= reportStep)
|
||||
m_events.resize( 2 * reportStep + 1 );
|
||||
|
||||
m_events[reportStep] |= event;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/DynamicVector.hpp>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
namespace ScheduleEvents {
|
||||
@@ -84,11 +86,11 @@ namespace Opm
|
||||
|
||||
class Events {
|
||||
public:
|
||||
Events();
|
||||
Events(std::shared_ptr<const TimeMap> timeMap);
|
||||
void addEvent(ScheduleEvents::Events event, size_t reportStep);
|
||||
bool hasEvent(ScheduleEvents::Events event, size_t reportStep) const;
|
||||
private:
|
||||
std::vector<uint64_t> m_events;
|
||||
DynamicVector<uint64_t> m_events;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace Opm {
|
||||
initializeNOSIM(deck);
|
||||
createTimeMap(deck);
|
||||
m_tuning.reset(new Tuning(m_timeMap));
|
||||
m_events.reset(new Events(m_timeMap));
|
||||
addGroup( "FIELD", 0 );
|
||||
initRootGroupTreeNode(getTimeMap());
|
||||
initOilVaporization(getTimeMap());
|
||||
@@ -306,7 +307,7 @@ namespace Opm {
|
||||
|
||||
if (needNewTree) {
|
||||
m_rootGroupTree->update(currentStep, newTree);
|
||||
m_events.addEvent( ScheduleEvents::GROUP_CHANGE , currentStep);
|
||||
m_events->addEvent( ScheduleEvents::GROUP_CHANGE , currentStep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,8 +408,8 @@ namespace Opm {
|
||||
}
|
||||
updateWellStatus( well , currentStep , status );
|
||||
if (well->setProductionProperties(currentStep, properties))
|
||||
m_events.addEvent( ScheduleEvents::PRODUCTION_UPDATE , currentStep);
|
||||
|
||||
m_events->addEvent( ScheduleEvents::PRODUCTION_UPDATE , currentStep);
|
||||
|
||||
if ( !well->getAllowCrossFlow() && !isPredictionMode && (properties.OilRate + properties.WaterRate + properties.GasRate) == 0 ) {
|
||||
|
||||
std::string msg =
|
||||
@@ -417,14 +418,13 @@ namespace Opm {
|
||||
OpmLog::addMessage(Log::MessageType::Info , Log::prefixMessage(Log::MessageType::Info, msg));
|
||||
updateWellStatus(well, currentStep, WellCommon::StatusEnum::SHUT );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Schedule::updateWellStatus(std::shared_ptr<Well> well, size_t reportStep , WellCommon::StatusEnum status) {
|
||||
if (well->setStatus( reportStep , status ))
|
||||
m_events.addEvent( ScheduleEvents::WELL_STATUS_CHANGE , reportStep );
|
||||
m_events->addEvent( ScheduleEvents::WELL_STATUS_CHANGE , reportStep );
|
||||
}
|
||||
|
||||
|
||||
@@ -583,7 +583,7 @@ namespace Opm {
|
||||
}
|
||||
|
||||
if (well->setInjectionProperties(currentStep, properties))
|
||||
m_events.addEvent( ScheduleEvents::INJECTION_UPDATE , currentStep );
|
||||
m_events->addEvent( ScheduleEvents::INJECTION_UPDATE , currentStep );
|
||||
|
||||
if ( ! well->getAllowCrossFlow() && (properties.surfaceInjectionRate == 0) ) {
|
||||
std::string msg =
|
||||
@@ -674,7 +674,7 @@ namespace Opm {
|
||||
properties.predictionMode = false;
|
||||
|
||||
if (well->setInjectionProperties(currentStep, properties))
|
||||
m_events.addEvent( ScheduleEvents::INJECTION_UPDATE , currentStep );
|
||||
m_events->addEvent( ScheduleEvents::INJECTION_UPDATE , currentStep );
|
||||
|
||||
if ( ! well->getAllowCrossFlow() && (injectionRate == 0) ) {
|
||||
std::string msg =
|
||||
@@ -683,7 +683,6 @@ namespace Opm {
|
||||
OpmLog::addMessage(Log::MessageType::Info , Log::prefixMessage(Log::MessageType::Info, msg));
|
||||
updateWellStatus(well, currentStep, WellCommon::StatusEnum::SHUT );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,7 +766,7 @@ namespace Opm {
|
||||
}
|
||||
|
||||
well->addCompletionSet(currentStep, newCompletionSet);
|
||||
m_events.addEvent(ScheduleEvents::COMPLETION_CHANGE, currentStep);
|
||||
m_events->addEvent(ScheduleEvents::COMPLETION_CHANGE, currentStep);
|
||||
if (newCompletionSet->allCompletionsShut())
|
||||
updateWellStatus( well , currentStep , WellCommon::StatusEnum::SHUT);
|
||||
|
||||
@@ -1206,7 +1205,7 @@ namespace Opm {
|
||||
WellPtr well = getWell(wellName);
|
||||
well->addCompletions(currentStep, iter->second);
|
||||
}
|
||||
m_events.addEvent(ScheduleEvents::COMPLETION_CHANGE, currentStep);
|
||||
m_events->addEvent(ScheduleEvents::COMPLETION_CHANGE, currentStep);
|
||||
}
|
||||
|
||||
void Schedule::handleWGRUPCON(DeckKeywordConstPtr keyword, size_t currentStep) {
|
||||
@@ -1353,7 +1352,7 @@ namespace Opm {
|
||||
|
||||
well = std::make_shared<Well>(wellName, m_grid , headI, headJ, refDepth, preferredPhase, m_timeMap , timeStep, wellCompletionOrder, allowCrossFlow);
|
||||
m_wells.insert( wellName , well);
|
||||
m_events.addEvent( ScheduleEvents::NEW_WELL , timeStep );
|
||||
m_events->addEvent( ScheduleEvents::NEW_WELL , timeStep );
|
||||
}
|
||||
|
||||
size_t Schedule::numWells() const {
|
||||
@@ -1433,7 +1432,7 @@ namespace Opm {
|
||||
}
|
||||
GroupPtr group(new Group(groupName, m_timeMap , timeStep));
|
||||
m_groups[ groupName ] = group;
|
||||
m_events.addEvent( ScheduleEvents::NEW_GROUP , timeStep );
|
||||
m_events->addEvent( ScheduleEvents::NEW_GROUP , timeStep );
|
||||
}
|
||||
|
||||
size_t Schedule::numGroups() const {
|
||||
@@ -1534,7 +1533,7 @@ namespace Opm {
|
||||
}
|
||||
|
||||
const Events& Schedule::getEvents() const {
|
||||
return m_events;
|
||||
return *m_events;
|
||||
}
|
||||
|
||||
OilVaporizationPropertiesConstPtr Schedule::getOilVaporizationProperties(size_t timestep){
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace Opm
|
||||
std::map<std::string , GroupPtr> m_groups;
|
||||
std::shared_ptr<DynamicState<GroupTreePtr> > m_rootGroupTree;
|
||||
std::shared_ptr<DynamicState<OilVaporizationPropertiesPtr> > m_oilvaporizationproperties;
|
||||
Events m_events;
|
||||
std::shared_ptr<Events> m_events;
|
||||
TuningPtr m_tuning;
|
||||
bool nosim;
|
||||
|
||||
|
||||
@@ -21,14 +21,21 @@
|
||||
#include <iostream>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#define BOOST_TEST_MODULE CompletionSetTests
|
||||
#define BOOST_TEST_MODULE EventTests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Events.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CreateEmpty) {
|
||||
Opm::Events events;
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(boost::posix_time::ptime(startDate)));
|
||||
Opm::DynamicVector<double> vector(timeMap , 9.99);
|
||||
Opm::Events events( timeMap );
|
||||
|
||||
for (size_t i = 0; i < 11; i++)
|
||||
timeMap->addTStep( boost::posix_time::hours( (i+1) * 24 ));
|
||||
|
||||
BOOST_CHECK_EQUAL( false , events.hasEvent(Opm::ScheduleEvents::NEW_WELL , 10));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user