Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable INP support without ODB libraries #10990

Merged
merged 5 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ApplicationExeCode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ if(RESINSIGHT_ENABLE_GRPC)
list(APPEND LINK_LIBRARIES GrpcInterface)
endif()

list(APPEND LINK_LIBRARIES RigGeoMechDataModel)
list(APPEND LINK_LIBRARIES RigGeoMechDataModel RifGeoMechFileInterface)

if(RESINSIGHT_USE_ODB_API)
add_definitions(-DUSE_ODB_API)
Expand Down
1 change: 1 addition & 0 deletions ApplicationLibCode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ target_include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/UserInterface
${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/GeoMechDataModel
${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/GeoMechVisualization
${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/GeoMechFileInterface
${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/OdbReader
${CMAKE_CURRENT_SOURCE_DIR}/Measurement
${ResInsight_SOURCE_DIR}/ThirdParty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ void RicGeoMechCopyCaseFeature::onActionTriggered( bool isChecked )
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->lastUsedDialogDirectory( "GEOMECH_MODEL" );

QString filterStr;
#if USE_ODB_API
filterStr += "Abaqus results (*.odb);;";
#endif
filterStr += "Abaqus input file (*.inp)";

for ( RimGeoMechCase* gmc : cases )
{
QString fileName =
RiuFileDialogTools::getOpenFileName( nullptr, "Import Geo-Mechanical Model", defaultDir, "Abaqus results (*.odb)" );
QString fileName = RiuFileDialogTools::getOpenFileName( nullptr, "Import Geo-Mechanical Model", defaultDir, filterStr );
if ( fileName.isEmpty() ) break;

defaultDir = QFileInfo( fileName ).absolutePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ void RicImportGeoMechCaseFeature::onActionTriggered( bool isChecked )
{
RiaApplication* app = RiaApplication::instance();

QString filterStr;
#if USE_ODB_API
filterStr += "Abaqus results (*.odb);;";
#endif
filterStr += "Abaqus input file (*.inp)";

QString defaultDir = app->lastUsedDialogDirectory( "GEOMECH_MODEL" );
QStringList fileNames = RiuFileDialogTools::getOpenFileNames( nullptr,
"Import Geo-Mechanical Model",
defaultDir,
"Abaqus results (*.odb);;Abaqus input file (*.inp)" );
QStringList fileNames = RiuFileDialogTools::getOpenFileNames( nullptr, "Import Geo-Mechanical Model", defaultDir, filterStr );
if ( !fileNames.empty() ) defaultDir = QFileInfo( fileNames.last() ).absolutePath();
app->setLastUsedDialogDirectory( "GEOMECH_MODEL", defaultDir );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ void RicImportGeoMechCaseTimeStepFilterFeature::onActionTriggered( bool isChecke
{
RiaApplication* app = RiaApplication::instance();

QString filterStr;
#if USE_ODB_API
filterStr += "Abaqus results (*.odb);;";
#endif
filterStr += "Abaqus input file (*.inp)";

jonjenssen marked this conversation as resolved.
Show resolved Hide resolved
QString defaultDir = app->lastUsedDialogDirectory( "GEOMECH_MODEL" );
QStringList fileNames =
RiuFileDialogTools::getOpenFileNames( nullptr, "Import Geo-Mechanical Model", defaultDir, "Abaqus results (*.odb)" );
QStringList fileNames = RiuFileDialogTools::getOpenFileNames( nullptr, "Import Geo-Mechanical Model", defaultDir, filterStr );
if ( !fileNames.empty() ) defaultDir = QFileInfo( fileNames.last() ).absolutePath();
for ( QString fileName : fileNames )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@

#include "Riu3DMainWindowTools.h"

#ifdef USE_ODB_API
#include "RifOdbReader.h"
#endif

#include "cafProgressInfo.h"
#include "cafTensor3.h"

Expand Down Expand Up @@ -159,6 +155,11 @@ RigFemPartResultsCollection::RigFemPartResultsCollection( RifGeoMechReaderInterf

m_waterDensityShearSlipIndicator = 1.03;

m_fractureGradientCalculationTypeMudWeightWindow = RimMudWeightWindowParameters::FractureGradientCalculationType::DERIVED_FROM_K0FG;
m_lowerLimitParameterMudWeightWindow = RimMudWeightWindowParameters::LowerLimitType::PORE_PRESSURE;
m_upperLimitParameterMudWeightWindow = RimMudWeightWindowParameters::UpperLimitType::FG;
m_nonReservoirPorePressureTypeMudWeightWindow = RimMudWeightWindowParameters::NonReservoirPorePressureType::PER_ELEMENT;

m_resultCalculators.push_back( std::unique_ptr<RigFemPartResultCalculator>( new RigFemPartResultCalculatorTimeLapse( *this ) ) );
m_resultCalculators.push_back( std::unique_ptr<RigFemPartResultCalculator>( new RigFemPartResultCalculatorSurfaceAngles( *this ) ) );
m_resultCalculators.push_back( std::unique_ptr<RigFemPartResultCalculator>( new RigFemPartResultCalculatorSurfaceAlignedStress( *this ) ) );
Expand Down
25 changes: 13 additions & 12 deletions ApplicationLibCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include "RigFemPartResultsCollection.h"
#include "RigGeoMechCaseData.h"

#ifdef USE_ODB_API
#include "RifInpReader.h"
#ifdef USE_ODB_API
#include "RifOdbReader.h"
#endif

Expand Down Expand Up @@ -86,19 +86,23 @@ RigFemPartResultsCollection* RigGeoMechCaseData::femPartResults()
return m_femPartResultsColl.p();
}

#include "RiaStdStringTools.h"

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigGeoMechCaseData::open( std::string* errorMessage )
{
#ifdef USE_ODB_API
if ( m_geoMechCaseFileName.ends_with( ".odb" ) )
auto filename = RiaStdStringTools::toUpper( m_geoMechCaseFileName );

if ( filename.ends_with( ".INP" ) )
{
m_readerInterface = new RifOdbReader;
m_readerInterface = new RifInpReader();
}
else
#ifdef USE_ODB_API
else if ( filename.ends_with( ".ODB" ) )
{
m_readerInterface = new RifInpReader;
m_readerInterface = new RifOdbReader();
}
#endif

Expand All @@ -111,13 +115,11 @@ bool RigGeoMechCaseData::open( std::string* errorMessage )
bool RigGeoMechCaseData::readTimeSteps( std::string* errorMessage, std::vector<std::string>* stepNames )
{
CVF_ASSERT( stepNames );
#ifdef USE_ODB_API
if ( m_readerInterface.notNull() && m_readerInterface->isOpen() )
{
*stepNames = m_readerInterface->allStepNames();
return true;
}
#endif
*errorMessage = std::string( "Could not read time steps" );
return false;
}
Expand All @@ -128,7 +130,7 @@ bool RigGeoMechCaseData::readTimeSteps( std::string* errorMessage, std::vector<s
bool RigGeoMechCaseData::readFemParts( std::string* errorMessage, const std::vector<size_t>& timeStepFilter, bool readOnlyLastFrame )
{
CVF_ASSERT( errorMessage );
#ifdef USE_ODB_API

if ( m_readerInterface.notNull() && m_readerInterface->isOpen() )
{
m_readerInterface->setTimeStepFilter( timeStepFilter, readOnlyLastFrame );
Expand All @@ -154,7 +156,7 @@ bool RigGeoMechCaseData::readFemParts( std::string* errorMessage, const std::vec
return true;
}
}
#endif

*errorMessage = std::string( "Could not read FEM parts" );
return false;
}
Expand All @@ -165,14 +167,13 @@ bool RigGeoMechCaseData::readFemParts( std::string* errorMessage, const std::vec
bool RigGeoMechCaseData::readDisplacements( std::string* errorMessage, int partId, int timeStep, int frameIndex, std::vector<cvf::Vec3f>* displacements )
{
CVF_ASSERT( errorMessage );
#ifdef USE_ODB_API

if ( m_readerInterface.notNull() && m_readerInterface->isOpen() )
{
m_readerInterface->readDisplacements( partId, timeStep, frameIndex, displacements );
return true;
}

#endif
*errorMessage = std::string( "Could not read displacements." );
return false;
}
21 changes: 21 additions & 0 deletions ApplicationLibCode/GeoMech/GeoMechFileInterface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
project(RifGeoMechFileInterface)

# Unity Build
if(RESINSIGHT_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : ${PROJECT_NAME}")
set(CMAKE_UNITY_BUILD true)
endif()

add_library(
${PROJECT_NAME}
RifInpReader.h RifInpReader.cpp RifGeoMechReaderInterface.h
RifGeoMechReaderInterface.cpp RifInpIncludeReader.h RifInpIncludeReader.cpp
)

target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

set(LINK_LIBRARIES RigGeoMechDataModel LibCore)

target_link_libraries(${PROJECT_NAME} ${LINK_LIBRARIES})

source_group("" FILES ${PROJECT_FILES})
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool RifInpReader::readFemParts( RigFemPartCollection* femParts )

auto elementType = read( m_stream, parts, nodes, elements, elementSets, m_stepNames, m_enableIncludes, m_includeEntries );

for ( int i = 0; i < m_includeEntries.size(); i++ )
for ( int i = 0; i < (int)m_includeEntries.size(); i++ )
{
m_includeEntries[i].fileName = ( m_inputPath / m_includeEntries[i].fileName ).string();
}
Expand Down Expand Up @@ -590,7 +590,7 @@ int RifInpReader::frameCount( int stepIndex ) const
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RifInpReader::elementSetNames( int partIndex, std::string partName )
{
if ( partIndex >= m_partElementSetNames.size() ) return {};
if ( partIndex >= (int)m_partElementSetNames.size() ) return {};
return m_partElementSetNames.at( partIndex );
}

Expand Down
16 changes: 3 additions & 13 deletions ApplicationLibCode/GeoMech/OdbReader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,7 @@ else()
add_definitions(-DABQ_MPI_PMPI)
endif(MSVC)

add_library(
${PROJECT_NAME}
RifOdbReader.h
RifOdbReader.cpp
RifInpReader.h
RifInpReader.cpp
RifGeoMechReaderInterface.h
RifGeoMechReaderInterface.cpp
RifInpIncludeReader.h
RifInpIncludeReader.cpp
OdbSetup.cmake
)
add_library(${PROJECT_NAME} RifOdbReader.h RifOdbReader.cpp OdbSetup.cmake)

target_include_directories(
${PROJECT_NAME} PRIVATE ${RESINSIGHT_ODB_API_DIR}/include
Expand Down Expand Up @@ -88,7 +77,8 @@ endif(MSVC)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(
${PROJECT_NAME} ${RI_ODB_LIBS} RigGeoMechDataModel LibCore
${PROJECT_NAME} ${RI_ODB_LIBS} RigGeoMechDataModel RifGeoMechFileInterface
LibCore
)

source_group("" FILES ${PROJECT_FILES})
6 changes: 3 additions & 3 deletions ApplicationLibCode/GeoMech/OdbReader_UnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cmake_minimum_required(VERSION 2.8)

project(OdbReader_UnitTests)

set(RI_VIZ_FWK_ROOT
Expand All @@ -21,12 +19,14 @@ add_subdirectory(${RI_VIZ_FWK_ROOT}/LibCore buildVizFwk)
add_subdirectory(../../ResultStatisticsCache buildResultStatisticsCache)
add_subdirectory(../OdbReader buildOdbReader)
add_subdirectory(../GeoMechDataModel buildGeoMechDataModel)
add_subdirectory(../GeoMechFileInterface buildGeoMechFileInterface)

add_definitions(-DTEST_FILE="${RI_TEST_FILE}")

include_directories(${RI_VIZ_FWK_ROOT}/LibCore)
include_directories(../../ResultStatisticsCache)
include_directories(../../ReservoirDataModel)
include_directories(../GeoMechFileInterface)
include_directories(../OdbReader)
include_directories(../GeoMechDataModel)
include_directories(${RI_GTEST_ROOT})
Expand All @@ -36,6 +36,6 @@ set(UNIT_TEST_CPP_SOURCES main.cpp RifOdbReader-Test.cpp
)

add_executable(${PROJECT_NAME} ${UNIT_TEST_CPP_SOURCES})
target_link_libraries(${PROJECT_NAME} RifOdbReader)
target_link_libraries(${PROJECT_NAME} RifOdbReader RifGeoMechFileInterface)

include(../OdbReader/OdbSetup.cmake)
3 changes: 1 addition & 2 deletions ApplicationLibCode/UserInterface/RiuMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,15 +571,14 @@ void RiuMainWindow::createToolBars()
toolbar->addAction( cmdFeatureMgr->action( "RicImportEnsembleFeature" ) );
toolbar->hide();
}

{
#ifdef USE_ODB_API
QToolBar* toolbar = addToolBar( tr( "Import GeoMech" ) );
toolbar->setObjectName( toolbar->windowTitle() );
toolbar->addAction( cmdFeatureMgr->action( "RicImportGeoMechCaseFeature" ) );
toolbar->addAction( cmdFeatureMgr->action( "RicImportGeoMechCaseTimeStepFilterFeature" ) );
toolbar->addAction( cmdFeatureMgr->action( "RicImportElementPropertyFeature" ) );
toolbar->hide();
#endif
}

{
Expand Down
2 changes: 0 additions & 2 deletions ApplicationLibCode/UserInterface/RiuMenuBarBuildTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,11 @@ void RiuMenuBarBuildTools::addImportMenuWithActions( QObject* parent, QMenu* men
importSummaryMenu->addAction( cmdFeatureMgr->action( "RicImportSummaryGroupFeature" ) );
importSummaryMenu->addAction( cmdFeatureMgr->action( "RicImportEnsembleFeature" ) );

#ifdef USE_ODB_API
importMenu->addSeparator();
QMenu* importGeoMechMenu = importMenu->addMenu( QIcon( ":/GeoMechCase24x24.png" ), "Geo Mechanical Cases" );
importGeoMechMenu->addAction( cmdFeatureMgr->action( "RicImportGeoMechCaseFeature" ) );
importGeoMechMenu->addAction( cmdFeatureMgr->action( "RicImportGeoMechCaseTimeStepFilterFeature" ) );
importGeoMechMenu->addAction( cmdFeatureMgr->action( "RicImportElementPropertyFeature" ) );
#endif

importMenu->addSeparator();
QMenu* importWellMenu = importMenu->addMenu( QIcon( ":/Well.svg" ), "Well Data" );
Expand Down
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ add_subdirectory(ApplicationLibCode)
add_subdirectory(ApplicationLibCode/Commands)
add_subdirectory(ApplicationLibCode/ResultStatisticsCache)
add_subdirectory(ApplicationLibCode/GeoMech/GeoMechDataModel)
add_subdirectory(ApplicationLibCode/GeoMech/GeoMechFileInterface)
if(RESINSIGHT_USE_ODB_API)
add_subdirectory(ApplicationLibCode/GeoMech/OdbReader)
endif()
Expand Down Expand Up @@ -941,8 +942,13 @@ if(MSVC AND RESINSIGHT_ENABLE_STATIC_ANALYSIS)
)

set(TARGETS_FOR_STATIC_ANALYSIS
${APP_FWK_LIBRARIES} ${APP_FWK_TEST_PROJECTS} ApplicationLibCode Commands
ResultStatisticsCache RigGeoMechDataModel
${APP_FWK_LIBRARIES}
${APP_FWK_TEST_PROJECTS}
ApplicationLibCode
Commands
ResultStatisticsCache
RigGeoMechDataModel
RifGeoMechFileInterface
)

foreach(TARGET_PROJECT ${TARGETS_FOR_STATIC_ANALYSIS})
Expand Down