mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-23 23:13:39 -06:00
806a149809
* Use constructor instead of nullptr for WindowFlags * Use constructor instead of nullptr for Alignment * Disable deprecation warning for QProcess * Add string split method to RaTextStringTools * Add caf.cpp used to manage Qt function deprecations * Use position()
110 lines
3.8 KiB
C++
110 lines
3.8 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2021 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 "RifFaultRAJsonWriter.h"
|
|
|
|
#include "RimFaultRAPostprocSettings.h"
|
|
#include "RimFaultRAPreprocSettings.h"
|
|
#include "RimGenericParameter.h"
|
|
#include "RimParameterGroup.h"
|
|
|
|
#include "caf.h"
|
|
|
|
#include <QFile>
|
|
#include <QTextStream>
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RifFaultRAJSonWriter::writeToPreprocFile( RimFaultRAPreprocSettings& settings, QString& outErrorText )
|
|
{
|
|
QString filename = settings.preprocParameterFilename();
|
|
|
|
outErrorText = "Unable to write to file \"" + filename + "\" - ";
|
|
|
|
QFile file( filename );
|
|
if ( file.open( QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text ) )
|
|
{
|
|
QTextStream stream( &file );
|
|
|
|
stream << "{" << caf::endl;
|
|
stream << "\"odb_path\": \"" + settings.geomechCaseFilename() + "\"," << caf::endl;
|
|
stream << "\"time_start\": \"" + settings.startTimeStepGeoMech() + "\"," << caf::endl;
|
|
stream << "\"time_end\": \"" + settings.endTimeStepGeoMech() + "\"," << caf::endl;
|
|
stream << "\"out_path\": \"" + settings.outputAbaqusDirectory() + "\"" << caf::endl;
|
|
stream << "}" << caf::endl;
|
|
|
|
file.close();
|
|
}
|
|
else
|
|
{
|
|
outErrorText += "Could not open file.";
|
|
return false;
|
|
}
|
|
|
|
outErrorText = "";
|
|
return true;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RifFaultRAJSonWriter::writeToPostprocFile( int faultID, RimFaultRAPostprocSettings* settings, QString& outErrorText )
|
|
{
|
|
QString filename = settings->postprocParameterFilename( faultID );
|
|
|
|
outErrorText = "Unable to write to file \"" + filename + "\" - ";
|
|
|
|
QFile file( filename );
|
|
if ( file.open( QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text ) )
|
|
{
|
|
QTextStream stream( &file );
|
|
|
|
stream << "{" << caf::endl;
|
|
|
|
if ( settings->geomechEnabled() )
|
|
{
|
|
if ( QFile::exists( settings->advancedMacrisDatabase() ) )
|
|
stream << "\"MacrisCalcCalibration_path\": \"" + settings->advancedMacrisDatabase() + "\"," << caf::endl;
|
|
}
|
|
|
|
if ( QFile::exists( settings->basicMacrisDatabase() ) )
|
|
stream << "\"MacrisCalc_path\": \"" + settings->basicMacrisDatabase() + "\"," << caf::endl;
|
|
|
|
stream << "\"base_directory_path\": \"" + settings->outputBaseDirectory() + "\"," << caf::endl;
|
|
|
|
for ( auto p : settings->parameters()->parameters() )
|
|
{
|
|
stream << "\"" + p->name() + "\" : " + p->stringValue() + "," << caf::endl;
|
|
}
|
|
|
|
stream << "\"tsurf_loadsteps\": [ " + settings->stepsToLoad().join( ',' ) + " ]" << caf::endl;
|
|
stream << "}" << caf::endl;
|
|
|
|
file.close();
|
|
}
|
|
else
|
|
{
|
|
outErrorText += "Could not open file.";
|
|
return false;
|
|
}
|
|
|
|
outErrorText = "";
|
|
return true;
|
|
}
|