Added events to wells.

This commit is contained in:
Joakim Hove
2017-04-05 14:43:25 +02:00
parent 39859c8d88
commit 67dd83264b
5 changed files with 89 additions and 15 deletions

View File

@@ -28,15 +28,27 @@ namespace Opm
namespace ScheduleEvents {
// These values are used as bitmask - 2^n structure is essential.
enum Events {
/* The NEW_WELL event is triggered by the WELSPECS
keyword. */
/*
The NEW_WELL event is triggered by the WELSPECS
keyword. For wells the event is triggered the first
time the well is mentioned in the WELSPECS keyword, for
the Schedule object the NEW_WELL event is triggered
every time a WELSPECS keyword is encountered.
*/
NEW_WELL = 1,
/*
WHen the well data is updated with the WELSPECS keyword
this event is triggered. Only applies to individual
wells, and not the global Schedule object.
*/
WELL_WELSPECS_UPDATE = 2,
/*
The NEW_GROUP event is triggered by the WELSPECS and
GRUPTREE keywords.
*/
NEW_GROUP = 2,
NEW_GROUP = 4,
/*
The PRODUCTION_UPDATE event is triggered by the
@@ -45,32 +57,32 @@ namespace Opm
is changed. Quite simlar for INJECTION_UPDATE and
POLYMER_UPDATE.
*/
PRODUCTION_UPDATE = 4,
INJECTION_UPDATE = 8,
POLYMER_UPDATES = 16,
PRODUCTION_UPDATE = 8,
INJECTION_UPDATE = 16,
POLYMER_UPDATES = 32,
/*
This event is triggered if the well status is changed
between {OPEN,SHUT,STOP,AUTO}. There are many keywords
which can trigger a well status change.
*/
WELL_STATUS_CHANGE = 32,
WELL_STATUS_CHANGE = 64,
/*
COMPDAT and WELOPEN
*/
COMPLETION_CHANGE = 64,
COMPLETION_CHANGE = 128,
/*
The well group topolyg has changed.
*/
GROUP_CHANGE = 128,
GROUP_CHANGE = 256,
/*
Geology modifier.
*/
GEO_MODIFIER = 256
GEO_MODIFIER = 512
};
}

View File

@@ -327,6 +327,7 @@ namespace Opm {
const auto& record = keyword.getRecord(recordNr);
const std::string& wellName = record.getItem("WELL").getTrimmedString(0);
const std::string& groupName = record.getItem("GROUP").getTrimmedString(0);
bool new_well = false;
if (!hasGroup(groupName))
addGroup(groupName , currentStep);
@@ -348,12 +349,15 @@ namespace Opm {
}
}
addWell(wellName, record, currentStep, wellCompletionOrder);
new_well = true;
}
auto& currentWell = this->m_wells.get( wellName );
const auto headI = record.getItem( "HEAD_I" ).get< int >( 0 ) - 1;
const auto headJ = record.getItem( "HEAD_J" ).get< int >( 0 ) - 1;
if (!new_well)
currentWell.addEvent( ScheduleEvents::WELL_WELSPECS_UPDATE , currentStep );
if( currentWell.getHeadI() != headI ) {
std::string msg = "HEAD_I changed for well " + currentWell.name();
@@ -467,7 +471,7 @@ namespace Opm {
updateWellStatus( *well , currentStep , status );
if (well->setProductionProperties(currentStep, properties))
m_events.addEvent( ScheduleEvents::PRODUCTION_UPDATE , currentStep);
if ( !well->getAllowCrossFlow() && !isPredictionMode && (properties.OilRate + properties.WaterRate + properties.GasRate) == 0 ) {
std::string msg =

View File

@@ -62,8 +62,11 @@ namespace Opm {
m_allowCrossFlow(allowCrossFlow),
m_automaticShutIn(automaticShutIn),
m_segmentset( timeMap, SegmentSet{} ),
timesteps( timeMap.numTimesteps() )
{}
timesteps( timeMap.numTimesteps() ),
events( timeMap )
{
addEvent( ScheduleEvents::NEW_WELL , creationTimeStep );
}
const std::string& Well::name() const {
return m_name;
@@ -208,13 +211,19 @@ namespace Opm {
if ((WellCommon::StatusEnum::OPEN == status) && getCompletions(timeStep).allCompletionsShut()) {
m_messages.note("When handling keyword for well " + name() + ": Cannot open a well where all completions are shut");
return false;
} else
return m_status.update( timeStep , status );
} else {
bool update = m_status.update( timeStep , status );
if (update)
addEvent( ScheduleEvents::WELL_STATUS_CHANGE , timeStep );
return update;
}
}
const MessageContainer& Well::getMessageContainer() const {
return m_messages;
}
bool Well::isProducer(size_t timeStep) const {
return bool( m_isProducer.get(timeStep) );
}
@@ -354,6 +363,7 @@ namespace Opm {
}
m_completions.update( time_step, std::move( new_set ) );
addEvent( ScheduleEvents::COMPLETION_CHANGE , time_step );
}
const std::string Well::getGroupName(size_t time_step) const {
@@ -493,4 +503,16 @@ namespace Opm {
}
m_segmentset.update(time_step, new_segmentset);
}
void Well::addEvent(ScheduleEvents::Events event, size_t reportStep) {
this->events.addEvent( event , reportStep );
}
bool Well::hasEvent(uint64_t eventMask, size_t reportStep) const {
return this->events.hasEvent( eventMask , reportStep );
}
}

View File

@@ -26,6 +26,7 @@
#include <vector>
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Events.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/CompletionSet.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/DynamicState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/WellEconProductionLimits.hpp>
@@ -150,6 +151,9 @@ namespace Opm {
void addSegmentSet(size_t time_step, SegmentSet new_segmentset);
const MessageContainer& getMessageContainer() const;
const Events& getEvents() const;
void addEvent(ScheduleEvents::Events event, size_t reportStep);
bool hasEvent(uint64_t eventMask, size_t reportStep) const;
private:
size_t m_creationTimeStep;
std::string m_name;
@@ -185,6 +189,7 @@ namespace Opm {
// flag indicating if the well is a multi-segment well
DynamicState< SegmentSet > m_segmentset;
size_t timesteps;
Events events;
};
}