Merge pull request #1941 from joakim-hove/rm-sim-container
Remove unused class SimulationDataContainer
This commit is contained in:
@@ -21,7 +21,6 @@
|
|||||||
# the library needs it.
|
# the library needs it.
|
||||||
|
|
||||||
list (APPEND MAIN_SOURCE_FILES
|
list (APPEND MAIN_SOURCE_FILES
|
||||||
src/opm/common/data/SimulationDataContainer.cpp
|
|
||||||
src/opm/common/OpmLog/CounterLog.cpp
|
src/opm/common/OpmLog/CounterLog.cpp
|
||||||
src/opm/common/OpmLog/EclipsePRTLog.cpp
|
src/opm/common/OpmLog/EclipsePRTLog.cpp
|
||||||
src/opm/common/OpmLog/LogBackend.cpp
|
src/opm/common/OpmLog/LogBackend.cpp
|
||||||
@@ -304,7 +303,6 @@ list (APPEND TEST_SOURCE_FILES
|
|||||||
tests/test_OpmLog.cpp
|
tests/test_OpmLog.cpp
|
||||||
tests/test_param.cpp
|
tests/test_param.cpp
|
||||||
tests/test_RootFinders.cpp
|
tests/test_RootFinders.cpp
|
||||||
tests/test_SimulationDataContainer.cpp
|
|
||||||
tests/test_sparsevector.cpp
|
tests/test_sparsevector.cpp
|
||||||
tests/test_uniformtablelinear.cpp
|
tests/test_uniformtablelinear.cpp
|
||||||
)
|
)
|
||||||
@@ -508,7 +506,6 @@ endif()
|
|||||||
list( APPEND PUBLIC_HEADER_FILES
|
list( APPEND PUBLIC_HEADER_FILES
|
||||||
opm/common/ErrorMacros.hpp
|
opm/common/ErrorMacros.hpp
|
||||||
opm/common/Exceptions.hpp
|
opm/common/Exceptions.hpp
|
||||||
opm/common/data/SimulationDataContainer.hpp
|
|
||||||
opm/common/OpmLog/CounterLog.hpp
|
opm/common/OpmLog/CounterLog.hpp
|
||||||
opm/common/OpmLog/EclipsePRTLog.hpp
|
opm/common/OpmLog/EclipsePRTLog.hpp
|
||||||
opm/common/OpmLog/LogBackend.hpp
|
opm/common/OpmLog/LogBackend.hpp
|
||||||
|
|||||||
@@ -1,191 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 Statoil ASA.
|
|
||||||
|
|
||||||
This file is part of the Open Porous Media project (OPM).
|
|
||||||
|
|
||||||
OPM is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OPM is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SIMULATION_DATA_CONTAINER_HPP
|
|
||||||
#define SIMULATION_DATA_CONTAINER_HPP
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace Opm {
|
|
||||||
|
|
||||||
|
|
||||||
/// The SimulationDataContainer is a simple container to manage
|
|
||||||
/// simulation data. The container is instantiated with information
|
|
||||||
/// of how many cells, faces and phases are present in the
|
|
||||||
/// reservoirmodel. You can then add data to the container by using the
|
|
||||||
///
|
|
||||||
/// registerCellData()
|
|
||||||
/// registerFaceData()
|
|
||||||
///
|
|
||||||
/// functions. The container owns and manages the data, but
|
|
||||||
/// mutable references are returned with the getCellData() and
|
|
||||||
/// getFaceData() methods, and the content will typically be
|
|
||||||
/// modified by external scope.
|
|
||||||
class SimulationDataContainer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Main constructor setting the sizes for the contained data
|
|
||||||
/// types.
|
|
||||||
/// \param num_cells number of elements in cell data vectors
|
|
||||||
/// \param num_faces number of elements in face data vectors
|
|
||||||
/// \param num_phases number of phases, the number of components
|
|
||||||
/// in any data vector must equal 1 or this
|
|
||||||
/// number (this behaviour and argument is deprecated).
|
|
||||||
SimulationDataContainer(size_t num_cells, size_t num_faces, size_t num_phases);
|
|
||||||
|
|
||||||
/// Copy constructor.
|
|
||||||
/// Must be defined explicitly because class contains non-value objects
|
|
||||||
/// (the reference pointers pressure_ref_ etc.) that should not simply
|
|
||||||
/// be copied.
|
|
||||||
SimulationDataContainer(const SimulationDataContainer&);
|
|
||||||
|
|
||||||
/// Copy assignment operator.
|
|
||||||
/// Must be defined explicitly because class contains non-value objects
|
|
||||||
/// (the reference pointers pressure_ref_ etc.) that should not simply
|
|
||||||
/// be copied.
|
|
||||||
SimulationDataContainer& operator=(const SimulationDataContainer&);
|
|
||||||
|
|
||||||
/// Efficient O(1) swap.
|
|
||||||
void swap(SimulationDataContainer& other);
|
|
||||||
|
|
||||||
size_t numPhases() const;
|
|
||||||
size_t numFaces() const;
|
|
||||||
size_t numCells() const;
|
|
||||||
|
|
||||||
bool hasCellData( const std::string& name ) const;
|
|
||||||
|
|
||||||
/// Will register a data vector of size numCells() *
|
|
||||||
/// components.
|
|
||||||
void registerCellData( const std::string& name , size_t components , double initialValue = 0.0 );
|
|
||||||
std::vector<double>& getCellData( const std::string& name );
|
|
||||||
const std::vector<double>& getCellData( const std::string& name ) const;
|
|
||||||
|
|
||||||
bool hasFaceData( const std::string& name ) const;
|
|
||||||
void registerFaceData( const std::string& name , size_t components , double initialValue = 0.0 );
|
|
||||||
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;
|
|
||||||
|
|
||||||
|
|
||||||
/// Will set the values of component nr @component in the
|
|
||||||
/// field @key. All the cells in @cells will be set to the
|
|
||||||
/// values in @values.
|
|
||||||
void setCellDataComponent( const std::string& key , size_t component , const std::vector<int>& cells , const std::vector<double>& values);
|
|
||||||
|
|
||||||
// Direct explicit field access for certain default fields.
|
|
||||||
// These methods are all deprecated, and will eventually be moved to
|
|
||||||
// concrete subclasses.
|
|
||||||
|
|
||||||
std::vector<double>& pressure ();
|
|
||||||
std::vector<double>& temperature ();
|
|
||||||
std::vector<double>& saturation ();
|
|
||||||
|
|
||||||
std::vector<double>& facepressure();
|
|
||||||
std::vector<double>& faceflux ();
|
|
||||||
|
|
||||||
const std::vector<double>& pressure () const;
|
|
||||||
const std::vector<double>& temperature () const;
|
|
||||||
const std::vector<double>& saturation () const;
|
|
||||||
|
|
||||||
const std::vector<double>& facepressure() const;
|
|
||||||
const std::vector<double>& faceflux () const;
|
|
||||||
|
|
||||||
const std::map<std::string, std::vector<double>>& cellData() const;
|
|
||||||
std::map<std::string, std::vector<double>>& cellData();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void addDefaultFields();
|
|
||||||
void setReferencePointers();
|
|
||||||
|
|
||||||
size_t m_num_cells;
|
|
||||||
size_t m_num_faces;
|
|
||||||
size_t m_num_phases;
|
|
||||||
|
|
||||||
std::map< std::string , std::vector<double> > m_cell_data;
|
|
||||||
std::map< std::string , std::vector<double> > m_face_data;
|
|
||||||
|
|
||||||
std::vector<double>* pressure_ref_;
|
|
||||||
std::vector<double>* temperature_ref_;
|
|
||||||
std::vector<double>* saturation_ref_;
|
|
||||||
std::vector<double>* facepressure_ref_;
|
|
||||||
std::vector<double>* faceflux_ref_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Inline implementations of the direct accessors required to guarantee
|
|
||||||
// performance.
|
|
||||||
|
|
||||||
|
|
||||||
inline std::vector<double>& SimulationDataContainer::pressure( ) {
|
|
||||||
return *pressure_ref_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::vector<double>& SimulationDataContainer::temperature() {
|
|
||||||
return *temperature_ref_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::vector<double>& SimulationDataContainer::saturation() {
|
|
||||||
return *saturation_ref_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::vector<double>& SimulationDataContainer::facepressure() {
|
|
||||||
return *facepressure_ref_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::vector<double>& SimulationDataContainer::faceflux() {
|
|
||||||
return *faceflux_ref_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const std::vector<double>& SimulationDataContainer::pressure( ) const {
|
|
||||||
return *pressure_ref_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const std::vector<double>& SimulationDataContainer::temperature() const {
|
|
||||||
return *temperature_ref_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const std::vector<double>& SimulationDataContainer::saturation() const {
|
|
||||||
return *saturation_ref_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const std::vector<double>& SimulationDataContainer::facepressure() const {
|
|
||||||
return *facepressure_ref_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const std::vector<double>& SimulationDataContainer::faceflux() const {
|
|
||||||
return *faceflux_ref_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,207 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 Statoil ASA.
|
|
||||||
|
|
||||||
This file is part of the Open Porous Media project (OPM).
|
|
||||||
|
|
||||||
OPM is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OPM is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#define BOOST_TEST_MODULE SIMULATION_DATA_CONTAINER_TESTS
|
|
||||||
#include <boost/test/unit_test.hpp>
|
|
||||||
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <iostream>
|
|
||||||
#include <opm/common/data/SimulationDataContainer.hpp>
|
|
||||||
|
|
||||||
using namespace Opm;
|
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(TestCreate) {
|
|
||||||
SimulationDataContainer container(1000 , 10 , 2);
|
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( 2U , container.numPhases() );
|
|
||||||
BOOST_CHECK_EQUAL( 1000U , container.numCells() );
|
|
||||||
BOOST_CHECK_EQUAL( 10U , container.numFaces() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
This test verifies that the default fields are correctly registered;
|
|
||||||
this special behavior is deprecated - and the test should die; along
|
|
||||||
with the behavior.
|
|
||||||
*/
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(TestRegisterDefaults) {
|
|
||||||
SimulationDataContainer container(1000 , 10 , 2);
|
|
||||||
|
|
||||||
BOOST_CHECK( container.hasCellData("PRESSURE") );
|
|
||||||
BOOST_CHECK( container.hasCellData("SATURATION") );
|
|
||||||
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto pressure = container.pressure();
|
|
||||||
BOOST_CHECK_EQUAL( pressure.size() , 1000U );
|
|
||||||
|
|
||||||
auto sat = container.saturation();
|
|
||||||
BOOST_CHECK_EQUAL( sat.size() , 1000U*2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_CHECK( container.hasFaceData("FACEPRESSURE") );
|
|
||||||
BOOST_CHECK( container.hasFaceData("FACEFLUX") );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(TestRegisterFaceData) {
|
|
||||||
SimulationDataContainer container(100 , 10 , 2);
|
|
||||||
BOOST_CHECK( !container.hasFaceData("FLUX"));
|
|
||||||
BOOST_CHECK_THROW( container.getFaceData("FLUX") , std::invalid_argument );
|
|
||||||
|
|
||||||
container.registerFaceData("FLUX" , 1 , 99 );
|
|
||||||
auto& flux = container.getFaceData("FLUX");
|
|
||||||
BOOST_CHECK_EQUAL( flux.size() , 10U );
|
|
||||||
BOOST_CHECK_EQUAL( flux[0] , 99 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(TestRegisterCellData) {
|
|
||||||
|
|
||||||
SimulationDataContainer container(100 , 10 , 2);
|
|
||||||
BOOST_CHECK( !container.hasCellData("FIELDX"));
|
|
||||||
BOOST_CHECK_THROW( container.getCellData("FIELDX") , std::invalid_argument );
|
|
||||||
|
|
||||||
container.registerCellData("FIELDX" , 1 , 123 );
|
|
||||||
{
|
|
||||||
auto& fieldx = container.getCellData("FIELDX");
|
|
||||||
BOOST_CHECK_EQUAL( fieldx.size() , 100U );
|
|
||||||
for (auto v : fieldx)
|
|
||||||
BOOST_CHECK_EQUAL( v , 123 );
|
|
||||||
|
|
||||||
fieldx[0] *= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto fieldx = container.getCellData("FIELDX");
|
|
||||||
BOOST_CHECK_EQUAL( fieldx[0] , 246 );
|
|
||||||
BOOST_CHECK_EQUAL( fieldx[1] , 123 );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(Test_Equal) {
|
|
||||||
{
|
|
||||||
SimulationDataContainer container1(100 , 10 , 2);
|
|
||||||
SimulationDataContainer container2(100 , 10 , 2);
|
|
||||||
BOOST_CHECK( container1.equal( container2 ));
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
SimulationDataContainer container1(100 , 10 , 2);
|
|
||||||
SimulationDataContainer container2(100 , 10 , 1);
|
|
||||||
BOOST_CHECK( !container1.equal( container2 ));
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
SimulationDataContainer container1(100 , 10 , 2);
|
|
||||||
SimulationDataContainer container2(100 , 10 , 2);
|
|
||||||
|
|
||||||
container1.registerCellData( "FIELDX" , 1 , 123 );
|
|
||||||
BOOST_CHECK( !container1.equal( container2 ));
|
|
||||||
container2.registerCellData( "FIELDX" , 1 , 123 );
|
|
||||||
BOOST_CHECK( container1.equal( container2 ));
|
|
||||||
|
|
||||||
container1.registerFaceData( "FACEX" , 1 , 123 );
|
|
||||||
BOOST_CHECK( !container1.equal( container2 ));
|
|
||||||
container2.registerFaceData( "FACEX" , 1 , 123 );
|
|
||||||
BOOST_CHECK( container1.equal( container2 ));
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
SimulationDataContainer container1(100 , 10 , 2);
|
|
||||||
SimulationDataContainer container2(100 , 10 , 2);
|
|
||||||
|
|
||||||
container1.registerCellData( "FIELD1" , 1 , 123 );
|
|
||||||
container2.registerCellData( "FIELD2" , 1 , 123 );
|
|
||||||
BOOST_CHECK( !container1.equal( container2 ));
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
SimulationDataContainer container1(100 , 10 , 2);
|
|
||||||
SimulationDataContainer container2(100 , 10 , 2);
|
|
||||||
|
|
||||||
container1.registerFaceData( "FIELD1" , 1 , 123 );
|
|
||||||
container2.registerFaceData( "FIELD2" , 1 , 123 );
|
|
||||||
BOOST_CHECK( !container1.equal( container2 ));
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
SimulationDataContainer container1(100 , 10 , 2);
|
|
||||||
SimulationDataContainer container2(100 , 10 , 2);
|
|
||||||
|
|
||||||
container1.registerFaceData( "FIELD1" , 1 , 123 );
|
|
||||||
container2.registerFaceData( "FIELD1" , 1 , 123 );
|
|
||||||
BOOST_CHECK( container1.equal( container2 ));
|
|
||||||
|
|
||||||
std::vector<double>& f = container1.getFaceData( "FIELD1" );
|
|
||||||
f[0] *= 1.1;
|
|
||||||
BOOST_CHECK( !container1.equal( container2 ));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(TestSetComponent) {
|
|
||||||
|
|
||||||
SimulationDataContainer container(100 , 10 , 2);
|
|
||||||
container.registerCellData("FIELDX" , 2 , 123 );
|
|
||||||
std::vector<int> cells = { 1,2,3};
|
|
||||||
std::vector<int> cells2 = { 1,2,3,4};
|
|
||||||
std::vector<int> cells3 = { 1,2,100};
|
|
||||||
std::vector<double> values0 = {20,30,40};
|
|
||||||
std::vector<double> values1 = {2,3,4};
|
|
||||||
|
|
||||||
BOOST_CHECK_THROW( container.setCellDataComponent( "FIELDY" , 0 , cells , values0 ) , std::invalid_argument );
|
|
||||||
BOOST_CHECK_THROW( container.setCellDataComponent( "FIELDX" , 2 , cells , values0 ) , std::invalid_argument );
|
|
||||||
BOOST_CHECK_THROW( container.setCellDataComponent( "FIELDX" , 0 , cells2 , values0 ) , std::invalid_argument );
|
|
||||||
BOOST_CHECK_THROW( container.setCellDataComponent( "FIELDX" , 0 , cells3 , values0 ) , std::invalid_argument );
|
|
||||||
|
|
||||||
container.setCellDataComponent( "FIELDX" , 0 , cells , values0 );
|
|
||||||
container.setCellDataComponent( "FIELDX" , 1 , cells , values1 );
|
|
||||||
const auto& data = container.getCellData( "FIELDX" );
|
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( data[1*2 + 1] , 2 );
|
|
||||||
BOOST_CHECK_EQUAL( data[2*2 + 1] , 3 );
|
|
||||||
BOOST_CHECK_EQUAL( data[3*2 + 1] , 4 );
|
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( data[1*2] , 20 );
|
|
||||||
BOOST_CHECK_EQUAL( data[2*2] , 30 );
|
|
||||||
BOOST_CHECK_EQUAL( data[3*2] , 40 );
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user