mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Add partialCopy() method for transferring well states.
Also add numWells() and numPhases() helpers.
This commit is contained in:
parent
6fccb4b446
commit
43c00773db
@ -24,6 +24,7 @@
|
|||||||
#include <opm/core/wells.h>
|
#include <opm/core/wells.h>
|
||||||
#include <opm/core/well_controls.h>
|
#include <opm/core/well_controls.h>
|
||||||
#include <opm/core/simulator/WellState.hpp>
|
#include <opm/core/simulator/WellState.hpp>
|
||||||
|
#include <opm/core/utility/ErrorMacros.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
@ -102,6 +103,53 @@ namespace Opm
|
|||||||
return basic_well_state_;
|
return basic_well_state_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The number of wells present.
|
||||||
|
int numWells() const
|
||||||
|
{
|
||||||
|
return bhp().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The number of phases present.
|
||||||
|
int numPhases() const
|
||||||
|
{
|
||||||
|
return wellRates().size() / numWells();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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)
|
||||||
|
{
|
||||||
|
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_;
|
||||||
|
Loading…
Reference in New Issue
Block a user