SimulatorState: use register{Cell/Face}Data also in SimulatorState.

This commit is contained in:
Robert Kloefkorn 2015-07-08 16:30:51 +02:00
parent 0ad5146b1f
commit ae740adaf3
2 changed files with 24 additions and 27 deletions

View File

@ -1,3 +1,4 @@
#include <opm/core/utility/ErrorMacros.hpp>
#include <opm/core/simulator/SimulatorState.hpp>
#include <opm/core/grid.h>
@ -48,20 +49,23 @@ SimulatorState::init(const UnstructuredGrid& g, int num_phases)
void
SimulatorState::init(int number_of_cells, int number_of_faces, int num_phases)
{
num_cells_ = number_of_cells;
num_faces_ = number_of_faces;
num_phases_ = num_phases;
// clear memory
cellData_ = std::vector< std::vector<double> > ( 3 );
faceData_ = std::vector< std::vector<double> > ( 2 );
cellData_ = std::vector< std::vector<double> > ();
faceData_ = std::vector< std::vector<double> > ();
pressure().resize(number_of_cells, 0.0);
temperature().resize(number_of_cells, 273.15 + 20);
saturation().resize(num_phases_ * number_of_cells, 0.0);
cellDataNames_.resize( 3 );
cellDataNames_[ pressureId_ ] = "PRESSURE" ;
cellDataNames_[ temperatureId_ ] = "TEMPERATURE";
cellDataNames_[ saturationId_ ] = "SATURATION" ;
int id;
id = registerCellData("PRESSURE", 1, 0.0 );
if( id != pressureId_ )
OPM_THROW(std::logic_error,"ids in SimulatorState do not match");
assert( pressureId_ == id );
id = registerCellData("TEMPERATURE", 1, 273.15 + 20 );
assert( temperatureId_ == id );
id = registerCellData("SATURATION", num_phases_, 0.0 );
assert( saturationId_ == id );
for (int cell = 0; cell < number_of_cells; ++cell) {
// Defaulting the second saturation to 1.0.
@ -72,25 +76,19 @@ SimulatorState::init(int number_of_cells, int number_of_faces, int num_phases)
saturation()[num_phases_*cell + 1] = 1.0;
}
facepressure().resize(number_of_faces, 0.0);
faceflux().resize(number_of_faces, 0.0);
faceDataNames_.resize( 2 );
faceDataNames_[ facePressureId_ ] = "FACEPRESSURE" ;
faceDataNames_[ faceFluxId_ ] = "FACEFLUX" ;
id = registerFaceData("FACEPRESSURE", 1, 0.0 );
assert( facePressureId_ == id );
id = registerFaceData("FACEFLUX", 1, 0.0 );
assert( faceFluxId_ == id );
}
size_t
SimulatorState::registerCellData( const std::string& name, const int components, const double initialValue )
{
// check if init has been called
assert( cellData_.size() > 0 );
const size_t pos = cellData_.size();
cellDataNames_.push_back( name );
const size_t nCells = pressure().size();
assert( nCells > 0 );
cellData_.push_back( std::vector<double>( nCells * components, initialValue ) );
cellDataNames_.emplace_back( name );
cellData_.emplace_back( num_cells_ * components, initialValue );
return pos;
}
@ -98,12 +96,9 @@ size_t
SimulatorState::registerFaceData( const std::string& name, const int components, const double initialValue )
{
// check if init has been called
assert( faceData_.size() > 0 );
const size_t pos = faceData_.size();
faceDataNames_.push_back( name );
const size_t nFaces = facepressure().size();
assert( nFaces > 0 );
faceData_.push_back( std::vector<double>( nFaces * components, initialValue ) );
faceDataNames_.emplace_back( name );
faceData_.emplace_back( num_faces_ * components, initialValue );
return pos ;
}

View File

@ -77,6 +77,8 @@ namespace Opm
const std::vector< std::vector<double> >& faceData() const { return faceData_; }
private:
int num_cells_;
int num_faces_;
int num_phases_;
/// \brief vector containing all registered cell data