Initial commit of ResInsight version 0.4.8

This commit is contained in:
Alf B. Rustad
2012-05-18 09:45:23 +02:00
parent a680bf941e
commit dfe97efb1b
657 changed files with 176690 additions and 0 deletions

View File

@@ -0,0 +1,119 @@
cmake_minimum_required (VERSION 2.8)
SET (ProjectName FileInterface_UnitTests)
project ( ${ProjectName} )
# Qt
find_package (Qt4 COMPONENTS QtCore QtGui QtMain QtOpenGl REQUIRED)
include (${QT_USE_FILE})
include_directories(
${LibCore_SOURCE_DIR}
${LibGeometry_SOURCE_DIR}
${LibRender_SOURCE_DIR}
${LibViewing_SOURCE_DIR}
${ResInsight_SOURCE_DIR}/ApplicationCode
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel
${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface
${ResInsight_SOURCE_DIR}/ApplicationCode/ProjectDataModel
${ResInsight_SOURCE_DIR}/ThirdParty
${ResInsight_SOURCE_DIR}/cafProjectDataModel
${ResInsight_SOURCE_DIR}/CommonCode
${ResInsight_SOURCE_DIR}/ThirdParty/Ert/ecl/include
${ResInsight_SOURCE_DIR}/ThirdParty/Ert/util/include
${ResInsight_SOURCE_DIR}/ThirdParty/Ert/well/include
)
set( FILEINTERFACE_CPP_SOURCES
../RifReaderEclipseFileAccess.cpp
../RifReaderEclipseRestartFiles.cpp
../RifReaderEclipseResultAccess.cpp
../RifReaderEclipseUnifiedRestartFile.cpp
../RifReaderInterfaceEcl.cpp
../RifReaderInterfaceMock.cpp
)
set( RESERVOIRDATAMODEL_CPP_SOURCES
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigCell.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigGridBase.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoir.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigWellResults.cpp
)
set( CPP_SOURCES
${FILEINTERFACE_CPP_SOURCES}
${RESERVOIRDATAMODEL_CPP_SOURCES}
)
source_group( "FileInterface" FILES ${FILEINTERFACE_CPP_SOURCES} )
source_group( "ReservoirDataModel" FILES ${RESERVOIRDATAMODEL_CPP_SOURCES} )
set( UNIT_TEST_CPP_SOURCES
main.cpp
RifReaderInterfaceEcl-Test.cpp
Ert-Test.cpp
)
set( LINK_LIBRARIES
CommonCode
LibViewing
LibRender
LibGeometry
LibCore
${QT_LIBRARIES}
)
add_executable( ${ProjectName}
${CPP_SOURCES}
${UNIT_TEST_CPP_SOURCES}
${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc
)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set ( LINUX_LINK_LIBRARIES
${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert/ecl/lib/libecl.a
${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert/util/lib/libutil.a
${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert/well/lib/libwell.a
lapack
)
# Linux specific code
set(CMAKE_CXX_FLAGS "-DCVF_LINUX -DUSE_ECL_LIB -pipe -Wextra -Woverloaded-virtual -Wformat")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG -D_DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNO_DEBUG")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries( ${ProjectName} ${LINK_LIBRARIES} ${LINUX_LINK_LIBRARIES})
# Copy Qt Dlls
if (MSVC)
set (QTLIBLIST QtCore QtGui QtOpenGl)
foreach (qtlib ${QTLIBLIST})
# Debug
execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}d4.dll ${CMAKE_CURRENT_BINARY_DIR}/Debug/${qtlib}d4.dll)
# Release
execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}4.dll ${CMAKE_CURRENT_BINARY_DIR}/Release/${qtlib}4.dll)
endforeach( qtlib )
endif(MSVC)

View File

@@ -0,0 +1,104 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight 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.
//
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#ifdef USE_ECL_LIB
#include <time.h>
#include <stdbool.h>
#include <util.h>
#include <int_vector.h>
#include <ecl_intehead.h>
#include <ecl_file.h>
#include <ecl_kw.h>
#include <ecl_kw_magic.h>
#include <ecl_util.h>
#include <well_state.h>
#include <well_info.h>
#include <well_conn.h>
#include <well_ts.h>
#include "gtest/gtest.h"
//--------------------------------------------------------------------------------------------------
/// This file contains test code taken from the test cases in ERT source code.
// There is a typedef issue (center) between ERT and QTextStream, so this file does not include any
// Qt files.
//--------------------------------------------------------------------------------------------------
TEST(RigReservoirTest, WellTestErt)
{
char filename[1024] = "/mnt/hgfs/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.UNRST";
well_info_type * well_info = well_info_alloc( NULL );
well_info_load_rstfile( well_info , filename);
// List all wells:
{
int iwell;
for (iwell = 0; iwell < well_info_get_num_wells( well_info ); iwell++)
{
printf("Well[%02d] : %s \n",iwell , well_info_iget_well_name( well_info , iwell));
}
}
// Look at the timeseries for one well:
{
well_ts_type * well_ts = well_info_get_ts( well_info , well_info_iget_well_name( well_info , 0));
for (int i =0; i < well_ts_get_size( well_ts ); i++)
{
well_state_type * well_state = well_ts_iget_state( well_ts , i );
printf("Well:%s report:%04d state:",well_state_get_name( well_state ), well_state_get_report_nr( well_state ));
if (well_state_is_open( well_state ))
printf("OPEN\n");
else
printf("CLOSED\n");
}
}
// Look at one well_state:
{
well_state_type * well_state = well_info_iiget_state( well_info , 0 , 0 );
printf("Well:%s report:%04d \n",well_state_get_name( well_state ), well_state_get_report_nr( well_state ));
{
int branchCount = well_state_get_num_branches(well_state);
for (int ibranch = 0 ; ibranch < branchCount; ++ibranch)
{
printf("Branch: %d", ibranch);
for (int iconn = 0; iconn < well_state_get_num_connections( well_state, ibranch ); iconn++)
{
const well_conn_type * conn = well_state_get_connections( well_state , ibranch)[iconn];
printf("Connection:%02d i=%3d j=%3d k=%3d State:",iconn , conn->i, conn->j , conn->k);
if (conn->open)
printf("Open\n");
else
printf("Closed\n");
}
}
}
}
well_info_free( well_info );
}
#endif //USE_ECL_LIB

View File

@@ -0,0 +1,99 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight 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.
//
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "gtest/gtest.h"
#include "RigReservoir.h"
#include "RifReaderInterfaceEcl.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(RigReservoirTest, BasicTest)
{
cvf::ref<RifReaderInterfaceECL> readerInterfaceEcl = new RifReaderInterfaceECL;
cvf::ref<RigReservoir> reservoir = new RigReservoir;
// Location of test dataset received from Håkon Høgstøl in July 2011 with 10k active cells
QString filename("/mnt/hgfs/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.EGRID");
bool result = readerInterfaceEcl->open(filename, reservoir.p());
EXPECT_TRUE(result);
{
QStringList staticResults = readerInterfaceEcl->staticResults();
EXPECT_EQ(42, staticResults.size());
qDebug() << "Static results\n" << staticResults;
QStringList dynamicResults = readerInterfaceEcl->dynamicResults();
EXPECT_EQ(23, dynamicResults.size());
qDebug() << "Dynamic results\n" << dynamicResults;
int numTimeSteps = static_cast<int>(readerInterfaceEcl->numTimeSteps());
EXPECT_EQ(9, numTimeSteps);
QStringList timeStepText = readerInterfaceEcl->timeStepText();
EXPECT_EQ(numTimeSteps, timeStepText.size());
qDebug() << "Time step texts\n" << timeStepText;
}
readerInterfaceEcl->close();
{
QStringList staticResults = readerInterfaceEcl->staticResults();
EXPECT_EQ(0, staticResults.size());
QStringList dynamicResults = readerInterfaceEcl->dynamicResults();
EXPECT_EQ(0, dynamicResults.size());
int numTimeSteps = static_cast<int>(readerInterfaceEcl->numTimeSteps());
EXPECT_EQ(0, numTimeSteps);
QStringList timeStepText = readerInterfaceEcl->timeStepText();
EXPECT_EQ(numTimeSteps, timeStepText.size());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(RigReservoirTest, WellTest)
{
cvf::ref<RifReaderInterfaceECL> readerInterfaceEcl = new RifReaderInterfaceECL;
cvf::ref<RigReservoir> reservoir = new RigReservoir;
// Location of test dataset received from Håkon Høgstøl in July 2011 with 10k active cells
QString filename("/mnt/hgfs/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.EGRID");
bool result = readerInterfaceEcl->open(filename, reservoir.p());
EXPECT_TRUE(result);
cvf::UByteArray* mainGridWellCells = reservoir->wellCellsInGrid(0);
EXPECT_TRUE(mainGridWellCells->size() == reservoir->mainGrid()->cellCount());
}

View File

@@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight 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.
//
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "cvfBase.h"
#include "gtest/gtest.h"
#include <stdio.h>
#include "cvfTrace.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int main(int argc, char **argv)
{
cvf::Assert::setReportMode(cvf::Assert::CONSOLE);
testing::InitGoogleTest(&argc, argv);
int result = RUN_ALL_TESTS();
std::cout << "Please press <Enter> to close the window.";
std::cin.get();
return result;
}