|
|
|
|
@ -2,6 +2,8 @@
|
|
|
|
|
|
|
|
|
|
#include "nmAttrRegistry.h"
|
|
|
|
|
#include "nmPebiResultSnapshot.h"
|
|
|
|
|
#include "nmPebiResultSnapshotSerializer.h"
|
|
|
|
|
#include "nmNumericalSaveSession.h"
|
|
|
|
|
|
|
|
|
|
#include "nmDataAnalyzeContext.h"
|
|
|
|
|
#include "nmDataAnalyzeContextProvider.h"
|
|
|
|
|
@ -56,6 +58,7 @@
|
|
|
|
|
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <new>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include "singlePhaseSolver.h"
|
|
|
|
|
|
|
|
|
|
@ -504,6 +507,185 @@ void createDefaultLayer(double dThickness, QVector<nmDataLayer*>& vecLayers)
|
|
|
|
|
vecLayers.append(pDefaultLayer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rapidjson::Value numericalJsonString(
|
|
|
|
|
const QString& sValue,
|
|
|
|
|
rapidjson::Document::AllocatorType& oAllocator)
|
|
|
|
|
{
|
|
|
|
|
const QByteArray baValue = sValue.toUtf8();
|
|
|
|
|
return rapidjson::Value(baValue.constData(),
|
|
|
|
|
static_cast<rapidjson::SizeType>(baValue.size()), oAllocator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addNumericalFileReference(
|
|
|
|
|
rapidjson::Value& oParent,
|
|
|
|
|
const char* pName,
|
|
|
|
|
const nmNumericalFileReference& oReference,
|
|
|
|
|
rapidjson::Document::AllocatorType& oAllocator)
|
|
|
|
|
{
|
|
|
|
|
rapidjson::Value oJson(rapidjson::kObjectType);
|
|
|
|
|
oJson.AddMember("Path", numericalJsonString(
|
|
|
|
|
oReference.m_sRelativePath, oAllocator), oAllocator);
|
|
|
|
|
oJson.AddMember("Length", oReference.m_nLength, oAllocator);
|
|
|
|
|
oJson.AddMember("Sha1", numericalJsonString(
|
|
|
|
|
oReference.m_sSha1, oAllocator), oAllocator);
|
|
|
|
|
oParent.AddMember(rapidjson::Value(pName, oAllocator).Move(),
|
|
|
|
|
oJson, oAllocator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool readNumericalFileReference(
|
|
|
|
|
const rapidjson::Value& oParent,
|
|
|
|
|
const char* pName,
|
|
|
|
|
nmNumericalFileReference& oReference)
|
|
|
|
|
{
|
|
|
|
|
if(!oParent.IsObject() || !oParent.HasMember(pName) ||
|
|
|
|
|
!oParent[pName].IsObject())
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
const rapidjson::Value& oJson = oParent[pName];
|
|
|
|
|
if(!oJson.HasMember("Path") || !oJson["Path"].IsString() ||
|
|
|
|
|
!oJson.HasMember("Length") || !oJson["Length"].IsUint64() ||
|
|
|
|
|
!oJson.HasMember("Sha1") || !oJson["Sha1"].IsString())
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
oReference.m_sRelativePath = QString::fromUtf8(oJson["Path"].GetString());
|
|
|
|
|
oReference.m_nLength = oJson["Length"].GetUint64();
|
|
|
|
|
oReference.m_sSha1 = QString::fromLatin1(oJson["Sha1"].GetString());
|
|
|
|
|
return oReference.isValid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool readV3WindowHeader(
|
|
|
|
|
const QString& sMainJsonPath,
|
|
|
|
|
nmNumericalWindowPayloadReferences& oReferences,
|
|
|
|
|
QString& sCurrentResultWellInstanceId,
|
|
|
|
|
quint64& nGridInputRevision,
|
|
|
|
|
quint64& nBuiltGridRevision,
|
|
|
|
|
quint64& nResultInputRevision,
|
|
|
|
|
QString* pError)
|
|
|
|
|
{
|
|
|
|
|
const QFileInfo oInfo(sMainJsonPath);
|
|
|
|
|
if(!oInfo.isFile() || oInfo.size() <= 0 ||
|
|
|
|
|
oInfo.size() > 64ll * 1024ll * 1024ll)
|
|
|
|
|
{
|
|
|
|
|
if(pError != NULL) *pError = "Numerical v3 main JSON is missing or too large.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
rapidjson::Document oDocument;
|
|
|
|
|
if(!nmDataJsonTools::ReadDomFromFile(sMainJsonPath, oDocument) ||
|
|
|
|
|
!oDocument.IsObject() ||
|
|
|
|
|
!oDocument.HasMember("NumericalProjectVersion") ||
|
|
|
|
|
!oDocument["NumericalProjectVersion"].IsInt())
|
|
|
|
|
{
|
|
|
|
|
if(pError != NULL) *pError = "Numerical project version is missing.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
const int nVersion = oDocument["NumericalProjectVersion"].GetInt();
|
|
|
|
|
if(nVersion != nmNumericalResultPersistence::projectVersion())
|
|
|
|
|
{
|
|
|
|
|
if(pError != NULL)
|
|
|
|
|
{
|
|
|
|
|
*pError = nVersion == 2
|
|
|
|
|
? "Numerical project version 2 is not supported."
|
|
|
|
|
: "Numerical project version is not supported.";
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(!oDocument.HasMember("InputRevisions") ||
|
|
|
|
|
!oDocument["InputRevisions"].IsObject() ||
|
|
|
|
|
!oDocument.HasMember("CurrentResultWellInstanceId") ||
|
|
|
|
|
!oDocument["CurrentResultWellInstanceId"].IsString() ||
|
|
|
|
|
!oDocument.HasMember("PayloadFiles") ||
|
|
|
|
|
!oDocument["PayloadFiles"].IsObject())
|
|
|
|
|
{
|
|
|
|
|
if(pError != NULL) *pError = "Numerical v3 main JSON header is incomplete.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
const rapidjson::Value& oRevisions = oDocument["InputRevisions"];
|
|
|
|
|
if(!oRevisions.HasMember("GridInputRevision") ||
|
|
|
|
|
!oRevisions["GridInputRevision"].IsUint64() ||
|
|
|
|
|
!oRevisions.HasMember("BuiltGridRevision") ||
|
|
|
|
|
!oRevisions["BuiltGridRevision"].IsUint64() ||
|
|
|
|
|
!oRevisions.HasMember("ResultInputRevision") ||
|
|
|
|
|
!oRevisions["ResultInputRevision"].IsUint64())
|
|
|
|
|
{
|
|
|
|
|
if(pError != NULL) *pError = "Numerical input revisions are invalid.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
nGridInputRevision = oRevisions["GridInputRevision"].GetUint64();
|
|
|
|
|
nBuiltGridRevision = oRevisions["BuiltGridRevision"].GetUint64();
|
|
|
|
|
nResultInputRevision = oRevisions["ResultInputRevision"].GetUint64();
|
|
|
|
|
if(nGridInputRevision == 0 || nResultInputRevision == 0 ||
|
|
|
|
|
(nBuiltGridRevision != 0 && nBuiltGridRevision != nGridInputRevision))
|
|
|
|
|
{
|
|
|
|
|
if(pError != NULL) *pError = "Numerical input revision values are invalid.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
sCurrentResultWellInstanceId = QString::fromUtf8(
|
|
|
|
|
oDocument["CurrentResultWellInstanceId"].GetString());
|
|
|
|
|
|
|
|
|
|
const rapidjson::Value& oPayload = oDocument["PayloadFiles"];
|
|
|
|
|
if(!oPayload.HasMember("CurrentGrid") ||
|
|
|
|
|
!oPayload.HasMember("WellHistories") ||
|
|
|
|
|
!oPayload["WellHistories"].IsArray() ||
|
|
|
|
|
oPayload["WellHistories"].Size() > 10000u ||
|
|
|
|
|
!oPayload.HasMember("Snapshot"))
|
|
|
|
|
{
|
|
|
|
|
if(pError != NULL) *pError = "Numerical payload reference list is invalid.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
QSet<QString> setPaths;
|
|
|
|
|
oReferences = nmNumericalWindowPayloadReferences();
|
|
|
|
|
if(!oPayload["CurrentGrid"].IsNull())
|
|
|
|
|
{
|
|
|
|
|
if(!readNumericalFileReference(oPayload, "CurrentGrid",
|
|
|
|
|
oReferences.m_oCurrentGrid))
|
|
|
|
|
{
|
|
|
|
|
if(pError != NULL) *pError = "Current grid reference is invalid.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
oReferences.m_bHasCurrentGrid = true;
|
|
|
|
|
setPaths.insert(oReferences.m_oCurrentGrid.m_sRelativePath);
|
|
|
|
|
}
|
|
|
|
|
const rapidjson::Value& oHistories = oPayload["WellHistories"];
|
|
|
|
|
for(rapidjson::SizeType nIndex = 0; nIndex < oHistories.Size(); ++nIndex)
|
|
|
|
|
{
|
|
|
|
|
const rapidjson::Value& oJson = oHistories[nIndex];
|
|
|
|
|
nmNumericalFileReference oReference;
|
|
|
|
|
if(!oJson.IsObject() ||
|
|
|
|
|
!oJson.HasMember("WellInstanceId") ||
|
|
|
|
|
!oJson["WellInstanceId"].IsString() ||
|
|
|
|
|
!readNumericalFileReference(oJson, "File", oReference))
|
|
|
|
|
{
|
|
|
|
|
if(pError != NULL) *pError = "Well history reference is invalid.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
const QString sWellInstanceId = QString::fromUtf8(
|
|
|
|
|
oJson["WellInstanceId"].GetString());
|
|
|
|
|
if(sWellInstanceId.isEmpty() ||
|
|
|
|
|
oReferences.m_mapWellHistories.contains(sWellInstanceId) ||
|
|
|
|
|
setPaths.contains(oReference.m_sRelativePath))
|
|
|
|
|
{
|
|
|
|
|
if(pError != NULL) *pError = "Well history references are duplicated.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
oReferences.m_mapWellHistories.insert(sWellInstanceId, oReference);
|
|
|
|
|
setPaths.insert(oReference.m_sRelativePath);
|
|
|
|
|
}
|
|
|
|
|
if(!oPayload["Snapshot"].IsNull())
|
|
|
|
|
{
|
|
|
|
|
if(!readNumericalFileReference(oPayload, "Snapshot",
|
|
|
|
|
oReferences.m_oSnapshot) ||
|
|
|
|
|
setPaths.contains(oReferences.m_oSnapshot.m_sRelativePath))
|
|
|
|
|
{
|
|
|
|
|
if(pError != NULL) *pError = "Snapshot reference is invalid or duplicated.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
oReferences.m_bHasSnapshot = true;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ZX_DEFINE_DYNAMIC(DataAnalyzeManager, nmDataAnalyzeManager)
|
|
|
|
|
@ -4456,7 +4638,7 @@ bool nmDataAnalyzeManager::ReadProjectData(const QString & filePath)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 新数据模型不兼容旧项目。明确校验版本,避免按井名或对象顺序猜测关联关系。
|
|
|
|
|
const int nSupportedProjectVersion = 2;
|
|
|
|
|
const int nSupportedProjectVersion = 3;
|
|
|
|
|
if(!doc.HasMember("NumericalProjectVersion") ||
|
|
|
|
|
!doc["NumericalProjectVersion"].IsInt() ||
|
|
|
|
|
doc["NumericalProjectVersion"].GetInt() != nSupportedProjectVersion) {
|
|
|
|
|
@ -4464,6 +4646,39 @@ bool nmDataAnalyzeManager::ReadProjectData(const QString & filePath)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
quint64 nSavedGridInputRevision = 0;
|
|
|
|
|
quint64 nSavedBuiltGridRevision = 0;
|
|
|
|
|
quint64 nSavedResultInputRevision = 0;
|
|
|
|
|
if(!doc.HasMember("InputRevisions") ||
|
|
|
|
|
!doc["InputRevisions"].IsObject()) {
|
|
|
|
|
qWarning() << "Numerical v3 project has no input revisions:" << filePath;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
const rapidjson::Value& oRevisionJson = doc["InputRevisions"];
|
|
|
|
|
if(!oRevisionJson.HasMember("GridInputRevision") ||
|
|
|
|
|
!oRevisionJson["GridInputRevision"].IsUint64() ||
|
|
|
|
|
!oRevisionJson.HasMember("BuiltGridRevision") ||
|
|
|
|
|
!oRevisionJson["BuiltGridRevision"].IsUint64() ||
|
|
|
|
|
!oRevisionJson.HasMember("ResultInputRevision") ||
|
|
|
|
|
!oRevisionJson["ResultInputRevision"].IsUint64()) {
|
|
|
|
|
qWarning() << "Numerical v3 project contains invalid input revisions:"
|
|
|
|
|
<< filePath;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
nSavedGridInputRevision =
|
|
|
|
|
oRevisionJson["GridInputRevision"].GetUint64();
|
|
|
|
|
nSavedBuiltGridRevision =
|
|
|
|
|
oRevisionJson["BuiltGridRevision"].GetUint64();
|
|
|
|
|
nSavedResultInputRevision =
|
|
|
|
|
oRevisionJson["ResultInputRevision"].GetUint64();
|
|
|
|
|
if(nSavedGridInputRevision == 0 || nSavedResultInputRevision == 0 ||
|
|
|
|
|
(nSavedBuiltGridRevision != 0 &&
|
|
|
|
|
nSavedBuiltGridRevision != nSavedGridInputRevision)) {
|
|
|
|
|
qWarning() << "Numerical v3 project input revision values are invalid:"
|
|
|
|
|
<< filePath;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString sSavedPrimaryWellCode;
|
|
|
|
|
QString sSavedCurrentResultWellCode;
|
|
|
|
|
NM_CASE_WELL_MODE eSavedPrimaryWellMode = NM_CaseWell_Observation;
|
|
|
|
|
@ -4819,9 +5034,8 @@ bool nmDataAnalyzeManager::ReadProjectData(const QString & filePath)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 前置校验已完成,从这里开始替换当前项目;旧项目快照不能跨项目残留。
|
|
|
|
|
clearPebiResultSnapshot();
|
|
|
|
|
|
|
|
|
|
// 前置校验已完成,从这里开始替换当前输入。旧快照要到全部 v3 载荷
|
|
|
|
|
// 成功后才替换,加载失败或内存不足时仍保留上一套已发布快照。
|
|
|
|
|
// 清空现有数据,确保从头加载新数据
|
|
|
|
|
foreach(nmDataFracture* pFractureData, m_vFractureData) {
|
|
|
|
|
delete pFractureData; // 释放堆上分配的 nmDataFracture 对象
|
|
|
|
|
@ -5238,13 +5452,27 @@ bool nmDataAnalyzeManager::ReadProjectData(const QString & filePath)
|
|
|
|
|
if(doc.HasMember("PebiIluReuseSteps") && doc["PebiIluReuseSteps"].IsInt()) {
|
|
|
|
|
setPebiIluReuseSteps(doc["PebiIluReuseSteps"].GetInt());
|
|
|
|
|
}
|
|
|
|
|
if(!m_oNumericalAnalysisCase.restoreInputRevisions(
|
|
|
|
|
nSavedGridInputRevision,
|
|
|
|
|
nSavedBuiltGridRevision,
|
|
|
|
|
nSavedResultInputRevision)) {
|
|
|
|
|
qWarning() << "Failed to restore numerical v3 input revisions:"
|
|
|
|
|
<< filePath;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 将 C++ 对象数据写入 JSON 文件
|
|
|
|
|
bool nmDataAnalyzeManager::WriteProjectData(const QString & filePath)
|
|
|
|
|
bool nmDataAnalyzeManager::WriteProjectData(
|
|
|
|
|
const QString & filePath,
|
|
|
|
|
const nmNumericalWindowPayloadReferences* pPayloadReferences)
|
|
|
|
|
{
|
|
|
|
|
if(pPayloadReferences == NULL) {
|
|
|
|
|
qWarning() << "Numerical v3 project requires explicit payload references.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// 第一步:保存前校验 Map 井目录,持久化身份只允许非空且唯一的 WellCode。
|
|
|
|
|
QSet<QString> setWellCodes;
|
|
|
|
|
QMap<QString, NM_WELL_MODEL> mapWellTypes;
|
|
|
|
|
@ -5260,7 +5488,9 @@ bool nmDataAnalyzeManager::WriteProjectData(const QString & filePath)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString sPrimaryWellCode = getPrimaryWellCode();
|
|
|
|
|
const QString sCurrentResultWellCode = getCurrentResultWellCode();
|
|
|
|
|
const QString sCurrentResultWellCode =
|
|
|
|
|
setWellCodes.contains(getCurrentResultWellCode())
|
|
|
|
|
? getCurrentResultWellCode() : sPrimaryWellCode;
|
|
|
|
|
if(!setWellCodes.contains(sPrimaryWellCode) ||
|
|
|
|
|
!setWellCodes.contains(sCurrentResultWellCode) ||
|
|
|
|
|
!qIsFinite(getPebiGridControl()) ||
|
|
|
|
|
@ -5321,7 +5551,8 @@ bool nmDataAnalyzeManager::WriteProjectData(const QString & filePath)
|
|
|
|
|
|
|
|
|
|
// 最后结果使用独立井顺序,不要求继续属于当前有效计算井,也不要求井型
|
|
|
|
|
// 仍与当前模型一致;但对应 WellCode 必须仍存在,才能保存单井曲线数据。
|
|
|
|
|
const bool bHasResults = m_oNumericalAnalysisCase.hasResults();
|
|
|
|
|
// v3 的最后结果只由独立快照表达,旧 AnalysisCase 结果字段写成空适配值。
|
|
|
|
|
const bool bHasResults = false;
|
|
|
|
|
QVector<nmSolverWellRef> vecValidatedResultOrder;
|
|
|
|
|
if(bHasResults) {
|
|
|
|
|
vecValidatedResultOrder =
|
|
|
|
|
@ -5395,8 +5626,17 @@ bool nmDataAnalyzeManager::WriteProjectData(const QString & filePath)
|
|
|
|
|
doc.SetObject(); // 根节点是对象
|
|
|
|
|
rapidjson::Document::AllocatorType& allocator = doc.GetAllocator(); // 获取内存分配器
|
|
|
|
|
|
|
|
|
|
// 新的数据模型从版本2开始只使用 WellCode 建立跨模块关联。
|
|
|
|
|
doc.AddMember("NumericalProjectVersion", 2, allocator);
|
|
|
|
|
doc.AddMember("NumericalProjectVersion", 3, allocator);
|
|
|
|
|
rapidjson::Value oRevisionJson(rapidjson::kObjectType);
|
|
|
|
|
oRevisionJson.AddMember("GridInputRevision",
|
|
|
|
|
m_oNumericalAnalysisCase.getGridInputRevision(), allocator);
|
|
|
|
|
oRevisionJson.AddMember("BuiltGridRevision",
|
|
|
|
|
m_oNumericalAnalysisCase.getBuiltGridRevision(), allocator);
|
|
|
|
|
oRevisionJson.AddMember("ResultInputRevision",
|
|
|
|
|
m_oNumericalAnalysisCase.getResultInputRevision(), allocator);
|
|
|
|
|
doc.AddMember("InputRevisions", oRevisionJson, allocator);
|
|
|
|
|
doc.AddMember("CurrentResultWellInstanceId", numericalJsonString(
|
|
|
|
|
m_sCurrentResultWellInstanceId, allocator), allocator);
|
|
|
|
|
|
|
|
|
|
// 构建 "Fractures" 数组的 JSON Value
|
|
|
|
|
rapidjson::Value fracturesJsonArray(rapidjson::kArrayType);
|
|
|
|
|
@ -5648,9 +5888,9 @@ bool nmDataAnalyzeManager::WriteProjectData(const QString & filePath)
|
|
|
|
|
vecSolverOrderJson.PushBack(oOrderJson, allocator);
|
|
|
|
|
}
|
|
|
|
|
oCaseJson.AddMember("SolverWellOrder", vecSolverOrderJson, allocator);
|
|
|
|
|
oCaseJson.AddMember("ResultsAvailable", bHasResults, allocator);
|
|
|
|
|
oCaseJson.AddMember("ResultsCurrent",
|
|
|
|
|
m_oNumericalAnalysisCase.areResultsCurrent(), allocator);
|
|
|
|
|
// v3 的结果状态只由独立快照及输入版本判断,旧字段必须保持一致的空状态。
|
|
|
|
|
oCaseJson.AddMember("ResultsAvailable", false, allocator);
|
|
|
|
|
oCaseJson.AddMember("ResultsCurrent", false, allocator);
|
|
|
|
|
|
|
|
|
|
rapidjson::Value vecResultOrderJson(rapidjson::kArrayType);
|
|
|
|
|
for(int nIndex = 0;
|
|
|
|
|
@ -5699,6 +5939,37 @@ bool nmDataAnalyzeManager::WriteProjectData(const QString & filePath)
|
|
|
|
|
doc.AddMember("PebiOmpThreads", m_nPebiOmpThreads, allocator);
|
|
|
|
|
doc.AddMember("PebiIluReuseSteps", m_nPebiIluReuseSteps, allocator);
|
|
|
|
|
|
|
|
|
|
// 主 JSON 只保存引用,不通过目录扫描推断网格、历史或快照载荷。
|
|
|
|
|
rapidjson::Value oPayloadJson(rapidjson::kObjectType);
|
|
|
|
|
if(pPayloadReferences->m_bHasCurrentGrid) {
|
|
|
|
|
addNumericalFileReference(oPayloadJson, "CurrentGrid",
|
|
|
|
|
pPayloadReferences->m_oCurrentGrid, allocator);
|
|
|
|
|
} else {
|
|
|
|
|
oPayloadJson.AddMember("CurrentGrid",
|
|
|
|
|
rapidjson::Value(rapidjson::kNullType).Move(), allocator);
|
|
|
|
|
}
|
|
|
|
|
rapidjson::Value oHistoryJson(rapidjson::kArrayType);
|
|
|
|
|
QMap<QString, nmNumericalFileReference>::const_iterator oHistoryIt =
|
|
|
|
|
pPayloadReferences->m_mapWellHistories.constBegin();
|
|
|
|
|
for(; oHistoryIt != pPayloadReferences->m_mapWellHistories.constEnd();
|
|
|
|
|
++oHistoryIt) {
|
|
|
|
|
rapidjson::Value oWellJson(rapidjson::kObjectType);
|
|
|
|
|
oWellJson.AddMember("WellInstanceId", numericalJsonString(
|
|
|
|
|
oHistoryIt.key(), allocator), allocator);
|
|
|
|
|
addNumericalFileReference(oWellJson, "File",
|
|
|
|
|
oHistoryIt.value(), allocator);
|
|
|
|
|
oHistoryJson.PushBack(oWellJson, allocator);
|
|
|
|
|
}
|
|
|
|
|
oPayloadJson.AddMember("WellHistories", oHistoryJson, allocator);
|
|
|
|
|
if(pPayloadReferences->m_bHasSnapshot) {
|
|
|
|
|
addNumericalFileReference(oPayloadJson, "Snapshot",
|
|
|
|
|
pPayloadReferences->m_oSnapshot, allocator);
|
|
|
|
|
} else {
|
|
|
|
|
oPayloadJson.AddMember("Snapshot",
|
|
|
|
|
rapidjson::Value(rapidjson::kNullType).Move(), allocator);
|
|
|
|
|
}
|
|
|
|
|
doc.AddMember("PayloadFiles", oPayloadJson, allocator);
|
|
|
|
|
|
|
|
|
|
// 将最终构建好的 Document 写入文件
|
|
|
|
|
if(!nmDataJsonTools::WriteDomToFile(doc, filePath)) {
|
|
|
|
|
qDebug() << "Error: Failed to write DOM to file:" << filePath;
|
|
|
|
|
@ -5708,6 +5979,181 @@ bool nmDataAnalyzeManager::WriteProjectData(const QString & filePath)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmDataAnalyzeManager::saveNmResultV3(
|
|
|
|
|
const QString& sWindowDirectory,
|
|
|
|
|
nmNumericalFileReference& oMainJsonReference,
|
|
|
|
|
QString* pError)
|
|
|
|
|
{
|
|
|
|
|
if(pError != NULL) {
|
|
|
|
|
pError->clear();
|
|
|
|
|
}
|
|
|
|
|
oMainJsonReference = nmNumericalFileReference();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if(sWindowDirectory.isEmpty() ||
|
|
|
|
|
!ensureDirectoryExists(sWindowDirectory)) {
|
|
|
|
|
if(pError != NULL) *pError = "Cannot create numerical v3 window directory.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmNumericalWindowPayloadReferences oReferences;
|
|
|
|
|
if(isPebiGridValid()) {
|
|
|
|
|
if(m_pVtkUnstructuredGrid == NULL ||
|
|
|
|
|
!ensureDirectoryExists(QDir(sWindowDirectory).filePath("Grid"))) {
|
|
|
|
|
if(pError != NULL) *pError = "Current PEBI grid is unavailable.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
const QString sCurrentGridPath = QDir(sWindowDirectory).filePath(
|
|
|
|
|
"Grid/CurrentGrid.vtu");
|
|
|
|
|
if(!nmNumericalResultPersistence::writeGrid(
|
|
|
|
|
m_pVtkUnstructuredGrid, sCurrentGridPath, pError) ||
|
|
|
|
|
!nmNumericalResultPersistence::buildFileReference(
|
|
|
|
|
sCurrentGridPath, "Grid/CurrentGrid.vtu",
|
|
|
|
|
oReferences.m_oCurrentGrid)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
oReferences.m_bHasCurrentGrid = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString sHistoryDirectory = QDir(sWindowDirectory).filePath(
|
|
|
|
|
"WellHistory");
|
|
|
|
|
if(!ensureDirectoryExists(sHistoryDirectory)) {
|
|
|
|
|
if(pError != NULL) *pError = "Cannot create v3 well history directory.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
QSet<QString> setWellInstanceIds;
|
|
|
|
|
for(int nIndex = 0; nIndex < m_vWellData.size(); ++nIndex) {
|
|
|
|
|
nmDataWellBase* pWell = m_vWellData[nIndex];
|
|
|
|
|
if(pWell == NULL || pWell->getWellInstanceId().isEmpty() ||
|
|
|
|
|
setWellInstanceIds.contains(pWell->getWellInstanceId())) {
|
|
|
|
|
if(pError != NULL) *pError = "Live well UUID directory is invalid.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
setWellInstanceIds.insert(pWell->getWellInstanceId());
|
|
|
|
|
nmNumericalWellHistoryData oHistory;
|
|
|
|
|
oHistory.m_vecPressure = pWell->getHistoryPressure();
|
|
|
|
|
oHistory.m_vecLogLog = pWell->getHistoryLogLog();
|
|
|
|
|
oHistory.m_vecSemiLog = pWell->getHistorySemiLog();
|
|
|
|
|
const QString sRelativePath = QString("WellHistory/%1.bin")
|
|
|
|
|
.arg(pWell->getWellInstanceId());
|
|
|
|
|
const QString sHistoryPath = QDir(sWindowDirectory).filePath(
|
|
|
|
|
sRelativePath);
|
|
|
|
|
nmNumericalFileReference oReference;
|
|
|
|
|
if(!nmNumericalResultPersistence::writeWellHistory(
|
|
|
|
|
sHistoryPath, oHistory, pError) ||
|
|
|
|
|
!nmNumericalResultPersistence::buildFileReference(
|
|
|
|
|
sHistoryPath, sRelativePath, oReference)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
oReferences.m_mapWellHistories.insert(
|
|
|
|
|
pWell->getWellInstanceId(), oReference);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!m_pPebiResultSnapshot.isNull()) {
|
|
|
|
|
if(!nmPebiResultSnapshotSerializer::save(
|
|
|
|
|
m_pPebiResultSnapshot, sWindowDirectory,
|
|
|
|
|
oReferences.m_oSnapshot, pError)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
oReferences.m_bHasSnapshot = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 所有外部载荷成功后才写主 JSON,使引用链不会指向半成品文件。
|
|
|
|
|
const QString sMainJsonPath = QDir(sWindowDirectory).filePath(
|
|
|
|
|
"Numerical_Parameters.json");
|
|
|
|
|
if(!WriteProjectData(sMainJsonPath, &oReferences) ||
|
|
|
|
|
!nmNumericalResultPersistence::buildFileReference(
|
|
|
|
|
sMainJsonPath, "Numerical_Parameters.json",
|
|
|
|
|
oMainJsonReference)) {
|
|
|
|
|
if(pError != NULL && pError->isEmpty())
|
|
|
|
|
*pError = "Cannot write numerical v3 main JSON.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 返回保存会话前沿主 JSON 的明确引用完整复核本窗口载荷。
|
|
|
|
|
return validateNmResultV3Window(
|
|
|
|
|
sWindowDirectory, sMainJsonPath, pError);
|
|
|
|
|
}
|
|
|
|
|
catch(const std::bad_alloc&) {
|
|
|
|
|
if(pError != NULL) *pError = "Not enough memory to save numerical v3 result.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmDataAnalyzeManager::validateNmResultV3Window(
|
|
|
|
|
const QString& sWindowDirectory,
|
|
|
|
|
const QString& sMainJsonPath,
|
|
|
|
|
QString* pError)
|
|
|
|
|
{
|
|
|
|
|
if(pError != NULL) {
|
|
|
|
|
pError->clear();
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
const QString sExpectedDirectory = QDir::cleanPath(
|
|
|
|
|
QFileInfo(sWindowDirectory).absoluteFilePath());
|
|
|
|
|
const QFileInfo oMainInfo(sMainJsonPath);
|
|
|
|
|
if(!oMainInfo.isFile() ||
|
|
|
|
|
QDir::cleanPath(oMainInfo.absolutePath()).compare(
|
|
|
|
|
sExpectedDirectory, Qt::CaseInsensitive) != 0) {
|
|
|
|
|
if(pError != NULL)
|
|
|
|
|
*pError = "Numerical v3 main JSON leaves its window directory.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmNumericalWindowPayloadReferences oReferences;
|
|
|
|
|
QString sCurrentResultWellInstanceId;
|
|
|
|
|
quint64 nGridInputRevision = 0;
|
|
|
|
|
quint64 nBuiltGridRevision = 0;
|
|
|
|
|
quint64 nResultInputRevision = 0;
|
|
|
|
|
if(!readV3WindowHeader(sMainJsonPath, oReferences,
|
|
|
|
|
sCurrentResultWellInstanceId, nGridInputRevision,
|
|
|
|
|
nBuiltGridRevision, nResultInputRevision, pError)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
Q_UNUSED(nGridInputRevision);
|
|
|
|
|
Q_UNUSED(nBuiltGridRevision);
|
|
|
|
|
Q_UNUSED(nResultInputRevision);
|
|
|
|
|
if(!oReferences.m_bHasSnapshot &&
|
|
|
|
|
!sCurrentResultWellInstanceId.isEmpty()) {
|
|
|
|
|
if(pError != NULL)
|
|
|
|
|
*pError = "Numerical v3 result well is selected without a snapshot.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(oReferences.m_bHasCurrentGrid &&
|
|
|
|
|
!nmNumericalResultPersistence::validateFileReference(
|
|
|
|
|
sWindowDirectory, oReferences.m_oCurrentGrid,
|
|
|
|
|
NULL, pError)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QMap<QString, nmNumericalFileReference>::const_iterator oIt =
|
|
|
|
|
oReferences.m_mapWellHistories.constBegin();
|
|
|
|
|
for(; oIt != oReferences.m_mapWellHistories.constEnd(); ++oIt) {
|
|
|
|
|
QString sHistoryPath;
|
|
|
|
|
nmNumericalWellHistoryData oValidatedHistory;
|
|
|
|
|
if(!nmNumericalResultPersistence::validateFileReference(
|
|
|
|
|
sWindowDirectory, oIt.value(), &sHistoryPath, pError) ||
|
|
|
|
|
!nmNumericalResultPersistence::readWellHistory(
|
|
|
|
|
sHistoryPath, oValidatedHistory, pError)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(oReferences.m_bHasSnapshot &&
|
|
|
|
|
!nmPebiResultSnapshotSerializer::validate(
|
|
|
|
|
sWindowDirectory, oReferences.m_oSnapshot, pError)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch(const std::bad_alloc&) {
|
|
|
|
|
if(pError != NULL)
|
|
|
|
|
*pError = "Not enough memory to validate numerical v3 result.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmDataAnalyzeManager::saveNmResult(QString sRstCode, iSubWndFitting* pSubWndF, bool bClearRoot)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(nullptr != pSubWndF);
|
|
|
|
|
@ -5719,6 +6165,23 @@ bool nmDataAnalyzeManager::saveNmResult(QString sRstCode, iSubWndFitting* pSubWn
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_UNUSED(bClearRoot);
|
|
|
|
|
// 旧入口按单窗口兼容会话执行;显式跨窗口会话由 nmSubWndUtils 统一持有。
|
|
|
|
|
nmNumericalSaveSession oCompatibilitySession;
|
|
|
|
|
const QFileInfo oLogicalWindowInfo(QDir::cleanPath(sDir));
|
|
|
|
|
QString sError;
|
|
|
|
|
if(!oCompatibilitySession.begin(
|
|
|
|
|
oLogicalWindowInfo.dir().absolutePath(), sRstCode,
|
|
|
|
|
true, &sError) ||
|
|
|
|
|
!oCompatibilitySession.saveWindowGeneration(
|
|
|
|
|
oLogicalWindowInfo.fileName(), this, &sError) ||
|
|
|
|
|
!oCompatibilitySession.commit(&sError)) {
|
|
|
|
|
qWarning() << sError;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
// bClearRoot为true时清空整个成果目录,清理已删除窗口的残留数据。
|
|
|
|
|
// 仅在遍历保存的第一个窗口传入true,后续窗口传false避免误删其他窗口数据。
|
|
|
|
|
if(bClearRoot) {
|
|
|
|
|
@ -5852,10 +6315,195 @@ bool nmDataAnalyzeManager::saveNmResult(QString sRstCode, iSubWndFitting* pSubWn
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmDataAnalyzeManager::loadNmResult(QString sLoadAnalDir)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
// 外部框架仍传入旧的“成果根/窗口标识”逻辑路径;v3 只从根清单解析真实代次。
|
|
|
|
|
const QFileInfo oLogicalWindowInfo(QDir::cleanPath(sLoadAnalDir));
|
|
|
|
|
const QString sWindowId = oLogicalWindowInfo.fileName();
|
|
|
|
|
const QString sResultRootDirectory = oLogicalWindowInfo.dir().absolutePath();
|
|
|
|
|
const QString sManifestPath = QDir(sResultRootDirectory).filePath(
|
|
|
|
|
"NumericalSaveManifest.json");
|
|
|
|
|
if(!QFileInfo(sManifestPath).isFile()) {
|
|
|
|
|
const QString sLegacyJsonPath = QDir(sLoadAnalDir).filePath(
|
|
|
|
|
"Results/Numerical_Parameters.json");
|
|
|
|
|
if(QFileInfo(sLegacyJsonPath).isFile()) {
|
|
|
|
|
qWarning() << "Numerical project version 2 is not supported:"
|
|
|
|
|
<< sLegacyJsonPath;
|
|
|
|
|
} else {
|
|
|
|
|
qWarning() << "Numerical v3 root manifest is missing:"
|
|
|
|
|
<< sManifestPath;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString sWindowDirectory;
|
|
|
|
|
QString sMainJsonPath;
|
|
|
|
|
QString sError;
|
|
|
|
|
if(!nmNumericalSaveSession::resolveWindowMainJson(
|
|
|
|
|
sResultRootDirectory, sWindowId, sWindowDirectory,
|
|
|
|
|
sMainJsonPath, NULL, &sError)) {
|
|
|
|
|
qWarning() << sError;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmNumericalWindowPayloadReferences oReferences;
|
|
|
|
|
QString sSavedResultWellInstanceId;
|
|
|
|
|
quint64 nGridInputRevision = 0;
|
|
|
|
|
quint64 nBuiltGridRevision = 0;
|
|
|
|
|
quint64 nResultInputRevision = 0;
|
|
|
|
|
if(!readV3WindowHeader(sMainJsonPath, oReferences,
|
|
|
|
|
sSavedResultWellInstanceId, nGridInputRevision,
|
|
|
|
|
nBuiltGridRevision, nResultInputRevision, &sError)) {
|
|
|
|
|
qWarning() << sError << sMainJsonPath;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 所有引用文件先完成哈希和结构读取,任何失败都不能替换已发布快照。
|
|
|
|
|
vtkSmartPointer<vtkUnstructuredGrid> pLoadedCurrentGrid;
|
|
|
|
|
if(oReferences.m_bHasCurrentGrid) {
|
|
|
|
|
QString sCurrentGridPath;
|
|
|
|
|
if(!nmNumericalResultPersistence::validateFileReference(
|
|
|
|
|
sWindowDirectory, oReferences.m_oCurrentGrid,
|
|
|
|
|
&sCurrentGridPath, &sError) ||
|
|
|
|
|
!nmNumericalResultPersistence::readGrid(
|
|
|
|
|
sCurrentGridPath, pLoadedCurrentGrid, &sError)) {
|
|
|
|
|
qWarning() << sError;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QMap<QString, nmNumericalWellHistoryData> mapLoadedHistories;
|
|
|
|
|
QMap<QString, nmNumericalFileReference>::const_iterator oHistoryIt =
|
|
|
|
|
oReferences.m_mapWellHistories.constBegin();
|
|
|
|
|
for(; oHistoryIt != oReferences.m_mapWellHistories.constEnd();
|
|
|
|
|
++oHistoryIt) {
|
|
|
|
|
QString sHistoryPath;
|
|
|
|
|
nmNumericalWellHistoryData oHistory;
|
|
|
|
|
if(!nmNumericalResultPersistence::validateFileReference(
|
|
|
|
|
sWindowDirectory, oHistoryIt.value(),
|
|
|
|
|
&sHistoryPath, &sError) ||
|
|
|
|
|
!nmNumericalResultPersistence::readWellHistory(
|
|
|
|
|
sHistoryPath, oHistory, &sError)) {
|
|
|
|
|
qWarning() << sError;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
mapLoadedHistories.insert(oHistoryIt.key(), oHistory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QSharedPointer<nmPebiResultSnapshot> pLoadedCandidate;
|
|
|
|
|
if(oReferences.m_bHasSnapshot &&
|
|
|
|
|
!nmPebiResultSnapshotSerializer::load(
|
|
|
|
|
sWindowDirectory, oReferences.m_oSnapshot,
|
|
|
|
|
pLoadedCandidate, &sError)) {
|
|
|
|
|
qWarning() << sError;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 主 JSON 在外部载荷全部可用后才恢复当前输入;v2 会在版本检查处直接拒绝。
|
|
|
|
|
if(!ReadProjectData(sMainJsonPath)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(m_oNumericalAnalysisCase.getGridInputRevision() !=
|
|
|
|
|
nGridInputRevision ||
|
|
|
|
|
m_oNumericalAnalysisCase.getBuiltGridRevision() !=
|
|
|
|
|
nBuiltGridRevision ||
|
|
|
|
|
m_oNumericalAnalysisCase.getResultInputRevision() !=
|
|
|
|
|
nResultInputRevision ||
|
|
|
|
|
oReferences.m_bHasCurrentGrid !=
|
|
|
|
|
m_oNumericalAnalysisCase.isGridValid()) {
|
|
|
|
|
qWarning() << "Loaded numerical input revisions and current grid are inconsistent.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 实时井历史按 UUID 一一匹配;井名、井编码和数组顺序都不能替代身份。
|
|
|
|
|
if(mapLoadedHistories.size() != m_vWellData.size()) {
|
|
|
|
|
qWarning() << "Loaded numerical well history directory is incomplete.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
for(int nIndex = 0; nIndex < m_vWellData.size(); ++nIndex) {
|
|
|
|
|
nmDataWellBase* pWell = m_vWellData[nIndex];
|
|
|
|
|
if(pWell == NULL ||
|
|
|
|
|
!mapLoadedHistories.contains(pWell->getWellInstanceId())) {
|
|
|
|
|
qWarning() << "Loaded numerical well UUID has no history payload.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
const nmNumericalWellHistoryData oHistory =
|
|
|
|
|
mapLoadedHistories.take(pWell->getWellInstanceId());
|
|
|
|
|
pWell->setHistoryPressure(oHistory.m_vecPressure);
|
|
|
|
|
pWell->setHistoryLogLog(oHistory.m_vecLogLog);
|
|
|
|
|
pWell->setHistorySemiLog(oHistory.m_vecSemiLog);
|
|
|
|
|
}
|
|
|
|
|
if(!mapLoadedHistories.isEmpty()) {
|
|
|
|
|
qWarning() << "Numerical v3 project contains unreferenced well histories.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadWellPreAndFlow();
|
|
|
|
|
const QVector<nmCalculationWellRef> vecIncludedWells =
|
|
|
|
|
getIncludedCalculationWells();
|
|
|
|
|
for(int nIndex = 0; nIndex < vecIncludedWells.size(); ++nIndex) {
|
|
|
|
|
nmDataWellBase* pWell = findWellByCode(
|
|
|
|
|
vecIncludedWells[nIndex].m_sWellCode);
|
|
|
|
|
if(!isSupportedNumericalWell(pWell) ||
|
|
|
|
|
pWell->getFlowPoints().size() < 2) {
|
|
|
|
|
qWarning() << "Failed to restore included numerical well:"
|
|
|
|
|
<< vecIncludedWells[nIndex].m_sWellCode;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!pLoadedCandidate.isNull() &&
|
|
|
|
|
!sSavedResultWellInstanceId.isEmpty() &&
|
|
|
|
|
!pLoadedCandidate->isDisplayWell(sSavedResultWellInstanceId)) {
|
|
|
|
|
qWarning() << "Saved result well UUID is absent from the PEBI snapshot.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(pLoadedCandidate.isNull() &&
|
|
|
|
|
!sSavedResultWellInstanceId.isEmpty()) {
|
|
|
|
|
qWarning() << "Numerical project selects a result well without a snapshot.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 所有可能失败的读取和映射已完成,再一次替换当前网格与规范快照。
|
|
|
|
|
m_pVtkUnstructuredGrid = pLoadedCurrentGrid;
|
|
|
|
|
m_mapTimeStepDataP.clear();
|
|
|
|
|
m_mapWellLocations.clear();
|
|
|
|
|
m_pResultBaseGrid = NULL;
|
|
|
|
|
m_dScalarRangeP[0] = DBL_MAX;
|
|
|
|
|
m_dScalarRangeP[1] = -DBL_MAX;
|
|
|
|
|
|
|
|
|
|
if(pLoadedCandidate.isNull()) {
|
|
|
|
|
clearPebiResultSnapshot();
|
|
|
|
|
} else {
|
|
|
|
|
QSharedPointer<const nmPebiResultSnapshot> pPublished(
|
|
|
|
|
pLoadedCandidate);
|
|
|
|
|
QString sNextWellInstanceId = sSavedResultWellInstanceId;
|
|
|
|
|
if(sNextWellInstanceId.isEmpty()) {
|
|
|
|
|
const QStringList& listDisplayIds =
|
|
|
|
|
pPublished->getDisplayWellInstanceIds();
|
|
|
|
|
sNextWellInstanceId = listDisplayIds.isEmpty()
|
|
|
|
|
? QString() : listDisplayIds.first();
|
|
|
|
|
}
|
|
|
|
|
m_pPebiResultSnapshot = pPublished;
|
|
|
|
|
m_sCurrentResultWellInstanceId = sNextWellInstanceId;
|
|
|
|
|
pLoadedCandidate.clear();
|
|
|
|
|
rebindPebiResultSnapshotToWells();
|
|
|
|
|
emit sigPebiResultSnapshotChanged();
|
|
|
|
|
}
|
|
|
|
|
m_bIsLoadData = m_pVtkUnstructuredGrid != NULL ||
|
|
|
|
|
!m_pPebiResultSnapshot.isNull();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch(const std::bad_alloc&) {
|
|
|
|
|
qWarning() << "Not enough memory to load numerical v3 result.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
// 将Json文件内容读取出来
|
|
|
|
|
QString sResultPath = sLoadAnalDir + "/Results/Numerical_Parameters.json";
|
|
|
|
|
if(!this->ReadProjectData(sResultPath)) {
|
|
|
|
|
@ -6063,6 +6711,7 @@ bool nmDataAnalyzeManager::loadNmResult(QString sLoadAnalDir)
|
|
|
|
|
m_bIsLoadData = true;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmDataAnalyzeManager::ensureDirectoryExists(const QString & dirPath)
|
|
|
|
|
|