mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Add small method SegmentState::scale_pressure()
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <opm/simulators/wells/SegmentState.hpp>
|
||||
|
||||
@@ -44,4 +46,15 @@ bool SegmentState::empty() const {
|
||||
return this->rates.empty();
|
||||
}
|
||||
|
||||
void SegmentState::scale_pressure(double bhp) {
|
||||
if (this->empty())
|
||||
throw std::logic_error("Tried to pressure scale empty SegmentState");
|
||||
|
||||
auto scale_factor = bhp / this->pressure[0];
|
||||
std::transform(this->pressure.begin(),
|
||||
this->pressure.end(),
|
||||
this->pressure.begin(),
|
||||
[scale_factor] (const double& p) { return p*scale_factor;});
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -36,6 +36,8 @@ public:
|
||||
SegmentState(int num_phases, const WellSegments& segments);
|
||||
double pressure_drop(std::size_t index) const;
|
||||
bool empty() const;
|
||||
void scale_pressure(double bhp);
|
||||
|
||||
|
||||
std::vector<double> rates;
|
||||
std::vector<double> pressure;
|
||||
|
@@ -519,6 +519,16 @@ BOOST_AUTO_TEST_CASE(TESTSegmentState2) {
|
||||
segments.pressure_drop_hydrostatic[0] = 4;
|
||||
|
||||
BOOST_CHECK_EQUAL(segments.pressure_drop(0), 7);
|
||||
|
||||
|
||||
for (std::size_t i=0; i < segments.pressure.size(); i++)
|
||||
segments.pressure[i] = (i + 1);
|
||||
|
||||
const double bhp = 2.0;
|
||||
segments.scale_pressure(bhp);
|
||||
|
||||
for (std::size_t i=0; i < segments.pressure.size(); i++)
|
||||
BOOST_CHECK_EQUAL(segments.pressure[i], 2*(i+1));
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user