mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4204 Export faults as part of visible grid export
#4204 Enable reading of faults from a different file than the main grid file
This commit is contained in:
parent
88d2ad2c35
commit
677f42591b
@ -27,10 +27,12 @@
|
||||
#include "RifEclipseInputFileTools.h"
|
||||
#include "RifReaderEclipseOutput.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "Rim3dView.h"
|
||||
#include "RimFaultInView.h"
|
||||
#include "RimFaultInViewCollection.h"
|
||||
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigMainGrid.h"
|
||||
@ -74,13 +76,18 @@ void RicExportEclipseInputGridFeature::executeCommand(RimEclipseView* view,
|
||||
const QString& logPrefix)
|
||||
{
|
||||
int resultProgressPercentage = exportSettings.exportResults() ?
|
||||
std::min((int) exportSettings.exportMainKeywords().size(), 30) : 0;
|
||||
std::min((int) exportSettings.exportMainKeywords().size(), 20) : 0;
|
||||
|
||||
int faultsProgressPercentage = exportSettings.exportFaults() ? 10 : 0;
|
||||
|
||||
int gridProgressPercentage = 100 - resultProgressPercentage - faultsProgressPercentage;
|
||||
caf::ProgressInfo progress(gridProgressPercentage + resultProgressPercentage + faultsProgressPercentage,
|
||||
"Export Eclipse Data");
|
||||
|
||||
int gridProgressPercentage = 100 - resultProgressPercentage;
|
||||
caf::ProgressInfo progress(gridProgressPercentage + resultProgressPercentage, "Export Eclipse Data");
|
||||
|
||||
cvf::Vec3st refinement(exportSettings.cellCountI(), exportSettings.cellCountJ(), exportSettings.cellCountK());
|
||||
|
||||
CVF_ASSERT(refinement.x() > 0u && refinement.y() > 0u && refinement.z() > 0u);
|
||||
|
||||
cvf::Vec3st min, max;
|
||||
std::tie(min, max) = getVisibleCellRange(view);
|
||||
if (exportSettings.exportGrid())
|
||||
@ -144,6 +151,43 @@ void RicExportEclipseInputGridFeature::executeCommand(RimEclipseView* view,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (exportSettings.exportFaults() != RicExportEclipseInputGridUi::EXPORT_NO_RESULTS)
|
||||
{
|
||||
auto task = progress.task("Export Faults", faultsProgressPercentage);
|
||||
if (exportSettings.exportFaults == RicExportEclipseInputGridUi::EXPORT_TO_SEPARATE_FILE_PER_RESULT)
|
||||
{
|
||||
QFileInfo info(exportSettings.exportGridFilename());
|
||||
QDir dirPath = info.absoluteDir();
|
||||
|
||||
for (auto faultInView : view->faultCollection()->faults())
|
||||
{
|
||||
auto rigFault = faultInView->faultGeometry();
|
||||
QString fileName = QString("%1.GRDECL").arg(rigFault->name());
|
||||
RifEclipseInputFileTools::saveFault(
|
||||
fileName, view->eclipseCase()->mainGrid(), rigFault->faultFaces(), rigFault->name(), min, max, refinement);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QString fileName = exportSettings.exportFaultsFilename();
|
||||
QIODevice::OpenMode openFlag = QIODevice::Truncate;
|
||||
if (exportSettings.exportResults() == RicExportEclipseInputGridUi::EXPORT_TO_GRID_FILE)
|
||||
{
|
||||
openFlag = QIODevice::Append;
|
||||
fileName = exportSettings.exportGridFilename();
|
||||
}
|
||||
QFile exportFile(fileName);
|
||||
|
||||
if (!exportFile.open(QIODevice::Text | QIODevice::WriteOnly | openFlag))
|
||||
{
|
||||
RiaLogging::error("Could not open the file : " + fileName);
|
||||
}
|
||||
|
||||
QTextStream stream(&exportFile);
|
||||
RifEclipseInputFileTools::saveFaults(stream, view->eclipseCase()->mainGrid(), min, max, refinement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -26,11 +26,13 @@
|
||||
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
#include "cafPdmUiGroup.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiOrdering.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QIntValidator>
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RicExportEclipseInputGridUi, "RicExportEclipseInputGridUi");
|
||||
|
||||
@ -57,11 +59,17 @@ RicExportEclipseInputGridUi::RicExportEclipseInputGridUi(RigEclipseCaseData* cas
|
||||
CAF_PDM_InitObject("Export Visible Cells as Eclipse Input Grid", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&exportGrid, "ExportGrid", true, "Export Grid", "", "Includes COORD, ZCORN and ACTNUM", "");
|
||||
CAF_PDM_InitFieldNoDefault(&exportResults, "ExportResults", "Export Results", "", "", "");
|
||||
CAF_PDM_InitField(&exportResultsFilename, "ExportResultsFilename", QString(), "Results File Name", "", "", "");
|
||||
CAF_PDM_InitField(&exportGridFilename, "ExportGridFilename", QString(), "Grid File Name", "", "", "");
|
||||
exportGridFilename.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&exportResults, "ExportResults", "Export Results", "", "", "");
|
||||
CAF_PDM_InitField(&exportResultsFilename, "ExportResultsFilename", QString(), "Results File Name", "", "", "");
|
||||
exportResultsFilename.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&exportFaults, "ExportFaults", "Export Faults", "", "", "");
|
||||
CAF_PDM_InitField(&exportFaultsFilename, "ExportFaultsFilename", QString(), "Faults File Name", "", "", "");
|
||||
exportFaultsFilename.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&exportMainKeywords, "ExportMainKeywords", "Main Keywords", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&exportAdditionalKeywords, "ExportAdditionalKeywords", "Additional Keywords", "", "", "");
|
||||
|
||||
@ -72,6 +80,7 @@ RicExportEclipseInputGridUi::RicExportEclipseInputGridUi(RigEclipseCaseData* cas
|
||||
|
||||
exportGridFilename = defaultGridFileName();
|
||||
exportResultsFilename = defaultResultsFileName();
|
||||
exportFaultsFilename = defaultFaultsFileName();
|
||||
|
||||
for (QString keyword : mainKeywords())
|
||||
{
|
||||
@ -102,7 +111,7 @@ std::vector<QString> RicExportEclipseInputGridUi::allSelectedKeywords() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportEclipseInputGridUi::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
|
||||
{
|
||||
if (field == &exportResultsFilename || field == &exportGridFilename)
|
||||
if (field == &exportResultsFilename || field == &exportGridFilename || field == &exportFaultsFilename)
|
||||
{
|
||||
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
|
||||
if (myAttr)
|
||||
@ -118,6 +127,15 @@ void RicExportEclipseInputGridUi::defineEditorAttribute(const caf::PdmFieldHandl
|
||||
myAttr->m_heightHint = 200;
|
||||
}
|
||||
}
|
||||
else if (field == &cellCountI || field == &cellCountJ || field == &cellCountK)
|
||||
{
|
||||
caf::PdmUiLineEditorAttribute* myAttr = dynamic_cast<caf::PdmUiLineEditorAttribute*>(attribute);
|
||||
if (myAttr)
|
||||
{
|
||||
QIntValidator* validator = new QIntValidator(1, 10, nullptr);
|
||||
myAttr->validator = validator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -130,8 +148,9 @@ void RicExportEclipseInputGridUi::defineUiOrdering(QString uiConfigName, caf::Pd
|
||||
gridGroup->add(&exportGridFilename);
|
||||
exportGridFilename.uiCapability()->setUiReadOnly(!exportGrid());
|
||||
|
||||
caf::PdmUiGroup* resultsGroup = uiOrdering.addNewGroup("Results Export");
|
||||
caf::PdmUiGroup* resultsGroup = uiOrdering.addNewGroup("Results and Faults Export");
|
||||
resultsGroup->add(&exportResults);
|
||||
resultsGroup->add(&exportFaults);
|
||||
if (exportResults() != EXPORT_NO_RESULTS)
|
||||
{
|
||||
if (exportResults() == EXPORT_TO_SINGLE_SEPARATE_FILE)
|
||||
@ -140,6 +159,13 @@ void RicExportEclipseInputGridUi::defineUiOrdering(QString uiConfigName, caf::Pd
|
||||
resultsGroup->add(&exportMainKeywords);
|
||||
resultsGroup->add(&exportAdditionalKeywords);
|
||||
}
|
||||
if (exportFaults() != EXPORT_NO_RESULTS)
|
||||
{
|
||||
if (exportFaults() == EXPORT_TO_SINGLE_SEPARATE_FILE)
|
||||
{
|
||||
resultsGroup->add(&exportFaultsFilename);
|
||||
}
|
||||
}
|
||||
|
||||
caf::PdmUiGroup* gridRefinement = uiOrdering.addNewGroup("Grid Refinement");
|
||||
gridRefinement->add(&cellCountI, { true, 2, 1 });
|
||||
@ -156,20 +182,44 @@ void RicExportEclipseInputGridUi::fieldChangedByUi(const caf::PdmFieldHandle* ch
|
||||
{
|
||||
if (changedField == &exportGridFilename)
|
||||
{
|
||||
QFileInfo info(exportGridFilename());
|
||||
QDir dirPath = info.absoluteDir();
|
||||
|
||||
if (exportResultsFilename() == defaultResultsFileName())
|
||||
{
|
||||
QFileInfo info(exportGridFilename());
|
||||
QDir gridDirPath = info.absoluteDir();
|
||||
exportResultsFilename = gridDirPath.absoluteFilePath("results.grdecl");
|
||||
exportResultsFilename = dirPath.absoluteFilePath("RESULTS.GRDECL");
|
||||
}
|
||||
if (exportFaultsFilename() == defaultFaultsFileName())
|
||||
{
|
||||
exportFaultsFilename = dirPath.absoluteFilePath("FAULTS.GRDECL");
|
||||
}
|
||||
}
|
||||
else if (changedField == &exportResultsFilename)
|
||||
{
|
||||
QFileInfo info(exportResultsFilename());
|
||||
QDir dirPath = info.absoluteDir();
|
||||
|
||||
if (exportGridFilename() == defaultGridFileName())
|
||||
{
|
||||
QFileInfo info(exportResultsFilename());
|
||||
QDir resultsDirPath = info.absoluteDir();
|
||||
exportGridFilename = resultsDirPath.absoluteFilePath("grid.grdecl");
|
||||
exportGridFilename = dirPath.absoluteFilePath("GRID.GRDECL");
|
||||
}
|
||||
if (exportFaultsFilename() == defaultFaultsFileName())
|
||||
{
|
||||
exportFaultsFilename = dirPath.absoluteFilePath("FAULTS.GRDECL");
|
||||
}
|
||||
}
|
||||
else if (changedField == &exportFaultsFilename)
|
||||
{
|
||||
QFileInfo info(exportFaultsFilename());
|
||||
QDir dirPath = info.absoluteDir();
|
||||
|
||||
if (exportGridFilename() == defaultGridFileName())
|
||||
{
|
||||
exportGridFilename = dirPath.absoluteFilePath("GRID.GRDECL");
|
||||
}
|
||||
if (exportResultsFilename() == defaultResultsFileName())
|
||||
{
|
||||
exportResultsFilename = dirPath.absoluteFilePath("RESULTS.GRDECL");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -247,3 +297,12 @@ QString RicExportEclipseInputGridUi::defaultResultsFileName() const
|
||||
QDir baseDir(RiaApplication::instance()->currentProjectPath());
|
||||
return baseDir.absoluteFilePath("RESULTS.GRDECL");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicExportEclipseInputGridUi::defaultFaultsFileName() const
|
||||
{
|
||||
QDir baseDir(RiaApplication::instance()->currentProjectPath());
|
||||
return baseDir.absoluteFilePath("FAULTS.GRDECL");
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ class RicExportEclipseInputGridUi : public caf::PdmObject
|
||||
EXPORT_TO_SINGLE_SEPARATE_FILE,
|
||||
EXPORT_TO_SEPARATE_FILE_PER_RESULT
|
||||
};
|
||||
|
||||
typedef caf::AppEnum<ResultExportOptions> ResultExportOptionsEnum;
|
||||
|
||||
public:
|
||||
@ -54,9 +55,14 @@ public:
|
||||
std::vector<QString> allSelectedKeywords() const;
|
||||
|
||||
caf::PdmField<bool> exportGrid;
|
||||
caf::PdmField<QString> exportGridFilename;
|
||||
|
||||
caf::PdmField<ResultExportOptionsEnum> exportResults;
|
||||
caf::PdmField<QString> exportGridFilename;
|
||||
caf::PdmField<QString> exportResultsFilename;
|
||||
|
||||
caf::PdmField<ResultExportOptionsEnum> exportFaults;
|
||||
caf::PdmField<QString> exportFaultsFilename;
|
||||
|
||||
caf::PdmField<std::vector<QString>> exportMainKeywords;
|
||||
caf::PdmField<std::vector<QString>> exportAdditionalKeywords;
|
||||
|
||||
@ -74,6 +80,7 @@ protected:
|
||||
static std::set<QString> mainKeywords();
|
||||
QString defaultGridFileName() const;
|
||||
QString defaultResultsFileName() const;
|
||||
QString defaultFaultsFileName() const;
|
||||
private:
|
||||
RigEclipseCaseData* m_caseData;
|
||||
};
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "RigActiveCellInfo.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigFault.h"
|
||||
#include "RigMainGrid.h"
|
||||
|
||||
#include "cafProgressInfo.h"
|
||||
@ -66,9 +67,9 @@ RifEclipseInputFileTools::~RifEclipseInputFileTools() {}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseCaseData* eclipseCase, bool readFaultData)
|
||||
bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseCaseData* eclipseCase, bool readFaultData, QString* errorMessages)
|
||||
{
|
||||
CVF_ASSERT(eclipseCase);
|
||||
CVF_ASSERT(eclipseCase && errorMessages);
|
||||
|
||||
std::vector<RifKeywordAndFilePos> keywordsAndFilePos;
|
||||
findKeywordsOnFile(fileName, &keywordsAndFilePos);
|
||||
@ -100,7 +101,7 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC
|
||||
errorText += " Missing required keyword SPECGRID";
|
||||
}
|
||||
|
||||
RiaLogging::error(errorText);
|
||||
*errorMessages += errorText;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -216,7 +217,7 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC
|
||||
bool RifEclipseInputFileTools::exportGrid(const QString& fileName,
|
||||
RigEclipseCaseData* eclipseCase,
|
||||
const cvf::Vec3st& min,
|
||||
const cvf::Vec3st& max,
|
||||
const cvf::Vec3st& maxIn,
|
||||
const cvf::Vec3st& refinement)
|
||||
{
|
||||
if (!eclipseCase)
|
||||
@ -231,9 +232,17 @@ bool RifEclipseInputFileTools::exportGrid(const QString& fileName,
|
||||
|
||||
const RigMainGrid* mainGrid = eclipseCase->mainGrid();
|
||||
|
||||
int ecl_nx = static_cast<int>((max.x() - min.x()) * refinement.x() + 1);
|
||||
int ecl_ny = static_cast<int>((max.y() - min.y()) * refinement.y() + 1);
|
||||
int ecl_nz = static_cast<int>((max.z() - min.z()) * refinement.z() + 1);
|
||||
cvf::Vec3st max = maxIn;
|
||||
if (max == cvf::Vec3st::UNDEFINED)
|
||||
{
|
||||
max = cvf::Vec3st(mainGrid->cellCountI() - 1, mainGrid->cellCountJ() - 1, mainGrid->cellCountK() - 1);
|
||||
}
|
||||
|
||||
int ecl_nx = static_cast<int>((max.x() - min.x() + 1) * refinement.x());
|
||||
int ecl_ny = static_cast<int>((max.y() - min.y() + 1) * refinement.y());
|
||||
int ecl_nz = static_cast<int>((max.z() - min.z() + 1) * refinement.z());
|
||||
|
||||
CVF_ASSERT(ecl_nx > 0 && ecl_ny > 0 && ecl_nz > 0);
|
||||
|
||||
size_t cellsPerOriginal = refinement.x() * refinement.y() * refinement.z();
|
||||
|
||||
@ -337,7 +346,7 @@ bool RifEclipseInputFileTools::exportKeywords(const QString& result
|
||||
const std::vector<QString>& keywords,
|
||||
const QString& fileWriteMode,
|
||||
const cvf::Vec3st& min,
|
||||
const cvf::Vec3st& max,
|
||||
const cvf::Vec3st& maxIn,
|
||||
const cvf::Vec3st& refinement)
|
||||
{
|
||||
FILE* filePtr = util_fopen(RiaStringEncodingTools::toNativeEncoded(resultFileName).data(),
|
||||
@ -350,6 +359,12 @@ bool RifEclipseInputFileTools::exportKeywords(const QString& result
|
||||
RigActiveCellInfo* activeCells = cellResultsData->activeCellInfo();
|
||||
RigMainGrid* mainGrid = eclipseCase->mainGrid();
|
||||
|
||||
cvf::Vec3st max = maxIn;
|
||||
if (max == cvf::Vec3st::UNDEFINED)
|
||||
{
|
||||
max = cvf::Vec3st(mainGrid->cellCountI() - 1, mainGrid->cellCountJ() - 1, mainGrid->cellCountK() - 1);
|
||||
}
|
||||
|
||||
caf::ProgressInfo progress(keywords.size(), "Saving Keywords");
|
||||
|
||||
for (const QString& keyword : keywords)
|
||||
@ -418,13 +433,17 @@ bool RifEclipseInputFileTools::exportKeywords(const QString& result
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseInputFileTools::saveFault(QString completeFilename,
|
||||
const RigMainGrid* mainGrid,
|
||||
const std::vector<RigFault::FaultFace>& faultFaces,
|
||||
QString faultName)
|
||||
QString faultName,
|
||||
const cvf::Vec3st& min,
|
||||
const cvf::Vec3st& maxIn,
|
||||
const cvf::Vec3st& refinement)
|
||||
{
|
||||
QFile exportFile(completeFilename);
|
||||
|
||||
@ -434,14 +453,34 @@ void RifEclipseInputFileTools::saveFault(QString
|
||||
}
|
||||
|
||||
QTextStream stream(&exportFile);
|
||||
|
||||
stream << "FAULTS" << endl;
|
||||
|
||||
stream << "-- Name I1 I2 J1 J2 K1 K2 Face ( I/J/K )" << endl;
|
||||
|
||||
saveFault(stream, mainGrid, faultFaces, faultName, min, maxIn, refinement);
|
||||
stream << "/" << endl;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseInputFileTools::saveFault(QTextStream& stream,
|
||||
const RigMainGrid* mainGrid,
|
||||
const std::vector<RigFault::FaultFace>& faultFaces,
|
||||
QString faultName,
|
||||
const cvf::Vec3st& min,
|
||||
const cvf::Vec3st& maxIn,
|
||||
const cvf::Vec3st& refinement)
|
||||
{
|
||||
// 'NAME' 1 1 1 1 1 2 J /
|
||||
|
||||
std::vector<RigFault::FaultCellAndFace> faultCellAndFaces;
|
||||
std::vector<RigFault::CellAndFace> faultCellAndFaces;
|
||||
|
||||
cvf::Vec3st max = maxIn;
|
||||
if (max == cvf::Vec3st::UNDEFINED)
|
||||
{
|
||||
max = cvf::Vec3st(mainGrid->cellCountI() - 1, mainGrid->cellCountJ() - 1, mainGrid->cellCountK() - 1);
|
||||
}
|
||||
|
||||
for (const RigFault::FaultFace& faultCellAndFace : faultFaces)
|
||||
{
|
||||
@ -449,11 +488,89 @@ void RifEclipseInputFileTools::saveFault(QString
|
||||
bool ok = mainGrid->ijkFromCellIndex(faultCellAndFace.m_nativeReservoirCellIndex, &i, &j, &k);
|
||||
if (!ok) continue;
|
||||
|
||||
faultCellAndFaces.push_back(std::make_tuple(i, j, k, faultCellAndFace.m_nativeFace));
|
||||
if (i < min.x() || i > max.x() || j < min.y() || j > max.y() || k < min.z() || k > max.z())
|
||||
continue;
|
||||
|
||||
size_t shifted_i = (i - min.x()) * refinement.x();
|
||||
size_t shifted_j = (j - min.y()) * refinement.y();
|
||||
size_t shifted_k = (k - min.z()) * refinement.z();
|
||||
|
||||
// 2x2 Refinement of Original Cell 0, 0
|
||||
// Y/J POS_J boundary
|
||||
// ^ _______________
|
||||
// | | | |
|
||||
// | | 0,1 | 1,1 |
|
||||
// | |_______|_______| POS_I boundary
|
||||
// | | | |
|
||||
// | | 0,0 | 1,0 |
|
||||
// | |_______|_______|
|
||||
// ---------------------> X/I
|
||||
// NEG_J boundary
|
||||
//
|
||||
// POS_J gets shifted 1 index in J direction, NEG_J stays the same in J but spans two I.
|
||||
// POS_I gets shifted 1 index in I direction, NEG_I stays the same in I but spans two J.
|
||||
|
||||
if (refinement != cvf::Vec3st(1, 1, 1))
|
||||
{
|
||||
if (faultCellAndFace.m_nativeFace == cvf::StructGridInterface::POS_I ||
|
||||
faultCellAndFace.m_nativeFace == cvf::StructGridInterface::NEG_I)
|
||||
{
|
||||
if (faultCellAndFace.m_nativeFace == cvf::StructGridInterface::POS_I)
|
||||
{
|
||||
shifted_i += refinement.x() - 1;
|
||||
}
|
||||
for (size_t refineK = 0; refineK < refinement.z(); ++refineK)
|
||||
{
|
||||
for (size_t refineJ = 0; refineJ < refinement.y(); ++refineJ)
|
||||
{
|
||||
faultCellAndFaces.push_back(
|
||||
std::make_tuple(shifted_i, shifted_j + refineJ, shifted_k + refineK, faultCellAndFace.m_nativeFace));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (faultCellAndFace.m_nativeFace == cvf::StructGridInterface::POS_J ||
|
||||
faultCellAndFace.m_nativeFace == cvf::StructGridInterface::NEG_J)
|
||||
{
|
||||
if (faultCellAndFace.m_nativeFace == cvf::StructGridInterface::POS_J)
|
||||
{
|
||||
shifted_j += refinement.y() - 1;
|
||||
}
|
||||
|
||||
for (size_t refineK = 0; refineK < refinement.z(); ++refineK)
|
||||
{
|
||||
for (size_t refineI = 0; refineI < refinement.x(); ++refineI)
|
||||
{
|
||||
faultCellAndFaces.push_back(std::make_tuple(
|
||||
shifted_i + refineI, shifted_j, shifted_k + refineK, faultCellAndFace.m_nativeFace));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (faultCellAndFace.m_nativeFace == cvf::StructGridInterface::POS_K ||
|
||||
faultCellAndFace.m_nativeFace == cvf::StructGridInterface::NEG_K)
|
||||
{
|
||||
if (faultCellAndFace.m_nativeFace == cvf::StructGridInterface::POS_K)
|
||||
{
|
||||
shifted_k += refinement.z() - 1;
|
||||
}
|
||||
|
||||
for (size_t refineJ = 0; refineJ < refinement.y(); ++refineJ)
|
||||
{
|
||||
for (size_t refineI = 0; refineI < refinement.x(); ++refineI)
|
||||
{
|
||||
faultCellAndFaces.push_back(std::make_tuple(
|
||||
shifted_i + refineI, shifted_j + refineJ, shifted_k, faultCellAndFace.m_nativeFace));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
faultCellAndFaces.push_back(std::make_tuple(shifted_i, shifted_j, shifted_k, faultCellAndFace.m_nativeFace));
|
||||
}
|
||||
}
|
||||
|
||||
// Sort order: i, j, face then k.
|
||||
std::sort(faultCellAndFaces.begin(), faultCellAndFaces.end(), RigFault::faultOrdering);
|
||||
std::sort(faultCellAndFaces.begin(), faultCellAndFaces.end(), RigFault::ordering);
|
||||
|
||||
size_t lastI = std::numeric_limits<size_t>::max();
|
||||
size_t lastJ = std::numeric_limits<size_t>::max();
|
||||
@ -461,7 +578,7 @@ void RifEclipseInputFileTools::saveFault(QString
|
||||
size_t startK = std::numeric_limits<size_t>::max();
|
||||
cvf::StructGridInterface::FaceType lastFaceType = cvf::StructGridInterface::FaceType::NO_FACE;
|
||||
|
||||
for (const RigFault::FaultCellAndFace& faultCellAndFace : faultCellAndFaces)
|
||||
for (const RigFault::CellAndFace& faultCellAndFace : faultCellAndFaces)
|
||||
{
|
||||
size_t i, j, k;
|
||||
cvf::StructGridInterface::FaceType faceType;
|
||||
@ -490,8 +607,27 @@ void RifEclipseInputFileTools::saveFault(QString
|
||||
{
|
||||
writeFaultLine(stream, faultName, lastI, lastJ, startK, lastK, lastFaceType);
|
||||
}
|
||||
stream << "/" << endl;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseInputFileTools::saveFaults(QTextStream& stream,
|
||||
const RigMainGrid* mainGrid,
|
||||
const cvf::Vec3st& min /*= cvf::Vec3st::ZERO*/,
|
||||
const cvf::Vec3st& max /*= cvf::Vec3st::UNDEFINED*/,
|
||||
const cvf::Vec3st& refinement /*= cvf::Vec3st(1, 1, 1)*/)
|
||||
{
|
||||
stream << "FAULTS" << endl;
|
||||
|
||||
stream << "-- Name I1 I2 J1 J2 K1 K2 Face ( I/J/K )" << endl;
|
||||
|
||||
const cvf::Collection<RigFault>& faults = mainGrid->faults();
|
||||
for (const auto fault : faults)
|
||||
{
|
||||
saveFault(stream, mainGrid, fault->faultFaces(), fault->name(), min, max, refinement);
|
||||
}
|
||||
stream << "/" << endl;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -58,27 +58,44 @@ public:
|
||||
RifEclipseInputFileTools();
|
||||
~RifEclipseInputFileTools() override;
|
||||
|
||||
static bool openGridFile(const QString& fileName, RigEclipseCaseData* eclipseCase, bool readFaultData);
|
||||
static bool openGridFile(const QString& fileName, RigEclipseCaseData* eclipseCase, bool readFaultData, QString* errorMessages);
|
||||
|
||||
static bool exportGrid(const QString& gridFileName,
|
||||
RigEclipseCaseData* eclipseCase,
|
||||
const cvf::Vec3st& min,
|
||||
const cvf::Vec3st& max,
|
||||
const cvf::Vec3st& refinement);
|
||||
const cvf::Vec3st& min = cvf::Vec3st::ZERO,
|
||||
const cvf::Vec3st& max = cvf::Vec3st::UNDEFINED,
|
||||
const cvf::Vec3st& refinement = cvf::Vec3st(1, 1, 1));
|
||||
|
||||
static bool exportKeywords(const QString& resultFileName,
|
||||
RigEclipseCaseData* eclipseCase,
|
||||
const std::vector<QString>& keywords,
|
||||
const QString& fileWriteMode,
|
||||
const cvf::Vec3st& min,
|
||||
const cvf::Vec3st& max,
|
||||
const cvf::Vec3st& refinement);
|
||||
const cvf::Vec3st& min = cvf::Vec3st::ZERO,
|
||||
const cvf::Vec3st& max = cvf::Vec3st::UNDEFINED,
|
||||
const cvf::Vec3st& refinement = cvf::Vec3st(1, 1, 1));
|
||||
|
||||
static void saveFault(QString completeFilename,
|
||||
const RigMainGrid* mainGrid,
|
||||
const std::vector<RigFault::FaultFace>& faultFaces,
|
||||
QString faultName);
|
||||
|
||||
QString faultName,
|
||||
const cvf::Vec3st& min = cvf::Vec3st::ZERO,
|
||||
const cvf::Vec3st& max = cvf::Vec3st::UNDEFINED,
|
||||
const cvf::Vec3st& refinement = cvf::Vec3st(1, 1, 1));
|
||||
|
||||
static void saveFault(QTextStream& stream,
|
||||
const RigMainGrid* mainGrid,
|
||||
const std::vector<RigFault::FaultFace>& faultFaces,
|
||||
QString faultName,
|
||||
const cvf::Vec3st& min = cvf::Vec3st::ZERO,
|
||||
const cvf::Vec3st& max = cvf::Vec3st::UNDEFINED,
|
||||
const cvf::Vec3st& refinement = cvf::Vec3st(1, 1, 1));
|
||||
|
||||
static void saveFaults(QTextStream& stream,
|
||||
const RigMainGrid* mainGrid,
|
||||
const cvf::Vec3st& min = cvf::Vec3st::ZERO,
|
||||
const cvf::Vec3st& max = cvf::Vec3st::UNDEFINED,
|
||||
const cvf::Vec3st& refinement = cvf::Vec3st(1, 1, 1));
|
||||
|
||||
// Returns map of assigned resultName and Eclipse Keyword.
|
||||
static std::map<QString, QString> readProperties(const QString& fileName, RigEclipseCaseData* eclipseCase);
|
||||
static bool readProperty (const QString& fileName, RigEclipseCaseData* eclipseCase, const QString& eclipseKeyWord, const QString& resultName );
|
||||
@ -106,12 +123,12 @@ public:
|
||||
static bool readKeywordAndParseIncludeStatementsRecursively(const QString& keyword,
|
||||
const QString& keywordToStopParsing,
|
||||
QFile& file,
|
||||
qint64 startPos,
|
||||
const std::vector< std::pair<QString, QString> >& pathAliasDefinitions,
|
||||
QStringList* keywordDataContent,
|
||||
std::vector<QString>* filenamesContainingKeyword,
|
||||
bool* isEditKeywordDetected,
|
||||
const QString& faultIncludeFileAbsolutePathPrefix // rename to includeStatementAbsolutePathPrefix
|
||||
qint64 startPos,
|
||||
const std::vector< std::pair<QString, QString> >& pathAliasDefinitions,
|
||||
QStringList* keywordDataContent,
|
||||
std::vector<QString>* filenamesContainingKeyword,
|
||||
bool* isEditKeywordDetected,
|
||||
const QString& faultIncludeFileAbsolutePathPrefix // rename to includeStatementAbsolutePathPrefix
|
||||
);
|
||||
|
||||
static void readKeywordDataContent(QFile &data, qint64 filePos, QStringList* textContent, bool* isEditKeywordDetected);
|
||||
@ -139,5 +156,5 @@ private:
|
||||
static QString faultFaceText(cvf::StructGridInterface::FaceType faceType);
|
||||
|
||||
private:
|
||||
static const std::vector<QString>& invalidPropertyDataKeywords();
|
||||
static const std::vector<QString>& invalidPropertyDataKeywords();
|
||||
};
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "RifReaderEclipseInput.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include "RifEclipseInputFileTools.h"
|
||||
|
||||
#include "RigEclipseCaseData.h"
|
||||
@ -74,7 +75,12 @@ bool RifReaderEclipseInput::open(const QString& fileName, RigEclipseCaseData* ec
|
||||
bool isOk = false;
|
||||
if (eclipseCase->mainGrid()->gridPointDimensions() == cvf::Vec3st(0,0,0))
|
||||
{
|
||||
isOk = RifEclipseInputFileTools::openGridFile(fileName, eclipseCase, isFaultImportEnabled());
|
||||
QString errorMesssages;
|
||||
isOk = RifEclipseInputFileTools::openGridFile(fileName, eclipseCase, isFaultImportEnabled(), &errorMesssages);
|
||||
if (!isOk)
|
||||
{
|
||||
RiaLogging::error(errorMesssages);
|
||||
}
|
||||
}
|
||||
|
||||
return isOk;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "RimEclipseInputCase.h"
|
||||
|
||||
#include "RiaFieldHandleTools.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RifEclipseInputFileTools.h"
|
||||
@ -109,14 +110,17 @@ bool RimEclipseInputCase::openDataFileSet(const QStringList& fileNames)
|
||||
this->setReservoirData(new RigEclipseCaseData(this));
|
||||
}
|
||||
|
||||
bool importFaults = RiaApplication::instance()->preferences()->readerSettings()->importFaults();
|
||||
|
||||
std::vector<QString> allErrorMessages;
|
||||
|
||||
// First find and read the grid data
|
||||
if (this->eclipseCaseData()->mainGrid()->gridPointDimensions() == cvf::Vec3st(0,0,0))
|
||||
{
|
||||
RiaPreferences* prefs = RiaApplication::instance()->preferences();
|
||||
|
||||
for (int i = 0; i < fileNames.size(); i++)
|
||||
{
|
||||
if (RifEclipseInputFileTools::openGridFile(fileNames[i], this->eclipseCaseData(), prefs->readerSettings()->importFaults()))
|
||||
QString errorMessages;
|
||||
if (RifEclipseInputFileTools::openGridFile(fileNames[i], this->eclipseCaseData(), importFaults, &errorMessages))
|
||||
{
|
||||
m_gridFileName = fileNames[i];
|
||||
|
||||
@ -131,11 +135,22 @@ bool RimEclipseInputCase::openDataFileSet(const QStringList& fileNames)
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
allErrorMessages.push_back(errorMessages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this->eclipseCaseData()->mainGrid()->gridPointDimensions() == cvf::Vec3st(0,0,0))
|
||||
{
|
||||
if (!allErrorMessages.empty())
|
||||
{
|
||||
for (QString errorMessages : allErrorMessages)
|
||||
{
|
||||
RiaLogging::error(errorMessages);
|
||||
}
|
||||
}
|
||||
return false; // No grid present
|
||||
}
|
||||
|
||||
@ -171,6 +186,17 @@ bool RimEclipseInputCase::openDataFileSet(const QStringList& fileNames)
|
||||
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
|
||||
m_inputPropertyCollection->inputProperties.push_back(inputProperty);
|
||||
}
|
||||
|
||||
if (importFaults)
|
||||
{
|
||||
cvf::Collection<RigFault> faultCollection;
|
||||
RifEclipseInputFileTools::parseAndReadFaults(propertyFileName, &faultCollection);
|
||||
|
||||
if (!faultCollection.empty())
|
||||
{
|
||||
this->eclipseCaseData()->mainGrid()->setFaults(faultCollection);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ const std::vector<size_t>& RigFault::connectionIndices() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Order FaultCellAndFace by i, j, face then k.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigFault::faultOrdering(FaultCellAndFace first, FaultCellAndFace second)
|
||||
bool RigFault::ordering(CellAndFace first, CellAndFace second)
|
||||
{
|
||||
size_t i1, i2, j1, j2, k1, k2;
|
||||
cvf::StructGridInterface::FaceType f1, f2;
|
||||
|
@ -76,7 +76,7 @@ private:
|
||||
class RigFault : public cvf::Object
|
||||
{
|
||||
public:
|
||||
typedef std::tuple<size_t, size_t, size_t, cvf::StructGridInterface::FaceType> FaultCellAndFace;
|
||||
typedef std::tuple<size_t, size_t, size_t, cvf::StructGridInterface::FaceType> CellAndFace;
|
||||
|
||||
struct FaultFace
|
||||
{
|
||||
@ -108,7 +108,7 @@ public:
|
||||
std::vector<size_t>& connectionIndices();
|
||||
const std::vector<size_t>& connectionIndices() const;
|
||||
|
||||
static bool faultOrdering(RigFault::FaultCellAndFace first, RigFault::FaultCellAndFace second);
|
||||
static bool ordering(CellAndFace first, CellAndFace second);
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
|
@ -406,7 +406,15 @@ void RigMainGrid::setFaults(const cvf::Collection<RigFault>& faults)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const cvf::Collection<RigFault>& RigMainGrid::faults()
|
||||
const cvf::Collection<RigFault>& RigMainGrid::faults() const
|
||||
{
|
||||
return m_faults;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Collection<RigFault>& RigMainGrid::faults()
|
||||
{
|
||||
return m_faults;
|
||||
}
|
||||
|
@ -71,7 +71,8 @@ public:
|
||||
|
||||
RigNNCData* nncData();
|
||||
void setFaults(const cvf::Collection<RigFault>& faults);
|
||||
const cvf::Collection<RigFault>& faults();
|
||||
const cvf::Collection<RigFault>& faults() const;
|
||||
cvf::Collection<RigFault>& faults();
|
||||
void calculateFaults(const RigActiveCellInfo* activeCellInfo);
|
||||
|
||||
void distributeNNCsToFaults();
|
||||
|
Loading…
Reference in New Issue
Block a user