Added method to query for number of components.

This commit is contained in:
Joakim Hove 2016-02-28 23:04:30 +01:00
parent 32dbe00516
commit 84a827e847
3 changed files with 15 additions and 0 deletions

View File

@ -174,6 +174,11 @@ namespace Opm {
return true;
}
size_t SimulationDataContainer::numCellDataComponents( const std::string& name ) const {
const auto& data = getCellData( name );
return data.size() / m_num_cells;
}
/* This is very deprecated. */

View File

@ -63,6 +63,14 @@ namespace Opm {
std::vector<double>& getFaceData( const std::string& name );
const std::vector<double>& getFaceData( const std::string& name ) const;
/// Will return the number of components of the celldata with
/// name @name:
///
/// numCellDataComponents( "PRESSURE" ) -> 1
/// numCellDataComponents( "SATURATION" ) -> 3
///
/// for a three phase model.
size_t numCellDataComponents( const std::string& name ) const;
bool equal(const SimulationDataContainer& other) const;

View File

@ -55,9 +55,11 @@ BOOST_AUTO_TEST_CASE(TestRegisterDefaults) {
{
auto pressure = container.getCellData("PRESSURE");
BOOST_CHECK_EQUAL( pressure.size() , 1000U );
BOOST_CHECK_EQUAL( container.numCellDataComponents( "PRESSURE") , 1U);
auto sat = container.getCellData("SATURATION");
BOOST_CHECK_EQUAL( sat.size() , 1000U*2 );
BOOST_CHECK_EQUAL( container.numCellDataComponents( "SATURATION") , 2U);
}
{