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