You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWTAI-Platform/Src/nmNum/nmSubWxs/nmReservoirPropertiesDataSo...

123 lines
4.3 KiB
C++

#include "nmReservoirPropertiesDataSource.h"
#include "nmDataAnalyzeManager.h"
#include "nmDataWellBase.h"
#include "nmWxParameterProperty.h"
nmReservoirPropertiesSnapshot::nmReservoirPropertiesSnapshot()
: m_nSolverModelType(0)
{
}
nmIReservoirPropertiesDataSource::~nmIReservoirPropertiesDataSource()
{
}
nmAnalyzeManagerReservoirDataSource::nmAnalyzeManagerReservoirDataSource(
nmDataAnalyzeManager* pDataManager)
: m_pDataManager(pDataManager)
{
}
nmAnalyzeManagerReservoirDataSource::~nmAnalyzeManagerReservoirDataSource()
{
m_pDataManager = nullptr;
}
bool nmAnalyzeManagerReservoirDataSource::loadSnapshot(
nmReservoirPropertiesSnapshot& oSnapshot,
QString& sError) const
{
// 第一步:确认入口已经注入有效的数据管理器。
if (m_pDataManager == nullptr)
{
sError = QObject::tr("The current numerical well-test data is unavailable.");
return false;
}
// 第二步:复制求解器模型、储层和几何对象,确保界面编辑不会触碰实时数据。
oSnapshot.m_nSolverModelType =
static_cast<int>(m_pDataManager->getSolverModelType());
oSnapshot.m_oReservoir = m_pDataManager->getReservoirDataCopy();
oSnapshot.m_vecRegionMarks = m_pDataManager->getRegionMarkDataListCopy();
oSnapshot.m_vecFaults = m_pDataManager->getFaultDataListCopy();
oSnapshot.m_vecFractures = m_pDataManager->getFractureDataListCopy();
oSnapshot.m_vecRegions = m_pDataManager->getRegionDataListCopy();
oSnapshot.m_vecVerticalWells.clear();
oSnapshot.m_vecVerticalFracturedWells.clear();
oSnapshot.m_vecHorizontalFracturedWells.clear();
// 第三步:按最具体的井型复制数据,显式排除不受求解器支持的普通水平井。
QVector<nmDataWellBase*> vecWells = m_pDataManager->getWellDataList();
for (int nIndex = 0; nIndex < vecWells.size(); ++nIndex)
{
nmDataWellBase* pWell = vecWells[nIndex];
if (pWell == nullptr)
{
continue;
}
nmDataVerticalFracturedWell* pVerticalFractured =
dynamic_cast<nmDataVerticalFracturedWell*>(pWell);
nmDataHorizontalFracturedWell* pHorizontalFractured =
dynamic_cast<nmDataHorizontalFracturedWell*>(pWell);
nmDataVerticalWell* pVertical = dynamic_cast<nmDataVerticalWell*>(pWell);
if (pVerticalFractured != nullptr)
{
oSnapshot.m_vecVerticalFracturedWells.append(*pVerticalFractured);
}
else if (pHorizontalFractured != nullptr)
{
oSnapshot.m_vecHorizontalFracturedWells.append(*pHorizontalFractured);
}
else if (pVertical != nullptr)
{
oSnapshot.m_vecVerticalWells.append(*pVertical);
}
}
sError.clear();
return true;
}
bool nmAnalyzeManagerReservoirDataSource::commitSnapshot(
const nmReservoirPropertiesSnapshot& oSnapshot,
bool bGeometryChanged,
QString& sError)
{
// 第一步:提交前再次校验数据管理器生命周期。
if (m_pDataManager == nullptr)
{
sError = QObject::tr("The current numerical well-test data is unavailable.");
return false;
}
// 第二步:按对象类型批量替换现有数据,不改变对象地址和列表结构。
m_pDataManager->updateVerticalWells(oSnapshot.m_vecVerticalWells);
m_pDataManager->updateVerticalFracturedWells(oSnapshot.m_vecVerticalFracturedWells);
m_pDataManager->updateHorizontalFracturedWells(oSnapshot.m_vecHorizontalFracturedWells);
m_pDataManager->updateFaultData(oSnapshot.m_vecFaults);
m_pDataManager->updateFractureData(oSnapshot.m_vecFractures);
m_pDataManager->updateRegionData(oSnapshot.m_vecRegions);
m_pDataManager->updateRegionMarkData(oSnapshot.m_vecRegionMarks);
m_pDataManager->updateReservoirData(oSnapshot.m_oReservoir);
// 第三步:重建实时注册表映射,并在几何变化时统一通知画布和网格。
m_pDataManager->syncWellAttrs();
m_pDataManager->syncGeometryAttrs();
if (bGeometryChanged)
{
m_pDataManager->notifyDataChanged();
m_pDataManager->updateWellPlotByDataManager();
}
// 第四步:兼容仍在使用旧参数树的窗口,提交完成后只刷新一次表格入口。
nmWxParameterProperty::notifyUpdateTable();
sError.clear();
return true;
}