2015-04-23 06:24:15 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-04-23 06:24:15 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-04-23 06:24:15 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2015-04-23 06:24:15 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2021-04-06 14:04:31 -05:00
|
|
|
#include <cstdlib>
|
2015-06-04 05:35:22 -05:00
|
|
|
|
2018-01-10 03:43:33 -06:00
|
|
|
#include "RifElementPropertyReader.h"
|
|
|
|
#include "RifGeoMechReaderInterface.h"
|
|
|
|
#include "RigFemPartCollection.h"
|
2015-06-04 05:35:22 -05:00
|
|
|
#include "RigFemPartResultsCollection.h"
|
2015-04-23 06:24:15 -05:00
|
|
|
#include "RigGeoMechCaseData.h"
|
2015-05-06 09:07:30 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
#ifdef USE_ODB_API
|
2015-05-06 09:07:30 -05:00
|
|
|
#include "RifOdbReader.h"
|
|
|
|
#endif
|
2018-01-10 03:43:33 -06:00
|
|
|
|
2015-05-08 03:35:49 -05:00
|
|
|
#include "RigFemScalarResultFrames.h"
|
|
|
|
#include "RigStatisticsDataCache.h"
|
2018-01-10 03:43:33 -06:00
|
|
|
|
2015-05-29 05:14:40 -05:00
|
|
|
#include "cafProgressInfo.h"
|
2018-01-10 03:43:33 -06:00
|
|
|
#include "cvfBoundingBox.h"
|
|
|
|
|
2015-06-03 06:22:34 -05:00
|
|
|
#include <QString>
|
2018-01-10 03:43:33 -06:00
|
|
|
#include <cmath>
|
2015-04-23 06:24:15 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-04-23 06:24:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RigGeoMechCaseData::RigGeoMechCaseData( const std::string& fileName )
|
|
|
|
: m_geoMechCaseFileName( fileName )
|
2015-04-23 06:24:15 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-04-23 06:24:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:13:38 -06:00
|
|
|
RigGeoMechCaseData::~RigGeoMechCaseData()
|
|
|
|
{
|
|
|
|
}
|
2015-04-23 06:24:15 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-04-23 06:24:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-04-27 03:25:04 -05:00
|
|
|
RigFemPartCollection* RigGeoMechCaseData::femParts()
|
2015-04-23 06:24:15 -05:00
|
|
|
{
|
2015-04-27 03:25:04 -05:00
|
|
|
return m_femParts.p();
|
2015-04-23 06:24:15 -05:00
|
|
|
}
|
2015-04-27 06:51:22 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-04-27 06:51:22 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
const RigFemPartCollection* RigGeoMechCaseData::femParts() const
|
|
|
|
{
|
|
|
|
return m_femParts.p();
|
|
|
|
}
|
2015-05-06 09:07:30 -05:00
|
|
|
|
2015-06-04 04:54:21 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-06-04 04:54:21 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
const RigFemPartResultsCollection* RigGeoMechCaseData::femPartResults() const
|
|
|
|
{
|
|
|
|
return m_femPartResultsColl.p();
|
|
|
|
}
|
|
|
|
|
2015-06-04 09:36:48 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-06-04 09:36:48 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RigFemPartResultsCollection* RigGeoMechCaseData::femPartResults()
|
|
|
|
{
|
|
|
|
return m_femPartResultsColl.p();
|
|
|
|
}
|
|
|
|
|
2015-05-06 09:07:30 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-06-11 06:47:21 -05:00
|
|
|
///
|
2015-05-06 09:07:30 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
bool RigGeoMechCaseData::open( std::string* errorMessage )
|
2015-05-06 09:07:30 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
#ifdef USE_ODB_API
|
2015-05-06 09:07:30 -05:00
|
|
|
m_readerInterface = new RifOdbReader;
|
|
|
|
#endif
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_readerInterface.notNull() && m_readerInterface->openFile( m_geoMechCaseFileName, errorMessage ) )
|
2015-05-06 09:07:30 -05:00
|
|
|
{
|
2018-06-11 06:47:21 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
bool RigGeoMechCaseData::readTimeSteps( std::string* errorMessage, std::vector<std::string>* stepNames )
|
2018-06-11 06:47:21 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( stepNames );
|
|
|
|
#ifdef USE_ODB_API
|
|
|
|
if ( m_readerInterface.notNull() && m_readerInterface->isOpen() )
|
2018-06-11 06:47:21 -05:00
|
|
|
{
|
|
|
|
*stepNames = m_readerInterface->allStepNames();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
2019-09-06 03:40:57 -05:00
|
|
|
*errorMessage = std::string( "Could not read time steps" );
|
2018-06-11 06:47:21 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
bool RigGeoMechCaseData::readFemParts( std::string* errorMessage, const std::vector<size_t>& timeStepFilter )
|
2018-06-11 06:47:21 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( errorMessage );
|
|
|
|
#ifdef USE_ODB_API
|
|
|
|
if ( m_readerInterface.notNull() && m_readerInterface->isOpen() )
|
2018-06-11 06:47:21 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_readerInterface->setTimeStepFilter( timeStepFilter );
|
2015-05-06 09:07:30 -05:00
|
|
|
m_femParts = new RigFemPartCollection();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::ProgressInfo progress( 10, "" ); // Here because the next call uses progress
|
|
|
|
progress.setNextProgressIncrement( 9 );
|
|
|
|
if ( m_readerInterface->readFemParts( m_femParts.p() ) )
|
2015-05-06 09:07:30 -05:00
|
|
|
{
|
2015-05-29 05:14:40 -05:00
|
|
|
progress.incrementProgress();
|
2019-09-06 03:40:57 -05:00
|
|
|
progress.setProgressDescription( "Calculating element neighbors" );
|
2015-05-29 05:14:40 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_elementPropertyReader = new RifElementPropertyReader( m_femParts->part( 0 )->elementIdxToId() );
|
2015-05-06 09:07:30 -05:00
|
|
|
// Initialize results containers
|
2020-02-12 04:43:15 -06:00
|
|
|
m_femPartResultsColl =
|
|
|
|
new RigFemPartResultsCollection( m_readerInterface.p(), m_elementPropertyReader.p(), m_femParts.p() );
|
2015-05-26 07:02:25 -05:00
|
|
|
|
|
|
|
// Calculate derived Fem data
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( int pIdx = 0; pIdx < m_femParts->partCount(); ++pIdx )
|
2015-05-26 07:02:25 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_femParts->part( pIdx )->assertNodeToElmIndicesIsCalculated();
|
|
|
|
m_femParts->part( pIdx )->assertElmNeighborsIsCalculated();
|
|
|
|
}
|
2015-05-06 09:07:30 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2018-06-11 06:47:21 -05:00
|
|
|
#endif
|
2019-09-06 03:40:57 -05:00
|
|
|
*errorMessage = std::string( "Could not read FEM parts" );
|
2015-05-06 09:07:30 -05:00
|
|
|
return false;
|
|
|
|
}
|
2021-10-06 19:12:42 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RigGeoMechCaseData::readDisplacements( std::string* errorMessage,
|
|
|
|
int partId,
|
|
|
|
int timeStep,
|
|
|
|
std::vector<cvf::Vec3f>* displacements )
|
|
|
|
{
|
|
|
|
CVF_ASSERT( errorMessage );
|
|
|
|
#ifdef USE_ODB_API
|
|
|
|
if ( m_readerInterface.notNull() && m_readerInterface->isOpen() )
|
|
|
|
{
|
2021-10-15 09:55:55 -05:00
|
|
|
const auto& frames = m_readerInterface->frameTimes( timeStep );
|
|
|
|
m_readerInterface->readDisplacements( partId, timeStep, (int)frames.size() - 1, displacements );
|
2021-10-06 19:12:42 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
*errorMessage = std::string( "Could not read displacements." );
|
|
|
|
return false;
|
|
|
|
}
|