mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Adressing comments in the PR
The following comments has been adressed 1. An array is used in stead of pair 2. is not empty is used instead of size>0 to check if the well has been initialized before 3. const_iterator is used instead of iterator 4. partial copy is removed 5. WellMapType is no longer mutable
This commit is contained in:
parent
b4a7b6157b
commit
b614aa5f90
@ -31,6 +31,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
@ -40,9 +41,10 @@ namespace Opm
|
|||||||
class WellStateFullyImplicitBlackoil
|
class WellStateFullyImplicitBlackoil
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::pair<int,int> mapentry_t;
|
typedef std::array< int, 2 > mapentry_t;
|
||||||
typedef std::map< std::string, mapentry_t > WellMapType;
|
typedef std::map< std::string, mapentry_t > WellMapType;
|
||||||
|
|
||||||
|
|
||||||
/// Allocate and initialize if wells is non-null. Also tries
|
/// Allocate and initialize if wells is non-null. Also tries
|
||||||
/// to give useful initial values to the bhp(), wellRates()
|
/// to give useful initial values to the bhp(), wellRates()
|
||||||
/// and perfPhaseRates() fields, depending on controls
|
/// and perfPhaseRates() fields, depending on controls
|
||||||
@ -71,9 +73,8 @@ namespace Opm
|
|||||||
std::string name( wells->name[ w ] );
|
std::string name( wells->name[ w ] );
|
||||||
assert( name.size() > 0 );
|
assert( name.size() > 0 );
|
||||||
mapentry_t& wellMapEntry = wellMap_[ name ];
|
mapentry_t& wellMapEntry = wellMap_[ name ];
|
||||||
assert( wellMapEntry.size() == 0 );
|
wellMapEntry[ 0 ] = w ;
|
||||||
wellMapEntry.first = w ;
|
wellMapEntry[ 1 ] = wells->well_connpos[w ] ;
|
||||||
wellMapEntry.second = wells->well_connpos[w ] ;
|
|
||||||
if (well_controls_well_is_shut(ctrl)) {
|
if (well_controls_well_is_shut(ctrl)) {
|
||||||
// Shut well: perfphaserates_ are all zero.
|
// Shut well: perfphaserates_ are all zero.
|
||||||
} else {
|
} else {
|
||||||
@ -98,16 +99,16 @@ namespace Opm
|
|||||||
|
|
||||||
// intialize wells that have been there before
|
// intialize wells that have been there before
|
||||||
// order may change so the mapping is based on the well name
|
// order may change so the mapping is based on the well name
|
||||||
if( prevState.wellMap().size() > 0 )
|
if( ! prevState.wellMap().empty() )
|
||||||
{
|
{
|
||||||
typedef typename WellMapType :: iterator iterator;
|
typedef typename WellMapType :: const_iterator const_iterator;
|
||||||
const iterator end = prevState.wellMap().end();
|
const_iterator end = prevState.wellMap().end();
|
||||||
for (int w = 0; w < nw; ++w) {
|
for (int w = 0; w < nw; ++w) {
|
||||||
std::string name( wells->name[ w ] );
|
std::string name( wells->name[ w ] );
|
||||||
iterator it = prevState.wellMap().find( name );
|
const_iterator it = prevState.wellMap().find( name );
|
||||||
if( it != end )
|
if( it != end )
|
||||||
{
|
{
|
||||||
const int oldIndex = (*it).second.first;
|
const int oldIndex = (*it).second[ 0 ];
|
||||||
const int newIndex = w;
|
const int newIndex = w;
|
||||||
|
|
||||||
// bhp
|
// bhp
|
||||||
@ -120,7 +121,7 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
|
|
||||||
// perfPhaseRates
|
// perfPhaseRates
|
||||||
int oldPerf = (*it).second.second * np;
|
int oldPerf = (*it).second[ 1 ] * np;
|
||||||
for (int perf = wells->well_connpos[ newIndex ]*np;
|
for (int perf = wells->well_connpos[ newIndex ]*np;
|
||||||
perf < wells->well_connpos[ newIndex + 1]*np; ++perf, ++oldPerf )
|
perf < wells->well_connpos[ newIndex + 1]*np; ++perf, ++oldPerf )
|
||||||
{
|
{
|
||||||
@ -168,50 +169,13 @@ namespace Opm
|
|||||||
return wellRates().size() / numWells();
|
return wellRates().size() / numWells();
|
||||||
}
|
}
|
||||||
|
|
||||||
WellMapType& wellMap() const { return wellMap_; }
|
const WellMapType& wellMap() const { return wellMap_; }
|
||||||
|
|
||||||
/// Copy data for the first num_wells_to_copy from source,
|
|
||||||
/// overwriting any data in this object associated with those
|
|
||||||
/// wells. Assumes that the number of phases are the same,
|
|
||||||
/// that the number of perforations associated with the wells
|
|
||||||
/// is unchanging, and that both objects contain at least
|
|
||||||
/// num_wells_to_copy wells.
|
|
||||||
void partialCopy(const WellStateFullyImplicitBlackoil& source,
|
|
||||||
const Wells& wells,
|
|
||||||
const int num_wells_to_copy)
|
|
||||||
{
|
|
||||||
std::abort();
|
|
||||||
|
|
||||||
if (numPhases() != source.numPhases()) {
|
|
||||||
OPM_THROW(std::logic_error, "partialCopy(): source and destination have different number of phases.");
|
|
||||||
}
|
|
||||||
if (num_wells_to_copy > numWells() || num_wells_to_copy > source.numWells()) {
|
|
||||||
OPM_THROW(std::logic_error, "partialCopy(): trying to copy too many wells.");
|
|
||||||
}
|
|
||||||
// bhp
|
|
||||||
std::copy(source.bhp().begin(),
|
|
||||||
source.bhp().begin() + num_wells_to_copy,
|
|
||||||
bhp().begin());
|
|
||||||
// wellRates
|
|
||||||
std::copy(source.wellRates().begin(),
|
|
||||||
source.wellRates().begin() + numPhases()*num_wells_to_copy,
|
|
||||||
wellRates().begin());
|
|
||||||
// perfPhaseRates
|
|
||||||
const int num_perfs_to_copy = wells.well_connpos[num_wells_to_copy];
|
|
||||||
std::copy(source.perfPhaseRates().begin(),
|
|
||||||
source.perfPhaseRates().begin() + numPhases()*num_perfs_to_copy,
|
|
||||||
perfPhaseRates().begin());
|
|
||||||
// currentControls
|
|
||||||
std::copy(source.currentControls().begin(),
|
|
||||||
source.currentControls().begin() + num_wells_to_copy,
|
|
||||||
currentControls().begin());
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WellState basic_well_state_;
|
WellState basic_well_state_;
|
||||||
std::vector<double> perfphaserates_;
|
std::vector<double> perfphaserates_;
|
||||||
std::vector<int> current_controls_;
|
std::vector<int> current_controls_;
|
||||||
mutable WellMapType wellMap_;
|
WellMapType wellMap_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
Loading…
Reference in New Issue
Block a user