mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3478 Export Cell Result to File : Move code to RicEclipseCellResultToFileImpl
This commit is contained in:
parent
911de7c973
commit
4290d8d836
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "RicfCommandFileExecutor.h"
|
#include "RicfCommandFileExecutor.h"
|
||||||
|
|
||||||
|
#include "../Commands/ExportCommands/RicEclipseCellResultToFileImpl.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
#include "RiaLogging.h"
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
@ -36,8 +38,6 @@
|
|||||||
#include "RimEclipseView.h"
|
#include "RimEclipseView.h"
|
||||||
#include "RimEclipseCellColors.h"
|
#include "RimEclipseCellColors.h"
|
||||||
|
|
||||||
#include "RifEclipseInputFileTools.h"
|
|
||||||
|
|
||||||
#include "cafUtils.h"
|
#include "cafUtils.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@ -118,7 +118,7 @@ void RicfExportProperty::execute()
|
|||||||
auto resultAccessor = findResult(view, timeStepIndex, propertyType, propertyName);
|
auto resultAccessor = findResult(view, timeStepIndex, propertyType, propertyName);
|
||||||
if (!resultAccessor.isNull())
|
if (!resultAccessor.isNull())
|
||||||
{
|
{
|
||||||
RifEclipseInputFileTools::writeResultToTextFile(filePath, eclipseCase->eclipseCaseData(), resultAccessor, eclipseKeyword, m_undefinedValue, "exportProperty");
|
RicEclipseCellResultToFileImpl::writeResultToTextFile(filePath, eclipseCase->eclipseCaseData(), resultAccessor.p(), eclipseKeyword, m_undefinedValue, "exportProperty");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicExportVisibleWellPathsFeature.h
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicExportWellPathsUi.h
|
${CMAKE_CURRENT_LIST_DIR}/RicExportWellPathsUi.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicExportLgrFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicExportLgrFeature.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicExportLgrUi.h
|
${CMAKE_CURRENT_LIST_DIR}/RicExportLgrUi.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicEclipseCellResultToFileImpl.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (SOURCE_GROUP_SOURCE_FILES
|
set (SOURCE_GROUP_SOURCE_FILES
|
||||||
@ -46,6 +47,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicExportVisibleWellPathsFeature.cpp
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicExportWellPathsUi.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicExportWellPathsUi.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicExportLgrFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicExportLgrFeature.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicExportLgrUi.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicExportLgrUi.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicEclipseCellResultToFileImpl.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND CODE_HEADER_FILES
|
list(APPEND CODE_HEADER_FILES
|
||||||
|
@ -0,0 +1,157 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018- Equinor ASA
|
||||||
|
//
|
||||||
|
// 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 "RicEclipseCellResultToFileImpl.h"
|
||||||
|
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
#include "RigCaseCellResultsData.h"
|
||||||
|
#include "RigEclipseCaseData.h"
|
||||||
|
#include "RigMainGrid.h"
|
||||||
|
#include "RigResultAccessor.h"
|
||||||
|
#include "RigResultAccessorFactory.h"
|
||||||
|
|
||||||
|
#include "RimEclipseResultDefinition.h"
|
||||||
|
|
||||||
|
#include "cafProgressInfo.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicEclipseCellResultToFileImpl::writePropertyToTextFile(const QString& fileName,
|
||||||
|
RigEclipseCaseData* eclipseCase,
|
||||||
|
size_t timeStep,
|
||||||
|
const QString& resultName,
|
||||||
|
const QString& eclipseKeyword)
|
||||||
|
{
|
||||||
|
CVF_TIGHT_ASSERT(eclipseCase);
|
||||||
|
if (!eclipseCase) return false;
|
||||||
|
|
||||||
|
cvf::ref<RigResultAccessor> resultAccessor =
|
||||||
|
RigResultAccessorFactory::createFromUiResultName(eclipseCase, 0, RiaDefines::MATRIX_MODEL, timeStep, resultName);
|
||||||
|
if (resultAccessor.isNull())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const double undefinedValue = 0.0;
|
||||||
|
|
||||||
|
return writeResultToTextFile(
|
||||||
|
fileName, eclipseCase, resultAccessor.p(), eclipseKeyword, undefinedValue, "writePropertyToTextFile");
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicEclipseCellResultToFileImpl::writeBinaryResultToTextFile(const QString& fileName,
|
||||||
|
RigEclipseCaseData* eclipseCase,
|
||||||
|
size_t timeStep,
|
||||||
|
RimEclipseResultDefinition* resultDefinition,
|
||||||
|
const QString& eclipseKeyword,
|
||||||
|
const double undefinedValue,
|
||||||
|
const QString& logPrefix)
|
||||||
|
{
|
||||||
|
CVF_TIGHT_ASSERT(eclipseCase);
|
||||||
|
|
||||||
|
cvf::ref<RigResultAccessor> resultAccessor =
|
||||||
|
RigResultAccessorFactory::createFromResultDefinition(eclipseCase, 0, timeStep, resultDefinition);
|
||||||
|
if (resultAccessor.isNull())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return writeResultToTextFile(fileName, eclipseCase, resultAccessor.p(), eclipseKeyword, undefinedValue, logPrefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicEclipseCellResultToFileImpl::writeResultToTextFile(const QString& fileName,
|
||||||
|
RigEclipseCaseData* eclipseCase,
|
||||||
|
RigResultAccessor* resultAccessor,
|
||||||
|
const QString& eclipseKeyword,
|
||||||
|
const double undefinedValue,
|
||||||
|
const QString& logPrefix)
|
||||||
|
{
|
||||||
|
if (!resultAccessor)
|
||||||
|
{
|
||||||
|
RiaLogging::error(logPrefix + QString(" : : Could not access result data for '%1'").arg(fileName));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile file(fileName);
|
||||||
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
|
{
|
||||||
|
RiaLogging::error(logPrefix + QString(" : Could not open file '%1'. Do the folder exist?").arg(fileName));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<double> resultData;
|
||||||
|
for (size_t i = 0; i < eclipseCase->mainGrid()->cellCount(); i++)
|
||||||
|
{
|
||||||
|
double resultValue = resultAccessor->cellScalar(i);
|
||||||
|
if (resultValue == HUGE_VAL)
|
||||||
|
{
|
||||||
|
resultValue = undefinedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
resultData.push_back(resultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
writeDataToTextFile(&file, eclipseKeyword, resultData);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicEclipseCellResultToFileImpl::writeDataToTextFile(QFile* file,
|
||||||
|
const QString& eclipseKeyword,
|
||||||
|
const std::vector<double>& resultData)
|
||||||
|
{
|
||||||
|
QTextStream textstream(file);
|
||||||
|
textstream << "\n";
|
||||||
|
textstream << "-- Exported from ResInsight"
|
||||||
|
<< "\n";
|
||||||
|
textstream << eclipseKeyword << "\n" << right << qSetFieldWidth(16);
|
||||||
|
|
||||||
|
caf::ProgressInfo pi(resultData.size(), QString("Writing data to file %1").arg(file->fileName()));
|
||||||
|
size_t progressSteps = resultData.size() / 20;
|
||||||
|
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < resultData.size(); i++)
|
||||||
|
{
|
||||||
|
textstream << resultData[i];
|
||||||
|
|
||||||
|
if ((i + 1) % 5 == 0)
|
||||||
|
{
|
||||||
|
textstream << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i % progressSteps == 0)
|
||||||
|
{
|
||||||
|
pi.setProgress(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
textstream << "\n"
|
||||||
|
<< "/"
|
||||||
|
<< "\n";
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018- Equinor ASA
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class QFile;
|
||||||
|
|
||||||
|
class RigEclipseCaseData;
|
||||||
|
class RimEclipseResultDefinition;
|
||||||
|
class RigResultAccessor;
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicEclipseCellResultToFileImpl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static bool writePropertyToTextFile(const QString& fileName,
|
||||||
|
RigEclipseCaseData* eclipseCase,
|
||||||
|
size_t timeStep,
|
||||||
|
const QString& resultName,
|
||||||
|
const QString& eclipseKeyword);
|
||||||
|
|
||||||
|
static bool writeBinaryResultToTextFile(const QString& fileName,
|
||||||
|
RigEclipseCaseData* eclipseCase,
|
||||||
|
size_t timeStep,
|
||||||
|
RimEclipseResultDefinition* resultDefinition,
|
||||||
|
const QString& eclipseKeyword,
|
||||||
|
const double undefinedValue,
|
||||||
|
const QString& logPrefix);
|
||||||
|
|
||||||
|
static bool writeResultToTextFile(const QString& fileName,
|
||||||
|
RigEclipseCaseData* eclipseCase,
|
||||||
|
RigResultAccessor* resultAccessor,
|
||||||
|
const QString& eclipseKeyword,
|
||||||
|
const double undefinedValue,
|
||||||
|
const QString& logPrefix);
|
||||||
|
|
||||||
|
static void writeDataToTextFile(QFile* file, const QString& eclipseKeyword, const std::vector<double>& resultData);
|
||||||
|
};
|
@ -22,8 +22,7 @@
|
|||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
|
||||||
#include "RicExportFeatureImpl.h"
|
#include "RicExportFeatureImpl.h"
|
||||||
|
#include "RicEclipseCellResultToFileImpl.h"
|
||||||
#include "RifEclipseInputFileTools.h"
|
|
||||||
|
|
||||||
#include "RimEclipseInputCase.h"
|
#include "RimEclipseInputCase.h"
|
||||||
#include "RimEclipseInputProperty.h"
|
#include "RimEclipseInputProperty.h"
|
||||||
@ -106,7 +105,7 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered(bool isChecked)
|
|||||||
|
|
||||||
if (propertyDialog.exec() == QDialog::Accepted)
|
if (propertyDialog.exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
bool isOk = RifEclipseInputFileTools::writePropertyToTextFile(exportSettings.fileName, inputReservoir->eclipseCaseData(), 0, inputProperty->resultName, exportSettings.eclipseKeyword);
|
bool isOk = RicEclipseCellResultToFileImpl::writePropertyToTextFile(exportSettings.fileName, inputReservoir->eclipseCaseData(), 0, inputProperty->resultName, exportSettings.eclipseKeyword);
|
||||||
if (isOk)
|
if (isOk)
|
||||||
{
|
{
|
||||||
inputProperty->fileName = exportSettings.fileName;
|
inputProperty->fileName = exportSettings.fileName;
|
||||||
|
@ -22,11 +22,9 @@
|
|||||||
#include "RiaLogging.h"
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
#include "RicExportFeatureImpl.h"
|
#include "RicExportFeatureImpl.h"
|
||||||
|
#include "RicEclipseCellResultToFileImpl.h"
|
||||||
#include "RicSaveEclipseInputVisibleCellsUi.h"
|
#include "RicSaveEclipseInputVisibleCellsUi.h"
|
||||||
|
|
||||||
#include "RifEclipseInputFileTools.h"
|
|
||||||
|
|
||||||
#include "RimEclipseCase.h"
|
#include "RimEclipseCase.h"
|
||||||
#include "RimEclipseCellColors.h"
|
#include "RimEclipseCellColors.h"
|
||||||
#include "RimEclipseView.h"
|
#include "RimEclipseView.h"
|
||||||
@ -99,7 +97,8 @@ void RicSaveEclipseInputVisibleCellsFeature::executeCommand(RimEclipseView* view
|
|||||||
RiaLogging::error(QString("%1: Unable to open file '%2' for writing.").arg(logPrefix).arg(exportSettings.exportFilename));
|
RiaLogging::error(QString("%1: Unable to open file '%2' for writing.").arg(logPrefix).arg(exportSettings.exportFilename));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RifEclipseInputFileTools::writeDataToTextFile(&exportFile, exportSettings.exportKeyword().text(), values);
|
|
||||||
|
RicEclipseCellResultToFileImpl::writeDataToTextFile(&exportFile, exportSettings.exportKeyword().text(), values);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
#include "RiaLogging.h"
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
#include "RicExportFeatureImpl.h"
|
#include "RicExportFeatureImpl.h"
|
||||||
|
#include "RicEclipseCellResultToFileImpl.h"
|
||||||
#include "RifEclipseInputFileTools.h"
|
|
||||||
#include "RifReaderInterface.h"
|
|
||||||
|
|
||||||
#include "RigCaseCellResultsData.h"
|
#include "RigCaseCellResultsData.h"
|
||||||
|
|
||||||
@ -99,7 +97,7 @@ void RicSaveEclipseResultAsInputPropertyExec::redo()
|
|||||||
{
|
{
|
||||||
size_t timeStep = m_cellColors->reservoirView()->currentTimeStep();
|
size_t timeStep = m_cellColors->reservoirView()->currentTimeStep();
|
||||||
|
|
||||||
bool isOk = RifEclipseInputFileTools::writeBinaryResultToTextFile(exportSettings.fileName, m_cellColors->reservoirView()->eclipseCase()->eclipseCaseData(), timeStep, m_cellColors, exportSettings.eclipseKeyword, exportSettings.undefinedValue, "saveEclipseResultAsInputPropertyExec");
|
bool isOk = RicEclipseCellResultToFileImpl::writeBinaryResultToTextFile(exportSettings.fileName, m_cellColors->reservoirView()->eclipseCase()->eclipseCaseData(), timeStep, m_cellColors, exportSettings.eclipseKeyword, exportSettings.undefinedValue, "saveEclipseResultAsInputPropertyExec");
|
||||||
if (!isOk)
|
if (!isOk)
|
||||||
{
|
{
|
||||||
RiaLogging::error("Failed to exported current result to " + exportSettings.fileName);
|
RiaLogging::error("Failed to exported current result to " + exportSettings.fileName);
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include "RigCaseCellResultsData.h"
|
#include "RigCaseCellResultsData.h"
|
||||||
#include "RigEclipseCaseData.h"
|
#include "RigEclipseCaseData.h"
|
||||||
#include "RigMainGrid.h"
|
#include "RigMainGrid.h"
|
||||||
#include "RigResultAccessorFactory.h"
|
|
||||||
|
|
||||||
#include "cafProgressInfo.h"
|
#include "cafProgressInfo.h"
|
||||||
|
|
||||||
@ -471,133 +470,6 @@ const std::vector<QString>& RifEclipseInputFileTools::invalidPropertyDataKeyword
|
|||||||
return keywords;
|
return keywords;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName, RigEclipseCaseData* eclipseCase, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord)
|
|
||||||
{
|
|
||||||
CVF_ASSERT(eclipseCase);
|
|
||||||
|
|
||||||
size_t resultIndex = eclipseCase->results(RiaDefines::MATRIX_MODEL)->findScalarResultIndex(resultName);
|
|
||||||
if (resultIndex == cvf::UNDEFINED_SIZE_T)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFile file(fileName);
|
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector< std::vector<double> >& resultData = eclipseCase->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(resultIndex);
|
|
||||||
if (resultData.size() == 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<double>& singleTimeStepData = resultData[timeStep];
|
|
||||||
writeDataToTextFile(&file, eclipseKeyWord, singleTimeStepData);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
/// Create and write a result vector with values for all cells.
|
|
||||||
/// undefinedValue is used for cells with no result
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileName,
|
|
||||||
RigEclipseCaseData* eclipseCase,
|
|
||||||
size_t timeStep,
|
|
||||||
RimEclipseResultDefinition* resultDefinition,
|
|
||||||
const QString& eclipseKeyWord,
|
|
||||||
const double undefinedValue,
|
|
||||||
const QString& logPrefix)
|
|
||||||
{
|
|
||||||
CVF_ASSERT(eclipseCase);
|
|
||||||
|
|
||||||
cvf::ref<RigResultAccessor> resultAccessor = RigResultAccessorFactory::createFromResultDefinition(eclipseCase, eclipseCase->mainGrid()->gridIndex(), timeStep, resultDefinition);
|
|
||||||
if (resultAccessor.isNull())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return writeResultToTextFile(fileName, eclipseCase, resultAccessor, eclipseKeyWord, undefinedValue, logPrefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
bool RifEclipseInputFileTools::writeResultToTextFile(const QString& fileName,
|
|
||||||
RigEclipseCaseData* eclipseCase,
|
|
||||||
cvf::ref<RigResultAccessor> resultAccessor,
|
|
||||||
const QString& eclipseKeyWord,
|
|
||||||
const double undefinedValue,
|
|
||||||
const QString& logPrefix)
|
|
||||||
{
|
|
||||||
QFile file(fileName);
|
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
|
||||||
{
|
|
||||||
RiaLogging::error(QString("Could not open file '%1'. Do the folder exist?"). arg(fileName));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<double> resultData;
|
|
||||||
size_t i, j, k;
|
|
||||||
for (k = 0; k < eclipseCase->mainGrid()->cellCountK(); k++)
|
|
||||||
{
|
|
||||||
for (j = 0; j < eclipseCase->mainGrid()->cellCountJ(); j++)
|
|
||||||
{
|
|
||||||
for (i = 0; i < eclipseCase->mainGrid()->cellCountI(); i++)
|
|
||||||
{
|
|
||||||
double resultValue = resultAccessor->cellScalar(eclipseCase->mainGrid()->cellIndexFromIJK(i, j, k));
|
|
||||||
if (resultValue == HUGE_VAL)
|
|
||||||
{
|
|
||||||
resultValue = undefinedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
resultData.push_back(resultValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
writeDataToTextFile(&file, eclipseKeyWord, resultData);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RifEclipseInputFileTools::writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector<double>& resultData)
|
|
||||||
{
|
|
||||||
QTextStream out(file);
|
|
||||||
out << "\n";
|
|
||||||
out << "-- Exported from ResInsight" << "\n";
|
|
||||||
out << eclipseKeyWord << "\n" << right << qSetFieldWidth(16);
|
|
||||||
|
|
||||||
caf::ProgressInfo pi(resultData.size(), QString("Writing data to file %1").arg(file->fileName()) );
|
|
||||||
size_t progressSteps = resultData.size() / 20;
|
|
||||||
|
|
||||||
size_t i;
|
|
||||||
for (i = 0; i < resultData.size(); i++)
|
|
||||||
{
|
|
||||||
out << resultData[i];
|
|
||||||
|
|
||||||
if ( (i + 1) % 5 == 0)
|
|
||||||
{
|
|
||||||
out << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i % progressSteps == 0)
|
|
||||||
{
|
|
||||||
pi.setProgress(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
out << "\n" << "/" << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -36,8 +36,6 @@
|
|||||||
|
|
||||||
class RigEclipseCaseData;
|
class RigEclipseCaseData;
|
||||||
class QFile;
|
class QFile;
|
||||||
class RimEclipseResultDefinition;
|
|
||||||
class RigResultAccessor;
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Structure used to cache file position of keywords
|
/// Structure used to cache file position of keywords
|
||||||
@ -76,10 +74,6 @@ public:
|
|||||||
static void parseAndReadPathAliasKeyword(const QString &fileName, std::vector< std::pair<QString, QString> >* pathAliasDefinitions);
|
static void parseAndReadPathAliasKeyword(const QString &fileName, std::vector< std::pair<QString, QString> >* pathAliasDefinitions);
|
||||||
|
|
||||||
|
|
||||||
static bool writePropertyToTextFile(const QString& fileName, RigEclipseCaseData* eclipseCase, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord);
|
|
||||||
static bool writeBinaryResultToTextFile(const QString& fileName, RigEclipseCaseData* eclipseCase, size_t timeStep, RimEclipseResultDefinition* resultdefinition, const QString& eclipseKeyWord, const double undefinedValue, const QString& logPrefix);
|
|
||||||
static bool writeResultToTextFile(const QString& fileName, RigEclipseCaseData* eclipseCase, cvf::ref<RigResultAccessor> resultAccessor, const QString& eclipseKeyWord, const double undefinedValue, const QString& logPrefix);
|
|
||||||
|
|
||||||
static bool readFaultsAndParseIncludeStatementsRecursively( QFile& file,
|
static bool readFaultsAndParseIncludeStatementsRecursively( QFile& file,
|
||||||
qint64 startPos,
|
qint64 startPos,
|
||||||
const std::vector< std::pair<QString, QString> >& pathAliasDefinitions,
|
const std::vector< std::pair<QString, QString> >& pathAliasDefinitions,
|
||||||
@ -89,7 +83,6 @@ public:
|
|||||||
const QString& faultIncludeFileAbsolutePathPrefix);
|
const QString& faultIncludeFileAbsolutePathPrefix);
|
||||||
|
|
||||||
static cvf::StructGridInterface::FaceEnum faceEnumFromText(const QString& faceString);
|
static cvf::StructGridInterface::FaceEnum faceEnumFromText(const QString& faceString);
|
||||||
static void writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector<double>& resultData);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool readDataFromKeyword(ecl_kw_type* eclipseKeywordData, RigEclipseCaseData* caseData, const QString& resultName);
|
static bool readDataFromKeyword(ecl_kw_type* eclipseKeywordData, RigEclipseCaseData* caseData, const QString& resultName);
|
||||||
|
Loading…
Reference in New Issue
Block a user